@agile-team/mach-report 2.25.1 → 2.26.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 (143) hide show
  1. package/README.md +14 -8
  2. package/dist/ExcelBindingWizard-B418l44t.js +1578 -0
  3. package/dist/ExcelBindingWizard-C4FGVsY_.cjs +1 -0
  4. package/dist/{ParamEditor-CGfaweYX.cjs → ParamEditor-BemJE8n8.cjs} +1 -1
  5. package/dist/{ParamEditor-B7YVD28E.js → ParamEditor-XvMtf_XQ.js} +2 -2
  6. package/dist/{ReportBatchPanel-BRJt0TXp.cjs → ReportBatchPanel-CbY4fvXD.cjs} +1 -1
  7. package/dist/{ReportBatchPanel-BTKHtLTW.js → ReportBatchPanel-Ds0R_uXn.js} +37 -37
  8. package/dist/{ReportLabelStudio-BvK_WBke.cjs → ReportLabelStudio-DuTwN5er.cjs} +1 -1
  9. package/dist/{ReportLabelStudio-CZwqyO3t.js → ReportLabelStudio-ZFy79eRv.js} +26 -26
  10. package/dist/ReportParamPanel-Chxu4MTx.cjs +1 -0
  11. package/dist/{ReportParamPanel-DGXzBzl2.js → ReportParamPanel-Czm3OPo_.js} +216 -205
  12. package/dist/ReportPreview-C9c0Rp7Y.js +7380 -0
  13. package/dist/ReportPreview-CIMR4ERo.cjs +6 -0
  14. package/dist/{ReportTemplateLibrary-ClwxhnC0.cjs → ReportTemplateLibrary-C6lByc69.cjs} +1 -1
  15. package/dist/{ReportTemplateLibrary-C7sB0Jay.js → ReportTemplateLibrary-XJVoTDIz.js} +1 -1
  16. package/dist/{RuleEditor-CsDGFaWz.js → RuleEditor-CeNFPeOc.js} +5 -5
  17. package/dist/{RuleEditor-D-OdaGdR.cjs → RuleEditor-gggUkEwB.cjs} +1 -1
  18. package/dist/{TemplateOutlinePanel-DAqR9zQi.cjs → TemplateOutlinePanel-B0e-umq2.cjs} +1 -1
  19. package/dist/{TemplateOutlinePanel-CXOT7d1r.js → TemplateOutlinePanel-BWN4Y9iz.js} +2 -2
  20. package/dist/{TemplateReusePanel-Dcfx3Hba.js → TemplateReusePanel-CR-4OHoU.js} +2 -2
  21. package/dist/{TemplateReusePanel-ygIi-Ajz.cjs → TemplateReusePanel-Cthig1S1.cjs} +1 -1
  22. package/dist/{TemplateReviewPanel-COU8FqPq.js → TemplateReviewPanel-BkWzyNL4.js} +2 -2
  23. package/dist/{TemplateReviewPanel-DyGULVxr.cjs → TemplateReviewPanel-D8o2gDaK.cjs} +1 -1
  24. package/dist/analytics.cjs +1 -1
  25. package/dist/analytics.js +5 -5
  26. package/dist/artifact-integrity.json +106 -102
  27. package/dist/{assets-C4MIvzQ4.js → assets-BFTP-0WR.js} +2 -2
  28. package/dist/{assets-BYdpkTIt.cjs → assets-CZiZhTf2.cjs} +1 -1
  29. package/dist/{auto-D7x7QsWD.js → auto-C7udkeAa.js} +89 -88
  30. package/dist/auto-CXd2E2aZ.cjs +1 -0
  31. package/dist/capabilities-D8UU2clQ.cjs +1 -0
  32. package/dist/{capabilities-CN_kSVjO.js → capabilities-g0a2j9Yy.js} +50 -46
  33. package/dist/{charts-Cjw5AYkg.cjs → charts-D-Vg-ak9.cjs} +1 -1
  34. package/dist/{charts-CxJZ0XaY.js → charts-D48XCefN.js} +1 -1
  35. package/dist/computed-BQgBrma-.cjs +1 -0
  36. package/dist/{computed-f3pOqWLX.js → computed-CH3NYPOW.js} +198 -188
  37. package/dist/{data-bar-Bfh54sT4.js → data-bar-DjOgTLqu.js} +1 -1
  38. package/dist/{dataset-DL83majE.js → dataset-B8oTsC6o.js} +69 -66
  39. package/dist/dataset-D3OsyzG1.cjs +1 -0
  40. package/dist/designer-COuSUxZ1.cjs +2 -0
  41. package/dist/designer-CT4mlrr0.js +7997 -0
  42. package/dist/designer.cjs +1 -1
  43. package/dist/designer.d.cts +83 -4
  44. package/dist/designer.d.ts +83 -4
  45. package/dist/designer.js +4 -4
  46. package/dist/{diagnostic-collector-gB07PHy2.js → diagnostic-collector-C-JBA016.js} +2 -2
  47. package/dist/dom-DgWc-DY1.js +452 -0
  48. package/dist/dom-Fk4NF-gN.cjs +1 -0
  49. package/dist/{encoding-Amq3XrtU.js → encoding-D480EM2r.js} +2 -2
  50. package/dist/{encoding-DRVXs5xm.cjs → encoding-tWc2Wn89.cjs} +1 -1
  51. package/dist/execution-result-7sG_mdcD.cjs +1 -0
  52. package/dist/execution-result-Ba65gieT.js +39 -0
  53. package/dist/{font-loader-p_SyTvqt.cjs → font-loader-BIxme_9g.cjs} +1 -1
  54. package/dist/{font-loader-D4NLIKJL.js → font-loader-CHmEwkHl.js} +1 -1
  55. package/dist/{grid-strokes-DkZEZvcI.js → grid-strokes-DsoICRjZ.js} +1 -1
  56. package/dist/import-range-BwT86Z3j.cjs +1 -0
  57. package/dist/import-range-D9p_blcb.js +98 -0
  58. package/dist/index.cjs +1 -1
  59. package/dist/index.d.cts +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.js +25 -25
  62. package/dist/{json-snapshot-CBVWZvyC.js → json-snapshot-BZ0CIQln.js} +1142 -951
  63. package/dist/json-snapshot-DGFeI30h.cjs +2 -0
  64. package/dist/{matrix-b6T291xo.js → matrix-CB9TqTEy.js} +1 -1
  65. package/dist/{matrix-DUYPRL7t.cjs → matrix-CcqYOuq_.cjs} +1 -1
  66. package/dist/{pdf-DU8HelKd.js → pdf-DTR7fAIr.js} +3596 -3517
  67. package/dist/{pdf-C060D5UY.cjs → pdf-d9oJ6V0P.cjs} +49 -49
  68. package/dist/pdf.cjs +1 -1
  69. package/dist/pdf.js +2 -2
  70. package/dist/{plugin-DHe8y5pD.cjs → plugin-B7Bi-1te.cjs} +1 -1
  71. package/dist/{plugin-BdCplNe1.js → plugin-OKDFQFS4.js} +1 -1
  72. package/dist/{prefill-Buy4NJ15.js → prefill-C8fF91JB.js} +3 -3
  73. package/dist/{prefill-Cw4ZYGXZ.cjs → prefill-C_Bf_AMo.cjs} +1 -1
  74. package/dist/{prepared-BlNeOjoO.cjs → prepared-BLhV7vdE.cjs} +1 -1
  75. package/dist/{prepared-CBJ7BkK0.js → prepared-DhgQ0d-h.js} +7 -7
  76. package/dist/protocol-CZ-BILne.cjs +1 -0
  77. package/dist/{protocol-CB19KXGr.js → protocol-DHO91-Jt.js} +3 -3
  78. package/dist/{record-bindings-Cv7lFiof.js → record-bindings-DBrCu6zO.js} +3 -3
  79. package/dist/{record-bindings-B7djSjNs.cjs → record-bindings-KEs-DKCS.cjs} +1 -1
  80. package/dist/region-binding-workflow-FSyIZge8.js +882 -0
  81. package/dist/region-binding-workflow-ikpY1Kbw.cjs +3 -0
  82. package/dist/report-encoding-worker.cjs +1 -1
  83. package/dist/report-encoding-worker.js +1 -1
  84. package/dist/rich-text-layout-BYbIc3eJ.cjs +3 -0
  85. package/dist/rich-text-layout-BtygMWZC.js +96 -0
  86. package/dist/runtime-B5HG8poy.cjs +1 -0
  87. package/dist/runtime-BsvAqz4a.js +204 -0
  88. package/dist/sbom.cdx.json +1 -1
  89. package/dist/server-node.cjs +5 -5
  90. package/dist/server-node.js +2323 -2120
  91. package/dist/server.cjs +1 -1
  92. package/dist/server.d.cts +35 -0
  93. package/dist/server.d.ts +35 -0
  94. package/dist/server.js +340 -328
  95. package/dist/style.css +1 -1
  96. package/dist/{template-catalog-CM6U_RlD.js → template-catalog-BbrN9dgu.js} +5 -5
  97. package/dist/{template-catalog-Cj66M84u.cjs → template-catalog-DDH-5J57.cjs} +1 -1
  98. package/dist/{template-fragments-BDxdCuMD.js → template-fragments-CUTE8-_I.js} +3 -3
  99. package/dist/{template-fragments-DbKdxI1z.cjs → template-fragments-cyAQu7aw.cjs} +1 -1
  100. package/dist/{template-registry-B-AK1oam.cjs → template-registry-D24Z8aQf.cjs} +1 -1
  101. package/dist/{template-registry-DeVgwEZj.js → template-registry-PSuLsnyq.js} +4 -4
  102. package/dist/{template-serialization-CqQY4zDg.cjs → template-serialization-BOUidUlh.cjs} +1 -1
  103. package/dist/{template-serialization-CWmHq7lX.js → template-serialization-BgGWYV_1.js} +1 -1
  104. package/dist/{textwrap-BywMBMXM.js → textwrap-Bt_tnI6V.js} +1 -1
  105. package/dist/vue/async.d.cts +46 -3
  106. package/dist/vue/async.d.ts +46 -3
  107. package/dist/vue/index.d.cts +217 -25
  108. package/dist/vue/index.d.ts +217 -25
  109. package/dist/vue-async.cjs +1 -1
  110. package/dist/vue-async.js +3 -3
  111. package/dist/vue.cjs +1 -1
  112. package/dist/vue.js +434 -202
  113. package/dist/workbook-session-BJfZVp4q.cjs +29 -0
  114. package/dist/{workbook-session-B6hRjTyX.js → workbook-session-DRnMjIFK.js} +2377 -2350
  115. package/dist/worker.cjs +1 -1
  116. package/dist/worker.js +4 -4
  117. package/dist/xlsx.cjs +1 -1
  118. package/dist/xlsx.d.cts +27 -2
  119. package/dist/xlsx.d.ts +27 -2
  120. package/dist/xlsx.js +15 -15
  121. package/package.json +1 -1
  122. package/dist/ExcelBindingWizard-bs3F4dD8.js +0 -1486
  123. package/dist/ExcelBindingWizard-jSdjBtWw.cjs +0 -1
  124. package/dist/ReportParamPanel-B27IGJjk.cjs +0 -1
  125. package/dist/ReportPreview-CnxaDTCO.js +0 -7170
  126. package/dist/ReportPreview-DqFBcsJQ.cjs +0 -6
  127. package/dist/auto-mPK9W0y5.cjs +0 -1
  128. package/dist/capabilities-D4nfhcvB.cjs +0 -1
  129. package/dist/computed-DK6BruFz.cjs +0 -1
  130. package/dist/dataset-IrlXbUvh.cjs +0 -1
  131. package/dist/designer-B597ZdC0.js +0 -7595
  132. package/dist/designer-DFIdv_n7.cjs +0 -2
  133. package/dist/dom-CXWMmwh-.cjs +0 -1
  134. package/dist/dom-DxdCMLzs.js +0 -452
  135. package/dist/json-snapshot-DCFEtfFw.cjs +0 -2
  136. package/dist/protocol-BU_4sXP0.cjs +0 -1
  137. package/dist/region-binding-workflow-EYxvUYJ-.js +0 -977
  138. package/dist/region-binding-workflow-NdkMSFCh.cjs +0 -3
  139. package/dist/rich-text-layout-Ch_N0Ubu.js +0 -52
  140. package/dist/rich-text-layout-yJGuThtC.cjs +0 -3
  141. package/dist/runtime-B5d_lQNQ.js +0 -227
  142. package/dist/runtime-BRx8Agqr.cjs +0 -1
  143. package/dist/workbook-session-BclW7KKH.cjs +0 -29
