@agile-team/mach-report 2.6.1 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +59 -8
  2. package/dist/ReportPreview-BKKDAv8e.js +4481 -0
  3. package/dist/ReportPreview-E3cm67Tk.cjs +6 -0
  4. package/dist/{assets-NVA_sftu.js → assets-B9qJku3V.js} +54 -57
  5. package/dist/assets-RZan7EyL.cjs +1 -0
  6. package/dist/capabilities-joSutDF8.js +63 -0
  7. package/dist/capabilities-xGTpnPjJ.cjs +1 -0
  8. package/dist/designer.cjs +1 -1
  9. package/dist/designer.d.cts +922 -753
  10. package/dist/designer.d.ts +922 -753
  11. package/dist/designer.js +490 -234
  12. package/dist/index.cjs +8 -8
  13. package/dist/index.d.cts +128 -3
  14. package/dist/index.d.ts +128 -3
  15. package/dist/index.js +971 -699
  16. package/dist/pdf.cjs +30 -30
  17. package/dist/pdf.d.cts +11 -3
  18. package/dist/pdf.d.ts +11 -3
  19. package/dist/pdf.js +1501 -1500
  20. package/dist/{plugin-Ds10VnQO.js → plugin-PCgxBVB2.js} +1 -1
  21. package/dist/{plugin-BqBkn_kI.cjs → plugin-mAfvgSey.cjs} +1 -1
  22. package/dist/progress-DD964VAB.js +102 -0
  23. package/dist/progress-KvhwXZ1Q.cjs +1 -0
  24. package/dist/{report-source-B9bENO0F.js → report-source-BXHNy_AD.js} +337 -332
  25. package/dist/report-source-CCAvFE3t.cjs +1 -0
  26. package/dist/server/node.d.cts +26 -3
  27. package/dist/server/node.d.ts +26 -3
  28. package/dist/server-node.cjs +1 -1
  29. package/dist/server-node.js +125 -92
  30. package/dist/server.cjs +1 -1
  31. package/dist/server.d.cts +28 -3
  32. package/dist/server.d.ts +28 -3
  33. package/dist/server.js +172 -164
  34. package/dist/style.css +1 -1
  35. package/dist/task-events-DQ276fn2.cjs +1 -0
  36. package/dist/task-events-Dpsvf_t2.js +47 -0
  37. package/dist/vue/async.d.cts +1553 -2083
  38. package/dist/vue/async.d.ts +1553 -2083
  39. package/dist/vue/index.d.cts +2465 -3310
  40. package/dist/vue/index.d.ts +2465 -3310
  41. package/dist/vue-async.cjs +1 -1
  42. package/dist/vue-async.js +3 -3
  43. package/dist/vue.cjs +1 -1
  44. package/dist/vue.js +159 -132
  45. package/dist/worker.cjs +1 -1
  46. package/dist/worker.d.cts +26 -3
  47. package/dist/worker.d.ts +26 -3
  48. package/dist/worker.js +110 -85
  49. package/dist/xlsx.cjs +14 -14
  50. package/dist/xlsx.d.cts +11 -3
  51. package/dist/xlsx.d.ts +11 -3
  52. package/dist/xlsx.js +656 -652
  53. package/package.json +2 -2
  54. package/dist/ReportPreview-Dk-28QAi.js +0 -2946
  55. package/dist/ReportPreview-FSvcBLjH.cjs +0 -6
  56. package/dist/assets-66UBlhES.cjs +0 -1
  57. package/dist/capabilities-CNjIirfo.js +0 -36
  58. package/dist/capabilities-D4xeVYSR.cjs +0 -1
  59. package/dist/grid-geometry-BNptEcMm.js +0 -65
  60. package/dist/grid-geometry-CZ_cYB6O.cjs +0 -1
  61. package/dist/report-source-BbNkkBDy.cjs +0 -1
package/dist/index.d.ts CHANGED
@@ -45,6 +45,9 @@ export declare interface BoxBorders {
45
45
  inner: boolean;
46
46
  }
47
47
 
48
+ /** Read-only local analysis. Never changes the plan, formulas, datasets or business persistence. */
49
+ export declare function calculateReportSelection(plan: RenderPlan, selection: ReportCalculationSelection, options?: ReportSelectionCalculationOptions): Promise<ReportSelectionCalculationResult>;
50
+
48
51
  export declare type CanvasImageLoader = (source: string, signal?: AbortSignal) => Promise<CanvasImageSource>;
49
52
 
