@agile-team/mach-report 2.4.1 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +119 -13
  2. package/dist/ReportPreview-Dk-28QAi.js +2946 -0
  3. package/dist/ReportPreview-FSvcBLjH.cjs +6 -0
  4. package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
  5. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  6. package/dist/analytics.cjs +1 -0
  7. package/dist/analytics.d.cts +276 -0
  8. package/dist/analytics.d.ts +276 -0
  9. package/dist/analytics.js +223 -0
  10. package/dist/assets-66UBlhES.cjs +1 -0
  11. package/dist/assets-NVA_sftu.js +163 -0
  12. package/dist/capabilities-CNjIirfo.js +36 -0
  13. package/dist/capabilities-D4xeVYSR.cjs +1 -0
  14. package/dist/designer.cjs +1 -0
  15. package/dist/designer.d.cts +753 -0
  16. package/dist/designer.d.ts +753 -0
  17. package/dist/designer.js +372 -0
  18. package/dist/grid-geometry-BNptEcMm.js +65 -0
  19. package/dist/grid-geometry-CZ_cYB6O.cjs +1 -0
  20. package/dist/index.cjs +8 -5
  21. package/dist/index.d.cts +413 -8
  22. package/dist/index.d.ts +413 -8
  23. package/dist/index.js +1016 -1501
  24. package/dist/param-validation-BWNjLcN0.js +116 -0
  25. package/dist/param-validation-CiTxFeZ8.cjs +1 -0
  26. package/dist/pdf.cjs +48 -48
  27. package/dist/pdf.d.cts +111 -1
  28. package/dist/pdf.d.ts +111 -1
  29. package/dist/pdf.js +3931 -3868
  30. package/dist/{plugin-DwKr8oF6.cjs → plugin-BqBkn_kI.cjs} +1 -1
  31. package/dist/{plugin-CKnSVuVe.js → plugin-Ds10VnQO.js} +2 -2
  32. package/dist/render-plan-CckPEQyf.cjs +1 -0
  33. package/dist/{render-plan-CXBWRog4.js → render-plan-uzZYYSy1.js} +11 -10
  34. package/dist/report-params-B_VCihAh.js +12 -0
  35. package/dist/report-params-CjWrjPl6.cjs +1 -0
  36. package/dist/report-source-B9bENO0F.js +750 -0
  37. package/dist/report-source-BbNkkBDy.cjs +1 -0
  38. package/dist/server/node.d.cts +297 -0
  39. package/dist/server/node.d.ts +297 -0
  40. package/dist/server-node.cjs +1 -0
  41. package/dist/server-node.js +270 -0
  42. package/dist/server.cjs +1 -0
  43. package/dist/server.d.cts +643 -0
  44. package/dist/server.d.ts +643 -0
  45. package/dist/server.js +237 -0
  46. package/dist/style-CpwiOPyB.cjs +1 -0
  47. package/dist/style-Dv5o_x6b.js +67 -0
  48. package/dist/style.css +1 -1
  49. package/dist/template-registry-DWExx0gU.cjs +1 -0
  50. package/dist/template-registry-NpOakidD.js +354 -0
  51. package/dist/textwrap-CnGsEum6.cjs +4 -0
  52. package/dist/textwrap-DOl04hCQ.js +110 -0
  53. package/dist/validate-DfHPD8wX.cjs +1 -0
  54. package/dist/validate-S6CgIm5d.js +148 -0
  55. package/dist/vue/async.d.cts +694 -54
  56. package/dist/vue/async.d.ts +694 -54
  57. package/dist/vue/index.d.cts +1212 -111
  58. package/dist/vue/index.d.ts +1212 -111
  59. package/dist/vue-async.cjs +1 -1
  60. package/dist/vue-async.js +3 -3
  61. package/dist/vue.cjs +1 -1
  62. package/dist/vue.js +167 -80
  63. package/dist/worker.cjs +1 -0
  64. package/dist/worker.d.cts +302 -0
  65. package/dist/worker.d.ts +302 -0
  66. package/dist/worker.js +133 -0
  67. package/dist/xlsx/node.d.cts +47 -0
  68. package/dist/xlsx/node.d.ts +47 -0
  69. package/dist/xlsx-node.cjs +221 -0
  70. package/dist/xlsx-node.js +36409 -0
  71. package/dist/xlsx.cjs +20 -20
  72. package/dist/xlsx.d.cts +78 -1
  73. package/dist/xlsx.d.ts +78 -1
  74. package/dist/xlsx.js +5974 -5831
  75. package/package.json +62 -2
  76. package/dist/ReportPreview-BVTpw9Tb.cjs +0 -6
  77. package/dist/ReportPreview-XF8iSUG1.js +0 -1910
  78. package/dist/grid-geometry-BNIvw52m.cjs +0 -1
  79. package/dist/grid-geometry-C8hGoe9o.js +0 -130
  80. package/dist/render-plan-CCTL4F9v.cjs +0 -1
  81. package/dist/report-params-B3Fia6JO.js +0 -10
  82. package/dist/report-params-D1gZ1DME.cjs +0 -1
  83. package/dist/textwrap-nH0UYU6D.js +0 -108
  84. package/dist/textwrap-oD-t4b4B.cjs +0 -4
package/dist/index.d.ts CHANGED
@@ -1,8 +1,40 @@
1
1
  /** 复制发生变化的页/组件/行;原计划保持不变,并拒绝覆盖已改变的单元格。 */
2
2
  export declare function applyReportCellEdit(plan: RenderPlan, edit: ReportCellEdit): RenderPlan;
3
3
 
