@dmdata/telegram-json-types 1.0.8 → 1.0.9-jschema.0
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 +26 -0
- package/dist/build.d.ts +1 -0
- package/dist/build.js +57 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +6 -0
- package/dist/jschema/earthquake-information.json +1778 -0
- package/dist/jschema/eew-information.json +2742 -0
- package/dist/jschema/tsunami-information.json +3891 -0
- package/dist/jschema/weather-typhoon.json +4969 -0
- package/dist/jschema-load.d.ts +1 -0
- package/dist/jschema-load.js +38 -0
- package/index.d.ts +1 -0
- package/jschema/build.ts +56 -0
- package/jschema/config.ts +4 -0
- package/jschema/jschema-load.ts +26 -0
- package/package.json +21 -11
- package/tsconfig.jschema.json +16 -0
- package/types/index.d.ts +4 -3
- package/types/schema/component/coordinate.d.ts +15 -15
- package/types/schema/component/earthquake.d.ts +56 -56
- package/types/schema/earthquake-information.d.ts +20 -16
- package/types/schema/eew-information.d.ts +167 -0
- package/types/schema/tsunami-information.d.ts +2 -1
- package/types/schema/weather-typhoon.d.ts +122 -117
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,26 @@
|
|
|
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
|
+
```:typescirpt
|
|
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.Main>
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 使える型定義
|
|
22
|
+
|
|
23
|
+
* [EewInformation](https://dmdata.jp/doc/reference/conversion/json/schema/eew-information)
|
|
24
|
+
* [EarthquakeInformation](https://dmdata.jp/doc/reference/conversion/json/schema/earthquake-information)
|
|
25
|
+
* [TsunamiInformation](https://dmdata.jp/doc/reference/conversion/json/schema/tsunami-information)
|
|
26
|
+
* [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,57 @@
|
|
|
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)
|
|
33
|
+
.then(files => programTypescript(files));
|
|
34
|
+
async function programTypescript(files) {
|
|
35
|
+
const tsTypeFiles = files.filter(file => /\.ts$/.test(file));
|
|
36
|
+
const filepath = tsTypeFiles.map(file => (0, path_1.resolve)(config_1.basePath, file));
|
|
37
|
+
const program = TJS.getProgramFromFiles(filepath, compilerOptions);
|
|
38
|
+
const generator = TJS.buildGenerator(program, settings);
|
|
39
|
+
const objectMaps = tsTypeFiles.map(file => tsTypeFileName2TypeSymbolName(file));
|
|
40
|
+
await (0, promises_1.rm)(config_1.distDir, { recursive: true, force: true });
|
|
41
|
+
await (0, promises_1.mkdir)(config_1.distDir, { recursive: true });
|
|
42
|
+
for (let i = 0; i < objectMaps.length; i++) {
|
|
43
|
+
const { schemaName, typeName } = objectMaps[i];
|
|
44
|
+
console.log(`Build ok: ${schemaName}: ${typeName}`);
|
|
45
|
+
const schema = generator?.getSchemaForSymbol(typeName, true);
|
|
46
|
+
await (0, promises_1.writeFile)((0, path_1.resolve)(config_1.distDir, `${schemaName}.json`), JSON.stringify(schema, undefined, 4));
|
|
47
|
+
}
|
|
48
|
+
console.log('Build complete');
|
|
49
|
+
}
|
|
50
|
+
function tsTypeFileName2TypeSymbolName(file) {
|
|
51
|
+
const schemaName = file.replace(/^([\w-]+?)(\.d)?\.ts$/, '$1');
|
|
52
|
+
const nameScope = schemaName.replace(/-(\w)|(^\w)/g, (match, p1 = '', p2 = '') => `${p1}${p2}`.toUpperCase());
|
|
53
|
+
return {
|
|
54
|
+
schemaName,
|
|
55
|
+
typeName: nameScope + '.Main'
|
|
56
|
+
};
|
|
57
|
+
}
|
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/');
|