@dmdata/telegram-json-types 1.0.9-jschema.0 → 1.1.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/README.md +44 -3
- package/dist/build.js +22 -11
- package/dist/config.d.ts +2 -1
- package/dist/config.js +3 -2
- 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-early_1.0.0.json +1 -0
- package/dist/jschema/weather-impact-society_1.0.0.json +1 -0
- package/dist/jschema/weather-information_1.0.0.json +1 -0
- package/dist/jschema/weather-landslide_1.0.0.json +1 -0
- package/dist/jschema/weather-river-flood_1.0.0.json +1 -0
- package/dist/jschema/weather-tornado_1.0.0.json +1 -0
- package/dist/jschema/weather-typhoon_1.0.0.json +1 -0
- package/dist/jschema/weather-warning_1.0.0.json +1 -0
- package/dist/jschema-load.d.ts +1 -1
- package/dist/jschema-load.js +12 -6
- package/index.d.ts +2 -2
- package/jest.config.ts +202 -0
- package/package.json +29 -21
- package/test/sample-schema-check.test.ts +54 -0
- package/tsconfig.json +28 -15
- package/types/component/code-name.ts +4 -0
- package/types/{schema/component → component}/coordinate.d.ts +2 -2
- package/types/{schema/component → component}/earthquake.d.ts +0 -0
- package/types/{schema/component → component}/unit-value.d.ts +13 -13
- package/types/index.d.ts +35 -4
- 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 +159 -0
- package/types/schema/{earthquake-information.d.ts → earthquake-information/1.1.0.d.ts} +206 -181
- package/types/schema/earthquake-information/index.d.ts +9 -0
- package/types/schema/earthquake-nankai/1.0.0.d.ts +86 -0
- package/types/schema/earthquake-nankai/index.d.ts +7 -0
- package/types/schema/{eew-information.d.ts → eew-information/1.0.0.d.ts} +42 -39
- package/types/schema/eew-information/index.d.ts +7 -0
- package/types/schema/{tsunami-information.d.ts → tsunami-information/1.0.0.d.ts} +262 -230
- package/types/schema/tsunami-information/index.d.ts +7 -0
- package/types/schema/volcano-information/1.0.0.d.ts +450 -0
- package/types/schema/volcano-information/index.d.ts +7 -0
- package/types/schema/weather-early/1.0.0.d.ts +135 -0
- package/types/schema/weather-early/index.d.ts +7 -0
- package/types/schema/weather-impact-society/1.0.0.d.ts +140 -0
- package/types/schema/weather-impact-society/index.d.ts +7 -0
- package/types/schema/weather-information/1.0.0.d.ts +30 -0
- package/types/schema/weather-information/index.d.ts +7 -0
- package/types/schema/weather-landslide/1.0.0.d.ts +51 -0
- package/types/schema/weather-landslide/index.d.ts +7 -0
- package/types/schema/weather-river-flood/1.0.0.d.ts +188 -0
- package/types/schema/weather-river-flood/index.d.ts +7 -0
- package/types/schema/weather-tornado/1.0.0.d.ts +51 -0
- package/types/schema/weather-tornado/index.d.ts +7 -0
- package/types/schema/{weather-typhoon.d.ts → weather-typhoon/1.0.0.d.ts} +26 -13
- package/types/schema/weather-typhoon/index.d.ts +7 -0
- package/types/schema/weather-warning/1.0.0.d.ts +212 -0
- package/types/schema/weather-warning/index.d.ts +7 -0
- package/dist/jschema/earthquake-information.json +0 -1778
- package/dist/jschema/eew-information.json +0 -2742
- package/dist/jschema/tsunami-information.json +0 -3891
- package/dist/jschema/weather-typhoon.json +0 -4969
- package/jschema/build.ts +0 -56
- package/jschema/config.ts +0 -4
- package/jschema/jschema-load.ts +0 -26
- package/tsconfig.jschema.json +0 -16
package/jschema/build.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
|
-
import { mkdir, readdir, rm, writeFile } from 'fs/promises';
|
|
3
|
-
import * as TJS from 'typescript-json-schema';
|
|
4
|
-
|
|
5
|
-
import { basePath, distDir } from './config';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const settings: TJS.PartialArgs = {
|
|
11
|
-
required: true,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const compilerOptions: TJS.CompilerOptions = {
|
|
15
|
-
strictNullChecks: true,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
readdir(basePath)
|
|
19
|
-
.then(files => programTypescript(files));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
async function programTypescript(files: string[]) {
|
|
23
|
-
const tsTypeFiles = files.filter(file => /\.ts$/.test(file));
|
|
24
|
-
const filepath = tsTypeFiles.map(file => resolve(basePath, file));
|
|
25
|
-
|
|
26
|
-
const program = TJS.getProgramFromFiles(filepath, compilerOptions);
|
|
27
|
-
const generator = TJS.buildGenerator(program, settings);
|
|
28
|
-
|
|
29
|
-
const objectMaps = tsTypeFiles.map(file => tsTypeFileName2TypeSymbolName(file));
|
|
30
|
-
|
|
31
|
-
await rm(distDir, { recursive: true, force: true });
|
|
32
|
-
await mkdir(distDir, { recursive: true });
|
|
33
|
-
for (let i = 0; i < objectMaps.length; i++) {
|
|
34
|
-
const { schemaName, typeName } = objectMaps[i];
|
|
35
|
-
console.log(`Build ok: ${schemaName}: ${typeName}`);
|
|
36
|
-
|
|
37
|
-
const schema = generator?.getSchemaForSymbol(typeName, true);
|
|
38
|
-
|
|
39
|
-
await writeFile(
|
|
40
|
-
resolve(distDir, `${schemaName}.json`),
|
|
41
|
-
JSON.stringify(schema, undefined, 4)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
console.log('Build complete');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function tsTypeFileName2TypeSymbolName(file: string) {
|
|
49
|
-
const schemaName = file.replace(/^([\w-]+?)(\.d)?\.ts$/, '$1');
|
|
50
|
-
const nameScope = schemaName.replace(/-(\w)|(^\w)/g, (match, p1 = '', p2 = '') => `${p1}${p2}`.toUpperCase());
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
schemaName,
|
|
54
|
-
typeName: nameScope + '.Main'
|
|
55
|
-
};
|
|
56
|
-
}
|
package/jschema/config.ts
DELETED
package/jschema/jschema-load.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { readdirSync } from 'fs';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
|
|
4
|
-
import { distDir } from './config';
|
|
5
|
-
|
|
6
|
-
const schemas = new Map<string, string>();
|
|
7
|
-
|
|
8
|
-
const jschemaList = readdirSync(distDir).filter(file => /\.json$/.test(file));
|
|
9
|
-
|
|
10
|
-
jschemaList.forEach(jschema => {
|
|
11
|
-
schemas.set(
|
|
12
|
-
jschema.replace('.json', ''),
|
|
13
|
-
resolve(distDir, jschema)
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export function getJSchema(name: string) {
|
|
19
|
-
const filePath = schemas.get(name);
|
|
20
|
-
|
|
21
|
-
if (!filePath) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return import(filePath);
|
|
26
|
-
}
|
package/tsconfig.jschema.json
DELETED