New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

martok

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

martok

Martok - Glory To Your Schema! ==

  • 1.8.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
increased by53.85%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 24 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc