@keneth80/k-chart 1.18.1 → 1.20.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/CHANGELOG.md +33 -0
- package/README.md +30 -3
- package/ai/catalog.json +2291 -0
- package/ai/chart-plan.schema.json +372 -0
- package/ai/examples/intent-to-config.jsonl +32 -0
- package/ai/prompts/dashboard-system.md +42 -0
- package/docs/ai/agent-usage.md +79 -0
- package/docs/ai/chart-selection.md +65 -0
- package/docs/ai/index.md +195 -0
- package/docs/configuration-reference.md +34 -4
- package/docs/functional-api.md +27 -2
- package/examples/stackblitz-realtime-line-basic/src/main.ts +6 -0
- package/lib/ai/catalog.d.ts +4 -0
- package/lib/ai/catalog.d.ts.map +1 -0
- package/lib/ai/catalog.js +676 -0
- package/lib/ai/catalog.js.map +1 -0
- package/lib/ai/compiler.d.ts +63 -0
- package/lib/ai/compiler.d.ts.map +1 -0
- package/lib/ai/compiler.js +950 -0
- package/lib/ai/compiler.js.map +1 -0
- package/lib/ai/contracts.d.ts +117 -0
- package/lib/ai/contracts.d.ts.map +1 -0
- package/lib/ai/contracts.js +3 -0
- package/lib/ai/contracts.js.map +1 -0
- package/lib/ai/index.d.ts +6 -0
- package/lib/ai/index.d.ts.map +1 -0
- package/lib/ai/index.js +22 -0
- package/lib/ai/index.js.map +1 -0
- package/lib/ai/schema.d.ts +272 -0
- package/lib/ai/schema.d.ts.map +1 -0
- package/lib/ai/schema.js +199 -0
- package/lib/ai/schema.js.map +1 -0
- package/lib/ai/validate-plan.d.ts +5 -0
- package/lib/ai/validate-plan.d.ts.map +1 -0
- package/lib/ai/validate-plan.js +877 -0
- package/lib/ai/validate-plan.js.map +1 -0
- package/lib/core/animation.d.ts +8 -0
- package/lib/core/animation.d.ts.map +1 -0
- package/lib/core/animation.js +66 -0
- package/lib/core/animation.js.map +1 -0
- package/lib/core/contracts.d.ts +2 -0
- package/lib/core/contracts.d.ts.map +1 -1
- package/lib/core/create-kchart.d.ts.map +1 -1
- package/lib/core/create-kchart.js +82 -10
- package/lib/core/create-kchart.js.map +1 -1
- package/lib/series/canvas-line.d.ts.map +1 -1
- package/lib/series/canvas-line.js +68 -64
- package/lib/series/canvas-line.js.map +1 -1
- package/lib/series/svg-line.d.ts.map +1 -1
- package/lib/series/svg-line.js +1 -0
- package/lib/series/svg-line.js.map +1 -1
- package/lib/series/webgl-line.d.ts.map +1 -1
- package/lib/series/webgl-line.js +75 -71
- package/lib/series/webgl-line.js.map +1 -1
- package/lib/worker/render-worker.d.ts.map +1 -1
- package/lib/worker/render-worker.js +18 -6
- package/lib/worker/render-worker.js.map +1 -1
- package/llms.txt +37 -0
- package/package.json +19 -4
|
@@ -0,0 +1,877 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listKChartAICapabilityIds = exports.assertKChartAIPlan = exports.validateKChartAIPlan = void 0;
|
|
4
|
+
var catalog_1 = require("./catalog");
|
|
5
|
+
var topLevelKeys = [
|
|
6
|
+
'version',
|
|
7
|
+
'intent',
|
|
8
|
+
'title',
|
|
9
|
+
'data',
|
|
10
|
+
'axes',
|
|
11
|
+
'series',
|
|
12
|
+
'adapters',
|
|
13
|
+
'options',
|
|
14
|
+
'theme',
|
|
15
|
+
'rationale',
|
|
16
|
+
'warnings'
|
|
17
|
+
];
|
|
18
|
+
var fieldTypes = new Set([
|
|
19
|
+
'number',
|
|
20
|
+
'number-array',
|
|
21
|
+
'time',
|
|
22
|
+
'string',
|
|
23
|
+
'boolean',
|
|
24
|
+
'latitude',
|
|
25
|
+
'longitude',
|
|
26
|
+
'geojson',
|
|
27
|
+
'url'
|
|
28
|
+
]);
|
|
29
|
+
var rendererIds = new Set(['svg', 'canvas', 'webgl']);
|
|
30
|
+
var axisTypes = new Set(['number', 'time', 'string', 'point']);
|
|
31
|
+
var axisPlacements = new Set(['top', 'right', 'bottom', 'left']);
|
|
32
|
+
var themes = new Set(['dark', 'light']);
|
|
33
|
+
var dangerousSettingKeys = new Set(['__proto__', 'prototype', 'constructor']);
|
|
34
|
+
var numericSettingKeys = new Set([
|
|
35
|
+
'strokeWidth',
|
|
36
|
+
'lineWidth',
|
|
37
|
+
'fontSize',
|
|
38
|
+
'fontWeight',
|
|
39
|
+
'fillOpacity',
|
|
40
|
+
'opacity',
|
|
41
|
+
'radius',
|
|
42
|
+
'markerRadius',
|
|
43
|
+
'pointSize',
|
|
44
|
+
'duration',
|
|
45
|
+
'threshold',
|
|
46
|
+
'barRatio',
|
|
47
|
+
'barRadius',
|
|
48
|
+
'innerRadiusRatio',
|
|
49
|
+
'minRadius',
|
|
50
|
+
'maxRadius',
|
|
51
|
+
'candleWidth',
|
|
52
|
+
'minCandleWidth',
|
|
53
|
+
'maxCandleWidth',
|
|
54
|
+
'gap',
|
|
55
|
+
'thickness',
|
|
56
|
+
'zoomScale',
|
|
57
|
+
'focusZoom',
|
|
58
|
+
'mapZoomThreshold',
|
|
59
|
+
'globeZoomThreshold'
|
|
60
|
+
]);
|
|
61
|
+
var booleanSettingKeys = new Set([
|
|
62
|
+
'visible',
|
|
63
|
+
'enabled',
|
|
64
|
+
'selectable',
|
|
65
|
+
'dot',
|
|
66
|
+
'wheelZoom',
|
|
67
|
+
'gestureZoom',
|
|
68
|
+
'resetOnDoubleClick',
|
|
69
|
+
'respectReducedMotion',
|
|
70
|
+
'draggable',
|
|
71
|
+
'autoMapOnZoom',
|
|
72
|
+
'resetControl',
|
|
73
|
+
'graticuleVisible',
|
|
74
|
+
'landVisible',
|
|
75
|
+
'countryBordersVisible'
|
|
76
|
+
]);
|
|
77
|
+
var pushIssue = function (issues, issue) {
|
|
78
|
+
issues.push(issue);
|
|
79
|
+
};
|
|
80
|
+
var isRecord = function (value) {
|
|
81
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
82
|
+
};
|
|
83
|
+
var validateJsonSettingValue = function (value, path, issues, seen) {
|
|
84
|
+
if (seen === void 0) { seen = new Set(); }
|
|
85
|
+
if (value === null
|
|
86
|
+
|| typeof value === 'string'
|
|
87
|
+
|| typeof value === 'boolean') {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (typeof value === 'number') {
|
|
91
|
+
if (!Number.isFinite(value)) {
|
|
92
|
+
pushIssue(issues, {
|
|
93
|
+
code: 'invalid-plan',
|
|
94
|
+
path: path,
|
|
95
|
+
message: 'Settings numbers must be finite JSON numbers.',
|
|
96
|
+
severity: 'error'
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (typeof value !== 'object') {
|
|
102
|
+
pushIssue(issues, {
|
|
103
|
+
code: 'invalid-plan',
|
|
104
|
+
path: path,
|
|
105
|
+
message: 'Settings must contain JSON-safe values only.',
|
|
106
|
+
severity: 'error'
|
|
107
|
+
});
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (seen.has(value)) {
|
|
111
|
+
pushIssue(issues, {
|
|
112
|
+
code: 'invalid-plan',
|
|
113
|
+
path: path,
|
|
114
|
+
message: 'Settings must not contain circular references.',
|
|
115
|
+
severity: 'error'
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
seen.add(value);
|
|
120
|
+
if (Array.isArray(value)) {
|
|
121
|
+
value.forEach(function (item, index) {
|
|
122
|
+
validateJsonSettingValue(item, "".concat(path, "[").concat(index, "]"), issues, seen);
|
|
123
|
+
});
|
|
124
|
+
seen.delete(value);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
var prototype = Object.getPrototypeOf(value);
|
|
128
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
129
|
+
pushIssue(issues, {
|
|
130
|
+
code: 'invalid-plan',
|
|
131
|
+
path: path,
|
|
132
|
+
message: 'Settings objects must be plain JSON objects.',
|
|
133
|
+
severity: 'error'
|
|
134
|
+
});
|
|
135
|
+
seen.delete(value);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
Object.entries(value).forEach(function (_a) {
|
|
139
|
+
var key = _a[0], item = _a[1];
|
|
140
|
+
if (dangerousSettingKeys.has(key)) {
|
|
141
|
+
pushIssue(issues, {
|
|
142
|
+
code: 'invalid-plan',
|
|
143
|
+
path: "".concat(path, ".").concat(key),
|
|
144
|
+
message: "Settings key \"".concat(key, "\" is not allowed."),
|
|
145
|
+
severity: 'error'
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
validateJsonSettingValue(item, "".concat(path, ".").concat(key), issues, seen);
|
|
150
|
+
});
|
|
151
|
+
seen.delete(value);
|
|
152
|
+
};
|
|
153
|
+
var validateKnownSettingTypes = function (settings, path, issues, seen) {
|
|
154
|
+
if (seen === void 0) { seen = new Set(); }
|
|
155
|
+
if (seen.has(settings)) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
seen.add(settings);
|
|
159
|
+
Object.entries(settings).forEach(function (_a) {
|
|
160
|
+
var key = _a[0], value = _a[1];
|
|
161
|
+
var valuePath = "".concat(path, ".").concat(key);
|
|
162
|
+
if (numericSettingKeys.has(key)
|
|
163
|
+
&& (typeof value !== 'number' || !Number.isFinite(value))) {
|
|
164
|
+
pushIssue(issues, {
|
|
165
|
+
code: 'invalid-plan',
|
|
166
|
+
path: valuePath,
|
|
167
|
+
message: "".concat(key, " must be a finite number."),
|
|
168
|
+
severity: 'error'
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (booleanSettingKeys.has(key) && typeof value !== 'boolean') {
|
|
172
|
+
pushIssue(issues, {
|
|
173
|
+
code: 'invalid-plan',
|
|
174
|
+
path: valuePath,
|
|
175
|
+
message: "".concat(key, " must be a boolean."),
|
|
176
|
+
severity: 'error'
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (key === 'scaleExtent'
|
|
180
|
+
&& (!Array.isArray(value)
|
|
181
|
+
|| value.length !== 2
|
|
182
|
+
|| value.some(function (item) { return typeof item !== 'number' || !Number.isFinite(item); }))) {
|
|
183
|
+
pushIssue(issues, {
|
|
184
|
+
code: 'invalid-plan',
|
|
185
|
+
path: valuePath,
|
|
186
|
+
message: 'scaleExtent must contain two finite numbers.',
|
|
187
|
+
severity: 'error'
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (key === 'direction'
|
|
191
|
+
&& value !== 'x'
|
|
192
|
+
&& value !== 'y'
|
|
193
|
+
&& value !== 'both') {
|
|
194
|
+
pushIssue(issues, {
|
|
195
|
+
code: 'invalid-plan',
|
|
196
|
+
path: valuePath,
|
|
197
|
+
message: 'direction must be "x", "y", or "both".',
|
|
198
|
+
severity: 'error'
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (isRecord(value)) {
|
|
202
|
+
validateKnownSettingTypes(value, valuePath, issues, seen);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
seen.delete(settings);
|
|
206
|
+
};
|
|
207
|
+
var reportUnknownKeys = function (value, allowedKeys, path, issues) {
|
|
208
|
+
Object.keys(value).forEach(function (key) {
|
|
209
|
+
if (!allowedKeys.includes(key)) {
|
|
210
|
+
pushIssue(issues, {
|
|
211
|
+
code: 'unknown-property',
|
|
212
|
+
path: "".concat(path, ".").concat(key),
|
|
213
|
+
message: "Unknown property \"".concat(key, "\"."),
|
|
214
|
+
severity: 'error'
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
var validateBindings = function (capability, bindings, fields, path, issues) {
|
|
220
|
+
var roles = new Map(capability.fieldRoles.map(function (role) { return [role.id, role]; }));
|
|
221
|
+
var boundRoles = new Set();
|
|
222
|
+
bindings.forEach(function (binding, bindingIndex) {
|
|
223
|
+
var bindingPath = "".concat(path, ".bindings[").concat(bindingIndex, "]");
|
|
224
|
+
if (!isRecord(binding)) {
|
|
225
|
+
pushIssue(issues, {
|
|
226
|
+
code: 'invalid-binding',
|
|
227
|
+
path: bindingPath,
|
|
228
|
+
message: 'Binding must be an object.',
|
|
229
|
+
severity: 'error'
|
|
230
|
+
});
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
reportUnknownKeys(binding, ['role', 'field', 'fields'], bindingPath, issues);
|
|
234
|
+
if (typeof binding.role !== 'string' || binding.role.length === 0) {
|
|
235
|
+
pushIssue(issues, {
|
|
236
|
+
code: 'invalid-binding',
|
|
237
|
+
path: "".concat(bindingPath, ".role"),
|
|
238
|
+
message: 'Binding role must be a non-empty string.',
|
|
239
|
+
severity: 'error'
|
|
240
|
+
});
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
var role = roles.get(binding.role);
|
|
244
|
+
if (!role) {
|
|
245
|
+
pushIssue(issues, {
|
|
246
|
+
code: 'invalid-binding',
|
|
247
|
+
path: "".concat(bindingPath, ".role"),
|
|
248
|
+
message: "Role \"".concat(binding.role, "\" is not supported by ").concat(capability.id, "."),
|
|
249
|
+
severity: 'error'
|
|
250
|
+
});
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
boundRoles.add(binding.role);
|
|
254
|
+
var hasField = typeof binding.field === 'string' && binding.field.length > 0;
|
|
255
|
+
var hasFields = Array.isArray(binding.fields)
|
|
256
|
+
&& binding.fields.length > 0
|
|
257
|
+
&& binding.fields.every(function (field) { return typeof field === 'string' && field.length > 0; });
|
|
258
|
+
var values = hasFields
|
|
259
|
+
? binding.fields
|
|
260
|
+
: hasField
|
|
261
|
+
? [binding.field]
|
|
262
|
+
: [];
|
|
263
|
+
if (values.length === 0 || (binding.field !== undefined && binding.fields !== undefined)) {
|
|
264
|
+
pushIssue(issues, {
|
|
265
|
+
code: 'invalid-binding',
|
|
266
|
+
path: bindingPath,
|
|
267
|
+
message: 'A binding must contain exactly one of "field" or "fields".',
|
|
268
|
+
severity: 'error'
|
|
269
|
+
});
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (!role.multiple && values.length > 1) {
|
|
273
|
+
pushIssue(issues, {
|
|
274
|
+
code: 'invalid-binding',
|
|
275
|
+
path: bindingPath,
|
|
276
|
+
message: "Role \"".concat(binding.role, "\" accepts only one field."),
|
|
277
|
+
severity: 'error'
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
values.forEach(function (field) {
|
|
281
|
+
var fieldType = fields.get(field);
|
|
282
|
+
if (!fieldType) {
|
|
283
|
+
pushIssue(issues, {
|
|
284
|
+
code: 'unknown-field',
|
|
285
|
+
path: bindingPath,
|
|
286
|
+
message: "Field \"".concat(field, "\" is not declared in plan.data.fields."),
|
|
287
|
+
severity: 'error'
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
else if (!role.types.includes(fieldType)) {
|
|
291
|
+
pushIssue(issues, {
|
|
292
|
+
code: 'field-type-mismatch',
|
|
293
|
+
path: bindingPath,
|
|
294
|
+
message: "Role \"".concat(binding.role, "\" expects ").concat(role.types.join(' or '), ", but \"").concat(field, "\" is ").concat(fieldType, "."),
|
|
295
|
+
severity: 'error'
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
capability.fieldRoles
|
|
301
|
+
.filter(function (role) { return role.required; })
|
|
302
|
+
.forEach(function (role) {
|
|
303
|
+
if (!boundRoles.has(role.id)) {
|
|
304
|
+
pushIssue(issues, {
|
|
305
|
+
code: 'missing-binding',
|
|
306
|
+
path: path,
|
|
307
|
+
message: "".concat(capability.id, " requires a \"").concat(role.id, "\" field binding."),
|
|
308
|
+
severity: 'error'
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
var validateKChartAIPlan = function (input) {
|
|
314
|
+
var issues = [];
|
|
315
|
+
if (!isRecord(input)) {
|
|
316
|
+
return {
|
|
317
|
+
valid: false,
|
|
318
|
+
issues: [{
|
|
319
|
+
code: 'invalid-plan',
|
|
320
|
+
path: '$',
|
|
321
|
+
message: 'ChartPlan must be an object.',
|
|
322
|
+
severity: 'error'
|
|
323
|
+
}]
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
reportUnknownKeys(input, topLevelKeys, '$', issues);
|
|
327
|
+
if (input.version !== 1) {
|
|
328
|
+
pushIssue(issues, {
|
|
329
|
+
code: 'invalid-plan',
|
|
330
|
+
path: '$.version',
|
|
331
|
+
message: 'ChartPlan version must be 1.',
|
|
332
|
+
severity: 'error'
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
if (typeof input.intent !== 'string' || input.intent.trim().length === 0) {
|
|
336
|
+
pushIssue(issues, {
|
|
337
|
+
code: 'invalid-plan',
|
|
338
|
+
path: '$.intent',
|
|
339
|
+
message: 'ChartPlan intent must be a non-empty string.',
|
|
340
|
+
severity: 'error'
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
if (input.title !== undefined && typeof input.title !== 'string') {
|
|
344
|
+
pushIssue(issues, {
|
|
345
|
+
code: 'invalid-plan',
|
|
346
|
+
path: '$.title',
|
|
347
|
+
message: 'ChartPlan title must be a string.',
|
|
348
|
+
severity: 'error'
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
if (input.theme !== undefined && !themes.has(input.theme)) {
|
|
352
|
+
pushIssue(issues, {
|
|
353
|
+
code: 'invalid-plan',
|
|
354
|
+
path: '$.theme',
|
|
355
|
+
message: 'ChartPlan theme must be "dark" or "light".',
|
|
356
|
+
severity: 'error'
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
for (var _i = 0, _a = ['rationale', 'warnings']; _i < _a.length; _i++) {
|
|
360
|
+
var key = _a[_i];
|
|
361
|
+
var value = input[key];
|
|
362
|
+
if (value !== undefined
|
|
363
|
+
&& (!Array.isArray(value) || !value.every(function (item) { return typeof item === 'string'; }))) {
|
|
364
|
+
pushIssue(issues, {
|
|
365
|
+
code: 'invalid-plan',
|
|
366
|
+
path: "$.".concat(key),
|
|
367
|
+
message: "".concat(key, " must be an array of strings."),
|
|
368
|
+
severity: 'error'
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
var data = input.data;
|
|
373
|
+
var dataRecord = isRecord(data) ? data : undefined;
|
|
374
|
+
var declaredFieldTypes = new Map();
|
|
375
|
+
if (!dataRecord || dataRecord.shape !== 'records' || !Array.isArray(dataRecord.fields)) {
|
|
376
|
+
pushIssue(issues, {
|
|
377
|
+
code: 'invalid-plan',
|
|
378
|
+
path: '$.data',
|
|
379
|
+
message: 'ChartPlan data must declare record-shaped fields.',
|
|
380
|
+
severity: 'error'
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
reportUnknownKeys(dataRecord, ['shape', 'fields', 'rowCount'], '$.data', issues);
|
|
385
|
+
if (dataRecord.rowCount !== undefined
|
|
386
|
+
&& (typeof dataRecord.rowCount !== 'number'
|
|
387
|
+
|| !Number.isInteger(dataRecord.rowCount)
|
|
388
|
+
|| dataRecord.rowCount < 0)) {
|
|
389
|
+
pushIssue(issues, {
|
|
390
|
+
code: 'invalid-plan',
|
|
391
|
+
path: '$.data.rowCount',
|
|
392
|
+
message: 'rowCount must be a non-negative integer.',
|
|
393
|
+
severity: 'error'
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
dataRecord.fields.forEach(function (rawField, index) {
|
|
397
|
+
var path = "$.data.fields[".concat(index, "]");
|
|
398
|
+
if (!isRecord(rawField)) {
|
|
399
|
+
pushIssue(issues, {
|
|
400
|
+
code: 'invalid-plan',
|
|
401
|
+
path: path,
|
|
402
|
+
message: 'Data field must be an object.',
|
|
403
|
+
severity: 'error'
|
|
404
|
+
});
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
reportUnknownKeys(rawField, ['name', 'type', 'nullable', 'sampleValues'], path, issues);
|
|
408
|
+
if (typeof rawField.name !== 'string' || typeof rawField.type !== 'string') {
|
|
409
|
+
pushIssue(issues, {
|
|
410
|
+
code: 'invalid-plan',
|
|
411
|
+
path: path,
|
|
412
|
+
message: 'Data field requires string name and type values.',
|
|
413
|
+
severity: 'error'
|
|
414
|
+
});
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
if (rawField.name.length === 0) {
|
|
418
|
+
pushIssue(issues, {
|
|
419
|
+
code: 'invalid-plan',
|
|
420
|
+
path: "".concat(path, ".name"),
|
|
421
|
+
message: 'Data field name must not be empty.',
|
|
422
|
+
severity: 'error'
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
if (rawField.nullable !== undefined && typeof rawField.nullable !== 'boolean') {
|
|
426
|
+
pushIssue(issues, {
|
|
427
|
+
code: 'invalid-plan',
|
|
428
|
+
path: "".concat(path, ".nullable"),
|
|
429
|
+
message: 'nullable must be a boolean.',
|
|
430
|
+
severity: 'error'
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
if (rawField.sampleValues !== undefined) {
|
|
434
|
+
var validSamples = Array.isArray(rawField.sampleValues)
|
|
435
|
+
&& rawField.sampleValues.length <= 8
|
|
436
|
+
&& rawField.sampleValues.every(function (sample) {
|
|
437
|
+
return sample === null
|
|
438
|
+
|| ['string', 'number', 'boolean'].includes(typeof sample)
|
|
439
|
+
|| (Array.isArray(sample)
|
|
440
|
+
&& sample.every(function (item) { return typeof item === 'number'; }));
|
|
441
|
+
});
|
|
442
|
+
if (!validSamples) {
|
|
443
|
+
pushIssue(issues, {
|
|
444
|
+
code: 'invalid-plan',
|
|
445
|
+
path: "".concat(path, ".sampleValues"),
|
|
446
|
+
message: 'sampleValues must contain at most eight JSON-safe primitive or number-array values.',
|
|
447
|
+
severity: 'error'
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (!fieldTypes.has(rawField.type)) {
|
|
452
|
+
pushIssue(issues, {
|
|
453
|
+
code: 'invalid-plan',
|
|
454
|
+
path: "".concat(path, ".type"),
|
|
455
|
+
message: "Unknown data field type \"".concat(rawField.type, "\"."),
|
|
456
|
+
severity: 'error'
|
|
457
|
+
});
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
if (declaredFieldTypes.has(rawField.name)) {
|
|
461
|
+
pushIssue(issues, {
|
|
462
|
+
code: 'invalid-plan',
|
|
463
|
+
path: "".concat(path, ".name"),
|
|
464
|
+
message: "Duplicate data field \"".concat(rawField.name, "\"."),
|
|
465
|
+
severity: 'error'
|
|
466
|
+
});
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
declaredFieldTypes.set(rawField.name, rawField.type);
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
if (input.series !== undefined
|
|
473
|
+
&& (!Array.isArray(input.series) || input.series.length === 0)) {
|
|
474
|
+
pushIssue(issues, {
|
|
475
|
+
code: 'invalid-plan',
|
|
476
|
+
path: '$.series',
|
|
477
|
+
message: 'series must be a non-empty array when provided.',
|
|
478
|
+
severity: 'error'
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
else if (Array.isArray(input.series)) {
|
|
482
|
+
input.series.forEach(function (rawSeries, index) {
|
|
483
|
+
var _a;
|
|
484
|
+
var path = "$.series[".concat(index, "]");
|
|
485
|
+
if (!isRecord(rawSeries)) {
|
|
486
|
+
pushIssue(issues, {
|
|
487
|
+
code: 'invalid-plan',
|
|
488
|
+
path: path,
|
|
489
|
+
message: 'Series plan must be an object.',
|
|
490
|
+
severity: 'error'
|
|
491
|
+
});
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
reportUnknownKeys(rawSeries, ['capability', 'renderer', 'bindings', 'displayName', 'settings'], path, issues);
|
|
495
|
+
if (rawSeries.displayName !== undefined
|
|
496
|
+
&& typeof rawSeries.displayName !== 'string') {
|
|
497
|
+
pushIssue(issues, {
|
|
498
|
+
code: 'invalid-plan',
|
|
499
|
+
path: "".concat(path, ".displayName"),
|
|
500
|
+
message: 'displayName must be a string.',
|
|
501
|
+
severity: 'error'
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
if (rawSeries.settings !== undefined && !isRecord(rawSeries.settings)) {
|
|
505
|
+
pushIssue(issues, {
|
|
506
|
+
code: 'invalid-plan',
|
|
507
|
+
path: "".concat(path, ".settings"),
|
|
508
|
+
message: 'settings must be an object.',
|
|
509
|
+
severity: 'error'
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
else if (rawSeries.settings !== undefined) {
|
|
513
|
+
validateJsonSettingValue(rawSeries.settings, "".concat(path, ".settings"), issues);
|
|
514
|
+
validateKnownSettingTypes(rawSeries.settings, "".concat(path, ".settings"), issues);
|
|
515
|
+
}
|
|
516
|
+
var capabilityId = typeof rawSeries.capability === 'string'
|
|
517
|
+
? rawSeries.capability
|
|
518
|
+
: '';
|
|
519
|
+
var capability = (0, catalog_1.findKChartAICapability)(capabilityId);
|
|
520
|
+
if (!capability
|
|
521
|
+
|| !['series', 'preset', 'recipe'].includes(capability.kind)) {
|
|
522
|
+
pushIssue(issues, {
|
|
523
|
+
code: 'unknown-capability',
|
|
524
|
+
path: "".concat(path, ".capability"),
|
|
525
|
+
message: "Unknown chart capability \"".concat(capabilityId, "\"."),
|
|
526
|
+
severity: 'error'
|
|
527
|
+
});
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
if (typeof rawSeries.renderer !== 'string'
|
|
531
|
+
|| !rendererIds.has(rawSeries.renderer)
|
|
532
|
+
|| !capability.renderers.includes(rawSeries.renderer)) {
|
|
533
|
+
pushIssue(issues, {
|
|
534
|
+
code: 'invalid-renderer',
|
|
535
|
+
path: "".concat(path, ".renderer"),
|
|
536
|
+
message: "".concat(capability.id, " supports: ").concat(capability.renderers.join(', '), "."),
|
|
537
|
+
severity: 'error'
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
var bindings = Array.isArray(rawSeries.bindings)
|
|
541
|
+
? rawSeries.bindings
|
|
542
|
+
: [];
|
|
543
|
+
if (!Array.isArray(rawSeries.bindings)) {
|
|
544
|
+
pushIssue(issues, {
|
|
545
|
+
code: 'invalid-binding',
|
|
546
|
+
path: "".concat(path, ".bindings"),
|
|
547
|
+
message: 'Series bindings must be an array.',
|
|
548
|
+
severity: 'error'
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
validateBindings(capability, bindings, declaredFieldTypes, path, issues);
|
|
553
|
+
}
|
|
554
|
+
var rowCount = typeof (dataRecord === null || dataRecord === void 0 ? void 0 : dataRecord.rowCount) === 'number'
|
|
555
|
+
? dataRecord.rowCount
|
|
556
|
+
: undefined;
|
|
557
|
+
if (rowCount !== undefined
|
|
558
|
+
&& ((_a = capability.rowCount) === null || _a === void 0 ? void 0 : _a.idealMax) !== undefined
|
|
559
|
+
&& rowCount > capability.rowCount.idealMax) {
|
|
560
|
+
pushIssue(issues, {
|
|
561
|
+
code: 'row-count-warning',
|
|
562
|
+
path: path,
|
|
563
|
+
message: "".concat(capability.id, " is ideally used at or below ").concat(capability.rowCount.idealMax.toLocaleString(), " rows."),
|
|
564
|
+
severity: 'warning'
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
if (input.adapters !== undefined && !Array.isArray(input.adapters)) {
|
|
570
|
+
pushIssue(issues, {
|
|
571
|
+
code: 'invalid-plan',
|
|
572
|
+
path: '$.adapters',
|
|
573
|
+
message: 'adapters must be an array.',
|
|
574
|
+
severity: 'error'
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
else if (Array.isArray(input.adapters)) {
|
|
578
|
+
if (input.adapters.length === 0) {
|
|
579
|
+
pushIssue(issues, {
|
|
580
|
+
code: 'invalid-plan',
|
|
581
|
+
path: '$.adapters',
|
|
582
|
+
message: 'adapters must not be empty when provided.',
|
|
583
|
+
severity: 'error'
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
input.adapters.forEach(function (rawAdapter, index) {
|
|
587
|
+
var path = "$.adapters[".concat(index, "]");
|
|
588
|
+
if (!isRecord(rawAdapter)) {
|
|
589
|
+
pushIssue(issues, {
|
|
590
|
+
code: 'invalid-plan',
|
|
591
|
+
path: path,
|
|
592
|
+
message: 'Adapter plan must be an object.',
|
|
593
|
+
severity: 'error'
|
|
594
|
+
});
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
reportUnknownKeys(rawAdapter, ['capability', 'bindings', 'settings'], path, issues);
|
|
598
|
+
var capabilityId = typeof rawAdapter.capability === 'string'
|
|
599
|
+
? rawAdapter.capability
|
|
600
|
+
: '';
|
|
601
|
+
var capability = (0, catalog_1.findKChartAICapability)(capabilityId);
|
|
602
|
+
if (!capability || capability.kind !== 'adapter') {
|
|
603
|
+
pushIssue(issues, {
|
|
604
|
+
code: 'unknown-capability',
|
|
605
|
+
path: "".concat(path, ".capability"),
|
|
606
|
+
message: "Unknown adapter capability \"".concat(capabilityId, "\"."),
|
|
607
|
+
severity: 'error'
|
|
608
|
+
});
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
if (rawAdapter.settings !== undefined && !isRecord(rawAdapter.settings)) {
|
|
612
|
+
pushIssue(issues, {
|
|
613
|
+
code: 'invalid-plan',
|
|
614
|
+
path: "".concat(path, ".settings"),
|
|
615
|
+
message: 'settings must be an object.',
|
|
616
|
+
severity: 'error'
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
else if (rawAdapter.settings !== undefined) {
|
|
620
|
+
validateJsonSettingValue(rawAdapter.settings, "".concat(path, ".settings"), issues);
|
|
621
|
+
}
|
|
622
|
+
var bindings = rawAdapter.bindings === undefined
|
|
623
|
+
? []
|
|
624
|
+
: Array.isArray(rawAdapter.bindings)
|
|
625
|
+
? rawAdapter.bindings
|
|
626
|
+
: [];
|
|
627
|
+
if (rawAdapter.bindings !== undefined && !Array.isArray(rawAdapter.bindings)) {
|
|
628
|
+
pushIssue(issues, {
|
|
629
|
+
code: 'invalid-binding',
|
|
630
|
+
path: "".concat(path, ".bindings"),
|
|
631
|
+
message: 'Adapter bindings must be an array.',
|
|
632
|
+
severity: 'error'
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
validateBindings(capability, bindings, declaredFieldTypes, path, issues);
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
if ((!Array.isArray(input.series) || input.series.length === 0)
|
|
641
|
+
&& (!Array.isArray(input.adapters) || input.adapters.length === 0)) {
|
|
642
|
+
pushIssue(issues, {
|
|
643
|
+
code: 'invalid-plan',
|
|
644
|
+
path: '$',
|
|
645
|
+
message: 'ChartPlan requires at least one series or adapter.',
|
|
646
|
+
severity: 'error'
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
if (input.axes !== undefined && !Array.isArray(input.axes)) {
|
|
650
|
+
pushIssue(issues, {
|
|
651
|
+
code: 'invalid-plan',
|
|
652
|
+
path: '$.axes',
|
|
653
|
+
message: 'axes must be an array.',
|
|
654
|
+
severity: 'error'
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
else if (Array.isArray(input.axes)) {
|
|
658
|
+
input.axes.forEach(function (rawAxis, index) {
|
|
659
|
+
if (!isRecord(rawAxis) || typeof rawAxis.field !== 'string') {
|
|
660
|
+
pushIssue(issues, {
|
|
661
|
+
code: 'invalid-plan',
|
|
662
|
+
path: "$.axes[".concat(index, "]"),
|
|
663
|
+
message: 'Axis requires field, type, and placement.',
|
|
664
|
+
severity: 'error'
|
|
665
|
+
});
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
reportUnknownKeys(rawAxis, ['field', 'type', 'placement', 'title', 'min', 'max', 'tickCount'], "$.axes[".concat(index, "]"), issues);
|
|
669
|
+
if (!axisTypes.has(rawAxis.type)
|
|
670
|
+
|| !axisPlacements.has(rawAxis.placement)) {
|
|
671
|
+
pushIssue(issues, {
|
|
672
|
+
code: 'invalid-plan',
|
|
673
|
+
path: "$.axes[".concat(index, "]"),
|
|
674
|
+
message: 'Axis type or placement is invalid.',
|
|
675
|
+
severity: 'error'
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
var declaredType = declaredFieldTypes.get(rawAxis.field);
|
|
679
|
+
var axisType = rawAxis.type;
|
|
680
|
+
var compatibleAxisType = declaredType === 'time'
|
|
681
|
+
? axisType === 'time'
|
|
682
|
+
: declaredType === 'string' || declaredType === 'boolean'
|
|
683
|
+
? axisType === 'point' || axisType === 'string'
|
|
684
|
+
: declaredType === 'number'
|
|
685
|
+
|| declaredType === 'latitude'
|
|
686
|
+
|| declaredType === 'longitude'
|
|
687
|
+
? axisType === 'number'
|
|
688
|
+
: false;
|
|
689
|
+
if (declaredType && !compatibleAxisType) {
|
|
690
|
+
pushIssue(issues, {
|
|
691
|
+
code: 'field-type-mismatch',
|
|
692
|
+
path: "$.axes[".concat(index, "].type"),
|
|
693
|
+
message: "Axis type \"".concat(axisType, "\" is not compatible with ").concat(declaredType, " field \"").concat(rawAxis.field, "\"."),
|
|
694
|
+
severity: 'error'
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
if (rawAxis.title !== undefined && typeof rawAxis.title !== 'string') {
|
|
698
|
+
pushIssue(issues, {
|
|
699
|
+
code: 'invalid-plan',
|
|
700
|
+
path: "$.axes[".concat(index, "].title"),
|
|
701
|
+
message: 'Axis title must be a string.',
|
|
702
|
+
severity: 'error'
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
if (rawAxis.tickCount !== undefined
|
|
706
|
+
&& (typeof rawAxis.tickCount !== 'number'
|
|
707
|
+
|| !Number.isInteger(rawAxis.tickCount)
|
|
708
|
+
|| rawAxis.tickCount < 1)) {
|
|
709
|
+
pushIssue(issues, {
|
|
710
|
+
code: 'invalid-plan',
|
|
711
|
+
path: "$.axes[".concat(index, "].tickCount"),
|
|
712
|
+
message: 'tickCount must be a positive integer.',
|
|
713
|
+
severity: 'error'
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
for (var _i = 0, _a = ['min', 'max']; _i < _a.length; _i++) {
|
|
717
|
+
var bound = _a[_i];
|
|
718
|
+
var value = rawAxis[bound];
|
|
719
|
+
var validNumberBound = axisType === 'number'
|
|
720
|
+
&& typeof value === 'number'
|
|
721
|
+
&& Number.isFinite(value);
|
|
722
|
+
var validTimeBound = axisType === 'time'
|
|
723
|
+
&& (typeof value === 'number'
|
|
724
|
+
&& Number.isFinite(value)
|
|
725
|
+
|| typeof value === 'string'
|
|
726
|
+
&& value.trim().length > 0
|
|
727
|
+
&& Number.isFinite(Date.parse(value)));
|
|
728
|
+
var validCategoricalBound = (axisType === 'point' || axisType === 'string')
|
|
729
|
+
&& (typeof value === 'number' || typeof value === 'string');
|
|
730
|
+
if (value !== undefined && !validNumberBound && !validTimeBound && !validCategoricalBound) {
|
|
731
|
+
pushIssue(issues, {
|
|
732
|
+
code: 'invalid-plan',
|
|
733
|
+
path: "$.axes[".concat(index, "].").concat(bound),
|
|
734
|
+
message: "".concat(bound, " is invalid for a ").concat(axisType, " axis."),
|
|
735
|
+
severity: 'error'
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
if (!declaredFieldTypes.has(rawAxis.field)) {
|
|
740
|
+
pushIssue(issues, {
|
|
741
|
+
code: 'unknown-field',
|
|
742
|
+
path: "$.axes[".concat(index, "].field"),
|
|
743
|
+
message: "Axis field \"".concat(rawAxis.field, "\" is not declared in plan.data.fields."),
|
|
744
|
+
severity: 'error'
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
if (input.options !== undefined && !Array.isArray(input.options)) {
|
|
750
|
+
pushIssue(issues, {
|
|
751
|
+
code: 'invalid-plan',
|
|
752
|
+
path: '$.options',
|
|
753
|
+
message: 'options must be an array.',
|
|
754
|
+
severity: 'error'
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
else if (Array.isArray(input.options)) {
|
|
758
|
+
var seriesCapabilities_1 = Array.isArray(input.series)
|
|
759
|
+
? input.series
|
|
760
|
+
.filter(isRecord)
|
|
761
|
+
.map(function (item) { return typeof item.capability === 'string'
|
|
762
|
+
? (0, catalog_1.findKChartAICapability)(item.capability)
|
|
763
|
+
: undefined; })
|
|
764
|
+
.filter(function (item) { return Boolean(item); })
|
|
765
|
+
: [];
|
|
766
|
+
input.options.forEach(function (rawOption, index) {
|
|
767
|
+
var path = "$.options[".concat(index, "].capability");
|
|
768
|
+
if (!isRecord(rawOption) || typeof rawOption.capability !== 'string') {
|
|
769
|
+
pushIssue(issues, {
|
|
770
|
+
code: 'invalid-plan',
|
|
771
|
+
path: path,
|
|
772
|
+
message: 'Option capability must be a string.',
|
|
773
|
+
severity: 'error'
|
|
774
|
+
});
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
reportUnknownKeys(rawOption, ['capability', 'enabled', 'settings'], "$.options[".concat(index, "]"), issues);
|
|
778
|
+
if (rawOption.enabled !== undefined && typeof rawOption.enabled !== 'boolean') {
|
|
779
|
+
pushIssue(issues, {
|
|
780
|
+
code: 'invalid-plan',
|
|
781
|
+
path: "$.options[".concat(index, "].enabled"),
|
|
782
|
+
message: 'enabled must be a boolean.',
|
|
783
|
+
severity: 'error'
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
if (rawOption.settings !== undefined && !isRecord(rawOption.settings)) {
|
|
787
|
+
pushIssue(issues, {
|
|
788
|
+
code: 'invalid-plan',
|
|
789
|
+
path: "$.options[".concat(index, "].settings"),
|
|
790
|
+
message: 'settings must be an object.',
|
|
791
|
+
severity: 'error'
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
else if (rawOption.settings !== undefined) {
|
|
795
|
+
validateJsonSettingValue(rawOption.settings, "".concat(path, ".settings"), issues);
|
|
796
|
+
validateKnownSettingTypes(rawOption.settings, "".concat(path, ".settings"), issues);
|
|
797
|
+
}
|
|
798
|
+
var capability = (0, catalog_1.findKChartAICapability)(rawOption.capability);
|
|
799
|
+
if (!capability || capability.kind !== 'option') {
|
|
800
|
+
pushIssue(issues, {
|
|
801
|
+
code: 'unknown-capability',
|
|
802
|
+
path: path,
|
|
803
|
+
message: "Unknown option capability \"".concat(rawOption.capability, "\"."),
|
|
804
|
+
severity: 'error'
|
|
805
|
+
});
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
if (seriesCapabilities_1.length === 0
|
|
809
|
+
&& Array.isArray(input.adapters)
|
|
810
|
+
&& input.adapters.length > 0) {
|
|
811
|
+
pushIssue(issues, {
|
|
812
|
+
code: 'incompatible-option',
|
|
813
|
+
path: path,
|
|
814
|
+
message: "".concat(capability.id, " is a core chart option. Configure adapter interaction through adapters[].settings."),
|
|
815
|
+
severity: 'error'
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
seriesCapabilities_1.forEach(function (seriesCapability) {
|
|
819
|
+
if (seriesCapability.compatibleOptions
|
|
820
|
+
&& !seriesCapability.compatibleOptions.includes(capability.id)) {
|
|
821
|
+
pushIssue(issues, {
|
|
822
|
+
code: 'incompatible-option',
|
|
823
|
+
path: path,
|
|
824
|
+
message: "".concat(capability.id, " is not compatible with ").concat(seriesCapability.id, "."),
|
|
825
|
+
severity: 'error'
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
if (capability.id === 'option.zoom' && Array.isArray(input.series)) {
|
|
830
|
+
input.series.filter(isRecord).forEach(function (seriesPlan, seriesIndex) {
|
|
831
|
+
if (!Array.isArray(seriesPlan.bindings)) {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
var xBinding = seriesPlan.bindings
|
|
835
|
+
.filter(isRecord)
|
|
836
|
+
.find(function (binding) { return binding.role === 'x'; });
|
|
837
|
+
var xField = typeof (xBinding === null || xBinding === void 0 ? void 0 : xBinding.field) === 'string'
|
|
838
|
+
? xBinding.field
|
|
839
|
+
: undefined;
|
|
840
|
+
var xType = xField ? declaredFieldTypes.get(xField) : undefined;
|
|
841
|
+
if (xType === 'string' || xType === 'boolean') {
|
|
842
|
+
pushIssue(issues, {
|
|
843
|
+
code: 'incompatible-option',
|
|
844
|
+
path: path,
|
|
845
|
+
message: "option.zoom is not supported for categorical x field \"".concat(xField, "\" in series[").concat(seriesIndex, "]."),
|
|
846
|
+
severity: 'error'
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
var valid = !issues.some(function (issue) { return issue.severity === 'error'; });
|
|
854
|
+
return {
|
|
855
|
+
valid: valid,
|
|
856
|
+
plan: valid ? input : undefined,
|
|
857
|
+
issues: issues
|
|
858
|
+
};
|
|
859
|
+
};
|
|
860
|
+
exports.validateKChartAIPlan = validateKChartAIPlan;
|
|
861
|
+
var assertKChartAIPlan = function (input) {
|
|
862
|
+
var result = (0, exports.validateKChartAIPlan)(input);
|
|
863
|
+
if (!result.valid || !result.plan) {
|
|
864
|
+
var message = result.issues
|
|
865
|
+
.filter(function (issue) { return issue.severity === 'error'; })
|
|
866
|
+
.map(function (issue) { return "".concat(issue.path, ": ").concat(issue.message); })
|
|
867
|
+
.join('\n');
|
|
868
|
+
throw new Error("Invalid KChart AI ChartPlan:\n".concat(message));
|
|
869
|
+
}
|
|
870
|
+
return result.plan;
|
|
871
|
+
};
|
|
872
|
+
exports.assertKChartAIPlan = assertKChartAIPlan;
|
|
873
|
+
var listKChartAICapabilityIds = function () {
|
|
874
|
+
return catalog_1.kChartAICatalog.capabilities.map(function (capability) { return capability.id; });
|
|
875
|
+
};
|
|
876
|
+
exports.listKChartAICapabilityIds = listKChartAICapabilityIds;
|
|
877
|
+
//# sourceMappingURL=validate-plan.js.map
|