JSPM

create-typescript-from-avro

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q59595F
  • License MIT

TypeSript code generator for Apache Avro types

Package Exports

  • create-typescript-from-avro

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (create-typescript-from-avro) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Avro Typescript

A simple JS library to convert Avro Schemas to TypeScript interfaces.

Install

npm install create-typescript-from-avro

The library can be run in node.js or the browser. It takes a Avro Schema as a JavaScript object (from JSON) and returns the TypeScript code as a string.

Usage

import * as fs from "fs";
import { avroToTypeScript, RecordType } from "create-typescript-from-avro";

const schemaText = fs.readFileSync(__dirname + "/example.avsc", "UTF8");
const schema: RecordType = JSON.parse(schemaText);
console.log(
  avroToTypeScript(schema, { convertEnumToType: false, removeNameSpace: true })
);

Features

Most Avro features are supported, including:

  • Enumerated Types
  • Maps
  • Named Records
  • Mandatory and optional fields
  • Unions
  • Primitives

Running the tests

npm test

Building the javascript files

npm build