4
+ /** Transactional from the caller's perspective: a later conflict never exposes earlier writes. */
5
+ export declare function applyReportCellEditBatch(plan: RenderPlan, batch: Pick<ReportEditBatch, "edits">): RenderPlan;
6
+
7
+ /** Refresh concurrency metadata without changing values, layout, or the host's source objects. */
8
+ export declare function applyReportEditResult(plan: RenderPlan, batch: ReportEditBatch, result: void | ReportEditResult): RenderPlan;
9
+
4
10
  export declare function assertRenderPlan(input: unknown): PlanPage[];
5
11
 
12
+ export declare function assertReportParams(defs: readonly ReportParamDef[], input?: Record<string, unknown>): Record<string, string>;
13
+
14
+ export declare interface AssetRenderBudget {
15
+ /** Maximum newly rendered assets, default 1000. Existing imageData is kept unchanged. */
16
+ maxAssets?: number;
17
+ /** Maximum image payload bytes per new asset, default 32 MiB. */
18
+ maxImageBytes?: number;
19
+ /** Maximum total image payload bytes for new assets, default 128 MiB. */
20
+ maxTotalImageBytes?: number;
21
+ /** Wall-clock budget, including adapters that ignore AbortSignal. Default 30 seconds. */
22
+ maxDurationMs?: number;
23
+ }
24
+
25
+ export declare interface AssetRenderOptions extends OutputDiagnosticOptions {
26
+ assetRenderers?: Partial<Record<ImageComponentKind, ComponentImageRenderer>>;
27
+ assetBudget?: AssetRenderBudget;
28
+ /** Default throw prevents an incomplete export; placeholder retains the component and emits diagnostics. */
29
+ assetFailure?: "throw" | "placeholder";
30
+ signal?: AbortSignal;
31
+ }
32
+
33
+ export declare interface AsyncCanvasRenderOptions extends CanvasRenderOptions, AssetRenderOptions {
34
+ /** Optional image decoder for CORS-aware URLs or custom assets. Browser default supports image data URLs. */
35
+ imageLoader?: CanvasImageLoader;
36
+ }
37
+
6
38
  /** 盒子边框语义:四边开关 + 内部网格线(四边全关则内线不画) */
