@baron1996/kline-scene-schema 0.2.3 → 0.3.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.
Files changed (31) hide show
  1. package/dist/generated/schemas.d.ts +308 -0
  2. package/dist/generated/schemas.d.ts.map +1 -1
  3. package/dist/generated/schemas.js +401 -0
  4. package/dist/generated/time-series-scene.d.ts +88 -0
  5. package/dist/generated/time-series-scene.d.ts.map +1 -0
  6. package/dist/generated/time-series-scene.js +2 -0
  7. package/dist/generated/validate-time-series-scene.d.ts +15 -0
  8. package/dist/generated/validate-time-series-scene.d.ts.map +1 -0
  9. package/dist/generated/validate-time-series-scene.js +2359 -0
  10. package/dist/index.d.ts +7 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +7 -1
  13. package/dist/time-series-canonical-json.d.ts +3 -0
  14. package/dist/time-series-canonical-json.d.ts.map +1 -0
  15. package/dist/time-series-canonical-json.js +15 -0
  16. package/dist/time-series-canonicalize.d.ts +3 -0
  17. package/dist/time-series-canonicalize.d.ts.map +1 -0
  18. package/dist/time-series-canonicalize.js +19 -0
  19. package/dist/time-series-errors.d.ts +13 -0
  20. package/dist/time-series-errors.d.ts.map +1 -0
  21. package/dist/time-series-errors.js +12 -0
  22. package/dist/time-series-semantic-validator.d.ts +5 -0
  23. package/dist/time-series-semantic-validator.d.ts.map +1 -0
  24. package/dist/time-series-semantic-validator.js +81 -0
  25. package/dist/time-series-validator.d.ts +4 -0
  26. package/dist/time-series-validator.d.ts.map +1 -0
  27. package/dist/time-series-validator.js +52 -0
  28. package/package.json +1 -1
  29. package/schema/time-series-chart-config.schema.json +75 -0
  30. package/schema/time-series-runtime.schema.json +13 -0
  31. package/schema/time-series-scene.schema.json +154 -0
@@ -1051,3 +1051,404 @@ export const ChartSceneSchema = {
1051
1051
  }
1052
1052
  }
1053
1053
  };
