@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const c=["text","number","boolean","date","decimal"],p=new Set(["__proto__","prototype","constructor"]);function i(e){throw new Error(`数据契约无效:${e}`)}function g(e){(!e||!Array.isArray(e.fields)||!e.fields.length||e.fields.length>2048)&&i("fields 应包含 1–2048 个字段");const n=new Set;for(const t of e.fields)(!t||typeof t.field!="string"||!t.field.trim()||p.has(t.field)||n.has(t.field))&&i("字段名应安全、非空且唯一"),n.add(t.field),c.includes(t.type)||i(`未知字段类型 ${t.type}`),x(t),l(t),d(t);b(e,n)}function d(e){e.enum!==void 0&&(!Array.isArray(e.enum)||!e.enum.length||e.enum.some(n=>!f(n,e.type)))&&i("enum 应为匹配字段类型的非空标量数组")}function b(e,n){e.rowKey!==void 0&&((typeof e.rowKey!="string"||!e.rowKey.trim()||!n.has(e.rowKey))&&i("rowKey 应为引用已声明字段的非空字符串"),e.fields.find(t=>t.field===e.rowKey)?.type==="boolean"&&i("布尔字段不能作为业务主键"))}function l(e){for(const n of["label","unit"])e[n]!==void 0&&typeof e[n]!="string"&&i(`${n} 应为字符串`);for(const n of["required","nullable"])e[n]!==void 0&&typeof e[n]!="boolean"&&i(`${n} 应为布尔值`);e.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(e.semanticRole)&&i("未知字段语义")}function x(e){for(const n of["min","max","minLength","maxLength"]){const t=e[n];t!==void 0&&(!Number.isFinite(t)||n.includes("Length")&&(!Number.isInteger(t)||t<0))&&i(`${n} 无效`)}e.min!==void 0&&e.max!==void 0&&e.min>e.max&&i("min 不能超过 max"),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&i("minLength 不能超过 maxLength"),e.type!=="number"&&(e.min!==void 0||e.max!==void 0)&&i("min/max 仅适用于 number,精确小数文本需业务校验"),["number","boolean"].includes(e.type)&&(e.minLength!==void 0||e.maxLength!==void 0)&&i("长度约束仅适用于文本类型")}function w(e){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!n)return!1;const t=Number(n[1]),r=Number(n[2]),s=Number(n[3]),m=t%4===0&&(t%100!==0||t%400===0);return t>0&&r>=1&&r<=12&&s>=1&&s<=[31,m?29:28,31,30,31,30,31,31,30,31,30,31][r-1]}function f(e,n){return n==="number"?typeof e=="number"&&Number.isFinite(e):n==="boolean"?typeof e=="boolean":typeof e!="string"?!1:n==="date"?w(e):n==="decimal"?e.length<=1e4&&/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(e):!0}function L(e,n){if(e==null)return n.required||e===null&&n.nullable===!1?{code:"required",message:"缺少必需字段值"}:void 0;if(!f(e,n.type))return{code:"type",message:`值应为 ${n.type},不会自动转换原始值`};if(n.enum&&!n.enum.includes(e))return{code:"enum",message:"值不在允许的枚举中"};if(typeof e=="number"&&(n.min!==void 0&&e<n.min||n.max!==void 0&&e>n.max))return{code:"range",message:"数值超出范围"};if(typeof e=="string"&&!v(e,n))return{code:"range",message:"文本长度超出范围"}}function v(e,n){if(n.minLength===void 0&&n.maxLength===void 0)return!0;let t=0;for(const r of e)t++;return(n.minLength===void 0||t>=n.minLength)&&(n.maxLength===void 0||t<=n.maxLength)}function h(e,n){const t=e??n;if(!Number.isInteger(t)||t<1)throw new Error("数据校验预算应为正整数");return t}function $(e,n,t){const r=Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0;if((typeof r!="string"||!r.trim())&&!(typeof r=="number"&&Number.isFinite(r)))return"业务主键应为非空字符串或有限数字";const s=JSON.stringify([typeof r,r]);if(t.has(s))return"业务主键重复";t.add(s)}function K(e,n,t={}){g(n);const r=t.path??"$.rows",s=[],m=h(t.maxIssues,100);if(!Array.isArray(e))return{ok:!1,issues:[{code:"row",path:r,message:"数据集应为对象数组"}]};if(e.length>h(t.maxRows,1e5)||e.length*n.fields.length>h(t.maxCells,2e6))return{ok:!1,issues:[{code:"budget",path:r,message:"数据校验超出行数或单元格预算"}]};const u=new Set;for(let o=0;o<e.length&&s.length<m;o++){const a=e[o];if(!a||typeof a!="object"||Array.isArray(a)){s.push({code:"row",path:`${r}[${o}]`,rowIndex:o,message:"行应为对象"});continue}k(a,n,o,r,u,s,m)}return{ok:s.length===0,issues:s}}function k(e,n,t,r,s,m,u){for(const o of n.fields){if(m.length>=u)return;const a=L(Object.prototype.hasOwnProperty.call(e,o.field)?e[o.field]:void 0,o);a&&m.push({...a,rowIndex:t,field:o.field,path:`${r}[${t}].${o.field}`})}if(n.rowKey&&m.length<u){const o=$(e,n.rowKey,s);o&&m.push({code:"row-key",path:`${r}[${t}].${n.rowKey}`,message:o,rowIndex:t,field:n.rowKey})}}function S(e){return g(e),{$schema:"https://json-schema.org/draft/2020-12/schema",type:"array",items:{type:"object",properties:Object.fromEntries(e.fields.map(t=>[t.field,N(t,t.field===e.rowKey)])),required:e.fields.filter(t=>t.required||t.field===e.rowKey).map(t=>t.field),additionalProperties:!0},...e.rowKey?{"x-report-rowKey":e.rowKey}:{}}}function N(e,n){const t=!n&&e.nullable!==!1&&!e.required;return{type:t?[y(e.type),"null"]:y(e.type),...e.label?{title:e.label}:{},...e.type==="date"?{format:"date"}:{},...e.type==="decimal"?{pattern:"^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$"}:{},...e.enum?{enum:t?[...e.enum,null]:[...e.enum]}:{},...e.min===void 0?{}:{minimum:e.min},...e.max===void 0?{}:{maximum:e.max},...R(e,n),...n&&e.type==="text"?{pattern:"\\S"}:{},...e.unit?{"x-report-unit":e.unit}:{},...e.semanticRole?{"x-report-semanticRole":e.semanticRole}:{}}}function R(e,n){const t={};return(e.minLength!==void 0||n&&e.type!=="number")&&(t.minLength=Math.max(e.minLength??0,n?1:0)),e.type==="decimal"?t.maxLength=Math.min(e.maxLength??1e4,1e4):e.maxLength!==void 0&&(t.maxLength=e.maxLength),t}function y(e){return e==="text"||e==="date"||e==="decimal"?"string":e}exports.datasetJsonSchema=S;exports.validateDatasetRows=K;
|
package/dist/dataset-H5pFuQGU.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
const c = ["text", "number", "boolean", "date", "decimal"], p = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
2
|
-
function i(e) {
|
|
3
|
-
throw new Error(`数据契约无效:${e}`);
|
|
4
|
-
}
|
|
5
|
-
function g(e) {
|
|
6
|
-
(!e || !Array.isArray(e.fields) || !e.fields.length || e.fields.length > 2048) && i("fields 应包含 1–2048 个字段");
|
|
7
|
-
const n = /* @__PURE__ */ new Set();
|
|
8
|
-
for (const t of e.fields)
|
|
9
|
-
(!t || typeof t.field != "string" || !t.field.trim() || p.has(t.field) || n.has(t.field)) && i("字段名应安全、非空且唯一"), n.add(t.field), c.includes(t.type) || i(`未知字段类型 ${t.type}`), l(t), x(t), d(t);
|
|
10
|
-
b(e, n);
|
|
11
|
-
}
|
|
12
|
-
function d(e) {
|
|
13
|
-
e.enum !== void 0 && (!Array.isArray(e.enum) || !e.enum.length || e.enum.some((n) => !f(n, e.type))) && i("enum 应为匹配字段类型的非空标量数组");
|
|
14
|
-
}
|
|
15
|
-
function b(e, n) {
|
|
16
|
-
e.rowKey !== void 0 && ((typeof e.rowKey != "string" || !e.rowKey.trim() || !n.has(e.rowKey)) && i("rowKey 应为引用已声明字段的非空字符串"), e.fields.find((t) => t.field === e.rowKey)?.type === "boolean" && i("布尔字段不能作为业务主键"));
|
|
17
|
-
}
|
|
18
|
-
function x(e) {
|
|
19
|
-
for (const n of ["label", "unit"]) e[n] !== void 0 && typeof e[n] != "string" && i(`${n} 应为字符串`);
|
|
20
|
-
for (const n of ["required", "nullable"]) e[n] !== void 0 && typeof e[n] != "boolean" && i(`${n} 应为布尔值`);
|
|
21
|
-
e.semanticRole !== void 0 && !["identifier", "dimension", "measure", "date", "text"].includes(e.semanticRole) && i("未知字段语义");
|
|
22
|
-
}
|
|
23
|
-
function l(e) {
|
|
24
|
-
for (const n of ["min", "max", "minLength", "maxLength"]) {
|
|
25
|
-
const t = e[n];
|
|
26
|
-
t !== void 0 && (!Number.isFinite(t) || n.includes("Length") && (!Number.isInteger(t) || t < 0)) && i(`${n} 无效`);
|
|
27
|
-
}
|
|
28
|
-
e.min !== void 0 && e.max !== void 0 && e.min > e.max && i("min 不能超过 max"), e.minLength !== void 0 && e.maxLength !== void 0 && e.minLength > e.maxLength && i("minLength 不能超过 maxLength"), e.type !== "number" && (e.min !== void 0 || e.max !== void 0) && i("min/max 仅适用于 number,精确小数文本需业务校验"), ["number", "boolean"].includes(e.type) && (e.minLength !== void 0 || e.maxLength !== void 0) && i("长度约束仅适用于文本类型");
|
|
29
|
-
}
|
|
30
|
-
function w(e) {
|
|
31
|
-
const n = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
32
|
-
if (!n) return !1;
|
|
33
|
-
const t = Number(n[1]), r = Number(n[2]), s = Number(n[3]), m = t % 4 === 0 && (t % 100 !== 0 || t % 400 === 0);
|
|
34
|
-
return t > 0 && r >= 1 && r <= 12 && s >= 1 && s <= [31, m ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][r - 1];
|
|
35
|
-
}
|
|
36
|
-
function f(e, n) {
|
|
37
|
-
return n === "number" ? typeof e == "number" && Number.isFinite(e) : n === "boolean" ? typeof e == "boolean" : typeof e != "string" ? !1 : n === "date" ? w(e) : n === "decimal" ? e.length <= 1e4 && /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(e) : !0;
|
|
38
|
-
}
|
|
39
|
-
function L(e, n) {
|
|
40
|
-
if (e == null)
|
|
41
|
-
return n.required || e === null && n.nullable === !1 ? { code: "required", message: "缺少必需字段值" } : void 0;
|
|
42
|
-
if (!f(e, n.type)) return { code: "type", message: `值应为 ${n.type},不会自动转换原始值` };
|
|
43
|
-
if (n.enum && !n.enum.includes(e)) return { code: "enum", message: "值不在允许的枚举中" };
|
|
44
|
-
if (typeof e == "number" && (n.min !== void 0 && e < n.min || n.max !== void 0 && e > n.max)) return { code: "range", message: "数值超出范围" };
|
|
45
|
-
if (typeof e == "string" && !v(e, n)) return { code: "range", message: "文本长度超出范围" };
|
|
46
|
-
}
|
|
47
|
-
function v(e, n) {
|
|
48
|
-
if (n.minLength === void 0 && n.maxLength === void 0) return !0;
|
|
49
|
-
let t = 0;
|
|
50
|
-
for (const r of e) t++;
|
|
51
|
-
return (n.minLength === void 0 || t >= n.minLength) && (n.maxLength === void 0 || t <= n.maxLength);
|
|
52
|
-
}
|
|
53
|
-
function h(e, n) {
|
|
54
|
-
const t = e ?? n;
|
|
55
|
-
if (!Number.isInteger(t) || t < 1) throw new Error("数据校验预算应为正整数");
|
|
56
|
-
return t;
|
|
57
|
-
}
|
|
58
|
-
function $(e, n, t) {
|
|
59
|
-
const r = Object.prototype.hasOwnProperty.call(e, n) ? e[n] : void 0;
|
|
60
|
-
if ((typeof r != "string" || !r.trim()) && !(typeof r == "number" && Number.isFinite(r))) return "业务主键应为非空字符串或有限数字";
|
|
61
|
-
const s = JSON.stringify([typeof r, r]);
|
|
62
|
-
if (t.has(s)) return "业务主键重复";
|
|
63
|
-
t.add(s);
|
|
64
|
-
}
|
|
65
|
-
function S(e, n, t = {}) {
|
|
66
|
-
g(n);
|
|
67
|
-
const r = t.path ?? "$.rows", s = [], m = h(t.maxIssues, 100);
|
|
68
|
-
if (!Array.isArray(e)) return { ok: !1, issues: [{ code: "row", path: r, message: "数据集应为对象数组" }] };
|
|
69
|
-
if (e.length > h(t.maxRows, 1e5) || e.length * n.fields.length > h(t.maxCells, 2e6)) return { ok: !1, issues: [{ code: "budget", path: r, message: "数据校验超出行数或单元格预算" }] };
|
|
70
|
-
const u = /* @__PURE__ */ new Set();
|
|
71
|
-
for (let o = 0; o < e.length && s.length < m; o++) {
|
|
72
|
-
const a = e[o];
|
|
73
|
-
if (!a || typeof a != "object" || Array.isArray(a)) {
|
|
74
|
-
s.push({ code: "row", path: `${r}[${o}]`, rowIndex: o, message: "行应为对象" });
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
K(a, n, o, r, u, s, m);
|
|
78
|
-
}
|
|
79
|
-
return { ok: s.length === 0, issues: s };
|
|
80
|
-
}
|
|
81
|
-
function K(e, n, t, r, s, m, u) {
|
|
82
|
-
for (const o of n.fields) {
|
|
83
|
-
if (m.length >= u) return;
|
|
84
|
-
const a = L(Object.prototype.hasOwnProperty.call(e, o.field) ? e[o.field] : void 0, o);
|
|
85
|
-
a && m.push({ ...a, rowIndex: t, field: o.field, path: `${r}[${t}].${o.field}` });
|
|
86
|
-
}
|
|
87
|
-
if (n.rowKey && m.length < u) {
|
|
88
|
-
const o = $(e, n.rowKey, s);
|
|
89
|
-
o && m.push({ code: "row-key", path: `${r}[${t}].${n.rowKey}`, message: o, rowIndex: t, field: n.rowKey });
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function A(e) {
|
|
93
|
-
return g(e), { $schema: "https://json-schema.org/draft/2020-12/schema", type: "array", items: { type: "object", properties: Object.fromEntries(e.fields.map((t) => [t.field, k(t, t.field === e.rowKey)])), required: e.fields.filter((t) => t.required || t.field === e.rowKey).map((t) => t.field), additionalProperties: !0 }, ...e.rowKey ? { "x-report-rowKey": e.rowKey } : {} };
|
|
94
|
-
}
|
|
95
|
-
function k(e, n) {
|
|
96
|
-
const t = !n && e.nullable !== !1 && !e.required;
|
|
97
|
-
return {
|
|
98
|
-
type: t ? [y(e.type), "null"] : y(e.type),
|
|
99
|
-
...e.label ? { title: e.label } : {},
|
|
100
|
-
...e.type === "date" ? { format: "date" } : {},
|
|
101
|
-
...e.type === "decimal" ? { pattern: "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$" } : {},
|
|
102
|
-
...e.enum ? { enum: t ? [...e.enum, null] : [...e.enum] } : {},
|
|
103
|
-
...e.min === void 0 ? {} : { minimum: e.min },
|
|
104
|
-
...e.max === void 0 ? {} : { maximum: e.max },
|
|
105
|
-
...N(e, n),
|
|
106
|
-
...n && e.type === "text" ? { pattern: "\\S" } : {},
|
|
107
|
-
...e.unit ? { "x-report-unit": e.unit } : {},
|
|
108
|
-
...e.semanticRole ? { "x-report-semanticRole": e.semanticRole } : {}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function N(e, n) {
|
|
112
|
-
const t = {};
|
|
113
|
-
return (e.minLength !== void 0 || n && e.type !== "number") && (t.minLength = Math.max(e.minLength ?? 0, n ? 1 : 0)), e.type === "decimal" ? t.maxLength = Math.min(e.maxLength ?? 1e4, 1e4) : e.maxLength !== void 0 && (t.maxLength = e.maxLength), t;
|
|
114
|
-
}
|
|
115
|
-
function y(e) {
|
|
116
|
-
return e === "text" || e === "date" || e === "decimal" ? "string" : e;
|
|
117
|
-
}
|
|
118
|
-
export {
|
|
119
|
-
A as d,
|
|
120
|
-
S as v
|
|
121
|
-
};
|