7
39
  export declare interface BoxBorders {
8
40
  top: boolean;
@@ -13,6 +45,8 @@ export declare interface BoxBorders {
13
45
  inner: boolean;
14
46
  }
15
47
 
48
+ export declare type CanvasImageLoader = (source: string, signal?: AbortSignal) => Promise<CanvasImageSource>;
49
+
16
50
  export declare interface CanvasPager {
17
51
  /** 挂载到滚动容器(viewport,overflow:auto),接管其内容 */
18
52
  attach(viewport: HTMLElement): void;
@@ -24,7 +58,7 @@ export declare interface CanvasPager {
24
58
  };
25
59
  }
26
60
 
27
- export declare interface CanvasPagerOptions extends CanvasRenderOptions {
61
+ export declare interface CanvasPagerOptions extends AsyncCanvasRenderOptions {
28
62
  /** 预渲染页数缓冲(窗口两侧各加 N 页),默认 1 */
29
63
  overscan?: number;
30
64
  /** 页间距 px,默认 18 */
@@ -33,10 +67,12 @@ export declare interface CanvasPagerOptions extends CanvasRenderOptions {
33
67
  pagesPerFrame?: number;
34
68
  }
35
69
 
36
- export declare interface CanvasRenderOptions {
70
+ export declare interface CanvasRenderOptions extends OutputDiagnosticOptions {
37
71
  /** 设备像素比,默认取运行环境 devicePixelRatio */
38
72
  dpr?: number;
39
73
  dpi?: number;
74
+ /** Per-page bitmap allocation guard; default 64 million pixels (about 256 MB RGBA). */
75
+ maxCanvasPixels?: number;
40
76
  /** 文本默认字体族 */
41
77
  fontFamily?: string;
42
78
  /** 文本测量器(默认启发式) */
@@ -48,6 +84,7 @@ export declare interface CanvasRenderOptions {
48
84
 
49
85
  export declare interface CanvasRenderResult {
50
86
  canvases: HTMLCanvasElement[];
87
+ diagnostics: OutputDiagnostic[];
51
88
  }
52
89
 
53
90
  export declare function charWidthEm(ch: string): number;
@@ -79,6 +116,19 @@ export declare type ColumnFormat = {
79
116
  pattern?: string;
80
117
  };
81
118
 
119
+ /** 同一字段契约生成列语义和表头,业务侧无需复制另一份字段清单。 */
120
+ export declare function columnsFromContract(contract: DatasetContract, overrides?: Record<string, Partial<TableTemplateColumn>>): TableTemplateColumn[];
121
+
122
+ export declare interface ComponentImageContext {
123
+ readonly component: Readonly<PlanComponent>;
124
+ readonly pageIndex: number;
125
+ readonly componentIndex: number;
126
+ readonly componentPath: readonly number[];
127
+ readonly signal: AbortSignal;
128
+ }
129
+
130
+ export declare type ComponentImageRenderer = (context: ComponentImageContext) => string | Promise<string>;
131
+
82
132
  export declare type ComponentKind = "text" | "image" | "barcode" | "qrcode" | "chart" | "line" | "rect" | "ellipse";
83
133
 
84
134
  export declare interface ComponentStyle {
@@ -127,15 +177,30 @@ export declare function createCanvasPager(plan: RenderPlan, options?: CanvasPage
127
177
  /** 兼容旧 API:默认启发式测量 */
128
178
  export declare function createHeuristicMeasurer(): TextMeasurer;
129
179
 
180
+ /** 单进程参考适配器;多实例服务请实现具备数据库事务/CAS 的持久化适配器。 */
181
+ export declare function createMemoryTemplateStore(): ReportTemplateStore;
182
+
183
+ export declare function createProviderReport(definition: Omit<ReportDefinition, "load" | "datasets"> & {
184
+ provider: ReportProvider;
185
+ }): ReportDefinition;
186
+
130
187
  /** 生成可供宿主持久化/审计的补丁;不修改 plan 或宿主业务对象。 */
131
188
  export declare function createReportCellEdit(plan: RenderPlan, address: ReportCellAddress, input: ReportCellValue): ReportCellEdit;
132
189
 
190
+ /** Parse and validate every value before persistence. No plan or source objects are mutated. */
191
+ export declare function createReportCellEditBatch(plan: RenderPlan, inputs: readonly ReportCellInput[], requestId: string): ReportEditBatch;
192
+
193
+ /** Operation-scoped index: avoids repeated geometry work without caching mutable plans globally. */
194
+ export declare function createReportCellResolver(plan: RenderPlan): (address: ReportCellAddress) => ReportCellContext | null;
195
+
133
196
  /**
134
197
  * 框架无关的报表数据源:注册一次模板与取数,包内完成分页、校验、按 ID 顺序合并。
135
198
  * 不缓存业务结果、不推断接口包装、不自动重试;鉴权与完整数据范围由宿主决定。
136
199
  */
137
200
  export declare function createReportSource(reports: ReportRegistry, options?: {
138
201
  onWarning?: (message: string) => void;
202
+ onDatasets?: (reportId: string, datasets: DatasetRows, template: ReportTemplate) => void;
203
+ maxPages?: number;
139
204
  }): ReportSource;
140
205
 
141
206
  /**
@@ -146,16 +211,48 @@ export declare function createTableTemplate(options: TableTemplateOptions): Repo
146
211
 
147
212
  export declare function createTemplate(): TemplateBuilder;
148
213
 
214
+ /** 持久化和框架无关的发布流程;历史返回快照,回滚会产生新修订而不会覆盖旧历史。 */
215
+ export declare function createTemplateManager(store: ReportTemplateStore, options?: {
216
+ migrate?: (input: unknown) => unknown | Promise<unknown>;
217
+ now?: () => Date;
218
+ }): ReportTemplateManager;
219
+
149
220
  /** 存储无关的模板目录;后台 CRUD、权限、发布审批与持久化由宿主接入。 */
150
221
  export declare function createTemplateRegistry(documents?: readonly ReportTemplateDocument[]): ReportTemplateRegistry;
151
222
 
152
223
  export declare const CSS_DPI = 96;
153
224
 
225
+ export declare interface DatasetContract {
226
+ fields: readonly ReportFieldContract[];
227
+ rowKey?: string;
228
+ }
229
+
230
+ export declare interface DatasetIssue {
231
+ code: "schema" | "budget" | "row" | "required" | "type" | "enum" | "range" | "row-key";
232
+ path: string;
233
+ message: string;
234
+ rowIndex?: number;
235
+ field?: string;
236
+ }
237
+
238
+ /** 公开JSON Schema供Java DTO/表单/接口文档复用;decimal保持文本以免精度丢失。 */
239
+ export declare function datasetJsonSchema(contract: DatasetContract): Record<string, unknown>;
240
+
154
241
  export declare type DatasetRows = Record<string, Record<string, unknown>[]>;
155
242
 
243
+ export declare interface DatasetValidationOptions {
244
+ path?: string;
245
+ maxRows?: number;
246
+ maxCells?: number;
247
+ maxIssues?: number;
248
+ }
249
+
156
250
  /** 默认边框线宽(pt) */
157
251
  export declare const DEFAULT_BORDER_PT = 0.75;
158
252
 
253
+ /** Browser preview, Canvas metrics and pagination use the same fallback font stack. */
254
+ export declare const DEFAULT_FONT_FAMILY = "\"Microsoft YaHei\", sans-serif";
255
+
159
256
  /** 默认字号(pt) */
160
257
  export declare const DEFAULT_FONT_PT = 10.5;
161
258
 
@@ -185,6 +282,9 @@ export declare function evalStyleRule(row: Record<string, unknown>, when: StyleR
185
282
  /** 同步 text/raw value,所有输出后端读取同一份更新后的 RenderPlan。 */
186
283
  export declare function formatReportCellEdit(context: ReportCellContext, value: ReportCellValue): string;
187
284
 
285
+ /** TSV with Excel-compatible quoting; quoted line breaks remain inside their cells. */
286
+ export declare function formatReportClipboard(rows: readonly (readonly string[])[]): string;
287
+
188
288
  /**
189
289
  * 应用格式化。非数值/无法解析时原样返回基础文本(降级不报错):
190
290
  * - number:digits 小数位 + 可选千分位(12,345.60;thousands 默认 false)
@@ -195,7 +295,6 @@ export declare function formatValue(value: unknown, format?: ColumnFormat): stri
195
295
 
196
296
  declare type Geometry = Partial<Pick<PlanComponent, "leftMm" | "topMm" | "widthMm" | "heightMm">>;
197
297
 
198
- /** 缺失、被合并覆盖、显式 null 占位不生成编辑目标。 */
199
298
  export declare function getReportCellContext(plan: RenderPlan, address: ReportCellAddress): ReportCellContext | null;
200
299
 
201
300
  export declare interface GridCell {
@@ -209,6 +308,7 @@ export declare interface GridCell {
209
308
  valueType?: "text" | "number" | "boolean";
210
309
  /** 单元格级编辑控制;预览仍需显式开启 editing。 */
211
310
  editable?: boolean;
311
+ source?: ReportCellSource;
212
312
  /** Excel 公式保留元数据;当前引擎不计算公式,公式格始终只读。 */
213
313
  formula?: string;
214
314
  children?: PlanComponent[];
@@ -253,7 +353,9 @@ export declare interface GridLayout {
253
353
  /** 启发式测量器:无 Canvas 时的默认宽度估算 */
254
354
  export declare const heuristicMeasurer: TextMeasurer;
255
355
 
256
- export declare interface ImageRenderOptions extends CanvasRenderOptions {
356
+ export declare type ImageComponentKind = "image" | "chart" | "barcode" | "qrcode";
357
+
358
+ export declare interface ImageRenderOptions extends AsyncCanvasRenderOptions {
257
359
  /** 图片格式(默认 png;jpeg 体积更小但无透明) */
258
360
  format?: "png" | "jpeg";
259
361
  /** jpeg 质量 0-1(默认 0.92,仅 jpeg 生效) */
@@ -262,10 +364,15 @@ export declare interface ImageRenderOptions extends CanvasRenderOptions {
262
364
 
263
365
  export declare interface ImageRenderResult {
264
366
  blobs: Blob[];
367
+ diagnostics: OutputDiagnostic[];
265
368
  }
266
369
 
370
+ export declare function inspectOutputCapabilities(plan: RenderPlan, format: OutputFormat): OutputDiagnostic[];
371
+
267
372
  export declare function isImageBackedComponent(comp: PlanComponent): boolean;
268
373
 
374
+ export declare function isReportDate(value: string): boolean;
375
+
269
376
  export declare function isRichText(comp: PlanComponent): boolean;
270
377
 
271
378
  /** 默认行高倍数(基线距 = 字号 × 该系数) */
@@ -293,6 +400,8 @@ export declare interface ListColumn {
293
400
  editable?: boolean;
294
401
  /** 空值列或特殊数据类型可显式声明编辑输入类型。 */
295
402
  valueType?: GridCell["valueType"];
403
+ /** 字段语义用于 auto 对齐;明确声明编号,避免把数字编号当成度量。 */
404
+ semanticRole?: "identifier" | "dimension" | "measure" | "date" | "text";
296
405
  }
297
406
 
298
407
  export declare interface ListComponent {
@@ -306,6 +415,10 @@ export declare interface ListComponent {
306
415
  topMm: number;
307
416
  widthMm: number;
308
417
  dataset: string;
418
+ /** 数据集中稳定业务主键的字段名;省略时编辑仅有计划内坐标。 */
419
+ rowKey?: string;
420
+ revisionField?: string;
421
+ sourceTokenField?: string;
309
422
  columns: ListColumn[];
310
423
  fontSizePt?: number;
311
424
  headerBold?: boolean;
@@ -318,6 +431,8 @@ export declare interface ListComponent {
318
431
  /** 表头默认对齐,列配置可覆盖。 */
319
432
  headerAlign?: ComponentStyle["align"];
320
433
  headerStyle?: ComponentStyle;
434
+ /** 可选多行合并表头;列宽按列表物理列对齐,供 Excel 业务模板复用。 */
435
+ headerGrid?: PlanGrid;
321
436
  border?: boolean;
322
437
  /** 分组小计(组头/组尾小计/组头防孤行) */
323
438
  groupBy?: ListGroupBy;
@@ -363,6 +478,32 @@ export declare function mmToPx(value: number, dpi?: number): number;
363
478
 
364
479
  export declare function mmToPxFactor(dpi?: number): number;
365
480
 
481
+ export declare class OutputAssetError extends Error {
482
+ readonly diagnostic: OutputDiagnostic;
483
+ readonly cause: unknown;
484
+ constructor(diagnostic: OutputDiagnostic, cause?: unknown);
485
+ }
486
+
487
+ export declare interface OutputDiagnostic {
488
+ code: "missing-image" | "unsupported-component" | "unsupported-image-format" | "rich-text-flattened" | "nested-components-omitted" | "async-image-required" | "image-decode-failed" | "asset-render-failed" | "asset-budget-exceeded";
489
+ severity: "warning";
490
+ format: OutputFormat;
491
+ pageIndex: number;
492
+ componentIndex: number;
493
+ /** Nested grid child location as repeating [rowIndex, columnIndex, childIndex] triples. */
494
+ componentPath?: readonly number[];
495
+ kind: string;
496
+ nid?: string;
497
+ message: string;
498
+ }
499
+
500
+ export declare interface OutputDiagnosticOptions {
501
+ /** Structured fidelity diagnostics; rendering never silently invents missing content. */
502
+ onDiagnostic?: (diagnostic: OutputDiagnostic) => void;
503
+ }
504
+
505
+ export declare type OutputFormat = "dom" | "canvas" | "pdf" | "xlsx";
506
+
366
507
  export declare class PageBuilder {
367
508
  private readonly parent;
368
509
  private readonly page;
@@ -408,6 +549,15 @@ export declare interface PaginateOptions {
408
549
  mmPerRow?: number;
409
550
  /** 文本测量器(默认启发式;浏览器端可注入 canvas 测量校准) */
410
551
  measurer?: TextMeasurer;
552
+ /** 可选页数上限;在追加超限页前终止,避免先分配全部页面再检查。 */
553
+ maxPages?: number;
554
+ }
555
+
556
+ export declare class PaginatePageLimitError extends Error {
557
+ readonly limit: number;
558
+ readonly actual: number;
559
+ readonly code = "page-limit";
560
+ constructor(limit: number, actual: number);
411
561
  }
412
562
 
413
563
  export declare interface PaginateResult {
@@ -432,6 +582,9 @@ export declare function parseDateLocal(input: string): Date | null;
432
582
  /** 严格解析编辑输入;文本列不隐式推断数值,清空数值/布尔列得到 null。 */
433
583
  export declare function parseReportCellInput(context: ReportCellContext, input: ReportCellValue): ReportCellValue;
434
584
 
585
+ /** Bounded parser for clipboard data; invalid quotes are rejected before edits are built. */
586
+ export declare function parseReportClipboard(text: string, maxCells?: number): string[][];
587
+
435
588
  /** 校验文件 JSON 文本或接口返回的未知对象,返回独立模板快照。 */
436
589
  export declare function parseReportTemplate(input: unknown): ReportTemplateDocument;
437
590
 
@@ -448,6 +601,8 @@ export declare interface PlanComponent {
448
601
  lines?: string[];
449
602
  richParagraphs?: RichParagraph[];
450
603
  imageData?: string;
604
+ /** 明确指定线段方向;省略保持历史水平线行为。 */
605
+ lineDirection?: "down" | "up";
451
606
  grid?: PlanGrid;
452
607
  table?: PlanTableFragment;
453
608
  style?: ComponentStyle;
@@ -495,6 +650,10 @@ export declare interface PlanTableFragment {
495
650
  columnKeys: string[];
496
651
  layout?: "page" | "wide";
497
652
  title?: string;
653
+ /** 只有宿主声明稳定 rowKey 时生成,不能用显示顺序替代业务主键。 */
654
+ source?: Omit<ReportCellSource, "field" | "rowKey"> & {
655
+ rowKey?: string | number;
656
+ };
498
657
  }
499
658
 
500
659
  export declare function ptToPx(pt: number, dpi?: number): number;
@@ -505,7 +664,7 @@ export declare const RENDER_PLAN_SCHEMA_VERSION = "1.0.0-mach";
505
664
 
506
665
  export declare function renderComponent(comp: PlanComponent, dpi: number, options: RenderOptions, doc: Document): HTMLElement;
507
666
 
508
- export declare interface RenderOptions {
667
+ export declare interface RenderOptions extends OutputDiagnosticOptions {
509
668
  dpi?: number;
510
669
  classNames?: Partial<Record<ClassKey, string>>;
511
670
  }
@@ -528,6 +687,9 @@ export declare function renderPlan(plan: RenderPlan, doc: Document, options?: Re
528
687
  */
529
688
  export declare function renderPlanToCanvas(plan: RenderPlan, options?: CanvasRenderOptions): CanvasRenderResult;
530
689
 
690
+ /** Browser async raster output: waits for every image and preserves component paint order. */
691
+ export declare function renderPlanToCanvasAsync(plan: RenderPlan, options?: AsyncCanvasRenderOptions): Promise<CanvasRenderResult>;
692
+
531
693
  /**
532
694
  * RenderPlan → 每页一张图片 Blob(浏览器环境):
533
695
  * 复用位图渲染管线(区间/dpr/字体/测量器均可配),再 toBlob 编码。
@@ -536,7 +698,7 @@ export declare function renderPlanToCanvas(plan: RenderPlan, options?: CanvasRen
536
698
  export declare function renderPlanToImages(plan: RenderPlan, options?: ImageRenderOptions): Promise<ImageRenderResult>;
537
699
 
538
700
  /** 模板存储文档版本;与渲染计划版本独立演进。 */
539
- export declare const REPORT_TEMPLATE_DOCUMENT_VERSION: "1.0";
701
+ export declare const REPORT_TEMPLATE_DOCUMENT_VERSION = "1.0";
540
702
 
541
703
  /** 预览中的物理坐标;合并单元格使用左上角坐标。 */
542
704
  export declare interface ReportCellAddress {
@@ -553,6 +715,8 @@ export declare interface ReportCellContext {
553
715
  value: ReportCellValue;
554
716
  valueType: ReportCellValueType;
555
717
  table?: ReportCellTableIdentity;
718
+ /** Stable business identity. Physical row indices must never be used as database keys. */
719
+ source?: Readonly<ReportCellSource>;
556
720
  editable: boolean;
557
721
  readOnlyReason?: ReportCellReadOnlyReason;
558
722
  }
@@ -560,6 +724,7 @@ export declare interface ReportCellContext {
560
724
  export declare interface ReportCellEdit {
561
725
  address: ReportCellAddress;
562
726
  table?: ReportCellTableIdentity;
727
+ source?: Readonly<ReportCellSource>;
563
728
  previousValue: ReportCellValue;
564
729
  previousText: string;
565
730
  value: ReportCellValue;
@@ -571,10 +736,26 @@ export declare class ReportCellEditError extends Error {
571
736
  constructor(code: ReportCellEditErrorCode);
572
737
  }
573
738
 
574
- export declare type ReportCellEditErrorCode = "missing" | "readonly" | "number" | "boolean" | "conflict";
739
+ export declare type ReportCellEditErrorCode = "missing" | "readonly" | "number" | "boolean" | "conflict" | "duplicate" | "limit" | "atomic" | "clipboard";
740
+
741
+ export declare function reportCellEditKey(edit: Pick<ReportCellEdit, "address" | "source" | "table">): string;
742
+
743
+ export declare interface ReportCellInput {
744
+ address: ReportCellAddress;
745
+ value: ReportCellValue;
746
+ }
575
747
 
576
748
  export declare type ReportCellReadOnlyReason = "cell" | "formula" | "complex" | "structure";
577
749
 
750
+ /** 可持久化的业务身份与计划坐标独立;权限及并发校验仍由业务服务器执行。 */
751
+ export declare interface ReportCellSource {
752
+ datasetId: string;
753
+ rowKey: string | number;
754
+ field: string;
755
+ revision?: string | number;
756
+ sourceToken?: string;
757
+ }
758
+
578
759
  export declare interface ReportCellTableIdentity {
579
760
  id: string;
580
761
  /** 逻辑表行索引;跨分页的同一行保持不变。 */
@@ -593,6 +774,11 @@ export declare interface ReportDefinition {
593
774
  /** 静态数据;load 存在时优先使用 load 的结果。 */
594
775
  datasets?: DatasetRows;
595
776
  load?: (context: ReportLoadContext) => DatasetRows | Promise<DatasetRows>;
777
+ /** 可选统一适配器;load 存在时仍优先 load,兼容已有定义。 */
778
+ provider?: ReportProvider;
779
+ /** 可选业务数据契约;声明的数据集缺失或字段不合法时,在分页前给出结构化错误。 */
780
+ dataSchema?: Record<string, DatasetContract>;
781
+ dataValidation?: Pick<DatasetValidationOptions, "maxRows" | "maxCells" | "maxIssues">;
596
782
  /** 覆盖模板参数定义;动态模板应在此声明查询面板元数据,避免查询前先请求模板。 */
597
783
  params?: ReportParamDef[];
598
784
  pagination?: PaginateOptions;
@@ -603,6 +789,35 @@ export declare interface ReportDefinitionOptions<TData> extends Omit<ReportDefin
603
789
  mapData: (data: TData, context: ReportLoadContext) => DatasetRows;
604
790
  }
605
791
 
792
+ export declare interface ReportDiagnostic {
793
+ code: string;
794
+ message: string;
795
+ path?: string;
796
+ severity: "warning" | "error" | "info";
797
+ }
798
+
799
+ export declare interface ReportEditBatch {
800
+ /** Idempotency identity; the server should bind it to the exact payload. */
801
+ requestId: string;
802
+ edits: ReportCellEdit[];
803
+ }
804
+
805
+ export declare interface ReportEditConflict {
806
+ source?: Readonly<ReportCellSource>;
807
+ address?: ReportCellAddress;
808
+ message: string;
809
+ currentValue?: ReportCellValue;
810
+ revision?: string | number;
811
+ }
812
+
813
+ export declare interface ReportEditResult {
814
+ /** A successful result may advance concurrency tokens for the affected dataset. */
815
+ revision?: string | number;
816
+ sourceToken?: string;
817
+ /** Any conflict rejects the entire client batch. A server must also transact atomically. */
818
+ conflicts?: readonly ReportEditConflict[];
819
+ }
820
+
606
821
  /** 保持 Promise<RenderPlan> 契约;元数据为可选,旧业务 fetcher 无需改造。 */
607
822
  export declare interface ReportFetcher {
608
823
  (input: ReportFetchInput): Promise<RenderPlan>;
@@ -615,6 +830,22 @@ export declare interface ReportFetchInput {
615
830
  signal?: AbortSignal;
616
831
  /** 本次分页与计划告警;未提供时使用数据源配置的告警通道。 */
617
832
  onWarning?: (message: string) => void;
833
+ onQueryResult?: (reportId: string, result: ReportQueryResult) => void;
834
+ }
835
+
836
+ export declare interface ReportFieldContract {
837
+ field: string;
838
+ label?: string;
839
+ type: "text" | "number" | "boolean" | "date" | "decimal";
840
+ required?: boolean;
841
+ nullable?: boolean;
842
+ enum?: readonly (string | number | boolean)[];
843
+ min?: number;
844
+ max?: number;
845
+ minLength?: number;
846
+ maxLength?: number;
847
+ semanticRole?: "identifier" | "dimension" | "measure" | "date" | "text";
848
+ unit?: string;
618
849
  }
619
850
 
620
851
  /** 取数与排版共同使用的请求上下文;取消只影响本次调用。 */
@@ -624,6 +855,8 @@ export declare interface ReportLoadContext {
624
855
  signal?: AbortSignal;
625
856
  }
626
857
 
858
+ export declare function reportOutputDiagnostics(plan: RenderPlan, format: OutputFormat, options: OutputDiagnosticOptions): OutputDiagnostic[];
859
+
627
860
  /** 报表参数定义(声明式,模板自描述参数面:渲染组件据此生成查询面板) */
628
861
  export declare interface ReportParamDef {
629
862
  /** 参数名(传入 params,与数据集 SQL #{field} 绑定对应) */
@@ -639,10 +872,87 @@ export declare interface ReportParamDef {
639
872
  defaultValue?: string;
640
873
  required?: boolean;
641
874
  placeholder?: string;
875
+ /** 数字上下界;date 参数使用 YYYY-MM-DD 字符串(含边界)。 */
876
+ min?: number | string;
877
+ max?: number | string;
878
+ minLength?: number;
879
+ maxLength?: number;
880
+ }
881
+
882
+ export declare interface ReportParamIssue {
883
+ code: ReportParamIssueCode;
884
+ path: string;
885
+ field: string;
886
+ message: string;
887
+ }
888
+
889
+ export declare type ReportParamIssueCode = "definition" | "required" | "type" | "option" | "minimum" | "maximum" | "minLength" | "maxLength";
890
+
891
+ /** 描述 typedValues 的 Draft 2020-12 Schema;日期区间额外保留 x-report-* 扩展。 */
892
+ export declare function reportParamsJsonSchema(defs: readonly ReportParamDef[]): Record<string, unknown>;
893
+
894
+ export declare interface ReportParamValidation {
895
+ ok: boolean;
896
+ /** 保留历史取数契约的字符串形式;未知参数保留,不能代替接口权限白名单。 */
897
+ values: Record<string, string>;
898
+ /** JSON Schema 对应的规范值:number 参数转换为有限数字。 */
899
+ typedValues: Record<string, string | number>;
900
+ issues: ReportParamIssue[];
901
+ }
902
+
903
+ export declare class ReportParamValidationError extends Error {
904
+ readonly issues: readonly ReportParamIssue[];
905
+ readonly code = "params";
906
+ constructor(issues: readonly ReportParamIssue[]);
907
+ }
908
+
909
+ /** 查询是唯一基础能力;权限、HTTP、数据库和事务都留在宿主适配器内。 */
910
+ export declare interface ReportProvider {
911
+ query(context: ReportLoadContext): ReportQueryResult | Promise<ReportQueryResult>;
912
+ save?(input: ReportSaveInput): ReportSaveResult | Promise<ReportSaveResult>;
913
+ export?(input: ReportProviderExportInput): ReportProviderExportResult | Promise<ReportProviderExportResult>;
914
+ templates?: ReportTemplateProvider;
915
+ }
916
+
917
+ export declare interface ReportProviderExportInput extends ReportLoadContext {
918
+ format: "pdf" | "xlsx";
919
+ }
920
+
921
+ export declare interface ReportProviderExportResult {
922
+ bytes: Uint8Array;
923
+ contentType: string;
924
+ fileName?: string;
925
+ diagnostics?: ReportDiagnostic[];
926
+ }
927
+
928
+ export declare interface ReportQueryResult {
929
+ datasets: DatasetRows;
930
+ revision?: string;
931
+ sourceToken?: string;
932
+ diagnostics?: ReportDiagnostic[];
642
933
  }
643
934
 
644
935
  export declare type ReportRegistry = Record<string, ReportDefinition>;
645
936
 
937
+ export declare interface ReportSaveInput extends ReportLoadContext {
938
+ requestId: string;
939
+ expectedRevision?: string;
940
+ sourceToken?: string;
941
+ edits: readonly ReportCellEdit[];
942
+ action?: "edit" | "undo" | "redo" | "restore";
943
+ }
944
+
945
+ export declare interface ReportSaveResult {
946
+ revision: string;
947
+ sourceToken?: string;
948
+ conflicts?: Array<{
949
+ editIndex: number;
950
+ code: string;
951
+ message: string;
952
+ }>;
953
+ diagnostics?: ReportDiagnostic[];
954
+ }
955
+
646
956
  export declare interface ReportSource extends ReportFetcher {
647
957
  getParamDefs(reportIds: string[]): ReportParamDef[];
648
958
  }
@@ -662,7 +972,7 @@ export declare interface ReportTemplate {
662
972
 
663
973
  /** 可存入数据库/文件的纯 JSON 模板;数据、接口与鉴权仍由宿主提供。 */
664
974
  export declare interface ReportTemplateDocument {
665
- schemaVersion: typeof REPORT_TEMPLATE_DOCUMENT_VERSION;
975
+ schemaVersion: "1.0";
666
976
  id: string;
667
977
  name: string;
668
978
  /** 宿主的发布版本/乐观锁标识,不由引擎自动递增。 */
@@ -678,6 +988,35 @@ export declare class ReportTemplateError extends Error {
678
988
 
679
989
  export declare type ReportTemplateLoader = (context: ReportLoadContext) => ReportTemplate | Promise<ReportTemplate>;
680
990
 
991
+ export declare interface ReportTemplateManager {
992
+ list(signal?: AbortSignal): ReturnType<ReportTemplateStore["list"]>;
993
+ get(id: string, options?: {
994
+ draft?: boolean;
995
+ signal?: AbortSignal;
996
+ }): Promise<ReportTemplateDocument | undefined>;
997
+ history(id: string, signal?: AbortSignal): Promise<readonly ReportTemplateVersion[]>;
998
+ saveDraft(input: unknown, options: TemplateMutationOptions): Promise<ReportTemplateRecord>;
999
+ publish(id: string, options: TemplateMutationOptions): Promise<ReportTemplateRecord>;
1000
+ rollback(id: string, revision: string, options: TemplateMutationOptions): Promise<ReportTemplateRecord>;
1001
+ }
1002
+
1003
+ export declare interface ReportTemplateProvider {
1004
+ list(context: {
1005
+ signal?: AbortSignal;
1006
+ }): Promise<ReportTemplateSummary[]>;
1007
+ get(id: string, context: {
1008
+ signal?: AbortSignal;
1009
+ }): Promise<ReportTemplateDocument | undefined>;
1010
+ }
1011
+
1012
+ export declare interface ReportTemplateRecord {
1013
+ id: string;
1014
+ revision: string;
1015
+ draft?: ReportTemplateDocument;
1016
+ publishedRevision?: string;
1017
+ published?: ReportTemplateDocument;
1018
+ }
1019
+
681
1020
  export declare interface ReportTemplateRegistry {
682
1021
  /** 返回独立快照,调用方编辑不会改变目录中的已注册模板。 */
683
1022
  get(id: string): ReportTemplateDocument | undefined;
@@ -689,8 +1028,34 @@ export declare interface ReportTemplateRegistry {
689
1028
  remove(id: string): boolean;
690
1029
  }
691
1030
 
1031
+ /** compareAndSwap 必须由宿主数据库/文件适配器保证原子性,不能用先读再无条件写替代。 */
1032
+ export declare interface ReportTemplateStore {
1033
+ read(id: string, signal?: AbortSignal): Promise<ReportTemplateRecord | undefined>;
1034
+ list(signal?: AbortSignal): Promise<Array<{
1035
+ id: string;
1036
+ revision: string;
1037
+ publishedRevision?: string;
1038
+ }>>;
1039
+ history(id: string, signal?: AbortSignal): Promise<ReportTemplateVersion[]>;
1040
+ getVersion(id: string, revision: string, signal?: AbortSignal): Promise<ReportTemplateVersion | undefined>;
1041
+ /** 状态更新和 publication 的不可变追加必须处于同一原子事务;草稿写入不读取历史。 */
1042
+ compareAndSwap(id: string, expectedRevision: string | null, next: ReportTemplateRecord, options: TemplateStoreWriteOptions): Promise<boolean>;
1043
+ }
1044
+
1045
+ export declare class ReportTemplateStoreError extends Error {
1046
+ readonly code: "conflict" | "missing" | "draft" | "history";
1047
+ constructor(code: "conflict" | "missing" | "draft" | "history", message: string);
1048
+ }
1049
+
692
1050
  export declare type ReportTemplateSummary = Omit<ReportTemplateDocument, "template">;
693
1051
 
1052
+ export declare interface ReportTemplateVersion {
1053
+ revision: string;
1054
+ publishedAt: string;
1055
+ document: ReportTemplateDocument;
1056
+ restoredFrom?: string;
1057
+ }
1058
+
694
1059
  /**
695
1060
  * 边框开关解析:
696
1061
  * - 未声明(undefined)→ 四边全开(与既有 rect 总有边框的行为兼容)
@@ -731,6 +1096,19 @@ export declare function resolvePaper(paper: PaperName | {
731
1096
  heightMm: number;
732
1097
  };
733
1098
 
1099
+ /** Resolve optional third-party chart/barcode/QR adapters once, before any output backend. Input stays immutable. */
1100
+ export declare function resolvePlanAssets(plan: RenderPlan, options?: ResolvePlanAssetsOptions): Promise<{
1101
+ plan: RenderPlan;
1102
+ diagnostics: OutputDiagnostic[];
1103
+ }>;
1104
+
1105
+ export declare interface ResolvePlanAssetsOptions extends AssetRenderOptions {
1106
+ /** Only labels diagnostics; no output library is imported. Default dom. */
1107
+ format?: OutputFormat;
1108
+ start?: number;
1109
+ end?: number;
1110
+ }
1111
+
734
1112
  /** 描边解析:颜色 + 线宽(pt) */
735
1113
  export declare function resolveStroke(style: Pick<ComponentStyle, "borderColor" | "lineColor" | "lineWidthPt"> | undefined, fallbackColor?: string): {
736
1114
  color: string;
@@ -775,6 +1153,9 @@ export declare interface StyleRule {
775
1153
  style: Record<string, unknown>;
776
1154
  }
777
1155
 
1156
+ /** Ordered, net changes for review; a change restored to its original value disappears. */
1157
+ export declare function summarizeReportCellEdits(edits: readonly ReportCellEdit[]): ReportCellEdit[];
1158
+
778
1159
  /** 明细列:显式 widthMm 优先;纸张模式按 flex 分余量,宽表模式按 flex 放大基准列宽。 */
779
1160
  export declare type TableTemplateColumn = Omit<ListColumn, "widthMm"> & {
780
1161
  widthMm?: number;
@@ -842,6 +1223,11 @@ export declare class TemplateBuilder {
842
1223
 
843
1224
  export declare type TemplateComponent = PlanComponent | ListComponent;
844
1225
 
1226
+ export declare interface TemplateMutationOptions {
1227
+ expectedRevision: string | null;
1228
+ signal?: AbortSignal;
1229
+ }
1230
+
845
1231
  export declare interface TemplatePage {
846
1232
  widthMm: number;
847
1233
  heightMm: number;
@@ -854,6 +1240,11 @@ export declare interface TemplatePage {
854
1240
  components: TemplateComponent[];
855
1241
  }
856
1242
 
1243
+ export declare interface TemplateStoreWriteOptions {
1244
+ publication?: ReportTemplateVersion;
1245
+ signal?: AbortSignal;
1246
+ }
1247
+
857
1248
  /**
858
1249
  * 文本测量与折行(分页/Canvas/PDF 共用的唯一折行真相源)。
859
1250
  *
@@ -863,7 +1254,9 @@ export declare interface TemplatePage {
863
1254
  */
864
1255
  export declare interface TextMeasureOptions {
865
1256
  fontSizePt: number;
1257
+ fontFamily?: string;
866
1258
  bold?: boolean;
1259
+ italic?: boolean;
867
1260
  letterSpacingPt?: number;
868
1261
  }
869
1262
 
@@ -879,10 +1272,22 @@ export declare function toNumber(value: unknown): number | null;
879
1272
 
880
1273
  export declare function validateComponent(comp: unknown, path: string, errors: ValidationError[], warnings?: ValidationError[]): void;
881
1274
 
1275
+ /** 浏览器/Node共用的只读值校验;返回精确路径,不以0或空数组掩盖接口结构错误。 */
1276
+ export declare function validateDatasetRows(input: unknown, contract: DatasetContract, options?: DatasetValidationOptions): {
1277
+ ok: boolean;
1278
+ issues: DatasetIssue[];
1279
+ };
1280
+
882
1281
  export declare function validatePage(page: unknown, path: string, errors: ValidationError[], warnings?: ValidationError[]): void;
883
1282
 
884
1283
  export declare function validateRenderPlan(input: unknown): ValidationResult;
885
1284
 
1285
+ /** 模板参数配置错误也统一返回结构化问题,不让无效默认值或边界静默进入后端。 */
1286
+ export declare function validateReportParamDefinitions(defs: readonly ReportParamDef[]): ReportParamIssue[];
1287
+
1288
+ /** 在浏览器或服务端执行相同默认值、必填、类型、枚举及范围规则。 */
1289
+ export declare function validateReportParams(defs: readonly ReportParamDef[], input?: Record<string, unknown>): ReportParamValidation;
1290
+
886
1291
  /** 对入库/导入模板做声明式校验,不执行分页或数据请求。 */
887
1292
  export declare function validateReportTemplate(input: unknown): ValidationResult;
888
1293