@agile-team/mach-report 2.13.0 → 2.15.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 (260) hide show
  1. package/README.md +20 -7
  2. package/THIRD_PARTY_NOTICES.md +3 -1
  3. package/dist/ExcelBindingWizard-BKH1nGNS.js +1485 -0
  4. package/dist/ExcelBindingWizard-Bs43BGNp.cjs +1 -0
  5. package/dist/ParamEditor-Da4akw6V.cjs +1 -0
  6. package/dist/ParamEditor-DoAhzJsm.js +594 -0
  7. package/dist/{ReportBatchPanel-CW2HV9I8.js → ReportBatchPanel-BMf6boMA.js} +39 -39
  8. package/dist/ReportBatchPanel-wP9m9Pj1.cjs +1 -0
  9. package/dist/ReportPreview-ChV19HBp.js +4619 -0
  10. package/dist/ReportPreview-DbLvvOUT.cjs +6 -0
  11. package/dist/{ReportTemplateLibrary-BZB-XWjj.js → ReportTemplateLibrary-C9wutIiT.js} +1 -1
  12. package/dist/ReportTemplateLibrary-Sxr3eD0J.cjs +1 -0
  13. package/dist/RuleEditor-C_Clasvd.js +2037 -0
  14. package/dist/RuleEditor-XhGHK8DE.cjs +1 -0
  15. package/dist/TemplateOutlinePanel-D6Bkny59.js +96 -0
  16. package/dist/TemplateOutlinePanel-JTSR53vJ.cjs +1 -0
  17. package/dist/TemplateReusePanel-Kx35S0Ql.cjs +1 -0
  18. package/dist/TemplateReusePanel-rVuK1kTz.js +388 -0
  19. package/dist/TemplateReviewPanel-B0ar9_zf.js +592 -0
  20. package/dist/TemplateReviewPanel-Dn6X9UmY.cjs +1 -0
  21. package/dist/analytics.cjs +1 -1
  22. package/dist/analytics.d.cts +3 -1
  23. package/dist/analytics.d.ts +3 -1
  24. package/dist/analytics.js +154 -60
  25. package/dist/artifact-integrity.json +135 -0
  26. package/dist/assets-B9ImAi6_.cjs +1 -0
  27. package/dist/assets-DEaz4qsp.js +124 -0
  28. package/dist/batch-BaP6pWDE.cjs +1 -0
  29. package/dist/batch-BfZHN1do.js +220 -0
  30. package/dist/batch-CGyt-b2W.js +273 -0
  31. package/dist/batch-CLpELXBl.cjs +1 -0
  32. package/dist/capabilities-CAh2Nrue.cjs +1 -0
  33. package/dist/capabilities-DskCHs3V.js +69 -0
  34. package/dist/codes.d.cts +2 -0
  35. package/dist/codes.d.ts +2 -0
  36. package/dist/{computed-Bvk0W15F.js → computed-C-4C2S5h.js} +3 -3
  37. package/dist/config-BVsJXSqS.js +842 -0
  38. package/dist/config-D10us76d.cjs +1 -0
  39. package/dist/data-explanation-B8MZRYVS.js +16 -0
  40. package/dist/data-explanation-DE55G30w.cjs +1 -0
  41. package/dist/designer-2bDlcNXQ.js +5136 -0
  42. package/dist/designer-BT7XCdbW.cjs +2 -0
  43. package/dist/designer.cjs +1 -2
  44. package/dist/designer.d.cts +432 -17
  45. package/dist/designer.d.ts +432 -17
  46. package/dist/designer.js +21 -4312
  47. package/dist/drill-ByJviLXS.js +145 -0
  48. package/dist/drill-DYTxuL3A.cjs +1 -0
  49. package/dist/font-loader-B_UkxpzC.cjs +1 -0
  50. package/dist/font-loader-Q3bQjmrI.js +297 -0
  51. package/dist/index.cjs +8 -8
  52. package/dist/index.d.cts +239 -5
  53. package/dist/index.d.ts +239 -5
  54. package/dist/index.js +939 -893
  55. package/dist/json-snapshot-DFb2eWkf.js +1416 -0
  56. package/dist/json-snapshot-WWSGlaHG.cjs +2 -0
  57. package/dist/licenses/_bwip-js_generic-4.11.4.txt +24 -0
  58. package/dist/licenses/_fast-csv_format-4.3.5.txt +22 -0
  59. package/dist/licenses/_fast-csv_parse-4.3.6.txt +22 -0
  60. package/dist/licenses/_pdf-lib_fontkit-1.1.1.txt +326 -0
  61. package/dist/licenses/_pdf-lib_standard-fonts-1.0.0.txt +22 -0
  62. package/dist/licenses/_pdf-lib_upng-1.0.1.txt +22 -0
  63. package/dist/licenses/_types_node-14.18.63.txt +22 -0
  64. package/dist/licenses/_types_pako-2.0.3.txt +22 -0
  65. package/dist/licenses/_types_pegjs-0.10.6.txt +22 -0
  66. package/dist/licenses/archiver-5.3.2.txt +23 -0
  67. package/dist/licenses/archiver-utils-2.1.0.txt +23 -0
  68. package/dist/licenses/archiver-utils-3.0.4.txt +23 -0
  69. package/dist/licenses/async-3.2.6.txt +20 -0
  70. package/dist/licenses/balanced-match-1.0.2.txt +22 -0
  71. package/dist/licenses/base64-js-1.5.1.txt +22 -0
  72. package/dist/licenses/big-integer-1.6.52.txt +25 -0
  73. package/dist/licenses/binary-0.3.0.txt +178 -0
  74. package/dist/licenses/bl-4.1.0.txt +14 -0
  75. package/dist/licenses/bluebird-3.4.7.txt +22 -0
  76. package/dist/licenses/brace-expansion-1.1.21.txt +22 -0
  77. package/dist/licenses/brace-expansion-2.1.7.txt +22 -0
  78. package/dist/licenses/buffer-5.7.1.txt +22 -0
  79. package/dist/licenses/buffer-crc32-0.2.13.txt +20 -0
  80. package/dist/licenses/buffer-indexof-polyfill-1.0.2.txt +23 -0
  81. package/dist/licenses/buffers-0.1.1.txt +140 -0
  82. package/dist/licenses/chainsaw-0.1.0.txt +184 -0
  83. package/dist/licenses/compress-commons-4.1.2.txt +23 -0
  84. package/dist/licenses/concat-map-0.0.1.txt +19 -0
  85. package/dist/licenses/core-util-is-1.0.3.txt +20 -0
  86. package/dist/licenses/crc-32-1.2.2.txt +202 -0
  87. package/dist/licenses/crc32-stream-4.0.3.txt +23 -0
  88. package/dist/licenses/dayjs-1.11.23.txt +22 -0
  89. package/dist/licenses/duplexer2-0.1.4.txt +27 -0
  90. package/dist/licenses/end-of-stream-1.4.5.txt +22 -0
  91. package/dist/licenses/exceljs-4.4.0.txt +23 -0
  92. package/dist/licenses/fast-csv-4.3.6.txt +22 -0
  93. package/dist/licenses/fast-png-6.4.0.txt +22 -0
  94. package/dist/licenses/fs-constants-1.0.0.txt +22 -0
  95. package/dist/licenses/fs.realpath-1.0.0.txt +44 -0
  96. package/dist/licenses/fstream-1.0.12.txt +16 -0
  97. package/dist/licenses/glob-7.2.3.txt +22 -0
  98. package/dist/licenses/graceful-fs-4.2.11.txt +16 -0
  99. package/dist/licenses/ieee754-1.2.1.txt +12 -0
  100. package/dist/licenses/immediate-3.0.6.txt +21 -0
  101. package/dist/licenses/inflight-1.0.6.txt +16 -0
  102. package/dist/licenses/inherits-2.0.4.txt +17 -0
  103. package/dist/licenses/iobuffer-5.4.0.txt +23 -0
  104. package/dist/licenses/isarray-1.0.0.txt +61 -0
  105. package/dist/licenses/jszip-3.10.2.txt +652 -0
  106. package/dist/licenses/lazystream-1.0.1.txt +24 -0
  107. package/dist/licenses/lie-3.3.0.txt +8 -0
  108. package/dist/licenses/listenercount-1.0.1.txt +6 -0
  109. package/dist/licenses/lodash.defaults-4.2.0.txt +48 -0
  110. package/dist/licenses/lodash.difference-4.5.0.txt +48 -0
  111. package/dist/licenses/lodash.escaperegexp-4.1.2.txt +48 -0
  112. package/dist/licenses/lodash.flatten-4.4.0.txt +48 -0
  113. package/dist/licenses/lodash.groupby-4.6.0.txt +48 -0
  114. package/dist/licenses/lodash.isboolean-3.0.3.txt +23 -0
  115. package/dist/licenses/lodash.isequal-4.5.0.txt +48 -0
  116. package/dist/licenses/lodash.isfunction-3.0.9.txt +48 -0
  117. package/dist/licenses/lodash.isnil-4.0.0.txt +23 -0
  118. package/dist/licenses/lodash.isplainobject-4.0.6.txt +48 -0
  119. package/dist/licenses/lodash.isundefined-3.0.1.txt +23 -0
  120. package/dist/licenses/lodash.union-4.6.0.txt +48 -0
  121. package/dist/licenses/lodash.uniq-4.5.0.txt +48 -0
  122. package/dist/licenses/minimatch-3.1.5.txt +16 -0
  123. package/dist/licenses/minimatch-5.1.9.txt +16 -0
  124. package/dist/licenses/minimist-1.2.8.txt +19 -0
  125. package/dist/licenses/mkdirp-0.5.6.txt +22 -0
  126. package/dist/licenses/node-sql-parser-5.4.0.txt +202 -0
  127. package/dist/licenses/normalize-path-3.0.0.txt +22 -0
  128. package/dist/licenses/once-1.4.0.txt +16 -0
  129. package/dist/licenses/pako-1.0.11.txt +22 -0
  130. package/dist/licenses/pako-2.2.0.txt +22 -0
  131. package/dist/licenses/path-is-absolute-1.0.1.txt +22 -0
  132. package/dist/licenses/pdf-lib-1.17.1.txt +22 -0
  133. package/dist/licenses/process-nextick-args-2.0.1.txt +20 -0
  134. package/dist/licenses/readable-stream-2.3.8.txt +48 -0
  135. package/dist/licenses/readable-stream-3.6.2.txt +48 -0
  136. package/dist/licenses/readdir-glob-1.1.3.txt +202 -0
  137. package/dist/licenses/rimraf-2.7.1.txt +16 -0
  138. package/dist/licenses/safe-buffer-5.1.2.txt +22 -0
  139. package/dist/licenses/safe-buffer-5.2.1.txt +22 -0
  140. package/dist/licenses/saxes-5.0.1.txt +397 -0
  141. package/dist/licenses/setimmediate-1.0.5.txt +21 -0
  142. package/dist/licenses/string_decoder-1.1.1.txt +49 -0
  143. package/dist/licenses/string_decoder-1.3.0.txt +49 -0
  144. package/dist/licenses/tar-stream-2.2.0.txt +22 -0
  145. package/dist/licenses/tmp-0.2.7.txt +22 -0
  146. package/dist/licenses/traverse-0.3.9.txt +25 -0
  147. package/dist/licenses/tslib-1.14.1.txt +13 -0
  148. package/dist/licenses/unzipper-0.10.14.txt +26 -0
  149. package/dist/licenses/util-deprecate-1.0.2.txt +25 -0
  150. package/dist/licenses/uuid-11.1.1.txt +10 -0
  151. package/dist/licenses/wrappy-1.0.2.txt +16 -0
  152. package/dist/licenses/xmlchars-2.2.0.txt +19 -0
  153. package/dist/licenses/zip-stream-4.1.1.txt +23 -0
  154. package/dist/matrix-CGRGkn5s.js +112 -0
  155. package/dist/matrix-gEO7ZM_u.cjs +1 -0
  156. package/dist/media-B7vnpD8k.cjs +1 -0
  157. package/dist/media-Y90dHK9z.js +70 -0
  158. package/dist/param-validation-C3HlcLLO.cjs +1 -0
  159. package/dist/param-validation-Do7Eg8Zv.js +181 -0
  160. package/dist/pdf-BwNyeGpt.js +36352 -0
  161. package/dist/pdf-CvvrjPQg.cjs +103 -0
  162. package/dist/pdf.cjs +1 -101
  163. package/dist/pdf.d.cts +18 -3
  164. package/dist/pdf.d.ts +18 -3
  165. package/dist/pdf.js +9 -36579
  166. package/dist/plugin-Ca_XZG3l.js +22 -0
  167. package/dist/{plugin-DzS6pxTA.cjs → plugin-DHO7X8z2.cjs} +1 -1
  168. package/dist/prepared-CFy9B75C.cjs +1 -0
  169. package/dist/prepared-ajM-H-9B.js +69 -0
  170. package/dist/progress-B0ctFpKf.cjs +1 -0
  171. package/dist/progress-D-OTpEav.js +52 -0
  172. package/dist/{record-bindings-D-5jQlTj.js → record-bindings-Do_b3h4V.js} +1 -1
  173. package/dist/{region-binding-workflow-CcUq8W2Q.js → region-binding-workflow-BMhK_TjP.js} +1 -1
  174. package/dist/{region-binding-workflow-BzfbxRiR.cjs → region-binding-workflow-DIYJdCUr.cjs} +1 -1
  175. package/dist/{report-params-B44imUd4.js → report-params-B1RzkhJj.js} +1 -1
  176. package/dist/{report-params-SJfhKgaX.cjs → report-params-WDGrA4oP.cjs} +1 -1
  177. package/dist/sbom.cdx.json +3982 -0
  178. package/dist/server/node.d.cts +66 -12
  179. package/dist/server/node.d.ts +66 -12
  180. package/dist/server-node.cjs +1 -1
  181. package/dist/server-node.js +405 -381
  182. package/dist/server.cjs +1 -1
  183. package/dist/server.d.cts +878 -15
  184. package/dist/server.d.ts +878 -15
  185. package/dist/server.js +1034 -534
  186. package/dist/sha256-ArEYjaTI.cjs +1 -0
  187. package/dist/sha256-DPEuJ3nh.js +155 -0
  188. package/dist/style.css +1 -1
  189. package/dist/template-bindings-C2SpvsMU.js +58 -0
  190. package/dist/template-bindings-CEtWyiLX.cjs +1 -0
  191. package/dist/template-catalog-FJE_c9Qe.cjs +1 -0
  192. package/dist/template-catalog-j2B1MJlL.js +414 -0
  193. package/dist/template-fragments-BGbQLGlV.js +187 -0
  194. package/dist/template-fragments-DcKeiylI.cjs +1 -0
  195. package/dist/template-outline-BwRV_eRo.cjs +1 -0
  196. package/dist/template-outline-cnWfT_LK.js +88 -0
  197. package/dist/{template-registry-BjE1VS6g.js → template-registry-BtaKPELV.js} +364 -201
  198. package/dist/template-registry-Co1zPq5e.cjs +1 -0
  199. package/dist/textwrap-CWHyzkBH.cjs +4 -0
  200. package/dist/textwrap-DE1kgcJB.js +110 -0
  201. package/dist/{tree-CqcQ99NM.js → tree-CjVZLRw7.js} +1 -1
  202. package/dist/{useLocalDraft-C07SYRnC.js → useLocalDraft-BnhcxXk_.js} +1 -1
  203. package/dist/{useLocalDraft-Yiw1wFgI.cjs → useLocalDraft-CioIfDb6.cjs} +1 -1
  204. package/dist/vue/async.d.cts +190 -15
  205. package/dist/vue/async.d.ts +190 -15
  206. package/dist/vue/index.d.cts +274 -24
  207. package/dist/vue/index.d.ts +274 -24
  208. package/dist/vue-async.cjs +1 -1
  209. package/dist/vue-async.js +5 -5
  210. package/dist/vue.cjs +1 -1
  211. package/dist/vue.js +90 -81
  212. package/dist/{workbook-session-DNa2RHNG.cjs → workbook-session-Bjv1YCRK.cjs} +18 -18
  213. package/dist/{workbook-session-BPb3TMnT.js → workbook-session-BvToI-Fd.js} +5440 -5288
  214. package/dist/worker.cjs +1 -1
  215. package/dist/worker.d.cts +66 -12
  216. package/dist/worker.d.ts +66 -12
  217. package/dist/worker.js +61 -56
  218. package/dist/xlsx-node.cjs +34 -34
  219. package/dist/xlsx-node.js +878 -870
  220. package/dist/xlsx.cjs +3 -4
  221. package/dist/xlsx.d.cts +22 -10
  222. package/dist/xlsx.d.ts +22 -10
  223. package/dist/xlsx.js +261 -253
  224. package/package.json +2 -2
  225. package/dist/ExcelBindingWizard-CeAf4QSE.js +0 -1465
  226. package/dist/ExcelBindingWizard-y0mT-AHR.cjs +0 -1
  227. package/dist/ParamEditor-BLaE5q5W.js +0 -522
  228. package/dist/ParamEditor-MBBC7lUE.cjs +0 -1
  229. package/dist/ReportBatchPanel-Fp1ePFag.cjs +0 -1
  230. package/dist/ReportPreview-BN6fk7Wz.cjs +0 -6
  231. package/dist/ReportPreview-D2Jkyh1U.js +0 -4243
  232. package/dist/ReportTemplateLibrary-5fk5CQBO.cjs +0 -1
  233. package/dist/RuleEditor-ChRzNQuF.cjs +0 -1
  234. package/dist/RuleEditor-DzAmW5YH.js +0 -2024
  235. package/dist/TemplateReviewPanel-BKofGrV9.js +0 -222
  236. package/dist/TemplateReviewPanel-DwtOcLue.cjs +0 -1
  237. package/dist/assets-C2U-e-Sz.cjs +0 -4
  238. package/dist/assets-Q0wUwNrV.js +0 -217
  239. package/dist/batch-Bt3Fd27Z.cjs +0 -1
  240. package/dist/batch-mRqhhhjt.js +0 -364
  241. package/dist/capabilities-CK_7hizc.js +0 -63
  242. package/dist/capabilities-CsZ-pNHR.cjs +0 -1
  243. package/dist/config-Bb7RiIO5.cjs +0 -1
  244. package/dist/config-XVwG87IA.js +0 -529
  245. package/dist/matrix-DVyWiYsd.cjs +0 -1
  246. package/dist/matrix-yZsGnldA.js +0 -227
  247. package/dist/page-window-index-CIuT4BAv.js +0 -43
  248. package/dist/page-window-index-DEjnM6IB.cjs +0 -1
  249. package/dist/param-validation-BlHHXs6u.js +0 -153
  250. package/dist/param-validation-DCK039V1.cjs +0 -1
  251. package/dist/plugin-D4wizDXB.js +0 -22
  252. package/dist/progress-7OSZbFok.js +0 -39
  253. package/dist/progress-BnLiS5eH.cjs +0 -1
  254. package/dist/task-events-DQ276fn2.cjs +0 -1
  255. package/dist/task-events-Dpsvf_t2.js +0 -47
  256. package/dist/template-registry-D3SjENi6.cjs +0 -1
  257. package/dist/template-review-DGwWOoCv.cjs +0 -2
  258. package/dist/template-review-PgEe_Wr9.js +0 -1742
  259. package/dist/validate-BJ5HIWY8.cjs +0 -1
  260. package/dist/validate-DbgEM1Hh.js +0 -163
