@dmdata/telegram-json-types 1.0.9-jschema.2 → 1.1.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.
Files changed (52) hide show
  1. package/README.md +13 -4
  2. package/dist/build.js +9 -4
  3. package/dist/config.d.ts +2 -1
  4. package/dist/config.js +3 -2
  5. package/dist/jschema/earthquake-counts_1.0.0.json +1 -1
  6. package/dist/jschema/earthquake-explanation_1.0.0.json +1 -1
  7. package/dist/jschema/earthquake-hypocenter-update_1.0.0.json +1 -1
  8. package/dist/jschema/earthquake-information_1.0.0.json +1 -1
  9. package/dist/jschema/earthquake-information_1.1.0.json +1 -1
  10. package/dist/jschema/earthquake-nankai_1.0.0.json +1 -1
  11. package/dist/jschema/eew-information_1.0.0.json +1 -1
  12. package/dist/jschema/tsunami-information_1.0.0.json +1 -1
  13. package/dist/jschema/volcano-information_1.0.0.json +1 -1
  14. package/dist/jschema/weather-early_1.0.0.json +1 -0
  15. package/dist/jschema/weather-impact-society_1.0.0.json +1 -0
  16. package/dist/jschema/weather-information_1.0.0.json +1 -0
  17. package/dist/jschema/weather-landslide_1.0.0.json +1 -0
  18. package/dist/jschema/weather-river-flood_1.0.0.json +1 -0
  19. package/dist/jschema/weather-tornado_1.0.0.json +1 -0
  20. package/dist/jschema/weather-typhoon_1.0.0.json +1 -1
  21. package/dist/jschema/weather-warning_1.0.0.json +1 -0
  22. package/jest.config.ts +202 -0
  23. package/package.json +16 -4
  24. package/test/sample-schema-check.test.ts +54 -0
  25. package/tsconfig.json +28 -20
  26. package/types/component/code-name.ts +4 -0
  27. package/types/index.d.ts +37 -1
  28. package/types/schema/earthquake-counts/1.0.0.d.ts +69 -69
  29. package/types/schema/earthquake-explanation/1.0.0.d.ts +57 -57
  30. package/types/schema/earthquake-hypocenter-update/1.0.0.d.ts +53 -53
  31. package/types/schema/earthquake-information/1.0.0.d.ts +16 -22
  32. package/types/schema/earthquake-information/1.1.0.d.ts +18 -24
  33. package/types/schema/earthquake-nankai/1.0.0.d.ts +86 -87
  34. package/types/schema/earthquake-nankai/index.d.ts +1 -1
  35. package/types/schema/eew-information/1.0.0.d.ts +23 -29
  36. package/types/schema/tsunami-information/1.0.0.d.ts +76 -57
  37. package/types/schema/volcano-information/1.0.0.d.ts +450 -449
  38. package/types/schema/weather-early/1.0.0.d.ts +135 -0
  39. package/types/schema/weather-early/index.d.ts +7 -0
  40. package/types/schema/weather-impact-society/1.0.0.d.ts +140 -0
  41. package/types/schema/weather-impact-society/index.d.ts +7 -0
  42. package/types/schema/weather-information/1.0.0.d.ts +30 -0
  43. package/types/schema/weather-information/index.d.ts +7 -0
  44. package/types/schema/weather-landslide/1.0.0.d.ts +51 -0
  45. package/types/schema/weather-landslide/index.d.ts +7 -0
  46. package/types/schema/weather-river-flood/1.0.0.d.ts +188 -0
  47. package/types/schema/weather-river-flood/index.d.ts +7 -0
  48. package/types/schema/weather-tornado/1.0.0.d.ts +51 -0
  49. package/types/schema/weather-tornado/index.d.ts +7 -0
  50. package/types/schema/weather-typhoon/1.0.0.d.ts +24 -13
  51. package/types/schema/weather-warning/1.0.0.d.ts +212 -0
  52. package/types/schema/weather-warning/index.d.ts +7 -0
