@agile-team/mach-report 2.16.0 → 2.18.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.
- package/README.md +25 -12
- package/dist/{ExcelBindingWizard-CP6h2x1f.cjs → ExcelBindingWizard-Czn3C2yE.cjs} +1 -1
- package/dist/{ExcelBindingWizard-HhB3hAJE.js → ExcelBindingWizard-DMGZj6I6.js} +3 -3
- package/dist/ParamEditor-KzDQvbHY.js +732 -0
- package/dist/ParamEditor-oDfD8LgE.cjs +1 -0
- package/dist/{ReportBatchPanel-ruxcbfY6.js → ReportBatchPanel-BJK7PvZ4.js} +39 -39
- package/dist/ReportBatchPanel-DnmNRssu.cjs +1 -0
- package/dist/ReportParamPanel-mQkeN70Q.js +1020 -0
- package/dist/ReportParamPanel-sOANVRz-.cjs +1 -0
- package/dist/ReportPreview-BxWWTUL5.js +5583 -0
- package/dist/ReportPreview-Yf99omi3.cjs +6 -0
- package/dist/{ReportTemplateLibrary-DcwrH-63.js → ReportTemplateLibrary-BFjB08Wu.js} +1 -1
- package/dist/{ReportTemplateLibrary-BDlNT8JN.cjs → ReportTemplateLibrary-BO42QnWd.cjs} +1 -1
- package/dist/RuleEditor-CqxT1a-W.js +2337 -0
- package/dist/RuleEditor-D7YWigD9.cjs +1 -0
- package/dist/{TemplateOutlinePanel-CGrT5DFN.cjs → TemplateOutlinePanel-B0XX350V.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-SXCjaPKR.js → TemplateOutlinePanel-zG0DrsIB.js} +2 -2
- package/dist/{TemplateReusePanel-6Z3wRFz8.cjs → TemplateReusePanel-BD0HSKp_.cjs} +1 -1
- package/dist/{TemplateReusePanel-lHLOS9Wn.js → TemplateReusePanel-Czwe5GbC.js} +2 -2
- package/dist/{TemplateReviewPanel-Dpk7sLcF.cjs → TemplateReviewPanel-CA5sdffM.cjs} +1 -1
- package/dist/{TemplateReviewPanel-CJ9PLc48.js → TemplateReviewPanel-NhmQI65C.js} +2 -2
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +163 -42
- package/dist/analytics.d.ts +163 -42
- package/dist/analytics.js +76 -141
- package/dist/artifact-integrity.json +110 -108
- package/dist/assets-2eC3mOcV.js +232 -0
- package/dist/assets-B0Hxn4l6.cjs +1 -0
- package/dist/{auto-uVBjX1j5.cjs → auto-B0EZFIK1.cjs} +1 -1
- package/dist/{auto-YR7a4BtF.js → auto-BlchZ1b8.js} +10 -10
- package/dist/{batch-WzDIXJAt.js → batch-DGCt44XM.js} +1 -1
- package/dist/{batch-z6Aw5GEY.cjs → batch-DYcokH4v.cjs} +1 -1
- package/dist/charts-Dlv8j2AG.js +141 -0
- package/dist/charts-aCtoswXq.cjs +1 -0
- package/dist/codes.cjs +9 -9
- package/dist/codes.d.cts +54 -0
- package/dist/codes.d.ts +54 -0
- package/dist/codes.js +12097 -13668
- package/dist/column-visual-BpgQVWwT.js +238 -0
- package/dist/column-visual-CtYxnBCP.cjs +1 -0
- package/dist/component-tree-6TV7W6Yj.cjs +1 -0
- package/dist/component-tree-CvW4lzpv.js +67 -0
- package/dist/computed-4TnxzgIh.cjs +1 -0
- package/dist/computed-C8NRZQss.js +739 -0
- package/dist/data-bar-Ce38juRZ.cjs +1 -0
- package/dist/data-bar-PtjXhMgN.js +9 -0
- package/dist/dataset-DL83majE.js +161 -0
- package/dist/dataset-IrlXbUvh.cjs +1 -0
- package/dist/designer--TKECSEc.cjs +2 -0
- package/dist/designer-d6hJS41w.js +5683 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +835 -45
- package/dist/designer.d.ts +835 -45
- package/dist/designer.js +23 -20
- package/dist/{encoding-BYF9ZTl9.cjs → encoding-B--eZpp1.cjs} +1 -1
- package/dist/{encoding-BOGq4qYL.js → encoding-mctOLocI.js} +2 -2
- package/dist/{font-loader-EKLzOJxf.cjs → font-loader-DBBJ5KE9.cjs} +1 -1
- package/dist/{font-loader-CzI1GuBc.js → font-loader-DW8tIaNp.js} +1 -1
- package/dist/index-CPh6tqge.js +1575 -0
- package/dist/index-CUNw7dL9.cjs +1 -0
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +534 -16
- package/dist/index.d.ts +534 -16
- package/dist/index.js +1393 -955
- package/dist/json-snapshot-By4ZVVUt.js +1967 -0
- package/dist/json-snapshot-jiXff4lc.cjs +2 -0
- package/dist/matrix-0hywp0-F.cjs +1 -0
- package/dist/matrix-Dy-tyY7E.js +381 -0
- package/dist/param-validation-C-8sRJLq.cjs +1 -0
- package/dist/param-validation-CnDEd2l-.js +333 -0
- package/dist/{pdf-DJ5S6ukC.js → pdf-CKROKygt.js} +1845 -1845
- package/dist/{pdf-ByVCb1i6.cjs → pdf-DqyxJ96U.cjs} +47 -47
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +66 -0
- package/dist/pdf.d.ts +66 -0
- package/dist/pdf.js +2 -2
- package/dist/{plugin-C2j5_mhx.js → plugin-ByjF2kiV.js} +5 -5
- package/dist/{plugin-Dr39GBRG.cjs → plugin-DM1M2wlI.cjs} +1 -1
- package/dist/prefill-B8H9qwE4.js +371 -0
- package/dist/prefill-D7EswyTI.cjs +1 -0
- package/dist/{prepared-DqtpvRTn.js → prepared-BE-4jfX5.js} +2 -2
- package/dist/{prepared-DdrjLC7L.cjs → prepared-CGVphji3.cjs} +1 -1
- package/dist/{protocol-BzwMP4Vw.cjs → protocol-ByRVzzQG.cjs} +1 -1
- package/dist/{protocol-kt4Iy6-3.js → protocol-Cr81vFSQ.js} +3 -3
- package/dist/{record-bindings-CZWBJ1fU.js → record-bindings-DEJtmo3p.js} +67 -107
- package/dist/record-bindings-ehjnCDHt.cjs +1 -0
- package/dist/{region-binding-workflow-CWNvIjkV.js → region-binding-workflow-CBg0l_tj.js} +2 -2
- package/dist/{region-binding-workflow-CqSMxQ4p.cjs → region-binding-workflow-D05tOYn3.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{report-params-B1RzkhJj.js → report-params-D9tBuM9B.js} +1 -1
- package/dist/{report-params-WDGrA4oP.cjs → report-params-VTg8MoCp.cjs} +1 -1
- package/dist/runtime-CDA6d263.cjs +1 -0
- package/dist/runtime-CEMvybO7.js +170 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server/node.d.cts +121 -7
- package/dist/server/node.d.ts +121 -7
- package/dist/server-node.cjs +4 -4
- package/dist/server-node.js +3446 -2115
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +417 -29
- package/dist/server.d.ts +417 -29
- package/dist/server.js +787 -544
- package/dist/sha256-BDQ1Qk7A.js +158 -0
- package/dist/sha256-DgZAKXqI.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/template-bindings-Cg5oBLFT.cjs +1 -0
- package/dist/template-bindings-TKnXM7ll.js +62 -0
- package/dist/{template-catalog-BtR2JmCL.js → template-catalog-CmbWOJqy.js} +16 -16
- package/dist/template-catalog-Utu4GP09.cjs +1 -0
- package/dist/{template-fragments-BVsbxs4a.cjs → template-fragments-C_zSHJAa.cjs} +1 -1
- package/dist/{template-fragments-By0aZC1D.js → template-fragments-DWgo9tlZ.js} +2 -2
- package/dist/{template-outline-BwRV_eRo.cjs → template-outline-DWkzZXVC.cjs} +1 -1
- package/dist/{template-outline-cnWfT_LK.js → template-outline-DiADphlq.js} +1 -1
- package/dist/{template-registry-Cw3vRTX2.js → template-registry-BIhIHOab.js} +319 -314
- package/dist/template-registry-DzWswQI5.cjs +1 -0
- package/dist/vue/async.d.cts +636 -35
- package/dist/vue/async.d.ts +636 -35
- package/dist/vue/index.d.cts +746 -67
- package/dist/vue/index.d.ts +746 -67
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +94 -89
- package/dist/{workbook-session-Cbts-22R.cjs → workbook-session-B94EwVa_.cjs} +1 -1
- package/dist/{workbook-session-BeSO8PFB.js → workbook-session-BoScoOg-.js} +2 -2
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +75 -7
- package/dist/worker.d.ts +75 -7
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.d.cts +208 -15
- package/dist/xlsx.d.ts +208 -15
- package/dist/xlsx.js +288 -252
- package/package.json +1 -1
- package/dist/ParamEditor-CUQLgoxa.cjs +0 -1
- package/dist/ParamEditor-OKesP_nO.js +0 -594
- package/dist/ReportBatchPanel-cZCAMAwH.cjs +0 -1
- package/dist/ReportPreview-BcDKCLiK.js +0 -4834
- package/dist/ReportPreview-Bk9nLfO9.cjs +0 -6
- package/dist/RuleEditor-BX5S8RSF.cjs +0 -1
- package/dist/RuleEditor-CGl9XY2s.js +0 -2037
- package/dist/assets-CqIbfbTr.js +0 -126
- package/dist/assets-e4YSke8n.cjs +0 -1
- package/dist/capabilities-DDwXr_cA.js +0 -103
- package/dist/capabilities-DNLyZdNw.cjs +0 -1
- package/dist/component-tree-Ca6YYfHq.js +0 -61
- package/dist/component-tree-DkGLEfZC.cjs +0 -1
- package/dist/computed-C-4C2S5h.js +0 -521
- package/dist/computed-CGV2a809.cjs +0 -1
- package/dist/config-Dg_o8e7m.cjs +0 -1
- package/dist/config-XQ4qrQ7Q.js +0 -844
- package/dist/dataset-BkRmwgeJ.cjs +0 -1
- package/dist/dataset-H5pFuQGU.js +0 -121
- package/dist/designer-BfQSahxq.js +0 -5163
- package/dist/designer-CPPdeM5_.cjs +0 -2
- package/dist/diagnostic-notification-B9K9We3h.cjs +0 -1
- package/dist/diagnostic-notification-qGAYZdkB.js +0 -7
- package/dist/drill-CsdjgkRM.cjs +0 -1
- package/dist/drill-DIGsZfyB.js +0 -145
- package/dist/json-snapshot-D6ioHth9.js +0 -1702
- package/dist/json-snapshot-DknkjvxP.cjs +0 -2
- package/dist/matrix-CGRGkn5s.js +0 -112
- package/dist/matrix-gEO7ZM_u.cjs +0 -1
- package/dist/param-validation-C3HlcLLO.cjs +0 -1
- package/dist/param-validation-Do7Eg8Zv.js +0 -181
- package/dist/record-bindings-DUX1VMlR.cjs +0 -1
- package/dist/runtime-BjKBI530.js +0 -168
- package/dist/runtime-CBFEPKEs.cjs +0 -1
- package/dist/sha256-BshdOkCC.cjs +0 -1
- package/dist/sha256-DTG-Gq8i.js +0 -157
- package/dist/template-bindings-C2SpvsMU.js +0 -58
- package/dist/template-bindings-CEtWyiLX.cjs +0 -1
- package/dist/template-catalog-C2NLdrwB.cjs +0 -1
- package/dist/template-registry-C62vpv4a.cjs +0 -1
- package/dist/tree-BX380Rr7.cjs +0 -1
- package/dist/tree-CjVZLRw7.js +0 -172
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function y(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)return;const n=Object.getOwnPropertyDescriptor(e,"length")?.value;if(typeof n!="number"||!Number.isSafeInteger(n)||n<0||n>t||Reflect.ownKeys(e).length!==n+1)return;const r=[];for(let o=0;o<n;o++){const s=Object.getOwnPropertyDescriptor(e,String(o));if(!s||!Object.prototype.hasOwnProperty.call(s,"value"))return;r.push(s.value)}return r}const O=100,N=16,R=104857;function j(e,t,n){if(typeof e=="string"){if(e.length>R)return;try{e=JSON.parse(e)}catch{return}}const i=y(e,t);if(!i)return;const r=[];let o=2;for(const s of i){if(typeof s!="string"||!s.trim()||s.length>1024||n&&r.includes(s)||(o+=JSON.stringify(s).length+(r.length?1:0),o>R))return;r.push(s)}return r}function I(e){return j(e,O,!0)}function S(e){return j(e,N,!1)}function E(e){const t=S(e);if(!t)throw new TypeError("Invalid report cascader path");return JSON.stringify(t)}function q(e){const t=I(e);if(!t)throw new TypeError("Invalid report parameter selection");return JSON.stringify(t)}function P(e){if(typeof e=="string"){if(e.length>2048)return;try{e=JSON.parse(e)}catch{return}}const t=y(e,2);if(!t||t.length!==2)return;const n=t[0],i=t[1];return typeof n=="number"&&typeof i=="number"&&Number.isFinite(n)&&Number.isFinite(i)&&n<=i?[n,i]:void 0}function T(e){const t=P(e);if(!t)throw new TypeError("Invalid report number range");return JSON.stringify(t)}function u(e){return["multiSelect","cascader","numberRange"].includes(e.type??"")}function b(e,t){return e.type==="numberRange"?P(t):e.type==="cascader"?S(t):I(t)}function k(e,t,n=!1){const i=y(e,1e3);if(!i)return!1;const r=[{items:i,depth:1}],o=new Set;let s=0;for(let a=0;a<r.length;a++){const{items:m,depth:l}=r[a];if(l>N)return!1;const c=new Set;for(const p of m){const h=C(p,n);if(++s>1e3||!h||o.has(p)||c.has(h.value))return!1;if(o.add(p),c.add(h.value),h.children!==void 0){const v=y(h.children,1e3);if(!t||!v)return!1;v.length&&r.push({items:v,depth:l+1})}}}return!0}function w(e){return e.map(t=>({value:t.value,label:t.label,...t.children?{children:w(t.children)}:{}}))}function C(e,t){if(!e||typeof e!="object"||![Object.prototype,null].includes(Object.getPrototypeOf(e)))return;const n=Object.getOwnPropertyDescriptors(e);if(Object.values(n).some(o=>!Object.prototype.hasOwnProperty.call(o,"value")))return;const i=n.value?.value,r=n.label?.value;if(!(typeof i!="string"||!t&&!i.trim()||i.length>1024||typeof r!="string"||r.length>1024))return{value:i,label:r,...n.children?{children:n.children.value}:{}}}function J(e,t){let n=e;for(const[i,r]of t.entries()){const o=n.find(s=>s.value===r);if(!o)return!1;if(n=o.children??[],i===t.length-1)return n.length===0}return!1}function _(e,t){const n=b(e,t);if(!n)return[["type",e.type==="numberRange"?"请填写完整数字范围,最小值不能大于最大值":e.type==="cascader"?"请选择完整的末级路径":"请选择有效选项,不能重复或超出数量限制"]];if(e.type==="numberRange")return F(e,n);const i=n,r=[];return e.type==="cascader"&&e.options&&!J(e.options,i)&&r.push(["option","应为允许选项中的完整叶节点路径"]),e.type==="multiSelect"&&(e.options&&i.some(o=>!e.options.some(s=>s.value===o))&&r.push(["option","不在允许的选项中"]),e.minItems!==void 0&&i.length<e.minItems&&r.push(["minItems",`至少选择 ${e.minItems} 项`]),e.maxItems!==void 0&&i.length>e.maxItems&&r.push(["maxItems",`最多选择 ${e.maxItems} 项`])),r}function F(e,t){const n=[];return typeof e.min=="number"&&t[0]<e.min&&n.push(["minimum",`不能小于 ${e.min}`]),typeof e.max=="number"&&t[1]>e.max&&n.push(["maximum",`不能大于 ${e.max}`]),n}function B(e){const t=[];for(const n of["minItems","maxItems"])e[n]!==void 0&&(e.type!=="multiSelect"||!Number.isSafeInteger(e[n])||e[n]<0||e[n]>O)&&t.push(`${n} 应为多选参数的 0–100 整数边界`);return e.minItems!==void 0&&e.maxItems!==void 0&&e.minItems>e.maxItems&&t.push("最少项目数不能大于最多项目数"),t}function W(e){if(e.type==="numberRange"){const n={type:"number",...typeof e.min=="number"?{minimum:e.min}:{},...typeof e.max=="number"?{maximum:e.max}:{}};return{type:"array",minItems:2,maxItems:2,prefixItems:[n,{...n}],items:!1,"x-report-number-range":{ordered:!0},"x-report-wire-encoding":"json"}}const t={"x-report-wire-encoding":"json","x-report-wire-max-code-units":R,type:"array",minItems:Math.max(e.required?1:0,e.minItems??0),maxItems:e.type==="cascader"?16:e.maxItems??O,items:{type:"string",minLength:1,maxLength:1024,pattern:"\\S","x-report-max-code-units":1024}};return e.type==="multiSelect"?(t.uniqueItems=!0,e.options&&(t.items={...t.items,enum:e.options.map(n=>n.value)})):t["x-report-cascader"]={leafOnly:!0,...e.options?{options:w(e.options)}:{}},t}function z(e){const t=[];return e.optionsSource!==void 0&&((!["select","multiSelect","cascader"].includes(e.type??"")||typeof e.optionsSource!="string"||!/^[\w][\w.:-]{0,127}$/.test(e.optionsSource))&&t.push("远程选项来源应为选择参数的有效来源键(最多 128 字符)"),e.options!==void 0&&t.push("远程选项来源与静态选项不能同时配置")),e.dependsOn!==void 0&&(!e.optionsSource||!Array.isArray(e.dependsOn)||e.dependsOn.length>32||e.dependsOn.some(n=>typeof n!="string"||!n)||new Set(e.dependsOn).size!==e.dependsOn.length)&&t.push("联动依赖应为远程选项的最多 32 个唯一参数名"),t}function H(e){const t=new Map(e.map((r,o)=>[r.field,{def:r,index:o,degree:0,children:[]}])),n=[];for(const r of t.values())for(const o of r.def.dependsOn??[]){const s=t.get(o);if(!s){n.push({index:r.index,message:`联动依赖参数 ${o} 未声明`});continue}r.degree++,s.children.push(r.def.field)}const i=[...t.values()].filter(r=>r.degree===0);for(let r=0;r<i.length;r++)for(const o of i[r].children){const s=t.get(o);--s.degree===0&&i.push(s)}for(const r of t.values())r.degree>0&&n.push({index:r.index,message:"联动依赖不能形成循环"});return n}function g(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e)||e.startsWith("0000-"))return!1;const t=new Date(`${e}T00:00:00.000Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,10)===e}function d(e){return e.length===4&&/^\d{4}$/.test(e)&&e!=="0000"}function $(e){return e.length===7&&/^\d{4}-(?:0[1-9]|1[0-2])$/.test(e)&&d(e.slice(0,4))}function x(e){const[t,n,i]=e.split("/");if(!(i!==void 0||!t||!n||!g(t)||!g(n)||t>n))return{start:t,end:n}}function K(e){const t=`${e.start}/${e.end}`;if(!x(t))throw new RangeError("日期范围必须为完整且有序的 YYYY-MM-DD/YYYY-MM-DD");return t}function Y(e,t){return typeof t!="string"?!1:e==="month"?$(t):e==="year"?d(t):(e==="date"||e==="dateRange")&&g(t)}function U(e,t){if(e==="date"&&!g(t))return"应为有效的 YYYY-MM-DD 日期";if(e==="month"&&!$(t))return"应为有效的 YYYY-MM 月份";if(e==="year"&&!d(t))return"应为 0001 至 9999 的四位年份";if(e==="dateRange"&&!x(t))return"应为完整且有序的 YYYY-MM-DD/YYYY-MM-DD 日期范围"}class D extends Error{constructor(t){super(t.map(n=>`${n.field}: ${n.message}`).join("; ")),this.issues=t,this.code="params",this.name="ReportParamValidationError"}}function M(e){return/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e)&&Number.isFinite(Number(e))}function V(e,t){if(u(e))return _(e,t);if(e.type==="number"&&!M(t))return[["type","应为有限数字"]];const n=U(e.type,t);if(n)return[["type",n]];const i=[];e.type==="select"&&e.options&&!e.options.some(o=>o.value===t)&&i.push(["option","不在允许的选项中"]);const r=Array.from(t).length;return e.minLength!==void 0&&r<e.minLength&&i.push(["minLength",`至少 ${e.minLength} 个字符`]),e.maxLength!==void 0&&r>e.maxLength&&i.push(["maxLength",`最多 ${e.maxLength} 个字符`]),i.push(...X(e,t)),i}function X(e,t){const n=e.type==="dateRange"?x(t):void 0,i=n?.start??(e.type==="number"?Number(t):t),r=n?.end??i,o=[];return e.min!==void 0&&i<e.min&&o.push(["minimum",`不能小于 ${e.min}`]),e.max!==void 0&&r>e.max&&o.push(["maximum",`不能大于 ${e.max}`]),o}function Z(e){const t=[];for(const r of["min","max"]){const o=e[r];if(o===void 0)continue;Y(e.type,o)||["number","numberRange"].includes(e.type??"")&&typeof o=="number"&&Number.isFinite(o)||t.push(`${r} 应为数字的有限边界或日期/月/年的规范字符串边界`)}const n=typeof e.min=="number"&&typeof e.max=="number"&&e.min>e.max,i=typeof e.min=="string"&&typeof e.max=="string"&&e.min>e.max;return(n||i)&&t.push("最小边界不能大于最大边界"),[...t,...G(e),...B(e)]}function G(e){const t=[];u(e)&&(e.minLength!==void 0||e.maxLength!==void 0)&&t.push("复合参数使用项目数或数值边界,而不是文本长度约束"),e.type==="number"&&(e.minLength!==void 0||e.maxLength!==void 0)&&t.push("number 参数使用 min/max 而不是文本长度约束");for(const n of["minLength","maxLength"]){const i=e[n];i!==void 0&&(!Number.isSafeInteger(i)||i<0)&&t.push(`${n} 应为非负整数`)}return typeof e.minLength=="number"&&typeof e.maxLength=="number"&&e.minLength>e.maxLength&&t.push("最小长度不能大于最大长度"),t}function L(e){if(!Array.isArray(e))return[{code:"definition",field:"",path:"$.paramDefs",message:"参数定义应为数组"}];const t=new Set,n=e.flatMap((i,r)=>{const o=i&&typeof i.field=="string"?i.field:"";return ee(i,t).map(a=>({code:"definition",field:o,path:`$.paramDefs.${r}`,message:a}))});return n.length?n:H(e).map(({index:i,message:r})=>({code:"definition",field:e[i].field,path:`$.paramDefs.${i}`,message:r}))}function Q(e){const t=[];return e.type!==void 0&&!["text","number","date","month","year","dateRange","select","multiSelect","cascader","numberRange"].includes(e.type)&&t.push("未知参数类型"),e.label!==void 0&&typeof e.label!="string"&&t.push("参数标签应为字符串"),e.placeholder!==void 0&&typeof e.placeholder!="string"&&t.push("提示文字应为字符串"),e.required!==void 0&&typeof e.required!="boolean"&&t.push("required 应为布尔值"),e.defaultValue!==void 0&&typeof e.defaultValue!="string"&&t.push("默认值应为字符串"),e.options!==void 0&&!k(e.options,e.type==="cascader",!u(e))&&t.push("选项应为包含字符串 label/value 的数组"),[...t,...z(e)]}function ee(e,t){if(!e||typeof e!="object"||Array.isArray(e))return["参数定义项应为对象"];const n=Q(e);return typeof e.field!="string"||!e.field.trim()||t.has(e.field)?n.push("参数名应为非空且不重复的字符串"):t.add(e.field),n.length||(n.push(...Z(e)),n.length)||e.defaultValue!==void 0&&(e.required&&(!e.defaultValue.trim()||u(e)&&b(e,e.defaultValue)?.length===0)?n.push("必填参数的默认值不能为空"):e.defaultValue.trim()&&n.push(...V(e,e.defaultValue).map(([,i])=>`默认值${i}`))),n}function te(e,t,n){for(const[i,r]of Object.entries(e))(typeof r=="string"||typeof r=="number"&&Number.isFinite(r))&&(Object.defineProperty(t,i,{value:String(r),writable:!0,enumerable:!0,configurable:!0}),Object.defineProperty(n,i,{value:r,writable:!0,enumerable:!0,configurable:!0}))}function f(e){return e==null||typeof e=="string"&&!e.trim()}function A(e,t={}){const n=Object.create(null),i=Object.create(null),r=L(e);if((!t||typeof t!="object"||Array.isArray(t))&&r.push({code:"type",field:"",path:"$.params",message:"参数应为对象"}),r.length)return{ok:!1,values:n,typedValues:i,issues:r};te(t,n,i);for(const o of e){const s=Object.prototype.hasOwnProperty.call(t,o.field)&&t[o.field]!==void 0?t[o.field]:o.defaultValue;ne(o,s,{values:n,typedValues:i,issues:r})}return r.push(...re(e,n)),{ok:r.length===0,values:n,typedValues:i,issues:r}}function ne(e,t,n){const{values:i,typedValues:r,issues:o}=n,s=(c,p)=>o.push({code:c,path:`$.params.${e.field}`,field:e.field,message:p}),a=u(e)&&!f(t)?b(e,t):void 0;if(f(t)||a?.length===0){e.required&&s("required","此参数为必填项"),(typeof t=="string"||a)&&(i[e.field]=a?"":String(t)),delete r[e.field];return}if(!a&&typeof t!="string"&&!(typeof t=="number"&&Number.isFinite(t))){s("type","参数应为字符串、有限数字或当前控件的规范数组");return}const m=a?JSON.stringify(a):String(t);i[e.field]=m;const l=V(e,m);l.forEach(([c,p])=>s(c,p)),l.length&&u(e)?delete r[e.field]:r[e.field]=a??(e.type==="number"&&M(m)?Number(m):m)}function re(e,t){return e.flatMap(n=>!f(t[n.field])&&n.dependsOn?.some(i=>f(t[i]))?[{code:"dependency",path:`$.params.${n.field}`,field:n.field,message:"请先填写联动依赖的上级参数"}]:[])}function ie(e,t={}){const n=A(e,t);if(!n.ok)throw new D(n.issues);return n.values}function oe(e){const t={},n="(?![\\s\\S])";return e.type==="date"&&(t.format="date"),e.type==="month"&&(t.pattern=`^(?!0000)[0-9]{4}-(0[1-9]|1[0-2])${n}`),e.type==="year"&&(t.pattern=`^(?!0000)[0-9]{4}${n}`),e.type==="dateRange"&&(t.pattern=`^[0-9]{4}-[0-9]{2}-[0-9]{2}/[0-9]{4}-[0-9]{2}-[0-9]{2}${n}`),e.type==="dateRange"&&(t["x-report-date-range"]={separator:"/",ordered:!0,calendarDates:!0}),t}function se(e){const t={type:e.type==="number"?"number":"string",title:e.label??e.field,...oe(e)};return u(e)&&Object.assign(t,W(e)),e.required&&!u(e)&&e.type!=="number"&&!t.pattern&&(t.pattern="\\S"),e.type==="select"&&e.options&&(t.enum=e.options.map(n=>n.value)),Object.assign(t,ue(e)),Object.assign(t,ae(e)),t}function ae(e){const t={};return e.defaultValue!==void 0&&(!(e.type==="number"||u(e))||e.defaultValue.trim())&&(t.default=u(e)?b(e,e.defaultValue):e.type==="number"?Number(e.defaultValue):e.defaultValue),e.minLength!==void 0&&(t.minLength=e.minLength),e.maxLength!==void 0&&(t.maxLength=e.maxLength),!u(e)&&typeof e.min=="number"&&(t.minimum=e.min),!u(e)&&typeof e.max=="number"&&(t.maximum=e.max),typeof e.min=="string"&&(t["x-report-minimum"]=e.min),typeof e.max=="string"&&(t["x-report-maximum"]=e.max),t}function ue(e){return{...e.optionsSource?{"x-report-options-source":e.optionsSource}:{},...e.dependsOn?.length?{"x-report-depends-on":[...e.dependsOn]}:{}}}function me(e){const t=L(e);if(t.length)throw new D(t);return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",properties:Object.fromEntries(e.map(n=>[n.field,se(n)])),required:e.filter(n=>n.required).map(n=>n.field),additionalProperties:!0}}exports.ReportParamValidationError=D;exports.assertReportParams=ie;exports.formatReportCascaderPath=E;exports.formatReportDateRange=K;exports.formatReportNumberRange=T;exports.formatReportParamSelection=q;exports.isReportDate=g;exports.isReportMonth=$;exports.isReportTemporalBound=Y;exports.isReportYear=d;exports.parseReportCascaderPath=S;exports.parseReportDateRange=x;exports.parseReportNumberRange=P;exports.parseReportParamSelection=I;exports.reportParamsJsonSchema=me;exports.validateReportParamDefinitions=L;exports.validateReportParams=A;
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
function g(e, t) {
|
|
2
|
+
if (!Array.isArray(e) || Object.getPrototypeOf(e) !== Array.prototype) return;
|
|
3
|
+
const n = Object.getOwnPropertyDescriptor(e, "length")?.value;
|
|
4
|
+
if (typeof n != "number" || !Number.isSafeInteger(n) || n < 0 || n > t || Reflect.ownKeys(e).length !== n + 1) return;
|
|
5
|
+
const r = [];
|
|
6
|
+
for (let s = 0; s < n; s++) {
|
|
7
|
+
const o = Object.getOwnPropertyDescriptor(e, String(s));
|
|
8
|
+
if (!o || !Object.prototype.hasOwnProperty.call(o, "value")) return;
|
|
9
|
+
r.push(o.value);
|
|
10
|
+
}
|
|
11
|
+
return r;
|
|
12
|
+
}
|
|
13
|
+
const v = 100, S = 16, x = 104857;
|
|
14
|
+
function R(e, t, n) {
|
|
15
|
+
if (typeof e == "string") {
|
|
16
|
+
if (e.length > x) return;
|
|
17
|
+
try {
|
|
18
|
+
e = JSON.parse(e);
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const i = g(e, t);
|
|
24
|
+
if (!i) return;
|
|
25
|
+
const r = [];
|
|
26
|
+
let s = 2;
|
|
27
|
+
for (const o of i) {
|
|
28
|
+
if (typeof o != "string" || !o.trim() || o.length > 1024 || n && r.includes(o) || (s += JSON.stringify(o).length + (r.length ? 1 : 0), s > x)) return;
|
|
29
|
+
r.push(o);
|
|
30
|
+
}
|
|
31
|
+
return r;
|
|
32
|
+
}
|
|
33
|
+
function $(e) {
|
|
34
|
+
return R(e, v, !0);
|
|
35
|
+
}
|
|
36
|
+
function P(e) {
|
|
37
|
+
return R(e, S, !1);
|
|
38
|
+
}
|
|
39
|
+
function ie(e) {
|
|
40
|
+
const t = P(e);
|
|
41
|
+
if (!t) throw new TypeError("Invalid report cascader path");
|
|
42
|
+
return JSON.stringify(t);
|
|
43
|
+
}
|
|
44
|
+
function se(e) {
|
|
45
|
+
const t = $(e);
|
|
46
|
+
if (!t) throw new TypeError("Invalid report parameter selection");
|
|
47
|
+
return JSON.stringify(t);
|
|
48
|
+
}
|
|
49
|
+
function L(e) {
|
|
50
|
+
if (typeof e == "string") {
|
|
51
|
+
if (e.length > 2048) return;
|
|
52
|
+
try {
|
|
53
|
+
e = JSON.parse(e);
|
|
54
|
+
} catch {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const t = g(e, 2);
|
|
59
|
+
if (!t || t.length !== 2) return;
|
|
60
|
+
const n = t[0], i = t[1];
|
|
61
|
+
return typeof n == "number" && typeof i == "number" && Number.isFinite(n) && Number.isFinite(i) && n <= i ? [n, i] : void 0;
|
|
62
|
+
}
|
|
63
|
+
function oe(e) {
|
|
64
|
+
const t = L(e);
|
|
65
|
+
if (!t) throw new TypeError("Invalid report number range");
|
|
66
|
+
return JSON.stringify(t);
|
|
67
|
+
}
|
|
68
|
+
function u(e) {
|
|
69
|
+
return ["multiSelect", "cascader", "numberRange"].includes(e.type ?? "");
|
|
70
|
+
}
|
|
71
|
+
function b(e, t) {
|
|
72
|
+
return e.type === "numberRange" ? L(t) : e.type === "cascader" ? P(t) : $(t);
|
|
73
|
+
}
|
|
74
|
+
function V(e, t, n = !1) {
|
|
75
|
+
const i = g(e, 1e3);
|
|
76
|
+
if (!i) return !1;
|
|
77
|
+
const r = [{ items: i, depth: 1 }], s = /* @__PURE__ */ new Set();
|
|
78
|
+
let o = 0;
|
|
79
|
+
for (let a = 0; a < r.length; a++) {
|
|
80
|
+
const { items: m, depth: l } = r[a];
|
|
81
|
+
if (l > S) return !1;
|
|
82
|
+
const c = /* @__PURE__ */ new Set();
|
|
83
|
+
for (const p of m) {
|
|
84
|
+
const h = A(p, n);
|
|
85
|
+
if (++o > 1e3 || !h || s.has(p) || c.has(h.value)) return !1;
|
|
86
|
+
if (s.add(p), c.add(h.value), h.children !== void 0) {
|
|
87
|
+
const d = g(h.children, 1e3);
|
|
88
|
+
if (!t || !d) return !1;
|
|
89
|
+
d.length && r.push({ items: d, depth: l + 1 });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return !0;
|
|
94
|
+
}
|
|
95
|
+
function j(e) {
|
|
96
|
+
return e.map((t) => ({ value: t.value, label: t.label, ...t.children ? { children: j(t.children) } : {} }));
|
|
97
|
+
}
|
|
98
|
+
function A(e, t) {
|
|
99
|
+
if (!e || typeof e != "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(e))) return;
|
|
100
|
+
const n = Object.getOwnPropertyDescriptors(e);
|
|
101
|
+
if (Object.values(n).some((s) => !Object.prototype.hasOwnProperty.call(s, "value"))) return;
|
|
102
|
+
const i = n.value?.value, r = n.label?.value;
|
|
103
|
+
if (!(typeof i != "string" || !t && !i.trim() || i.length > 1024 || typeof r != "string" || r.length > 1024))
|
|
104
|
+
return { value: i, label: r, ...n.children ? { children: n.children.value } : {} };
|
|
105
|
+
}
|
|
106
|
+
function E(e, t) {
|
|
107
|
+
let n = e;
|
|
108
|
+
for (const [i, r] of t.entries()) {
|
|
109
|
+
const s = n.find((o) => o.value === r);
|
|
110
|
+
if (!s) return !1;
|
|
111
|
+
if (n = s.children ?? [], i === t.length - 1) return n.length === 0;
|
|
112
|
+
}
|
|
113
|
+
return !1;
|
|
114
|
+
}
|
|
115
|
+
function q(e, t) {
|
|
116
|
+
const n = b(e, t);
|
|
117
|
+
if (!n) return [["type", e.type === "numberRange" ? "请填写完整数字范围,最小值不能大于最大值" : e.type === "cascader" ? "请选择完整的末级路径" : "请选择有效选项,不能重复或超出数量限制"]];
|
|
118
|
+
if (e.type === "numberRange") return T(e, n);
|
|
119
|
+
const i = n, r = [];
|
|
120
|
+
return e.type === "cascader" && e.options && !E(e.options, i) && r.push(["option", "应为允许选项中的完整叶节点路径"]), e.type === "multiSelect" && (e.options && i.some((s) => !e.options.some((o) => o.value === s)) && r.push(["option", "不在允许的选项中"]), e.minItems !== void 0 && i.length < e.minItems && r.push(["minItems", `至少选择 ${e.minItems} 项`]), e.maxItems !== void 0 && i.length > e.maxItems && r.push(["maxItems", `最多选择 ${e.maxItems} 项`])), r;
|
|
121
|
+
}
|
|
122
|
+
function T(e, t) {
|
|
123
|
+
const n = [];
|
|
124
|
+
return typeof e.min == "number" && t[0] < e.min && n.push(["minimum", `不能小于 ${e.min}`]), typeof e.max == "number" && t[1] > e.max && n.push(["maximum", `不能大于 ${e.max}`]), n;
|
|
125
|
+
}
|
|
126
|
+
function k(e) {
|
|
127
|
+
const t = [];
|
|
128
|
+
for (const n of ["minItems", "maxItems"]) e[n] !== void 0 && (e.type !== "multiSelect" || !Number.isSafeInteger(e[n]) || e[n] < 0 || e[n] > v) && t.push(`${n} 应为多选参数的 0–100 整数边界`);
|
|
129
|
+
return e.minItems !== void 0 && e.maxItems !== void 0 && e.minItems > e.maxItems && t.push("最少项目数不能大于最多项目数"), t;
|
|
130
|
+
}
|
|
131
|
+
function J(e) {
|
|
132
|
+
if (e.type === "numberRange") {
|
|
133
|
+
const n = { type: "number", ...typeof e.min == "number" ? { minimum: e.min } : {}, ...typeof e.max == "number" ? { maximum: e.max } : {} };
|
|
134
|
+
return { type: "array", minItems: 2, maxItems: 2, prefixItems: [n, { ...n }], items: !1, "x-report-number-range": { ordered: !0 }, "x-report-wire-encoding": "json" };
|
|
135
|
+
}
|
|
136
|
+
const t = { "x-report-wire-encoding": "json", "x-report-wire-max-code-units": x, type: "array", minItems: Math.max(e.required ? 1 : 0, e.minItems ?? 0), maxItems: e.type === "cascader" ? 16 : e.maxItems ?? v, items: { type: "string", minLength: 1, maxLength: 1024, pattern: "\\S", "x-report-max-code-units": 1024 } };
|
|
137
|
+
return e.type === "multiSelect" ? (t.uniqueItems = !0, e.options && (t.items = { ...t.items, enum: e.options.map((n) => n.value) })) : t["x-report-cascader"] = { leafOnly: !0, ...e.options ? { options: j(e.options) } : {} }, t;
|
|
138
|
+
}
|
|
139
|
+
function _(e) {
|
|
140
|
+
const t = [];
|
|
141
|
+
return e.optionsSource !== void 0 && ((!["select", "multiSelect", "cascader"].includes(e.type ?? "") || typeof e.optionsSource != "string" || !/^[\w][\w.:-]{0,127}$/.test(e.optionsSource)) && t.push("远程选项来源应为选择参数的有效来源键(最多 128 字符)"), e.options !== void 0 && t.push("远程选项来源与静态选项不能同时配置")), e.dependsOn !== void 0 && (!e.optionsSource || !Array.isArray(e.dependsOn) || e.dependsOn.length > 32 || e.dependsOn.some((n) => typeof n != "string" || !n) || new Set(e.dependsOn).size !== e.dependsOn.length) && t.push("联动依赖应为远程选项的最多 32 个唯一参数名"), t;
|
|
142
|
+
}
|
|
143
|
+
function C(e) {
|
|
144
|
+
const t = new Map(e.map((r, s) => [r.field, { def: r, index: s, degree: 0, children: [] }])), n = [];
|
|
145
|
+
for (const r of t.values()) for (const s of r.def.dependsOn ?? []) {
|
|
146
|
+
const o = t.get(s);
|
|
147
|
+
if (!o) {
|
|
148
|
+
n.push({ index: r.index, message: `联动依赖参数 ${s} 未声明` });
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
r.degree++, o.children.push(r.def.field);
|
|
152
|
+
}
|
|
153
|
+
const i = [...t.values()].filter((r) => r.degree === 0);
|
|
154
|
+
for (let r = 0; r < i.length; r++) for (const s of i[r].children) {
|
|
155
|
+
const o = t.get(s);
|
|
156
|
+
--o.degree === 0 && i.push(o);
|
|
157
|
+
}
|
|
158
|
+
for (const r of t.values()) r.degree > 0 && n.push({ index: r.index, message: "联动依赖不能形成循环" });
|
|
159
|
+
return n;
|
|
160
|
+
}
|
|
161
|
+
function y(e) {
|
|
162
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
|
|
163
|
+
const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
164
|
+
return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
|
|
165
|
+
}
|
|
166
|
+
function O(e) {
|
|
167
|
+
return e.length === 4 && /^\d{4}$/.test(e) && e !== "0000";
|
|
168
|
+
}
|
|
169
|
+
function N(e) {
|
|
170
|
+
return e.length === 7 && /^\d{4}-(?:0[1-9]|1[0-2])$/.test(e) && O(e.slice(0, 4));
|
|
171
|
+
}
|
|
172
|
+
function I(e) {
|
|
173
|
+
const [t, n, i] = e.split("/");
|
|
174
|
+
if (!(i !== void 0 || !t || !n || !y(t) || !y(n) || t > n))
|
|
175
|
+
return { start: t, end: n };
|
|
176
|
+
}
|
|
177
|
+
function ae(e) {
|
|
178
|
+
const t = `${e.start}/${e.end}`;
|
|
179
|
+
if (!I(t)) throw new RangeError("日期范围必须为完整且有序的 YYYY-MM-DD/YYYY-MM-DD");
|
|
180
|
+
return t;
|
|
181
|
+
}
|
|
182
|
+
function F(e, t) {
|
|
183
|
+
return typeof t != "string" ? !1 : e === "month" ? N(t) : e === "year" ? O(t) : (e === "date" || e === "dateRange") && y(t);
|
|
184
|
+
}
|
|
185
|
+
function B(e, t) {
|
|
186
|
+
if (e === "date" && !y(t)) return "应为有效的 YYYY-MM-DD 日期";
|
|
187
|
+
if (e === "month" && !N(t)) return "应为有效的 YYYY-MM 月份";
|
|
188
|
+
if (e === "year" && !O(t)) return "应为 0001 至 9999 的四位年份";
|
|
189
|
+
if (e === "dateRange" && !I(t)) return "应为完整且有序的 YYYY-MM-DD/YYYY-MM-DD 日期范围";
|
|
190
|
+
}
|
|
191
|
+
class w extends Error {
|
|
192
|
+
constructor(t) {
|
|
193
|
+
super(t.map((n) => `${n.field}: ${n.message}`).join("; ")), this.issues = t, this.code = "params", this.name = "ReportParamValidationError";
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function D(e) {
|
|
197
|
+
return /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e) && Number.isFinite(Number(e));
|
|
198
|
+
}
|
|
199
|
+
function Y(e, t) {
|
|
200
|
+
if (u(e)) return q(e, t);
|
|
201
|
+
if (e.type === "number" && !D(t)) return [["type", "应为有限数字"]];
|
|
202
|
+
const n = B(e.type, t);
|
|
203
|
+
if (n) return [["type", n]];
|
|
204
|
+
const i = [];
|
|
205
|
+
e.type === "select" && e.options && !e.options.some((s) => s.value === t) && i.push(["option", "不在允许的选项中"]);
|
|
206
|
+
const r = Array.from(t).length;
|
|
207
|
+
return e.minLength !== void 0 && r < e.minLength && i.push(["minLength", `至少 ${e.minLength} 个字符`]), e.maxLength !== void 0 && r > e.maxLength && i.push(["maxLength", `最多 ${e.maxLength} 个字符`]), i.push(...W(e, t)), i;
|
|
208
|
+
}
|
|
209
|
+
function W(e, t) {
|
|
210
|
+
const n = e.type === "dateRange" ? I(t) : void 0, i = n?.start ?? (e.type === "number" ? Number(t) : t), r = n?.end ?? i, s = [];
|
|
211
|
+
return e.min !== void 0 && i < e.min && s.push(["minimum", `不能小于 ${e.min}`]), e.max !== void 0 && r > e.max && s.push(["maximum", `不能大于 ${e.max}`]), s;
|
|
212
|
+
}
|
|
213
|
+
function z(e) {
|
|
214
|
+
const t = [];
|
|
215
|
+
for (const r of ["min", "max"]) {
|
|
216
|
+
const s = e[r];
|
|
217
|
+
if (s === void 0) continue;
|
|
218
|
+
F(e.type, s) || ["number", "numberRange"].includes(e.type ?? "") && typeof s == "number" && Number.isFinite(s) || t.push(`${r} 应为数字的有限边界或日期/月/年的规范字符串边界`);
|
|
219
|
+
}
|
|
220
|
+
const n = typeof e.min == "number" && typeof e.max == "number" && e.min > e.max, i = typeof e.min == "string" && typeof e.max == "string" && e.min > e.max;
|
|
221
|
+
return (n || i) && t.push("最小边界不能大于最大边界"), [...t, ...H(e), ...k(e)];
|
|
222
|
+
}
|
|
223
|
+
function H(e) {
|
|
224
|
+
const t = [];
|
|
225
|
+
u(e) && (e.minLength !== void 0 || e.maxLength !== void 0) && t.push("复合参数使用项目数或数值边界,而不是文本长度约束"), e.type === "number" && (e.minLength !== void 0 || e.maxLength !== void 0) && t.push("number 参数使用 min/max 而不是文本长度约束");
|
|
226
|
+
for (const n of ["minLength", "maxLength"]) {
|
|
227
|
+
const i = e[n];
|
|
228
|
+
i !== void 0 && (!Number.isSafeInteger(i) || i < 0) && t.push(`${n} 应为非负整数`);
|
|
229
|
+
}
|
|
230
|
+
return typeof e.minLength == "number" && typeof e.maxLength == "number" && e.minLength > e.maxLength && t.push("最小长度不能大于最大长度"), t;
|
|
231
|
+
}
|
|
232
|
+
function M(e) {
|
|
233
|
+
if (!Array.isArray(e)) return [{ code: "definition", field: "", path: "$.paramDefs", message: "参数定义应为数组" }];
|
|
234
|
+
const t = /* @__PURE__ */ new Set(), n = e.flatMap((i, r) => {
|
|
235
|
+
const s = i && typeof i.field == "string" ? i.field : "";
|
|
236
|
+
return U(i, t).map((a) => ({ code: "definition", field: s, path: `$.paramDefs.${r}`, message: a }));
|
|
237
|
+
});
|
|
238
|
+
return n.length ? n : C(e).map(({ index: i, message: r }) => ({ code: "definition", field: e[i].field, path: `$.paramDefs.${i}`, message: r }));
|
|
239
|
+
}
|
|
240
|
+
function K(e) {
|
|
241
|
+
const t = [];
|
|
242
|
+
return e.type !== void 0 && !["text", "number", "date", "month", "year", "dateRange", "select", "multiSelect", "cascader", "numberRange"].includes(e.type) && t.push("未知参数类型"), e.label !== void 0 && typeof e.label != "string" && t.push("参数标签应为字符串"), e.placeholder !== void 0 && typeof e.placeholder != "string" && t.push("提示文字应为字符串"), e.required !== void 0 && typeof e.required != "boolean" && t.push("required 应为布尔值"), e.defaultValue !== void 0 && typeof e.defaultValue != "string" && t.push("默认值应为字符串"), e.options !== void 0 && !V(e.options, e.type === "cascader", !u(e)) && t.push("选项应为包含字符串 label/value 的数组"), [...t, ..._(e)];
|
|
243
|
+
}
|
|
244
|
+
function U(e, t) {
|
|
245
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return ["参数定义项应为对象"];
|
|
246
|
+
const n = K(e);
|
|
247
|
+
return typeof e.field != "string" || !e.field.trim() || t.has(e.field) ? n.push("参数名应为非空且不重复的字符串") : t.add(e.field), n.length || (n.push(...z(e)), n.length) || e.defaultValue !== void 0 && (e.required && (!e.defaultValue.trim() || u(e) && b(e, e.defaultValue)?.length === 0) ? n.push("必填参数的默认值不能为空") : e.defaultValue.trim() && n.push(...Y(e, e.defaultValue).map(([, i]) => `默认值${i}`))), n;
|
|
248
|
+
}
|
|
249
|
+
function X(e, t, n) {
|
|
250
|
+
for (const [i, r] of Object.entries(e))
|
|
251
|
+
(typeof r == "string" || typeof r == "number" && Number.isFinite(r)) && (Object.defineProperty(t, i, { value: String(r), writable: !0, enumerable: !0, configurable: !0 }), Object.defineProperty(n, i, { value: r, writable: !0, enumerable: !0, configurable: !0 }));
|
|
252
|
+
}
|
|
253
|
+
function f(e) {
|
|
254
|
+
return e == null || typeof e == "string" && !e.trim();
|
|
255
|
+
}
|
|
256
|
+
function Z(e, t = {}) {
|
|
257
|
+
const n = /* @__PURE__ */ Object.create(null), i = /* @__PURE__ */ Object.create(null), r = M(e);
|
|
258
|
+
if ((!t || typeof t != "object" || Array.isArray(t)) && r.push({ code: "type", field: "", path: "$.params", message: "参数应为对象" }), r.length) return { ok: !1, values: n, typedValues: i, issues: r };
|
|
259
|
+
X(t, n, i);
|
|
260
|
+
for (const s of e) {
|
|
261
|
+
const o = Object.prototype.hasOwnProperty.call(t, s.field) && t[s.field] !== void 0 ? t[s.field] : s.defaultValue;
|
|
262
|
+
G(s, o, { values: n, typedValues: i, issues: r });
|
|
263
|
+
}
|
|
264
|
+
return r.push(...Q(e, n)), { ok: r.length === 0, values: n, typedValues: i, issues: r };
|
|
265
|
+
}
|
|
266
|
+
function G(e, t, n) {
|
|
267
|
+
const { values: i, typedValues: r, issues: s } = n, o = (c, p) => s.push({ code: c, path: `$.params.${e.field}`, field: e.field, message: p }), a = u(e) && !f(t) ? b(e, t) : void 0;
|
|
268
|
+
if (f(t) || a?.length === 0) {
|
|
269
|
+
e.required && o("required", "此参数为必填项"), (typeof t == "string" || a) && (i[e.field] = a ? "" : String(t)), delete r[e.field];
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (!a && typeof t != "string" && !(typeof t == "number" && Number.isFinite(t))) {
|
|
273
|
+
o("type", "参数应为字符串、有限数字或当前控件的规范数组");
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const m = a ? JSON.stringify(a) : String(t);
|
|
277
|
+
i[e.field] = m;
|
|
278
|
+
const l = Y(e, m);
|
|
279
|
+
l.forEach(([c, p]) => o(c, p)), l.length && u(e) ? delete r[e.field] : r[e.field] = a ?? (e.type === "number" && D(m) ? Number(m) : m);
|
|
280
|
+
}
|
|
281
|
+
function Q(e, t) {
|
|
282
|
+
return e.flatMap((n) => !f(t[n.field]) && n.dependsOn?.some((i) => f(t[i])) ? [{ code: "dependency", path: `$.params.${n.field}`, field: n.field, message: "请先填写联动依赖的上级参数" }] : []);
|
|
283
|
+
}
|
|
284
|
+
function ue(e, t = {}) {
|
|
285
|
+
const n = Z(e, t);
|
|
286
|
+
if (!n.ok) throw new w(n.issues);
|
|
287
|
+
return n.values;
|
|
288
|
+
}
|
|
289
|
+
function ee(e) {
|
|
290
|
+
const t = {}, n = "(?![\\s\\S])";
|
|
291
|
+
return e.type === "date" && (t.format = "date"), e.type === "month" && (t.pattern = `^(?!0000)[0-9]{4}-(0[1-9]|1[0-2])${n}`), e.type === "year" && (t.pattern = `^(?!0000)[0-9]{4}${n}`), e.type === "dateRange" && (t.pattern = `^[0-9]{4}-[0-9]{2}-[0-9]{2}/[0-9]{4}-[0-9]{2}-[0-9]{2}${n}`), e.type === "dateRange" && (t["x-report-date-range"] = { separator: "/", ordered: !0, calendarDates: !0 }), t;
|
|
292
|
+
}
|
|
293
|
+
function te(e) {
|
|
294
|
+
const t = { type: e.type === "number" ? "number" : "string", title: e.label ?? e.field, ...ee(e) };
|
|
295
|
+
return u(e) && Object.assign(t, J(e)), e.required && !u(e) && e.type !== "number" && !t.pattern && (t.pattern = "\\S"), e.type === "select" && e.options && (t.enum = e.options.map((n) => n.value)), Object.assign(t, re(e)), Object.assign(t, ne(e)), t;
|
|
296
|
+
}
|
|
297
|
+
function ne(e) {
|
|
298
|
+
const t = {};
|
|
299
|
+
return e.defaultValue !== void 0 && (!(e.type === "number" || u(e)) || e.defaultValue.trim()) && (t.default = u(e) ? b(e, e.defaultValue) : e.type === "number" ? Number(e.defaultValue) : e.defaultValue), e.minLength !== void 0 && (t.minLength = e.minLength), e.maxLength !== void 0 && (t.maxLength = e.maxLength), !u(e) && typeof e.min == "number" && (t.minimum = e.min), !u(e) && typeof e.max == "number" && (t.maximum = e.max), typeof e.min == "string" && (t["x-report-minimum"] = e.min), typeof e.max == "string" && (t["x-report-maximum"] = e.max), t;
|
|
300
|
+
}
|
|
301
|
+
function re(e) {
|
|
302
|
+
return { ...e.optionsSource ? { "x-report-options-source": e.optionsSource } : {}, ...e.dependsOn?.length ? { "x-report-depends-on": [...e.dependsOn] } : {} };
|
|
303
|
+
}
|
|
304
|
+
function me(e) {
|
|
305
|
+
const t = M(e);
|
|
306
|
+
if (t.length) throw new w(t);
|
|
307
|
+
return {
|
|
308
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
309
|
+
type: "object",
|
|
310
|
+
properties: Object.fromEntries(e.map((n) => [n.field, te(n)])),
|
|
311
|
+
required: e.filter((n) => n.required).map((n) => n.field),
|
|
312
|
+
additionalProperties: !0
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
export {
|
|
316
|
+
w as R,
|
|
317
|
+
ue as a,
|
|
318
|
+
ae as b,
|
|
319
|
+
oe as c,
|
|
320
|
+
se as d,
|
|
321
|
+
N as e,
|
|
322
|
+
ie as f,
|
|
323
|
+
O as g,
|
|
324
|
+
I as h,
|
|
325
|
+
y as i,
|
|
326
|
+
L as j,
|
|
327
|
+
$ as k,
|
|
328
|
+
Z as l,
|
|
329
|
+
F as m,
|
|
330
|
+
P as p,
|
|
331
|
+
me as r,
|
|
332
|
+
M as v
|
|
333
|
+
};
|