@yejiming/dsh-data-agent 0.0.6 → 0.0.9

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.
@@ -0,0 +1,1071 @@
1
+ /**
2
+ * Shared version-1 analysis report contract, used by BOTH package halves:
3
+ * the Node tool half (render-analysis) validates and builds reports with it,
4
+ * and the Web client decodes persisted tool/result.meta with it. The module
5
+ * is pure TypeScript (no node: imports, no DOM) so it bundles into the client
6
+ * unchanged.
7
+ *
8
+ * The strict parser rejects unknown properties, duplicate ids, dangling
9
+ * dataset references, count violations and every disallowed view shape, so a
10
+ * model can never smuggle arbitrary chart-library options, HTML, CSS or URLs
11
+ * through the wire contract.
12
+ * @module @yejiming/dsh-data-agent/analysis
13
+ */
14
+ /** Wire version stamped onto every request/report. */
15
+ export declare const ANALYSIS_REPORT_VERSION: 1;
16
+ /** Dataset count bounds for one report (D1). */
17
+ export declare const MAX_ANALYSIS_DATASETS = 6;
18
+ export declare const MIN_ANALYSIS_DATASETS = 1;
19
+ /** View count bounds for one report (D1). */
20
+ export declare const MAX_ANALYSIS_VIEWS = 8;
21
+ export declare const MIN_ANALYSIS_VIEWS = 1;
22
+ /** Series bounds for one line/bar view (D2). */
23
+ export declare const MIN_ANALYSIS_SERIES = 1;
24
+ export declare const MAX_ANALYSIS_SERIES = 4;
25
+ /** Total JSON-encoded report size bound (D4): 512 KiB. */
26
+ export declare const MAX_REPORT_BYTES: number;
27
+ /** The six discriminated view kinds. */
28
+ export type AnalysisViewKind = 'metric' | 'line' | 'bar' | 'pie' | 'scatter' | 'table';
29
+ /** Grid width of one non-metric view. */
30
+ export type AnalysisViewWidth = 'full' | 'half';
31
+ /** line/bar x axis semantics. */
32
+ export type AnalysisAxisType = 'category' | 'time';
33
+ /** Supported metric number format. */
34
+ export type AnalysisMetricFormat = 'number' | 'percent';
35
+ /** Fields shared by every view. */
36
+ interface AnalysisViewBaseV1 {
37
+ id: string;
38
+ kind: AnalysisViewKind;
39
+ datasetId: string;
40
+ label?: string;
41
+ }
42
+ /** Fields shared by the non-metric views. */
43
+ interface AnalysisGridBaseV1 extends AnalysisViewBaseV1 {
44
+ width?: AnalysisViewWidth;
45
+ }
46
+ /** One metric view: a single finite number with a label. */
47
+ export interface AnalysisMetricViewV1 extends AnalysisViewBaseV1 {
48
+ kind: 'metric';
49
+ field: string;
50
+ label: string;
51
+ format?: AnalysisMetricFormat;
52
+ }
53
+ /** One line/bar view over a shared x axis and 1-4 y fields (or one seriesField). */
54
+ export interface AnalysisLineBarViewV1 extends AnalysisGridBaseV1 {
55
+ kind: 'line' | 'bar';
56
+ x: {
57
+ field: string;
58
+ type: AnalysisAxisType;
59
+ label?: string;
60
+ };
61
+ y: string[];
62
+ seriesField?: string;
63
+ }
64
+ /** One pie view (category + non-negative value). */
65
+ export interface AnalysisPieViewV1 extends AnalysisGridBaseV1 {
66
+ kind: 'pie';
67
+ categoryField: string;
68
+ valueField: string;
69
+ }
70
+ /** One scatter view (x/y numeric pairs). */
71
+ export interface AnalysisScatterViewV1 extends AnalysisGridBaseV1 {
72
+ kind: 'scatter';
73
+ xField: string;
74
+ yField: string;
75
+ }
76
+ /** One semantic table view with an optional column whitelist. */
77
+ export interface AnalysisTableViewV1 extends AnalysisGridBaseV1 {
78
+ kind: 'table';
79
+ columns?: string[];
80
+ }
81
+ export type AnalysisViewV1 = AnalysisMetricViewV1 | AnalysisLineBarViewV1 | AnalysisPieViewV1 | AnalysisScatterViewV1 | AnalysisTableViewV1;
82
+ /** One request dataset: a unique id plus one read-only SQL statement. */
83
+ export interface AnalysisDatasetRequestV1 {
84
+ id: string;
85
+ sql: string;
86
+ }
87
+ /** The wire request accepted by the render-analysis tool. */
88
+ export interface AnalysisRequestV1 {
89
+ title: string;
90
+ summary?: string;
91
+ datasets: AnalysisDatasetRequestV1[];
92
+ views: AnalysisViewV1[];
93
+ }
94
+ /** One normalized dataset inside a report: aligned two-dimensional rows. */
95
+ export interface AnalysisDatasetResultV1 {
96
+ id: string;
97
+ columns: string[];
98
+ rows: (string | null)[][];
99
+ }
100
+ /** The canonical version-1 report persisted into presentationMeta. */
101
+ export interface AnalysisReportV1 {
102
+ version: typeof ANALYSIS_REPORT_VERSION;
103
+ title: string;
104
+ summary?: string;
105
+ datasets: AnalysisDatasetResultV1[];
106
+ views: AnalysisViewV1[];
107
+ }
108
+ /** Dataset rows in object form (the sql-query canonical shape). */
109
+ export interface DatasetRows {
110
+ columns: string[];
111
+ rows: Record<string, string | null>[];
112
+ }
113
+ /** Whether a view kind is one of the four chart kinds. */
114
+ export declare function isChartKind(kind: AnalysisViewKind): boolean;
115
+ /**
116
+ * Strictly parse a model-supplied analysis request. Every structural
117
+ * violation (unknown fields, duplicate ids, dangling references, count or
118
+ * union constraints) throws with a message naming the offending view/dataset.
119
+ */
120
+ export declare function parseAnalysisRequest(input: unknown, prefix?: string): AnalysisRequestV1;
121
+ /** Strictly parse a persisted report meta; throws on any shape violation. */
122
+ export declare function parseAnalysisReport(input: unknown, prefix?: string): AnalysisReportV1;
123
+ /** Whether one string parses to a finite number. */
124
+ export declare function isFiniteNumberText(value: string): boolean;
125
+ /** Whether one string parses as a time value. */
126
+ export declare function isParseableTimeText(value: string): boolean;
127
+ /**
128
+ * Validate view→dataset semantics AFTER all queries succeeded and BEFORE any
129
+ * meta is built: field existence, finite numerics, pie non-negativity, time
130
+ * parseability, and table whitelist existence. The client is never asked to
131
+ * aggregate, sort, or treat null as zero — validation happens here.
132
+ */
133
+ export declare function validateViewSemantics(views: readonly AnalysisViewV1[], datasets: ReadonlyMap<string, DatasetRows>, prefix?: string): void;
134
+ /** Compress object rows into column-aligned two-dimensional arrays (D2). */
135
+ export declare function rowsToArrays(columns: string[], rows: readonly Record<string, string | null>[]): (string | null)[][];
136
+ /** JSON-encoded UTF-8 size of the normalized report (the 512 KiB bound). */
137
+ export declare function reportJsonBytes(report: AnalysisReportV1): number;
138
+ /** One-line model-facing summary; never re-injects rows into model context (D5). */
139
+ export declare function formatAnalysisSummary(report: Pick<AnalysisReportV1, 'title' | 'datasets' | 'views'>): string;
140
+ /** The view union: exactly the six supported kinds, nothing else. */
141
+ export declare const ANALYSIS_VIEWS_SCHEMA: {
142
+ readonly oneOf: readonly [{
143
+ readonly type: "object";
144
+ readonly properties: {
145
+ readonly id: {
146
+ readonly type: "string";
147
+ readonly required: true;
148
+ readonly description: "视图唯一 id(本报告内不重复)";
149
+ };
150
+ readonly kind: {
151
+ readonly type: "string";
152
+ readonly const: "metric";
153
+ readonly required: true;
154
+ };
155
+ readonly datasetId: {
156
+ readonly type: "string";
157
+ readonly required: true;
158
+ readonly description: "引用本次请求中的一个 dataset id";
159
+ };
160
+ readonly field: {
161
+ readonly type: "string";
162
+ readonly required: true;
163
+ readonly description: "数值字段名(来自 dataset 查询结果的列)";
164
+ };
165
+ readonly label: {
166
+ readonly type: "string";
167
+ readonly required: true;
168
+ readonly description: "指标名称,如「本月营收」";
169
+ };
170
+ readonly format: {
171
+ readonly type: "string";
172
+ readonly enum: readonly ["number", "percent"];
173
+ readonly description: "可选数值格式:number(默认)或 percent(值×100 后加 %)";
174
+ };
175
+ };
176
+ readonly additionalProperties: false;
177
+ }, {
178
+ readonly type: "object";
179
+ readonly properties: {
180
+ readonly id: {
181
+ readonly type: "string";
182
+ readonly required: true;
183
+ readonly description: "视图唯一 id(本报告内不重复)";
184
+ };
185
+ readonly kind: {
186
+ readonly type: "string";
187
+ readonly const: "line" | "bar";
188
+ readonly required: true;
189
+ };
190
+ readonly datasetId: {
191
+ readonly type: "string";
192
+ readonly required: true;
193
+ readonly description: "引用本次请求中的一个 dataset id";
194
+ };
195
+ readonly label: {
196
+ readonly type: "string";
197
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
198
+ };
199
+ readonly width: {
200
+ readonly type: "string";
201
+ readonly enum: readonly ["full", "half"];
202
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
203
+ };
204
+ readonly x: {
205
+ readonly type: "object";
206
+ readonly properties: {
207
+ readonly field: {
208
+ readonly type: "string";
209
+ readonly required: true;
210
+ readonly description: "x 轴字段名";
211
+ };
212
+ readonly type: {
213
+ readonly type: "string";
214
+ readonly enum: readonly ["category", "time"];
215
+ readonly required: true;
216
+ readonly description: "category 分类轴 / time 时间轴(数据需可由 Date 解析,SQL 请 ORDER BY)";
217
+ };
218
+ readonly label: {
219
+ readonly type: "string";
220
+ readonly description: "可选 x 轴名称";
221
+ };
222
+ };
223
+ readonly additionalProperties: false;
224
+ readonly required: true;
225
+ };
226
+ readonly y: {
227
+ readonly type: "array";
228
+ readonly required: true;
229
+ readonly items: {
230
+ readonly type: "string";
231
+ };
232
+ readonly description: "1-4 个数值 y 字段名;声明多个 y 时不得同时声明 seriesField";
233
+ };
234
+ readonly seriesField: {
235
+ readonly type: "string";
236
+ readonly description: "可选分组字段:按该字段取值拆成多个系列(与多个 y 字段互斥)";
237
+ };
238
+ };
239
+ readonly additionalProperties: false;
240
+ }, {
241
+ readonly type: "object";
242
+ readonly properties: {
243
+ readonly id: {
244
+ readonly type: "string";
245
+ readonly required: true;
246
+ readonly description: "视图唯一 id(本报告内不重复)";
247
+ };
248
+ readonly kind: {
249
+ readonly type: "string";
250
+ readonly const: "line" | "bar";
251
+ readonly required: true;
252
+ };
253
+ readonly datasetId: {
254
+ readonly type: "string";
255
+ readonly required: true;
256
+ readonly description: "引用本次请求中的一个 dataset id";
257
+ };
258
+ readonly label: {
259
+ readonly type: "string";
260
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
261
+ };
262
+ readonly width: {
263
+ readonly type: "string";
264
+ readonly enum: readonly ["full", "half"];
265
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
266
+ };
267
+ readonly x: {
268
+ readonly type: "object";
269
+ readonly properties: {
270
+ readonly field: {
271
+ readonly type: "string";
272
+ readonly required: true;
273
+ readonly description: "x 轴字段名";
274
+ };
275
+ readonly type: {
276
+ readonly type: "string";
277
+ readonly enum: readonly ["category", "time"];
278
+ readonly required: true;
279
+ readonly description: "category 分类轴 / time 时间轴(数据需可由 Date 解析,SQL 请 ORDER BY)";
280
+ };
281
+ readonly label: {
282
+ readonly type: "string";
283
+ readonly description: "可选 x 轴名称";
284
+ };
285
+ };
286
+ readonly additionalProperties: false;
287
+ readonly required: true;
288
+ };
289
+ readonly y: {
290
+ readonly type: "array";
291
+ readonly required: true;
292
+ readonly items: {
293
+ readonly type: "string";
294
+ };
295
+ readonly description: "1-4 个数值 y 字段名;声明多个 y 时不得同时声明 seriesField";
296
+ };
297
+ readonly seriesField: {
298
+ readonly type: "string";
299
+ readonly description: "可选分组字段:按该字段取值拆成多个系列(与多个 y 字段互斥)";
300
+ };
301
+ };
302
+ readonly additionalProperties: false;
303
+ }, {
304
+ readonly type: "object";
305
+ readonly properties: {
306
+ readonly id: {
307
+ readonly type: "string";
308
+ readonly required: true;
309
+ readonly description: "视图唯一 id(本报告内不重复)";
310
+ };
311
+ readonly kind: {
312
+ readonly type: "string";
313
+ readonly const: "pie";
314
+ readonly required: true;
315
+ };
316
+ readonly datasetId: {
317
+ readonly type: "string";
318
+ readonly required: true;
319
+ readonly description: "引用本次请求中的一个 dataset id";
320
+ };
321
+ readonly label: {
322
+ readonly type: "string";
323
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
324
+ };
325
+ readonly width: {
326
+ readonly type: "string";
327
+ readonly enum: readonly ["full", "half"];
328
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
329
+ };
330
+ readonly categoryField: {
331
+ readonly type: "string";
332
+ readonly required: true;
333
+ readonly description: "分类字段名";
334
+ };
335
+ readonly valueField: {
336
+ readonly type: "string";
337
+ readonly required: true;
338
+ readonly description: "非负数值字段名";
339
+ };
340
+ };
341
+ readonly additionalProperties: false;
342
+ }, {
343
+ readonly type: "object";
344
+ readonly properties: {
345
+ readonly id: {
346
+ readonly type: "string";
347
+ readonly required: true;
348
+ readonly description: "视图唯一 id(本报告内不重复)";
349
+ };
350
+ readonly kind: {
351
+ readonly type: "string";
352
+ readonly const: "scatter";
353
+ readonly required: true;
354
+ };
355
+ readonly datasetId: {
356
+ readonly type: "string";
357
+ readonly required: true;
358
+ readonly description: "引用本次请求中的一个 dataset id";
359
+ };
360
+ readonly label: {
361
+ readonly type: "string";
362
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
363
+ };
364
+ readonly width: {
365
+ readonly type: "string";
366
+ readonly enum: readonly ["full", "half"];
367
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
368
+ };
369
+ readonly xField: {
370
+ readonly type: "string";
371
+ readonly required: true;
372
+ readonly description: "数值 x 字段名";
373
+ };
374
+ readonly yField: {
375
+ readonly type: "string";
376
+ readonly required: true;
377
+ readonly description: "数值 y 字段名";
378
+ };
379
+ };
380
+ readonly additionalProperties: false;
381
+ }, {
382
+ readonly type: "object";
383
+ readonly properties: {
384
+ readonly id: {
385
+ readonly type: "string";
386
+ readonly required: true;
387
+ readonly description: "视图唯一 id(本报告内不重复)";
388
+ };
389
+ readonly kind: {
390
+ readonly type: "string";
391
+ readonly const: "table";
392
+ readonly required: true;
393
+ };
394
+ readonly datasetId: {
395
+ readonly type: "string";
396
+ readonly required: true;
397
+ readonly description: "引用本次请求中的一个 dataset id";
398
+ };
399
+ readonly label: {
400
+ readonly type: "string";
401
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
402
+ };
403
+ readonly width: {
404
+ readonly type: "string";
405
+ readonly enum: readonly ["full", "half"];
406
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
407
+ };
408
+ readonly columns: {
409
+ readonly type: "array";
410
+ readonly items: {
411
+ readonly type: "string";
412
+ };
413
+ readonly description: "可选列白名单;省略时按 dataset 列顺序显示";
414
+ };
415
+ };
416
+ readonly additionalProperties: false;
417
+ }];
418
+ };
419
+ /** Wire parameter schema of the render-analysis tool. */
420
+ export declare const RENDER_ANALYSIS_PARAMETERS: {
421
+ readonly title: {
422
+ readonly type: "string";
423
+ readonly required: true;
424
+ readonly description: "报告标题,如「月度经营分析」";
425
+ };
426
+ readonly summary: {
427
+ readonly type: "string";
428
+ readonly description: "可选一句话结论/摘要,显示在报告头部";
429
+ };
430
+ readonly datasets: {
431
+ readonly type: "array";
432
+ readonly required: true;
433
+ readonly items: {
434
+ readonly type: "object";
435
+ readonly properties: {
436
+ readonly id: {
437
+ readonly type: "string";
438
+ readonly required: true;
439
+ readonly description: "数据集唯一 id(供 views 引用)";
440
+ };
441
+ readonly sql: {
442
+ readonly type: "string";
443
+ readonly required: true;
444
+ readonly description: "一条只读 SQL(SELECT/SHOW/DESCRIBE/EXPLAIN;聚合、Top N、排序都写在 SQL 中)";
445
+ };
446
+ };
447
+ readonly additionalProperties: false;
448
+ };
449
+ readonly description: "1-6 个数据集;每个按顺序恰好执行一次,同一数据集可被多个视图复用";
450
+ };
451
+ readonly views: {
452
+ readonly type: "array";
453
+ readonly required: true;
454
+ readonly items: {
455
+ readonly oneOf: readonly [{
456
+ readonly type: "object";
457
+ readonly properties: {
458
+ readonly id: {
459
+ readonly type: "string";
460
+ readonly required: true;
461
+ readonly description: "视图唯一 id(本报告内不重复)";
462
+ };
463
+ readonly kind: {
464
+ readonly type: "string";
465
+ readonly const: "metric";
466
+ readonly required: true;
467
+ };
468
+ readonly datasetId: {
469
+ readonly type: "string";
470
+ readonly required: true;
471
+ readonly description: "引用本次请求中的一个 dataset id";
472
+ };
473
+ readonly field: {
474
+ readonly type: "string";
475
+ readonly required: true;
476
+ readonly description: "数值字段名(来自 dataset 查询结果的列)";
477
+ };
478
+ readonly label: {
479
+ readonly type: "string";
480
+ readonly required: true;
481
+ readonly description: "指标名称,如「本月营收」";
482
+ };
483
+ readonly format: {
484
+ readonly type: "string";
485
+ readonly enum: readonly ["number", "percent"];
486
+ readonly description: "可选数值格式:number(默认)或 percent(值×100 后加 %)";
487
+ };
488
+ };
489
+ readonly additionalProperties: false;
490
+ }, {
491
+ readonly type: "object";
492
+ readonly properties: {
493
+ readonly id: {
494
+ readonly type: "string";
495
+ readonly required: true;
496
+ readonly description: "视图唯一 id(本报告内不重复)";
497
+ };
498
+ readonly kind: {
499
+ readonly type: "string";
500
+ readonly const: "line" | "bar";
501
+ readonly required: true;
502
+ };
503
+ readonly datasetId: {
504
+ readonly type: "string";
505
+ readonly required: true;
506
+ readonly description: "引用本次请求中的一个 dataset id";
507
+ };
508
+ readonly label: {
509
+ readonly type: "string";
510
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
511
+ };
512
+ readonly width: {
513
+ readonly type: "string";
514
+ readonly enum: readonly ["full", "half"];
515
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
516
+ };
517
+ readonly x: {
518
+ readonly type: "object";
519
+ readonly properties: {
520
+ readonly field: {
521
+ readonly type: "string";
522
+ readonly required: true;
523
+ readonly description: "x 轴字段名";
524
+ };
525
+ readonly type: {
526
+ readonly type: "string";
527
+ readonly enum: readonly ["category", "time"];
528
+ readonly required: true;
529
+ readonly description: "category 分类轴 / time 时间轴(数据需可由 Date 解析,SQL 请 ORDER BY)";
530
+ };
531
+ readonly label: {
532
+ readonly type: "string";
533
+ readonly description: "可选 x 轴名称";
534
+ };
535
+ };
536
+ readonly additionalProperties: false;
537
+ readonly required: true;
538
+ };
539
+ readonly y: {
540
+ readonly type: "array";
541
+ readonly required: true;
542
+ readonly items: {
543
+ readonly type: "string";
544
+ };
545
+ readonly description: "1-4 个数值 y 字段名;声明多个 y 时不得同时声明 seriesField";
546
+ };
547
+ readonly seriesField: {
548
+ readonly type: "string";
549
+ readonly description: "可选分组字段:按该字段取值拆成多个系列(与多个 y 字段互斥)";
550
+ };
551
+ };
552
+ readonly additionalProperties: false;
553
+ }, {
554
+ readonly type: "object";
555
+ readonly properties: {
556
+ readonly id: {
557
+ readonly type: "string";
558
+ readonly required: true;
559
+ readonly description: "视图唯一 id(本报告内不重复)";
560
+ };
561
+ readonly kind: {
562
+ readonly type: "string";
563
+ readonly const: "line" | "bar";
564
+ readonly required: true;
565
+ };
566
+ readonly datasetId: {
567
+ readonly type: "string";
568
+ readonly required: true;
569
+ readonly description: "引用本次请求中的一个 dataset id";
570
+ };
571
+ readonly label: {
572
+ readonly type: "string";
573
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
574
+ };
575
+ readonly width: {
576
+ readonly type: "string";
577
+ readonly enum: readonly ["full", "half"];
578
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
579
+ };
580
+ readonly x: {
581
+ readonly type: "object";
582
+ readonly properties: {
583
+ readonly field: {
584
+ readonly type: "string";
585
+ readonly required: true;
586
+ readonly description: "x 轴字段名";
587
+ };
588
+ readonly type: {
589
+ readonly type: "string";
590
+ readonly enum: readonly ["category", "time"];
591
+ readonly required: true;
592
+ readonly description: "category 分类轴 / time 时间轴(数据需可由 Date 解析,SQL 请 ORDER BY)";
593
+ };
594
+ readonly label: {
595
+ readonly type: "string";
596
+ readonly description: "可选 x 轴名称";
597
+ };
598
+ };
599
+ readonly additionalProperties: false;
600
+ readonly required: true;
601
+ };
602
+ readonly y: {
603
+ readonly type: "array";
604
+ readonly required: true;
605
+ readonly items: {
606
+ readonly type: "string";
607
+ };
608
+ readonly description: "1-4 个数值 y 字段名;声明多个 y 时不得同时声明 seriesField";
609
+ };
610
+ readonly seriesField: {
611
+ readonly type: "string";
612
+ readonly description: "可选分组字段:按该字段取值拆成多个系列(与多个 y 字段互斥)";
613
+ };
614
+ };
615
+ readonly additionalProperties: false;
616
+ }, {
617
+ readonly type: "object";
618
+ readonly properties: {
619
+ readonly id: {
620
+ readonly type: "string";
621
+ readonly required: true;
622
+ readonly description: "视图唯一 id(本报告内不重复)";
623
+ };
624
+ readonly kind: {
625
+ readonly type: "string";
626
+ readonly const: "pie";
627
+ readonly required: true;
628
+ };
629
+ readonly datasetId: {
630
+ readonly type: "string";
631
+ readonly required: true;
632
+ readonly description: "引用本次请求中的一个 dataset id";
633
+ };
634
+ readonly label: {
635
+ readonly type: "string";
636
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
637
+ };
638
+ readonly width: {
639
+ readonly type: "string";
640
+ readonly enum: readonly ["full", "half"];
641
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
642
+ };
643
+ readonly categoryField: {
644
+ readonly type: "string";
645
+ readonly required: true;
646
+ readonly description: "分类字段名";
647
+ };
648
+ readonly valueField: {
649
+ readonly type: "string";
650
+ readonly required: true;
651
+ readonly description: "非负数值字段名";
652
+ };
653
+ };
654
+ readonly additionalProperties: false;
655
+ }, {
656
+ readonly type: "object";
657
+ readonly properties: {
658
+ readonly id: {
659
+ readonly type: "string";
660
+ readonly required: true;
661
+ readonly description: "视图唯一 id(本报告内不重复)";
662
+ };
663
+ readonly kind: {
664
+ readonly type: "string";
665
+ readonly const: "scatter";
666
+ readonly required: true;
667
+ };
668
+ readonly datasetId: {
669
+ readonly type: "string";
670
+ readonly required: true;
671
+ readonly description: "引用本次请求中的一个 dataset id";
672
+ };
673
+ readonly label: {
674
+ readonly type: "string";
675
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
676
+ };
677
+ readonly width: {
678
+ readonly type: "string";
679
+ readonly enum: readonly ["full", "half"];
680
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
681
+ };
682
+ readonly xField: {
683
+ readonly type: "string";
684
+ readonly required: true;
685
+ readonly description: "数值 x 字段名";
686
+ };
687
+ readonly yField: {
688
+ readonly type: "string";
689
+ readonly required: true;
690
+ readonly description: "数值 y 字段名";
691
+ };
692
+ };
693
+ readonly additionalProperties: false;
694
+ }, {
695
+ readonly type: "object";
696
+ readonly properties: {
697
+ readonly id: {
698
+ readonly type: "string";
699
+ readonly required: true;
700
+ readonly description: "视图唯一 id(本报告内不重复)";
701
+ };
702
+ readonly kind: {
703
+ readonly type: "string";
704
+ readonly const: "table";
705
+ readonly required: true;
706
+ };
707
+ readonly datasetId: {
708
+ readonly type: "string";
709
+ readonly required: true;
710
+ readonly description: "引用本次请求中的一个 dataset id";
711
+ };
712
+ readonly label: {
713
+ readonly type: "string";
714
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
715
+ };
716
+ readonly width: {
717
+ readonly type: "string";
718
+ readonly enum: readonly ["full", "half"];
719
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
720
+ };
721
+ readonly columns: {
722
+ readonly type: "array";
723
+ readonly items: {
724
+ readonly type: "string";
725
+ };
726
+ readonly description: "可选列白名单;省略时按 dataset 列顺序显示";
727
+ };
728
+ };
729
+ readonly additionalProperties: false;
730
+ }];
731
+ };
732
+ readonly description: "1-8 个视图;每个视图必须回答一个不同子问题,多个视图可共享同一 dataset";
733
+ };
734
+ };
735
+ /** Canonical output schema of the render-analysis tool. */
736
+ export declare const ANALYSIS_REPORT_OUTPUT_SCHEMA: {
737
+ readonly type: "object";
738
+ readonly properties: {
739
+ readonly version: {
740
+ readonly type: "integer";
741
+ readonly const: 1;
742
+ readonly required: true;
743
+ };
744
+ readonly title: {
745
+ readonly type: "string";
746
+ readonly required: true;
747
+ };
748
+ readonly summary: {
749
+ readonly type: "string";
750
+ };
751
+ readonly datasets: {
752
+ readonly type: "array";
753
+ readonly required: true;
754
+ readonly items: {
755
+ readonly type: "object";
756
+ readonly properties: {
757
+ readonly id: {
758
+ readonly type: "string";
759
+ readonly required: true;
760
+ };
761
+ readonly columns: {
762
+ readonly type: "array";
763
+ readonly required: true;
764
+ readonly items: {
765
+ readonly type: "string";
766
+ };
767
+ };
768
+ readonly rows: {
769
+ readonly type: "array";
770
+ readonly required: true;
771
+ readonly items: {
772
+ readonly type: "array";
773
+ readonly items: {
774
+ readonly oneOf: readonly [{
775
+ readonly type: "string";
776
+ }, {
777
+ readonly type: "null";
778
+ }];
779
+ };
780
+ };
781
+ };
782
+ };
783
+ readonly additionalProperties: false;
784
+ };
785
+ };
786
+ readonly views: {
787
+ readonly type: "array";
788
+ readonly required: true;
789
+ readonly items: {
790
+ readonly oneOf: readonly [{
791
+ readonly type: "object";
792
+ readonly properties: {
793
+ readonly id: {
794
+ readonly type: "string";
795
+ readonly required: true;
796
+ readonly description: "视图唯一 id(本报告内不重复)";
797
+ };
798
+ readonly kind: {
799
+ readonly type: "string";
800
+ readonly const: "metric";
801
+ readonly required: true;
802
+ };
803
+ readonly datasetId: {
804
+ readonly type: "string";
805
+ readonly required: true;
806
+ readonly description: "引用本次请求中的一个 dataset id";
807
+ };
808
+ readonly field: {
809
+ readonly type: "string";
810
+ readonly required: true;
811
+ readonly description: "数值字段名(来自 dataset 查询结果的列)";
812
+ };
813
+ readonly label: {
814
+ readonly type: "string";
815
+ readonly required: true;
816
+ readonly description: "指标名称,如「本月营收」";
817
+ };
818
+ readonly format: {
819
+ readonly type: "string";
820
+ readonly enum: readonly ["number", "percent"];
821
+ readonly description: "可选数值格式:number(默认)或 percent(值×100 后加 %)";
822
+ };
823
+ };
824
+ readonly additionalProperties: false;
825
+ }, {
826
+ readonly type: "object";
827
+ readonly properties: {
828
+ readonly id: {
829
+ readonly type: "string";
830
+ readonly required: true;
831
+ readonly description: "视图唯一 id(本报告内不重复)";
832
+ };
833
+ readonly kind: {
834
+ readonly type: "string";
835
+ readonly const: "line" | "bar";
836
+ readonly required: true;
837
+ };
838
+ readonly datasetId: {
839
+ readonly type: "string";
840
+ readonly required: true;
841
+ readonly description: "引用本次请求中的一个 dataset id";
842
+ };
843
+ readonly label: {
844
+ readonly type: "string";
845
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
846
+ };
847
+ readonly width: {
848
+ readonly type: "string";
849
+ readonly enum: readonly ["full", "half"];
850
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
851
+ };
852
+ readonly x: {
853
+ readonly type: "object";
854
+ readonly properties: {
855
+ readonly field: {
856
+ readonly type: "string";
857
+ readonly required: true;
858
+ readonly description: "x 轴字段名";
859
+ };
860
+ readonly type: {
861
+ readonly type: "string";
862
+ readonly enum: readonly ["category", "time"];
863
+ readonly required: true;
864
+ readonly description: "category 分类轴 / time 时间轴(数据需可由 Date 解析,SQL 请 ORDER BY)";
865
+ };
866
+ readonly label: {
867
+ readonly type: "string";
868
+ readonly description: "可选 x 轴名称";
869
+ };
870
+ };
871
+ readonly additionalProperties: false;
872
+ readonly required: true;
873
+ };
874
+ readonly y: {
875
+ readonly type: "array";
876
+ readonly required: true;
877
+ readonly items: {
878
+ readonly type: "string";
879
+ };
880
+ readonly description: "1-4 个数值 y 字段名;声明多个 y 时不得同时声明 seriesField";
881
+ };
882
+ readonly seriesField: {
883
+ readonly type: "string";
884
+ readonly description: "可选分组字段:按该字段取值拆成多个系列(与多个 y 字段互斥)";
885
+ };
886
+ };
887
+ readonly additionalProperties: false;
888
+ }, {
889
+ readonly type: "object";
890
+ readonly properties: {
891
+ readonly id: {
892
+ readonly type: "string";
893
+ readonly required: true;
894
+ readonly description: "视图唯一 id(本报告内不重复)";
895
+ };
896
+ readonly kind: {
897
+ readonly type: "string";
898
+ readonly const: "line" | "bar";
899
+ readonly required: true;
900
+ };
901
+ readonly datasetId: {
902
+ readonly type: "string";
903
+ readonly required: true;
904
+ readonly description: "引用本次请求中的一个 dataset id";
905
+ };
906
+ readonly label: {
907
+ readonly type: "string";
908
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
909
+ };
910
+ readonly width: {
911
+ readonly type: "string";
912
+ readonly enum: readonly ["full", "half"];
913
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
914
+ };
915
+ readonly x: {
916
+ readonly type: "object";
917
+ readonly properties: {
918
+ readonly field: {
919
+ readonly type: "string";
920
+ readonly required: true;
921
+ readonly description: "x 轴字段名";
922
+ };
923
+ readonly type: {
924
+ readonly type: "string";
925
+ readonly enum: readonly ["category", "time"];
926
+ readonly required: true;
927
+ readonly description: "category 分类轴 / time 时间轴(数据需可由 Date 解析,SQL 请 ORDER BY)";
928
+ };
929
+ readonly label: {
930
+ readonly type: "string";
931
+ readonly description: "可选 x 轴名称";
932
+ };
933
+ };
934
+ readonly additionalProperties: false;
935
+ readonly required: true;
936
+ };
937
+ readonly y: {
938
+ readonly type: "array";
939
+ readonly required: true;
940
+ readonly items: {
941
+ readonly type: "string";
942
+ };
943
+ readonly description: "1-4 个数值 y 字段名;声明多个 y 时不得同时声明 seriesField";
944
+ };
945
+ readonly seriesField: {
946
+ readonly type: "string";
947
+ readonly description: "可选分组字段:按该字段取值拆成多个系列(与多个 y 字段互斥)";
948
+ };
949
+ };
950
+ readonly additionalProperties: false;
951
+ }, {
952
+ readonly type: "object";
953
+ readonly properties: {
954
+ readonly id: {
955
+ readonly type: "string";
956
+ readonly required: true;
957
+ readonly description: "视图唯一 id(本报告内不重复)";
958
+ };
959
+ readonly kind: {
960
+ readonly type: "string";
961
+ readonly const: "pie";
962
+ readonly required: true;
963
+ };
964
+ readonly datasetId: {
965
+ readonly type: "string";
966
+ readonly required: true;
967
+ readonly description: "引用本次请求中的一个 dataset id";
968
+ };
969
+ readonly label: {
970
+ readonly type: "string";
971
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
972
+ };
973
+ readonly width: {
974
+ readonly type: "string";
975
+ readonly enum: readonly ["full", "half"];
976
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
977
+ };
978
+ readonly categoryField: {
979
+ readonly type: "string";
980
+ readonly required: true;
981
+ readonly description: "分类字段名";
982
+ };
983
+ readonly valueField: {
984
+ readonly type: "string";
985
+ readonly required: true;
986
+ readonly description: "非负数值字段名";
987
+ };
988
+ };
989
+ readonly additionalProperties: false;
990
+ }, {
991
+ readonly type: "object";
992
+ readonly properties: {
993
+ readonly id: {
994
+ readonly type: "string";
995
+ readonly required: true;
996
+ readonly description: "视图唯一 id(本报告内不重复)";
997
+ };
998
+ readonly kind: {
999
+ readonly type: "string";
1000
+ readonly const: "scatter";
1001
+ readonly required: true;
1002
+ };
1003
+ readonly datasetId: {
1004
+ readonly type: "string";
1005
+ readonly required: true;
1006
+ readonly description: "引用本次请求中的一个 dataset id";
1007
+ };
1008
+ readonly label: {
1009
+ readonly type: "string";
1010
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
1011
+ };
1012
+ readonly width: {
1013
+ readonly type: "string";
1014
+ readonly enum: readonly ["full", "half"];
1015
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
1016
+ };
1017
+ readonly xField: {
1018
+ readonly type: "string";
1019
+ readonly required: true;
1020
+ readonly description: "数值 x 字段名";
1021
+ };
1022
+ readonly yField: {
1023
+ readonly type: "string";
1024
+ readonly required: true;
1025
+ readonly description: "数值 y 字段名";
1026
+ };
1027
+ };
1028
+ readonly additionalProperties: false;
1029
+ }, {
1030
+ readonly type: "object";
1031
+ readonly properties: {
1032
+ readonly id: {
1033
+ readonly type: "string";
1034
+ readonly required: true;
1035
+ readonly description: "视图唯一 id(本报告内不重复)";
1036
+ };
1037
+ readonly kind: {
1038
+ readonly type: "string";
1039
+ readonly const: "table";
1040
+ readonly required: true;
1041
+ };
1042
+ readonly datasetId: {
1043
+ readonly type: "string";
1044
+ readonly required: true;
1045
+ readonly description: "引用本次请求中的一个 dataset id";
1046
+ };
1047
+ readonly label: {
1048
+ readonly type: "string";
1049
+ readonly description: "可选视图标题,用于图表可访问名称与空态";
1050
+ };
1051
+ readonly width: {
1052
+ readonly type: "string";
1053
+ readonly enum: readonly ["full", "half"];
1054
+ readonly description: "可选宽度:full 整行 / half 半行(缺省由系统决定)";
1055
+ };
1056
+ readonly columns: {
1057
+ readonly type: "array";
1058
+ readonly items: {
1059
+ readonly type: "string";
1060
+ };
1061
+ readonly description: "可选列白名单;省略时按 dataset 列顺序显示";
1062
+ };
1063
+ };
1064
+ readonly additionalProperties: false;
1065
+ }];
1066
+ };
1067
+ };
1068
+ };
1069
+ readonly additionalProperties: false;
1070
+ };
1071
+ export {};