50
53
  export declare interface CanvasPager {
@@ -279,6 +282,9 @@ export declare function defineReportTemplate(document: Omit<ReportTemplateDocume
279
282
  */
280
283
  export declare function evalStyleRule(row: Record<string, unknown>, when: StyleRule["when"]): boolean;
281
284
 
285
+ /** A tiny arithmetic parser: no functions, property access, globals, assignments or executable source. */
286
+ export declare function evaluateReportAggregateExpression(expression: string, values: Readonly<Record<string, number>>): number;
287
+
282
288
  /** 同步 text/raw value,所有输出后端读取同一份更新后的 RenderPlan。 */
283
289
  export declare function formatReportCellEdit(context: ReportCellContext, value: ReportCellValue): string;
284
290
 
@@ -485,7 +491,7 @@ export declare class OutputAssetError extends Error {
485
491
  }
486
492
 
487
493
  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";
494
+ code: "missing-image" | "unsupported-component" | "unsupported-image-format" | "unsupported-style" | "rich-text-flattened" | "nested-components-omitted" | "async-image-required" | "image-decode-failed" | "asset-render-failed" | "asset-budget-exceeded";
489
495
  severity: "warning";
490
496
  format: OutputFormat;
491
497
  pageIndex: number;
@@ -497,13 +503,27 @@ export declare interface OutputDiagnostic {
497
503
  message: string;
498
504
  }
499
505
 
500
- export declare interface OutputDiagnosticOptions {
506
+ export declare interface OutputDiagnosticOptions extends OutputTaskOptions {
501
507
  /** Structured fidelity diagnostics; rendering never silently invents missing content. */
502
508
  onDiagnostic?: (diagnostic: OutputDiagnostic) => void;
509
+ /** Reject known unsupported content before creating an incomplete file. Default warn. */
510
+ fidelity?: "warn" | "strict";
511
+ }
512
+
513
+ export declare class OutputFidelityError extends Error {
514
+ readonly diagnostics: readonly OutputDiagnostic[];
515
+ readonly code = "output-fidelity";
516
+ constructor(diagnostics: readonly OutputDiagnostic[]);
503
517
  }
504
518
 
505
519
  export declare type OutputFormat = "dom" | "canvas" | "pdf" | "xlsx";
506
520
 
521
+ /** Stage counts are exact completed units; encoding libraries may remain indeterminate. */
522
+ export declare interface OutputTaskOptions {
523
+ signal?: AbortSignal;
524
+ onProgress?: (completed: number, total: number) => void;
525
+ }
526
+
507
527
  export declare class PageBuilder {
508
528
  private readonly parent;
509
529
  private readonly page;
@@ -579,6 +599,9 @@ export declare type PaperName = keyof typeof PAPER_SIZES;
579
599
  /** 日历日字符串 → 本地 Date(不含时间的纯日期,杜绝 UTC 偏移) */
580
600
  export declare function parseDateLocal(input: string): Date | null;
581
601
 
602
+ /** Core type parsing is authoritative; field controls add restrictions, never coerce IDs or bypass readonly. */
603
+ export declare function parseReportCellFieldInput(context: ReportCellContext, input: ReportCellValue, field?: ReportCellFieldOptions): ReportCellValue;
604
+
582
605
  /** 严格解析编辑输入;文本列不隐式推断数值,清空数值/布尔列得到 null。 */
583
606
  export declare function parseReportCellInput(context: ReportCellContext, input: ReportCellValue): ReportCellValue;
584
607
 
@@ -700,6 +723,20 @@ export declare function renderPlanToImages(plan: RenderPlan, options?: ImageRend
700
723
  /** 模板存储文档版本;与渲染计划版本独立演进。 */
701
724
  export declare const REPORT_TEMPLATE_DOCUMENT_VERSION = "1.0";
702
725
 
726
+ export declare class ReportCalculationError extends Error {
727
+ readonly code: ReportCalculationErrorCode;
728
+ constructor(code: ReportCalculationErrorCode);
729
+ }
730
+
731
+ export declare type ReportCalculationErrorCode = "selection" | "limit" | "expression" | "division" | "overflow" | "precision";
732
+
733
+ export declare type ReportCalculationOperation = "sum" | "average" | "min" | "max" | "count" | "median" | "expression";
734
+
735
+ export declare interface ReportCalculationSelection {
736
+ anchor: ReportCellAddress;
737
+ focus: ReportCellAddress;
738
+ }
739
+
703
740
  /** 预览中的物理坐标;合并单元格使用左上角坐标。 */
704
741
  export declare interface ReportCellAddress {
705
742
  pageIndex: number;
@@ -708,6 +745,11 @@ export declare interface ReportCellAddress {
708
745
  columnIndex: number;
709
746
  }
710
747
 
748
+ export declare interface ReportCellChoice {
749
+ value: Exclude<ReportCellValue, null>;
750
+ label?: string;
751
+ }
752
+
711
753
  export declare interface ReportCellContext {
712
754
  address: ReportCellAddress;
713
755
  cell: Readonly<GridCell>;
@@ -740,6 +782,45 @@ export declare type ReportCellEditErrorCode = "missing" | "readonly" | "number"
740
782
 
741
783
  export declare function reportCellEditKey(edit: Pick<ReportCellEdit, "address" | "source" | "table">): string;
742
784
 
785
+ declare interface ReportCellFieldBase {
786
+ /** Presentation only; it never grants write permission. */
787
+ label?: string;
788
+ hint?: string;
789
+ unit?: string;
790
+ required?: boolean;
791
+ }
792
+
793
+ /** Shared structured validation for browser editors, pasted values and backend adapters. */
794
+ export declare class ReportCellFieldError extends Error {
795
+ readonly code: ReportCellFieldErrorCode;
796
+ readonly field: ReportCellFieldOptions;
797
+ readonly expected?: string | number | undefined;
798
+ constructor(code: ReportCellFieldErrorCode, field: ReportCellFieldOptions, expected?: string | number | undefined);
799
+ }
800
+
801
+ export declare type ReportCellFieldErrorCode = "definition" | "type" | "required" | "min" | "max" | "precision" | "length" | "choice" | "date";
802
+
803
+ export declare type ReportCellFieldOptions = ReportCellFieldBase & ({
804
+ type: "text";
805
+ maxLength?: number;
806
+ } | {
807
+ type: "number";
808
+ min?: number;
809
+ max?: number;
810
+ precision?: number;
811
+ } | {
812
+ type: "boolean";
813
+ trueLabel?: string;
814
+ falseLabel?: string;
815
+ } | {
816
+ type: "enum";
817
+ options: readonly ReportCellChoice[];
818
+ } | {
819
+ type: "date";
820
+ min?: string;
821
+ max?: string;
822
+ });
823
+
743
824
  export declare interface ReportCellInput {
744
825
  address: ReportCellAddress;
745
826
  value: ReportCellValue;
@@ -824,7 +905,7 @@ export declare interface ReportFetcher {
824
905
  getParamDefs?: (reportIds: string[]) => ReportParamDef[];
825
906
  }
826
907
 
827
- export declare interface ReportFetchInput {
908
+ export declare interface ReportFetchInput extends ReportTaskMonitoring {
828
909
  reportIds: string[];
829
910
  params: Record<string, string>;
830
911
  signal?: AbortSignal;
@@ -953,6 +1034,28 @@ export declare interface ReportSaveResult {
953
1034
  diagnostics?: ReportDiagnostic[];
954
1035
  }
955
1036
 
1037
+ export declare interface ReportSelectionCalculationOptions {
1038
+ operation?: ReportCalculationOperation;
1039
+ /** Only aggregate names, finite numeric constants, + - * / and parentheses. No cell/Excel formulas. */
1040
+ expression?: string;
1041
+ precision?: number;
1042
+ maxCells?: number;
1043
+ maxScannedCells?: number;
1044
+ signal?: AbortSignal;
1045
+ /** Cooperative scheduler; default yields to the browser/Node event loop. */
1046
+ yieldToHost?: () => Promise<void>;
1047
+ }
1048
+
1049
+ export declare interface ReportSelectionCalculationResult {
1050
+ value: number | null;
1051
+ formatted: string;
1052
+ numericCells: number;
1053
+ excludedCells: number;
1054
+ selectedCells: number;
1055
+ /** IEEE-754 arithmetic; presentation rounding does not change source values. */
1056
+ precision: number;
1057
+ }
1058
+
956
1059
  export declare interface ReportSource extends ReportFetcher {
957
1060
  getParamDefs(reportIds: string[]): ReportParamDef[];
958
1061
  }
@@ -963,6 +1066,25 @@ export declare class ReportSourceError extends Error {
963
1066
  constructor(code: ReportSourceError["code"], message: string, cause?: unknown);
964
1067
  }
965
1068
 
1069
+ /** 阶段事件只包含可序列化值;不表示估算百分比,也不包含业务数据。 */
1070
+ export declare interface ReportTaskEvent {
1071
+ taskId: string;
1072
+ correlationId?: string;
1073
+ stage: "query" | "validate" | "layout" | "encode";
1074
+ status: "started" | "completed" | "failed";
1075
+ reportId?: string;
1076
+ completed?: number;
1077
+ total?: number;
1078
+ }
1079
+
1080
+ export declare interface ReportTaskMonitoring {
1081
+ taskId?: string;
1082
+ correlationId?: string;
1083
+ onEvent?: ReportTaskObserver;
1084
+ }
1085
+
1086
+ export declare type ReportTaskObserver = (event: ReportTaskEvent) => void;
1087
+
966
1088
  export declare interface ReportTemplate {
967
1089
  schemaVersion?: string;
968
1090
  /** 参数定义(可选;宿主也可经 ReportPreview 的 paramDefs prop 提供,prop 优先) */
@@ -1282,6 +1404,9 @@ export declare function validatePage(page: unknown, path: string, errors: Valida
1282
1404
 
1283
1405
  export declare function validateRenderPlan(input: unknown): ValidationResult;
1284
1406
 
1407
+ /** Check configuration before opening an input, including JSON/JavaScript callers. */
1408
+ export declare function validateReportCellFieldDefinition(context: ReportCellContext, field: ReportCellFieldOptions): void;
1409
+
1285
1410
  /** 模板参数配置错误也统一返回结构化问题,不让无效默认值或边界静默进入后端。 */
1286
1411
  export declare function validateReportParamDefinitions(defs: readonly ReportParamDef[]): ReportParamIssue[];
1287
1412