@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";const n=require("./component-tree-6TV7W6Yj.cjs");function c(t,r,e,o){if(!n.validDataBar(t)||t.start===t.end)return;const a=Math.max(0,r-2*o);return{x:o+a*t.start,y:o,width:a*(t.end-t.start),height:Math.max(0,e-2*o),color:t.color}}exports.dataBarBox=c;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { v as n } from "./component-tree-CvW4lzpv.js";
|
|
2
|
+
function i(t, r, d, o) {
|
|
3
|
+
if (!n(t) || t.start === t.end) return;
|
|
4
|
+
const a = Math.max(0, r - 2 * o);
|
|
5
|
+
return { x: o + a * t.start, y: o, width: a * (t.end - t.start), height: Math.max(0, d - 2 * o), color: t.color };
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
i as d
|
|
9
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
function u(e) {
|
|
2
|
+
throw new Error(`数据契约无效:${e}`);
|
|
3
|
+
}
|
|
4
|
+
function d(e) {
|
|
5
|
+
return typeof e == "string" && e.trim().length > 0 && e.length <= 4096;
|
|
6
|
+
}
|
|
7
|
+
function y(e) {
|
|
8
|
+
for (const n of ["description", "missingMeaning"]) e[n] !== void 0 && !d(e[n]) && u(`${n} 应为 1–4096 位非空字符串`);
|
|
9
|
+
e.aggregation !== void 0 && !["sum", "avg", "min", "max", "count", "none"].includes(e.aggregation) && u("未知字段聚合语义"), e.aggregation && !["count", "none"].includes(e.aggregation) && !["number", "decimal"].includes(e.type) && u("数值聚合仅适用于 number/decimal"), e.format !== void 0 && l(e), e.calculation !== void 0 && (!e.calculation || !d(e.calculation.description) || !Array.isArray(e.calculation.dependsOn) || !e.calculation.dependsOn.length || e.calculation.dependsOn.length > 256 || e.calculation.dependsOn.some((n) => typeof n != "string" || !n.trim()) || new Set(e.calculation.dependsOn).size !== e.calculation.dependsOn.length) && u("计算说明需包含说明及 1–256 个唯一依赖字段");
|
|
10
|
+
}
|
|
11
|
+
function l(e) {
|
|
12
|
+
const n = e.format;
|
|
13
|
+
if ((!n || !["number", "percent", "date"].includes(n.kind)) && u("未知字段显示格式"), n.kind === "date") {
|
|
14
|
+
(e.type !== "date" || n.pattern !== void 0 && (!d(n.pattern) || n.pattern.length > 128)) && u("日期格式仅适用于日期,pattern 最多 128 位");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
["number", "decimal"].includes(e.type) || u("数值显示格式仅适用于 number/decimal"), n.digits !== void 0 && (!Number.isSafeInteger(n.digits) || n.digits < 0 || n.digits > 100) && u("显示小数位应为 0–100 的整数"), n.kind === "number" && n.thousands !== void 0 && typeof n.thousands != "boolean" && u("thousands 应为布尔值");
|
|
18
|
+
}
|
|
19
|
+
function x(e) {
|
|
20
|
+
const n = new Map(e.map((i) => [i.field, i])), t = /* @__PURE__ */ new Set();
|
|
21
|
+
for (const i of e) {
|
|
22
|
+
const o = [{ field: i.field, exit: !1 }], m = /* @__PURE__ */ new Set();
|
|
23
|
+
for (; o.length; ) {
|
|
24
|
+
const s = o.pop();
|
|
25
|
+
if (s.exit) {
|
|
26
|
+
m.delete(s.field), t.add(s.field);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (m.has(s.field) && u("字段计算依赖存在循环"), t.has(s.field)) continue;
|
|
30
|
+
const r = n.get(s.field);
|
|
31
|
+
r || u(`计算依赖字段未声明:${s.field}`), m.add(s.field), o.push({ field: s.field, exit: !0 });
|
|
32
|
+
for (const c of r.calculation?.dependsOn ?? []) o.push({ field: c, exit: !1 });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const b = ["text", "number", "boolean", "date", "decimal"], w = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
37
|
+
function a(e) {
|
|
38
|
+
throw new Error(`数据契约无效:${e}`);
|
|
39
|
+
}
|
|
40
|
+
function h(e) {
|
|
41
|
+
(!e || !Array.isArray(e.fields) || !e.fields.length || e.fields.length > 2048) && a("fields 应包含 1–2048 个字段");
|
|
42
|
+
const n = /* @__PURE__ */ new Set();
|
|
43
|
+
for (const t of e.fields)
|
|
44
|
+
(!t || typeof t.field != "string" || !t.field.trim() || w.has(t.field) || n.has(t.field)) && a("字段名应安全、非空且唯一"), n.add(t.field), b.includes(t.type) || a(`未知字段类型 ${t.type}`), k(t), $(t), y(t), v(t);
|
|
45
|
+
L(e, n), x(e.fields);
|
|
46
|
+
}
|
|
47
|
+
function v(e) {
|
|
48
|
+
e.enum !== void 0 && (!Array.isArray(e.enum) || !e.enum.length || e.enum.some((n) => !f(n, e.type))) && a("enum 应为匹配字段类型的非空标量数组");
|
|
49
|
+
}
|
|
50
|
+
function L(e, n) {
|
|
51
|
+
e.rowKey !== void 0 && ((typeof e.rowKey != "string" || !e.rowKey.trim() || !n.has(e.rowKey)) && a("rowKey 应为引用已声明字段的非空字符串"), e.fields.find((t) => t.field === e.rowKey)?.type === "boolean" && a("布尔字段不能作为业务主键"));
|
|
52
|
+
}
|
|
53
|
+
function $(e) {
|
|
54
|
+
for (const n of ["label", "unit"]) e[n] !== void 0 && typeof e[n] != "string" && a(`${n} 应为字符串`);
|
|
55
|
+
for (const n of ["required", "nullable"]) e[n] !== void 0 && typeof e[n] != "boolean" && a(`${n} 应为布尔值`);
|
|
56
|
+
e.semanticRole !== void 0 && !["identifier", "dimension", "measure", "date", "text"].includes(e.semanticRole) && a("未知字段语义");
|
|
57
|
+
}
|
|
58
|
+
function k(e) {
|
|
59
|
+
for (const n of ["min", "max", "minLength", "maxLength"]) {
|
|
60
|
+
const t = e[n];
|
|
61
|
+
t !== void 0 && (!Number.isFinite(t) || n.includes("Length") && (!Number.isInteger(t) || t < 0)) && a(`${n} 无效`);
|
|
62
|
+
}
|
|
63
|
+
e.min !== void 0 && e.max !== void 0 && e.min > e.max && a("min 不能超过 max"), e.minLength !== void 0 && e.maxLength !== void 0 && e.minLength > e.maxLength && a("minLength 不能超过 maxLength"), e.type !== "number" && (e.min !== void 0 || e.max !== void 0) && a("min/max 仅适用于 number,精确小数文本需业务校验"), ["number", "boolean"].includes(e.type) && (e.minLength !== void 0 || e.maxLength !== void 0) && a("长度约束仅适用于文本类型");
|
|
64
|
+
}
|
|
65
|
+
function O(e) {
|
|
66
|
+
const n = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
67
|
+
if (!n) return !1;
|
|
68
|
+
const t = Number(n[1]), i = Number(n[2]), o = Number(n[3]), m = t % 4 === 0 && (t % 100 !== 0 || t % 400 === 0);
|
|
69
|
+
return t > 0 && i >= 1 && i <= 12 && o >= 1 && o <= [31, m ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][i - 1];
|
|
70
|
+
}
|
|
71
|
+
function f(e, n) {
|
|
72
|
+
return n === "number" ? typeof e == "number" && Number.isFinite(e) : n === "boolean" ? typeof e == "boolean" : typeof e != "string" ? !1 : n === "date" ? O(e) : n === "decimal" ? e.length <= 1e4 && /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(e) : !0;
|
|
73
|
+
}
|
|
74
|
+
function S(e, n) {
|
|
75
|
+
if (e == null)
|
|
76
|
+
return n.required || e === null && n.nullable === !1 ? { code: "required", message: "缺少必需字段值" } : void 0;
|
|
77
|
+
if (!f(e, n.type)) return { code: "type", message: `值应为 ${n.type},不会自动转换原始值` };
|
|
78
|
+
if (n.enum && !n.enum.includes(e)) return { code: "enum", message: "值不在允许的枚举中" };
|
|
79
|
+
if (typeof e == "number" && (n.min !== void 0 && e < n.min || n.max !== void 0 && e > n.max)) return { code: "range", message: "数值超出范围" };
|
|
80
|
+
if (typeof e == "string" && !K(e, n)) return { code: "range", message: "文本长度超出范围" };
|
|
81
|
+
}
|
|
82
|
+
function K(e, n) {
|
|
83
|
+
if (n.minLength === void 0 && n.maxLength === void 0) return !0;
|
|
84
|
+
let t = 0;
|
|
85
|
+
for (const i of e) t++;
|
|
86
|
+
return (n.minLength === void 0 || t >= n.minLength) && (n.maxLength === void 0 || t <= n.maxLength);
|
|
87
|
+
}
|
|
88
|
+
function g(e, n) {
|
|
89
|
+
const t = e ?? n;
|
|
90
|
+
if (!Number.isInteger(t) || t < 1) throw new Error("数据校验预算应为正整数");
|
|
91
|
+
return t;
|
|
92
|
+
}
|
|
93
|
+
function A(e, n, t) {
|
|
94
|
+
const i = Object.prototype.hasOwnProperty.call(e, n) ? e[n] : void 0;
|
|
95
|
+
if ((typeof i != "string" || !i.trim()) && !(typeof i == "number" && Number.isFinite(i))) return "业务主键应为非空字符串或有限数字";
|
|
96
|
+
const o = JSON.stringify([typeof i, i]);
|
|
97
|
+
if (t.has(o)) return "业务主键重复";
|
|
98
|
+
t.add(o);
|
|
99
|
+
}
|
|
100
|
+
function M(e, n, t = {}) {
|
|
101
|
+
h(n);
|
|
102
|
+
const i = t.path ?? "$.rows", o = [], m = g(t.maxIssues, 100);
|
|
103
|
+
if (!Array.isArray(e)) return { ok: !1, issues: [{ code: "row", path: i, message: "数据集应为对象数组" }] };
|
|
104
|
+
if (e.length > g(t.maxRows, 1e5) || e.length * n.fields.length > g(t.maxCells, 2e6)) return { ok: !1, issues: [{ code: "budget", path: i, message: "数据校验超出行数或单元格预算" }] };
|
|
105
|
+
const s = /* @__PURE__ */ new Set();
|
|
106
|
+
for (let r = 0; r < e.length && o.length < m; r++) {
|
|
107
|
+
const c = e[r];
|
|
108
|
+
if (!c || typeof c != "object" || Array.isArray(c)) {
|
|
109
|
+
o.push({ code: "row", path: `${i}[${r}]`, rowIndex: r, message: "行应为对象" });
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
N(c, n, r, i, s, o, m);
|
|
113
|
+
}
|
|
114
|
+
return { ok: o.length === 0, issues: o };
|
|
115
|
+
}
|
|
116
|
+
function N(e, n, t, i, o, m, s) {
|
|
117
|
+
for (const r of n.fields) {
|
|
118
|
+
if (m.length >= s) return;
|
|
119
|
+
const c = S(Object.prototype.hasOwnProperty.call(e, r.field) ? e[r.field] : void 0, r);
|
|
120
|
+
c && m.push({ ...c, rowIndex: t, field: r.field, path: `${i}[${t}].${r.field}` });
|
|
121
|
+
}
|
|
122
|
+
if (n.rowKey && m.length < s) {
|
|
123
|
+
const r = A(e, n.rowKey, o);
|
|
124
|
+
r && m.push({ code: "row-key", path: `${i}[${t}].${n.rowKey}`, message: r, rowIndex: t, field: n.rowKey });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function j(e) {
|
|
128
|
+
return h(e), { $schema: "https://json-schema.org/draft/2020-12/schema", type: "array", items: { type: "object", properties: Object.fromEntries(e.fields.map((t) => [t.field, R(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 } : {} };
|
|
129
|
+
}
|
|
130
|
+
function R(e, n) {
|
|
131
|
+
const t = !n && e.nullable !== !1 && !e.required;
|
|
132
|
+
return {
|
|
133
|
+
type: t ? [p(e.type), "null"] : p(e.type),
|
|
134
|
+
...e.label ? { title: e.label } : {},
|
|
135
|
+
...e.description ? { description: e.description } : {},
|
|
136
|
+
...e.type === "date" ? { format: "date" } : {},
|
|
137
|
+
...e.type === "decimal" ? { pattern: "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$" } : {},
|
|
138
|
+
...e.enum ? { enum: t ? [...e.enum, null] : [...e.enum] } : {},
|
|
139
|
+
...e.min === void 0 ? {} : { minimum: e.min },
|
|
140
|
+
...e.max === void 0 ? {} : { maximum: e.max },
|
|
141
|
+
...E(e, n),
|
|
142
|
+
...n && e.type === "text" ? { pattern: "\\S" } : {},
|
|
143
|
+
...e.unit ? { "x-report-unit": e.unit } : {},
|
|
144
|
+
...e.semanticRole ? { "x-report-semanticRole": e.semanticRole } : {},
|
|
145
|
+
...e.aggregation ? { "x-report-aggregation": e.aggregation } : {},
|
|
146
|
+
...e.format ? { "x-report-format": { ...e.format } } : {},
|
|
147
|
+
...e.missingMeaning ? { "x-report-missingMeaning": e.missingMeaning } : {},
|
|
148
|
+
...e.calculation ? { "x-report-calculation": { description: e.calculation.description, dependsOn: [...e.calculation.dependsOn] } } : {}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function E(e, n) {
|
|
152
|
+
const t = {};
|
|
153
|
+
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;
|
|
154
|
+
}
|
|
155
|
+
function p(e) {
|
|
156
|
+
return e === "text" || e === "date" || e === "decimal" ? "string" : e;
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
j as d,
|
|
160
|
+
M as v
|
|
161
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function u(e){throw new Error(`数据契约无效:${e}`)}function d(e){return typeof e=="string"&&e.trim().length>0&&e.length<=4096}function y(e){for(const n of["description","missingMeaning"])e[n]!==void 0&&!d(e[n])&&u(`${n} 应为 1–4096 位非空字符串`);e.aggregation!==void 0&&!["sum","avg","min","max","count","none"].includes(e.aggregation)&&u("未知字段聚合语义"),e.aggregation&&!["count","none"].includes(e.aggregation)&&!["number","decimal"].includes(e.type)&&u("数值聚合仅适用于 number/decimal"),e.format!==void 0&&l(e),e.calculation!==void 0&&(!e.calculation||!d(e.calculation.description)||!Array.isArray(e.calculation.dependsOn)||!e.calculation.dependsOn.length||e.calculation.dependsOn.length>256||e.calculation.dependsOn.some(n=>typeof n!="string"||!n.trim())||new Set(e.calculation.dependsOn).size!==e.calculation.dependsOn.length)&&u("计算说明需包含说明及 1–256 个唯一依赖字段")}function l(e){const n=e.format;if((!n||!["number","percent","date"].includes(n.kind))&&u("未知字段显示格式"),n.kind==="date"){(e.type!=="date"||n.pattern!==void 0&&(!d(n.pattern)||n.pattern.length>128))&&u("日期格式仅适用于日期,pattern 最多 128 位");return}["number","decimal"].includes(e.type)||u("数值显示格式仅适用于 number/decimal"),n.digits!==void 0&&(!Number.isSafeInteger(n.digits)||n.digits<0||n.digits>100)&&u("显示小数位应为 0–100 的整数"),n.kind==="number"&&n.thousands!==void 0&&typeof n.thousands!="boolean"&&u("thousands 应为布尔值")}function b(e){const n=new Map(e.map(i=>[i.field,i])),t=new Set;for(const i of e){const o=[{field:i.field,exit:!1}],m=new Set;for(;o.length;){const s=o.pop();if(s.exit){m.delete(s.field),t.add(s.field);continue}if(m.has(s.field)&&u("字段计算依赖存在循环"),t.has(s.field))continue;const r=n.get(s.field);r||u(`计算依赖字段未声明:${s.field}`),m.add(s.field),o.push({field:s.field,exit:!0});for(const c of r.calculation?.dependsOn??[])o.push({field:c,exit:!1})}}}const x=["text","number","boolean","date","decimal"],w=new Set(["__proto__","prototype","constructor"]);function a(e){throw new Error(`数据契约无效:${e}`)}function h(e){(!e||!Array.isArray(e.fields)||!e.fields.length||e.fields.length>2048)&&a("fields 应包含 1–2048 个字段");const n=new Set;for(const t of e.fields)(!t||typeof t.field!="string"||!t.field.trim()||w.has(t.field)||n.has(t.field))&&a("字段名应安全、非空且唯一"),n.add(t.field),x.includes(t.type)||a(`未知字段类型 ${t.type}`),k(t),$(t),y(t),v(t);L(e,n),b(e.fields)}function v(e){e.enum!==void 0&&(!Array.isArray(e.enum)||!e.enum.length||e.enum.some(n=>!f(n,e.type)))&&a("enum 应为匹配字段类型的非空标量数组")}function L(e,n){e.rowKey!==void 0&&((typeof e.rowKey!="string"||!e.rowKey.trim()||!n.has(e.rowKey))&&a("rowKey 应为引用已声明字段的非空字符串"),e.fields.find(t=>t.field===e.rowKey)?.type==="boolean"&&a("布尔字段不能作为业务主键"))}function $(e){for(const n of["label","unit"])e[n]!==void 0&&typeof e[n]!="string"&&a(`${n} 应为字符串`);for(const n of["required","nullable"])e[n]!==void 0&&typeof e[n]!="boolean"&&a(`${n} 应为布尔值`);e.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(e.semanticRole)&&a("未知字段语义")}function k(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))&&a(`${n} 无效`)}e.min!==void 0&&e.max!==void 0&&e.min>e.max&&a("min 不能超过 max"),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&a("minLength 不能超过 maxLength"),e.type!=="number"&&(e.min!==void 0||e.max!==void 0)&&a("min/max 仅适用于 number,精确小数文本需业务校验"),["number","boolean"].includes(e.type)&&(e.minLength!==void 0||e.maxLength!==void 0)&&a("长度约束仅适用于文本类型")}function S(e){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!n)return!1;const t=Number(n[1]),i=Number(n[2]),o=Number(n[3]),m=t%4===0&&(t%100!==0||t%400===0);return t>0&&i>=1&&i<=12&&o>=1&&o<=[31,m?29:28,31,30,31,30,31,31,30,31,30,31][i-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"?S(e):n==="decimal"?e.length<=1e4&&/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(e):!0}function O(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"&&!K(e,n))return{code:"range",message:"文本长度超出范围"}}function K(e,n){if(n.minLength===void 0&&n.maxLength===void 0)return!0;let t=0;for(const i of e)t++;return(n.minLength===void 0||t>=n.minLength)&&(n.maxLength===void 0||t<=n.maxLength)}function g(e,n){const t=e??n;if(!Number.isInteger(t)||t<1)throw new Error("数据校验预算应为正整数");return t}function A(e,n,t){const i=Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0;if((typeof i!="string"||!i.trim())&&!(typeof i=="number"&&Number.isFinite(i)))return"业务主键应为非空字符串或有限数字";const o=JSON.stringify([typeof i,i]);if(t.has(o))return"业务主键重复";t.add(o)}function N(e,n,t={}){h(n);const i=t.path??"$.rows",o=[],m=g(t.maxIssues,100);if(!Array.isArray(e))return{ok:!1,issues:[{code:"row",path:i,message:"数据集应为对象数组"}]};if(e.length>g(t.maxRows,1e5)||e.length*n.fields.length>g(t.maxCells,2e6))return{ok:!1,issues:[{code:"budget",path:i,message:"数据校验超出行数或单元格预算"}]};const s=new Set;for(let r=0;r<e.length&&o.length<m;r++){const c=e[r];if(!c||typeof c!="object"||Array.isArray(c)){o.push({code:"row",path:`${i}[${r}]`,rowIndex:r,message:"行应为对象"});continue}R(c,n,r,i,s,o,m)}return{ok:o.length===0,issues:o}}function R(e,n,t,i,o,m,s){for(const r of n.fields){if(m.length>=s)return;const c=O(Object.prototype.hasOwnProperty.call(e,r.field)?e[r.field]:void 0,r);c&&m.push({...c,rowIndex:t,field:r.field,path:`${i}[${t}].${r.field}`})}if(n.rowKey&&m.length<s){const r=A(e,n.rowKey,o);r&&m.push({code:"row-key",path:`${i}[${t}].${n.rowKey}`,message:r,rowIndex:t,field:n.rowKey})}}function E(e){return h(e),{$schema:"https://json-schema.org/draft/2020-12/schema",type:"array",items:{type:"object",properties:Object.fromEntries(e.fields.map(t=>[t.field,M(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 M(e,n){const t=!n&&e.nullable!==!1&&!e.required;return{type:t?[p(e.type),"null"]:p(e.type),...e.label?{title:e.label}:{},...e.description?{description:e.description}:{},...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},...j(e,n),...n&&e.type==="text"?{pattern:"\\S"}:{},...e.unit?{"x-report-unit":e.unit}:{},...e.semanticRole?{"x-report-semanticRole":e.semanticRole}:{},...e.aggregation?{"x-report-aggregation":e.aggregation}:{},...e.format?{"x-report-format":{...e.format}}:{},...e.missingMeaning?{"x-report-missingMeaning":e.missingMeaning}:{},...e.calculation?{"x-report-calculation":{description:e.calculation.description,dependsOn:[...e.calculation.dependsOn]}}:{}}}function j(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 p(e){return e==="text"||e==="date"||e==="decimal"?"string":e}exports.datasetJsonSchema=E;exports.validateDatasetRows=N;
|