Giter Site home page Giter Site logo

ptpt / dts-els Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 16 KB

A simple command line tool that generates TypeScript definition from ElasticSearch mappings

License: MIT License

JavaScript 45.10% TypeScript 52.49% Shell 2.41%
typescript elasticsearch

dts-els's Introduction

CircleCI

dts-els

A simple command line tool that generates TypeScript definition from ElasticSearch mappings.

Installation

npm install dts-els

Usage

usage: dts-els [--array ARRAY_PROPERTIES] [--maybe-array MAYBE_ARRAY_PROPERTIES] INTERFACE_NAME

ARRAY_PROPERTIES: Cast a property to an array of the derived type. Multiple properties are separated by comma.
MAYBE_ARRAY_PROPERTIES: Cast a property to the dervided type or an array of the type.
INTERFACE_NAME: Interface name of the definition

Example

Assume you have jq installed:

curl -s https://raw.githubusercontent.com/elastic/examples/master/Common%20Data%20Formats/twitter/twitter_template.json | jq .mappings.tweets.properties | npx dts-els --array=entities ITweet

will print out:

export interface ITweet {

    // @timestamp: date
    '@timestamp': number;

    // text: text
    'text': string;

    // user: object
    'user': {
        // description: text
        'description': string;
    };

    // coordinates: object
    'coordinates': {
        // coordinates: geo_point
        'coordinates': {
            // lon: float
            'lon': number;
            // lat: float
            'lat': number;
        };
    };

    // entities: object
    'entities': Array<{
        // hashtags: object
        'hashtags': {
            // text: text
            'text': string;
        };
    }>;

    // retweeted_status: object
    'retweeted_status': {
        // text: text
        'text': string;
    };
}

License

MIT. See License file.

dts-els's People

Contributors

ptpt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.