@@ -0,0 +1,54 @@
1
+ import Ajv from 'ajv';
2
+ import fetch from 'node-fetch';
3
+ import { getJSchema } from '../jschema/jschema-load';
4
+
5
+ const checkSchemaTypes = [
6
+ 'eew-information',
7
+ 'earthquake-information',
8
+ 'earthquake-explanation',
9
+ 'earthquake-counts',
10
+ 'earthquake-hypocenter-update',
11
+ 'earthquake-nankai',
12
+ 'tsunami-information',
13
+ 'volcano-information',
14
+ 'weather-information',
15
+ 'weather-impact-society',
16
+ 'weather-early',
17
+ 'weather-warning',
18
+ 'weather-tornado',
19
+ 'weather-typhoon',
20
+ 'weather-landslide',
21
+ 'weather-river-flood'
22
+ ];
23
+
24
+ const ajv = new Ajv({
25
+ strictTuples: false
26
+ });
27
+
28
+ test.each(checkSchemaTypes)('CheckSchemaType: %s', async schemaType => {
29
+ const sampleList = await getList(schemaType);
30
+
31
+ for (let i = 0; i < sampleList.length; i++) {
32
+ const url = sampleList[i];
33
+ const json: any = await fetch(url).then(res => res.json());
34
+ const schema = await getJSchema(json._schema.type, json._schema.version);
35
+ const validate = ajv.compile(schema);
36
+ const valid = validate(json);
37
+
38
+ console.group(url);
39
+ expect(validate.errors ?? []).toEqual([]);
40
+ console.groupEnd();
41
+ }
42
+ });
43
+
44
+
45
+ async function getList(schemaType: string) {
46
+ const url = `https://sample.dmdata.jp/conversion/json/schema/${schemaType}/`;
47
+ return await fetch(url).then(res => res.text())
48
+ .then(html => html
49
+ .replace(/^.+?<pre>.+?<hr>(.+?)<\/pre>.+?$/s, '$1')
50
+ .match(/<a\shref="(.+?)">/g)
51
+ ?.map(a => url + a.replace(/^<a\shref="(.+?)">$/, '$1'))
52
+ .filter(href => /\.json$/.test(href)) ?? []
53
+ );
54
+ }
package/tsconfig.json CHANGED
@@ -1,20 +1,28 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "target": "es2020",
5
- "sourceMap": false,
6
- "alwaysStrict": true,
7
- "noImplicitThis": true,
8
- "noImplicitReturns": true,
9
- "noFallthroughCasesInSwitch": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "strict": true,
12
- "esModuleInterop": true,
13
- "baseUrl": "./",
14
- "paths": {
15
- "@/types/*": [
16
- "./types/*"
17
- ]
18
- }
19
- },
20
- }
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "target": "es2020",
5
+ "sourceMap": false,
6
+ "alwaysStrict": true,
7
+ "noImplicitThis": true,
8
+ "noImplicitReturns": true,
9
+ "noFallthroughCasesInSwitch": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "baseUrl": "./",
14
+ "paths": {
15
+ "@t/*": [
16
+ "./types/*"
17
+ ]
18
+ }
19
+ },
20
+ "include": [
21
+ "types/**/*",
22
+ "test/**/*"
23
+ ],
24
+ "exclude": [
25
+ "jschema",
26
+ "node_modules"
27
+ ]
28
+ }
@@ -0,0 +1,4 @@
1
+ export interface CodeName {
2
+ code: string;
3
+ name: string;
4
+ }
package/types/index.d.ts CHANGED
@@ -6,7 +6,34 @@ import * as EarthquakeNankai from './schema/earthquake-nankai';
6
6
  import * as EewInformation from './schema/eew-information';
7
7
  import * as TsunamiInformation from './schema/tsunami-information';
8
8
  import * as VolcanoInformation from './schema/volcano-information';
9
+ import * as WeatherInformation from './schema/weather-information';
10
+ import * as WeatherImpactSociety from './schema/weather-impact-society';
11
+ import * as WeatherEarly from './schema/weather-early';
12
+ import * as WeatherWarning from './schema/weather-warning';
13
+ import * as WeatherTornado from './schema/weather-tornado';
9
14
  import * as WeatherTyphoon from './schema/weather-typhoon';
