1.8.9 • Published 16 days ago

martok v1.8.9

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
16 days ago

Martok - Glory To Your Schema!

Build Status codecov

image

(Want to get paid to build cool stuff on Kotlin Multiplatform? We're Hiring!)

Martok is built for one thing and one thing only: converting Typescript schemas into kotlinx.serialization schemas. It's the brutal and chaotic rival to Dukat.

Why Kotlin? Why Typescript?

Here at Volley, we're big believers in Kotlin Multiplatform for Mobile -- but also recognize the (well-earned) dominance of Node on the backend. Martok creates an automated schema pipeline from the Typescript in your backend codebase to the Kotlin data layer in your Android & iOS apps.

Why Not QuickType?

QuickType has gotten quite old and difficult to develop. The PRs have mostly stagnated, we currently cannot find a way to successfully build the project, so we've moved on.

Can I see some example output?

Sure! Check out the comparison files we use for our automated tests HERE.

For a quick example:

export type Unions = {
  foo: { bar: string } | { baz: string };
};

Would translate to

@Serializable
data class Unions(
    val foo: Foo
) {
    @Serializable
    data class Foo(
        val bar: String? = null,
        val baz: String? = null
    )
}

Installation

npm install -g martok

Usage

# Martok works with single files, directories, and always infers the right thing to do.
martok ./someFile.d.ts -o Schema.kt --package example
martok ./someDirectory -o BigSchema.kt
martok ./someDirectory -o ./outputDirectory # produce lots of little files.

SUPPORTS

  • Multiple source files
  • Output to multiple files or a single mega-file
  • Interfaces + Inheritance
  • Type Aliases + Intersections + Unions
  • string, number, boolean, Arrays, any
  • Anonymous types
  • Cross-references to other types
  • kotlinx.serializable
  • kotlinx.datetime (When annotated with @Date or @DateTime. See HERE for examples)
  • Custom package name
  • Enums
  • optional fields
  • Typescript "Utility" types (e.g. Omit and Pick)
  • Configurable numeric precision via the @precision jsdoc tag

TODO

  • Fully discriminated/disagreeing unions
  • documentation
  • Intended for .d.ts files. Work on safer execution for .ts
1.8.9

16 days ago

1.8.8

16 days ago

1.8.7

2 months ago

1.8.6

2 months ago

1.8.5

2 months ago

1.8.2

2 months ago

1.8.1

2 months ago

1.8.3-1

2 months ago

1.8.3-2

2 months ago

1.8.4

2 months ago

1.8.0

1 year ago

1.7.0

1 year ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.6.1

1 year ago

1.4.3

1 year ago

1.6.0

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.4.9

1 year ago

1.4.8

1 year ago

1.4.10

1 year ago

1.4.7

1 year ago

1.4.13

1 year ago

1.4.12

1 year ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.11.0

2 years ago

0.10.1

2 years ago

0.11.1

2 years ago

0.10.2

2 years ago

0.11.2

2 years ago

0.11.3

2 years ago

0.9.12

2 years ago

0.9.13

2 years ago

0.9.9

2 years ago

0.9.10

2 years ago

0.9.11

2 years ago

0.10.0

2 years ago

0.9.8

2 years ago

0.9.7

2 years ago

0.9.6

2 years ago

0.9.5

2 years ago

0.9.4

2 years ago

0.9.3

2 years ago

0.9.0

2 years ago

0.7.2

2 years ago

0.8.0

2 years ago

0.7.1

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago