@agile-team/mach-report 2.14.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 (256) hide show
  1. package/README.md +16 -11
  2. package/THIRD_PARTY_NOTICES.md +3 -1
  3. package/dist/{ExcelBindingWizard-CvsWR8Ga.js → ExcelBindingWizard-BKH1nGNS.js} +3 -3
  4. package/dist/{ExcelBindingWizard-CLT2p7P3.cjs → ExcelBindingWizard-Bs43BGNp.cjs} +1 -1
  5. package/dist/ParamEditor-Da4akw6V.cjs +1 -0
  6. package/dist/ParamEditor-DoAhzJsm.js +594 -0
  7. package/dist/{ReportBatchPanel-LqVgiqp7.js → ReportBatchPanel-BMf6boMA.js} +39 -39
  8. package/dist/{ReportBatchPanel-DkxTzBkD.cjs → ReportBatchPanel-wP9m9Pj1.cjs} +1 -1
  9. package/dist/ReportPreview-ChV19HBp.js +4619 -0
  10. package/dist/ReportPreview-DbLvvOUT.cjs +6 -0
  11. package/dist/{ReportTemplateLibrary-MjWEtc7X.js → ReportTemplateLibrary-C9wutIiT.js} +1 -1
  12. package/dist/{ReportTemplateLibrary-cQ1sqNYo.cjs → ReportTemplateLibrary-Sxr3eD0J.cjs} +1 -1
  13. package/dist/{RuleEditor-ChuXMlei.js → RuleEditor-C_Clasvd.js} +5 -5
  14. package/dist/{RuleEditor-BaR6xUiI.cjs → RuleEditor-XhGHK8DE.cjs} +1 -1
  15. package/dist/{TemplateOutlinePanel-Dci6aRn1.js → TemplateOutlinePanel-D6Bkny59.js} +2 -2
  16. package/dist/{TemplateOutlinePanel-BHKP89Xz.cjs → TemplateOutlinePanel-JTSR53vJ.cjs} +1 -1
  17. package/dist/{TemplateReusePanel-CY5eO2Sh.cjs → TemplateReusePanel-Kx35S0Ql.cjs} +1 -1
  18. package/dist/{TemplateReusePanel-B7Gmyc1z.js → TemplateReusePanel-rVuK1kTz.js} +2 -2
  19. package/dist/{TemplateReviewPanel-DjlX3xpt.js → TemplateReviewPanel-B0ar9_zf.js} +2 -2
  20. package/dist/{TemplateReviewPanel-JvZe9_4G.cjs → TemplateReviewPanel-Dn6X9UmY.cjs} +1 -1
  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 -1
  44. package/dist/designer.d.cts +144 -16
  45. package/dist/designer.d.ts +144 -16
  46. package/dist/designer.js +1 -1
  47. package/dist/drill-ByJviLXS.js +145 -0
  48. package/dist/drill-DYTxuL3A.cjs +1 -0
  49. package/dist/{font-loader-vhCT8znW.cjs → font-loader-B_UkxpzC.cjs} +1 -1
  50. package/dist/{font-loader-DHto6Lra.js → font-loader-Q3bQjmrI.js} +1 -1
  51. package/dist/index.cjs +8 -8
  52. package/dist/index.d.cts +82 -4
  53. package/dist/index.d.ts +82 -4
  54. package/dist/index.js +785 -820
  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-8UPQebOE.js → pdf-BwNyeGpt.js} +4385 -4321
  161. package/dist/{pdf-AyJGb22z.cjs → pdf-CvvrjPQg.cjs} +51 -49
  162. package/dist/pdf.cjs +1 -1
  163. package/dist/pdf.d.cts +18 -3
  164. package/dist/pdf.d.ts +18 -3
  165. package/dist/pdf.js +2 -2
  166. package/dist/{plugin-BGKf-Tqg.js → plugin-Ca_XZG3l.js} +2 -2
  167. package/dist/{plugin-CktLH_Iy.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-By_UKZ2g.cjs +1 -0
  173. package/dist/record-bindings-Do_b3h4V.js +196 -0
  174. package/dist/{region-binding-workflow-DEJbhpCv.js → region-binding-workflow-BMhK_TjP.js} +1 -1
  175. package/dist/{region-binding-workflow-BzfbxRiR.cjs → region-binding-workflow-DIYJdCUr.cjs} +1 -1
  176. package/dist/{report-params-B44imUd4.js → report-params-B1RzkhJj.js} +1 -1
  177. package/dist/{report-params-SJfhKgaX.cjs → report-params-WDGrA4oP.cjs} +1 -1
  178. package/dist/sbom.cdx.json +3982 -0
  179. package/dist/server/node.d.cts +20 -1
  180. package/dist/server/node.d.ts +20 -1
  181. package/dist/server-node.cjs +1 -1
  182. package/dist/server-node.js +247 -237
  183. package/dist/server.cjs +1 -1
  184. package/dist/server.d.cts +772 -4
  185. package/dist/server.d.ts +772 -4
  186. package/dist/server.js +885 -645
  187. package/dist/sha256-ArEYjaTI.cjs +1 -0
  188. package/dist/sha256-DPEuJ3nh.js +155 -0
  189. package/dist/style.css +1 -1
  190. package/dist/template-bindings-C2SpvsMU.js +58 -0
  191. package/dist/template-bindings-CEtWyiLX.cjs +1 -0
  192. package/dist/template-catalog-FJE_c9Qe.cjs +1 -0
  193. package/dist/template-catalog-j2B1MJlL.js +414 -0
  194. package/dist/{template-fragments-CLkGo6To.js → template-fragments-BGbQLGlV.js} +21 -21
  195. package/dist/{template-fragments-DFUpq5QM.cjs → template-fragments-DcKeiylI.cjs} +1 -1
  196. package/dist/{template-outline-B3xVkzSv.cjs → template-outline-BwRV_eRo.cjs} +1 -1
  197. package/dist/{template-outline-CFenM1PV.js → template-outline-cnWfT_LK.js} +3 -3
  198. package/dist/{template-registry-COXDEJEM.js → template-registry-BtaKPELV.js} +364 -201
  199. package/dist/template-registry-Co1zPq5e.cjs +1 -0
  200. package/dist/textwrap-CWHyzkBH.cjs +4 -0
  201. package/dist/textwrap-DE1kgcJB.js +110 -0
  202. package/dist/{tree-CqcQ99NM.js → tree-CjVZLRw7.js} +1 -1
  203. package/dist/vue/async.d.cts +123 -14
  204. package/dist/vue/async.d.ts +123 -14
  205. package/dist/vue/index.d.cts +158 -22
  206. package/dist/vue/index.d.ts +158 -22
  207. package/dist/vue-async.cjs +1 -1
  208. package/dist/vue-async.js +3 -3
  209. package/dist/vue.cjs +1 -1
  210. package/dist/vue.js +80 -78
  211. package/dist/{workbook-session-DNa2RHNG.cjs → workbook-session-Bjv1YCRK.cjs} +18 -18
  212. package/dist/{workbook-session-BfK1yHOO.js → workbook-session-BvToI-Fd.js} +5440 -5288
  213. package/dist/worker.cjs +1 -1
  214. package/dist/worker.d.cts +20 -1
  215. package/dist/worker.d.ts +20 -1
  216. package/dist/worker.js +33 -32
  217. package/dist/xlsx-node.cjs +34 -34
  218. package/dist/xlsx-node.js +878 -870
  219. package/dist/xlsx.cjs +3 -4
  220. package/dist/xlsx.d.cts +22 -10
  221. package/dist/xlsx.d.ts +22 -10
  222. package/dist/xlsx.js +261 -253
  223. package/package.json +2 -2
  224. package/dist/ParamEditor-CflQV3eQ.js +0 -526
  225. package/dist/ParamEditor-vIDzvpPV.cjs +0 -1
  226. package/dist/ReportPreview-CvbqLUzM.cjs +0 -6
  227. package/dist/ReportPreview-D_ywJ_-H.js +0 -4533
  228. package/dist/assets-C2U-e-Sz.cjs +0 -4
  229. package/dist/assets-Q0wUwNrV.js +0 -217
  230. package/dist/batch-DzaTNLWI.js +0 -371
  231. package/dist/batch-xMkqYiTr.cjs +0 -1
  232. package/dist/capabilities-CK_7hizc.js +0 -63
  233. package/dist/capabilities-CsZ-pNHR.cjs +0 -1
  234. package/dist/config-0UIohTS7.cjs +0 -1
  235. package/dist/config-Dt9NtCPl.js +0 -566
  236. package/dist/data-explanation-BktvER5B.cjs +0 -1
  237. package/dist/data-explanation-C_J6jYNi.js +0 -16
  238. package/dist/designer-Ci1LizA9.js +0 -5020
  239. package/dist/designer-rtmVIIdN.cjs +0 -2
  240. package/dist/json-snapshot-BeFT3Tso.js +0 -1952
  241. package/dist/json-snapshot-D1NTP2oI.cjs +0 -2
  242. package/dist/matrix-DVyWiYsd.cjs +0 -1
  243. package/dist/matrix-yZsGnldA.js +0 -227
  244. package/dist/page-window-index-CIuT4BAv.js +0 -43
  245. package/dist/page-window-index-DEjnM6IB.cjs +0 -1
  246. package/dist/param-validation-BlHHXs6u.js +0 -153
  247. package/dist/param-validation-DCK039V1.cjs +0 -1
  248. package/dist/progress-7OSZbFok.js +0 -39
  249. package/dist/progress-BnLiS5eH.cjs +0 -1
  250. package/dist/task-events-DQ276fn2.cjs +0 -1
  251. package/dist/task-events-Dpsvf_t2.js +0 -47
  252. package/dist/template-bindings-BJR4k7qZ.cjs +0 -1
  253. package/dist/template-bindings-Daui7hLF.js +0 -252
  254. package/dist/template-registry-D3SjENi6.cjs +0 -1
  255. package/dist/validate-BJ5HIWY8.cjs +0 -1
  256. package/dist/validate-CkQBWCeg.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
+ };
@@ -1,7 +1,7 @@
1
- import { p } from "./template-registry-COXDEJEM.js";
2
- import { g as S } from "./template-bindings-Daui7hLF.js";
3
- import { e as g } from "./style-CQ1PK8ZB.js";
4
- function c(t) {
1
+ import { p } from "./template-registry-BtaKPELV.js";
2
+ import { c as S } from "./template-bindings-C2SpvsMU.js";
3
+ import { e as h } from "./style-CQ1PK8ZB.js";
4
+ function m(t) {
5
5
  return JSON.parse(JSON.stringify(t));
6
6
  }
7
7
  function u(t) {
@@ -30,16 +30,16 @@ function j(t, a, e, n) {
30
30
  throw new Error("Select existing components to capture a fragment");
31
31
  const s = [...new Set(e)].map(
32
32
  (o) => r.components[o]
33
- ), l = Math.min(...s.map((o) => o.leftMm)), i = Math.min(...s.map((o) => o.topMm)), m = {
33
+ ), l = Math.min(...s.map((o) => o.leftMm)), i = Math.min(...s.map((o) => o.topMm)), c = {
34
34
  ...n,
35
35
  ...t.template.repeat ? { repeatDataset: t.template.repeat.dataset } : {},
36
- components: c(s).map((o) => ({
36
+ components: m(s).map((o) => ({
37
37
  ...o,
38
38
  leftMm: o.leftMm - l,
39
39
  topMm: o.topMm - i
40
40
  }))
41
41
  };
42
- return M(m), m;
42
+ return M(c), c;
43
43
  }
44
44
  function $(t) {
45
45
  M(t);
@@ -75,10 +75,10 @@ function b(t, a, e = {}) {
75
75
  s !== void 0 && E(n, `${r.path}.dataset`, s);
76
76
  }
77
77
  }
78
- function h(t) {
78
+ function g(t) {
79
79
  if (!t || typeof t != "object") return;
80
80
  if (Array.isArray(t)) {
81
- t.forEach(h);
81
+ t.forEach(g);
82
82
  return;
83
83
  }
84
84
  const a = t;
@@ -86,7 +86,7 @@ function h(t) {
86
86
  if (a.kind === "list" && delete a.id, a.meta && typeof a.meta == "object")
87
87
  for (const e of ["fragment", "labelSource", "record"])
88
88
  delete a.meta[e];
89
- Object.values(a).forEach(h);
89
+ Object.values(a).forEach(g);
90
90
  }
91
91
  function x(t) {
92
92
  const a = new Set(
@@ -130,11 +130,11 @@ function v(t, a, e) {
130
130
  const n = p(t), r = n.template.pages[e.pageIndex];
131
131
  if (!r || r.flow)
132
132
  throw new Error("Choose a fixed page before inserting a fragment");
133
- const s = F(r, a, e.replaceInstance), l = s.replacing, i = e.leftMm ?? s.left, m = e.topMm ?? s.top, o = c(a.components), w = e.replaceInstance ?? x(n);
133
+ const s = F(r, a, e.replaceInstance), l = s.replacing, i = e.leftMm ?? s.left, c = e.topMm ?? s.top, o = m(a.components), w = e.replaceInstance ?? x(n);
134
134
  if (a.repeatDataset && n.template.repeat?.dataset !== (e.bindings?.datasets?.[a.repeatDataset] ?? a.repeatDataset))
135
135
  throw new Error("Bind this label fragment to the current record dataset");
136
- b(a, o, e.bindings), o.forEach(h), o.forEach((f, d) => {
137
- f.leftMm += i, f.topMm += m, f.meta = {
136
+ b(a, o, e.bindings), o.forEach(g), o.forEach((f, d) => {
137
+ f.leftMm += i, f.topMm += c, f.meta = {
138
138
  ...f.meta,
139
139
  fragment: {
140
140
  id: a.id,
@@ -159,25 +159,25 @@ function B(t, a, e, n) {
159
159
  for (const l of e) {
160
160
  const i = s.components[l];
161
161
  if (!i) throw new Error("Component no longer exists");
162
- i.kind === "list" ? n.target === "header" ? D(i, n.style) : i.columns.forEach((m) => {
163
- m.style = g(m.style, c(n.style)), n.style.align && (m.align = n.style.align);
164
- }) : i.style = g(
162
+ i.kind === "list" ? n.target === "header" ? D(i, n.style) : i.columns.forEach((c) => {
163
+ c.style = h(c.style, m(n.style)), n.style.align && (c.align = n.style.align);
164
+ }) : i.style = h(
165
165
  i.style,
166
- c(n.style)
166
+ m(n.style)
167
167
  );
168
168
  }
169
169
  return p(r);
170
170
  }
171
171
  function D(t, a) {
172
- if (t.headerStyle = g(
172
+ if (t.headerStyle = h(
173
173
  t.headerStyle,
174
- c(a)
174
+ m(a)
175
175
  ), t.columns.forEach((e) => {
176
- e.headerStyle = g(e.headerStyle, c(a)), a.align && (e.headerAlign = a.align);
176
+ e.headerStyle = h(e.headerStyle, m(a)), a.align && (e.headerAlign = a.align);
177
177
  }), t.headerGrid)
178
178
  for (const e of t.headerGrid.cells)
179
179
  for (const n of e)
180
- n && (n.style = g(n.style, c(a)));
180
+ n && (n.style = h(n.style, m(a)));
181
181
  }
182
182
  export {
183
183
  B as a,
@@ -1 +1 @@
1
- "use strict";const f=require("./template-registry-D3SjENi6.cjs"),T=require("./template-bindings-BJR4k7qZ.cjs"),g=require("./style-UgIJSA1F.cjs");function p(t){return JSON.parse(JSON.stringify(t))}function u(t){return{...t.repeatDataset?{repeat:{dataset:t.repeatDataset}}:{},pages:[{widthMm:4999,heightMm:4999,components:t.components}]}}function y(t){if(!t.id.trim()||!t.name.trim()||!t.revision.trim())throw new Error("Fragment identity, name and revision are required");if(!t.components.length||t.components.length>200)throw new RangeError("A fragment must contain 1–200 components");f.parseReportTemplate({schemaVersion:"1.0",id:t.id,name:t.name,template:u(t)})}function E(t,n,e,a){const r=f.parseReportTemplate(t).template.pages[n];if(!r||!e.length||e.some(o=>!Number.isSafeInteger(o)||!r.components[o]))throw new Error("Select existing components to capture a fragment");const s=[...new Set(e)].map(o=>r.components[o]),l=Math.min(...s.map(o=>o.leftMm)),i=Math.min(...s.map(o=>o.topMm)),m={...a,...t.template.repeat?{repeatDataset:t.template.repeat.dataset}:{},components:p(s).map(o=>({...o,leftMm:o.leftMm-l,topMm:o.topMm-i}))};return y(m),m}function b(t){y(t);const n=new Map;for(const e of T.collectTemplateDatasetBindings(u(t))){const a=n.get(e.dataset)??new Set;for(const r of e.fields)!e.generated.has(r.field)&&!e.summaries.has(r.field)&&a.add(r.field);n.set(e.dataset,a)}return[...n].map(([e,a])=>({dataset:e,fields:[...a]}))}function S(t,n,e){const a=n.replace(/^\$\.template\./,"").replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const s of a.slice(0,-1))r=r[s];r[a[a.length-1]]=e}function F(t,n,e={}){const a=u({...t,components:n});for(const r of T.collectTemplateDatasetBindings(a)){for(const l of r.fields){const i=e.fields?.[r.dataset]?.[l.field];i!==void 0&&S(a,l.path,i)}const s=e.datasets?.[r.dataset];s!==void 0&&S(a,`${r.path}.dataset`,s)}}function h(t){if(!t||typeof t!="object")return;if(Array.isArray(t)){t.forEach(h);return}const n=t;for(const e of["nid","rkey","table","source"])delete n[e];if(n.kind==="list"&&delete n.id,n.meta&&typeof n.meta=="object")for(const e of["fragment","labelSource","record"])delete n.meta[e];Object.values(n).forEach(h)}function D(t){const n=new Set(t.template.pages.flatMap(a=>a.components.map(r=>r.meta?.fragment?.instance)));let e=1;for(;n.has(`fragment-${e}`);)e++;return`fragment-${e}`}function R(t,n,e){const a=e?t.components.flatMap((s,l)=>s.meta?.fragment?.instance===e?[l]:[]):[];if(e&&!a.length)throw new Error("Fragment instance no longer exists");const r=a.map(s=>t.components[s]);if(r.some(s=>s.meta?.fragment?.id!==n.id))throw new Error("An upgrade must use the same fragment identity");return{replacing:a,left:r.length?Math.min(...r.map(s=>s.leftMm)):t.marginLeftMm??0,top:r.length?Math.min(...r.map(s=>s.topMm)):t.marginTopMm??0}}function x(t,n){if(n.some(e=>e.leftMm<0||e.topMm<0||e.leftMm+e.widthMm>t.widthMm+.001||e.topMm+(e.kind==="list"?e.rowHeightMm??7:e.heightMm)>t.heightMm+.001))throw new Error("Fragment exceeds the target page; choose a larger page or adjust its placement")}function k(t,n,e){y(n);const a=f.parseReportTemplate(t),r=a.template.pages[e.pageIndex];if(!r||r.flow)throw new Error("Choose a fixed page before inserting a fragment");const s=R(r,n,e.replaceInstance),l=s.replacing,i=e.leftMm??s.left,m=e.topMm??s.top,o=p(n.components),M=e.replaceInstance??D(a);if(n.repeatDataset&&a.template.repeat?.dataset!==(e.bindings?.datasets?.[n.repeatDataset]??n.repeatDataset))throw new Error("Bind this label fragment to the current record dataset");F(n,o,e.bindings),o.forEach(h),o.forEach((c,d)=>{c.leftMm+=i,c.topMm+=m,c.meta={...c.meta,fragment:{id:n.id,revision:n.revision,instance:M,slot:d}}}),x(r,o);const w=l[0]??r.components.length;return r.components=r.components.filter((c,d)=>!l.includes(d)),r.components.splice(w,0,...o),{document:f.parseReportTemplate(a),componentIndices:o.map((c,d)=>w+d),instance:M}}function C(t,n,e,a){const r=f.parseReportTemplate(t),s=r.template.pages[n];if(!s)throw new Error("Page no longer exists");for(const l of e){const i=s.components[l];if(!i)throw new Error("Component no longer exists");i.kind==="list"?a.target==="header"?I(i,a.style):i.columns.forEach(m=>{m.style=g.mergeComponentStyles(m.style,p(a.style)),a.style.align&&(m.align=a.style.align)}):i.style=g.mergeComponentStyles(i.style,p(a.style))}return f.parseReportTemplate(r)}function I(t,n){if(t.headerStyle=g.mergeComponentStyles(t.headerStyle,p(n)),t.columns.forEach(e=>{e.headerStyle=g.mergeComponentStyles(e.headerStyle,p(n)),n.align&&(e.headerAlign=n.align)}),t.headerGrid)for(const e of t.headerGrid.cells)for(const a of e)a&&(a.style=g.mergeComponentStyles(a.style,p(n)))}exports.applyReportDocumentStyle=C;exports.captureTemplateFragment=E;exports.insertTemplateFragment=k;exports.inspectTemplateFragmentBindings=b;
1
+ "use strict";const f=require("./template-registry-Co1zPq5e.cjs"),T=require("./template-bindings-CEtWyiLX.cjs"),g=require("./style-UgIJSA1F.cjs");function p(t){return JSON.parse(JSON.stringify(t))}function u(t){return{...t.repeatDataset?{repeat:{dataset:t.repeatDataset}}:{},pages:[{widthMm:4999,heightMm:4999,components:t.components}]}}function y(t){if(!t.id.trim()||!t.name.trim()||!t.revision.trim())throw new Error("Fragment identity, name and revision are required");if(!t.components.length||t.components.length>200)throw new RangeError("A fragment must contain 1–200 components");f.parseReportTemplate({schemaVersion:"1.0",id:t.id,name:t.name,template:u(t)})}function E(t,n,e,a){const r=f.parseReportTemplate(t).template.pages[n];if(!r||!e.length||e.some(o=>!Number.isSafeInteger(o)||!r.components[o]))throw new Error("Select existing components to capture a fragment");const s=[...new Set(e)].map(o=>r.components[o]),l=Math.min(...s.map(o=>o.leftMm)),i=Math.min(...s.map(o=>o.topMm)),m={...a,...t.template.repeat?{repeatDataset:t.template.repeat.dataset}:{},components:p(s).map(o=>({...o,leftMm:o.leftMm-l,topMm:o.topMm-i}))};return y(m),m}function b(t){y(t);const n=new Map;for(const e of T.collectTemplateDatasetBindings(u(t))){const a=n.get(e.dataset)??new Set;for(const r of e.fields)!e.generated.has(r.field)&&!e.summaries.has(r.field)&&a.add(r.field);n.set(e.dataset,a)}return[...n].map(([e,a])=>({dataset:e,fields:[...a]}))}function S(t,n,e){const a=n.replace(/^\$\.template\./,"").replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const s of a.slice(0,-1))r=r[s];r[a[a.length-1]]=e}function F(t,n,e={}){const a=u({...t,components:n});for(const r of T.collectTemplateDatasetBindings(a)){for(const l of r.fields){const i=e.fields?.[r.dataset]?.[l.field];i!==void 0&&S(a,l.path,i)}const s=e.datasets?.[r.dataset];s!==void 0&&S(a,`${r.path}.dataset`,s)}}function h(t){if(!t||typeof t!="object")return;if(Array.isArray(t)){t.forEach(h);return}const n=t;for(const e of["nid","rkey","table","source"])delete n[e];if(n.kind==="list"&&delete n.id,n.meta&&typeof n.meta=="object")for(const e of["fragment","labelSource","record"])delete n.meta[e];Object.values(n).forEach(h)}function D(t){const n=new Set(t.template.pages.flatMap(a=>a.components.map(r=>r.meta?.fragment?.instance)));let e=1;for(;n.has(`fragment-${e}`);)e++;return`fragment-${e}`}function R(t,n,e){const a=e?t.components.flatMap((s,l)=>s.meta?.fragment?.instance===e?[l]:[]):[];if(e&&!a.length)throw new Error("Fragment instance no longer exists");const r=a.map(s=>t.components[s]);if(r.some(s=>s.meta?.fragment?.id!==n.id))throw new Error("An upgrade must use the same fragment identity");return{replacing:a,left:r.length?Math.min(...r.map(s=>s.leftMm)):t.marginLeftMm??0,top:r.length?Math.min(...r.map(s=>s.topMm)):t.marginTopMm??0}}function x(t,n){if(n.some(e=>e.leftMm<0||e.topMm<0||e.leftMm+e.widthMm>t.widthMm+.001||e.topMm+(e.kind==="list"?e.rowHeightMm??7:e.heightMm)>t.heightMm+.001))throw new Error("Fragment exceeds the target page; choose a larger page or adjust its placement")}function k(t,n,e){y(n);const a=f.parseReportTemplate(t),r=a.template.pages[e.pageIndex];if(!r||r.flow)throw new Error("Choose a fixed page before inserting a fragment");const s=R(r,n,e.replaceInstance),l=s.replacing,i=e.leftMm??s.left,m=e.topMm??s.top,o=p(n.components),M=e.replaceInstance??D(a);if(n.repeatDataset&&a.template.repeat?.dataset!==(e.bindings?.datasets?.[n.repeatDataset]??n.repeatDataset))throw new Error("Bind this label fragment to the current record dataset");F(n,o,e.bindings),o.forEach(h),o.forEach((c,d)=>{c.leftMm+=i,c.topMm+=m,c.meta={...c.meta,fragment:{id:n.id,revision:n.revision,instance:M,slot:d}}}),x(r,o);const w=l[0]??r.components.length;return r.components=r.components.filter((c,d)=>!l.includes(d)),r.components.splice(w,0,...o),{document:f.parseReportTemplate(a),componentIndices:o.map((c,d)=>w+d),instance:M}}function C(t,n,e,a){const r=f.parseReportTemplate(t),s=r.template.pages[n];if(!s)throw new Error("Page no longer exists");for(const l of e){const i=s.components[l];if(!i)throw new Error("Component no longer exists");i.kind==="list"?a.target==="header"?I(i,a.style):i.columns.forEach(m=>{m.style=g.mergeComponentStyles(m.style,p(a.style)),a.style.align&&(m.align=a.style.align)}):i.style=g.mergeComponentStyles(i.style,p(a.style))}return f.parseReportTemplate(r)}function I(t,n){if(t.headerStyle=g.mergeComponentStyles(t.headerStyle,p(n)),t.columns.forEach(e=>{e.headerStyle=g.mergeComponentStyles(e.headerStyle,p(n)),n.align&&(e.headerAlign=n.align)}),t.headerGrid)for(const e of t.headerGrid.cells)for(const a of e)a&&(a.style=g.mergeComponentStyles(a.style,p(n)))}exports.applyReportDocumentStyle=C;exports.captureTemplateFragment=E;exports.insertTemplateFragment=k;exports.inspectTemplateFragmentBindings=b;
@@ -1 +1 @@
1
- "use strict";const u=require("./template-bindings-BJR4k7qZ.cjs");function $(e){const a=/\.pages\[(\d+)\](?:\.components\[(\d+)\])?/.exec(e);return a?{pageIndex:Number(a[1]),...a[2]===void 0?{}:{componentIndex:Number(a[2])}}:{}}function m(e,a,l){return u.collectTemplateDatasetBindings(e).filter(s=>s.dataset===a).flatMap(s=>s.fields.filter(t=>t.field===l).map(t=>({...t,...$(t.path),dataset:a,kind:/\.computed\[/.test(t.path)?"calculation":/\.columns\[\d+\]\.field$/.test(t.path)?"display":"binding"})))}function g(e,a){const l=e.kind==="list"?e.title||e.dataset:e.binding?.field||e.text||e.nid;return`${e.kind} · ${(l||String(a+1)).replace(/\s+/g," ").slice(0,80)}`}function k(e){const a=u.collectTemplateDatasetBindings(e),l=new Map;for(const t of a)for(const d of t.fields){const c=/^\$\.template\.pages\[\d+\]\.components\[\d+\]/.exec(d.path)?.[0];if(!c)continue;const n=l.get(c)??[];n.push({...d,dataset:t.dataset}),l.set(c,n)}const s=[];return e.pages.forEach((t,d)=>{const c=`$.template.pages[${d}]`;s.push({path:c,pageIndex:d,kind:"page",depth:0,title:typeof t.meta?.title=="string"?t.meta.title:`${d+1} · ${t.widthMm} × ${t.heightMm} mm`}),t.components.forEach((n,p)=>{const o=`${c}.components[${p}]`,f={pageIndex:d,componentIndex:p};s.push({path:o,...f,depth:1,kind:"component",title:g(n,p)}),n.kind==="list"&&(n.columns.forEach((i,h)=>s.push({path:`${o}.columns[${h}].field`,...f,depth:2,kind:"field",title:`${i.header} · ${i.field}`,field:i.field,dataset:n.dataset})),n.computed?.forEach((i,h)=>s.push({path:`${o}.computed[${h}]`,...f,depth:2,kind:"calculation",title:i.field,field:i.field,dataset:n.dataset})));const r=new Set;for(const i of l.get(o)??[])/\.columns\[\d+\]\.field$/.test(i.path)||r.has(i.path)||(r.add(i.path),s.push({...i,...f,depth:2,kind:"binding",title:i.field}))})}),s}exports.collectTemplateOutline=k;exports.inspectTemplateFieldUsage=m;exports.templatePathLocation=$;
1
+ "use strict";const u=require("./template-bindings-CEtWyiLX.cjs");function $(e){const a=/\.pages\[(\d+)\](?:\.components\[(\d+)\])?/.exec(e);return a?{pageIndex:Number(a[1]),...a[2]===void 0?{}:{componentIndex:Number(a[2])}}:{}}function m(e,a,l){return u.collectTemplateDatasetBindings(e).filter(s=>s.dataset===a).flatMap(s=>s.fields.filter(t=>t.field===l).map(t=>({...t,...$(t.path),dataset:a,kind:/\.computed\[/.test(t.path)?"calculation":/\.columns\[\d+\]\.field$/.test(t.path)?"display":"binding"})))}function g(e,a){const l=e.kind==="list"?e.title||e.dataset:e.binding?.field||e.text||e.nid;return`${e.kind} · ${(l||String(a+1)).replace(/\s+/g," ").slice(0,80)}`}function k(e){const a=u.collectTemplateDatasetBindings(e),l=new Map;for(const t of a)for(const d of t.fields){const c=/^\$\.template\.pages\[\d+\]\.components\[\d+\]/.exec(d.path)?.[0];if(!c)continue;const n=l.get(c)??[];n.push({...d,dataset:t.dataset}),l.set(c,n)}const s=[];return e.pages.forEach((t,d)=>{const c=`$.template.pages[${d}]`;s.push({path:c,pageIndex:d,kind:"page",depth:0,title:typeof t.meta?.title=="string"?t.meta.title:`${d+1} · ${t.widthMm} × ${t.heightMm} mm`}),t.components.forEach((n,p)=>{const o=`${c}.components[${p}]`,f={pageIndex:d,componentIndex:p};s.push({path:o,...f,depth:1,kind:"component",title:g(n,p)}),n.kind==="list"&&(n.columns.forEach((i,h)=>s.push({path:`${o}.columns[${h}].field`,...f,depth:2,kind:"field",title:`${i.header} · ${i.field}`,field:i.field,dataset:n.dataset})),n.computed?.forEach((i,h)=>s.push({path:`${o}.computed[${h}]`,...f,depth:2,kind:"calculation",title:i.field,field:i.field,dataset:n.dataset})));const r=new Set;for(const i of l.get(o)??[])/\.columns\[\d+\]\.field$/.test(i.path)||r.has(i.path)||(r.add(i.path),s.push({...i,...f,depth:2,kind:"binding",title:i.field}))})}),s}exports.collectTemplateOutline=k;exports.inspectTemplateFieldUsage=m;exports.templatePathLocation=$;