15
+ import * as WeatherLandslide from './schema/weather-landslide';
16
+ import * as WeatherRiverFlood from './schema/weather-river-flood';
17
+ import { TelegramJSONMain } from './main';
18
+
19
+ type All =
20
+ EarthquakeInformation.v1_0_0.Main |
21
+ EarthquakeInformation.v1_1_0.Main |
22
+ EarthquakeExplanation.v1_0_0.Main |
23
+ EarthquakeCounts.v1_0_0.Main |
24
+ EarthquakeHypocenterUpdate.v1_0_0.Main |
25
+ EarthquakeNankai.v1_0_0.Main |
26
+ EewInformation.v1_0_0.Main |
27
+ TsunamiInformation.v1_0_0.Main |
28
+ VolcanoInformation.v1_0_0.Main |
29
+ WeatherInformation.v1_0_0.Main |
30
+ WeatherImpactSociety.v1_0_0.Main |
31
+ WeatherEarly.v1_0_0.Main |
32
+ WeatherWarning.v1_0_0.Main |
33
+ WeatherTornado.v1_0_0.Main |
34
+ WeatherTyphoon.v1_0_0.Main |
35
+ WeatherLandslide.v1_0_0.Main |
36
+ WeatherRiverFlood.v1_0_0.Main;
10
37
 
