@dmdata/telegram-json-types
v1.2.3
Published
DMDATA.JP が提供する [JSON Schema](https://dmdata.jp/doc/reference/conversion/json/) の、TypeScript型定義を公開しています。
Readme
@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();使える型定義
- earthquake-information v1.1.0
- earthquake-explantion v1.0.0
- earthquake-counts v1.0.0
- earthquake-hypocenter-update v1.0.0
- earthquake-nankai v1.0.0
- eew-information v1.0.0
- forecast-2week-temperature v1.0.0
- forecast-prefecture v1.0.0
- forecast-season v1.0.0
- forecast-warning-possibility v1.0.0
- forecast-weathermap v1.0.0
- tsunami-information v1.1.0
- volcano-information v1.0.0
- weather-warning v1.1.0
- weather-warning-timeseries v1.0.0
- weather-commentary v1.0.0
- weather-information v1.0.0
- weather-impact-society v1.0.1
- weather-early v1.0.0
- weather-tornado v1.0.0
- weather-typhoon v1.0.0
- weather-landslide v1.0.0
- weather-river-flood v1.0.0
