@dmdata/telegram-json-types 1.0.9-jschema.0 → 1.0.9-jschema.1
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 +31 -2
- package/dist/build.js +17 -11
- 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/eew-information_1.0.0.json +1 -0
- package/dist/jschema/tsunami-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 -1
- package/dist/jschema-load.js +12 -6
- package/index.d.ts +2 -2
- package/package.json +3 -3
- package/types/{schema/component → component}/coordinate.d.ts +0 -0
- package/types/{schema/component → component}/earthquake.d.ts +0 -0
- package/types/{schema/component → component}/unit-value.d.ts +0 -0
- package/types/index.d.ts +11 -4
- package/types/schema/earthquake-information/1.0.0.d.ts +135 -0
- package/types/schema/{earthquake-information.d.ts → earthquake-information/1.1.0.d.ts} +179 -181
- package/types/schema/earthquake-information/index.d.ts +11 -0
- package/types/schema/{eew-information.d.ts → eew-information/1.0.0.d.ts} +3 -3
- package/types/schema/eew-information/index.d.ts +9 -0
- package/types/schema/{tsunami-information.d.ts → tsunami-information/1.0.0.d.ts} +230 -230
- package/types/schema/tsunami-information/index.d.ts +9 -0
- package/types/schema/{weather-typhoon.d.ts → weather-typhoon/1.0.0.d.ts} +3 -3
- package/types/schema/weather-typhoon/index.d.ts +9 -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