1.1.14 • Published 3 months ago

@dmdata/telegram-json-types v1.1.14

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

@dmdata/telegram-json-types

概要

DMDATA.JP が提供する JSON Schema の、TypeScript型定義を公開しています。

使い方

インストール

$ npm i -D @dmdata/telegram-json-types

型の使用

import { EarthquakeInformation }  from '@dmdata/telegram-json-types';

const data = await fetch('https://data.api.dmdata.jp/v1/...')
      .then(res => res.json()) as Promise<EarthquakeInformation.Latest.Main>
      

JSON Schema による整合性チェック

Telegram JSON が、仕様通り整合するかチェックすることができます。

$ npm i @dmdata/telegram-json-types ajv

import { getJSchema } from '@dmdata/telegram-json-types';

// 実際の電文データ
const telegramData = {
  _schema: {
    type: 'earthquake-information',
    version: '1.1.0'
  }
};

async function check() {
  // Schema 名から JSON Schema 定義を読み込む 
  const jschema = await getJSchema(telegramData._schema.type, telegramData._schema.version);

  const validate = ajv.complite(jschema);

  console.log(validate(telegramData)); // false
}

check();

使える型定義

1.1.14

3 months ago

1.1.12

1 year ago

1.1.13

1 year ago

1.1.11

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.10

2 years ago

1.1.7

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9-jschema.0

2 years ago

1.0.8

2 years ago

1.0.9-jschema.1

2 years ago

1.0.7

2 years ago

1.1.5

2 years ago

1.0.6

2 years ago

1.1.4

2 years ago

1.0.5

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.9-jschema.2

2 years ago

1.0.9-jschema.3

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago