@dmdata/telegram-json-types 1.0.7 → 1.0.9-jschema.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +60 -0
- package/dist/build.d.ts +1 -0
- package/dist/build.js +63 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +6 -0
- package/dist/jschema/earthquake-counts_1.0.0.json +1 -0
- package/dist/jschema/earthquake-explanation_1.0.0.json +1 -0
- package/dist/jschema/earthquake-hypocenter-update_1.0.0.json +1 -0
- package/dist/jschema/earthquake-information_1.0.0.json +1 -0
- package/dist/jschema/earthquake-information_1.1.0.json +1 -0
- package/dist/jschema/earthquake-nankai_1.0.0.json +1 -0
- package/dist/jschema/eew-information_1.0.0.json +1 -0
- package/dist/jschema/tsunami-information_1.0.0.json +1 -0
- package/dist/jschema/volcano-information_1.0.0.json +1 -0
- package/dist/jschema/weather-typhoon_1.0.0.json +1 -0
- package/dist/jschema-load.d.ts +1 -0
- package/dist/jschema-load.js +44 -0
- package/index.d.ts +2 -1
- package/package.json +21 -11
- package/tsconfig.json +5 -0
- package/types/{schema/component → component}/coordinate.d.ts +15 -15
- package/types/{schema/component → component}/earthquake.d.ts +56 -56
- package/types/{schema/component → component}/unit-value.d.ts +13 -13
- package/types/index.d.ts +21 -2
- package/types/schema/earthquake-counts/1.0.0.d.ts +69 -0
- package/types/schema/earthquake-counts/index.d.ts +7 -0
- package/types/schema/earthquake-explanation/1.0.0.d.ts +57 -0
- package/types/schema/earthquake-explanation/index.d.ts +7 -0
- package/types/schema/earthquake-hypocenter-update/1.0.0.d.ts +53 -0
- package/types/schema/earthquake-hypocenter-update/index.d.ts +7 -0
- package/types/schema/earthquake-information/1.0.0.d.ts +165 -0
- package/types/schema/{earthquake-information.d.ts → earthquake-information/1.1.0.d.ts} +212 -177
- package/types/schema/earthquake-information/index.d.ts +9 -0
- package/types/schema/earthquake-nankai/1.0.0.d.ts +87 -0
- package/types/schema/earthquake-nankai/index.d.ts +7 -0
- package/types/schema/eew-information/1.0.0.d.ts +176 -0
- package/types/schema/eew-information/index.d.ts +7 -0
- package/types/schema/{tsunami-information.d.ts → tsunami-information/1.0.0.d.ts} +243 -229
- package/types/schema/tsunami-information/index.d.ts +7 -0
- package/types/schema/volcano-information/1.0.0.d.ts +449 -0
- package/types/schema/volcano-information/index.d.ts +7 -0
- package/types/schema/{weather-typhoon.d.ts → weather-typhoon/1.0.0.d.ts} +124 -117
- package/types/schema/weather-typhoon/index.d.ts +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Project DM-D.S.S (dmdata.jp)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# @dmdata/telegram-json-type
|
|
2
|
+
|
|
3
|
+
## 概要
|
|
4
|
+
DMDATA.JP が提供する [JSON Schema](https://dmdata.jp/doc/reference/conversion/json/) の、TypeScript型定義(作成中)を公開しています。
|
|
5
|
+
|
|
6
|
+
## 使い方
|
|
7
|
+
|
|
8
|
+
### インストール
|
|
9
|
+
`$ npm i -D @dmdata/telegram-json-type`
|
|
10
|
+
|
|
11
|
+
### 型の使用
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { EarthquakeInformation } from '@dmdata/telegram-json-types';
|
|
15
|
+
|
|
16
|
+
const data = await fetch('https://data.api.dmdata.jp/v1/...')
|
|
17
|
+
.then(res => res.json()) as Promise<EarthquakeInformation.Latest.Main>
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## JSON Schema による整合性チェック
|
|
22
|
+
|
|
23
|
+
Telegram JSON が、仕様通り整合するかチェックすることができます。
|
|
24
|
+
|
|
25
|
+
`$ npm i @dmdata/telegram-json-type ajv`
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { getJSchema } from '@dmdata/telegram-json-types';
|
|
29
|
+
|
|
30
|
+
// 実際の電文データ
|
|
31
|
+
const telegramData = {
|
|
32
|
+
_schema: {
|
|
33
|
+
type: 'earthquake-information',
|
|
34
|
+
version: '1.1.0'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
async function check() {
|
|
39
|
+
// Schema 名から JSON Schema 定義を読み込む
|
|
40
|
+
const jschema = await getJSchema(telegramData._schema.type, telegramData._schema.version);
|
|
41
|
+
|
|
42
|
+
const validate = ajv.complite(jschema);
|
|
43
|
+
|
|
44
|
+
console.log(validate(telegramData)); // false
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
check();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 使える型定義
|
|
51
|
+
|
|
52
|
+
* [EarthquakeInformation](https://dmdata.jp/doc/reference/conversion/json/schema/earthquake-information)
|
|
53
|
+
* [EarthquakeExplanation](https://dmdata.jp/doc/reference/conversion/json/schema/earthquake-explantion)
|
|
54
|
+
* [EarthquakeCounts](https://dmdata.jp/doc/reference/conversion/json/schema/earthquake-counts)
|
|
55
|
+
* [EarthquakeHypocenterUpdate](https://dmdata.jp/doc/reference/conversion/json/schema/earthquake-hypocenter-update)
|
|
56
|
+
* [EarthquakeNankai](https://dmdata.jp/doc/reference/conversion/json/schema/earthquake-nankai)
|
|
57
|
+
* [EewInformation](https://dmdata.jp/doc/reference/conversion/json/schema/eew-information)
|
|
58
|
+
* [TsunamiInformation](https://dmdata.jp/doc/reference/conversion/json/schema/tsunami-information)
|
|
59
|
+
* [VolcanoInformation](https://dmdata.jp/doc/reference/conversion/json/schema/volcano-information)
|
|
60
|
+
* [WeatherTyphoon](https://dmdata.jp/doc/reference/conversion/json/schema/weather-typhoon)
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/build.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const path_1 = require("path");
|
|
23
|
+
const promises_1 = require("fs/promises");
|
|
24
|
+
const TJS = __importStar(require("typescript-json-schema"));
|
|
25
|
+
const config_1 = require("./config");
|
|
26
|
+
const settings = {
|
|
27
|
+
required: true,
|
|
28
|
+
};
|
|
29
|
+
const compilerOptions = {
|
|
30
|
+
strictNullChecks: true,
|
|
31
|
+
};
|
|
32
|
+
(0, promises_1.readdir)(config_1.basePath, { withFileTypes: true })
|
|
33
|
+
.then(dirs => dirs.filter(dir => dir.isDirectory())
|
|
34
|
+
.map(async (dir) => [dir.name, await (0, promises_1.readdir)((0, path_1.resolve)(config_1.basePath, dir.name))]))
|
|
35
|
+
.then(dirs => Promise.all(dirs))
|
|
36
|
+
.then(dirs => dirs
|
|
37
|
+
.flatMap(([dir, files]) => files.map(file => (0, path_1.resolve)(config_1.basePath, dir, file)))
|
|
38
|
+
.filter(file => /(\d+\.\d+\.\d+)(\.d)?\.ts$/.test(file)))
|
|
39
|
+
.then(files => programTypescript(files));
|
|
40
|
+
async function programTypescript(files) {
|
|
41
|
+
const tsTypeFiles = files.filter(file => /\.ts$/.test(file));
|
|
42
|
+
const objectMaps = tsTypeFiles.map(file => tsTypeFileName2TypeSymbolName(file));
|
|
43
|
+
await (0, promises_1.rm)(config_1.distDir, { recursive: true, force: true });
|
|
44
|
+
await (0, promises_1.mkdir)(config_1.distDir, { recursive: true });
|
|
45
|
+
for (let i = 0; i < objectMaps.length; i++) {
|
|
46
|
+
const { schemaName, schemaVersion, typeName, file } = objectMaps[i];
|
|
47
|
+
const program = TJS.getProgramFromFiles([file], compilerOptions);
|
|
48
|
+
const schema = TJS.generateSchema(program, typeName, settings);
|
|
49
|
+
console.log(`Build ok: ${schemaName}:${schemaVersion} => ${typeName}`);
|
|
50
|
+
await (0, promises_1.writeFile)((0, path_1.resolve)(config_1.distDir, `${schemaName}_${schemaVersion}.json`), JSON.stringify(schema));
|
|
51
|
+
}
|
|
52
|
+
console.log('Build complete');
|
|
53
|
+
}
|
|
54
|
+
function tsTypeFileName2TypeSymbolName(file) {
|
|
55
|
+
const [, schemaName = null, schemaVersion = null] = file.match(/([\w-]+?)[\\/](\d+\.\d+\.\d+)(\.d)?\.ts$/) ?? [];
|
|
56
|
+
const nameScope = schemaName?.replace(/-(\w)|(^\w)/g, (match, p1 = '', p2 = '') => `${p1}${p2}`.toUpperCase());
|
|
57
|
+
return {
|
|
58
|
+
schemaName,
|
|
59
|
+
schemaVersion,
|
|
60
|
+
typeName: nameScope + '.Main',
|
|
61
|
+
file
|
|
62
|
+
};
|
|
63
|
+
}
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.distDir = exports.basePath = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
exports.basePath = (0, path_1.resolve)(__dirname, '../types/schema/');
|
|
6
|
+
exports.distDir = (0, path_1.resolve)(__dirname, '../dist/jschema/');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"anyOf":[{"$ref":"#/definitions/EarthquakeHypocenterUpdate.Public"},{"$ref":"#/definitions/EarthquakeHypocenterUpdate.Cancel"}],"definitions":{"EarthquakeHypocenterUpdate.Public":{"type":"object","properties":{"_schema":{"$ref":"#/definitions/EarthquakeHypocenterUpdate.Schema"},"type":{"type":"string","enum":["顕著な地震の震源要素更新のお知らせ"]},"title":{"type":"string","enum":["顕著な地震の震源要素更新のお知らせ"]},"infoType":{"enum":["発表","訂正"],"type":"string"},"eventId":{"type":"string"},"serialNo":{"type":"null"},"infoKind":{"type":"string","enum":["震源要素更新のお知らせ"]},"body":{"$ref":"#/definitions/EarthquakeHypocenterUpdate.PublicBody"},"_originalId":{"type":"string"},"status":{"enum":["訓練","試験","通常"],"type":"string"},"editorialOffice":{"type":"string"},"publishingOffice":{"type":"array","items":{"type":"string"}},"pressDateTime":{"type":"string"},"reportDateTime":{"type":"string"},"targetDateTime":{"type":"string"},"infoKindVersion":{"type":"string"},"headline":{"type":["null","string"]}},"required":["_originalId","_schema","body","editorialOffice","eventId","headline","infoKind","infoKindVersion","infoType","pressDateTime","publishingOffice","reportDateTime","serialNo","status","targetDateTime","title","type"]},"EarthquakeHypocenterUpdate.Schema":{"type":"object","properties":{"type":{"type":"string","enum":["earthquake-hypocenter-update"]},"version":{"type":"string","enum":["1.0.0"]}},"required":["type","version"]},"EarthquakeHypocenterUpdate.PublicBody":{"type":"object","properties":{"earthquake":{"$ref":"#/definitions/Earthquake"},"text":{"type":"string"},"comments":{"$ref":"#/definitions/EarthquakeHypocenterUpdate.Comments"}},"required":["earthquake","text"]},"Earthquake":{"type":"object","properties":{"originTime":{"type":"string"},"arrivalTime":{"type":"string"},"hypocenter":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"coordinate":{"anyOf":[{"type":"object","properties":{"condition":{"type":"string","enum":["不明"]}},"required":["condition"]},{"type":"object","properties":{"latitude":{"type":"object","properties":{"text":{"type":"string"},"value":{"type":"string"}},"required":["text","value"]},"longitude":{"type":"object","properties":{"text":{"type":"string"},"value":{"type":"string"}},"required":["text","value"]},"height":{"type":"object","properties":{"type":{"type":"string","enum":["高さ"]},"unit":{"type":"string","enum":["m"]},"value":{"type":["null","string"]}},"required":["type","unit","value"]},"geodeticSystem":{"enum":["日本測地系"],"type":"string"}},"required":["latitude","longitude"]}]},"depth":{"anyOf":[{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["深さ"]},"unit":{"type":"string","enum":["km"]}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"null"},"condition":{"type":"string","enum":["不明"]}},"required":["condition","value"]}]},{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["深さ"]},"unit":{"type":"string","enum":["km"]}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"string","enum":["0"]},"condition":{"type":"string","enum":["ごく浅い"]}},"required":["condition","value"]}]},{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["深さ"]},"unit":{"type":"string","enum":["km"]}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"string","enum":["700"]},"condition":{"type":"string","enum":["700km以上"]}},"required":["condition","value"]}]},{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["深さ"]},"unit":{"type":"string","enum":["km"]}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"string"}},"required":["value"]}]}]},"detailed":{"type":"object","properties":{"code":{"type":"string"},"name":{"type":"string"}},"required":["code","name"]},"auxiliary":{"type":"object","properties":{"text":{"type":"string"},"code":{"type":"string"},"name":{"type":"string"},"direction":{"type":"string"},"distance":{"$ref":"#/definitions/Omit<UnitValueNotNull<never,\"km\",never>,\"type\"|\"condition\">"}},"required":["code","direction","distance","name","text"]},"source":{"enum":["PTWC","USGS","WCATWC"],"type":"string"}},"required":["code","coordinate","depth","name"]},"magnitude":{"anyOf":[{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["マグニチュード"]},"unit":{"enum":["M","Mj"],"type":"string"}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"null"},"condition":{"enum":["M不明","M8を超える巨大地震"],"type":"string"}},"required":["condition","value"]}]},{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["マグニチュード"]},"unit":{"enum":["M","Mj"],"type":"string"}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"string"}},"required":["value"]}]}]}},"required":["arrivalTime","hypocenter","magnitude","originTime"]},"Omit<UnitValueNotNull<never,\"km\",never>,\"type\"|\"condition\">":{"type":"object","properties":{"unit":{"type":"string","enum":["km"]},"value":{"type":"string"}},"required":["unit","value"]},"EarthquakeHypocenterUpdate.Comments":{"type":"object","properties":{"free":{"type":"string"}},"required":["free"]},"EarthquakeHypocenterUpdate.Cancel":{"type":"object","properties":{"_schema":{"$ref":"#/definitions/EarthquakeHypocenterUpdate.Schema"},"type":{"type":"string","enum":["顕著な地震の震源要素更新のお知らせ"]},"title":{"type":"string","enum":["顕著な地震の震源要素更新のお知らせ"]},"infoType":{"type":"string","enum":["取消"]},"eventId":{"type":"string"},"serialNo":{"type":"null"},"infoKind":{"type":"string","enum":["震源要素更新のお知らせ"]},"body":{"$ref":"#/definitions/EarthquakeHypocenterUpdate.CancelBody"},"_originalId":{"type":"string"},"status":{"enum":["訓練","試験","通常"],"type":"string"},"editorialOffice":{"type":"string"},"publishingOffice":{"type":"array","items":{"type":"string"}},"pressDateTime":{"type":"string"},"reportDateTime":{"type":"string"},"targetDateTime":{"type":"string"},"infoKindVersion":{"type":"string"},"headline":{"type":["null","string"]}},"required":["_originalId","_schema","body","editorialOffice","eventId","headline","infoKind","infoKindVersion","infoType","pressDateTime","publishingOffice","reportDateTime","serialNo","status","targetDateTime","title","type"]},"EarthquakeHypocenterUpdate.CancelBody":{"type":"object","properties":{"text":{"type":"string"}},"required":["text"]}},"$schema":"http://json-schema.org/draft-07/schema#"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"anyOf":[{"$ref":"#/definitions/EarthquakeInformation.PublicVXSE51"},{"$ref":"#/definitions/EarthquakeInformation.PublicVXSE52"},{"$ref":"#/definitions/EarthquakeInformation.PublicVXSE53"},{"$ref":"#/definitions/EarthquakeInformation.PublicVXSE62"},{"$ref":"#/definitions/EarthquakeInformation.PublicVZSE40"},{"$ref":"#/definitions/EarthquakeInformation.Cancel"}],"definitions":{"EarthquakeInformation.PublicVXSE51":{"type":"object","properties":{"_schema":{"$ref":"#/definitions/EarthquakeInformation.Schema"},"type":{"type":"string","enum":["震度速報"]},"title":{"type":"string","enum":["震度速報"]},"infoType":{"enum":["発表","訂正"],"type":"string"},"eventId":{"type":"string"},"serialNo":{"type":"null"},"infoKind":{"type":"string","enum":["震度速報"]},"body":{"$ref":"#/definitions/EarthquakeInformation.PublicBodyVXSE51"},"_originalId":{"type":"string"},"status":{"enum":["訓練","試験","通常"],"type":"string"},"editorialOffice":{"type":"string"},"publishingOffice":{"type":"array","items":{"type":"string"}},"pressDateTime":{"type":"string"},"reportDateTime":{"type":"string"},"targetDateTime":{"type":"string"},"infoKindVersion":{"type":"string"},"headline":{"type":["null","string"]}},"required":["_originalId","_schema","body","editorialOffice","eventId","headline","infoKind","infoKindVersion","infoType","pressDateTime","publishingOffice","reportDateTime","serialNo","status","targetDateTime","title","type"]},"EarthquakeInformation.Schema":{"type":"object","properties":{"type":{"type":"string","enum":["earthquake-information"]},"version":{"type":"string","enum":["1.1.0"]}},"required":["type","version"]},"EarthquakeInformation.PublicBodyVXSE51":{"type":"object","properties":{"intensity":{"type":"object","properties":{"maxInt":{"$ref":"#/definitions/EarthquakeInformation.IntensityClass"},"prefectures":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"maxInt":{"$ref":"#/definitions/EarthquakeInformation.IntensityClass"}},"required":["code","maxInt","name"]}},"regions":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"maxInt":{"$ref":"#/definitions/EarthquakeInformation.IntensityClass"}},"required":["code","maxInt","name"]}}},"required":["maxInt","prefectures","regions"]},"text":{"type":"string"},"comments":{"$ref":"#/definitions/Omit<EarthquakeInformation.Comment,\"var\">"}},"required":["comments","intensity"]},"EarthquakeInformation.IntensityClass":{"enum":["1","2","3","4","5+","5-","6+","6-","7"],"type":"string"},"Omit<EarthquakeInformation.Comment,\"var\">":{"type":"object","properties":{"free":{"type":"string"},"forecast":{"type":"object","properties":{"text":{"type":"string"},"codes":{"type":"array","items":{"type":"string"}}},"required":["codes","text"]}}},"EarthquakeInformation.PublicVXSE52":{"type":"object","properties":{"_schema":{"$ref":"#/definitions/EarthquakeInformation.Schema"},"type":{"type":"string","enum":["震源に関する情報"]},"title":{"type":"string","enum":["震源に関する情報"]},"infoType":{"enum":["発表","訂正"],"type":"string"},"eventId":{"type":"string"},"serialNo":{"type":"null"},"infoKind":{"type":"string","enum":["震源速報"]},"body":{"$ref":"#/definitions/EarthquakeInformation.PublicBodyVXSE52"},"_originalId":{"type":"string"},"status":{"enum":["訓練","試験","通常"],"type":"string"},"editorialOffice":{"type":"string"},"publishingOffice":{"type":"array","items":{"type":"string"}},"pressDateTime":{"type":"string"},"reportDateTime":{"type":"string"},"targetDateTime":{"type":"string"},"infoKindVersion":{"type":"string"},"headline":{"type":["null","string"]}},"required":["_originalId","_schema","body","editorialOffice","eventId","headline","infoKind","infoKindVersion","infoType","pressDateTime","publishingOffice","reportDateTime","serialNo","status","targetDateTime","title","type"]},"EarthquakeInformation.PublicBodyVXSE52":{"type":"object","properties":{"earthquake":{"$ref":"#/definitions/Earthquake"},"text":{"type":"string"},"comments":{"$ref":"#/definitions/Omit<EarthquakeInformation.Comment,\"var\">"}},"required":["comments","earthquake"]},"Earthquake":{"type":"object","properties":{"originTime":{"type":"string"},"arrivalTime":{"type":"string"},"hypocenter":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"coordinate":{"anyOf":[{"type":"object","properties":{"condition":{"type":"string","enum":["不明"]}},"required":["condition"]},{"type":"object","properties":{"latitude":{"type":"object","properties":{"text":{"type":"string"},"value":{"type":"string"}},"required":["text","value"]},"longitude":{"type":"object","properties":{"text":{"type":"string"},"value":{"type":"string"}},"required":["text","value"]},"height":{"type":"object","properties":{"type":{"type":"string","enum":["高さ"]},"unit":{"type":"string","enum":["m"]},"value":{"type":["null","string"]}},"required":["type","unit","value"]},"geodeticSystem":{"enum":["日本測地系"],"type":"string"}},"required":["latitude","longitude"]}]},"depth":{"anyOf":[{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["深さ"]},"unit":{"type":"string","enum":["km"]}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"null"},"condition":{"type":"string","enum":["不明"]}},"required":["condition","value"]}]},{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["深さ"]},"unit":{"type":"string","enum":["km"]}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"string","enum":["0"]},"condition":{"type":"string","enum":["ごく浅い"]}},"required":["condition","value"]}]},{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["深さ"]},"unit":{"type":"string","enum":["km"]}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"string","enum":["700"]},"condition":{"type":"string","enum":["700km以上"]}},"required":["condition","value"]}]},{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["深さ"]},"unit":{"type":"string","enum":["km"]}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"string"}},"required":["value"]}]}]},"detailed":{"type":"object","properties":{"code":{"type":"string"},"name":{"type":"string"}},"required":["code","name"]},"auxiliary":{"type":"object","properties":{"text":{"type":"string"},"code":{"type":"string"},"name":{"type":"string"},"direction":{"type":"string"},"distance":{"$ref":"#/definitions/Omit<UnitValueNotNull<never,\"km\",never>,\"type\"|\"condition\">"}},"required":["code","direction","distance","name","text"]},"source":{"enum":["PTWC","USGS","WCATWC"],"type":"string"}},"required":["code","coordinate","depth","name"]},"magnitude":{"anyOf":[{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["マグニチュード"]},"unit":{"enum":["M","Mj"],"type":"string"}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"null"},"condition":{"enum":["M不明","M8を超える巨大地震"],"type":"string"}},"required":["condition","value"]}]},{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["マグニチュード"]},"unit":{"enum":["M","Mj"],"type":"string"}},"required":["type","unit"]},{"type":"object","properties":{"value":{"type":"string"}},"required":["value"]}]}]}},"required":["arrivalTime","hypocenter","magnitude","originTime"]},"Omit<UnitValueNotNull<never,\"km\",never>,\"type\"|\"condition\">":{"type":"object","properties":{"unit":{"type":"string","enum":["km"]},"value":{"type":"string"}},"required":["unit","value"]},"EarthquakeInformation.PublicVXSE53":{"type":"object","properties":{"_schema":{"$ref":"#/definitions/EarthquakeInformation.Schema"},"type":{"type":"string","enum":["震源・震度に関する情報"]},"title":{"enum":["遠地地震に関する情報","震源・震度情報"],"type":"string"},"infoType":{"enum":["発表","訂正"],"type":"string"},"eventId":{"type":"string"},"serialNo":{"type":"string"},"infoKind":{"type":"string","enum":["地震情報"]},"body":{"$ref":"#/definitions/EarthquakeInformation.PublicBodyVXSE53"},"_originalId":{"type":"string"},"status":{"enum":["訓練","試験","通常"],"type":"string"},"editorialOffice":{"type":"string"},"publishingOffice":{"type":"array","items":{"type":"string"}},"pressDateTime":{"type":"string"},"reportDateTime":{"type":"string"},"targetDateTime":{"type":"string"},"infoKindVersion":{"type":"string"},"headline":{"type":["null","string"]}},"required":["_originalId","_schema","body","editorialOffice","eventId","headline","infoKind","infoKindVersion","infoType","pressDateTime","publishingOffice","reportDateTime","serialNo","status","targetDateTime","title","type"]},"EarthquakeInformation.PublicBodyVXSE53":{"type":"object","properties":{"earthquake":{"$ref":"#/definitions/Earthquake"},"intensity":{"type":"object","properties":{"maxInt":{"$ref":"#/definitions/EarthquakeInformation.IntensityClass"},"prefectures":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"maxInt":{"enum":["1","2","3","4","5+","5-","6+","6-","7"],"type":"string"},"revise":{"enum":["上方修正","追加"],"type":"string"}},"required":["code","name"]}},"regions":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"maxInt":{"enum":["1","2","3","4","5+","5-","6+","6-","7"],"type":"string"},"revise":{"enum":["上方修正","追加"],"type":"string"}},"required":["code","name"]}},"cities":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"maxInt":{"enum":["1","2","3","4","5+","5-","6+","6-","7"],"type":"string"},"revise":{"enum":["上方修正","追加"],"type":"string"},"condition":{"enum":["震度5弱以上未入電"],"type":"string"}},"required":["code","name"]}},"stations":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"int":{"enum":["!5-","1","2","3","4","5+","5-","6+","6-","7"],"type":"string"},"revise":{"enum":["上方修正","追加"],"type":"string"},"condition":{"enum":["震度5弱以上未入電"],"type":"string"}},"required":["code","int","name"]}}},"required":["cities","maxInt","prefectures","regions","stations"]},"text":{"type":"string"},"comments":{"type":"object","properties":{"free":{"type":"string"},"forecast":{"type":"object","properties":{"text":{"type":"string"},"codes":{"type":"array","items":{"type":"string"}}},"required":["codes","text"]},"var":{"type":"object","properties":{"text":{"type":"string"},"codes":{"type":"array","items":{"type":"string"}}},"required":["codes","text"]}}}},"required":["comments","earthquake"]},"EarthquakeInformation.PublicVXSE62":{"type":"object","properties":{"_schema":{"$ref":"#/definitions/EarthquakeInformation.Schema"},"type":{"type":"string","enum":["長周期地震動に関する観測情報"]},"title":{"type":"string","enum":["長周期地震動に関する観測情報"]},"infoType":{"enum":["発表","訂正"],"type":"string"},"eventId":{"type":"string"},"serialNo":{"type":"string"},"infoKind":{"type":"string","enum":["長周期地震動に関する観測情報"]},"body":{"$ref":"#/definitions/EarthquakeInformation.PublicBodyVXSE62"},"_originalId":{"type":"string"},"status":{"enum":["訓練","試験","通常"],"type":"string"},"editorialOffice":{"type":"string"},"publishingOffice":{"type":"array","items":{"type":"string"}},"pressDateTime":{"type":"string"},"reportDateTime":{"type":"string"},"targetDateTime":{"type":"string"},"infoKindVersion":{"type":"string"},"headline":{"type":["null","string"]}},"required":["_originalId","_schema","body","editorialOffice","eventId","headline","infoKind","infoKindVersion","infoType","pressDateTime","publishingOffice","reportDateTime","serialNo","status","targetDateTime","title","type"]},"EarthquakeInformation.PublicBodyVXSE62":{"type":"object","properties":{"earthquake":{"$ref":"#/definitions/Earthquake"},"intensity":{"type":"object","properties":{"maxInt":{"$ref":"#/definitions/EarthquakeInformation.IntensityClass"},"maxLpgmInt":{"$ref":"#/definitions/EarthquakeInformation.LpgmIntensityClass"},"lpgmCategory":{"$ref":"#/definitions/EarthquakeInformation.LpgmCategory"},"prefectures":{"type":"array","items":{"allOf":[{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"maxInt":{"enum":["1","2","3","4","5+","5-","6+","6-","7"],"type":"string"},"revise":{"enum":["上方修正","追加"],"type":"string"}},"required":["code","name"]},{"type":"object","properties":{"maxLpgmInt":{"$ref":"#/definitions/EarthquakeInformation.LpgmIntensityClass"}},"required":["maxLpgmInt"]}]}},"regions":{"type":"array","items":{"allOf":[{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"maxInt":{"enum":["1","2","3","4","5+","5-","6+","6-","7"],"type":"string"},"revise":{"enum":["上方修正","追加"],"type":"string"}},"required":["code","name"]},{"type":"object","properties":{"maxLpgmInt":{"$ref":"#/definitions/EarthquakeInformation.LpgmIntensityClass"}},"required":["maxLpgmInt"]}]}},"stations":{"type":"array","items":{"allOf":[{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"int":{"enum":["!5-","1","2","3","4","5+","5-","6+","6-","7"],"type":"string"},"revise":{"enum":["上方修正","追加"],"type":"string"},"condition":{"enum":["震度5弱以上未入電"],"type":"string"}},"required":["code","int","name"]},{"type":"object","properties":{"lpgmInt":{"$ref":"#/definitions/EarthquakeInformation.LpgmIntensityClass"},"sva":{"type":"object","properties":{"unit":{"type":"string","enum":["cm/s"]},"value":{"type":"string"}},"required":["unit","value"]},"prePeriods":{"type":"array","items":{"type":"object","properties":{"periodicBand":{"type":"object","properties":{"unit":{"type":"string","enum":["秒台"]},"value":{"type":"string"}},"required":["unit","value"]},"lpgmInt":{"$ref":"#/definitions/EarthquakeInformation.LpgmIntensityClass"},"sva":{"type":"object","properties":{"unit":{"type":"string","enum":["cm/s"]},"value":{"type":"string"}},"required":["unit","value"]}},"required":["lpgmInt","periodicBand","sva"]}}},"required":["lpgmInt","prePeriods","sva"]}]}}},"required":["lpgmCategory","maxInt","maxLpgmInt","prefectures","regions","stations"]},"text":{"type":"string"},"comments":{"type":"object","properties":{"free":{"type":"string"},"forecast":{"type":"object","properties":{"text":{"type":"string"},"codes":{"type":"array","items":{"type":"string"}}},"required":["codes","text"]},"var":{"type":"object","properties":{"text":{"type":"string"},"codes":{"type":"array","items":{"type":"string"}}},"required":["codes","text"]}}}},"required":["comments","earthquake"]},"EarthquakeInformation.LpgmIntensityClass":{"enum":["0","1","2","3","4"],"type":"string"},"EarthquakeInformation.LpgmCategory":{"enum":["1","2","3","4"],"type":"string"},"EarthquakeInformation.PublicVZSE40":{"type":"object","properties":{"_schema":{"$ref":"#/definitions/EarthquakeInformation.Schema"},"type":{"type":"string","enum":["地震・津波に関するお知らせ"]},"title":{"type":"string","enum":["地震・津波に関するお知らせ"]},"infoType":{"enum":["発表","訂正"],"type":"string"},"eventId":{"type":"string"},"serialNo":{"type":"null"},"infoKind":{"type":"string","enum":["地震・津波に関するお知らせ"]},"body":{"$ref":"#/definitions/EarthquakeInformation.PublicBodyVXZSE40"},"_originalId":{"type":"string"},"status":{"enum":["訓練","試験","通常"],"type":"string"},"editorialOffice":{"type":"string"},"publishingOffice":{"type":"array","items":{"type":"string"}},"pressDateTime":{"type":"string"},"reportDateTime":{"type":"string"},"targetDateTime":{"type":"string"},"infoKindVersion":{"type":"string"},"headline":{"type":["null","string"]}},"required":["_originalId","_schema","body","editorialOffice","eventId","headline","infoKind","infoKindVersion","infoType","pressDateTime","publishingOffice","reportDateTime","serialNo","status","targetDateTime","title","type"]},"EarthquakeInformation.PublicBodyVXZSE40":{"type":"object","properties":{"text":{"type":"string"}},"required":["text"]},"EarthquakeInformation.Cancel":{"type":"object","properties":{"_schema":{"$ref":"#/definitions/EarthquakeInformation.Schema"},"type":{"enum":["地震・津波に関するお知らせ","長周期地震動に関する観測情報","震度速報","震源に関する情報","震源・震度に関する情報"],"type":"string"},"title":{"enum":["地震・津波に関するお知らせ","遠地地震に関する情報","長周期地震動に関する観測情報","震度速報","震源に関する情報","震源・震度情報"],"type":"string"},"infoType":{"type":"string","enum":["取消"]},"eventId":{"type":"string"},"infoKind":{"enum":["地震・津波に関するお知らせ","地震情報","長周期地震動に関する観測情報","震度速報","震源速報"],"type":"string"},"body":{"$ref":"#/definitions/EarthquakeInformation.CancelBody"},"_originalId":{"type":"string"},"status":{"enum":["訓練","試験","通常"],"type":"string"},"editorialOffice":{"type":"string"},"publishingOffice":{"type":"array","items":{"type":"string"}},"pressDateTime":{"type":"string"},"reportDateTime":{"type":"string"},"targetDateTime":{"type":"string"},"serialNo":{"type":["null","string"]},"infoKindVersion":{"type":"string"},"headline":{"type":["null","string"]}},"required":["_originalId","_schema","body","editorialOffice","eventId","headline","infoKind","infoKindVersion","infoType","pressDateTime","publishingOffice","reportDateTime","serialNo","status","targetDateTime","title","type"]},"EarthquakeInformation.CancelBody":{"type":"object","properties":{"text":{"type":"string"}},"required":["text"]}},"$schema":"http://json-schema.org/draft-07/schema#"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getJSchema(name: string, version?: string): Promise<any>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.getJSchema = void 0;
|
|
23
|
+
const fs_1 = require("fs");
|
|
24
|
+
const path_1 = require("path");
|
|
25
|
+
const config_1 = require("./config");
|
|
26
|
+
const schemas = new Map();
|
|
27
|
+
const jschemaList = (0, fs_1.readdirSync)(config_1.distDir)
|
|
28
|
+
.filter(file => /\.json$/.test(file))
|
|
29
|
+
.sort();
|
|
30
|
+
jschemaList.forEach(file => {
|
|
31
|
+
const [, schemaName, schemaVersion] = file.match(/^([\w-]+)_(\w+\.\w+\.\w+)\.json$/) ?? [];
|
|
32
|
+
const schemaVersions = schemas.get(schemaName) ?? schemas.set(schemaName, new Map()).get(schemaName);
|
|
33
|
+
const jschemaFile = (0, path_1.resolve)(config_1.distDir, file);
|
|
34
|
+
schemaVersions?.set(schemaVersion, jschemaFile);
|
|
35
|
+
schemaVersions?.set('latest', jschemaFile);
|
|
36
|
+
});
|
|
37
|
+
async function getJSchema(name, version = 'latest') {
|
|
38
|
+
const filePath = schemas.get(name)?.get(version);
|
|
39
|
+
if (!filePath) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return await Promise.resolve().then(() => __importStar(require(filePath)));
|
|
43
|
+
}
|
|
44
|
+
exports.getJSchema = getJSchema;
|
package/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './types';
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './dist/jschema-load'
|
package/package.json
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dmdata/telegram-json-types",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"scripts": {
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@dmdata/telegram-json-types",
|
|
3
|
+
"version": "1.0.9-jschema.2",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build:jschema": "npx tsc --project tsconfig.jschema.json",
|
|
6
|
+
"build:dist-jschema": "node ./dist/build.js",
|
|
7
|
+
"prepublishOnly": "npm run build:jschema && npm run build:dist-jschema",
|
|
8
|
+
"publish:npm": "npm version patch && npm publish --access=public"
|
|
9
|
+
},
|
|
10
|
+
"types": "index.d.ts",
|
|
11
|
+
"main": "./dist/jschema-load.js",
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^14.18.9",
|
|
17
|
+
"typescript": "^4.5.5",
|
|
18
|
+
"ts-node": "^10.4.0",
|
|
19
|
+
"typescript-json-schema": "^0.53.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { UnitValue } from './unit-value';
|
|
2
|
-
|
|
3
|
-
export type Coordinate<Geo = never> = {
|
|
4
|
-
latitude: { text: string, value: string };
|
|
5
|
-
longitude: { text: string, value: string };
|
|
6
|
-
height?: UnitValue<'
|
|
7
|
-
condition:
|
|
8
|
-
geodeticSystem: Geo;
|
|
9
|
-
} | {
|
|
10
|
-
latitude:
|
|
11
|
-
longitude:
|
|
12
|
-
height:
|
|
13
|
-
geodeticSystem: never;
|
|
14
|
-
condition: '不明';
|
|
15
|
-
}
|
|
1
|
+
import { UnitValue } from './unit-value';
|
|
2
|
+
|
|
3
|
+
export type Coordinate<Geo = never> = {
|
|
4
|
+
latitude: { text: string, value: string };
|
|
5
|
+
longitude: { text: string, value: string };
|
|
6
|
+
height?: UnitValue<'高さ', 'm'>;
|
|
7
|
+
condition: never;
|
|
8
|
+
geodeticSystem: Geo;
|
|
9
|
+
} | {
|
|
10
|
+
latitude: never;
|
|
11
|
+
longitude: never;
|
|
12
|
+
height: never;
|
|
13
|
+
geodeticSystem: never;
|
|
14
|
+
condition: '不明';
|
|
15
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { Coordinate } from './coordinate';
|
|
2
|
-
import { UnitValueNotNull } from './unit-value';
|
|
3
|
-
|
|
4
|
-
type Depth = {
|
|
5
|
-
type: '深さ';
|
|
6
|
-
unit: 'km';
|
|
7
|
-
} & ({
|
|
8
|
-
value: null;
|
|
9
|
-
condition: '不明';
|
|
10
|
-
} | {
|
|
11
|
-
value: '0';
|
|
12
|
-
condition: 'ごく浅い';
|
|
13
|
-
} | {
|
|
14
|
-
value: '700';
|
|
15
|
-
condition: '700km以上';
|
|
16
|
-
} | {
|
|
17
|
-
value: string;
|
|
18
|
-
condition:
|
|
19
|
-
});
|
|
20
|
-
type Magnitude = {
|
|
21
|
-
type: 'マグニチュード';
|
|
22
|
-
unit: 'Mj' | 'M';
|
|
23
|
-
} & ({
|
|
24
|
-
value: null;
|
|
25
|
-
condition: 'M不明' | 'M8を超える巨大地震';
|
|
26
|
-
} | {
|
|
27
|
-
value: string;
|
|
28
|
-
condition:
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export interface Earthquake {
|
|
32
|
-
originTime: string;
|
|
33
|
-
arrivalTime: string;
|
|
34
|
-
hypocenter: {
|
|
35
|
-
name: string;
|
|
36
|
-
code: string;
|
|
37
|
-
coordinate: Coordinate<'日本測地系' | undefined>;
|
|
38
|
-
depth: Depth;
|
|
39
|
-
detailed?: {
|
|
40
|
-
code: string;
|
|
41
|
-
name: string;
|
|
42
|
-
};
|
|
43
|
-
auxiliary?: {
|
|
44
|
-
text: string;
|
|
45
|
-
code: string;
|
|
46
|
-
name: string;
|
|
47
|
-
direction: string;
|
|
48
|
-
distance: Omit<UnitValueNotNull<never, 'km'>, 'type' | 'condition'>;
|
|
49
|
-
};
|
|
50
|
-
source?: 'PTWC' | 'USGS' | 'WCATWC';
|
|
51
|
-
};
|
|
52
|
-
magnitude: Magnitude;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
import { Coordinate } from './coordinate';
|
|
2
|
+
import { UnitValueNotNull } from './unit-value';
|
|
3
|
+
|
|
4
|
+
type Depth = {
|
|
5
|
+
type: '深さ';
|
|
6
|
+
unit: 'km';
|
|
7
|
+
} & ({
|
|
8
|
+
value: null;
|
|
9
|
+
condition: '不明';
|
|
10
|
+
} | {
|
|
11
|
+
value: '0';
|
|
12
|
+
condition: 'ごく浅い';
|
|
13
|
+
} | {
|
|
14
|
+
value: '700';
|
|
15
|
+
condition: '700km以上';
|
|
16
|
+
} | {
|
|
17
|
+
value: string;
|
|
18
|
+
condition: never;
|
|
19
|
+
});
|
|
20
|
+
type Magnitude = {
|
|
21
|
+
type: 'マグニチュード';
|
|
22
|
+
unit: 'Mj' | 'M';
|
|
23
|
+
} & ({
|
|
24
|
+
value: null;
|
|
25
|
+
condition: 'M不明' | 'M8を超える巨大地震';
|
|
26
|
+
} | {
|
|
27
|
+
value: string;
|
|
28
|
+
condition: never;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export interface Earthquake {
|
|
32
|
+
originTime: string;
|
|
33
|
+
arrivalTime: string;
|
|
34
|
+
hypocenter: {
|
|
35
|
+
name: string;
|
|
36
|
+
code: string;
|
|
37
|
+
coordinate: Coordinate<'日本測地系' | undefined>;
|
|
38
|
+
depth: Depth;
|
|
39
|
+
detailed?: {
|
|
40
|
+
code: string;
|
|
41
|
+
name: string;
|
|
42
|
+
};
|
|
43
|
+
auxiliary?: {
|
|
44
|
+
text: string;
|
|
45
|
+
code: string;
|
|
46
|
+
name: string;
|
|
47
|
+
direction: string;
|
|
48
|
+
distance: Omit<UnitValueNotNull<never, 'km'>, 'type' | 'condition'>;
|
|
49
|
+
};
|
|
50
|
+
source?: 'PTWC' | 'USGS' | 'WCATWC';
|
|
51
|
+
};
|
|
52
|
+
magnitude: Magnitude;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export type UnitValue<Type = string, Unit = string, Condition = never> = {
|
|
2
|
-
type: Type;
|
|
3
|
-
unit: Unit;
|
|
4
|
-
value: string | null;
|
|
5
|
-
condition: Condition
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type UnitValueNotNull<Type = string, Unit = string, Condition = never> = {
|
|
9
|
-
type: Type;
|
|
10
|
-
unit: Unit;
|
|
11
|
-
value: string;
|
|
12
|
-
condition: Condition
|
|
13
|
-
};
|
|
1
|
+
export type UnitValue<Type = string, Unit = string, Condition = never> = {
|
|
2
|
+
type: Type;
|
|
3
|
+
unit: Unit;
|
|
4
|
+
value: string | null;
|
|
5
|
+
condition: Condition
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type UnitValueNotNull<Type = string, Unit = string, Condition = never> = {
|
|
9
|
+
type: Type;
|
|
10
|
+
unit: Unit;
|
|
11
|
+
value: string;
|
|
12
|
+
condition: Condition
|
|
13
|
+
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as EarthquakeInformation from './schema/earthquake-information';
|
|
2
|
+
import * as EarthquakeExplanation from './schema/earthquake-explanation';
|
|
3
|
+
import * as EarthquakeCounts from './schema/earthquake-counts';
|
|
4
|
+
import * as EarthquakeHypocenterUpdate from './schema/earthquake-hypocenter-update';
|
|
5
|
+
import * as EarthquakeNankai from './schema/earthquake-nankai';
|
|
6
|
+
import * as EewInformation from './schema/eew-information';
|
|
7
|
+
import * as TsunamiInformation from './schema/tsunami-information';
|
|
8
|
+
import * as VolcanoInformation from './schema/volcano-information';
|
|
9
|
+
import * as WeatherTyphoon from './schema/weather-typhoon';
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
EarthquakeInformation,
|
|
13
|
+
EarthquakeExplanation,
|
|
14
|
+
EarthquakeCounts,
|
|
15
|
+
EarthquakeHypocenterUpdate,
|
|
16
|
+
EarthquakeNankai,
|
|
17
|
+
EewInformation,
|
|
18
|
+
TsunamiInformation,
|
|
19
|
+
VolcanoInformation,
|
|
20
|
+
WeatherTyphoon
|
|
21
|
+
};
|