@@ -0,0 +1,58 @@
1
+ function d(e) {
2
+ return !!e && typeof e == "object" && !Array.isArray(e);
3
+ }
4
+ function o(e, f, s) {
5
+ typeof e == "string" ? s.push({ field: e, path: f }) : Array.isArray(e) && e.forEach((i, r) => o(i, `${f}[${r}]`, s));
6
+ }
7
+ function c(e, f, s) {
8
+ if (Array.isArray(e)) {
9
+ e.forEach((i, r) => c(i, `${f}[${r}]`, s));
10
+ return;
11
+ }
12
+ if (d(e))
13
+ for (const [i, r] of Object.entries(e))
14
+ ["field", "weightField"].includes(i) ? o(r, `${f}.${i}`, s) : i !== "value" && i !== "style" && c(r, `${f}.${i}`, s);
15
+ }
16
+ function n(e, f, s) {
17
+ Array.isArray(e) && e.forEach((i, r) => {
18
+ if (!d(i)) return;
19
+ typeof i.field == "string" && i.valueField !== void 0 && i.valueField !== i.field && s.summaries.add(i.field);
20
+ const l = i.valueField === void 0 ? "field" : "valueField";
21
+ o(i[l], `${f}[${r}].${l}`, s.fields), i.valueField !== void 0 && i.valueField === i.field && o(i.field, `${f}[${r}].field`, s.fields), o(i.weightField, `${f}[${r}].weightField`, s.fields);
22
+ });
23
+ }
24
+ function u(e, f, s) {
25
+ for (const r of ["rowKey", "revisionField", "sourceTokenField"]) o(e[r], `${f}.${r}`, s.fields);
26
+ if (!e.matrix && Array.isArray(e.columns) && e.columns.forEach((r, l) => {
27
+ d(r) && (typeof r.field == "string" && s.fields.push({ field: r.field, path: `${f}.columns[${l}].field`, summary: !0 }), c(r.rules, `${f}.columns[${l}].rules`, s.fields), c(r.visibleWhen, `${f}.columns[${l}].visibleWhen`, s.fields));
28
+ }), c(e.rowVisibleWhen, `${f}.rowVisibleWhen`, s.fields), Array.isArray(e.computed) && e.computed.forEach((r, l) => {
29
+ d(r) && (typeof r.field == "string" && s.generated.add(r.field), c(r.expression, `${f}.computed[${l}].expression`, s.fields), o(r.dependsOn, `${f}.computed[${l}].dependsOn`, s.fields), o(r.groupBy, `${f}.computed[${l}].groupBy`, s.fields));
30
+ }), (Array.isArray(e.groups) ? e.groups.map((r, l) => ({ group: r, path: `${f}.groups[${l}]` })) : e.groupBy ? [{ group: e.groupBy, path: `${f}.groupBy` }] : []).forEach(({ group: r, path: l }) => {
31
+ d(r) && (o(r.field, `${l}.field`, s.fields), o(r.subtotal, `${l}.subtotal`, s.fields), n(r.aggregates, `${l}.aggregates`, s));
32
+ }), d(e.grandTotal) && (o(e.grandTotal.fields, `${f}.grandTotal.fields`, s.fields), n(e.grandTotal.aggregates, `${f}.grandTotal.aggregates`, s)), d(e.matrix) && (o(e.matrix.rowFields, `${f}.matrix.rowFields`, s.fields), o(e.matrix.columnFields, `${f}.matrix.columnFields`, s.fields), n(e.matrix.measures, `${f}.matrix.measures`, s)), d(e.tree)) {
33
+ for (const r of ["idField", "parentField", "labelField"]) o(e.tree[r], `${f}.tree.${r}`, s.fields);
34
+ n(e.tree.aggregates, `${f}.tree.aggregates`, s);
35
+ }
36
+ d(e.detail) && o(e.detail.parentKey, `${f}.detail.parentKey`, s.fields);
37
+ }
38
+ function a(e) {
39
+ const f = [], s = e.repeat, i = s ? { dataset: s.dataset, path: "$.template.repeat", fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() } : void 0;
40
+ i && s && (o(s.rowKey, "$.template.repeat.rowKey", i.fields), typeof s.copies == "object" && o(s.copies.field, "$.template.repeat.copies.field", i.fields), f.push(i));
41
+ function r(l, $) {
42
+ if (Array.isArray(l)) {
43
+ l.forEach((t, y) => r(t, `${$}[${y}]`));
44
+ return;
45
+ }
46
+ if (d(l)) {
47
+ if (i && d(l.binding) && o(l.binding.field, `${$}.binding.field`, i.fields), typeof l.dataset == "string" && Array.isArray(l.columns)) {
48
+ const t = { dataset: l.dataset, path: $, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
49
+ u(l, $, t), typeof l.foreignKey == "string" && o(l.foreignKey, `${$}.foreignKey`, t.fields), f.push(t);
50
+ }
51
+ for (const [t, y] of Object.entries(l)) r(y, `${$}.${t}`);
52
+ }
53
+ }
54
+ return r(e, "$.template"), f;
55
+ }
56
+ export {
57
+ a as c
58
+ };
@@ -0,0 +1 @@
1
+ "use strict";function d(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function o(e,i,r){typeof e=="string"?r.push({field:e,path:i}):Array.isArray(e)&&e.forEach((f,s)=>o(f,`${i}[${s}]`,r))}function c(e,i,r){if(Array.isArray(e)){e.forEach((f,s)=>c(f,`${i}[${s}]`,r));return}if(d(e))for(const[f,s]of Object.entries(e))["field","weightField"].includes(f)?o(s,`${i}.${f}`,r):f!=="value"&&f!=="style"&&c(s,`${i}.${f}`,r)}function n(e,i,r){Array.isArray(e)&&e.forEach((f,s)=>{if(!d(f))return;typeof f.field=="string"&&f.valueField!==void 0&&f.valueField!==f.field&&r.summaries.add(f.field);const l=f.valueField===void 0?"field":"valueField";o(f[l],`${i}[${s}].${l}`,r.fields),f.valueField!==void 0&&f.valueField===f.field&&o(f.field,`${i}[${s}].field`,r.fields),o(f.weightField,`${i}[${s}].weightField`,r.fields)})}function a(e,i,r){for(const s of["rowKey","revisionField","sourceTokenField"])o(e[s],`${i}.${s}`,r.fields);if(!e.matrix&&Array.isArray(e.columns)&&e.columns.forEach((s,l)=>{d(s)&&(typeof s.field=="string"&&r.fields.push({field:s.field,path:`${i}.columns[${l}].field`,summary:!0}),c(s.rules,`${i}.columns[${l}].rules`,r.fields),c(s.visibleWhen,`${i}.columns[${l}].visibleWhen`,r.fields))}),c(e.rowVisibleWhen,`${i}.rowVisibleWhen`,r.fields),Array.isArray(e.computed)&&e.computed.forEach((s,l)=>{d(s)&&(typeof s.field=="string"&&r.generated.add(s.field),c(s.expression,`${i}.computed[${l}].expression`,r.fields),o(s.dependsOn,`${i}.computed[${l}].dependsOn`,r.fields),o(s.groupBy,`${i}.computed[${l}].groupBy`,r.fields))}),(Array.isArray(e.groups)?e.groups.map((s,l)=>({group:s,path:`${i}.groups[${l}]`})):e.groupBy?[{group:e.groupBy,path:`${i}.groupBy`}]:[]).forEach(({group:s,path:l})=>{d(s)&&(o(s.field,`${l}.field`,r.fields),o(s.subtotal,`${l}.subtotal`,r.fields),n(s.aggregates,`${l}.aggregates`,r))}),d(e.grandTotal)&&(o(e.grandTotal.fields,`${i}.grandTotal.fields`,r.fields),n(e.grandTotal.aggregates,`${i}.grandTotal.aggregates`,r)),d(e.matrix)&&(o(e.matrix.rowFields,`${i}.matrix.rowFields`,r.fields),o(e.matrix.columnFields,`${i}.matrix.columnFields`,r.fields),n(e.matrix.measures,`${i}.matrix.measures`,r)),d(e.tree)){for(const s of["idField","parentField","labelField"])o(e.tree[s],`${i}.tree.${s}`,r.fields);n(e.tree.aggregates,`${i}.tree.aggregates`,r)}d(e.detail)&&o(e.detail.parentKey,`${i}.detail.parentKey`,r.fields)}function u(e){const i=[],r=e.repeat,f=r?{dataset:r.dataset,path:"$.template.repeat",fields:[],generated:new Set,summaries:new Set}:void 0;f&&r&&(o(r.rowKey,"$.template.repeat.rowKey",f.fields),typeof r.copies=="object"&&o(r.copies.field,"$.template.repeat.copies.field",f.fields),i.push(f));function s(l,$){if(Array.isArray(l)){l.forEach((t,y)=>s(t,`${$}[${y}]`));return}if(d(l)){if(f&&d(l.binding)&&o(l.binding.field,`${$}.binding.field`,f.fields),typeof l.dataset=="string"&&Array.isArray(l.columns)){const t={dataset:l.dataset,path:$,fields:[],generated:new Set,summaries:new Set};a(l,$,t),typeof l.foreignKey=="string"&&o(l.foreignKey,`${$}.foreignKey`,t.fields),i.push(t)}for(const[t,y]of Object.entries(l))s(y,`${$}.${t}`)}}return s(e,"$.template"),i}exports.collectTemplateDatasetBindings=u;
@@ -0,0 +1 @@
1
+ "use strict";const w=require("./json-snapshot-WWSGlaHG.cjs"),j=require("./capabilities-CAh2Nrue.cjs"),L=require("./dataset-BkRmwgeJ.cjs"),h=require("./template-registry-Co1zPq5e.cjs"),E=require("./template-bindings-CEtWyiLX.cjs"),P=require("./param-validation-C3HlcLLO.cjs");function R(e){if(e===void 0)return;const t=typeof e=="string"?e:JSON.stringify(e);return t.length>160?t.slice(0,157)+"…":t}function N(e){return/\.(?:repeat|binding)(?:\.|$)/.test(e)?/\.format(?:\.|$)/.test(e)?"format":"binding":/\.tree\.(?:idField|parentField|childrenField|labelField|input)$/.test(e)?"binding":/\.tree\.parentValues$/.test(e)?"calculation":/\.tree\.indentMm$/.test(e)?"format":/\.(?:computed|computeOptions|groups|groupBy|aggregates|grandTotal)(?:\.|\[|$)/.test(e)?"calculation":/\.(?:dataset|field|rowKey|revisionField|sourceTokenField|foreignKey|parentKey)$/.test(e)?"binding":/\.(?:style|headerStyle|format|rules|align|headerAlign|semanticRole|unit)(?:\.|\[|$)/.test(e)?"format":e.startsWith("$.template")?"structure":"metadata"}function T(e){const t=new Map;for(const r of e){if(!r||typeof r!="object"||!("field"in r)||typeof r.field!="string"||t.has(r.field))return;t.set(r.field,r)}return t}function D(e,t,r){return!e.startsWith("$.template.params")||t==="moved"?!1:/\.(?:type|required|min|max|minLength|maxLength|options|defaultValue)(?:\[|$)/.test(e)?!0:t!=="added"?!1:Array.isArray(r)?r.some(a=>!!a&&typeof a=="object"&&"required"in a&&a.required===!0):!!r&&typeof r=="object"&&"required"in r&&r.required===!0}function A(e,t,r={}){const a=h.parseReportTemplate(e),n=h.parseReportTemplate(t),o=r.maxChanges??500;if(!Number.isSafeInteger(o)||o<1||o>1e4)throw new RangeError("maxChanges must be between 1 and 10000");const s={changes:[],totalChanges:0,breakingChanges:0,truncated:!1};function d(c,l,u,m){const f=N(l),y=c!=="moved"&&(f==="binding"||l==="$.id"||c==="removed"&&f==="structure"||D(l,c,m));s.totalChanges++,y&&s.breakingChanges++,s.changes.length<o&&s.changes.push({kind:c,category:f,path:l,before:R(u),after:R(m),breaking:y})}function p(c,l,u){const m=T(c),f=T(l);if(!m||!f)return!1;const y=new Map(l.map((g,b)=>[g.field,b]));Array.from(m).forEach(([g,b],$)=>{const x=`${u}[${JSON.stringify(g)}]`;f.has(g)?(y.get(g)!==$&&d("moved",x,$,y.get(g)),i(b,f.get(g),x)):d("removed",x,b,void 0)});for(const[g,b]of f)m.has(g)||d("added",`${u}[${JSON.stringify(g)}]`,void 0,b);return!0}function i(c,l,u){if(!(Object.is(c,l)||u==="$.revision")){if(c===void 0||l===void 0){d(c===void 0?"added":"removed",u,c,l);return}if(Array.isArray(c)&&Array.isArray(l)){if((u.endsWith(".columns")||u.endsWith(".params"))&&p(c,l,u))return;for(let m=0;m<Math.max(c.length,l.length);m++)i(c[m],l[m],`${u}[${m}]`)}else if(c&&l&&typeof c=="object"&&typeof l=="object"&&!Array.isArray(c)&&!Array.isArray(l)){const m=c,f=l;for(const y of new Set([...Object.keys(m),...Object.keys(f)]))i(m[y],f[y],`${u}.${y}`)}else d("modified",u,c,l)}}return i(a,n,"$"),s.truncated=s.totalChanges>s.changes.length,s}function M(e,t,r){for(const a of E.collectTemplateDatasetBindings(e)){const n=Object.prototype.hasOwnProperty.call(t,a.dataset)?t[a.dataset]:void 0;if(!n){r.push({code:"dataset",severity:"error",path:`${a.path}.dataset`,message:`未声明数据集 ${a.dataset}`});continue}const o=new Set(n.fields.map(s=>s.field));a.fields.forEach(({field:s,path:d,summary:p})=>{!o.has(s)&&!a.generated.has(s)&&!(p&&a.summaries.has(s))&&r.push({code:"field",severity:"error",path:d,field:s,message:`数据集 ${a.dataset} 缺少字段 ${s}`})})}}function q(e,t,r,a){const n=r.maxSampleRows??1e3;let o;try{o=w.templateValidationDatasets(t,e.datasets,{maxRows:n})}catch(p){return a.push({code:"sample",severity:"error",path:"$.fixtures",fixture:e.name,message:p instanceof Error?p.message:String(p)}),!1}const s=Object.values(o).reduce((p,i)=>p+i.length,0);if(s>n)return a.push({code:"sample",severity:"error",path:"$.fixtures",fixture:e.name,message:`样例 ${s} 行超过预算 ${n},请显式选择验收样例`}),!1;const d=new Set(E.collectTemplateDatasetBindings(t).map(p=>p.dataset));for(const[p,i]of Object.entries(r.dataSchemas??{}).filter(([c])=>d.has(c)))try{const c=L.validateDatasetRows(o[p],i,{path:`$.datasets.${p}`,maxRows:n});if(a.push(...c.issues.map(l=>({...l,code:"sample",severity:"error",fixture:e.name}))),!c.ok)return!1}catch(c){return a.push({code:"dataset",severity:"error",path:`$.dataSchemas.${p}`,message:String(c)}),!1}return!0}function F(e,t){const r=e.pages[t.pageIndex]?.components[t.componentIndex]?.meta?.labelSource;if(r&&typeof r=="object"&&"pageIndex"in r&&"componentIndex"in r&&typeof r.pageIndex=="number"&&typeof r.componentIndex=="number")return{path:`$.template.pages[${r.pageIndex}].components[${r.componentIndex}]`,pageIndex:r.pageIndex,componentIndex:r.componentIndex};const a=e.pages[t.pageIndex]?.meta?.record;if(a&&typeof a=="object"&&"templatePageIndex"in a&&typeof a.templatePageIndex=="number")return{path:`$.template.pages[${a.templatePageIndex}].components[${t.componentIndex}]`,pageIndex:a.templatePageIndex,componentIndex:t.componentIndex}}function B(e,t,r){const a=F(t,r);if(a)return a;const n=t.pages[r.pageIndex]?.components[r.componentIndex],o=/^table:(\d+):(\d+)(?::|$)/.exec(n?.table?.id??"");if(o)return{path:`$.template.pages[${o[1]}].components[${o[2]}]`,pageIndex:Number(o[1]),componentIndex:Number(o[2])};for(const[s,d]of e.pages.entries()){const p=d.components.findIndex(i=>i===n||n?.nid!==void 0&&"nid"in i&&i.nid===n.nid);if(p>=0)return{path:`$.template.pages[${s}].components[${p}]`,pageIndex:s,componentIndex:p}}return{path:"$.template"}}function J(e,t,r,a,n){const o=P.validateReportParams(e.template.params??[],t.params??{});if(n.issues.push(...o.issues.map(s=>({...s,code:"params",severity:"error",fixture:t.name,path:s.path.replace(/^\$\.params/,`$.fixtures[${r}].params`)}))),!!o.ok&&q(t,e.template,a,n.issues))try{const{plan:s,warnings:d}=w.paginateTemplate(e.template,t.datasets,{maxPages:a.maxPages??100,maxCells:a.maxCells??25e4}),p=(a.formats??["pdf","xlsx"]).flatMap(i=>j.inspectOutputCapabilities(s,i));n.issues.push(...d.map(i=>({code:"layout",severity:"warning",path:"$.template",fixture:t.name,message:i}))),n.issues.push(...p.map(i=>({code:"output",severity:a.strictOutputs?"error":"warning",...B(e.template,s,i),fixture:t.name,message:`${i.format}: ${i.message}`,diagnostic:i}))),n.samples.push({name:t.name,pages:s.pages.length,rows:w.templateDatasetRowCount(e.template,t.datasets),diagnostics:p})}catch(s){n.issues.push({code:"layout",severity:"error",path:"$.template",fixture:t.name,message:s instanceof Error?s.message:String(s)})}}function V(e){for(const[r,a]of[["maxPages",e.maxPages],["maxCells",e.maxCells],["maxSampleRows",e.maxSampleRows]])if(a!==void 0&&(!Number.isSafeInteger(a)||a<1))throw new RangeError(`${r} must be a positive safe integer`);if((e.fixtures?.length??0)>20)throw new RangeError("At most 20 review fixtures are allowed");const t=new Set;for(const r of e.fixtures??[]){if(typeof r.name!="string"||!r.name.trim()||r.name.length>120||t.has(r.name))throw new Error("Review fixtures require unique non-empty names of at most 120 characters");t.add(r.name)}}function*C(e,t,r){let a;yield{stage:"template",run:()=>{V(t),a=h.parseReportTemplate(e)}};const n=t.previous;n&&(yield{stage:"baseline",run:()=>{r.changes=A(n,a),r.changes.breakingChanges&&!t.allowBreakingChanges&&r.issues.push({code:"compatibility",severity:"error",path:"$.template",message:`${r.changes.breakingChanges} 项字段或结构变更需要明确确认兼容性`})}}),t.dataSchemas&&(yield{stage:"bindings",run:()=>M(a.template,t.dataSchemas,r.issues)});for(const[o,s]of(t.fixtures??[]).entries())yield{stage:"fixture",fixture:s.name,run:()=>J(a,s,o,t,r)};t.fixtures?.length||r.issues.push({code:"sample",severity:"warning",path:"$.fixtures",message:"未提供验收样例,仅完成结构和字段检查,尚未验证排版与输出"})}function O(e){return e.ok=e.issues.every(t=>t.severity!=="error"),e}function k(e,t){e.issues.push({code:"template",severity:"error",path:"$",message:t instanceof Error?t.message:String(t)})}function W(e,t={}){const r={ok:!1,issues:[],samples:[]};try{for(const a of C(e,t,r))a.run()}catch(a){k(r,a)}return O(r)}function v(e){if(e?.aborted)throw e.reason??new DOMException("Template review was aborted","AbortError")}function K(e){return v(e),new Promise((t,r)=>{const a=()=>{clearTimeout(n),e?.removeEventListener("abort",a),r(e?.reason??new DOMException("Template review was aborted","AbortError"))},n=setTimeout(()=>{e?.removeEventListener("abort",a),t()},0);e?.addEventListener("abort",a,{once:!0}),e?.aborted&&a()})}function I(e,t){try{e.onProgress?.(t)}catch{}}async function _(e,t={}){const r={ok:!1,issues:[],samples:[]},a=t.fixtures?.length??0;let n=0;v(t.signal);try{const o=C(e,t,r),s=o.next();s.done||(s.value.run(),I(t,{completed:n,total:a,stage:s.value.stage})),v(t.signal);for(const d of o)await K(t.signal),v(t.signal),d.run(),d.stage==="fixture"&&n++,I(t,{completed:n,total:a,stage:d.stage,...d.fixture?{fixture:d.fixture}:{}}),v(t.signal)}catch(o){v(t.signal),k(r,o)}return O(r)}function z(e,t){const r=e.publishedRevision??e.published?.revision;for(const a of[e.draftRevision,r])if(a!==void 0&&(typeof a!="string"||!a.trim()))throw new TypeError("模板生命周期修订应为非空字符串");if(e.draftRevision!==void 0&&e.draftRevision!==t.revision)throw new TypeError("可编辑文档应与草稿修订一致");if(e.published&&(e.published.id!==t.id||e.published.revision!==r))throw new TypeError("发布文档身份或修订不一致");if(!e.published&&r!==void 0&&r!==t.revision)throw new TypeError("发布修订需要对应的独立文档");return{...e.draftRevision===void 0?{}:{draftRevision:e.draftRevision},...r===void 0?{}:{publishedRevision:r}}}function G(e,t){const r=h.parseReportTemplate(e);if(t.id===r.id)throw new Error("复制模板应使用新的 ID");const{revision:a,...n}=r;return h.parseReportTemplate({...n,id:t.id,name:t.name})}function H(e){if(!Array.isArray(e)||e.length>1e3)throw new RangeError("本地模板目录最多 1000 项");const t=new Map,r=new Map,a=[];for(const n of e){const o=h.parseReportTemplate(n.document);if(t.has(o.id))throw new Error(`模板 ID 重复:${o.id}`);if(n.category!==void 0&&(typeof n.category!="string"||n.category.length>128)||n.tags!==void 0&&(!Array.isArray(n.tags)||n.tags.length>20||n.tags.some(i=>typeof i!="string"||i.length>128)))throw new TypeError("模板分类和标签无效");const s=z(n,o),{template:d,...p}=o;t.set(o.id,o),n.published?r.set(o.id,h.parseReportTemplate(n.published)):s.publishedRevision&&r.set(o.id,h.parseReportTemplate(o)),a.push({...p,...s,...n.category?{category:n.category}:{},...n.tags?{tags:[...n.tags]}:{}})}return a.sort((n,o)=>n.id<o.id?-1:1),{search:async n=>{S(n.signal);const o=n.limit??30;if(!Number.isSafeInteger(o)||o<1||o>100)throw new RangeError("模板每页数量应为 1–100");const s=n.query?.trim().toLocaleLowerCase()??"",d=a.filter(i=>(!n.category||i.category===n.category)&&(!n.cursor||i.id>n.cursor)&&(!s||[i.id,i.name,i.description,...i.tags??[]].some(c=>c?.toLocaleLowerCase().includes(s)))),p=new Map;for(const i of a)i.category&&p.set(i.category,(p.get(i.category)??0)+1);return JSON.parse(JSON.stringify({items:d.slice(0,o),...d.length>o?{next:d[o-1].id}:{},categories:Array.from(p,([i,c])=>({id:i,label:i,count:c}))}))},get:async(n,o)=>{S(o.signal);const s=o.mode==="published"?r.get(n):t.get(n);return s?h.parseReportTemplate(s):void 0}}}function S(e){if(!e?.aborted)return;const t=new Error("模板目录操作已取消");throw t.name="AbortError",t}exports.cloneReportTemplate=G;exports.createLocalTemplateCatalog=H;exports.diffReportTemplates=A;exports.reviewReportTemplate=W;exports.reviewReportTemplateAsync=_;
@@ -0,0 +1,414 @@
1
+ import { p as O, q as k, v as j } from "./json-snapshot-DFb2eWkf.js";
2
+ import { i as P } from "./capabilities-DskCHs3V.js";
3
+ import { v as L } from "./dataset-H5pFuQGU.js";
4
+ import { p as h } from "./template-registry-BtaKPELV.js";
5
+ import { c as S } from "./template-bindings-C2SpvsMU.js";
6
+ import { d as N } from "./param-validation-Do7Eg8Zv.js";
7
+ function $(e) {
8
+ if (e === void 0) return;
9
+ const t = typeof e == "string" ? e : JSON.stringify(e);
10
+ return t.length > 160 ? t.slice(0, 157) + "…" : t;
11
+ }
12
+ function M(e) {
13
+ return /\.(?:repeat|binding)(?:\.|$)/.test(e) ? /\.format(?:\.|$)/.test(e) ? "format" : "binding" : /\.tree\.(?:idField|parentField|childrenField|labelField|input)$/.test(e) ? "binding" : /\.tree\.parentValues$/.test(e) ? "calculation" : /\.tree\.indentMm$/.test(e) ? "format" : /\.(?:computed|computeOptions|groups|groupBy|aggregates|grandTotal)(?:\.|\[|$)/.test(e) ? "calculation" : /\.(?:dataset|field|rowKey|revisionField|sourceTokenField|foreignKey|parentKey)$/.test(e) ? "binding" : /\.(?:style|headerStyle|format|rules|align|headerAlign|semanticRole|unit)(?:\.|\[|$)/.test(e) ? "format" : e.startsWith("$.template") ? "structure" : "metadata";
14
+ }
15
+ function I(e) {
16
+ const t = /* @__PURE__ */ new Map();
17
+ for (const r of e) {
18
+ if (!r || typeof r != "object" || !("field" in r) || typeof r.field != "string" || t.has(r.field)) return;
19
+ t.set(r.field, r);
20
+ }
21
+ return t;
22
+ }
23
+ function D(e, t, r) {
24
+ return !e.startsWith("$.template.params") || t === "moved" ? !1 : /\.(?:type|required|min|max|minLength|maxLength|options|defaultValue)(?:\[|$)/.test(e) ? !0 : t !== "added" ? !1 : Array.isArray(r) ? r.some((a) => !!a && typeof a == "object" && "required" in a && a.required === !0) : !!r && typeof r == "object" && "required" in r && r.required === !0;
25
+ }
26
+ function F(e, t, r = {}) {
27
+ const a = h(e), n = h(t), o = r.maxChanges ?? 500;
28
+ if (!Number.isSafeInteger(o) || o < 1 || o > 1e4) throw new RangeError("maxChanges must be between 1 and 10000");
29
+ const s = { changes: [], totalChanges: 0, breakingChanges: 0, truncated: !1 };
30
+ function f(c, m, p, u) {
31
+ const l = M(m), y = c !== "moved" && (l === "binding" || m === "$.id" || c === "removed" && l === "structure" || D(m, c, u));
32
+ s.totalChanges++, y && s.breakingChanges++, s.changes.length < o && s.changes.push({ kind: c, category: l, path: m, before: $(p), after: $(u), breaking: y });
33
+ }
34
+ function d(c, m, p) {
35
+ const u = I(c), l = I(m);
36
+ if (!u || !l) return !1;
37
+ const y = new Map(m.map((g, b) => [g.field, b]));
38
+ Array.from(u).forEach(([g, b], w) => {
39
+ const x = `${p}[${JSON.stringify(g)}]`;
40
+ l.has(g) ? (y.get(g) !== w && f("moved", x, w, y.get(g)), i(b, l.get(g), x)) : f("removed", x, b, void 0);
41
+ });
42
+ for (const [g, b] of l) u.has(g) || f("added", `${p}[${JSON.stringify(g)}]`, void 0, b);
43
+ return !0;
44
+ }
45
+ function i(c, m, p) {
46
+ if (!(Object.is(c, m) || p === "$.revision")) {
47
+ if (c === void 0 || m === void 0) {
48
+ f(c === void 0 ? "added" : "removed", p, c, m);
49
+ return;
50
+ }
51
+ if (Array.isArray(c) && Array.isArray(m)) {
52
+ if ((p.endsWith(".columns") || p.endsWith(".params")) && d(c, m, p)) return;
53
+ for (let u = 0; u < Math.max(c.length, m.length); u++) i(c[u], m[u], `${p}[${u}]`);
54
+ } else if (c && m && typeof c == "object" && typeof m == "object" && !Array.isArray(c) && !Array.isArray(m)) {
55
+ const u = c, l = m;
56
+ for (const y of /* @__PURE__ */ new Set([...Object.keys(u), ...Object.keys(l)])) i(u[y], l[y], `${p}.${y}`);
57
+ } else f("modified", p, c, m);
58
+ }
59
+ }
60
+ return i(a, n, "$"), s.truncated = s.totalChanges > s.changes.length, s;
61
+ }
62
+ function B(e, t, r) {
63
+ for (const a of S(e)) {
64
+ const n = Object.prototype.hasOwnProperty.call(
65
+ t,
66
+ a.dataset
67
+ ) ? t[a.dataset] : void 0;
68
+ if (!n) {
69
+ r.push({
70
+ code: "dataset",
71
+ severity: "error",
72
+ path: `${a.path}.dataset`,
73
+ message: `未声明数据集 ${a.dataset}`
74
+ });
75
+ continue;
76
+ }
77
+ const o = new Set(n.fields.map((s) => s.field));
78
+ a.fields.forEach(({ field: s, path: f, summary: d }) => {
79
+ !o.has(s) && !a.generated.has(s) && !(d && a.summaries.has(s)) && r.push({
80
+ code: "field",
81
+ severity: "error",
82
+ path: f,
83
+ field: s,
84
+ message: `数据集 ${a.dataset} 缺少字段 ${s}`
85
+ });
86
+ });
87
+ }
88
+ }
89
+ function J(e, t, r, a) {
90
+ const n = r.maxSampleRows ?? 1e3;
91
+ let o;
92
+ try {
93
+ o = j(t, e.datasets, {
94
+ maxRows: n
95
+ });
96
+ } catch (d) {
97
+ return a.push({
98
+ code: "sample",
99
+ severity: "error",
100
+ path: "$.fixtures",
101
+ fixture: e.name,
102
+ message: d instanceof Error ? d.message : String(d)
103
+ }), !1;
104
+ }
105
+ const s = Object.values(o).reduce(
106
+ (d, i) => d + i.length,
107
+ 0
108
+ );
109
+ if (s > n)
110
+ return a.push({
111
+ code: "sample",
112
+ severity: "error",
113
+ path: "$.fixtures",
114
+ fixture: e.name,
115
+ message: `样例 ${s} 行超过预算 ${n},请显式选择验收样例`
116
+ }), !1;
117
+ const f = new Set(
118
+ S(t).map((d) => d.dataset)
119
+ );
120
+ for (const [d, i] of Object.entries(r.dataSchemas ?? {}).filter(
121
+ ([c]) => f.has(c)
122
+ ))
123
+ try {
124
+ const c = L(o[d], i, {
125
+ path: `$.datasets.${d}`,
126
+ maxRows: n
127
+ });
128
+ if (a.push(
129
+ ...c.issues.map((m) => ({
130
+ ...m,
131
+ code: "sample",
132
+ severity: "error",
133
+ fixture: e.name
134
+ }))
135
+ ), !c.ok) return !1;
136
+ } catch (c) {
137
+ return a.push({
138
+ code: "dataset",
139
+ severity: "error",
140
+ path: `$.dataSchemas.${d}`,
141
+ message: String(c)
142
+ }), !1;
143
+ }
144
+ return !0;
145
+ }
146
+ function q(e, t) {
147
+ const r = e.pages[t.pageIndex]?.components[t.componentIndex]?.meta?.labelSource;
148
+ if (r && typeof r == "object" && "pageIndex" in r && "componentIndex" in r && typeof r.pageIndex == "number" && typeof r.componentIndex == "number")
149
+ return {
150
+ path: `$.template.pages[${r.pageIndex}].components[${r.componentIndex}]`,
151
+ pageIndex: r.pageIndex,
152
+ componentIndex: r.componentIndex
153
+ };
154
+ const a = e.pages[t.pageIndex]?.meta?.record;
155
+ if (a && typeof a == "object" && "templatePageIndex" in a && typeof a.templatePageIndex == "number")
156
+ return {
157
+ path: `$.template.pages[${a.templatePageIndex}].components[${t.componentIndex}]`,
158
+ pageIndex: a.templatePageIndex,
159
+ componentIndex: t.componentIndex
160
+ };
161
+ }
162
+ function W(e, t, r) {
163
+ const a = q(t, r);
164
+ if (a) return a;
165
+ const n = t.pages[r.pageIndex]?.components[r.componentIndex], o = /^table:(\d+):(\d+)(?::|$)/.exec(n?.table?.id ?? "");
166
+ if (o)
167
+ return {
168
+ path: `$.template.pages[${o[1]}].components[${o[2]}]`,
169
+ pageIndex: Number(o[1]),
170
+ componentIndex: Number(o[2])
171
+ };
172
+ for (const [s, f] of e.pages.entries()) {
173
+ const d = f.components.findIndex(
174
+ (i) => i === n || n?.nid !== void 0 && "nid" in i && i.nid === n.nid
175
+ );
176
+ if (d >= 0)
177
+ return {
178
+ path: `$.template.pages[${s}].components[${d}]`,
179
+ pageIndex: s,
180
+ componentIndex: d
181
+ };
182
+ }
183
+ return { path: "$.template" };
184
+ }
185
+ function K(e, t, r, a, n) {
186
+ const o = N(
187
+ e.template.params ?? [],
188
+ t.params ?? {}
189
+ );
190
+ if (n.issues.push(
191
+ ...o.issues.map((s) => ({
192
+ ...s,
193
+ code: "params",
194
+ severity: "error",
195
+ fixture: t.name,
196
+ path: s.path.replace(/^\$\.params/, `$.fixtures[${r}].params`)
197
+ }))
198
+ ), !!o.ok && J(t, e.template, a, n.issues))
199
+ try {
200
+ const { plan: s, warnings: f } = O(
201
+ e.template,
202
+ t.datasets,
203
+ {
204
+ maxPages: a.maxPages ?? 100,
205
+ maxCells: a.maxCells ?? 25e4
206
+ }
207
+ ), d = (a.formats ?? ["pdf", "xlsx"]).flatMap(
208
+ (i) => P(s, i)
209
+ );
210
+ n.issues.push(
211
+ ...f.map((i) => ({
212
+ code: "layout",
213
+ severity: "warning",
214
+ path: "$.template",
215
+ fixture: t.name,
216
+ message: i
217
+ }))
218
+ ), n.issues.push(
219
+ ...d.map((i) => ({
220
+ code: "output",
221
+ severity: a.strictOutputs ? "error" : "warning",
222
+ ...W(e.template, s, i),
223
+ fixture: t.name,
224
+ message: `${i.format}: ${i.message}`,
225
+ diagnostic: i
226
+ }))
227
+ ), n.samples.push({
228
+ name: t.name,
229
+ pages: s.pages.length,
230
+ rows: k(e.template, t.datasets),
231
+ diagnostics: d
232
+ });
233
+ } catch (s) {
234
+ n.issues.push({
235
+ code: "layout",
236
+ severity: "error",
237
+ path: "$.template",
238
+ fixture: t.name,
239
+ message: s instanceof Error ? s.message : String(s)
240
+ });
241
+ }
242
+ }
243
+ function V(e) {
244
+ for (const [r, a] of [
245
+ ["maxPages", e.maxPages],
246
+ ["maxCells", e.maxCells],
247
+ ["maxSampleRows", e.maxSampleRows]
248
+ ])
249
+ if (a !== void 0 && (!Number.isSafeInteger(a) || a < 1))
250
+ throw new RangeError(`${r} must be a positive safe integer`);
251
+ if ((e.fixtures?.length ?? 0) > 20)
252
+ throw new RangeError("At most 20 review fixtures are allowed");
253
+ const t = /* @__PURE__ */ new Set();
254
+ for (const r of e.fixtures ?? []) {
255
+ if (typeof r.name != "string" || !r.name.trim() || r.name.length > 120 || t.has(r.name))
256
+ throw new Error(
257
+ "Review fixtures require unique non-empty names of at most 120 characters"
258
+ );
259
+ t.add(r.name);
260
+ }
261
+ }
262
+ function* A(e, t, r) {
263
+ let a;
264
+ yield {
265
+ stage: "template",
266
+ run: () => {
267
+ V(t), a = h(e);
268
+ }
269
+ };
270
+ const n = t.previous;
271
+ n && (yield {
272
+ stage: "baseline",
273
+ run: () => {
274
+ r.changes = F(n, a), r.changes.breakingChanges && !t.allowBreakingChanges && r.issues.push({
275
+ code: "compatibility",
276
+ severity: "error",
277
+ path: "$.template",
278
+ message: `${r.changes.breakingChanges} 项字段或结构变更需要明确确认兼容性`
279
+ });
280
+ }
281
+ }), t.dataSchemas && (yield {
282
+ stage: "bindings",
283
+ run: () => B(a.template, t.dataSchemas, r.issues)
284
+ });
285
+ for (const [o, s] of (t.fixtures ?? []).entries())
286
+ yield {
287
+ stage: "fixture",
288
+ fixture: s.name,
289
+ run: () => K(a, s, o, t, r)
290
+ };
291
+ t.fixtures?.length || r.issues.push({
292
+ code: "sample",
293
+ severity: "warning",
294
+ path: "$.fixtures",
295
+ message: "未提供验收样例,仅完成结构和字段检查,尚未验证排版与输出"
296
+ });
297
+ }
298
+ function T(e) {
299
+ return e.ok = e.issues.every((t) => t.severity !== "error"), e;
300
+ }
301
+ function C(e, t) {
302
+ e.issues.push({
303
+ code: "template",
304
+ severity: "error",
305
+ path: "$",
306
+ message: t instanceof Error ? t.message : String(t)
307
+ });
308
+ }
309
+ function Z(e, t = {}) {
310
+ const r = { ok: !1, issues: [], samples: [] };
311
+ try {
312
+ for (const a of A(e, t, r)) a.run();
313
+ } catch (a) {
314
+ C(r, a);
315
+ }
316
+ return T(r);
317
+ }
318
+ function v(e) {
319
+ if (e?.aborted)
320
+ throw e.reason ?? new DOMException("Template review was aborted", "AbortError");
321
+ }
322
+ function _(e) {
323
+ return v(e), new Promise((t, r) => {
324
+ const a = () => {
325
+ clearTimeout(n), e?.removeEventListener("abort", a), r(
326
+ e?.reason ?? new DOMException("Template review was aborted", "AbortError")
327
+ );
328
+ }, n = setTimeout(() => {
329
+ e?.removeEventListener("abort", a), t();
330
+ }, 0);
331
+ e?.addEventListener("abort", a, { once: !0 }), e?.aborted && a();
332
+ });
333
+ }
334
+ function R(e, t) {
335
+ try {
336
+ e.onProgress?.(t);
337
+ } catch {
338
+ }
339
+ }
340
+ async function ee(e, t = {}) {
341
+ const r = { ok: !1, issues: [], samples: [] }, a = t.fixtures?.length ?? 0;
342
+ let n = 0;
343
+ v(t.signal);
344
+ try {
345
+ const o = A(e, t, r), s = o.next();
346
+ s.done || (s.value.run(), R(t, {
347
+ completed: n,
348
+ total: a,
349
+ stage: s.value.stage
350
+ })), v(t.signal);
351
+ for (const f of o)
352
+ await _(t.signal), v(t.signal), f.run(), f.stage === "fixture" && n++, R(t, {
353
+ completed: n,
354
+ total: a,
355
+ stage: f.stage,
356
+ ...f.fixture ? { fixture: f.fixture } : {}
357
+ }), v(t.signal);
358
+ } catch (o) {
359
+ v(t.signal), C(r, o);
360
+ }
361
+ return T(r);
362
+ }
363
+ function z(e, t) {
364
+ const r = e.publishedRevision ?? e.published?.revision;
365
+ for (const a of [e.draftRevision, r]) if (a !== void 0 && (typeof a != "string" || !a.trim())) throw new TypeError("模板生命周期修订应为非空字符串");
366
+ if (e.draftRevision !== void 0 && e.draftRevision !== t.revision) throw new TypeError("可编辑文档应与草稿修订一致");
367
+ if (e.published && (e.published.id !== t.id || e.published.revision !== r)) throw new TypeError("发布文档身份或修订不一致");
368
+ if (!e.published && r !== void 0 && r !== t.revision) throw new TypeError("发布修订需要对应的独立文档");
369
+ return { ...e.draftRevision === void 0 ? {} : { draftRevision: e.draftRevision }, ...r === void 0 ? {} : { publishedRevision: r } };
370
+ }
371
+ function te(e, t) {
372
+ const r = h(e);
373
+ if (t.id === r.id) throw new Error("复制模板应使用新的 ID");
374
+ const { revision: a, ...n } = r;
375
+ return h({ ...n, id: t.id, name: t.name });
376
+ }
377
+ function re(e) {
378
+ if (!Array.isArray(e) || e.length > 1e3) throw new RangeError("本地模板目录最多 1000 项");
379
+ const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), a = [];
380
+ for (const n of e) {
381
+ const o = h(n.document);
382
+ if (t.has(o.id)) throw new Error(`模板 ID 重复:${o.id}`);
383
+ if (n.category !== void 0 && (typeof n.category != "string" || n.category.length > 128) || n.tags !== void 0 && (!Array.isArray(n.tags) || n.tags.length > 20 || n.tags.some((i) => typeof i != "string" || i.length > 128))) throw new TypeError("模板分类和标签无效");
384
+ const s = z(n, o), { template: f, ...d } = o;
385
+ t.set(o.id, o), n.published ? r.set(o.id, h(n.published)) : s.publishedRevision && r.set(o.id, h(o)), a.push({ ...d, ...s, ...n.category ? { category: n.category } : {}, ...n.tags ? { tags: [...n.tags] } : {} });
386
+ }
387
+ return a.sort((n, o) => n.id < o.id ? -1 : 1), {
388
+ search: async (n) => {
389
+ E(n.signal);
390
+ const o = n.limit ?? 30;
391
+ if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new RangeError("模板每页数量应为 1–100");
392
+ const s = n.query?.trim().toLocaleLowerCase() ?? "", f = a.filter((i) => (!n.category || i.category === n.category) && (!n.cursor || i.id > n.cursor) && (!s || [i.id, i.name, i.description, ...i.tags ?? []].some((c) => c?.toLocaleLowerCase().includes(s)))), d = /* @__PURE__ */ new Map();
393
+ for (const i of a) i.category && d.set(i.category, (d.get(i.category) ?? 0) + 1);
394
+ return JSON.parse(JSON.stringify({ items: f.slice(0, o), ...f.length > o ? { next: f[o - 1].id } : {}, categories: Array.from(d, ([i, c]) => ({ id: i, label: i, count: c })) }));
395
+ },
396
+ get: async (n, o) => {
397
+ E(o.signal);
398
+ const s = o.mode === "published" ? r.get(n) : t.get(n);
399
+ return s ? h(s) : void 0;
400
+ }
401
+ };
402
+ }
403
+ function E(e) {
404
+ if (!e?.aborted) return;
405
+ const t = new Error("模板目录操作已取消");
406
+ throw t.name = "AbortError", t;
407
+ }
408
+ export {
409
+ re as a,
410
+ ee as b,
411
+ te as c,
412
+ F as d,
413
+ Z as r
414
+ };