11
38
  export {
12
39
  EarthquakeInformation,
@@ -17,5 +44,14 @@ export {
17
44
  EewInformation,
18
45
  TsunamiInformation,
19
46
  VolcanoInformation,
20
- WeatherTyphoon
47
+ WeatherInformation,
48
+ WeatherImpactSociety,
49
+ WeatherEarly,
50
+ WeatherWarning,
51
+ WeatherTornado,
52
+ WeatherTyphoon,
53
+ WeatherLandslide,
54
+ WeatherRiverFlood,
55
+ TelegramJSONMain,
56
+ All
21
57
  };
@@ -1,69 +1,69 @@
1
- import { TelegramJSONMain } from '@/types/main';
2
-
3
- export namespace EarthquakeCounts {
4
- export interface Schema {
5
- type: 'earthquake-counts';
6
- version: '1.0.0';
7
- }
8
-
9
- export interface EarthquakeCountTargetTime {
10
- start: string;
11
- end: string;
12
- }
13
-
14
- export interface EarthquakeCountValues {
15
- all: string | null;
16
- felt: string | null;
17
- }
18
-
19
- export interface EarthquakeCount {
20
- type: '1時間地震回数' | '累計地震回数' | '地震回数';
21
- targetTime: EarthquakeCountTargetTime;
22
- values: EarthquakeCountValues;
23
- }
24
-
25
- export interface Comments {
26
- free: string;
27
- }
28
-
29
- export interface PublicBody {
30
- earthquakeCounts?: EarthquakeCount;
31
- nextAdvisory?: string;
32
- text?: string;
33
- comments?: Comments;
34
- }
35
-
36
- export interface CancelBody {
37
- text: string;
38
- }
39
-
40
- export interface Public extends TelegramJSONMain {
41
- _schema: Schema;
42
- type: '地震回数に関する情報';
43
- title: '地震回数に関する情報';
44
- infoType: '発表' | '訂正';
45
- targetDateTimeDubious: never;
46
- targetDuration: never;
47
- validDateTime: never;
48
- eventId: string;
49
- serialNo: string;
50
- infoKind: '地震回数情報';
51
- body: PublicBody;
52
- }
53
-
54
- export interface Cancel extends TelegramJSONMain {
55
- _schema: Schema;
56
- type: '地震回数に関する情報';
57
- title: '地震回数に関する情報';
58
- infoType: '取消';
59
- targetDateTimeDubious: never;
60
- targetDuration: never;
61
- validDateTime: never;
62
- eventId: string;
63
- serialNo: string;
64
- infoKind: '地震回数情報';
65
- body: CancelBody;
66
- }
67
-
68
- export type Main = Public | Cancel;
69
- }
1
+ import { TelegramJSONMain } from '@t/main';
2
+
3
+ export namespace EarthquakeCounts {
4
+ export interface Schema {
5
+ type: 'earthquake-counts';
6
+ version: '1.0.0';
7
+ }
8
+
9
+ export interface EarthquakeCountTargetTime {
10
+ start: string;
11
+ end: string;
12
+ }
13
+
14
+ export interface EarthquakeCountValues {
15
+ all: string | null;
16
+ felt: string | null;
17
+ }
18
+
19
+ export interface EarthquakeCount {
20
+ type: '1時間地震回数' | '累積地震回数' | '地震回数';
21
+ targetTime: EarthquakeCountTargetTime;
22
+ values: EarthquakeCountValues;
23
+ }
24
+
25
+ export interface Comments {
26
+ free: string;
27
+ }
28
+
29
+ export interface PublicBody {
30
+ earthquakeCounts?: EarthquakeCount[];
31
+ nextAdvisory?: string;
32
+ text?: string;
33
+ comments?: Comments;
34
+ }
35
+
36
+ export interface CancelBody {
37
+ text: string;
38
+ }
39
+
40
+ export interface Public extends TelegramJSONMain {
41
+ _schema: Schema;
42
+ type: '地震回数に関する情報';
43
+ title: '地震回数に関する情報';
44
+ infoType: '発表' | '訂正';
45
+ targetDateTimeDubious: never;
46
+ targetDuration: never;
47
+ validDateTime: never;
48
+ eventId: string;
49
+ serialNo: string;
50
+ infoKind: '地震回数情報';
51
+ body: PublicBody;
52
+ }
53
+
54
+ export interface Cancel extends TelegramJSONMain {
55
+ _schema: Schema;
56
+ type: '地震回数に関する情報';
57
+ title: '地震回数に関する情報';
58
+ infoType: '取消';
59
+ targetDateTimeDubious: never;
60
+ targetDuration: never;
61
+ validDateTime: never;
62
+ eventId: string;
63
+ serialNo: string;
64
+ infoKind: '地震回数情報';
65
+ body: CancelBody;
66
+ }
67
+
68
+ export type Main = Public | Cancel;
69
+ }
@@ -1,57 +1,57 @@
1
- import { TelegramJSONMain } from '@/types/main';
2
-
3
- export namespace EarthquakeExplanation {
4
- export interface Schema {
5
- type: 'earthquake-explanation';
6
- version: '1.0.0';
7
- }
8
-
9
- export interface Naming {
10
- text: string;
11
- en?: string;
12
- }
13
-
14
- export interface Comments {
15
- free: string;
16
- }
17
-
18
- export interface PublicBody {
19
- naming?: Naming;
20
- text: string;
21
- comments?: Comments;
22
- }
23
-
24
- export interface CancelBody {
25
- text: string;
26
- }
27
-
28
- export interface Public extends TelegramJSONMain {
29
- _schema: Schema;
30
- type: '地震の活動状況等に関する情報';
31
- title: '地震の活動状況等に関する情報';
32
- infoType: '発表' | '訂正';
33
- targetDateTimeDubious: never;
34
- targetDuration: never;
35
- validDateTime: never;
36
- eventId: string;
37
- serialNo: null;
38
- infoKind: '地震の活動状況等に関する情報';
39
- body: PublicBody;
40
- }
41
-
42
- export interface Cancel extends TelegramJSONMain {
43
- _schema: Schema;
44
- type: '地震の活動状況等に関する情報';
45
- title: '地震の活動状況等に関する情報';
46
- infoType: '取消';
47
- targetDateTimeDubious: never;
48
- targetDuration: never;
49
- validDateTime: never;
50
- eventId: string;
51
- serialNo: null;
52
- infoKind: '地震の活動状況等に関する情報';
53
- body: CancelBody;
54
- }
55
-
56
- export type Main = Public | Cancel;
57
- }
1
+ import { TelegramJSONMain } from '@t/main';
2
+
3
+ export namespace EarthquakeExplanation {
4
+ export interface Schema {
5
+ type: 'earthquake-explanation';
6
+ version: '1.0.0';
7
+ }
8
+
9
+ export interface Naming {
10
+ text: string;
11
+ en?: string;
12
+ }
13
+
14
+ export interface Comments {
15
+ free: string;
16
+ }
17
+
18
+ export interface PublicBody {
19
+ naming?: Naming;
20
+ text: string;
21
+ comments?: Comments;
22
+ }
23
+
24
+ export interface CancelBody {
25
+ text: string;
26
+ }
27
+
28
+ export interface Public extends TelegramJSONMain {
29
+ _schema: Schema;
30
+ type: '地震の活動状況等に関する情報';
31
+ title: '地震の活動状況等に関する情報';
32
+ infoType: '発表' | '訂正';
33
+ targetDateTimeDubious: never;
34
+ targetDuration: never;
35
+ validDateTime: never;
36
+ eventId: string;
37
+ serialNo: null;
38
+ infoKind: '地震の活動状況等に関する情報';
39
+ body: PublicBody;
40
+ }
41
+
42
+ export interface Cancel extends TelegramJSONMain {
43
+ _schema: Schema;
44
+ type: '地震の活動状況等に関する情報';
45
+ title: '地震の活動状況等に関する情報';
46
+ infoType: '取消';
47
+ targetDateTimeDubious: never;
48
+ targetDuration: never;
49
+ validDateTime: never;
50
+ eventId: string;
51
+ serialNo: null;
52
+ infoKind: '地震の活動状況等に関する情報';
53
+ body: CancelBody;
54
+ }
55
+
56
+ export type Main = Public | Cancel;
57
+ }
@@ -1,53 +1,53 @@
1
- import { TelegramJSONMain } from '../../main';
2
- import { Earthquake } from '../../component/earthquake';
3
-
4
- export namespace EarthquakeHypocenterUpdate {
5
- export interface Schema {
6
- type: 'earthquake-hypocenter-update';
7
- version: '1.0.0';
8
- }
9
-
10
- export interface Comments {
11
- free: string;
12
- }
13
-
14
- export interface PublicBody {
15
- earthquake: Earthquake;
16
- text: string;
17
- comments?: Comments;
18
- }
19
-
20
- export interface CancelBody {
21
- text: string;
22
- }
23
-
24
- export interface Public extends TelegramJSONMain {
25
- _schema: Schema;
26
- type: '顕著な地震の震源要素更新のお知らせ';
27
- title: '顕著な地震の震源要素更新のお知らせ';
28
- infoType: '発表' | '訂正';
29
- targetDateTimeDubious: never;
30
- targetDuration: never;
31
- validDateTime: never;
32
- eventId: string;
33
- serialNo: null;
34
- infoKind: '震源要素更新のお知らせ';
35
- body: PublicBody;
36
- }
37
-
38
- export interface Cancel extends TelegramJSONMain {
39
- _schema: Schema;
40
- type: '顕著な地震の震源要素更新のお知らせ';
41
- title: '顕著な地震の震源要素更新のお知らせ';
42
- infoType: '取消';
43
- targetDateTimeDubious: never;
44
- targetDuration: never;
45
- validDateTime: never;
46
- eventId: string;
47
- serialNo: null;
48
- infoKind: '震源要素更新のお知らせ';
49
- body: CancelBody;
50
- }
51
-
52
- export type Main = Public | Cancel;
53
- }
1
+ import { TelegramJSONMain } from '@t/main';
2
+ import { Earthquake } from '@t/component/earthquake';
3
+
4
+ export namespace EarthquakeHypocenterUpdate {
5
+ export interface Schema {
6
+ type: 'earthquake-hypocenter-update';
7
+ version: '1.0.0';
8
+ }
9
+
10
+ export interface Comments {
11
+ free: string;
12
+ }
13
+
14
+ export interface PublicBody {
15
+ earthquake: Earthquake;
16
+ text?: string;
17
+ comments?: Comments;
18
+ }
19
+
20
+ export interface CancelBody {
21
+ text: string;
22
+ }
23
+
24
+ export interface Public extends TelegramJSONMain {
25
+ _schema: Schema;
26
+ type: '顕著な地震の震源要素更新のお知らせ';
27
+ title: '顕著な地震の震源要素更新のお知らせ';
28
+ infoType: '発表' | '訂正';
29
+ targetDateTimeDubious: never;
30
+ targetDuration: never;
31
+ validDateTime: never;
32
+ eventId: string;
33
+ serialNo: null;
34
+ infoKind: '震源要素更新のお知らせ';
35
+ body: PublicBody;
36
+ }
37
+
38
+ export interface Cancel extends TelegramJSONMain {
39
+ _schema: Schema;
40
+ type: '顕著な地震の震源要素更新のお知らせ';
41
+ title: '顕著な地震の震源要素更新のお知らせ';
42
+ infoType: '取消';
43
+ targetDateTimeDubious: never;
44
+ targetDuration: never;
45
+ validDateTime: never;
46
+ eventId: string;
47
+ serialNo: null;
48
+ infoKind: '震源要素更新のお知らせ';
49
+ body: CancelBody;
50
+ }
51
+
52
+ export type Main = Public | Cancel;
53
+ }
@@ -1,41 +1,35 @@
1
- import { TelegramJSONMain } from '@/types/main';
2
- import { Earthquake } from '@/types/component/earthquake';
1
+ import { TelegramJSONMain } from '@t/main';
2
+ import { CodeName } from '@t/component/code-name';
3
+ import { Earthquake } from '@t/component/earthquake';
3
4
 
4
5
  export namespace EarthquakeInformation {
5
6
  export interface Schema {
6
7
  type: 'earthquake-information';
7
- version: '1.1.0';
8
+ version: '1.0.0';
8
9
  }
9
10
 
10
11
  export type IntensityClass = '1' | '2' | '3' | '4' | '5-' | '5+' | '6-' | '6+' | '7';
11
12
 
12
- export type IntensityMaxInt = {
13
- name: string;
14
- code: string;
13
+ export interface IntensityMaxInt extends CodeName {
15
14
  maxInt: IntensityClass;
16
- };
17
- export type IntensityMaxIntOnRevise = {
18
- name: string;
19
- code: string;
15
+ }
16
+
17
+ export interface IntensityMaxIntOnRevise extends CodeName {
20
18
  maxInt?: IntensityClass;
21
19
  revise?: '上方修正' | '追加';
22
20
  }
23
21
 
24
- export type IntensityCity = {
25
- name: string;
26
- code: string;
22
+ export interface IntensityCity extends CodeName {
27
23
  maxInt?: IntensityClass;
28
24
  revise?: '上方修正' | '追加';
29
25
  condition?: '震度5弱以上未入電';
30
- };
26
+ }
31
27
 
32
- export type IntensityStation = {
33
- name: string;
34
- code: string;
28
+ export interface IntensityStation extends CodeName {
35
29
  int: IntensityClass | '!5-';
36
30
  revise?: '上方修正' | '追加';
37
31
  condition?: '震度5弱以上未入電';
38
- };
32
+ }
39
33
 
40
34
  export type Comment = {
41
35
  free?: string;
@@ -50,19 +44,19 @@ export namespace EarthquakeInformation {
50
44
  };
51
45
 
52
46
 
53
- export type IntensityVXSE51 = {
47
+ export interface IntensityVXSE51 {
54
48
  maxInt: IntensityClass;
55
49
  prefectures: IntensityMaxInt[];
56
50
  regions: IntensityMaxInt[];
57
- };
51
+ }
58
52
 
59
- export type IntensityVXSE53 = {
53
+ export interface IntensityVXSE53 {
60
54
  maxInt: IntensityClass;
61
55
  prefectures: IntensityMaxIntOnRevise[];
62
56
  regions: IntensityMaxIntOnRevise[];
63
57
  cities: IntensityCity[];
64
58
  stations: IntensityStation[];
65
- };
59
+ }
66
60
 
67
61
 
68
62
  export interface PublicBodyVXSE51 {