@agile-team/mach-report 2.9.1 → 2.11.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 (115) hide show
  1. package/README.md +11 -7
  2. package/dist/ExcelBindingWizard-CjIiVox-.cjs +1 -0
  3. package/dist/ExcelBindingWizard-Dxm-K5HL.js +1240 -0
  4. package/dist/ParamEditor-D-Hf5xfO.cjs +1 -0
  5. package/dist/ParamEditor-DRGxzxeO.js +381 -0
  6. package/dist/ReportBatchPanel-BYgg0EDB.cjs +1 -0
  7. package/dist/ReportBatchPanel-Bby5yLzU.js +287 -0
  8. package/dist/ReportPreview-DWXROHBP.cjs +6 -0
  9. package/dist/ReportPreview-DiNXhQI0.js +4138 -0
  10. package/dist/ReportTemplateLibrary-C6CO7YCT.cjs +1 -0
  11. package/dist/ReportTemplateLibrary-DfzDXRvr.js +260 -0
  12. package/dist/RuleEditor-C2QsOHOs.cjs +1 -0
  13. package/dist/RuleEditor-D9wQHrkf.js +2024 -0
  14. package/dist/TemplateReviewPanel-BKofGrV9.js +222 -0
  15. package/dist/TemplateReviewPanel-DwtOcLue.cjs +1 -0
  16. package/dist/analytics.cjs +1 -1
  17. package/dist/analytics.d.cts +4 -0
  18. package/dist/analytics.d.ts +4 -0
  19. package/dist/analytics.js +40 -39
  20. package/dist/{assets-ahTRUXRk.cjs → assets-Bu6UohJx.cjs} +1 -1
  21. package/dist/{assets-DDsfEi8R.js → assets-DegqDNqY.js} +1 -1
  22. package/dist/batch-Bt3Fd27Z.cjs +1 -0
  23. package/dist/batch-mRqhhhjt.js +364 -0
  24. package/dist/{capabilities-Cm9hZ3uV.js → capabilities-CK_7hizc.js} +16 -16
  25. package/dist/capabilities-CsZ-pNHR.cjs +1 -0
  26. package/dist/computed-Bvk0W15F.js +521 -0
  27. package/dist/computed-CGV2a809.cjs +1 -0
  28. package/dist/config-B612mw0x.js +525 -0
  29. package/dist/config-BRoLo2oj.cjs +1 -0
  30. package/dist/designer.cjs +2 -2
  31. package/dist/designer.d.cts +695 -50
  32. package/dist/designer.d.ts +695 -50
  33. package/dist/designer.js +2213 -1748
  34. package/dist/index.cjs +8 -8
  35. package/dist/index.d.cts +205 -6
  36. package/dist/index.d.ts +205 -6
  37. package/dist/index.js +808 -1033
  38. package/dist/injection-keys-Db_DyLkm.cjs +1 -0
  39. package/dist/injection-keys-e85udZCp.js +7 -0
  40. package/dist/list-cell-BuYn4tGF.cjs +1 -0
  41. package/dist/list-cell-ClFra1zS.js +173 -0
  42. package/dist/matrix-DVyWiYsd.cjs +1 -0
  43. package/dist/matrix-yZsGnldA.js +227 -0
  44. package/dist/param-validation-BlHHXs6u.js +153 -0
  45. package/dist/param-validation-DCK039V1.cjs +1 -0
  46. package/dist/pdf.cjs +49 -49
  47. package/dist/pdf.d.cts +31 -1
  48. package/dist/pdf.d.ts +31 -1
  49. package/dist/pdf.js +4797 -4650
  50. package/dist/plugin-BDTU4D94.cjs +1 -0
  51. package/dist/plugin-Cd5G2QQn.js +22 -0
  52. package/dist/region-binding-workflow-CXDmt9Bs.js +977 -0
  53. package/dist/region-binding-workflow-DhQvu1co.cjs +3 -0
  54. package/dist/{report-params-B_VCihAh.js → report-params-B44imUd4.js} +1 -1
  55. package/dist/{report-params-CjWrjPl6.cjs → report-params-SJfhKgaX.cjs} +1 -1
  56. package/dist/server/node.d.cts +48 -5
  57. package/dist/server/node.d.ts +48 -5
  58. package/dist/server-node.cjs +1 -1
  59. package/dist/server-node.js +503 -317
  60. package/dist/server.cjs +1 -1
  61. package/dist/server.d.cts +252 -4
  62. package/dist/server.d.ts +252 -4
  63. package/dist/server.js +567 -469
  64. package/dist/style.css +1 -1
  65. package/dist/template-registry-WNXdkiET.js +506 -0
  66. package/dist/template-registry-ukBGlm8N.cjs +1 -0
  67. package/dist/template-review-BXp2oyqg.cjs +1 -0
  68. package/dist/template-review-BdcXSYbx.js +1616 -0
  69. package/dist/tree-BX380Rr7.cjs +1 -0
  70. package/dist/tree-CqcQ99NM.js +172 -0
  71. package/dist/useLocalDraft-C07SYRnC.js +11 -0
  72. package/dist/useLocalDraft-Yiw1wFgI.cjs +1 -0
  73. package/dist/{validate-DWPF7icl.js → validate-7s0yn6ii.js} +26 -26
  74. package/dist/validate-DsRiNw8h.cjs +1 -0
  75. package/dist/vue/async.d.cts +118 -6
  76. package/dist/vue/async.d.ts +118 -6
  77. package/dist/vue/index.d.cts +177 -11
  78. package/dist/vue/index.d.ts +177 -11
  79. package/dist/vue-async.cjs +1 -1
  80. package/dist/vue-async.js +5 -5
  81. package/dist/vue.cjs +1 -1
  82. package/dist/vue.js +116 -113
  83. package/dist/{import-template-CNMLJSQw.js → workbook-session-BKOTwcoq.js} +4290 -4227
  84. package/dist/{import-template-CpxunKVp.cjs → workbook-session-CLYLhZWu.cjs} +17 -17
  85. package/dist/worker.cjs +1 -1
  86. package/dist/worker.d.cts +9 -2
  87. package/dist/worker.d.ts +9 -2
  88. package/dist/worker.js +1 -1
  89. package/dist/xlsx.cjs +4 -2
  90. package/dist/xlsx.d.cts +159 -3
  91. package/dist/xlsx.d.ts +159 -3
  92. package/dist/xlsx.js +354 -192
  93. package/package.json +1 -1
  94. package/dist/ExcelBindingWizard-DiaxvWpQ.cjs +0 -1
  95. package/dist/ExcelBindingWizard-RLJIXKKG.js +0 -816
  96. package/dist/ReportPreview-B5ZNEasW.js +0 -4439
  97. package/dist/ReportPreview-DRtVPUYo.cjs +0 -6
  98. package/dist/RuleEditor-CskN5Fr3.cjs +0 -1
  99. package/dist/RuleEditor-CtJFzKuY.js +0 -1578
  100. package/dist/TemplateReviewPanel-C_Lmzis6.cjs +0 -1
  101. package/dist/TemplateReviewPanel-Cn32OY4_.js +0 -173
  102. package/dist/binding-preview-B5834rml.cjs +0 -2
  103. package/dist/binding-preview-ChXjN5L5.js +0 -649
  104. package/dist/capabilities-DYzWL7KS.cjs +0 -1
  105. package/dist/matrix-CNPDJxED.js +0 -745
  106. package/dist/matrix-Div9Ilh3.cjs +0 -1
  107. package/dist/param-validation-BWNjLcN0.js +0 -116
  108. package/dist/param-validation-CiTxFeZ8.cjs +0 -1
  109. package/dist/plugin-BWwIgZXV.js +0 -25
  110. package/dist/plugin-Dg-J1Rbm.cjs +0 -1
  111. package/dist/template-registry-CHMYZ7SD.cjs +0 -1
  112. package/dist/template-registry-R61AMCr0.js +0 -433
  113. package/dist/template-review-hvWWQFsi.js +0 -1027
  114. package/dist/template-review-jEcOfmGr.cjs +0 -1
  115. package/dist/validate-BDiMqkJC.cjs +0 -1