@@ -1,4 +1,4 @@
1
- import { E as n } from "./diagnostic-collector-gB07PHy2.js";
1
+ import { E as n } from "./diagnostic-collector-C-JBA016.js";
2
2
  function i(t, r, d, o) {
3
3
  if (!n(t) || t.start === t.end) return;
4
4
  const a = Math.max(0, r - 2 * o);
@@ -1,136 +1,138 @@
1
- function u(e) {
1
+ function c(e) {
2
2
  throw new Error(`数据契约无效:${e}`);
3
3
  }
4
- function d(e) {
4
+ function p(e) {
5
5
  return typeof e == "string" && e.trim().length > 0 && e.length <= 4096;
6
6
  }
7
7
  function y(e) {
8
- for (const n of ["description", "missingMeaning"]) e[n] !== void 0 && !d(e[n]) && u(`${n} 应为 1–4096 位非空字符串`);
9
- e.aggregation !== void 0 && !["sum", "avg", "min", "max", "count", "none"].includes(e.aggregation) && u("未知字段聚合语义"), e.aggregation && !["count", "none"].includes(e.aggregation) && !["number", "decimal"].includes(e.type) && u("数值聚合仅适用于 number/decimal"), e.format !== void 0 && l(e), e.calculation !== void 0 && (!e.calculation || !d(e.calculation.description) || !Array.isArray(e.calculation.dependsOn) || !e.calculation.dependsOn.length || e.calculation.dependsOn.length > 256 || e.calculation.dependsOn.some((n) => typeof n != "string" || !n.trim()) || new Set(e.calculation.dependsOn).size !== e.calculation.dependsOn.length) && u("计算说明需包含说明及 1–256 个唯一依赖字段");
8
+ for (const n of ["description", "missingMeaning"]) e[n] !== void 0 && !p(e[n]) && c(`${n} 应为 1–4096 位非空字符串`);
9
+ e.aggregation !== void 0 && !["sum", "avg", "min", "max", "count", "none"].includes(e.aggregation) && c("未知字段聚合语义"), e.aggregation && !["count", "none"].includes(e.aggregation) && !["number", "decimal"].includes(e.type) && c("数值聚合仅适用于 number/decimal"), e.format !== void 0 && x(e), e.calculation !== void 0 && (!e.calculation || !p(e.calculation.description) || !Array.isArray(e.calculation.dependsOn) || !e.calculation.dependsOn.length || e.calculation.dependsOn.length > 256 || e.calculation.dependsOn.some((n) => typeof n != "string" || !n.trim()) || new Set(e.calculation.dependsOn).size !== e.calculation.dependsOn.length) && c("计算说明需包含说明及 1–256 个唯一依赖字段");
10
10
  }
11
- function l(e) {
11
+ function x(e) {
12
12
  const n = e.format;
13
- if ((!n || !["number", "percent", "date"].includes(n.kind)) && u("未知字段显示格式"), n.kind === "date") {
14
- (e.type !== "date" || n.pattern !== void 0 && (!d(n.pattern) || n.pattern.length > 128)) && u("日期格式仅适用于日期,pattern 最多 128 位");
13
+ if ((!n || !["number", "percent", "date"].includes(n.kind)) && c("未知字段显示格式"), n.kind === "date") {
14
+ (e.type !== "date" || n.pattern !== void 0 && (!p(n.pattern) || n.pattern.length > 128)) && c("日期格式仅适用于日期,pattern 最多 128 位");
15
15
  return;
16
16
  }
17
- ["number", "decimal"].includes(e.type) || u("数值显示格式仅适用于 number/decimal"), n.digits !== void 0 && (!Number.isSafeInteger(n.digits) || n.digits < 0 || n.digits > 100) && u("显示小数位应为 0–100 的整数"), n.kind === "number" && n.thousands !== void 0 && typeof n.thousands != "boolean" && u("thousands 应为布尔值");
17
+ ["number", "decimal"].includes(e.type) || c("数值显示格式仅适用于 number/decimal"), n.digits !== void 0 && (!Number.isSafeInteger(n.digits) || n.digits < 0 || n.digits > 100) && c("显示小数位应为 0–100 的整数"), n.kind === "number" && n.thousands !== void 0 && typeof n.thousands != "boolean" && c("thousands 应为布尔值");
18
18
  }
19
- function x(e) {
19
+ function b(e) {
20
20
  const n = new Map(e.map((i) => [i.field, i])), t = /* @__PURE__ */ new Set();
21
21
  for (const i of e) {
22
- const o = [{ field: i.field, exit: !1 }], m = /* @__PURE__ */ new Set();
22
+ const o = [{ field: i.field, exit: !1 }], r = /* @__PURE__ */ new Set();
23
23
  for (; o.length; ) {
24
24
  const s = o.pop();
25
25
  if (s.exit) {
26
- m.delete(s.field), t.add(s.field);
26
+ r.delete(s.field), t.add(s.field);
27
27
  continue;
28
28
  }
29
- if (m.has(s.field) && u("字段计算依赖存在循环"), t.has(s.field)) continue;
30
- const r = n.get(s.field);
31
- r || u(`计算依赖字段未声明:${s.field}`), m.add(s.field), o.push({ field: s.field, exit: !0 });
32
- for (const c of r.calculation?.dependsOn ?? []) o.push({ field: c, exit: !1 });
29
+ if (r.has(s.field) && c("字段计算依赖存在循环"), t.has(s.field)) continue;
30
+ const m = n.get(s.field);
31
+ m || c(`计算依赖字段未声明:${s.field}`), r.add(s.field), o.push({ field: s.field, exit: !0 });
32
+ for (const u of m.calculation?.dependsOn ?? []) o.push({ field: u, exit: !1 });
33
33
  }
34
34
  }
35
35
  }
36
- const b = ["text", "number", "boolean", "date", "decimal"], w = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
36
+ const w = ["text", "number", "boolean", "date", "decimal"], v = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
37
37
  function a(e) {
38
38
  throw new Error(`数据契约无效:${e}`);
39
39
  }
40
- function h(e) {
40
+ function f(e) {
41
41
  (!e || !Array.isArray(e.fields) || !e.fields.length || e.fields.length > 2048) && a("fields 应包含 1–2048 个字段");
42
42
  const n = /* @__PURE__ */ new Set();
43
43
  for (const t of e.fields)
44
- (!t || typeof t.field != "string" || !t.field.trim() || w.has(t.field) || n.has(t.field)) && a("字段名应安全、非空且唯一"), n.add(t.field), b.includes(t.type) || a(`未知字段类型 ${t.type}`), k(t), $(t), y(t), v(t);
45
- L(e, n), x(e.fields);
44
+ (!t || typeof t.field != "string" || !t.field.trim() || v.has(t.field) || n.has(t.field)) && a("字段名应安全、非空且唯一"), n.add(t.field), w.includes(t.type) || a(`未知字段类型 ${t.type}`), O(t), k(t), y(t), L(t);
45
+ $(e, n), b(e.fields);
46
46
  }
47
- function v(e) {
48
- e.enum !== void 0 && (!Array.isArray(e.enum) || !e.enum.length || e.enum.some((n) => !f(n, e.type))) && a("enum 应为匹配字段类型的非空标量数组");
47
+ function L(e) {
48
+ e.enum !== void 0 && (!Array.isArray(e.enum) || !e.enum.length || e.enum.some((n) => !l(n, e.type))) && a("enum 应为匹配字段类型的非空标量数组");
49
49
  }
50
- function L(e, n) {
50
+ function $(e, n) {
51
51
  e.rowKey !== void 0 && ((typeof e.rowKey != "string" || !e.rowKey.trim() || !n.has(e.rowKey)) && a("rowKey 应为引用已声明字段的非空字符串"), e.fields.find((t) => t.field === e.rowKey)?.type === "boolean" && a("布尔字段不能作为业务主键"));
52
52
  }
53
- function $(e) {
53
+ function k(e) {
54
54
  for (const n of ["label", "unit"]) e[n] !== void 0 && typeof e[n] != "string" && a(`${n} 应为字符串`);
55
55
  for (const n of ["required", "nullable"]) e[n] !== void 0 && typeof e[n] != "boolean" && a(`${n} 应为布尔值`);
56
56
  e.semanticRole !== void 0 && !["identifier", "dimension", "measure", "date", "text"].includes(e.semanticRole) && a("未知字段语义");
57
57
  }
58
- function k(e) {
58
+ function O(e) {
59
59
  for (const n of ["min", "max", "minLength", "maxLength"]) {
60
60
  const t = e[n];
61
61
  t !== void 0 && (!Number.isFinite(t) || n.includes("Length") && (!Number.isInteger(t) || t < 0)) && a(`${n} 无效`);
62
62
  }
63
63
  e.min !== void 0 && e.max !== void 0 && e.min > e.max && a("min 不能超过 max"), e.minLength !== void 0 && e.maxLength !== void 0 && e.minLength > e.maxLength && a("minLength 不能超过 maxLength"), e.type !== "number" && (e.min !== void 0 || e.max !== void 0) && a("min/max 仅适用于 number,精确小数文本需业务校验"), ["number", "boolean"].includes(e.type) && (e.minLength !== void 0 || e.maxLength !== void 0) && a("长度约束仅适用于文本类型");
64
64
  }
65
- function O(e) {
65
+ function S(e) {
66
66
  const n = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
67
67
  if (!n) return !1;
68
- const t = Number(n[1]), i = Number(n[2]), o = Number(n[3]), m = t % 4 === 0 && (t % 100 !== 0 || t % 400 === 0);
69
- return t > 0 && i >= 1 && i <= 12 && o >= 1 && o <= [31, m ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][i - 1];
68
+ const t = Number(n[1]), i = Number(n[2]), o = Number(n[3]), r = t % 4 === 0 && (t % 100 !== 0 || t % 400 === 0);
69
+ return t > 0 && i >= 1 && i <= 12 && o >= 1 && o <= [31, r ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][i - 1];
70
70
  }
71
- function f(e, n) {
72
- return n === "number" ? typeof e == "number" && Number.isFinite(e) : n === "boolean" ? typeof e == "boolean" : typeof e != "string" ? !1 : n === "date" ? O(e) : n === "decimal" ? e.length <= 1e4 && /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(e) : !0;
71
+ function l(e, n) {
72
+ return n === "number" ? typeof e == "number" && Number.isFinite(e) : n === "boolean" ? typeof e == "boolean" : typeof e != "string" ? !1 : n === "date" ? S(e) : n === "decimal" ? e.length <= 1e4 && /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(e) : !0;
73
73
  }
74
- function S(e, n) {
74
+ function K(e, n) {
75
75
  if (e == null)
76
76
  return n.required || e === null && n.nullable === !1 ? { code: "required", message: "缺少必需字段值" } : void 0;
77
- if (!f(e, n.type)) return { code: "type", message: `值应为 ${n.type},不会自动转换原始值` };
77
+ if (!l(e, n.type)) return { code: "type", message: `值应为 ${n.type},不会自动转换原始值` };
78
78
  if (n.enum && !n.enum.includes(e)) return { code: "enum", message: "值不在允许的枚举中" };
79
79
  if (typeof e == "number" && (n.min !== void 0 && e < n.min || n.max !== void 0 && e > n.max)) return { code: "range", message: "数值超出范围" };
80
- if (typeof e == "string" && !K(e, n)) return { code: "range", message: "文本长度超出范围" };
80
+ if (typeof e == "string" && !A(e, n)) return { code: "range", message: "文本长度超出范围" };
81
81
  }
82
- function K(e, n) {
82
+ function A(e, n) {
83
83
  if (n.minLength === void 0 && n.maxLength === void 0) return !0;
84
84
  let t = 0;
85
85
  for (const i of e) t++;
86
86
  return (n.minLength === void 0 || t >= n.minLength) && (n.maxLength === void 0 || t <= n.maxLength);
87
87
  }
88
- function g(e, n) {
88
+ function d(e, n) {
89
89
  const t = e ?? n;
90
90
  if (!Number.isInteger(t) || t < 1) throw new Error("数据校验预算应为正整数");
91
91
  return t;
92
92
  }
93
- function A(e, n, t) {
93
+ function N(e, n, t) {
94
94
  const i = Object.prototype.hasOwnProperty.call(e, n) ? e[n] : void 0;
95
95
  if ((typeof i != "string" || !i.trim()) && !(typeof i == "number" && Number.isFinite(i))) return "业务主键应为非空字符串或有限数字";
96
96
  const o = JSON.stringify([typeof i, i]);
97
97
  if (t.has(o)) return "业务主键重复";
98
98
  t.add(o);
99
99
  }
100
- function M(e, n, t = {}) {
101
- h(n);
102
- const i = t.path ?? "$.rows", o = [], m = g(t.maxIssues, 100);
103
- if (!Array.isArray(e)) return { ok: !1, issues: [{ code: "row", path: i, message: "数据集应为对象数组" }] };
104
- if (e.length > g(t.maxRows, 1e5) || e.length * n.fields.length > g(t.maxCells, 2e6)) return { ok: !1, issues: [{ code: "budget", path: i, message: "数据校验超出行数或单元格预算" }] };
105
- const s = /* @__PURE__ */ new Set();
106
- for (let r = 0; r < e.length && o.length < m; r++) {
107
- const c = e[r];
108
- if (!c || typeof c != "object" || Array.isArray(c)) {
109
- o.push({ code: "row", path: `${i}[${r}]`, rowIndex: r, message: "行应为对象" });
110
- continue;
111
- }
112
- N(c, n, r, i, s, o, m);
100
+ function F(e, n, t = {}) {
101
+ const i = R(e, n, t, !1);
102
+ let o = i.next();
103
+ for (; !o.done; ) o = i.next();
104
+ return o.value;
105
+ }
106
+ function* R(e, n, t = {}, i = !0) {
107
+ f(n);
108
+ const o = t.path ?? "$.rows", r = [], s = d(t.maxIssues, 100);
109
+ if (!Array.isArray(e)) return { ok: !1, issues: [{ code: "row", path: o, message: "数据集应为对象数组" }] };
110
+ if (e.length > d(t.maxRows, 1e5) || e.length * n.fields.length > d(t.maxCells, 2e6)) return { ok: !1, issues: [{ code: "budget", path: o, message: "数据校验超出行数或单元格预算" }] };
111
+ const m = /* @__PURE__ */ new Set();
112
+ for (let u = 0; u < e.length && r.length < s; u++) {
113
+ const g = e[u];
114
+ !g || typeof g != "object" || Array.isArray(g) ? r.push({ code: "row", path: `${o}[${u}]`, rowIndex: u, message: "行应为对象" }) : E(g, n, u, o, m, r, s), i && (yield);
113
115
  }
114
- return { ok: o.length === 0, issues: o };
116
+ return { ok: r.length === 0, issues: r };
115
117
  }
116
- function N(e, n, t, i, o, m, s) {
117
- for (const r of n.fields) {
118
- if (m.length >= s) return;
119
- const c = S(Object.prototype.hasOwnProperty.call(e, r.field) ? e[r.field] : void 0, r);
120
- c && m.push({ ...c, rowIndex: t, field: r.field, path: `${i}[${t}].${r.field}` });
118
+ function E(e, n, t, i, o, r, s) {
119
+ for (const m of n.fields) {
120
+ if (r.length >= s) return;
121
+ const u = K(Object.prototype.hasOwnProperty.call(e, m.field) ? e[m.field] : void 0, m);
122
+ u && r.push({ ...u, rowIndex: t, field: m.field, path: `${i}[${t}].${m.field}` });
121
123
  }
122
- if (n.rowKey && m.length < s) {
123
- const r = A(e, n.rowKey, o);
124
- r && m.push({ code: "row-key", path: `${i}[${t}].${n.rowKey}`, message: r, rowIndex: t, field: n.rowKey });
124
+ if (n.rowKey && r.length < s) {
125
+ const m = N(e, n.rowKey, o);
126
+ m && r.push({ code: "row-key", path: `${i}[${t}].${n.rowKey}`, message: m, rowIndex: t, field: n.rowKey });
125
127
  }
126
128
  }
127
- function j(e) {
128
- return h(e), { $schema: "https://json-schema.org/draft/2020-12/schema", type: "array", items: { type: "object", properties: Object.fromEntries(e.fields.map((t) => [t.field, R(t, t.field === e.rowKey)])), required: e.fields.filter((t) => t.required || t.field === e.rowKey).map((t) => t.field), additionalProperties: !0 }, ...e.rowKey ? { "x-report-rowKey": e.rowKey } : {} };
129
+ function q(e) {
130
+ return f(e), { $schema: "https://json-schema.org/draft/2020-12/schema", type: "array", items: { type: "object", properties: Object.fromEntries(e.fields.map((t) => [t.field, M(t, t.field === e.rowKey)])), required: e.fields.filter((t) => t.required || t.field === e.rowKey).map((t) => t.field), additionalProperties: !0 }, ...e.rowKey ? { "x-report-rowKey": e.rowKey } : {} };
129
131
  }
130
- function R(e, n) {
132
+ function M(e, n) {
131
133
  const t = !n && e.nullable !== !1 && !e.required;
132
134
  return {
133
- type: t ? [p(e.type), "null"] : p(e.type),
135
+ type: t ? [h(e.type), "null"] : h(e.type),
134
136
  ...e.label ? { title: e.label } : {},
135
137
  ...e.description ? { description: e.description } : {},
136
138
  ...e.type === "date" ? { format: "date" } : {},
@@ -138,7 +140,7 @@ function R(e, n) {
138
140
  ...e.enum ? { enum: t ? [...e.enum, null] : [...e.enum] } : {},
139
141
  ...e.min === void 0 ? {} : { minimum: e.min },
140
142
  ...e.max === void 0 ? {} : { maximum: e.max },
141
- ...E(e, n),
143
+ ...j(e, n),
142
144
  ...n && e.type === "text" ? { pattern: "\\S" } : {},
143
145
  ...e.unit ? { "x-report-unit": e.unit } : {},
144
146
  ...e.semanticRole ? { "x-report-semanticRole": e.semanticRole } : {},
@@ -148,14 +150,15 @@ function R(e, n) {
148
150
  ...e.calculation ? { "x-report-calculation": { description: e.calculation.description, dependsOn: [...e.calculation.dependsOn] } } : {}
149
151
  };
150
152
  }
151
- function E(e, n) {
153
+ function j(e, n) {
152
154
  const t = {};
153
155
  return (e.minLength !== void 0 || n && e.type !== "number") && (t.minLength = Math.max(e.minLength ?? 0, n ? 1 : 0)), e.type === "decimal" ? t.maxLength = Math.min(e.maxLength ?? 1e4, 1e4) : e.maxLength !== void 0 && (t.maxLength = e.maxLength), t;
154
156
  }
155
- function p(e) {
157
+ function h(e) {
156
158
  return e === "text" || e === "date" || e === "decimal" ? "string" : e;
157
159
  }
158
160
  export {
159
- j as d,
160
- M as v
161
+ q as d,
162
+ R as i,
163
+ F as v
161
164
  };
@@ -0,0 +1 @@
1
+ "use strict";function c(e){throw new Error(`数据契约无效:${e}`)}function h(e){return typeof e=="string"&&e.trim().length>0&&e.length<=4096}function x(e){for(const n of["description","missingMeaning"])e[n]!==void 0&&!h(e[n])&&c(`${n} 应为 1–4096 位非空字符串`);e.aggregation!==void 0&&!["sum","avg","min","max","count","none"].includes(e.aggregation)&&c("未知字段聚合语义"),e.aggregation&&!["count","none"].includes(e.aggregation)&&!["number","decimal"].includes(e.type)&&c("数值聚合仅适用于 number/decimal"),e.format!==void 0&&b(e),e.calculation!==void 0&&(!e.calculation||!h(e.calculation.description)||!Array.isArray(e.calculation.dependsOn)||!e.calculation.dependsOn.length||e.calculation.dependsOn.length>256||e.calculation.dependsOn.some(n=>typeof n!="string"||!n.trim())||new Set(e.calculation.dependsOn).size!==e.calculation.dependsOn.length)&&c("计算说明需包含说明及 1–256 个唯一依赖字段")}function b(e){const n=e.format;if((!n||!["number","percent","date"].includes(n.kind))&&c("未知字段显示格式"),n.kind==="date"){(e.type!=="date"||n.pattern!==void 0&&(!h(n.pattern)||n.pattern.length>128))&&c("日期格式仅适用于日期,pattern 最多 128 位");return}["number","decimal"].includes(e.type)||c("数值显示格式仅适用于 number/decimal"),n.digits!==void 0&&(!Number.isSafeInteger(n.digits)||n.digits<0||n.digits>100)&&c("显示小数位应为 0–100 的整数"),n.kind==="number"&&n.thousands!==void 0&&typeof n.thousands!="boolean"&&c("thousands 应为布尔值")}function w(e){const n=new Map(e.map(i=>[i.field,i])),t=new Set;for(const i of e){const o=[{field:i.field,exit:!1}],r=new Set;for(;o.length;){const s=o.pop();if(s.exit){r.delete(s.field),t.add(s.field);continue}if(r.has(s.field)&&c("字段计算依赖存在循环"),t.has(s.field))continue;const m=n.get(s.field);m||c(`计算依赖字段未声明:${s.field}`),r.add(s.field),o.push({field:s.field,exit:!0});for(const u of m.calculation?.dependsOn??[])o.push({field:u,exit:!1})}}}const v=["text","number","boolean","date","decimal"],L=new Set(["__proto__","prototype","constructor"]);function a(e){throw new Error(`数据契约无效:${e}`)}function f(e){(!e||!Array.isArray(e.fields)||!e.fields.length||e.fields.length>2048)&&a("fields 应包含 1–2048 个字段");const n=new Set;for(const t of e.fields)(!t||typeof t.field!="string"||!t.field.trim()||L.has(t.field)||n.has(t.field))&&a("字段名应安全、非空且唯一"),n.add(t.field),v.includes(t.type)||a(`未知字段类型 ${t.type}`),O(t),S(t),x(t),$(t);k(e,n),w(e.fields)}function $(e){e.enum!==void 0&&(!Array.isArray(e.enum)||!e.enum.length||e.enum.some(n=>!l(n,e.type)))&&a("enum 应为匹配字段类型的非空标量数组")}function k(e,n){e.rowKey!==void 0&&((typeof e.rowKey!="string"||!e.rowKey.trim()||!n.has(e.rowKey))&&a("rowKey 应为引用已声明字段的非空字符串"),e.fields.find(t=>t.field===e.rowKey)?.type==="boolean"&&a("布尔字段不能作为业务主键"))}function S(e){for(const n of["label","unit"])e[n]!==void 0&&typeof e[n]!="string"&&a(`${n} 应为字符串`);for(const n of["required","nullable"])e[n]!==void 0&&typeof e[n]!="boolean"&&a(`${n} 应为布尔值`);e.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(e.semanticRole)&&a("未知字段语义")}function O(e){for(const n of["min","max","minLength","maxLength"]){const t=e[n];t!==void 0&&(!Number.isFinite(t)||n.includes("Length")&&(!Number.isInteger(t)||t<0))&&a(`${n} 无效`)}e.min!==void 0&&e.max!==void 0&&e.min>e.max&&a("min 不能超过 max"),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&a("minLength 不能超过 maxLength"),e.type!=="number"&&(e.min!==void 0||e.max!==void 0)&&a("min/max 仅适用于 number,精确小数文本需业务校验"),["number","boolean"].includes(e.type)&&(e.minLength!==void 0||e.maxLength!==void 0)&&a("长度约束仅适用于文本类型")}function K(e){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!n)return!1;const t=Number(n[1]),i=Number(n[2]),o=Number(n[3]),r=t%4===0&&(t%100!==0||t%400===0);return t>0&&i>=1&&i<=12&&o>=1&&o<=[31,r?29:28,31,30,31,30,31,31,30,31,30,31][i-1]}function l(e,n){return n==="number"?typeof e=="number"&&Number.isFinite(e):n==="boolean"?typeof e=="boolean":typeof e!="string"?!1:n==="date"?K(e):n==="decimal"?e.length<=1e4&&/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(e):!0}function A(e,n){if(e==null)return n.required||e===null&&n.nullable===!1?{code:"required",message:"缺少必需字段值"}:void 0;if(!l(e,n.type))return{code:"type",message:`值应为 ${n.type},不会自动转换原始值`};if(n.enum&&!n.enum.includes(e))return{code:"enum",message:"值不在允许的枚举中"};if(typeof e=="number"&&(n.min!==void 0&&e<n.min||n.max!==void 0&&e>n.max))return{code:"range",message:"数值超出范围"};if(typeof e=="string"&&!N(e,n))return{code:"range",message:"文本长度超出范围"}}function N(e,n){if(n.minLength===void 0&&n.maxLength===void 0)return!0;let t=0;for(const i of e)t++;return(n.minLength===void 0||t>=n.minLength)&&(n.maxLength===void 0||t<=n.maxLength)}function d(e,n){const t=e??n;if(!Number.isInteger(t)||t<1)throw new Error("数据校验预算应为正整数");return t}function R(e,n,t){const i=Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0;if((typeof i!="string"||!i.trim())&&!(typeof i=="number"&&Number.isFinite(i)))return"业务主键应为非空字符串或有限数字";const o=JSON.stringify([typeof i,i]);if(t.has(o))return"业务主键重复";t.add(o)}function E(e,n,t={}){const i=y(e,n,t,!1);let o=i.next();for(;!o.done;)o=i.next();return o.value}function*y(e,n,t={},i=!0){f(n);const o=t.path??"$.rows",r=[],s=d(t.maxIssues,100);if(!Array.isArray(e))return{ok:!1,issues:[{code:"row",path:o,message:"数据集应为对象数组"}]};if(e.length>d(t.maxRows,1e5)||e.length*n.fields.length>d(t.maxCells,2e6))return{ok:!1,issues:[{code:"budget",path:o,message:"数据校验超出行数或单元格预算"}]};const m=new Set;for(let u=0;u<e.length&&r.length<s;u++){const g=e[u];!g||typeof g!="object"||Array.isArray(g)?r.push({code:"row",path:`${o}[${u}]`,rowIndex:u,message:"行应为对象"}):M(g,n,u,o,m,r,s),i&&(yield)}return{ok:r.length===0,issues:r}}function M(e,n,t,i,o,r,s){for(const m of n.fields){if(r.length>=s)return;const u=A(Object.prototype.hasOwnProperty.call(e,m.field)?e[m.field]:void 0,m);u&&r.push({...u,rowIndex:t,field:m.field,path:`${i}[${t}].${m.field}`})}if(n.rowKey&&r.length<s){const m=R(e,n.rowKey,o);m&&r.push({code:"row-key",path:`${i}[${t}].${n.rowKey}`,message:m,rowIndex:t,field:n.rowKey})}}function j(e){return f(e),{$schema:"https://json-schema.org/draft/2020-12/schema",type:"array",items:{type:"object",properties:Object.fromEntries(e.fields.map(t=>[t.field,F(t,t.field===e.rowKey)])),required:e.fields.filter(t=>t.required||t.field===e.rowKey).map(t=>t.field),additionalProperties:!0},...e.rowKey?{"x-report-rowKey":e.rowKey}:{}}}function F(e,n){const t=!n&&e.nullable!==!1&&!e.required;return{type:t?[p(e.type),"null"]:p(e.type),...e.label?{title:e.label}:{},...e.description?{description:e.description}:{},...e.type==="date"?{format:"date"}:{},...e.type==="decimal"?{pattern:"^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$"}:{},...e.enum?{enum:t?[...e.enum,null]:[...e.enum]}:{},...e.min===void 0?{}:{minimum:e.min},...e.max===void 0?{}:{maximum:e.max},...q(e,n),...n&&e.type==="text"?{pattern:"\\S"}:{},...e.unit?{"x-report-unit":e.unit}:{},...e.semanticRole?{"x-report-semanticRole":e.semanticRole}:{},...e.aggregation?{"x-report-aggregation":e.aggregation}:{},...e.format?{"x-report-format":{...e.format}}:{},...e.missingMeaning?{"x-report-missingMeaning":e.missingMeaning}:{},...e.calculation?{"x-report-calculation":{description:e.calculation.description,dependsOn:[...e.calculation.dependsOn]}}:{}}}function q(e,n){const t={};return(e.minLength!==void 0||n&&e.type!=="number")&&(t.minLength=Math.max(e.minLength??0,n?1:0)),e.type==="decimal"?t.maxLength=Math.min(e.maxLength??1e4,1e4):e.maxLength!==void 0&&(t.maxLength=e.maxLength),t}function p(e){return e==="text"||e==="date"||e==="decimal"?"string":e}exports.datasetJsonSchema=j;exports.iterateDatasetValidation=y;exports.validateDatasetRows=E;