1054
+ export const TimeSeriesRuntimeSchema = {
1055
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1056
+ "$id": "https://baron.dev/kline-scene/time-series-runtime.schema.json",
1057
+ "title": "TimeSeriesRuntimeIdentity",
1058
+ "type": "object",
1059
+ "additionalProperties": false,
1060
+ "required": [
1061
+ "engine",
1062
+ "engineVersion",
1063
+ "runtimeVersion"
1064
+ ],
1065
+ "properties": {
1066
+ "engine": {
1067
+ "const": "klinecharts"
1068
+ },
1069
+ "engineVersion": {
1070
+ "const": "10.0.0"
1071
+ },
1072
+ "runtimeVersion": {
1073
+ "const": "0.1.0"
1074
+ }
1075
+ }
1076
+ };
1077
+ export const TimeSeriesChartConfigSchema = {
1078
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1079
+ "$id": "https://baron.dev/kline-scene/time-series-chart-config.schema.json",
1080
+ "title": "TimeSeriesChartConfig",
1081
+ "type": "object",
1082
+ "additionalProperties": false,
1083
+ "required": [
1084
+ "locale",
1085
+ "timezone",
1086
+ "layout",
1087
+ "grid",
1088
+ "thousandsSeparator",
1089
+ "decimalFold",
1090
+ "zoomAnchor",
1091
+ "dateFormat",
1092
+ "largeNumberFormat"
1093
+ ],
1094
+ "properties": {
1095
+ "locale": {
1096
+ "type": "string",
1097
+ "minLength": 2,
1098
+ "maxLength": 64,
1099
+ "pattern": "^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$"
1100
+ },
1101
+ "timezone": {
1102
+ "type": "string",
1103
+ "minLength": 1,
1104
+ "maxLength": 128,
1105
+ "pattern": "^[A-Za-z_+-]+(?:/[A-Za-z0-9_+-]+)*$"
1106
+ },
1107
+ "layout": {
1108
+ "type": "object",
1109
+ "additionalProperties": false,
1110
+ "required": [
1111
+ "backgroundColor",
1112
+ "textColor",
1113
+ "fontFamily",
1114
+ "fontSize"
1115
+ ],
1116
+ "properties": {
1117
+ "backgroundColor": {
1118
+ "$ref": "https://baron.dev/kline-scene/common.schema.json#/$defs/rgbaColor"
1119
+ },
1120
+ "textColor": {
1121
+ "$ref": "https://baron.dev/kline-scene/common.schema.json#/$defs/rgbaColor"
1122
+ },
1123
+ "fontFamily": {
1124
+ "type": "string",
1125
+ "minLength": 1,
1126
+ "maxLength": 128
1127
+ },
1128
+ "fontSize": {
1129
+ "type": "number",
1130
+ "minimum": 8,
1131
+ "maximum": 32
1132
+ }
1133
+ }
1134
+ },
1135
+ "grid": {
1136
+ "type": "object",
1137
+ "additionalProperties": false,
1138
+ "required": [
1139
+ "horizontalColor",
1140
+ "verticalColor"
1141
+ ],
1142
+ "properties": {
1143
+ "horizontalColor": {
1144
+ "$ref": "https://baron.dev/kline-scene/common.schema.json#/$defs/rgbaColor"
1145
+ },
1146
+ "verticalColor": {
1147
+ "$ref": "https://baron.dev/kline-scene/common.schema.json#/$defs/rgbaColor"
1148
+ }
1149
+ }
1150
+ },
1151
+ "thousandsSeparator": {
1152
+ "enum": [
1153
+ "",
1154
+ ",",
1155
+ " ",
1156
+ "_"
1157
+ ]
1158
+ },
1159
+ "decimalFold": {
1160
+ "type": "object",
1161
+ "additionalProperties": false,
1162
+ "required": [
1163
+ "enabled",
1164
+ "threshold"
1165
+ ],
1166
+ "properties": {
1167
+ "enabled": {
1168
+ "type": "boolean"
1169
+ },
1170
+ "threshold": {
1171
+ "type": "integer",
1172
+ "minimum": 1,
1173
+ "maximum": 16
1174
+ }
1175
+ }
1176
+ },
1177
+ "zoomAnchor": {
1178
+ "enum": [
1179
+ "cursor",
1180
+ "right"
1181
+ ]
1182
+ },
1183
+ "dateFormat": {
1184
+ "enum": [
1185
+ "yyyy-MM-dd",
1186
+ "yyyy-MM-dd HH:mm",
1187
+ "yyyy-MM-dd HH:mm:ss"
1188
+ ]
1189
+ },
1190
+ "largeNumberFormat": {
1191
+ "enum": [
1192
+ "western",
1193
+ "chinese",
1194
+ "plain"
1195
+ ]
1196
+ }
1197
+ }
1198
+ };
1199
+ export const TimeSeriesSceneSchema = {
1200
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1201
+ "$id": "https://baron.dev/kline-scene/time-series-scene.schema.json",
1202
+ "title": "TimeSeriesScene",
1203
+ "type": "object",
1204
+ "additionalProperties": false,
1205
+ "required": [
1206
+ "schema",
1207
+ "version",
1208
+ "runtime",
1209
+ "period",
1210
+ "series",
1211
+ "data",
1212
+ "chart",
1213
+ "viewport",
1214
+ "render",
1215
+ "metadata"
1216
+ ],
1217
+ "properties": {
1218
+ "schema": {
1219
+ "const": "@baron1996/time-series-scene"
1220
+ },
1221
+ "version": {
1222
+ "const": 1
1223
+ },
1224
+ "runtime": {
1225
+ "$ref": "https://baron.dev/kline-scene/time-series-runtime.schema.json"
1226
+ },
1227
+ "period": {
1228
+ "$ref": "#/$defs/timeSeriesPeriod"
1229
+ },
1230
+ "series": {
1231
+ "type": "array",
1232
+ "minItems": 1,
1233
+ "maxItems": 64,
1234
+ "items": {
1235
+ "$ref": "#/$defs/timeSeriesDefinition"
1236
+ }
1237
+ },
1238
+ "data": {
1239
+ "type": "array",
1240
+ "minItems": 1,
1241
+ "maxItems": 1000000,
1242
+ "items": {
1243
+ "$ref": "#/$defs/timeSeriesPoint"
1244
+ }
1245
+ },
1246
+ "chart": {
1247
+ "$ref": "https://baron.dev/kline-scene/time-series-chart-config.schema.json"
1248
+ },
1249
+ "viewport": {
1250
+ "$ref": "#/$defs/timeSeriesViewport"
1251
+ },
1252
+ "render": {
1253
+ "$ref": "#/$defs/timeSeriesRender"
1254
+ },
1255
+ "metadata": {
1256
+ "$ref": "#/$defs/metadata"
1257
+ }
1258
+ },
1259
+ "$defs": {
1260
+ "timeSeriesPeriod": {
1261
+ "type": "object",
1262
+ "additionalProperties": false,
1263
+ "required": [
1264
+ "span",
1265
+ "type"
1266
+ ],
1267
+ "properties": {
1268
+ "span": {
1269
+ "type": "integer",
1270
+ "minimum": 1,
1271
+ "maximum": 100000
1272
+ },
1273
+ "type": {
1274
+ "enum": [
1275
+ "second",
1276
+ "minute",
1277
+ "hour",
1278
+ "day",
1279
+ "week",
1280
+ "month",
1281
+ "year"
1282
+ ]
1283
+ }
1284
+ }
1285
+ },
1286
+ "timeSeriesDefinition": {
1287
+ "type": "object",
1288
+ "additionalProperties": false,
1289
+ "required": [
1290
+ "id",
1291
+ "name",
1292
+ "type",
1293
+ "unit",
1294
+ "precision",
1295
+ "visible",
1296
+ "style"
1297
+ ],
1298
+ "properties": {
1299
+ "id": {
1300
+ "type": "string",
1301
+ "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$"
1302
+ },
1303
+ "name": {
1304
+ "type": "string",
1305
+ "minLength": 1,
1306
+ "maxLength": 256
1307
+ },
1308
+ "type": {
1309
+ "const": "line"
1310
+ },
1311
+ "unit": {
1312
+ "type": "string",
1313
+ "minLength": 1,
1314
+ "maxLength": 64
1315
+ },
1316
+ "precision": {
1317
+ "type": "integer",
1318
+ "minimum": 0,
1319
+ "maximum": 16
1320
+ },
1321
+ "visible": {
1322
+ "type": "boolean"
1323
+ },
1324
+ "style": {
1325
+ "$ref": "https://baron.dev/kline-scene/common.schema.json#/$defs/lineStyle"
1326
+ }
1327
+ }
1328
+ },
1329
+ "timeSeriesPoint": {
1330
+ "type": "object",
1331
+ "additionalProperties": false,
1332
+ "required": [
1333
+ "timestamp",
1334
+ "values"
1335
+ ],
1336
+ "properties": {
1337
+ "timestamp": {
1338
+ "type": "integer",
1339
+ "minimum": 1,
1340
+ "maximum": 9007199254740991
1341
+ },
1342
+ "values": {
1343
+ "type": "object",
1344
+ "minProperties": 1,
1345
+ "maxProperties": 64,
1346
+ "propertyNames": {
1347
+ "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$"
1348
+ },
1349
+ "additionalProperties": {
1350
+ "oneOf": [
1351
+ {
1352
+ "$ref": "https://baron.dev/kline-scene/common.schema.json#/$defs/finiteNumber"
1353
+ },
1354
+ {
1355
+ "type": "null"
1356
+ }
1357
+ ]
1358
+ }
1359
+ }
1360
+ }
1361
+ },
1362
+ "timeSeriesViewport": {
1363
+ "type": "object",
1364
+ "additionalProperties": false,
1365
+ "required": [
1366
+ "barSpace",
1367
+ "rightOffsetDistance",
1368
+ "anchorTimestamp"
1369
+ ],
1370
+ "properties": {
1371
+ "barSpace": {
1372
+ "type": "number",
1373
+ "minimum": 1,
1374
+ "maximum": 100
1375
+ },
1376
+ "rightOffsetDistance": {
1377
+ "type": "number",
1378
+ "minimum": 0,
1379
+ "maximum": 10000
1380
+ },
1381
+ "anchorTimestamp": {
1382
+ "type": "integer",
1383
+ "minimum": 1,
1384
+ "maximum": 9007199254740991
1385
+ }
1386
+ }
1387
+ },
1388
+ "timeSeriesRender": {
1389
+ "type": "object",
1390
+ "additionalProperties": false,
1391
+ "required": [
1392
+ "width",
1393
+ "height",
1394
+ "deviceScaleFactor",
1395
+ "background",
1396
+ "fontFamily",
1397
+ "timeoutMs"
1398
+ ],
1399
+ "properties": {
1400
+ "width": {
1401
+ "type": "integer",
1402
+ "minimum": 320,
1403
+ "maximum": 8192
1404
+ },
1405
+ "height": {
1406
+ "type": "integer",
1407
+ "minimum": 240,
1408
+ "maximum": 8192
1409
+ },
1410
+ "deviceScaleFactor": {
1411
+ "type": "number",
1412
+ "minimum": 0.5,
1413
+ "maximum": 4
1414
+ },
1415
+ "background": {
1416
+ "$ref": "https://baron.dev/kline-scene/common.schema.json#/$defs/rgbaColor"
1417
+ },
1418
+ "fontFamily": {
1419
+ "const": "Baron Sans"
1420
+ },
1421
+ "timeoutMs": {
1422
+ "type": "integer",
1423
+ "minimum": 100,
1424
+ "maximum": 120000
1425
+ }
1426
+ }
1427
+ },
1428
+ "metadata": {
1429
+ "type": "object",
1430
+ "maxProperties": 64,
1431
+ "propertyNames": {
1432
+ "type": "string",
1433
+ "minLength": 1,
1434
+ "maxLength": 128
1435
+ },
1436
+ "additionalProperties": {
1437
+ "oneOf": [
1438
+ {
1439
+ "type": "null"
1440
+ },
1441
+ {
1442
+ "type": "boolean"
1443
+ },
1444
+ {
1445
+ "$ref": "https://baron.dev/kline-scene/common.schema.json#/$defs/finiteNumber"
1446
+ },
1447
+ {
1448
+ "type": "string"
1449
+ }
1450
+ ]
1451
+ }
1452
+ }
1453
+ }
1454
+ };
@@ -0,0 +1,88 @@
1
+ export interface TimeSeriesScene {
2
+ schema: '@baron1996/time-series-scene';
3
+ version: 1;
4
+ runtime: TimeSeriesRuntimeIdentity;
5
+ period: TimeSeriesPeriod;
6
+ /**
7
+ * @minItems 1
8
+ * @maxItems 64
9
+ */
10
+ series: [TimeSeriesDefinition, ...TimeSeriesDefinition[]];
11
+ /**
12
+ * @minItems 1
13
+ * @maxItems 1000000
14
+ */
15
+ data: [TimeSeriesPoint, ...TimeSeriesPoint[]];
16
+ chart: TimeSeriesChartConfig;
17
+ viewport: TimeSeriesViewport;
18
+ render: TimeSeriesRender;
19
+ metadata: TimeSeriesMetadata;
20
+ }
21
+ export interface TimeSeriesRuntimeIdentity {
22
+ engine: 'klinecharts';
23
+ engineVersion: '10.0.0';
24
+ runtimeVersion: '0.1.0';
25
+ }
26
+ export interface TimeSeriesPeriod {
27
+ span: number;
28
+ type: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
29
+ }
30
+ export interface TimeSeriesDefinition {
31
+ id: string;
32
+ name: string;
33
+ type: 'line';
34
+ unit: string;
35
+ precision: number;
36
+ visible: boolean;
37
+ style: {
38
+ color: string;
39
+ size: number;
40
+ style: 'solid' | 'dashed' | 'dotted';
41
+ };
42
+ }
43
+ export interface TimeSeriesPoint {
44
+ timestamp: number;
45
+ values: {
46
+ [k: string]: (number | null) | undefined;
47
+ };
48
+ }
49
+ export interface TimeSeriesChartConfig {
50
+ locale: string;
51
+ timezone: string;
52
+ layout: {
53
+ backgroundColor: string;
54
+ textColor: string;
55
+ fontFamily: string;
56
+ fontSize: number;
57
+ };
58
+ grid: {
59
+ horizontalColor: string;
60
+ verticalColor: string;
61
+ };
62
+ thousandsSeparator: '' | ',' | ' ' | '_';
63
+ decimalFold: {
64
+ enabled: boolean;
65
+ threshold: number;
66
+ };
67
+ zoomAnchor: 'cursor' | 'right';
68
+ dateFormat: 'yyyy-MM-dd' | 'yyyy-MM-dd HH:mm' | 'yyyy-MM-dd HH:mm:ss';
69
+ largeNumberFormat: 'western' | 'chinese' | 'plain';
70
+ }
71
+ export interface TimeSeriesViewport {
72
+ barSpace: number;
73
+ rightOffsetDistance: number;
74
+ anchorTimestamp: number;
75
+ }
76
+ export interface TimeSeriesRender {
77
+ width: number;
78
+ height: number;
79
+ deviceScaleFactor: number;
80
+ background: string;
81
+ fontFamily: 'Baron Sans';
82
+ timeoutMs: number;
83
+ }
84
+ export type TimeSeriesMetadataValue = null | boolean | number | string;
85
+ export interface TimeSeriesMetadata {
86
+ [key: string]: TimeSeriesMetadataValue | undefined;
87
+ }
88
+ //# sourceMappingURL=time-series-scene.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-series-scene.d.ts","sourceRoot":"","sources":["../../src/generated/time-series-scene.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,8BAA8B,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,yBAAyB,CAAC;IACnC,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;OAGG;IACH,MAAM,EAAE,CAAC,oBAAoB,EAAE,GAAG,oBAAoB,EAAE,CAAC,CAAC;IAC1D;;;OAGG;IACH,IAAI,EAAE,CAAC,eAAe,EAAE,GAAG,eAAe,EAAE,CAAC,CAAC;IAC9C,KAAK,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,kBAAkB,CAAC;CAC7B;AACD,MAAM,WAAW,yBAAyB;IACzC,MAAM,EAAE,aAAa,CAAC;IACtB,aAAa,EAAE,QAAQ,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;CACxB;AACD,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG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,WAAW,kBAAkB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;CACxB;AACD,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,YAAY,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AACvE,MAAM,WAAW,kBAAkB;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS,CAAC;CACnD"}
@@ -0,0 +1,2 @@
1
+ /* Generated by scripts/generate.mjs. Do not edit. */
2
+ export {};
@@ -0,0 +1,15 @@
1
+ export declare const validateTimeSeriesScene: typeof validate20;
2
+ declare function validate20(data: any, { instancePath, parentData, parentDataProperty, rootData, dynamicAnchors }?: {
3
+ instancePath?: string | undefined;
4
+ rootData?: any;
5
+ dynamicAnchors?: {} | undefined;
6
+ }): boolean;
7
+ declare namespace validate20 {
8
+ var evaluated: {
9
+ props: boolean;
10
+ dynamicProps: boolean;
11
+ dynamicItems: boolean;
12
+ };
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=validate-time-series-scene.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-time-series-scene.d.ts","sourceRoot":"","sources":["../../src/generated/validate-time-series-scene.ts"],"names":[],"mappings":"AACa,eAAO,MAAM,uBAAuB,mBAAa,CAAC;AAAkx1D,iBAAS,UAAU,CAAC,IAAI,KAAA,EAAE,EAAC,YAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,QAAa,EAAE,cAAiB,EAAC;;;;CAAG,WAAiykB;kBAAx4kB,UAAU"}