@@ -1 +0,0 @@
1
- "use strict";function y(e){if(!Number.isSafeInteger(e)||e<0||e>1e3*2)throw new Error("十进制精度超出预算");return 10n**BigInt(e)}function M(e){if(e.coefficient.toString().length>1e3*2||e.scale>1e3*2)throw new Error("十进制结果超出精度预算");return e}function g(e){if(typeof e!="string"&&!(typeof e=="number"&&Number.isFinite(e)))throw new Error("十进制参数必须是有限数字或十进制文本");const r=String(e);if(r.length>1e3)throw new Error("十进制文本超出精度预算");const t=/^([+-]?)(\d+)(?:\.(\d*))?(?:[eE]([+-]?\d{1,4}))?$/.exec(r);if(!t)throw new Error("无效十进制文本");const n=t[3]??"",l=Number(t[4]??0),o=n.length-l,i=BigInt(`${t[1]==="-"?"-":""}${t[2]}${n}`);return M(o<0?{coefficient:i*y(-o),scale:0}:{coefficient:i,scale:o})}function L(e,r){const t=Math.max(e.scale,r.scale);return[e.coefficient*y(t-e.scale),r.coefficient*y(t-r.scale),t]}function D(e,r){const[t,n]=L(e,r);return t<n?-1:t>n?1:0}function E(e,r){const[t,n,l]=L(e,r);return M({coefficient:t+n,scale:l})}function O(e,r){return M({coefficient:e.coefficient*r.coefficient,scale:e.scale+r.scale})}function J(e,r){const t=e/r,n=e%r,l=o=>o<0n?-o:o;return l(n)*2n<l(r)?t:t+(e<0n==r<0n?1n:-1n)}function b(e){if(!Number.isInteger(e)||e<0||e>100)throw new Error("十进制小数位应为 0–100 的整数")}function F(e,r,t=20){if(b(t),r.coefficient===0n)throw new Error("不能除以零");const n=r.scale-e.scale+t,l=e.coefficient*y(Math.max(0,n)),o=r.coefficient*y(Math.max(0,-n));return M({coefficient:J(l,o),scale:t})}function x(e,r){let t=e.coefficient,n=e.scale;r!==void 0&&(b(r),t=r>=n?t*y(r-n):J(t,y(n-r)),n=r);const l=t<0n,o=(l?-t:t).toString().padStart(n+1,"0");let i=n?o.slice(-n):"";return r===void 0&&(i=i.replace(/0+$/,"")),`${l?"-":""}${n?o.slice(0,-n):o}${i?`.${i}`:""}`}function K(e,r,t=!1,n=!1){let l=g(e);n&&(l=O(l,{coefficient:100n,scale:0}));const[o,i]=x(l,r).split(".");return`${t?o.replace(/\B(?=(\d{3})+(?!\d))/g,","):o}${i===void 0?"":`.${i}`}${n?"%":""}`}const Q=["sum","count","avg","min","max","weightedAvg"];function j(e){if(typeof e!="number"||!Number.isFinite(e))throw new Error("聚合度量必须是有限数字,不能隐式转换;小数文本请显式选择 decimal");return e}function S(e,r){return r&&Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0}function U(e){let r=0,t=0,n=0,l=0,o=1/0,i=-1/0;const a=c=>{const f=c-n,d=t+f;n=d-t-f,t=d};return{add(c){const f=S(c,e.field);if(e.op==="count"){(!e.field||f!=null)&&r++;return}if(f==null)return;const d=j(f),u=e.op==="weightedAvg"?S(c,e.weightField):1;if(u==null)return;const s=j(u);if(e.op==="weightedAvg"&&s<0)throw new Error("加权平均的权重不能为负数");["sum","avg","weightedAvg"].includes(e.op)&&a(d*s),l+=s,o=Math.min(o,d),i=Math.max(i,d),r++},value(){if(e.op==="count")return r;if(!r)return null;const c=e.op==="min"?o:e.op==="max"?i:e.op==="avg"?t/r:e.op==="weightedAvg"?l===0?null:t/l:t;if(c!==null&&!Number.isFinite(c))throw new Error("聚合计算溢出");return c}}}function V(e){let r=0,t=g("0"),n=g("0"),l,o;return{add(i){const a=S(i,e.field);if(e.op==="count"){(!e.field||a!=null)&&r++;return}if(a==null)return;const c=e.op==="weightedAvg"?S(i,e.weightField):"1";if(c==null)return;const f=g(a),d=g(c);if(e.op==="weightedAvg"&&d.coefficient<0n)throw new Error("加权平均的权重不能为负数");["sum","avg","weightedAvg"].includes(e.op)&&(t=E(t,O(f,d))),e.op==="weightedAvg"&&(n=E(n,d)),(!l||D(f,l)<0)&&(l=f),(!o||D(f,o)>0)&&(o=f),r++},value(){if(e.op==="count")return r;if(!r||e.op==="weightedAvg"&&n.coefficient===0n)return null;let i=e.op==="min"?l:e.op==="max"?o:t;return e.op==="avg"&&(i=F(t,g(r),e.digits)),e.op==="weightedAvg"&&(i=F(t,n,e.digits)),x(i,e.digits)}}}function $(e){if(e.digits!==void 0&&b(e.digits),e.numeric!==void 0&&e.numeric!=="number"&&e.numeric!=="decimal")throw new Error("未知聚合数值模式");if(!Q.includes(e.op))throw new Error("未知聚合操作");if(e.op!=="count"&&!e.field)throw new Error("聚合需要度量字段");if(e.op==="weightedAvg"&&!e.weightField)throw new Error("加权平均需要权重字段");return e.numeric==="decimal"?V(e):U(e)}function C(e,r){const t=$(r);for(const n of e)t.add(n);return t.value()}function A(e,r){return Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0}function B(e){if(e==null)return"null";if(typeof e!="string"&&typeof e!="boolean"&&!(typeof e=="number"&&Number.isFinite(e)))throw new Error("交叉表维度应为字符串、布尔、有限数字或空值");return JSON.stringify([typeof e,e])}function z(e){return e==null?"":String(e)}function v(e,r){const t=e??r;if(!Number.isInteger(t)||t<1)throw new Error("交叉表预算应为正整数");return t}function Y(e,r,t,n){const l=t?1:0;if((e+l)*(r+1+l)>n)throw new Error("交叉表输出单元格超出 maxCells 预算,请减少维度或服务端预聚合")}function P(e,r){if(!Array.isArray(e))throw new Error("交叉表数据应为对象数组");const t=r.aggregate??"sum";if(!["sum","count","avg","min","max","weightedAvg"].includes(t))throw new Error("未知交叉表聚合类型");if(!r.rowField||!r.columnField||t!=="count"&&!r.valueField)throw new Error("交叉表需要明确的行维度、列维度和度量字段");if(e.length>v(r.maxInputRows,1e5))throw new Error("交叉表输入超出预算,请在服务端预聚合");const n=v(r.maxRows,1e3),l=v(r.maxColumns,200),o=v(r.maxCells,2e6),i=()=>$({op:t,field:t==="count"&&r.countMode!=="nonNull"?void 0:r.valueField,weightField:r.weightField,numeric:r.numeric,digits:r.digits}),a=new Map,c=new Map,f=new Map,d=i();for(const s of e){const m=B(A(s,r.rowField)),w=B(A(s,r.columnField));if(a.has(w)||a.set(w,z(A(s,r.columnField))),c.has(m)||c.set(m,{label:z(A(s,r.rowField)),cells:new Map,total:i()}),a.size>l||c.size>n)throw new Error("交叉表维度数量超出预算");Y(c.size,a.size,r.totals,o);const h=c.get(m);h.cells.has(w)||h.cells.set(w,i()),f.has(w)||f.set(w,i());for(const k of[h.cells.get(w),h.total,f.get(w),d])k.add(s)}const u={columns:[{header:r.rowHeader??r.rowField,field:"rowLabel",semanticRole:"dimension"},...[...a.values()].map((s,m)=>({header:s,field:`c${m}`,semanticRole:"measure"}))],rows:[...c.values()].map(s=>({rowLabel:s.label,...Object.fromEntries([...a.keys()].map((m,w)=>[`c${w}`,s.cells.get(m)?.value()??(t==="count"?0:null)])),...r.totals?{total:s.total.value()}:{}}))};return r.totals&&(u.columns.push({header:"合计",field:"total",semanticRole:"measure"}),e.length&&u.rows.push({rowLabel:"合计",...Object.fromEntries([...a.keys()].map((s,m)=>[`c${m}`,f.get(s)?.value()??(t==="count"?0:null)])),total:d.value()})),u}const q=new Set(["__proto__","prototype","constructor"]);function p(e){if(typeof e!="string"||!e.trim()||q.has(e))throw new Error("计算字段应为安全的非空字段名")}function I(e){return e===null||["string","boolean"].includes(typeof e)||typeof e=="number"&&Number.isFinite(e)}function ee(e){if(e.some(r=>typeof r!="number"||!Number.isFinite(r)))throw new Error("算术参数必须是有限数字;空值和小数文本不会隐式转换");return e}function re(e,r){const t=ee(r);let n;if(e==="add")n=t.reduce((l,o)=>l+o,0);else if(e==="multiply")n=t.reduce((l,o)=>l*o,1);else if(e==="subtract")n=t[0]-t[1];else{if(t[1]===0)throw new Error("不能除以零");n=t[0]/t[1]}if(!Number.isFinite(n))throw new Error("计算结果不是有限数字");return n}function te(e,r,t){const n=r.map(g);let l;return e==="add"?l=n.reduce(E):e==="multiply"?l=n.reduce(O):e==="subtract"?l=E(n[0],{...n[1],coefficient:-n[1].coefficient}):l=F(n[0],n[1],t),x(l,t)}function ne(e,r,t){return t.nulls!=="error"&&r.some(n=>n==null)||e==="divide"&&t.divisionByZero==="null"&&(t.numeric==="decimal"?g(r[1]).coefficient===0n:r[1]===0)?null:t.numeric==="decimal"?te(e,r,t.digits):re(e,r)}function ie(e,r){e.field!==void 0&&p(e.field),e.weightField!==void 0&&p(e.weightField);const t={op:e.aggregate,field:e.field,weightField:e.weightField,numeric:r.numeric,digits:r.digits};C([],t);const n=new WeakMap;return l=>{let o=n.get(l.rows);if(!o){try{o={value:C(l.rows,t)}}catch(i){o={error:i instanceof Error?i:new Error(String(i))}}n.set(l.rows,o)}if(o.error)throw o.error;return o.value}}function oe(e,r){for(const t of e){const n=t(r);if(n!=null)return n}return null}function R(e,r={},t={nodes:0},n=0){if(++t.nodes>256||n>16)throw new Error("计算表达式超出深度或节点预算");if(!e||typeof e!="object"||Array.isArray(e))throw new Error("计算表达式应为声明式对象");if("aggregate"in e)return ie(e,r);if("field"in e){p(e.field);const l=e.field;return({row:o})=>Object.prototype.hasOwnProperty.call(o,l)?o[l]:void 0}if("value"in e){if(!I(e.value))throw new Error("常量应为有限 JSON 标量");return()=>e.value}return le(e,r,t,n)}function le(e,r,t,n){if(!["add","subtract","multiply","divide","coalesce"].includes(e.op)||!Array.isArray(e.args))throw new Error("未知计算操作");if(e.args.length>256||Object.keys(e.args).length!==e.args.length)throw new Error("计算参数超出预算或包含空位");if(e.args.length<2||["subtract","divide"].includes(e.op)&&e.args.length!==2)throw new Error("运算参数数量不正确");const l=e.args.map(o=>R(o,r,t,n+1));return e.op==="coalesce"?o=>oe(l,o):o=>ne(e.op,l.map(i=>i(o)),r)}function ce(e){R(e);const r=new Set,t=n=>{"field"in n&&n.field&&r.add(n.field),"aggregate"in n&&n.weightField&&r.add(n.weightField),"args"in n&&n.args.forEach(t)};return t(e),[...r]}function ae(e){if(p(e.field),e.scope!==void 0&&!["row","group","dataset"].includes(e.scope))throw new Error("未知计算范围");if(e.numeric!==void 0&&e.numeric!=="number"&&e.numeric!=="decimal")throw new Error("未知数值模式");if(e.digits!==void 0&&b(e.digits),e.nulls!==void 0&&e.nulls!=="propagate"&&e.nulls!=="error")throw new Error("未知空值规则");if(e.divisionByZero!==void 0&&e.divisionByZero!=="null"&&e.divisionByZero!=="error")throw new Error("未知除零规则");if(e.scope==="group"&&(!Array.isArray(e.groupBy)||!e.groupBy.length))throw new Error("分组计算需要 groupBy 字段");ue(e)}function ue(e){if(e.groupBy!==void 0){if(!Array.isArray(e.groupBy)||e.groupBy.length>16)throw new Error("计算分组最多 16 级");e.groupBy.forEach(p)}if(e.dependsOn!==void 0){if(!Array.isArray(e.dependsOn)||e.dependsOn.length>2048)throw new Error("计算依赖超出预算");e.dependsOn.forEach(p)}}function G(e){return[...new Set([...typeof e.expression=="string"?e.dependsOn??[]:ce(e.expression),...e.groupBy??[]])]}function W(e){if(!Array.isArray(e)||e.length>2048)throw new Error("计算字段应为数组且最多2048项");const r=new Map;for(const i of e){if(ae(i),r.has(i.field))throw new Error(`计算字段重复:${i.field}`);r.set(i.field,i)}const t=new Set,n=new Set,l=[];function o(i){if(!n.has(i.field)){if(t.has(i.field))throw new Error(`计算字段存在循环依赖:${[...t,i.field].join(" → ")}`);t.add(i.field);for(const a of G(i)){const c=r.get(a);c&&o(c)}t.delete(i.field),n.add(i.field),l.push(i)}}return e.forEach(o),l}function se(e){try{const r=W(e);return{valid:!0,errors:[],order:r.map(t=>t.field),fields:e.map(t=>({field:t.field,dependencies:G(t),scope:t.scope??"row"}))}}catch(r){return{valid:!1,errors:[r instanceof Error?r.message:String(r)],fields:[],order:[]}}}function fe(e=[]){return{fields:e.map(r=>({...r})),functions:[{name:"add",minArgs:2,maxArgs:256,input:"numeric",output:"numeric"},{name:"subtract",minArgs:2,maxArgs:2,input:"numeric",output:"numeric"},{name:"multiply",minArgs:2,maxArgs:256,input:"numeric",output:"numeric"},{name:"divide",minArgs:2,maxArgs:2,input:"numeric",output:"numeric"},{name:"coalesce",minArgs:2,maxArgs:256,input:"scalar",output:"scalar"}],operations:["add","subtract","multiply","divide","coalesce"],aggregates:["sum","count","avg","min","max","weightedAvg"],scopes:["row","group","dataset"],numericModes:["number","decimal"],rules:{nulls:"propagate",aggregateNulls:"skip",emptyAggregate:null,countEmpty:0,divisionByZero:"error",decimalOutput:"string",rounding:"half-away-from-zero"}}}function me(e){return W(e.fields).map(r=>{if(typeof r.expression!="string")return{definition:r,read:R(r.expression,r)};if(!e.formula)throw new Error("字符串公式需要显式配置 formula adapter");const t=r.expression;return{definition:r,read:n=>e.formula.evaluate(t,n)}})}function de(e,r){return JSON.stringify(r.map(t=>{const n=Object.prototype.hasOwnProperty.call(e,t)?e[t]:null;if(n!=null&&!I(n))throw new Error("分组字段应为有限 JSON 标量");return[typeof n,n??null]}))}function we(e,r){if(r.scope==="dataset")return()=>e;if(r.scope!=="group"){const l=new WeakMap;return o=>{let i=l.get(o);return i||(i=[o],l.set(o,i)),i}}const t=new Map,n=new WeakMap;for(const l of e){const o=de(l,r.groupBy);n.set(l,o);const i=t.get(o);i?i.push(l):t.set(o,[l])}return l=>t.get(n.get(l))}function ge(e,r){const t=r.maxRows??1e5,n=r.maxCells??2e6;if(!Array.isArray(e)||!Number.isSafeInteger(t)||t<1||e.length>t)throw new Error("计算数据行数超出预算或输入不是数组");if(!Array.isArray(r.fields)||r.fields.length>2048)throw new Error("计算字段应为数组且最多2048项");if(!Number.isSafeInteger(n)||n<1||e.length*r.fields.length>n)throw new Error("计算单元格超出 maxCells 预算")}function _(e){if(e?.aborted){const r=new Error("数据计算已取消");throw r.name="AbortError",r}}function he(e,r,t,n,l,o){try{const i=e.read({row:r,rowIndex:t,rows:n});if(i!==void 0&&!I(i))throw new Error("计算结果应为有限 JSON 标量,异步公式请先在数据源中求值");r[e.definition.field]=i??null}catch(i){const a=i instanceof Error?i.message:String(i);if(l.onError!=="null")throw Object.assign(new Error(`第 ${t+1} 行 ${e.definition.field}:${a}`),{cause:i});r[e.definition.field]=null,o.push({rowIndex:t,field:e.definition.field,message:a})}}function ye(e,r){ge(e,r),_(r.signal);const t=me(r),n=[],l=e.map((o,i)=>{if(!o||typeof o!="object"||Array.isArray(o))throw new Error(`第 ${i+1} 行应为对象`);return{...o}});for(const o of t){const i=we(l,o.definition);l.forEach((a,c)=>{_(r.signal),he(o,a,c,i(a),r,n)})}return{rows:l,issues:n}}function N(e,r){const t=r.map(n=>Object.prototype.hasOwnProperty.call(e,n)?e[n]:null);if(t.some(n=>n!=null&&typeof n!="string"&&typeof n!="boolean"&&!(typeof n=="number"&&Number.isFinite(n))))throw new Error("矩阵维度必须是有限 JSON 标量");return{key:JSON.stringify(t.map(n=>[typeof n,n??null])),label:t.map(n=>n==null?"":String(n)).join(" / ")}}function pe(e){for(const r of["maxRows","maxColumns","maxInputRows","maxCells"])if(e[r]!==void 0&&(!Number.isSafeInteger(e[r])||e[r]<1))throw new Error("矩阵预算应为正安全整数");for(const r of["columnWidthMm","rowWidthMm"])if(e[r]!==void 0&&(!Number.isFinite(e[r])||e[r]<=0))throw new Error("矩阵列宽应为正数")}function X(e){if(!e||!Array.isArray(e.rowFields)||!Array.isArray(e.columnFields)||!Array.isArray(e.measures))throw new Error("矩阵需要行维度、列维度和度量数组");for(const t of[e.rowFields,e.columnFields])if(t.some(n=>typeof n!="string"||!n.trim())||new Set(t).size!==t.length)throw new Error("矩阵维度字段应非空且唯一");if(pe(e),!e.rowFields.length||!e.columnFields.length||e.rowFields.length>16||e.columnFields.length>16)throw new Error("矩阵需要 1–16 个行/列维度");if(!e.measures.length||e.measures.length>32)throw new Error("矩阵需要 1–32 个度量");if(e.measures.map(t=>{if(!t||typeof t!="object")throw new Error("矩阵度量应为对象");if($({...t,field:t.valueField??t.field}),t.label!==void 0&&typeof t.label!="string")throw new Error("矩阵度量标签应为字符串");return t.field}).some(t=>typeof t!="string"||!t.trim()))throw new Error("矩阵度量字段应非空")}function Z(e,r){if(X(r),!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const t=new Set,n=new Set;for(const i of e){if(!i||typeof i!="object"||Array.isArray(i))throw new Error("矩阵数据行应为对象");if(t.add(N(i,r.rowFields).key),n.add(N(i,r.columnFields).key),t.size>(r.maxRows??1e3)||n.size>(r.maxColumns??200))throw new Error("矩阵维度数量超出预算");if((t.size+ +!!r.totals)*((n.size+ +!!r.totals)*r.measures.length+1)>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算")}const l=t.size+ +(!!r.totals&&e.length>0),o=(n.size+ +!!r.totals)*r.measures.length+1;return{rowCount:l,columnCount:o,cells:l*o}}function T(e,r){let t=r;for(;e.some(n=>Object.prototype.hasOwnProperty.call(n,t));)t+="_";return t}function Ee(e,r){Z(e,r);const t=new Map,n=new Map,l=T(e,"__matrix_row"),o=T(e,"__matrix_column"),i=e.map(u=>{const s=N(u,r.rowFields),m=N(u,r.columnFields);return t.set(s.key,s.label),n.set(m.key,m.label),{...u,[l]:s.key,[o]:m.key}}),a=r.maxCells??2e6;if((t.size+ +!!r.totals)*((n.size+ +!!r.totals)*r.measures.length+1)>a)throw new Error("矩阵输出超出 maxCells 预算");const c=r.measures.map(u=>P(i,{rowField:l,columnField:o,valueField:u.valueField??u.field,aggregate:u.op,countMode:"nonNull",weightField:u.weightField,numeric:u.numeric,digits:u.digits,totals:r.totals,maxRows:r.maxRows,maxColumns:r.maxColumns,maxInputRows:r.maxInputRows,maxCells:a})),f=c[0].rows.map(u=>({rowLabel:t.get(String(u.rowLabel))??String(u.rowLabel)})),d=[{field:"rowLabel",header:r.rowHeader??r.rowFields.join(" / "),semanticRole:"dimension"}];for(let u=0;u<c.length;u++){const s=c[u],m=r.measures[u];for(const w of s.columns.slice(1)){const h=`${w.field}_${u}`;d.push({...w,field:h,...m.digits===void 0?{}:{format:{kind:"number",digits:m.digits}},header:`${n.get(w.header)??w.header} · ${m.label??`${m.field} (${m.op})`}`}),s.rows.forEach((k,H)=>{f[H][h]=k[w.field]})}}return{rows:f,columns:d}}exports.addDecimal=E;exports.aggregateRows=C;exports.compareDecimal=D;exports.computeDataset=ye;exports.createAggregateAccumulator=$;exports.createCrossTable=P;exports.createMatrixTable=Ee;exports.decimalDigits=b;exports.divideDecimal=F;exports.estimateMatrixTable=Z;exports.formatDecimal=K;exports.getComputationMetadata=fe;exports.multiplyDecimal=O;exports.parseDecimal=g;exports.printDecimal=x;exports.validateComputedFields=se;exports.validateMatrixOptions=X;
@@ -1,116 +0,0 @@
1
- class l extends Error {
2
- constructor(e) {
3
- super(e.map((i) => `${i.field}: ${i.message}`).join("; ")), this.issues = e, this.code = "params", this.name = "ReportParamValidationError";
4
- }
5
- }
6
- function c(t) {
7
- if (!/^\d{4}-\d{2}-\d{2}$/.test(t) || t.startsWith("0000-")) return !1;
8
- const e = /* @__PURE__ */ new Date(`${t}T00:00:00.000Z`);
9
- return Number.isFinite(e.getTime()) && e.toISOString().slice(0, 10) === t;
10
- }
11
- function h(t) {
12
- return /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(t) && Number.isFinite(Number(t));
13
- }
14
- function y(t, e) {
15
- if (t.type === "number" && !h(e)) return [["type", "应为有限数字"]];
16
- if (t.type === "date" && !c(e)) return [["type", "应为有效的 YYYY-MM-DD 日期"]];
17
- const i = [];
18
- t.type === "select" && t.options && !t.options.some((r) => r.value === e) && i.push(["option", "不在允许的选项中"]);
19
- const n = Array.from(e).length;
20
- t.minLength !== void 0 && n < t.minLength && i.push(["minLength", `至少 ${t.minLength} 个字符`]), t.maxLength !== void 0 && n > t.maxLength && i.push(["maxLength", `最多 ${t.maxLength} 个字符`]);
21
- const s = t.type === "number" ? Number(e) : e;
22
- return t.min !== void 0 && s < t.min && i.push(["minimum", `不能小于 ${t.min}`]), t.max !== void 0 && s > t.max && i.push(["maximum", `不能大于 ${t.max}`]), i;
23
- }
24
- function g(t) {
25
- const e = [];
26
- for (const s of ["min", "max"]) {
27
- const r = t[s];
28
- if (r === void 0) continue;
29
- (t.type === "date" ? typeof r == "string" && c(r) : t.type === "number" && typeof r == "number" && Number.isFinite(r)) || e.push(`${s} 应为 number 的有限数字边界或 date 的有效日期边界`);
30
- }
31
- const i = typeof t.min == "number" && typeof t.max == "number" && t.min > t.max, n = typeof t.min == "string" && typeof t.max == "string" && t.min > t.max;
32
- return (i || n) && e.push("最小边界不能大于最大边界"), [...e, ...f(t)];
33
- }
34
- function f(t) {
35
- const e = [];
36
- t.type === "number" && (t.minLength !== void 0 || t.maxLength !== void 0) && e.push("number 参数使用 min/max 而不是文本长度约束");
37
- for (const i of ["minLength", "maxLength"]) {
38
- const n = t[i];
39
- n !== void 0 && (!Number.isSafeInteger(n) || n < 0) && e.push(`${i} 应为非负整数`);
40
- }
41
- return typeof t.minLength == "number" && typeof t.maxLength == "number" && t.minLength > t.maxLength && e.push("最小长度不能大于最大长度"), e;
42
- }
43
- function b(t) {
44
- if (!Array.isArray(t)) return [{ code: "definition", field: "", path: "$.paramDefs", message: "参数定义应为数组" }];
45
- const e = /* @__PURE__ */ new Set();
46
- return t.flatMap((i, n) => {
47
- const s = i && typeof i.field == "string" ? i.field : "";
48
- return L(i, e).map((a) => ({ code: "definition", field: s, path: `$.paramDefs.${n}`, message: a }));
49
- });
50
- }
51
- function x(t) {
52
- return Array.isArray(t) && t.every((e) => !!e && typeof e == "object" && typeof e.value == "string" && typeof e.label == "string");
53
- }
54
- function v(t) {
55
- const e = [];
56
- return t.type !== void 0 && !["text", "number", "date", "select"].includes(t.type) && e.push("未知参数类型"), t.label !== void 0 && typeof t.label != "string" && e.push("参数标签应为字符串"), t.required !== void 0 && typeof t.required != "boolean" && e.push("required 应为布尔值"), t.defaultValue !== void 0 && typeof t.defaultValue != "string" && e.push("默认值应为字符串"), t.options !== void 0 && !x(t.options) && e.push("选项应为包含字符串 label/value 的数组"), e;
57
- }
58
- function L(t, e) {
59
- if (!t || typeof t != "object" || Array.isArray(t)) return ["参数定义项应为对象"];
60
- const i = v(t);
61
- return typeof t.field != "string" || !t.field.trim() || e.has(t.field) ? i.push("参数名应为非空且不重复的字符串") : e.add(t.field), i.length || (i.push(...g(t)), i.length) || (t.options && new Set(t.options.map((n) => n.value)).size !== t.options.length && i.push("选项值不能重复"), t.defaultValue !== void 0 && (t.required && !t.defaultValue.trim() ? i.push("必填参数的默认值不能为空") : t.defaultValue.trim() && i.push(...y(t, t.defaultValue).map(([, n]) => `默认值${n}`)))), i;
62
- }
63
- function $(t, e, i) {
64
- for (const [n, s] of Object.entries(t))
65
- (typeof s == "string" || typeof s == "number" && Number.isFinite(s)) && (Object.defineProperty(e, n, { value: String(s), writable: !0, enumerable: !0, configurable: !0 }), Object.defineProperty(i, n, { value: s, writable: !0, enumerable: !0, configurable: !0 }));
66
- }
67
- function d(t) {
68
- return t == null || typeof t == "string" && !t.trim();
69
- }
70
- function V(t, e = {}) {
71
- const i = /* @__PURE__ */ Object.create(null), n = /* @__PURE__ */ Object.create(null), s = b(t);
72
- if ((!e || typeof e != "object" || Array.isArray(e)) && s.push({ code: "type", field: "", path: "$.params", message: "参数应为对象" }), s.length) return { ok: !1, values: i, typedValues: n, issues: s };
73
- $(e, i, n);
74
- for (const r of t) {
75
- const a = Object.prototype.hasOwnProperty.call(e, r.field) && e[r.field] !== void 0 ? e[r.field] : r.defaultValue, u = (m, p) => s.push({ code: m, path: `$.params.${r.field}`, field: r.field, message: p });
76
- if (d(a)) {
77
- r.required && u("required", "此参数为必填项"), typeof a == "string" && (i[r.field] = a), delete n[r.field];
78
- continue;
79
- }
80
- if (typeof a != "string" && !(typeof a == "number" && Number.isFinite(a))) {
81
- u("type", "参数应为字符串或有限数字");
82
- continue;
83
- }
84
- const o = String(a);
85
- i[r.field] = o, y(r, o).forEach(([m, p]) => u(m, p)), n[r.field] = r.type === "number" && h(o) ? Number(o) : o;
86
- }
87
- return { ok: s.length === 0, values: i, typedValues: n, issues: s };
88
- }
89
- function w(t, e = {}) {
90
- const i = V(t, e);
91
- if (!i.ok) throw new l(i.issues);
92
- return i.values;
93
- }
94
- function j(t) {
95
- const e = { type: t.type === "number" ? "number" : "string", title: t.label ?? t.field };
96
- return t.type === "date" && (e.format = "date"), t.required && t.type !== "number" && (e.pattern = "\\S"), t.type === "select" && t.options && (e.enum = t.options.map((i) => i.value)), t.defaultValue !== void 0 && (t.type !== "number" || t.defaultValue.trim()) && (e.default = t.type === "number" ? Number(t.defaultValue) : t.defaultValue), t.minLength !== void 0 && (e.minLength = t.minLength), t.maxLength !== void 0 && (e.maxLength = t.maxLength), typeof t.min == "number" && (e.minimum = t.min), typeof t.max == "number" && (e.maximum = t.max), typeof t.min == "string" && (e["x-report-minimum"] = t.min), typeof t.max == "string" && (e["x-report-maximum"] = t.max), e;
97
- }
98
- function O(t) {
99
- const e = b(t);
100
- if (e.length) throw new l(e);
101
- return {
102
- $schema: "https://json-schema.org/draft/2020-12/schema",
103
- type: "object",
104
- properties: Object.fromEntries(t.map((i) => [i.field, j(i)])),
105
- required: t.filter((i) => i.required).map((i) => i.field),
106
- additionalProperties: !0
107
- };
108
- }
109
- export {
110
- l as R,
111
- w as a,
112
- V as b,
113
- c as i,
114
- O as r,
115
- b as v
116
- };
@@ -1 +0,0 @@
1
- "use strict";class l extends Error{constructor(e){super(e.map(i=>`${i.field}: ${i.message}`).join("; ")),this.issues=e,this.code="params",this.name="ReportParamValidationError"}}function c(t){if(!/^\d{4}-\d{2}-\d{2}$/.test(t)||t.startsWith("0000-"))return!1;const e=new Date(`${t}T00:00:00.000Z`);return Number.isFinite(e.getTime())&&e.toISOString().slice(0,10)===t}function y(t){return/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(t)&&Number.isFinite(Number(t))}function b(t,e){if(t.type==="number"&&!y(e))return[["type","应为有限数字"]];if(t.type==="date"&&!c(e))return[["type","应为有效的 YYYY-MM-DD 日期"]];const i=[];t.type==="select"&&t.options&&!t.options.some(n=>n.value===e)&&i.push(["option","不在允许的选项中"]);const r=Array.from(e).length;t.minLength!==void 0&&r<t.minLength&&i.push(["minLength",`至少 ${t.minLength} 个字符`]),t.maxLength!==void 0&&r>t.maxLength&&i.push(["maxLength",`最多 ${t.maxLength} 个字符`]);const s=t.type==="number"?Number(e):e;return t.min!==void 0&&s<t.min&&i.push(["minimum",`不能小于 ${t.min}`]),t.max!==void 0&&s>t.max&&i.push(["maximum",`不能大于 ${t.max}`]),i}function f(t){const e=[];for(const s of["min","max"]){const n=t[s];if(n===void 0)continue;(t.type==="date"?typeof n=="string"&&c(n):t.type==="number"&&typeof n=="number"&&Number.isFinite(n))||e.push(`${s} 应为 number 的有限数字边界或 date 的有效日期边界`)}const i=typeof t.min=="number"&&typeof t.max=="number"&&t.min>t.max,r=typeof t.min=="string"&&typeof t.max=="string"&&t.min>t.max;return(i||r)&&e.push("最小边界不能大于最大边界"),[...e,...x(t)]}function x(t){const e=[];t.type==="number"&&(t.minLength!==void 0||t.maxLength!==void 0)&&e.push("number 参数使用 min/max 而不是文本长度约束");for(const i of["minLength","maxLength"]){const r=t[i];r!==void 0&&(!Number.isSafeInteger(r)||r<0)&&e.push(`${i} 应为非负整数`)}return typeof t.minLength=="number"&&typeof t.maxLength=="number"&&t.minLength>t.maxLength&&e.push("最小长度不能大于最大长度"),e}function h(t){if(!Array.isArray(t))return[{code:"definition",field:"",path:"$.paramDefs",message:"参数定义应为数组"}];const e=new Set;return t.flatMap((i,r)=>{const s=i&&typeof i.field=="string"?i.field:"";return d(i,e).map(a=>({code:"definition",field:s,path:`$.paramDefs.${r}`,message:a}))})}function v(t){return Array.isArray(t)&&t.every(e=>!!e&&typeof e=="object"&&typeof e.value=="string"&&typeof e.label=="string")}function L(t){const e=[];return t.type!==void 0&&!["text","number","date","select"].includes(t.type)&&e.push("未知参数类型"),t.label!==void 0&&typeof t.label!="string"&&e.push("参数标签应为字符串"),t.required!==void 0&&typeof t.required!="boolean"&&e.push("required 应为布尔值"),t.defaultValue!==void 0&&typeof t.defaultValue!="string"&&e.push("默认值应为字符串"),t.options!==void 0&&!v(t.options)&&e.push("选项应为包含字符串 label/value 的数组"),e}function d(t,e){if(!t||typeof t!="object"||Array.isArray(t))return["参数定义项应为对象"];const i=L(t);return typeof t.field!="string"||!t.field.trim()||e.has(t.field)?i.push("参数名应为非空且不重复的字符串"):e.add(t.field),i.length||(i.push(...f(t)),i.length)||(t.options&&new Set(t.options.map(r=>r.value)).size!==t.options.length&&i.push("选项值不能重复"),t.defaultValue!==void 0&&(t.required&&!t.defaultValue.trim()?i.push("必填参数的默认值不能为空"):t.defaultValue.trim()&&i.push(...b(t,t.defaultValue).map(([,r])=>`默认值${r}`)))),i}function $(t,e,i){for(const[r,s]of Object.entries(t))(typeof s=="string"||typeof s=="number"&&Number.isFinite(s))&&(Object.defineProperty(e,r,{value:String(s),writable:!0,enumerable:!0,configurable:!0}),Object.defineProperty(i,r,{value:s,writable:!0,enumerable:!0,configurable:!0}))}function V(t){return t==null||typeof t=="string"&&!t.trim()}function g(t,e={}){const i=Object.create(null),r=Object.create(null),s=h(t);if((!e||typeof e!="object"||Array.isArray(e))&&s.push({code:"type",field:"",path:"$.params",message:"参数应为对象"}),s.length)return{ok:!1,values:i,typedValues:r,issues:s};$(e,i,r);for(const n of t){const a=Object.prototype.hasOwnProperty.call(e,n.field)&&e[n.field]!==void 0?e[n.field]:n.defaultValue,u=(m,p)=>s.push({code:m,path:`$.params.${n.field}`,field:n.field,message:p});if(V(a)){n.required&&u("required","此参数为必填项"),typeof a=="string"&&(i[n.field]=a),delete r[n.field];continue}if(typeof a!="string"&&!(typeof a=="number"&&Number.isFinite(a))){u("type","参数应为字符串或有限数字");continue}const o=String(a);i[n.field]=o,b(n,o).forEach(([m,p])=>u(m,p)),r[n.field]=n.type==="number"&&y(o)?Number(o):o}return{ok:s.length===0,values:i,typedValues:r,issues:s}}function P(t,e={}){const i=g(t,e);if(!i.ok)throw new l(i.issues);return i.values}function j(t){const e={type:t.type==="number"?"number":"string",title:t.label??t.field};return t.type==="date"&&(e.format="date"),t.required&&t.type!=="number"&&(e.pattern="\\S"),t.type==="select"&&t.options&&(e.enum=t.options.map(i=>i.value)),t.defaultValue!==void 0&&(t.type!=="number"||t.defaultValue.trim())&&(e.default=t.type==="number"?Number(t.defaultValue):t.defaultValue),t.minLength!==void 0&&(e.minLength=t.minLength),t.maxLength!==void 0&&(e.maxLength=t.maxLength),typeof t.min=="number"&&(e.minimum=t.min),typeof t.max=="number"&&(e.maximum=t.max),typeof t.min=="string"&&(e["x-report-minimum"]=t.min),typeof t.max=="string"&&(e["x-report-maximum"]=t.max),e}function N(t){const e=h(t);if(e.length)throw new l(e);return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",properties:Object.fromEntries(t.map(i=>[i.field,j(i)])),required:t.filter(i=>i.required).map(i=>i.field),additionalProperties:!0}}exports.ReportParamValidationError=l;exports.assertReportParams=P;exports.isReportDate=c;exports.reportParamsJsonSchema=N;exports.validateReportParamDefinitions=h;exports.validateReportParams=g;
@@ -1,25 +0,0 @@
1
- import { defineAsyncComponent as a, computed as s } from "vue";
2
- import { g as m } from "./report-params-B_VCihAh.js";
3
- const p = "mach-report/fetcher", l = "mach-report/pdf-exporter", R = "mach-report/config", h = "mach-report/controller", d = a(() => import("./ReportPreview-B5ZNEasW.js").then((r) => r.C)), _ = {
4
- install(r, e = {}) {
5
- let t = e.fetcher;
6
- if (!t && e.reports) {
7
- const o = e.reports;
8
- let n;
9
- t = async (c) => (n ??= import("@agile-team/mach-report").then(({ createReportSource: f }) => f(o)), (await n)(c)), t.getParamDefs = (c) => m(o, c);
10
- }
11
- t && r.provide(p, t), e.pdfExporter && r.provide(l, e.pdfExporter), r.provide(R, s(() => {
12
- if (e.pdfFontUrl === void 0) return e.config ?? null;
13
- const o = e.config ?? { defaults: {}, presets: {} };
14
- return { ...o, defaults: { ...o.defaults, pdfFontUrl: e.pdfFontUrl } };
15
- })), e.globalComponent !== !1 && !r.component("MachReportPreview") && r.component("MachReportPreview", d);
16
- }
17
- };
18
- export {
19
- d as M,
20
- h as a,
21
- R as b,
22
- p as c,
23
- l as d,
24
- _ as m
25
- };
@@ -1 +0,0 @@
1
- "use strict";var l=Object.create;var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var m=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of p(e))!h.call(r,c)&&c!==t&&n(r,c,{get:()=>e[c],enumerable:!(o=s(e,c))||o.enumerable});return r};var C=(r,e,t)=>(t=r!=null?l(d(r)):{},m(e||!r||!r.__esModule?n(t,"default",{value:r,enumerable:!0}):t,r));const E=require("vue"),O=require("./report-params-CjWrjPl6.cjs"),_="mach-report/fetcher",f="mach-report/pdf-exporter",P="mach-report/config",u="mach-report/controller",a=E.defineAsyncComponent(()=>Promise.resolve().then(()=>require("./ReportPreview-DRtVPUYo.cjs")).then(r=>r.ReportPreview$1)),T={install(r,e={}){let t=e.fetcher;if(!t&&e.reports){const o=e.reports;let c;t=async R=>(c??=import("@agile-team/mach-report").then(({createReportSource:i})=>i(o)),(await c)(R)),t.getParamDefs=R=>O.getReportParamDefs(o,R)}t&&r.provide(_,t),e.pdfExporter&&r.provide(f,e.pdfExporter),r.provide(P,E.computed(()=>{if(e.pdfFontUrl===void 0)return e.config??null;const o=e.config??{defaults:{},presets:{}};return{...o,defaults:{...o.defaults,pdfFontUrl:e.pdfFontUrl}}})),e.globalComponent!==!1&&!r.component("MachReportPreview")&&r.component("MachReportPreview",a)}};exports.MACH_REPORT_CONFIG_KEY=P;exports.MACH_REPORT_CONTROLLER_KEY=u;exports.MACH_REPORT_FETCHER_KEY=_;exports.MACH_REPORT_PDF_EXPORTER_KEY=f;exports.MachReportPreview=a;exports.machReportPlugin=T;
@@ -1 +0,0 @@
1
- "use strict";const E=require("./matrix-Div9Ilh3.cjs"),I=require("./render-plan-7xpGrCEl.cjs"),v=require("./validate-BDiMqkJC.cjs"),x=require("./param-validation-CiTxFeZ8.cjs");function L(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function S(e,i,t){if(e!==void 0){if(!L(e)){t.push({path:i,message:"条件应为对象"});return}(typeof e.field!="string"||!e.field.trim())&&t.push({path:`${i}.field`,message:"条件需要字段"}),e.numeric!==void 0&&e.numeric!=="number"&&e.numeric!=="decimal"&&t.push({path:`${i}.numeric`,message:"未知条件数值模式"}),[">",">=","<","<=","==","!="].includes(e.op)||t.push({path:`${i}.op`,message:"未知条件运算符"}),typeof e.value!="string"&&!(typeof e.value=="number"&&Number.isFinite(e.value))&&t.push({path:`${i}.value`,message:"条件值应为字符串或有限数字"})}}function _(e,i,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>2048){t.push({path:i,message:"聚合应为数组且最多 2048 项"});return}const s=new Set;e.forEach((n,a)=>{const f=`${i}.${a}`;if(!L(n)){t.push({path:f,message:"聚合应为对象"});return}const o=n.field;typeof o!="string"||!o.trim()||s.has(o)?t.push({path:`${f}.field`,message:"聚合输出字段应非空且唯一"}):s.add(o),n.numeric!==void 0&&n.numeric!=="number"&&n.numeric!=="decimal"&&t.push({path:`${f}.numeric`,message:"数值模式应为 number 或 decimal"}),n.digits!==void 0&&(!Number.isInteger(n.digits)||Number(n.digits)<0||Number(n.digits)>100)&&t.push({path:`${f}.digits`,message:"小数位应为 0–100 的整数"});try{E.createAggregateAccumulator({...n,field:n.valueField??o})}catch(m){t.push({path:f,message:m instanceof Error?m.message:String(m)})}})}function J(e,i,t){if(e===void 0)return;const s=E.validateComputedFields(e);for(const n of s.errors)t.push({path:i,message:n})}function F(e,i,t){if(e!==void 0)try{E.validateMatrixOptions(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}const k="1.0";class $ extends Error{constructor(i){super(`模板校验失败:${i.slice(0,3).map(t=>`${t.path}: ${t.message}`).join("; ")}`),this.errors=i,this.name="ReportTemplateError"}}const j=new Set(["__proto__","prototype","constructor"]),H=new Set(["schemaVersion","id","name","revision","description","template"]),U=new Set(["left","center","right","justify"]),M=2e5,W=64,R=1e7;function u(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function K(e,i,t){const s=Object.getPrototypeOf(e),n=Array.isArray(e);if(n?s!==Array.prototype:s!==Object.prototype&&s!==null)return t.push({path:i,message:"模板对象必须使用普通 JSON 对象原型"}),!1;if(n){const a=Object.keys(e);if(a.length!==e.length||a.some(f=>!/^(0|[1-9]\d*)$/.test(f)||Number(f)>=e.length))return t.push({path:i,message:"模板数组不能包含空位或额外属性"}),!1}return Object.getOwnPropertySymbols(e).length>0?(t.push({path:i,message:"模板不能包含 Symbol 键"}),!1):!0}function G(e,i,t,s){return j.has(e)?(s.push({path:t,message:"模板不能包含可能污染原型的键"}),!1):i.get||i.set||!i.enumerable?(s.push({path:t,message:"模板不能包含访问器或不可枚举字段"}),!1):!0}function Y(e){return e===null||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function O(e,i){const t=new Set;let s=0,n=0,a=!1;const f=(o,m,h)=>{if(!a){if(++s>M){s===M+1&&i.push({path:m,message:"模板超过 JSON 节点安全上限"});return}if(h>W){i.push({path:m,message:"模板嵌套层级过深"});return}if(typeof o=="string"){n+=o.length,n>R&&(a=!0,i.push({path:m,message:"模板文本超过 1000 万字符的安全上限"}));return}if(!Y(o)){if(!o||typeof o!="object"){i.push({path:m,message:"模板只允许 JSON 值,不允许函数、undefined 或非有限数字"});return}if(t.has(o)){i.push({path:m,message:"模板不能包含循环引用"});return}if(K(o,m,i)){t.add(o);for(const[g,l]of Object.entries(Object.getOwnPropertyDescriptors(o))){if(Array.isArray(o)&&g==="length")continue;const y=`${m}.${g}`;if(G(g,l,y,i)&&f(l.value,y,h+1),s>M||a)break}t.delete(o)}}}};f(e,"$",0)}function r(e,i,t,s,n=!1){const a=e[i];a===void 0&&!n||(typeof a!="string"||n&&!a.trim())&&s.push({path:`${t}.${i}`,message:n?"应为非空字符串":"应为字符串"})}function d(e,i,t,s,n=0,a=!1){const f=e[i];f===void 0&&!a||(typeof f!="number"||!Number.isFinite(f)||f<n)&&s.push({path:`${t}.${i}`,message:`应为大于等于 ${n} 的有限数字`})}function p(e,i,t,s){e[i]!==void 0&&typeof e[i]!="boolean"&&s.push({path:`${t}.${i}`,message:"应为布尔值"})}function b(e,i,t,s=!1){e!==void 0&&!U.has(e)&&!(s&&e==="auto")&&t.push({path:i,message:`未知对齐方式${s?"(支持 auto)":""}`})}function c(e,i,t){if(e!==void 0){if(!u(e)){t.push({path:i,message:"样式应为对象"});return}b(e.align,`${i}.align`,t),e.verticalAlign!==void 0&&!["top","middle","bottom"].includes(e.verticalAlign)&&t.push({path:`${i}.verticalAlign`,message:"未知垂直对齐方式"});for(const s of["fontSize","fontSizePx","lineWidthPt","lineHeight"])d(e,s,i,t);for(const s of["letterSpacing","rotateDeg"])d(e,s,i,t,-1/0);d(e,"opacity",i,t),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于 1"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])p(e,s,i,t);for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])r(e,s,i,t)}}function z(e,i,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({path:i,message:"参数定义应为数组"});return}const s=new Set,n=t.length;e.forEach((a,f)=>{const o=`${i}.${f}`;if(!u(a)){t.push({path:o,message:"参数定义应为对象"});return}r(a,"field",o,t,!0),typeof a.field=="string"&&(s.has(a.field)&&t.push({path:`${o}.field`,message:"参数名重复"}),s.add(a.field)),a.type!==void 0&&!["text","number","date","select"].includes(a.type)&&t.push({path:`${o}.type`,message:"未知参数类型"});for(const m of["label","defaultValue","placeholder"])r(a,m,o,t);p(a,"required",o,t);for(const m of["minLength","maxLength"]){const h=a[m];h!==void 0&&(typeof h!="number"||!Number.isSafeInteger(h)||h<0)&&t.push({path:`${o}.${m}`,message:"长度边界应为非负整数"})}q(a,o,t),a.options!==void 0&&(Array.isArray(a.options)?a.options.forEach((m,h)=>{const g=`${o}.options.${h}`;if(!u(m))t.push({path:g,message:"选项应为对象"});else for(const l of["label","value"])typeof m[l]!="string"&&t.push({path:`${g}.${l}`,message:"选项标签与值应为字符串(允许空白选项)"})}):t.push({path:`${o}.options`,message:"选项应为数组"}))}),t.length===n&&t.push(...x.validateReportParamDefinitions(e).map(a=>({path:a.path.replace("$.paramDefs",i),message:a.message})))}function q(e,i,t){for(const a of["min","max"]){const f=e[a];if(f===void 0)continue;(e.type==="date"?typeof f=="string"&&x.isReportDate(f):e.type==="number"&&typeof f=="number"&&Number.isFinite(f))||t.push({path:`${i}.${a}`,message:"number 使用有限数字边界,date 使用有效 YYYY-MM-DD 日期边界"})}const s=typeof e.min=="number"&&typeof e.max=="number"&&e.min>e.max,n=typeof e.min=="string"&&typeof e.max=="string"&&e.min>e.max;(s||n)&&t.push({path:i,message:"最小边界不能大于最大边界"}),typeof e.minLength=="number"&&typeof e.maxLength=="number"&&e.minLength>e.maxLength&&t.push({path:i,message:"最小长度不能大于最大长度"})}function P(e,i,t){if(!Array.isArray(e)||e.length===0){t.push({path:i,message:"列表至少需要一列"});return}e.every(s=>u(s)&&s.hidden===!0)&&t.push({path:i,message:"列表至少需要一列可见列"}),e.forEach((s,n)=>{const a=`${i}.${n}`;if(!u(s)){t.push({path:a,message:"列应为对象"});return}if(v.validateEditableMetadata(s,a,t),p(s,"hidden",a,t),S(s.visibleWhen,`${a}.visibleWhen`,t),typeof s.header!="string"&&t.push({path:`${a}.header`,message:"表头应为字符串(允许空白表头)"}),r(s,"field",a,t,!0),d(s,"widthMm",a,t,Number.MIN_VALUE,!0),c(s.style,`${a}.style`,t),c(s.headerStyle,`${a}.headerStyle`,t),b(s.align,`${a}.align`,t,!0),b(s.headerAlign,`${a}.headerAlign`,t),s.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(s.semanticRole)&&t.push({path:`${a}.semanticRole`,message:"未知列语义"}),s.format!==void 0)if(!u(s.format)||!["number","percent","date"].includes(s.format.kind))t.push({path:`${a}.format`,message:"未知列格式"});else{const f=s.format.digits;f!==void 0&&(typeof f!="number"||!Number.isInteger(f)||f<0||f>100)&&t.push({path:`${a}.format.digits`,message:"小数位应为 0–100 的整数"}),p(s.format,"thousands",`${a}.format`,t),r(s.format,"pattern",`${a}.format`,t)}s.rules!==void 0&&(Array.isArray(s.rules)?s.rules.forEach((f,o)=>{const m=`${a}.rules.${o}`;if(!u(f)||!u(f.when)){t.push({path:m,message:"条件格式缺少 when 对象"});return}S(f.when,`${m}.when`,t),r(f.when,"field",`${m}.when`,t,!0),[">",">=","<","<=","==","!="].includes(f.when.op)||t.push({path:`${m}.when.op`,message:"未知条件运算符"}),typeof f.when.value!="number"&&typeof f.when.value!="string"&&t.push({path:`${m}.when.value`,message:"条件值应为数字或字符串"}),c(f.style,`${m}.style`,t)}):t.push({path:`${a}.rules`,message:"条件格式应为数组"}))})}function V(e,i,t){if(e!==void 0){if(!u(e)){t.push({path:i,message:"分组应为对象"});return}r(e,"field",i,t,!0);for(const s of["headerTemplate","subtotalLabel"])r(e,s,i,t);for(const s of["headerStyle","subtotalStyle"])c(e[s],`${i}.${s}`,t);p(e,"keepWithNext",i,t),p(e,"repeatHeader",i,t),_(e.aggregates,`${i}.aggregates`,t),e.subtotal!==void 0&&(!Array.isArray(e.subtotal)||e.subtotal.some(s=>typeof s!="string"))&&t.push({path:`${i}.subtotal`,message:"小计字段应为字符串数组"})}}function X(e,i,t){if(!(e===void 0||typeof e=="boolean")){if(!u(e)){t.push({path:i,message:"合计应为布尔值或对象"});return}r(e,"label",i,t),_(e.aggregates,`${i}.aggregates`,t),c(e.style,`${i}.style`,t),e.fields!==void 0&&(!Array.isArray(e.fields)||e.fields.some(s=>typeof s!="string"))&&t.push({path:`${i}.fields`,message:"合计字段应为字符串数组"})}}function B(e,i,t,s){const n={kind:"rect",leftMm:0,topMm:0,widthMm:1,heightMm:1,grid:e};if(v.validateComponent(n,t,s,[]),T(n,t,s),!u(e)||!Array.isArray(e.cells))return;const a=e.cells,f=Array.isArray(i)?i.length:0;if(a.length*f>M){s.push({path:t,message:"表头逻辑网格超过 20 万格安全上限"});return}e.cells.length||s.push({path:`${t}.cells`,message:"表头至少需要一行"}),Array.isArray(e.colWidthsMm)&&e.colWidthsMm.length!==f&&s.push({path:`${t}.colWidthsMm`,message:"表头列宽数量应与列表列数一致"}),Array.isArray(e.rowHeightsMm)&&e.rowHeightsMm.length!==e.cells.length&&s.push({path:`${t}.rowHeightsMm`,message:"表头行高数量应与行数一致"}),Q(a,f,t,s)}function Q(e,i,t,s){const n=new Set;e.forEach((a,f)=>{if(!Array.isArray(a))return;let o=0;a.forEach((m,h)=>{for(;n.has(`${f}:${o}`);)o++;const g=u(m)&&typeof m.colSpan=="number"?m.colSpan:1,l=u(m)&&typeof m.rowSpan=="number"?m.rowSpan:1;(o+g>i||f+l>e.length)&&s.push({path:`${t}.cells.${f}.${h}`,message:"表头合并区域超出表头边界"});for(let y=f;y<Math.min(e.length,f+l);y++)for(let A=o;A<Math.min(i,o+g);A++)n.has(`${y}:${A}`)&&s.push({path:`${t}.cells.${f}.${h}`,message:"表头合并区域重叠"}),n.add(`${y}:${A}`);o+=g})})}function Z(e,i,t){if(J(e.computed,`${i}.computed`,t),F(e.matrix,`${i}.matrix`,t),e.matrix&&(e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.grandTotal)&&t.push({path:`${i}.matrix`,message:"矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细"}),S(e.rowVisibleWhen,`${i}.rowVisibleWhen`,t),e.groups!==void 0&&(!Array.isArray(e.groups)||e.groups.length>16?t.push({path:`${i}.groups`,message:"分组应为数组,最多 16 级"}):e.groups.forEach((a,f)=>V(a,`${i}.groups.${f}`,t))),e.detail===void 0)return;const s=e.detail,n=`${i}.detail`;if(!u(s)){t.push({path:n,message:"主从关联应为对象"});return}for(const a of["dataset","parentKey","foreignKey"])r(s,a,n,t,!0);r(s,"rowKey",n,t,s.rowKey!==void 0),r(s,"label",n,t),p(s,"header",n,t),d(s,"rowHeightMm",n,t,Number.MIN_VALUE),P(s.columns,`${n}.columns`,t),s.unmatched!==void 0&&s.unmatched!=="error"&&s.unmatched!=="ignore"&&t.push({path:`${n}.unmatched`,message:"未关联明细策略应为 error 或 ignore"})}function ee(e,i,t){for(const s of["leftMm","topMm"])d(e,s,i,t,-1/0,!0);d(e,"widthMm",i,t,Number.MIN_VALUE,!0),r(e,"dataset",i,t,!0),r(e,"title",i,t);for(const s of["rowKey","revisionField","sourceTokenField"])r(e,s,i,t,e[s]!==void 0);e.headerGrid!==void 0&&B(e.headerGrid,e.columns,`${i}.headerGrid`,t),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"}),P(e.columns,`${i}.columns`,t);for(const s of["fontSizePt","rowHeightMm"])d(e,s,i,t,Number.MIN_VALUE);d(e,"paddingMm",i,t);for(const s of["headerBold","headerEveryPage","border"])p(e,s,i,t);r(e,"headerBackgroundColor",i,t),b(e.align,`${i}.align`,t,!0),b(e.headerAlign,`${i}.headerAlign`,t),c(e.headerStyle,`${i}.headerStyle`,t),Z(e,i,t),V(e.groupBy,`${i}.groupBy`,t),X(e.grandTotal,`${i}.grandTotal`,t)}function T(e,i,t){c(e.style,`${i}.style`,t);for(const n of["text","rawText","imageData","fallbackText","nid","rkey"])r(e,n,i,t);if(e.lines!==void 0&&(!Array.isArray(e.lines)||e.lines.some(n=>typeof n!="string"))&&t.push({path:`${i}.lines`,message:"文本行应为字符串数组"}),Array.isArray(e.richParagraphs)&&e.richParagraphs.forEach((n,a)=>{if(!u(n))return;const f=`${i}.richParagraphs.${a}`;b(n.align,`${f}.align`,t);for(const o of["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"])d(n,o,f,t);Array.isArray(n.segments)&&n.segments.forEach((o,m)=>{const h=`${f}.segments.${m}`;if(!u(o)){t.push({path:h,message:"富文本片段应为对象"});return}o.kind!==void 0&&o.kind!=="text"&&o.kind!=="field"&&t.push({path:`${h}.kind`,message:"未知富文本片段类型"});for(const g of["text","field"])r(o,g,h,t);c(o.style,`${h}.style`,t)})}),!u(e.grid))return;const s=e.grid;d(s,"gapMm",`${i}.grid`,t),d(s,"paddingMm",`${i}.grid`,t);for(const n of["colWidthsMm","rowHeightsMm"]){const a=s[n];a!==void 0&&(!Array.isArray(a)||a.some(f=>typeof f!="number"||!Number.isFinite(f)||f<0))&&t.push({path:`${i}.grid.${n}`,message:"网格尺寸应为有限非负数字数组"})}Array.isArray(s.cells)&&s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((f,o)=>{const m=`${i}.grid.cells.${a}.${o}`;if(f!==null){if(!u(f)){t.push({path:m,message:"网格单元格应为对象或 null"});return}for(const h of["text","rawText","numberFormat"])r(f,h,m,t);for(const h of["colSpan","rowSpan"]){const g=f[h];g!==void 0&&(typeof g!="number"||!Number.isInteger(g)||g<=0)&&t.push({path:`${m}.${h}`,message:"跨度应为正整数"})}f.value!==void 0&&f.value!==null&&!["string","number","boolean"].includes(typeof f.value)&&t.push({path:`${m}.value`,message:"Excel 原始值应为字符串、数字、布尔值或 null"}),c(f.style,`${m}.style`,t),f.children!==void 0&&(Array.isArray(f.children)?f.children.forEach((h,g)=>{u(h)&&T(h,`${m}.children.${g}`,t)}):t.push({path:`${m}.children`,message:"嵌套组件应为数组"}))}})})}function D(e){const i=[],t=[];return O(e,i),i.length?{ok:!1,errors:i,warnings:t}:(u(e)?(e.schemaVersion!==void 0&&e.schemaVersion!==I.RENDER_PLAN_SCHEMA_VERSION&&i.push({path:"$.schemaVersion",message:"不支持的模板 schemaVersion"}),z(e.params,"$.params",i),!Array.isArray(e.pages)||e.pages.length===0?i.push({path:"$.pages",message:"模板至少需要一页"}):e.pages.forEach((s,n)=>{const a=`$.pages.${n}`;if(!u(s)){i.push({path:a,message:"页应为对象"});return}d(s,"widthMm",a,i,Number.MIN_VALUE,!0),d(s,"heightMm",a,i,Number.MIN_VALUE,!0),s.layout!==void 0&&s.layout!=="page"&&s.layout!=="wide"&&i.push({path:`${a}.layout`,message:"布局应为 page 或 wide"}),typeof s.heightMm=="number"&&s.heightMm>=5e3&&i.push({path:`${a}.heightMm`,message:"页高应小于 5000mm"});for(const f of["marginTopMm","marginBottomMm","marginLeftMm","marginRightMm"])d(s,f,a,i);typeof s.widthMm=="number"&&Number(s.marginLeftMm??0)+Number(s.marginRightMm??0)>=s.widthMm&&i.push({path:a,message:"横向页边距占满页面"}),typeof s.heightMm=="number"&&Number(s.marginTopMm??0)+Number(s.marginBottomMm??0)>=s.heightMm&&i.push({path:a,message:"纵向页边距占满页面"}),Array.isArray(s.components)?s.components.forEach((f,o)=>{const m=`${a}.components.${o}`;u(f)&&f.kind==="list"?ee(f,m,i):(v.validateComponent(f,m,i,t),u(f)&&T(f,m,i))}):i.push({path:`${a}.components`,message:"组件应为数组"})})):i.push({path:"$",message:"模板应为对象"}),{ok:i.length===0,errors:i,warnings:t})}function C(e){const i=[],t=[];if(O(e,i),i.length)return{ok:!1,errors:i,warnings:t};if(!u(e))i.push({path:"$",message:"模板文档应为对象"});else{for(const n of Object.keys(e))H.has(n)||i.push({path:`$.${n}`,message:"模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据"});e.schemaVersion!==k&&i.push({path:"$.schemaVersion",message:"不支持的模板文档版本"});for(const n of["id","name"])r(e,n,"$",i,!0);for(const n of["revision","description"])r(e,n,"$",i);const s=D(e.template);i.push(...s.errors.map(n=>({...n,path:`$.template${n.path.slice(1)}`}))),t.push(...s.warnings.map(n=>({...n,path:`$.template${n.path.slice(1)}`})))}return{ok:i.length===0,errors:i,warnings:t}}function N(e){const i=C(e);if(!i.ok)throw new $(i.errors)}function te(e){const i=[];if(O(e,i),i.length)throw new $(i);const t={...e,schemaVersion:e.schemaVersion??k};return N(t),w(t)}function ie(e){let i=e;if(typeof e=="string"){if(e.length>R)throw new $([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);try{i=JSON.parse(e)}catch{throw new $([{path:"$",message:"模板 JSON 语法无效"}])}}return N(i),w(i)}function se(e){N(e);const i=JSON.stringify(e,null,2);if(i.length>R)throw new $([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);return i}function w(e){return JSON.parse(JSON.stringify(e))}function ne(e=[]){const i=new Map,t={get:s=>{const n=i.get(s);return n?w(n):void 0},list:()=>Array.from(i.values(),({template:s,...n})=>({...n})),register:(s,n={})=>{if(N(s),i.has(s.id)&&!n.replace)throw new $([{path:"$.id",message:`模板 ID ${s.id} 已注册;更新需显式 replace:true`}]);i.set(s.id,w(s))},remove:s=>i.delete(s)};for(const s of e)t.register(s);return t}exports.REPORT_TEMPLATE_DOCUMENT_VERSION=k;exports.ReportTemplateError=$;exports.createTemplateRegistry=ne;exports.defineReportTemplate=te;exports.parseReportTemplate=ie;exports.serializeReportTemplate=se;exports.validateReportTemplate=D;exports.validateReportTemplateDocument=C;