@agile-team/mach-report 2.25.2 → 2.26.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 +12 -8
- package/dist/ExcelBindingWizard-B418l44t.js +1578 -0
- package/dist/ExcelBindingWizard-C4FGVsY_.cjs +1 -0
- package/dist/{ParamEditor-CGfaweYX.cjs → ParamEditor-BemJE8n8.cjs} +1 -1
- package/dist/{ParamEditor-B7YVD28E.js → ParamEditor-XvMtf_XQ.js} +2 -2
- package/dist/{ReportBatchPanel-BRJt0TXp.cjs → ReportBatchPanel-CbY4fvXD.cjs} +1 -1
- package/dist/{ReportBatchPanel-BTKHtLTW.js → ReportBatchPanel-Ds0R_uXn.js} +37 -37
- package/dist/{ReportLabelStudio-BvK_WBke.cjs → ReportLabelStudio-DuTwN5er.cjs} +1 -1
- package/dist/{ReportLabelStudio-CZwqyO3t.js → ReportLabelStudio-ZFy79eRv.js} +26 -26
- package/dist/ReportParamPanel-Chxu4MTx.cjs +1 -0
- package/dist/{ReportParamPanel-DGXzBzl2.js → ReportParamPanel-Czm3OPo_.js} +216 -205
- package/dist/{ReportPreview-D1ZC5kzz.js → ReportPreview-C9c0Rp7Y.js} +2938 -2875
- package/dist/ReportPreview-CIMR4ERo.cjs +6 -0
- package/dist/{ReportTemplateLibrary-ClwxhnC0.cjs → ReportTemplateLibrary-C6lByc69.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-C7sB0Jay.js → ReportTemplateLibrary-XJVoTDIz.js} +1 -1
- package/dist/{RuleEditor-CsDGFaWz.js → RuleEditor-CeNFPeOc.js} +5 -5
- package/dist/{RuleEditor-D-OdaGdR.cjs → RuleEditor-gggUkEwB.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-DAqR9zQi.cjs → TemplateOutlinePanel-B0e-umq2.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-CXOT7d1r.js → TemplateOutlinePanel-BWN4Y9iz.js} +2 -2
- package/dist/{TemplateReusePanel-Dcfx3Hba.js → TemplateReusePanel-CR-4OHoU.js} +2 -2
- package/dist/{TemplateReusePanel-ygIi-Ajz.cjs → TemplateReusePanel-Cthig1S1.cjs} +1 -1
- package/dist/{TemplateReviewPanel-COU8FqPq.js → TemplateReviewPanel-BkWzyNL4.js} +2 -2
- package/dist/{TemplateReviewPanel-DyGULVxr.cjs → TemplateReviewPanel-D8o2gDaK.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.js +5 -5
- package/dist/artifact-integrity.json +106 -102
- package/dist/{assets-C4MIvzQ4.js → assets-BFTP-0WR.js} +2 -2
- package/dist/{assets-BYdpkTIt.cjs → assets-CZiZhTf2.cjs} +1 -1
- package/dist/{auto-j7mr8Kvc.js → auto-C7udkeAa.js} +20 -19
- package/dist/auto-CXd2E2aZ.cjs +1 -0
- package/dist/capabilities-D8UU2clQ.cjs +1 -0
- package/dist/{capabilities-CN_kSVjO.js → capabilities-g0a2j9Yy.js} +50 -46
- package/dist/{charts-Cjw5AYkg.cjs → charts-D-Vg-ak9.cjs} +1 -1
- package/dist/{charts-CxJZ0XaY.js → charts-D48XCefN.js} +1 -1
- package/dist/computed-BQgBrma-.cjs +1 -0
- package/dist/{computed-f3pOqWLX.js → computed-CH3NYPOW.js} +198 -188
- package/dist/{data-bar-Bfh54sT4.js → data-bar-DjOgTLqu.js} +1 -1
- package/dist/{dataset-DL83majE.js → dataset-B8oTsC6o.js} +69 -66
- package/dist/dataset-D3OsyzG1.cjs +1 -0
- package/dist/designer-COuSUxZ1.cjs +2 -0
- package/dist/designer-CT4mlrr0.js +7997 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +83 -4
- package/dist/designer.d.ts +83 -4
- package/dist/designer.js +4 -4
- package/dist/{diagnostic-collector-gB07PHy2.js → diagnostic-collector-C-JBA016.js} +2 -2
- package/dist/dom-DgWc-DY1.js +452 -0
- package/dist/dom-Fk4NF-gN.cjs +1 -0
- package/dist/{encoding-BWEMdzFG.js → encoding-D480EM2r.js} +2 -2
- package/dist/{encoding-DVea2qIR.cjs → encoding-tWc2Wn89.cjs} +1 -1
- package/dist/execution-result-7sG_mdcD.cjs +1 -0
- package/dist/execution-result-Ba65gieT.js +39 -0
- package/dist/{font-loader-p_SyTvqt.cjs → font-loader-BIxme_9g.cjs} +1 -1
- package/dist/{font-loader-D4NLIKJL.js → font-loader-CHmEwkHl.js} +1 -1
- package/dist/{grid-strokes-DkZEZvcI.js → grid-strokes-DsoICRjZ.js} +1 -1
- package/dist/import-range-BwT86Z3j.cjs +1 -0
- package/dist/import-range-D9p_blcb.js +98 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +25 -25
- package/dist/{json-snapshot-DdzALe8q.js → json-snapshot-BZ0CIQln.js} +1041 -887
- package/dist/json-snapshot-DGFeI30h.cjs +2 -0
- package/dist/{matrix-b6T291xo.js → matrix-CB9TqTEy.js} +1 -1
- package/dist/{matrix-DUYPRL7t.cjs → matrix-CcqYOuq_.cjs} +1 -1
- package/dist/{pdf-DU8HelKd.js → pdf-DTR7fAIr.js} +3596 -3517
- package/dist/{pdf-C060D5UY.cjs → pdf-d9oJ6V0P.cjs} +49 -49
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-D5BRHlne.cjs → plugin-B7Bi-1te.cjs} +1 -1
- package/dist/{plugin-FWhTnjr0.js → plugin-OKDFQFS4.js} +1 -1
- package/dist/{prefill-m01IM1hl.js → prefill-C8fF91JB.js} +3 -3
- package/dist/{prefill-DZymomY6.cjs → prefill-C_Bf_AMo.cjs} +1 -1
- package/dist/{prepared-BHu8bIdj.cjs → prepared-BLhV7vdE.cjs} +1 -1
- package/dist/{prepared-DO5pe6Ed.js → prepared-DhgQ0d-h.js} +7 -7
- package/dist/protocol-CZ-BILne.cjs +1 -0
- package/dist/{protocol-CZddmu2n.js → protocol-DHO91-Jt.js} +3 -3
- package/dist/{record-bindings-Cv7lFiof.js → record-bindings-DBrCu6zO.js} +3 -3
- package/dist/{record-bindings-B7djSjNs.cjs → record-bindings-KEs-DKCS.cjs} +1 -1
- package/dist/region-binding-workflow-FSyIZge8.js +882 -0
- package/dist/region-binding-workflow-ikpY1Kbw.cjs +3 -0
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/rich-text-layout-BYbIc3eJ.cjs +3 -0
- package/dist/rich-text-layout-BtygMWZC.js +96 -0
- package/dist/runtime-B5HG8poy.cjs +1 -0
- package/dist/runtime-BsvAqz4a.js +204 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +2049 -1889
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +35 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.js +340 -328
- package/dist/style.css +1 -1
- package/dist/{template-catalog-DLu814zA.js → template-catalog-BbrN9dgu.js} +5 -5
- package/dist/{template-catalog-Lil5Ryt-.cjs → template-catalog-DDH-5J57.cjs} +1 -1
- package/dist/{template-fragments-BDxdCuMD.js → template-fragments-CUTE8-_I.js} +3 -3
- package/dist/{template-fragments-DbKdxI1z.cjs → template-fragments-cyAQu7aw.cjs} +1 -1
- package/dist/{template-registry-B-AK1oam.cjs → template-registry-D24Z8aQf.cjs} +1 -1
- package/dist/{template-registry-DeVgwEZj.js → template-registry-PSuLsnyq.js} +4 -4
- package/dist/{template-serialization-CqQY4zDg.cjs → template-serialization-BOUidUlh.cjs} +1 -1
- package/dist/{template-serialization-CWmHq7lX.js → template-serialization-BgGWYV_1.js} +1 -1
- package/dist/{textwrap-BywMBMXM.js → textwrap-Bt_tnI6V.js} +1 -1
- package/dist/vue/async.d.cts +46 -3
- package/dist/vue/async.d.ts +46 -3
- package/dist/vue/index.d.cts +215 -24
- package/dist/vue/index.d.ts +215 -24
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +433 -202
- package/dist/workbook-session-BJfZVp4q.cjs +29 -0
- package/dist/{workbook-session-B6hRjTyX.js → workbook-session-DRnMjIFK.js} +2377 -2350
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +1 -1
- package/dist/xlsx.d.cts +27 -2
- package/dist/xlsx.d.ts +27 -2
- package/dist/xlsx.js +15 -15
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-bs3F4dD8.js +0 -1486
- package/dist/ExcelBindingWizard-jSdjBtWw.cjs +0 -1
- package/dist/ReportParamPanel-B27IGJjk.cjs +0 -1
- package/dist/ReportPreview-DAU-V3Ov.cjs +0 -6
- package/dist/auto-DjmvmcX-.cjs +0 -1
- package/dist/capabilities-D4nfhcvB.cjs +0 -1
- package/dist/computed-DK6BruFz.cjs +0 -1
- package/dist/dataset-IrlXbUvh.cjs +0 -1
- package/dist/designer-B597ZdC0.js +0 -7595
- package/dist/designer-DFIdv_n7.cjs +0 -2
- package/dist/dom-CXWMmwh-.cjs +0 -1
- package/dist/dom-DxdCMLzs.js +0 -452
- package/dist/json-snapshot-L_gJ7KRS.cjs +0 -2
- package/dist/protocol-CymmHWmL.cjs +0 -1
- package/dist/region-binding-workflow-EYxvUYJ-.js +0 -977
- package/dist/region-binding-workflow-NdkMSFCh.cjs +0 -3
- package/dist/rich-text-layout-Ch_N0Ubu.js +0 -52
- package/dist/rich-text-layout-yJGuThtC.cjs +0 -3
- package/dist/runtime-D8AlfJ6S.js +0 -234
- package/dist/runtime-ywf3oLBR.cjs +0 -1
- package/dist/workbook-session-BclW7KKH.cjs +0 -29
|
@@ -1,136 +1,138 @@
|
|
|
1
|
-
function
|
|
1
|
+
function c(e) {
|
|
2
2
|
throw new Error(`数据契约无效:${e}`);
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function p(e) {
|
|
5
5
|
return typeof e == "string" && e.trim().length > 0 && e.length <= 4096;
|
|
6
6
|
}
|
|
7
7
|
function y(e) {
|
|
8
|
-
for (const n of ["description", "missingMeaning"]) e[n] !== void 0 && !
|
|
9
|
-
e.aggregation !== void 0 && !["sum", "avg", "min", "max", "count", "none"].includes(e.aggregation) &&
|
|
8
|
+
for (const n of ["description", "missingMeaning"]) e[n] !== void 0 && !p(e[n]) && c(`${n} 应为 1–4096 位非空字符串`);
|
|
9
|
+
e.aggregation !== void 0 && !["sum", "avg", "min", "max", "count", "none"].includes(e.aggregation) && c("未知字段聚合语义"), e.aggregation && !["count", "none"].includes(e.aggregation) && !["number", "decimal"].includes(e.type) && c("数值聚合仅适用于 number/decimal"), e.format !== void 0 && x(e), e.calculation !== void 0 && (!e.calculation || !p(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) && c("计算说明需包含说明及 1–256 个唯一依赖字段");
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function x(e) {
|
|
12
12
|
const n = e.format;
|
|
13
|
-
if ((!n || !["number", "percent", "date"].includes(n.kind)) &&
|
|
14
|
-
(e.type !== "date" || n.pattern !== void 0 && (!
|
|
13
|
+
if ((!n || !["number", "percent", "date"].includes(n.kind)) && c("未知字段显示格式"), n.kind === "date") {
|
|
14
|
+
(e.type !== "date" || n.pattern !== void 0 && (!p(n.pattern) || n.pattern.length > 128)) && c("日期格式仅适用于日期,pattern 最多 128 位");
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
["number", "decimal"].includes(e.type) ||
|
|
17
|
+
["number", "decimal"].includes(e.type) || c("数值显示格式仅适用于 number/decimal"), n.digits !== void 0 && (!Number.isSafeInteger(n.digits) || n.digits < 0 || n.digits > 100) && c("显示小数位应为 0–100 的整数"), n.kind === "number" && n.thousands !== void 0 && typeof n.thousands != "boolean" && c("thousands 应为布尔值");
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function b(e) {
|
|
20
20
|
const n = new Map(e.map((i) => [i.field, i])), t = /* @__PURE__ */ new Set();
|
|
21
21
|
for (const i of e) {
|
|
22
|
-
const o = [{ field: i.field, exit: !1 }],
|
|
22
|
+
const o = [{ field: i.field, exit: !1 }], r = /* @__PURE__ */ new Set();
|
|
23
23
|
for (; o.length; ) {
|
|
24
24
|
const s = o.pop();
|
|
25
25
|
if (s.exit) {
|
|
26
|
-
|
|
26
|
+
r.delete(s.field), t.add(s.field);
|
|
27
27
|
continue;
|
|
28
28
|
}
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
for (const
|
|
29
|
+
if (r.has(s.field) && c("字段计算依赖存在循环"), t.has(s.field)) continue;
|
|
30
|
+
const m = n.get(s.field);
|
|
31
|
+
m || c(`计算依赖字段未声明:${s.field}`), r.add(s.field), o.push({ field: s.field, exit: !0 });
|
|
32
|
+
for (const u of m.calculation?.dependsOn ?? []) o.push({ field: u, exit: !1 });
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const w = ["text", "number", "boolean", "date", "decimal"], v = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
37
37
|
function a(e) {
|
|
38
38
|
throw new Error(`数据契约无效:${e}`);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function f(e) {
|
|
41
41
|
(!e || !Array.isArray(e.fields) || !e.fields.length || e.fields.length > 2048) && a("fields 应包含 1–2048 个字段");
|
|
42
42
|
const n = /* @__PURE__ */ new Set();
|
|
43
43
|
for (const t of e.fields)
|
|
44
|
-
(!t || typeof t.field != "string" || !t.field.trim() ||
|
|
45
|
-
|
|
44
|
+
(!t || typeof t.field != "string" || !t.field.trim() || v.has(t.field) || n.has(t.field)) && a("字段名应安全、非空且唯一"), n.add(t.field), w.includes(t.type) || a(`未知字段类型 ${t.type}`), O(t), k(t), y(t), L(t);
|
|
45
|
+
$(e, n), b(e.fields);
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
e.enum !== void 0 && (!Array.isArray(e.enum) || !e.enum.length || e.enum.some((n) => !
|
|
47
|
+
function L(e) {
|
|
48
|
+
e.enum !== void 0 && (!Array.isArray(e.enum) || !e.enum.length || e.enum.some((n) => !l(n, e.type))) && a("enum 应为匹配字段类型的非空标量数组");
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function $(e, n) {
|
|
51
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
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function k(e) {
|
|
54
54
|
for (const n of ["label", "unit"]) e[n] !== void 0 && typeof e[n] != "string" && a(`${n} 应为字符串`);
|
|
55
55
|
for (const n of ["required", "nullable"]) e[n] !== void 0 && typeof e[n] != "boolean" && a(`${n} 应为布尔值`);
|
|
56
56
|
e.semanticRole !== void 0 && !["identifier", "dimension", "measure", "date", "text"].includes(e.semanticRole) && a("未知字段语义");
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function O(e) {
|
|
59
59
|
for (const n of ["min", "max", "minLength", "maxLength"]) {
|
|
60
60
|
const t = e[n];
|
|
61
61
|
t !== void 0 && (!Number.isFinite(t) || n.includes("Length") && (!Number.isInteger(t) || t < 0)) && a(`${n} 无效`);
|
|
62
62
|
}
|
|
63
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
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function S(e) {
|
|
66
66
|
const n = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
67
67
|
if (!n) return !1;
|
|
68
|
-
const t = Number(n[1]), i = Number(n[2]), o = Number(n[3]),
|
|
69
|
-
return t > 0 && i >= 1 && i <= 12 && o >= 1 && o <= [31,
|
|
68
|
+
const t = Number(n[1]), i = Number(n[2]), o = Number(n[3]), r = t % 4 === 0 && (t % 100 !== 0 || t % 400 === 0);
|
|
69
|
+
return t > 0 && i >= 1 && i <= 12 && o >= 1 && o <= [31, r ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][i - 1];
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return n === "number" ? typeof e == "number" && Number.isFinite(e) : n === "boolean" ? typeof e == "boolean" : typeof e != "string" ? !1 : n === "date" ?
|
|
71
|
+
function l(e, n) {
|
|
72
|
+
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;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function K(e, n) {
|
|
75
75
|
if (e == null)
|
|
76
76
|
return n.required || e === null && n.nullable === !1 ? { code: "required", message: "缺少必需字段值" } : void 0;
|
|
77
|
-
if (!
|
|
77
|
+
if (!l(e, n.type)) return { code: "type", message: `值应为 ${n.type},不会自动转换原始值` };
|
|
78
78
|
if (n.enum && !n.enum.includes(e)) return { code: "enum", message: "值不在允许的枚举中" };
|
|
79
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" && !
|
|
80
|
+
if (typeof e == "string" && !A(e, n)) return { code: "range", message: "文本长度超出范围" };
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function A(e, n) {
|
|
83
83
|
if (n.minLength === void 0 && n.maxLength === void 0) return !0;
|
|
84
84
|
let t = 0;
|
|
85
85
|
for (const i of e) t++;
|
|
86
86
|
return (n.minLength === void 0 || t >= n.minLength) && (n.maxLength === void 0 || t <= n.maxLength);
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function d(e, n) {
|
|
89
89
|
const t = e ?? n;
|
|
90
90
|
if (!Number.isInteger(t) || t < 1) throw new Error("数据校验预算应为正整数");
|
|
91
91
|
return t;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function N(e, n, t) {
|
|
94
94
|
const i = Object.prototype.hasOwnProperty.call(e, n) ? e[n] : void 0;
|
|
95
95
|
if ((typeof i != "string" || !i.trim()) && !(typeof i == "number" && Number.isFinite(i))) return "业务主键应为非空字符串或有限数字";
|
|
96
96
|
const o = JSON.stringify([typeof i, i]);
|
|
97
97
|
if (t.has(o)) return "业务主键重复";
|
|
98
98
|
t.add(o);
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
function F(e, n, t = {}) {
|
|
101
|
+
const i = R(e, n, t, !1);
|
|
102
|
+
let o = i.next();
|
|
103
|
+
for (; !o.done; ) o = i.next();
|
|
104
|
+
return o.value;
|
|
105
|
+
}
|
|
106
|
+
function* R(e, n, t = {}, i = !0) {
|
|
107
|
+
f(n);
|
|
108
|
+
const o = t.path ?? "$.rows", r = [], s = d(t.maxIssues, 100);
|
|
109
|
+
if (!Array.isArray(e)) return { ok: !1, issues: [{ code: "row", path: o, message: "数据集应为对象数组" }] };
|
|
110
|
+
if (e.length > d(t.maxRows, 1e5) || e.length * n.fields.length > d(t.maxCells, 2e6)) return { ok: !1, issues: [{ code: "budget", path: o, message: "数据校验超出行数或单元格预算" }] };
|
|
111
|
+
const m = /* @__PURE__ */ new Set();
|
|
112
|
+
for (let u = 0; u < e.length && r.length < s; u++) {
|
|
113
|
+
const g = e[u];
|
|
114
|
+
!g || typeof g != "object" || Array.isArray(g) ? r.push({ code: "row", path: `${o}[${u}]`, rowIndex: u, message: "行应为对象" }) : E(g, n, u, o, m, r, s), i && (yield);
|
|
113
115
|
}
|
|
114
|
-
return { ok:
|
|
116
|
+
return { ok: r.length === 0, issues: r };
|
|
115
117
|
}
|
|
116
|
-
function
|
|
117
|
-
for (const
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
|
|
118
|
+
function E(e, n, t, i, o, r, s) {
|
|
119
|
+
for (const m of n.fields) {
|
|
120
|
+
if (r.length >= s) return;
|
|
121
|
+
const u = K(Object.prototype.hasOwnProperty.call(e, m.field) ? e[m.field] : void 0, m);
|
|
122
|
+
u && r.push({ ...u, rowIndex: t, field: m.field, path: `${i}[${t}].${m.field}` });
|
|
121
123
|
}
|
|
122
|
-
if (n.rowKey &&
|
|
123
|
-
const
|
|
124
|
-
|
|
124
|
+
if (n.rowKey && r.length < s) {
|
|
125
|
+
const m = N(e, n.rowKey, o);
|
|
126
|
+
m && r.push({ code: "row-key", path: `${i}[${t}].${n.rowKey}`, message: m, rowIndex: t, field: n.rowKey });
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
|
-
function
|
|
128
|
-
return
|
|
129
|
+
function q(e) {
|
|
130
|
+
return f(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 } : {} };
|
|
129
131
|
}
|
|
130
|
-
function
|
|
132
|
+
function M(e, n) {
|
|
131
133
|
const t = !n && e.nullable !== !1 && !e.required;
|
|
132
134
|
return {
|
|
133
|
-
type: t ? [
|
|
135
|
+
type: t ? [h(e.type), "null"] : h(e.type),
|
|
134
136
|
...e.label ? { title: e.label } : {},
|
|
135
137
|
...e.description ? { description: e.description } : {},
|
|
136
138
|
...e.type === "date" ? { format: "date" } : {},
|
|
@@ -138,7 +140,7 @@ function R(e, n) {
|
|
|
138
140
|
...e.enum ? { enum: t ? [...e.enum, null] : [...e.enum] } : {},
|
|
139
141
|
...e.min === void 0 ? {} : { minimum: e.min },
|
|
140
142
|
...e.max === void 0 ? {} : { maximum: e.max },
|
|
141
|
-
...
|
|
143
|
+
...j(e, n),
|
|
142
144
|
...n && e.type === "text" ? { pattern: "\\S" } : {},
|
|
143
145
|
...e.unit ? { "x-report-unit": e.unit } : {},
|
|
144
146
|
...e.semanticRole ? { "x-report-semanticRole": e.semanticRole } : {},
|
|
@@ -148,14 +150,15 @@ function R(e, n) {
|
|
|
148
150
|
...e.calculation ? { "x-report-calculation": { description: e.calculation.description, dependsOn: [...e.calculation.dependsOn] } } : {}
|
|
149
151
|
};
|
|
150
152
|
}
|
|
151
|
-
function
|
|
153
|
+
function j(e, n) {
|
|
152
154
|
const t = {};
|
|
153
155
|
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
156
|
}
|
|
155
|
-
function
|
|
157
|
+
function h(e) {
|
|
156
158
|
return e === "text" || e === "date" || e === "decimal" ? "string" : e;
|
|
157
159
|
}
|
|
158
160
|
export {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
q as d,
|
|
162
|
+
R as i,
|
|
163
|
+
F as v
|
|
161
164
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function c(e){throw new Error(`数据契约无效:${e}`)}function h(e){return typeof e=="string"&&e.trim().length>0&&e.length<=4096}function x(e){for(const n of["description","missingMeaning"])e[n]!==void 0&&!h(e[n])&&c(`${n} 应为 1–4096 位非空字符串`);e.aggregation!==void 0&&!["sum","avg","min","max","count","none"].includes(e.aggregation)&&c("未知字段聚合语义"),e.aggregation&&!["count","none"].includes(e.aggregation)&&!["number","decimal"].includes(e.type)&&c("数值聚合仅适用于 number/decimal"),e.format!==void 0&&b(e),e.calculation!==void 0&&(!e.calculation||!h(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)&&c("计算说明需包含说明及 1–256 个唯一依赖字段")}function b(e){const n=e.format;if((!n||!["number","percent","date"].includes(n.kind))&&c("未知字段显示格式"),n.kind==="date"){(e.type!=="date"||n.pattern!==void 0&&(!h(n.pattern)||n.pattern.length>128))&&c("日期格式仅适用于日期,pattern 最多 128 位");return}["number","decimal"].includes(e.type)||c("数值显示格式仅适用于 number/decimal"),n.digits!==void 0&&(!Number.isSafeInteger(n.digits)||n.digits<0||n.digits>100)&&c("显示小数位应为 0–100 的整数"),n.kind==="number"&&n.thousands!==void 0&&typeof n.thousands!="boolean"&&c("thousands 应为布尔值")}function w(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}],r=new Set;for(;o.length;){const s=o.pop();if(s.exit){r.delete(s.field),t.add(s.field);continue}if(r.has(s.field)&&c("字段计算依赖存在循环"),t.has(s.field))continue;const m=n.get(s.field);m||c(`计算依赖字段未声明:${s.field}`),r.add(s.field),o.push({field:s.field,exit:!0});for(const u of m.calculation?.dependsOn??[])o.push({field:u,exit:!1})}}}const v=["text","number","boolean","date","decimal"],L=new Set(["__proto__","prototype","constructor"]);function a(e){throw new Error(`数据契约无效:${e}`)}function f(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()||L.has(t.field)||n.has(t.field))&&a("字段名应安全、非空且唯一"),n.add(t.field),v.includes(t.type)||a(`未知字段类型 ${t.type}`),O(t),S(t),x(t),$(t);k(e,n),w(e.fields)}function $(e){e.enum!==void 0&&(!Array.isArray(e.enum)||!e.enum.length||e.enum.some(n=>!l(n,e.type)))&&a("enum 应为匹配字段类型的非空标量数组")}function k(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 S(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 O(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 K(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]),r=t%4===0&&(t%100!==0||t%400===0);return t>0&&i>=1&&i<=12&&o>=1&&o<=[31,r?29:28,31,30,31,30,31,31,30,31,30,31][i-1]}function l(e,n){return n==="number"?typeof e=="number"&&Number.isFinite(e):n==="boolean"?typeof e=="boolean":typeof e!="string"?!1:n==="date"?K(e):n==="decimal"?e.length<=1e4&&/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(e):!0}function A(e,n){if(e==null)return n.required||e===null&&n.nullable===!1?{code:"required",message:"缺少必需字段值"}:void 0;if(!l(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"&&!N(e,n))return{code:"range",message:"文本长度超出范围"}}function N(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 d(e,n){const t=e??n;if(!Number.isInteger(t)||t<1)throw new Error("数据校验预算应为正整数");return t}function R(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 E(e,n,t={}){const i=y(e,n,t,!1);let o=i.next();for(;!o.done;)o=i.next();return o.value}function*y(e,n,t={},i=!0){f(n);const o=t.path??"$.rows",r=[],s=d(t.maxIssues,100);if(!Array.isArray(e))return{ok:!1,issues:[{code:"row",path:o,message:"数据集应为对象数组"}]};if(e.length>d(t.maxRows,1e5)||e.length*n.fields.length>d(t.maxCells,2e6))return{ok:!1,issues:[{code:"budget",path:o,message:"数据校验超出行数或单元格预算"}]};const m=new Set;for(let u=0;u<e.length&&r.length<s;u++){const g=e[u];!g||typeof g!="object"||Array.isArray(g)?r.push({code:"row",path:`${o}[${u}]`,rowIndex:u,message:"行应为对象"}):M(g,n,u,o,m,r,s),i&&(yield)}return{ok:r.length===0,issues:r}}function M(e,n,t,i,o,r,s){for(const m of n.fields){if(r.length>=s)return;const u=A(Object.prototype.hasOwnProperty.call(e,m.field)?e[m.field]:void 0,m);u&&r.push({...u,rowIndex:t,field:m.field,path:`${i}[${t}].${m.field}`})}if(n.rowKey&&r.length<s){const m=R(e,n.rowKey,o);m&&r.push({code:"row-key",path:`${i}[${t}].${n.rowKey}`,message:m,rowIndex:t,field:n.rowKey})}}function j(e){return f(e),{$schema:"https://json-schema.org/draft/2020-12/schema",type:"array",items:{type:"object",properties:Object.fromEntries(e.fields.map(t=>[t.field,F(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 F(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},...q(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 q(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=j;exports.iterateDatasetValidation=y;exports.validateDatasetRows=E;
|