@agile-team/mach-report 2.17.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 +18 -9
- package/dist/{ExcelBindingWizard-Bq6FYME6.cjs → ExcelBindingWizard-Czn3C2yE.cjs} +1 -1
- package/dist/{ExcelBindingWizard-Co1svTsw.js → ExcelBindingWizard-DMGZj6I6.js} +3 -3
- package/dist/ParamEditor-KzDQvbHY.js +732 -0
- package/dist/ParamEditor-oDfD8LgE.cjs +1 -0
- package/dist/{ReportBatchPanel-uQh06usx.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-TIL_Oj2l.js → ReportTemplateLibrary-BFjB08Wu.js} +1 -1
- package/dist/{ReportTemplateLibrary-CnP7_1pH.cjs → ReportTemplateLibrary-BO42QnWd.cjs} +1 -1
- package/dist/RuleEditor-CqxT1a-W.js +2337 -0
- package/dist/RuleEditor-D7YWigD9.cjs +1 -0
- package/dist/{TemplateOutlinePanel-BlLxRrfu.cjs → TemplateOutlinePanel-B0XX350V.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-BouxsuqQ.js → TemplateOutlinePanel-zG0DrsIB.js} +2 -2
- package/dist/{TemplateReusePanel-yxsHSO40.cjs → TemplateReusePanel-BD0HSKp_.cjs} +1 -1
- package/dist/{TemplateReusePanel-BEACLPaN.js → TemplateReusePanel-Czwe5GbC.js} +2 -2
- package/dist/{TemplateReviewPanel-D9Cx0m2N.cjs → TemplateReviewPanel-CA5sdffM.cjs} +1 -1
- package/dist/{TemplateReviewPanel-B1OGRY2i.js → TemplateReviewPanel-NhmQI65C.js} +2 -2
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +100 -41
- package/dist/analytics.d.ts +100 -41
- package/dist/analytics.js +76 -141
- package/dist/artifact-integrity.json +108 -102
- package/dist/assets-2eC3mOcV.js +232 -0
- package/dist/assets-B0Hxn4l6.cjs +1 -0
- package/dist/{auto-DDHflI9v.cjs → auto-B0EZFIK1.cjs} +1 -1
- package/dist/{auto-BIOmtVhk.js → auto-BlchZ1b8.js} +19 -19
- 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/designer--TKECSEc.cjs +2 -0
- package/dist/designer-d6hJS41w.js +5683 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +710 -42
- package/dist/designer.d.ts +710 -42
- package/dist/designer.js +23 -20
- package/dist/{encoding-BFMFIc4r.cjs → encoding-B--eZpp1.cjs} +1 -1
- package/dist/{encoding-DP_Eaf0A.js → encoding-mctOLocI.js} +2 -2
- package/dist/{font-loader-7FWVlykp.cjs → font-loader-DBBJ5KE9.cjs} +1 -1
- package/dist/{font-loader-CQZowp0I.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 +7 -7
- package/dist/index.d.cts +361 -15
- package/dist/index.d.ts +361 -15
- package/dist/index.js +876 -835
- 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-l3ea86di.js → pdf-CKROKygt.js} +1851 -1849
- package/dist/{pdf-B8JouyYv.cjs → pdf-DqyxJ96U.cjs} +46 -46
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +54 -0
- package/dist/pdf.d.ts +54 -0
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BBp74CQZ.js → plugin-ByjF2kiV.js} +5 -5
- package/dist/{plugin-CtFX9PFG.cjs → plugin-DM1M2wlI.cjs} +1 -1
- package/dist/prefill-B8H9qwE4.js +371 -0
- package/dist/prefill-D7EswyTI.cjs +1 -0
- package/dist/{prepared-CARicKYh.js → prepared-BE-4jfX5.js} +2 -2
- package/dist/{prepared-Ch1x_Gog.cjs → prepared-CGVphji3.cjs} +1 -1
- package/dist/{protocol-B5A2uom4.cjs → protocol-ByRVzzQG.cjs} +1 -1
- package/dist/{protocol-BaiWjq5w.js → protocol-Cr81vFSQ.js} +3 -3
- package/dist/{record-bindings-D4TuMzHs.js → record-bindings-DEJtmo3p.js} +67 -107
- package/dist/record-bindings-ehjnCDHt.cjs +1 -0
- package/dist/{region-binding-workflow-BNasF5kz.js → region-binding-workflow-CBg0l_tj.js} +1 -1
- package/dist/{region-binding-workflow-O2Cni3mF.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 +75 -7
- package/dist/server/node.d.ts +75 -7
- package/dist/server-node.cjs +4 -4
- package/dist/server-node.js +2692 -1990
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +243 -28
- package/dist/server.d.ts +243 -28
- package/dist/server.js +28 -28
- 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-wT1fNeAP.js → template-catalog-CmbWOJqy.js} +16 -16
- package/dist/{template-catalog-Dua8h9ZA.cjs → template-catalog-Utu4GP09.cjs} +1 -1
- package/dist/{template-fragments-BajTajb4.cjs → template-fragments-C_zSHJAa.cjs} +1 -1
- package/dist/{template-fragments-DmX5XK4N.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-u11fPd8D.js → template-registry-BIhIHOab.js} +319 -314
- package/dist/template-registry-DzWswQI5.cjs +1 -0
- package/dist/vue/async.d.cts +528 -33
- package/dist/vue/async.d.ts +528 -33
- package/dist/vue/index.d.cts +616 -64
- package/dist/vue/index.d.ts +616 -64
- 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-DN5LSA5C.cjs → workbook-session-B94EwVa_.cjs} +1 -1
- package/dist/{workbook-session-B8pNW24X.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 +120 -13
- package/dist/xlsx.d.ts +120 -13
- package/dist/xlsx.js +313 -279
- package/package.json +1 -1
- package/dist/ParamEditor-B5UZRgxv.cjs +0 -1
- package/dist/ParamEditor-DNNARyeB.js +0 -594
- package/dist/ReportBatchPanel-Ctvs2t_9.cjs +0 -1
- package/dist/ReportPreview-BdQawRh0.js +0 -4879
- package/dist/ReportPreview-CJC_-j2I.cjs +0 -6
- package/dist/RuleEditor-DkRjOLlr.js +0 -2141
- package/dist/RuleEditor-h5anGsDB.cjs +0 -1
- package/dist/assets-BIMVwjQe.js +0 -231
- package/dist/assets-Dfs2ElxI.cjs +0 -1
- package/dist/component-tree-Ca6YYfHq.js +0 -61
- package/dist/component-tree-DkGLEfZC.cjs +0 -1
- package/dist/computed-BW5a8QFk.js +0 -612
- package/dist/computed-C2GD3XcE.cjs +0 -1
- package/dist/config-Dg_o8e7m.cjs +0 -1
- package/dist/config-XQ4qrQ7Q.js +0 -844
- package/dist/designer-D9XAxqSc.js +0 -5178
- package/dist/designer-uCDo5XSK.cjs +0 -2
- package/dist/drill-ByN8COs_.cjs +0 -1
- package/dist/drill-CKW3Xtfa.js +0 -145
- package/dist/json-snapshot-D7PE1NsU.cjs +0 -2
- package/dist/json-snapshot-DYmEe3sO.js +0 -1779
- package/dist/matrix-JLAXlux-.js +0 -302
- package/dist/matrix-gTHpDTGm.cjs +0 -1
- package/dist/param-validation-C3HlcLLO.cjs +0 -1
- package/dist/param-validation-Do7Eg8Zv.js +0 -181
- package/dist/record-bindings-B86Sur_y.cjs +0 -1
- package/dist/runtime-DakRXui3.js +0 -170
- package/dist/runtime-dL5ygIfa.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-registry-CpysHAxy.cjs +0 -1
- package/dist/tree-CLpxYbKa.cjs +0 -1
- package/dist/tree-DNJorJUf.js +0 -172
package/dist/matrix-JLAXlux-.js
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import { c as g } from "./computed-BW5a8QFk.js";
|
|
2
|
-
function x(e, r) {
|
|
3
|
-
const l = () => r.measures.map((i) => g(i)), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = r.totals ? l() : void 0, s = (i, c) => i?.forEach((u) => u.add(c));
|
|
4
|
-
for (const i of e) {
|
|
5
|
-
const c = r.row(i), u = r.column(i);
|
|
6
|
-
n.has(u.key) || n.set(u.key, u.label);
|
|
7
|
-
let f = t.get(c.key);
|
|
8
|
-
f || (f = { label: c.label, cells: /* @__PURE__ */ new Map(), ...r.totals ? { totals: l() } : {} }, t.set(c.key, f)), r.check(t.size, n.size);
|
|
9
|
-
let d = f.cells.get(u.key);
|
|
10
|
-
if (d || (d = l(), f.cells.set(u.key, d)), s(d, i), !r.totals) continue;
|
|
11
|
-
let w = o.get(u.key);
|
|
12
|
-
w || (w = l(), o.set(u.key, w)), s(f.totals, i), s(w, i), s(a, i);
|
|
13
|
-
}
|
|
14
|
-
return { groups: t, columns: n, columnTotals: o, totals: a };
|
|
15
|
-
}
|
|
16
|
-
function h(e, r) {
|
|
17
|
-
return JSON.stringify([e.slice(0, r.length), r.map((l) => [l === null ? "null" : typeof l, l])]);
|
|
18
|
-
}
|
|
19
|
-
function M(e, r) {
|
|
20
|
-
return r.map((l) => {
|
|
21
|
-
const t = Object.prototype.hasOwnProperty.call(e, l) ? e[l] : null;
|
|
22
|
-
if (t == null) return null;
|
|
23
|
-
if (typeof t == "string" || typeof t == "boolean" || typeof t == "number" && Number.isFinite(t)) return t;
|
|
24
|
-
throw new Error("矩阵维度必须是有限 JSON 标量");
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
function C(e, r, l) {
|
|
28
|
-
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("矩阵层级应为对象");
|
|
29
|
-
for (const t of [e.emptyLabel, e.subtotalLabel, e.totalLabel]) if (t !== void 0 && typeof t != "string") throw new Error("矩阵层级标签应为字符串");
|
|
30
|
-
b(e.row, r.length), b(e.column, l.length);
|
|
31
|
-
}
|
|
32
|
-
function b(e, r) {
|
|
33
|
-
if (e !== void 0) {
|
|
34
|
-
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("矩阵轴配置应为对象");
|
|
35
|
-
if (e.labels !== void 0 && (!Array.isArray(e.labels) || e.labels.length !== r || e.labels.some((l) => typeof l != "string"))) throw new Error("矩阵维度标签必须与维度字段一一对应");
|
|
36
|
-
if (e.sort !== void 0 && (!Array.isArray(e.sort) || e.sort.length > r || e.sort.some((l) => !["source", "asc", "desc"].includes(l)))) throw new Error("矩阵维度排序应为 source、asc 或 desc");
|
|
37
|
-
if (e.subtotals !== void 0 && (!Array.isArray(e.subtotals) || new Set(e.subtotals).size !== e.subtotals.length || e.subtotals.some((l) => !Number.isInteger(l) || l < 1 || l >= r))) throw new Error("矩阵小计深度应唯一且位于 1 至末级之前");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function k(e, r, l) {
|
|
41
|
-
return { fields: e, options: r ?? {}, hierarchy: l, root: { values: [], children: /* @__PURE__ */ new Map() }, leaves: 0, expanded: 0 };
|
|
42
|
-
}
|
|
43
|
-
function F(e, r) {
|
|
44
|
-
const l = M(r, e.fields);
|
|
45
|
-
let t = e.root;
|
|
46
|
-
for (let n = 1; n <= l.length; n++) {
|
|
47
|
-
const o = l.slice(0, n), a = h(e.fields, o);
|
|
48
|
-
let s = t.children.get(a);
|
|
49
|
-
s || (s = { values: o, children: /* @__PURE__ */ new Map() }, t.children.set(a, s), n === l.length ? (e.leaves++, e.expanded++) : e.options.subtotals?.includes(n) && e.expanded++), t = s;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function N(e, r) {
|
|
53
|
-
if (e === r) return 0;
|
|
54
|
-
if (e === null) return -1;
|
|
55
|
-
if (r === null) return 1;
|
|
56
|
-
if (typeof e == "number" && typeof r == "number") return e - r;
|
|
57
|
-
const l = `${typeof e}:${e}`, t = `${typeof r}:${r}`;
|
|
58
|
-
return l < t ? -1 : 1;
|
|
59
|
-
}
|
|
60
|
-
function L(e, r) {
|
|
61
|
-
const l = [...e.children.values()];
|
|
62
|
-
return r && r !== "source" && l.sort((t, n) => N(t.values[t.values.length - 1], n.values[n.values.length - 1]) * (r === "desc" ? -1 : 1)), l;
|
|
63
|
-
}
|
|
64
|
-
function y(e, r, l) {
|
|
65
|
-
return {
|
|
66
|
-
key: h(e.fields, r),
|
|
67
|
-
kind: l,
|
|
68
|
-
depth: r.length,
|
|
69
|
-
fields: e.fields.slice(0, r.length),
|
|
70
|
-
values: r,
|
|
71
|
-
labels: r.map((t) => t === null ? e.hierarchy.emptyLabel ?? "(空)" : String(t))
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function A(e, r) {
|
|
75
|
-
const l = [];
|
|
76
|
-
function t(n) {
|
|
77
|
-
for (const o of L(n, e.options.sort?.[n.values.length]))
|
|
78
|
-
o.children.size ? (t(o), e.options.subtotals?.includes(o.values.length) && l.push(y(e, o.values, "subtotal"))) : l.push(y(e, o.values, "member"));
|
|
79
|
-
}
|
|
80
|
-
return t(e.root), r && e.leaves && l.push(y(e, [], "total")), l;
|
|
81
|
-
}
|
|
82
|
-
function E(e, r, l) {
|
|
83
|
-
const t = M(r, e.fields), n = [h(e.fields, t), ...(e.options.subtotals ?? []).map((o) => h(e.fields, t.slice(0, o)))];
|
|
84
|
-
return l && n.push(h(e.fields, [])), n;
|
|
85
|
-
}
|
|
86
|
-
function R(e, r, l) {
|
|
87
|
-
if (!(e.kind !== "member" && r > e.depth))
|
|
88
|
-
return e.kind === "total" ? { key: "total", text: l.totalLabel ?? "合计", rowSpan: 0 } : e.kind === "subtotal" && r === e.depth ? { key: e.key, text: l.subtotalLabel ?? "小计", rowSpan: 0 } : { key: JSON.stringify(e.values.slice(0, r + 1).map((t) => [typeof t, t])), text: e.labels[r], rowSpan: 1 };
|
|
89
|
-
}
|
|
90
|
-
function z(e, r) {
|
|
91
|
-
const l = e.columnFields.length + 1, t = e.rowFields.length, n = Array.from({ length: l }, () => Array(t + r.length).fill(null));
|
|
92
|
-
for (let o = 0; o < e.columnFields.length; o++) {
|
|
93
|
-
let a;
|
|
94
|
-
r.forEach((s, i) => {
|
|
95
|
-
const c = R(s, o, e.hierarchy);
|
|
96
|
-
if (!c) {
|
|
97
|
-
a = void 0;
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (a?.key === c.key) {
|
|
101
|
-
a.cell.colSpan = (a.cell.colSpan ?? 1) + 1;
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const u = { text: c.text, rowSpan: c.rowSpan || e.columnFields.length - o, editable: !1, derived: !0 };
|
|
105
|
-
n[o][t + i] = u, a = { key: c.key, cell: u };
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
return e.rowFields.forEach((o, a) => {
|
|
109
|
-
n[0][a] = { text: e.hierarchy.row?.labels?.[a] ?? o, rowSpan: l, editable: !1, derived: !0 };
|
|
110
|
-
}), r.forEach((o, a) => {
|
|
111
|
-
const s = e.measures[o.measure];
|
|
112
|
-
n[l - 1][t + a] = { text: s.label ?? `${s.field} (${s.op})`, editable: !1, derived: !0 };
|
|
113
|
-
}), {
|
|
114
|
-
cells: n.map((o) => o.filter((a) => a !== null)),
|
|
115
|
-
colWidthsMm: [...e.rowFields.map(() => e.rowWidthMm ?? 40), ...r.map(() => e.columnWidthMm ?? 28)]
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function v(e, r, l, t) {
|
|
119
|
-
const n = +(!!r.totals && e > 0), o = l.expanded + n, a = (t.expanded + n) * r.measures.length + r.rowFields.length;
|
|
120
|
-
if (o > (r.maxRows ?? 1e3) || t.expanded + n > (r.maxColumns ?? 200)) throw new Error("矩阵层级展开数量超出预算(包含小计/总计)");
|
|
121
|
-
if (o * a > (r.maxCells ?? 2e6)) throw new Error("矩阵输出超出 maxCells 预算");
|
|
122
|
-
return { rowCount: o, columnCount: a, cells: o * a };
|
|
123
|
-
}
|
|
124
|
-
function $(e, r) {
|
|
125
|
-
if (!Array.isArray(e) || e.length > (r.maxInputRows ?? 1e5)) throw new Error("矩阵输入超出预算");
|
|
126
|
-
const l = k(r.rowFields, r.hierarchy.row, r.hierarchy), t = k(r.columnFields, r.hierarchy.column, r.hierarchy);
|
|
127
|
-
if (e.length * (1 + (l.options.subtotals?.length ?? 0) + +!!r.totals) * (1 + (t.options.subtotals?.length ?? 0) + +!!r.totals) * r.measures.length > (r.maxAggregateUpdates ?? 1e7)) throw new Error("矩阵聚合更新超出 maxAggregateUpdates 预算");
|
|
128
|
-
let o = v(0, r, l, t);
|
|
129
|
-
for (const a of e) {
|
|
130
|
-
if (!a || typeof a != "object" || Array.isArray(a)) throw new Error("矩阵数据行应为对象");
|
|
131
|
-
F(l, a), F(t, a), o = v(e.length, r, l, t);
|
|
132
|
-
}
|
|
133
|
-
return { row: l, column: t, shape: o };
|
|
134
|
-
}
|
|
135
|
-
function j(e, r) {
|
|
136
|
-
return $(e, r).shape;
|
|
137
|
-
}
|
|
138
|
-
function O(e, r, l) {
|
|
139
|
-
const t = /* @__PURE__ */ new Map();
|
|
140
|
-
for (const n of e) {
|
|
141
|
-
const o = E(l.row, n, !!r.totals), a = E(l.column, n, !!r.totals);
|
|
142
|
-
for (const s of o) {
|
|
143
|
-
let i = t.get(s);
|
|
144
|
-
i || (i = /* @__PURE__ */ new Map(), t.set(s, i));
|
|
145
|
-
for (const c of a) {
|
|
146
|
-
let u = i.get(c);
|
|
147
|
-
u || (u = r.measures.map((f) => g({ ...f, field: f.valueField ?? f.field })), i.set(c, u)), u.forEach((f) => f.add(n));
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return t;
|
|
152
|
-
}
|
|
153
|
-
function p(e, r) {
|
|
154
|
-
return e.flatMap((l, t) => r.measures.map((n, o) => ({
|
|
155
|
-
...l,
|
|
156
|
-
field: l.kind === "total" ? `total_${o}` : `c${t}_${o}`,
|
|
157
|
-
measure: o,
|
|
158
|
-
measureField: n.field,
|
|
159
|
-
valueField: n.valueField ?? n.field,
|
|
160
|
-
operation: n.op
|
|
161
|
-
})));
|
|
162
|
-
}
|
|
163
|
-
function H(e, r) {
|
|
164
|
-
return e.kind === "total" ? r.hierarchy.totalLabel ?? "合计" : [...e.labels, ...e.kind === "subtotal" ? [r.hierarchy.subtotalLabel ?? "小计"] : []].join(" / ");
|
|
165
|
-
}
|
|
166
|
-
function I(e, r) {
|
|
167
|
-
return [
|
|
168
|
-
...r.rowFields.map((l, t) => ({ field: `r${t}`, header: r.hierarchy.row?.labels?.[t] ?? l, semanticRole: "dimension" })),
|
|
169
|
-
...e.map((l) => {
|
|
170
|
-
const t = r.measures[l.measure];
|
|
171
|
-
return {
|
|
172
|
-
field: l.field,
|
|
173
|
-
header: `${H(l, r)} · ${t.label ?? `${t.field} (${t.op})`}`,
|
|
174
|
-
semanticRole: "measure",
|
|
175
|
-
...t.digits === void 0 ? {} : { format: { kind: "number", digits: t.digits } }
|
|
176
|
-
};
|
|
177
|
-
})
|
|
178
|
-
];
|
|
179
|
-
}
|
|
180
|
-
function K(e, r, l, t) {
|
|
181
|
-
return e.map((n) => {
|
|
182
|
-
const o = {};
|
|
183
|
-
l.rowFields.forEach((a, s) => {
|
|
184
|
-
o[`r${s}`] = n.kind === "total" ? s === 0 ? l.hierarchy.totalLabel ?? "合计" : null : n.labels[s] ?? (s === n.depth ? l.hierarchy.subtotalLabel ?? "小计" : null);
|
|
185
|
-
});
|
|
186
|
-
for (const a of r) o[a.field] = t.get(n.key)?.get(a.key)?.[a.measure]?.value() ?? (l.measures[a.measure].op === "count" ? 0 : null);
|
|
187
|
-
return o;
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
function _(e, r) {
|
|
191
|
-
const l = $(e, r), t = A(l.row, !!r.totals), n = p(A(l.column, !!r.totals), r), o = O(e, r, l);
|
|
192
|
-
return { columns: I(n, r), rows: K(t, n, r, o), headerGrid: z(r, n), metadata: {
|
|
193
|
-
rowFields: [...r.rowFields],
|
|
194
|
-
rowLabels: [...r.hierarchy.row?.labels ?? r.rowFields],
|
|
195
|
-
columnFields: [...r.columnFields],
|
|
196
|
-
columnLabels: [...r.hierarchy.column?.labels ?? r.columnFields],
|
|
197
|
-
rows: t,
|
|
198
|
-
columns: n
|
|
199
|
-
} };
|
|
200
|
-
}
|
|
201
|
-
function m(e, r) {
|
|
202
|
-
const l = r.map(
|
|
203
|
-
(t) => Object.prototype.hasOwnProperty.call(e, t) ? e[t] : null
|
|
204
|
-
);
|
|
205
|
-
if (l.some(
|
|
206
|
-
(t) => t != null && typeof t != "string" && typeof t != "boolean" && !(typeof t == "number" && Number.isFinite(t))
|
|
207
|
-
))
|
|
208
|
-
throw new Error("矩阵维度必须是有限 JSON 标量");
|
|
209
|
-
return {
|
|
210
|
-
key: JSON.stringify(l.map((t) => [typeof t, t ?? null])),
|
|
211
|
-
label: l.map((t) => t == null ? "" : String(t)).join(" / ")
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
function J(e) {
|
|
215
|
-
for (const r of [
|
|
216
|
-
"maxRows",
|
|
217
|
-
"maxColumns",
|
|
218
|
-
"maxInputRows",
|
|
219
|
-
"maxCells",
|
|
220
|
-
"maxAggregateUpdates"
|
|
221
|
-
])
|
|
222
|
-
if (e[r] !== void 0 && (!Number.isSafeInteger(e[r]) || e[r] < 1))
|
|
223
|
-
throw new Error("矩阵预算应为正安全整数");
|
|
224
|
-
for (const r of ["columnWidthMm", "rowWidthMm"])
|
|
225
|
-
if (e[r] !== void 0 && (!Number.isFinite(e[r]) || e[r] <= 0))
|
|
226
|
-
throw new Error("矩阵列宽应为正数");
|
|
227
|
-
}
|
|
228
|
-
function S(e) {
|
|
229
|
-
if (!e || !Array.isArray(e.rowFields) || !Array.isArray(e.columnFields) || !Array.isArray(e.measures))
|
|
230
|
-
throw new Error("矩阵需要行维度、列维度和度量数组");
|
|
231
|
-
for (const l of [e.rowFields, e.columnFields])
|
|
232
|
-
if (l.some((t) => typeof t != "string" || !t.trim()) || new Set(l).size !== l.length)
|
|
233
|
-
throw new Error("矩阵维度字段应非空且唯一");
|
|
234
|
-
if (J(e), !e.rowFields.length || !e.columnFields.length || e.rowFields.length > 16 || e.columnFields.length > 16)
|
|
235
|
-
throw new Error("矩阵需要 1–16 个行/列维度");
|
|
236
|
-
if (!e.measures.length || e.measures.length > 32)
|
|
237
|
-
throw new Error("矩阵需要 1–32 个度量");
|
|
238
|
-
if (e.measures.map((l) => {
|
|
239
|
-
if (!l || typeof l != "object") throw new Error("矩阵度量应为对象");
|
|
240
|
-
if (g({
|
|
241
|
-
...l,
|
|
242
|
-
field: l.valueField ?? l.field
|
|
243
|
-
}), l.label !== void 0 && typeof l.label != "string")
|
|
244
|
-
throw new Error("矩阵度量标签应为字符串");
|
|
245
|
-
return l.field;
|
|
246
|
-
}).some((l) => typeof l != "string" || !l.trim()))
|
|
247
|
-
throw new Error("矩阵度量字段应非空");
|
|
248
|
-
e.hierarchy !== void 0 && C(e.hierarchy, e.rowFields, e.columnFields);
|
|
249
|
-
}
|
|
250
|
-
function W(e, r) {
|
|
251
|
-
if (S(r), r.hierarchy) return j(e, r);
|
|
252
|
-
if (!Array.isArray(e) || e.length > (r.maxInputRows ?? 1e5))
|
|
253
|
-
throw new Error("矩阵输入超出预算");
|
|
254
|
-
const l = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
|
|
255
|
-
for (const a of e) {
|
|
256
|
-
if (!a || typeof a != "object" || Array.isArray(a))
|
|
257
|
-
throw new Error("矩阵数据行应为对象");
|
|
258
|
-
if (l.add(m(a, r.rowFields).key), t.add(m(a, r.columnFields).key), l.size > (r.maxRows ?? 1e3) || t.size > (r.maxColumns ?? 200))
|
|
259
|
-
throw new Error("矩阵维度数量超出预算");
|
|
260
|
-
if ((l.size + +!!r.totals) * ((t.size + +!!r.totals) * r.measures.length + 1) > (r.maxCells ?? 2e6))
|
|
261
|
-
throw new Error("矩阵输出超出 maxCells 预算");
|
|
262
|
-
}
|
|
263
|
-
const n = l.size + +(!!r.totals && e.length > 0), o = (t.size + +!!r.totals) * r.measures.length + 1;
|
|
264
|
-
return { rowCount: n, columnCount: o, cells: n * o };
|
|
265
|
-
}
|
|
266
|
-
function T(e, r) {
|
|
267
|
-
if (r?.hierarchy)
|
|
268
|
-
return S(r), _(e, r);
|
|
269
|
-
W(e, r);
|
|
270
|
-
const l = x(e, {
|
|
271
|
-
row: (a) => m(a, r.rowFields),
|
|
272
|
-
column: (a) => m(a, r.columnFields),
|
|
273
|
-
measures: r.measures.map((a) => ({ ...a, field: a.valueField ?? a.field })),
|
|
274
|
-
totals: r.totals,
|
|
275
|
-
check: () => {
|
|
276
|
-
}
|
|
277
|
-
// Cardinality/budgets were checked before allocating accumulators.
|
|
278
|
-
}), t = [...l.groups.values()].map((a) => ({ rowLabel: a.label })), n = [{ field: "rowLabel", header: r.rowHeader ?? r.rowFields.join(" / "), semanticRole: "dimension" }], o = { rowLabel: "合计" };
|
|
279
|
-
return r.measures.forEach((a, s) => {
|
|
280
|
-
const i = [...l.columns.entries()].map(([c, u], f) => ({ key: c, label: u, field: `c${f}_${s}` }));
|
|
281
|
-
r.totals && i.push({ key: "", label: "合计", field: `total_${s}` });
|
|
282
|
-
for (const c of i) {
|
|
283
|
-
const u = c.field === `total_${s}`;
|
|
284
|
-
n.push({
|
|
285
|
-
field: c.field,
|
|
286
|
-
header: `${c.label} · ${a.label ?? `${a.field} (${a.op})`}`,
|
|
287
|
-
semanticRole: "measure",
|
|
288
|
-
...a.digits === void 0 ? {} : { format: { kind: "number", digits: a.digits } }
|
|
289
|
-
});
|
|
290
|
-
let f = 0;
|
|
291
|
-
for (const d of l.groups.values())
|
|
292
|
-
t[f++][c.field] = (u ? d.totals?.[s] : d.cells.get(c.key)?.[s])?.value() ?? (a.op === "count" ? 0 : null);
|
|
293
|
-
o[c.field] = (u ? l.totals?.[s] : l.columnTotals.get(c.key)?.[s])?.value() ?? (a.op === "count" ? 0 : null);
|
|
294
|
-
}
|
|
295
|
-
}), r.totals && e.length && t.push(o), { rows: t, columns: n };
|
|
296
|
-
}
|
|
297
|
-
export {
|
|
298
|
-
x as a,
|
|
299
|
-
T as c,
|
|
300
|
-
W as e,
|
|
301
|
-
S as v
|
|
302
|
-
};
|
package/dist/matrix-gTHpDTGm.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const g=require("./computed-C2GD3XcE.cjs");function $(e,r){const l=()=>r.measures.map(i=>g.createAggregateAccumulator(i)),t=new Map,n=new Map,o=new Map,a=r.totals?l():void 0,s=(i,c)=>i?.forEach(u=>u.add(c));for(const i of e){const c=r.row(i),u=r.column(i);n.has(u.key)||n.set(u.key,u.label);let f=t.get(c.key);f||(f={label:c.label,cells:new Map,...r.totals?{totals:l()}:{}},t.set(c.key,f)),r.check(t.size,n.size);let d=f.cells.get(u.key);if(d||(d=l(),f.cells.set(u.key,d)),s(d,i),!r.totals)continue;let w=o.get(u.key);w||(w=l(),o.set(u.key,w)),s(f.totals,i),s(w,i),s(a,i)}return{groups:t,columns:n,columnTotals:o,totals:a}}function h(e,r){return JSON.stringify([e.slice(0,r.length),r.map(l=>[l===null?"null":typeof l,l])])}function S(e,r){return r.map(l=>{const t=Object.prototype.hasOwnProperty.call(e,l)?e[l]:null;if(t==null)return null;if(typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t))return t;throw new Error("矩阵维度必须是有限 JSON 标量")})}function N(e,r,l){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("矩阵层级应为对象");for(const t of[e.emptyLabel,e.subtotalLabel,e.totalLabel])if(t!==void 0&&typeof t!="string")throw new Error("矩阵层级标签应为字符串");k(e.row,r.length),k(e.column,l.length)}function k(e,r){if(e!==void 0){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("矩阵轴配置应为对象");if(e.labels!==void 0&&(!Array.isArray(e.labels)||e.labels.length!==r||e.labels.some(l=>typeof l!="string")))throw new Error("矩阵维度标签必须与维度字段一一对应");if(e.sort!==void 0&&(!Array.isArray(e.sort)||e.sort.length>r||e.sort.some(l=>!["source","asc","desc"].includes(l))))throw new Error("矩阵维度排序应为 source、asc 或 desc");if(e.subtotals!==void 0&&(!Array.isArray(e.subtotals)||new Set(e.subtotals).size!==e.subtotals.length||e.subtotals.some(l=>!Number.isInteger(l)||l<1||l>=r)))throw new Error("矩阵小计深度应唯一且位于 1 至末级之前")}}function A(e,r,l){return{fields:e,options:r??{},hierarchy:l,root:{values:[],children:new Map},leaves:0,expanded:0}}function F(e,r){const l=S(r,e.fields);let t=e.root;for(let n=1;n<=l.length;n++){const o=l.slice(0,n),a=h(e.fields,o);let s=t.children.get(a);s||(s={values:o,children:new Map},t.children.set(a,s),n===l.length?(e.leaves++,e.expanded++):e.options.subtotals?.includes(n)&&e.expanded++),t=s}}function L(e,r){if(e===r)return 0;if(e===null)return-1;if(r===null)return 1;if(typeof e=="number"&&typeof r=="number")return e-r;const l=`${typeof e}:${e}`,t=`${typeof r}:${r}`;return l<t?-1:1}function R(e,r){const l=[...e.children.values()];return r&&r!=="source"&&l.sort((t,n)=>L(t.values[t.values.length-1],n.values[n.values.length-1])*(r==="desc"?-1:1)),l}function y(e,r,l){return{key:h(e.fields,r),kind:l,depth:r.length,fields:e.fields.slice(0,r.length),values:r,labels:r.map(t=>t===null?e.hierarchy.emptyLabel??"(空)":String(t))}}function E(e,r){const l=[];function t(n){for(const o of R(n,e.options.sort?.[n.values.length]))o.children.size?(t(o),e.options.subtotals?.includes(o.values.length)&&l.push(y(e,o.values,"subtotal"))):l.push(y(e,o.values,"member"))}return t(e.root),r&&e.leaves&&l.push(y(e,[],"total")),l}function v(e,r,l){const t=S(r,e.fields),n=[h(e.fields,t),...(e.options.subtotals??[]).map(o=>h(e.fields,t.slice(0,o)))];return l&&n.push(h(e.fields,[])),n}function z(e,r,l){if(!(e.kind!=="member"&&r>e.depth))return e.kind==="total"?{key:"total",text:l.totalLabel??"合计",rowSpan:0}:e.kind==="subtotal"&&r===e.depth?{key:e.key,text:l.subtotalLabel??"小计",rowSpan:0}:{key:JSON.stringify(e.values.slice(0,r+1).map(t=>[typeof t,t])),text:e.labels[r],rowSpan:1}}function O(e,r){const l=e.columnFields.length+1,t=e.rowFields.length,n=Array.from({length:l},()=>Array(t+r.length).fill(null));for(let o=0;o<e.columnFields.length;o++){let a;r.forEach((s,i)=>{const c=z(s,o,e.hierarchy);if(!c){a=void 0;return}if(a?.key===c.key){a.cell.colSpan=(a.cell.colSpan??1)+1;return}const u={text:c.text,rowSpan:c.rowSpan||e.columnFields.length-o,editable:!1,derived:!0};n[o][t+i]=u,a={key:c.key,cell:u}})}return e.rowFields.forEach((o,a)=>{n[0][a]={text:e.hierarchy.row?.labels?.[a]??o,rowSpan:l,editable:!1,derived:!0}}),r.forEach((o,a)=>{const s=e.measures[o.measure];n[l-1][t+a]={text:s.label??`${s.field} (${s.op})`,editable:!1,derived:!0}}),{cells:n.map(o=>o.filter(a=>a!==null)),colWidthsMm:[...e.rowFields.map(()=>e.rowWidthMm??40),...r.map(()=>e.columnWidthMm??28)]}}function M(e,r,l,t){const n=+(!!r.totals&&e>0),o=l.expanded+n,a=(t.expanded+n)*r.measures.length+r.rowFields.length;if(o>(r.maxRows??1e3)||t.expanded+n>(r.maxColumns??200))throw new Error("矩阵层级展开数量超出预算(包含小计/总计)");if(o*a>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算");return{rowCount:o,columnCount:a,cells:o*a}}function x(e,r){if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=A(r.rowFields,r.hierarchy.row,r.hierarchy),t=A(r.columnFields,r.hierarchy.column,r.hierarchy);if(e.length*(1+(l.options.subtotals?.length??0)+ +!!r.totals)*(1+(t.options.subtotals?.length??0)+ +!!r.totals)*r.measures.length>(r.maxAggregateUpdates??1e7))throw new Error("矩阵聚合更新超出 maxAggregateUpdates 预算");let o=M(0,r,l,t);for(const a of e){if(!a||typeof a!="object"||Array.isArray(a))throw new Error("矩阵数据行应为对象");F(l,a),F(t,a),o=M(e.length,r,l,t)}return{row:l,column:t,shape:o}}function j(e,r){return x(e,r).shape}function p(e,r,l){const t=new Map;for(const n of e){const o=v(l.row,n,!!r.totals),a=v(l.column,n,!!r.totals);for(const s of o){let i=t.get(s);i||(i=new Map,t.set(s,i));for(const c of a){let u=i.get(c);u||(u=r.measures.map(f=>g.createAggregateAccumulator({...f,field:f.valueField??f.field})),i.set(c,u)),u.forEach(f=>f.add(n))}}}return t}function H(e,r){return e.flatMap((l,t)=>r.measures.map((n,o)=>({...l,field:l.kind==="total"?`total_${o}`:`c${t}_${o}`,measure:o,measureField:n.field,valueField:n.valueField??n.field,operation:n.op})))}function I(e,r){return e.kind==="total"?r.hierarchy.totalLabel??"合计":[...e.labels,...e.kind==="subtotal"?[r.hierarchy.subtotalLabel??"小计"]:[]].join(" / ")}function K(e,r){return[...r.rowFields.map((l,t)=>({field:`r${t}`,header:r.hierarchy.row?.labels?.[t]??l,semanticRole:"dimension"})),...e.map(l=>{const t=r.measures[l.measure];return{field:l.field,header:`${I(l,r)} · ${t.label??`${t.field} (${t.op})`}`,semanticRole:"measure",...t.digits===void 0?{}:{format:{kind:"number",digits:t.digits}}}})]}function T(e,r,l,t){return e.map(n=>{const o={};l.rowFields.forEach((a,s)=>{o[`r${s}`]=n.kind==="total"?s===0?l.hierarchy.totalLabel??"合计":null:n.labels[s]??(s===n.depth?l.hierarchy.subtotalLabel??"小计":null)});for(const a of r)o[a.field]=t.get(n.key)?.get(a.key)?.[a.measure]?.value()??(l.measures[a.measure].op==="count"?0:null);return o})}function _(e,r){const l=x(e,r),t=E(l.row,!!r.totals),n=H(E(l.column,!!r.totals),r),o=p(e,r,l);return{columns:K(n,r),rows:T(t,n,r,o),headerGrid:O(r,n),metadata:{rowFields:[...r.rowFields],rowLabels:[...r.hierarchy.row?.labels??r.rowFields],columnFields:[...r.columnFields],columnLabels:[...r.hierarchy.column?.labels??r.columnFields],rows:t,columns:n}}}function m(e,r){const l=r.map(t=>Object.prototype.hasOwnProperty.call(e,t)?e[t]:null);if(l.some(t=>t!=null&&typeof t!="string"&&typeof t!="boolean"&&!(typeof t=="number"&&Number.isFinite(t))))throw new Error("矩阵维度必须是有限 JSON 标量");return{key:JSON.stringify(l.map(t=>[typeof t,t??null])),label:l.map(t=>t==null?"":String(t)).join(" / ")}}function J(e){for(const r of["maxRows","maxColumns","maxInputRows","maxCells","maxAggregateUpdates"])if(e[r]!==void 0&&(!Number.isSafeInteger(e[r])||e[r]<1))throw new Error("矩阵预算应为正安全整数");for(const r of["columnWidthMm","rowWidthMm"])if(e[r]!==void 0&&(!Number.isFinite(e[r])||e[r]<=0))throw new Error("矩阵列宽应为正数")}function b(e){if(!e||!Array.isArray(e.rowFields)||!Array.isArray(e.columnFields)||!Array.isArray(e.measures))throw new Error("矩阵需要行维度、列维度和度量数组");for(const l of[e.rowFields,e.columnFields])if(l.some(t=>typeof t!="string"||!t.trim())||new Set(l).size!==l.length)throw new Error("矩阵维度字段应非空且唯一");if(J(e),!e.rowFields.length||!e.columnFields.length||e.rowFields.length>16||e.columnFields.length>16)throw new Error("矩阵需要 1–16 个行/列维度");if(!e.measures.length||e.measures.length>32)throw new Error("矩阵需要 1–32 个度量");if(e.measures.map(l=>{if(!l||typeof l!="object")throw new Error("矩阵度量应为对象");if(g.createAggregateAccumulator({...l,field:l.valueField??l.field}),l.label!==void 0&&typeof l.label!="string")throw new Error("矩阵度量标签应为字符串");return l.field}).some(l=>typeof l!="string"||!l.trim()))throw new Error("矩阵度量字段应非空");e.hierarchy!==void 0&&N(e.hierarchy,e.rowFields,e.columnFields)}function C(e,r){if(b(r),r.hierarchy)return j(e,r);if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=new Set,t=new Set;for(const a of e){if(!a||typeof a!="object"||Array.isArray(a))throw new Error("矩阵数据行应为对象");if(l.add(m(a,r.rowFields).key),t.add(m(a,r.columnFields).key),l.size>(r.maxRows??1e3)||t.size>(r.maxColumns??200))throw new Error("矩阵维度数量超出预算");if((l.size+ +!!r.totals)*((t.size+ +!!r.totals)*r.measures.length+1)>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算")}const n=l.size+ +(!!r.totals&&e.length>0),o=(t.size+ +!!r.totals)*r.measures.length+1;return{rowCount:n,columnCount:o,cells:n*o}}function P(e,r){if(r?.hierarchy)return b(r),_(e,r);C(e,r);const l=$(e,{row:a=>m(a,r.rowFields),column:a=>m(a,r.columnFields),measures:r.measures.map(a=>({...a,field:a.valueField??a.field})),totals:r.totals,check:()=>{}}),t=[...l.groups.values()].map(a=>({rowLabel:a.label})),n=[{field:"rowLabel",header:r.rowHeader??r.rowFields.join(" / "),semanticRole:"dimension"}],o={rowLabel:"合计"};return r.measures.forEach((a,s)=>{const i=[...l.columns.entries()].map(([c,u],f)=>({key:c,label:u,field:`c${f}_${s}`}));r.totals&&i.push({key:"",label:"合计",field:`total_${s}`});for(const c of i){const u=c.field===`total_${s}`;n.push({field:c.field,header:`${c.label} · ${a.label??`${a.field} (${a.op})`}`,semanticRole:"measure",...a.digits===void 0?{}:{format:{kind:"number",digits:a.digits}}});let f=0;for(const d of l.groups.values())t[f++][c.field]=(u?d.totals?.[s]:d.cells.get(c.key)?.[s])?.value()??(a.op==="count"?0:null);o[c.field]=(u?l.totals?.[s]:l.columnTotals.get(c.key)?.[s])?.value()??(a.op==="count"?0:null)}}),r.totals&&e.length&&t.push(o),{rows:t,columns:n}}exports.accumulatePivotRows=$;exports.createMatrixTable=P;exports.estimateMatrixTable=C;exports.validateMatrixOptions=b;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function v(e){const t=[];return e.optionsSource!==void 0&&((e.type!=="select"||typeof e.optionsSource!="string"||!/^[\w][\w.:-]{0,127}$/.test(e.optionsSource))&&t.push("远程选项来源应为 select 的有效来源键(最多 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 Y(e){const t=new Map(e.map((i,s)=>[i.field,{def:i,index:s,degree:0,children:[]}])),n=[];for(const i of t.values())for(const s of i.def.dependsOn??[]){const o=t.get(s);if(!o){n.push({index:i.index,message:`联动依赖参数 ${s} 未声明`});continue}i.degree++,o.children.push(i.def.field)}const r=[...t.values()].filter(i=>i.degree===0);for(let i=0;i<r.length;i++)for(const s of r[i].children){const o=t.get(s);--o.degree===0&&r.push(o)}for(const i of t.values())i.degree>0&&n.push({index:i.index,message:"联动依赖不能形成循环"});return n}function p(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 m(e){return e.length===4&&/^\d{4}$/.test(e)&&e!=="0000"}function f(e){return e.length===7&&/^\d{4}-(?:0[1-9]|1[0-2])$/.test(e)&&m(e.slice(0,4))}function c(e){const[t,n,r]=e.split("/");if(!(r!==void 0||!t||!n||!p(t)||!p(n)||t>n))return{start:t,end:n}}function D(e){const t=`${e.start}/${e.end}`;if(!c(t))throw new RangeError("日期范围必须为完整且有序的 YYYY-MM-DD/YYYY-MM-DD");return t}function b(e,t){return typeof t!="string"?!1:e==="month"?f(t):e==="year"?m(t):(e==="date"||e==="dateRange")&&p(t)}function L(e,t){if(e==="date"&&!p(t))return"应为有效的 YYYY-MM-DD 日期";if(e==="month"&&!f(t))return"应为有效的 YYYY-MM 月份";if(e==="year"&&!m(t))return"应为 0001 至 9999 的四位年份";if(e==="dateRange"&&!c(t))return"应为完整且有序的 YYYY-MM-DD/YYYY-MM-DD 日期范围"}class y extends Error{constructor(t){super(t.map(n=>`${n.field}: ${n.message}`).join("; ")),this.issues=t,this.code="params",this.name="ReportParamValidationError"}}function x(e){return/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e)&&Number.isFinite(Number(e))}function R(e,t){if(e.type==="number"&&!x(t))return[["type","应为有限数字"]];const n=L(e.type,t);if(n)return[["type",n]];const r=[];e.type==="select"&&e.options&&!e.options.some(s=>s.value===t)&&r.push(["option","不在允许的选项中"]);const i=Array.from(t).length;return e.minLength!==void 0&&i<e.minLength&&r.push(["minLength",`至少 ${e.minLength} 个字符`]),e.maxLength!==void 0&&i>e.maxLength&&r.push(["maxLength",`最多 ${e.maxLength} 个字符`]),r.push(...O(e,t)),r}function O(e,t){const n=e.type==="dateRange"?c(t):void 0,r=n?.start??(e.type==="number"?Number(t):t),i=n?.end??r,s=[];return e.min!==void 0&&r<e.min&&s.push(["minimum",`不能小于 ${e.min}`]),e.max!==void 0&&i>e.max&&s.push(["maximum",`不能大于 ${e.max}`]),s}function S(e){const t=[];for(const i of["min","max"]){const s=e[i];if(s===void 0)continue;b(e.type,s)||e.type==="number"&&typeof s=="number"&&Number.isFinite(s)||t.push(`${i} 应为数字的有限边界或日期/月/年的规范字符串边界`)}const n=typeof e.min=="number"&&typeof e.max=="number"&&e.min>e.max,r=typeof e.min=="string"&&typeof e.max=="string"&&e.min>e.max;return(n||r)&&t.push("最小边界不能大于最大边界"),[...t,...w(e)]}function w(e){const t=[];e.type==="number"&&(e.minLength!==void 0||e.maxLength!==void 0)&&t.push("number 参数使用 min/max 而不是文本长度约束");for(const n of["minLength","maxLength"]){const r=e[n];r!==void 0&&(!Number.isSafeInteger(r)||r<0)&&t.push(`${n} 应为非负整数`)}return typeof e.minLength=="number"&&typeof e.maxLength=="number"&&e.minLength>e.maxLength&&t.push("最小长度不能大于最大长度"),t}function d(e){if(!Array.isArray(e))return[{code:"definition",field:"",path:"$.paramDefs",message:"参数定义应为数组"}];const t=new Set,n=e.flatMap((r,i)=>{const s=r&&typeof r.field=="string"?r.field:"";return P(r,t).map(a=>({code:"definition",field:s,path:`$.paramDefs.${i}`,message:a}))});return n.length?n:Y(e).map(({index:r,message:i})=>({code:"definition",field:e[r].field,path:`$.paramDefs.${r}`,message:i}))}function M(e){return Array.isArray(e)&&e.every(t=>!!t&&typeof t=="object"&&typeof t.value=="string"&&typeof t.label=="string")}function V(e){const t=[];return e.type!==void 0&&!["text","number","date","month","year","dateRange","select"].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&&!M(e.options)&&t.push("选项应为包含字符串 label/value 的数组"),[...t,...v(e)]}function P(e,t){if(!e||typeof e!="object"||Array.isArray(e))return["参数定义项应为对象"];const n=V(e);return typeof e.field!="string"||!e.field.trim()||t.has(e.field)?n.push("参数名应为非空且不重复的字符串"):t.add(e.field),n.length||(n.push(...S(e)),n.length)||(e.options&&new Set(e.options.map(r=>r.value)).size!==e.options.length&&n.push("选项值不能重复"),e.defaultValue!==void 0&&(e.required&&!e.defaultValue.trim()?n.push("必填参数的默认值不能为空"):e.defaultValue.trim()&&n.push(...R(e,e.defaultValue).map(([,r])=>`默认值${r}`)))),n}function j(e,t,n){for(const[r,i]of Object.entries(e))(typeof i=="string"||typeof i=="number"&&Number.isFinite(i))&&(Object.defineProperty(t,r,{value:String(i),writable:!0,enumerable:!0,configurable:!0}),Object.defineProperty(n,r,{value:i,writable:!0,enumerable:!0,configurable:!0}))}function g(e){return e==null||typeof e=="string"&&!e.trim()}function $(e,t={}){const n=Object.create(null),r=Object.create(null),i=d(e);if((!t||typeof t!="object"||Array.isArray(t))&&i.push({code:"type",field:"",path:"$.params",message:"参数应为对象"}),i.length)return{ok:!1,values:n,typedValues:r,issues:i};j(t,n,r);for(const s of e){const o=Object.prototype.hasOwnProperty.call(t,s.field)&&t[s.field]!==void 0?t[s.field]:s.defaultValue,a=(l,h)=>i.push({code:l,path:`$.params.${s.field}`,field:s.field,message:h});if(g(o)){s.required&&a("required","此参数为必填项"),typeof o=="string"&&(n[s.field]=o),delete r[s.field];continue}if(typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o))){a("type","参数应为字符串或有限数字");continue}const u=String(o);n[s.field]=u,R(s,u).forEach(([l,h])=>a(l,h)),r[s.field]=s.type==="number"&&x(u)?Number(u):u}return i.push(...I(e,n)),{ok:i.length===0,values:n,typedValues:r,issues:i}}function I(e,t){return e.flatMap(n=>!g(t[n.field])&&n.dependsOn?.some(r=>g(t[r]))?[{code:"dependency",path:`$.params.${n.field}`,field:n.field,message:"请先填写联动依赖的上级参数"}]:[])}function N(e,t={}){const n=$(e,t);if(!n.ok)throw new y(n.issues);return n.values}function A(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 q(e){const t={type:e.type==="number"?"number":"string",title:e.label??e.field,...A(e)};return e.required&&e.type!=="number"&&!t.pattern&&(t.pattern="\\S"),e.type==="select"&&e.options&&(t.enum=e.options.map(n=>n.value)),Object.assign(t,E(e)),e.defaultValue!==void 0&&(e.type!=="number"||e.defaultValue.trim())&&(t.default=e.type==="number"?Number(e.defaultValue):e.defaultValue),e.minLength!==void 0&&(t.minLength=e.minLength),e.maxLength!==void 0&&(t.maxLength=e.maxLength),typeof e.min=="number"&&(t.minimum=e.min),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 E(e){return{...e.optionsSource?{"x-report-options-source":e.optionsSource}:{},...e.dependsOn?.length?{"x-report-depends-on":[...e.dependsOn]}:{}}}function k(e){const t=d(e);if(t.length)throw new y(t);return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",properties:Object.fromEntries(e.map(n=>[n.field,q(n)])),required:e.filter(n=>n.required).map(n=>n.field),additionalProperties:!0}}exports.ReportParamValidationError=y;exports.assertReportParams=N;exports.formatReportDateRange=D;exports.isReportDate=p;exports.isReportMonth=f;exports.isReportTemporalBound=b;exports.isReportYear=m;exports.parseReportDateRange=c;exports.reportParamsJsonSchema=k;exports.validateReportParamDefinitions=d;exports.validateReportParams=$;
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
function $(e) {
|
|
2
|
-
const t = [];
|
|
3
|
-
return e.optionsSource !== void 0 && ((e.type !== "select" || typeof e.optionsSource != "string" || !/^[\w][\w.:-]{0,127}$/.test(e.optionsSource)) && t.push("远程选项来源应为 select 的有效来源键(最多 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;
|
|
4
|
-
}
|
|
5
|
-
function v(e) {
|
|
6
|
-
const t = new Map(e.map((i, s) => [i.field, { def: i, index: s, degree: 0, children: [] }])), n = [];
|
|
7
|
-
for (const i of t.values()) for (const s of i.def.dependsOn ?? []) {
|
|
8
|
-
const o = t.get(s);
|
|
9
|
-
if (!o) {
|
|
10
|
-
n.push({ index: i.index, message: `联动依赖参数 ${s} 未声明` });
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
i.degree++, o.children.push(i.def.field);
|
|
14
|
-
}
|
|
15
|
-
const r = [...t.values()].filter((i) => i.degree === 0);
|
|
16
|
-
for (let i = 0; i < r.length; i++) for (const s of r[i].children) {
|
|
17
|
-
const o = t.get(s);
|
|
18
|
-
--o.degree === 0 && r.push(o);
|
|
19
|
-
}
|
|
20
|
-
for (const i of t.values()) i.degree > 0 && n.push({ index: i.index, message: "联动依赖不能形成循环" });
|
|
21
|
-
return n;
|
|
22
|
-
}
|
|
23
|
-
function p(e) {
|
|
24
|
-
if (!/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
|
|
25
|
-
const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
26
|
-
return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
|
|
27
|
-
}
|
|
28
|
-
function h(e) {
|
|
29
|
-
return e.length === 4 && /^\d{4}$/.test(e) && e !== "0000";
|
|
30
|
-
}
|
|
31
|
-
function f(e) {
|
|
32
|
-
return e.length === 7 && /^\d{4}-(?:0[1-9]|1[0-2])$/.test(e) && h(e.slice(0, 4));
|
|
33
|
-
}
|
|
34
|
-
function g(e) {
|
|
35
|
-
const [t, n, r] = e.split("/");
|
|
36
|
-
if (!(r !== void 0 || !t || !n || !p(t) || !p(n) || t > n))
|
|
37
|
-
return { start: t, end: n };
|
|
38
|
-
}
|
|
39
|
-
function E(e) {
|
|
40
|
-
const t = `${e.start}/${e.end}`;
|
|
41
|
-
if (!g(t)) throw new RangeError("日期范围必须为完整且有序的 YYYY-MM-DD/YYYY-MM-DD");
|
|
42
|
-
return t;
|
|
43
|
-
}
|
|
44
|
-
function Y(e, t) {
|
|
45
|
-
return typeof t != "string" ? !1 : e === "month" ? f(t) : e === "year" ? h(t) : (e === "date" || e === "dateRange") && p(t);
|
|
46
|
-
}
|
|
47
|
-
function L(e, t) {
|
|
48
|
-
if (e === "date" && !p(t)) return "应为有效的 YYYY-MM-DD 日期";
|
|
49
|
-
if (e === "month" && !f(t)) return "应为有效的 YYYY-MM 月份";
|
|
50
|
-
if (e === "year" && !h(t)) return "应为 0001 至 9999 的四位年份";
|
|
51
|
-
if (e === "dateRange" && !g(t)) return "应为完整且有序的 YYYY-MM-DD/YYYY-MM-DD 日期范围";
|
|
52
|
-
}
|
|
53
|
-
class y extends Error {
|
|
54
|
-
constructor(t) {
|
|
55
|
-
super(t.map((n) => `${n.field}: ${n.message}`).join("; ")), this.issues = t, this.code = "params", this.name = "ReportParamValidationError";
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function d(e) {
|
|
59
|
-
return /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e) && Number.isFinite(Number(e));
|
|
60
|
-
}
|
|
61
|
-
function b(e, t) {
|
|
62
|
-
if (e.type === "number" && !d(t)) return [["type", "应为有限数字"]];
|
|
63
|
-
const n = L(e.type, t);
|
|
64
|
-
if (n) return [["type", n]];
|
|
65
|
-
const r = [];
|
|
66
|
-
e.type === "select" && e.options && !e.options.some((s) => s.value === t) && r.push(["option", "不在允许的选项中"]);
|
|
67
|
-
const i = Array.from(t).length;
|
|
68
|
-
return e.minLength !== void 0 && i < e.minLength && r.push(["minLength", `至少 ${e.minLength} 个字符`]), e.maxLength !== void 0 && i > e.maxLength && r.push(["maxLength", `最多 ${e.maxLength} 个字符`]), r.push(...D(e, t)), r;
|
|
69
|
-
}
|
|
70
|
-
function D(e, t) {
|
|
71
|
-
const n = e.type === "dateRange" ? g(t) : void 0, r = n?.start ?? (e.type === "number" ? Number(t) : t), i = n?.end ?? r, s = [];
|
|
72
|
-
return e.min !== void 0 && r < e.min && s.push(["minimum", `不能小于 ${e.min}`]), e.max !== void 0 && i > e.max && s.push(["maximum", `不能大于 ${e.max}`]), s;
|
|
73
|
-
}
|
|
74
|
-
function O(e) {
|
|
75
|
-
const t = [];
|
|
76
|
-
for (const i of ["min", "max"]) {
|
|
77
|
-
const s = e[i];
|
|
78
|
-
if (s === void 0) continue;
|
|
79
|
-
Y(e.type, s) || e.type === "number" && typeof s == "number" && Number.isFinite(s) || t.push(`${i} 应为数字的有限边界或日期/月/年的规范字符串边界`);
|
|
80
|
-
}
|
|
81
|
-
const n = typeof e.min == "number" && typeof e.max == "number" && e.min > e.max, r = typeof e.min == "string" && typeof e.max == "string" && e.min > e.max;
|
|
82
|
-
return (n || r) && t.push("最小边界不能大于最大边界"), [...t, ...R(e)];
|
|
83
|
-
}
|
|
84
|
-
function R(e) {
|
|
85
|
-
const t = [];
|
|
86
|
-
e.type === "number" && (e.minLength !== void 0 || e.maxLength !== void 0) && t.push("number 参数使用 min/max 而不是文本长度约束");
|
|
87
|
-
for (const n of ["minLength", "maxLength"]) {
|
|
88
|
-
const r = e[n];
|
|
89
|
-
r !== void 0 && (!Number.isSafeInteger(r) || r < 0) && t.push(`${n} 应为非负整数`);
|
|
90
|
-
}
|
|
91
|
-
return typeof e.minLength == "number" && typeof e.maxLength == "number" && e.minLength > e.maxLength && t.push("最小长度不能大于最大长度"), t;
|
|
92
|
-
}
|
|
93
|
-
function x(e) {
|
|
94
|
-
if (!Array.isArray(e)) return [{ code: "definition", field: "", path: "$.paramDefs", message: "参数定义应为数组" }];
|
|
95
|
-
const t = /* @__PURE__ */ new Set(), n = e.flatMap((r, i) => {
|
|
96
|
-
const s = r && typeof r.field == "string" ? r.field : "";
|
|
97
|
-
return M(r, t).map((a) => ({ code: "definition", field: s, path: `$.paramDefs.${i}`, message: a }));
|
|
98
|
-
});
|
|
99
|
-
return n.length ? n : v(e).map(({ index: r, message: i }) => ({ code: "definition", field: e[r].field, path: `$.paramDefs.${r}`, message: i }));
|
|
100
|
-
}
|
|
101
|
-
function S(e) {
|
|
102
|
-
return Array.isArray(e) && e.every((t) => !!t && typeof t == "object" && typeof t.value == "string" && typeof t.label == "string");
|
|
103
|
-
}
|
|
104
|
-
function w(e) {
|
|
105
|
-
const t = [];
|
|
106
|
-
return e.type !== void 0 && !["text", "number", "date", "month", "year", "dateRange", "select"].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 && !S(e.options) && t.push("选项应为包含字符串 label/value 的数组"), [...t, ...$(e)];
|
|
107
|
-
}
|
|
108
|
-
function M(e, t) {
|
|
109
|
-
if (!e || typeof e != "object" || Array.isArray(e)) return ["参数定义项应为对象"];
|
|
110
|
-
const n = w(e);
|
|
111
|
-
return typeof e.field != "string" || !e.field.trim() || t.has(e.field) ? n.push("参数名应为非空且不重复的字符串") : t.add(e.field), n.length || (n.push(...O(e)), n.length) || (e.options && new Set(e.options.map((r) => r.value)).size !== e.options.length && n.push("选项值不能重复"), e.defaultValue !== void 0 && (e.required && !e.defaultValue.trim() ? n.push("必填参数的默认值不能为空") : e.defaultValue.trim() && n.push(...b(e, e.defaultValue).map(([, r]) => `默认值${r}`)))), n;
|
|
112
|
-
}
|
|
113
|
-
function V(e, t, n) {
|
|
114
|
-
for (const [r, i] of Object.entries(e))
|
|
115
|
-
(typeof i == "string" || typeof i == "number" && Number.isFinite(i)) && (Object.defineProperty(t, r, { value: String(i), writable: !0, enumerable: !0, configurable: !0 }), Object.defineProperty(n, r, { value: i, writable: !0, enumerable: !0, configurable: !0 }));
|
|
116
|
-
}
|
|
117
|
-
function l(e) {
|
|
118
|
-
return e == null || typeof e == "string" && !e.trim();
|
|
119
|
-
}
|
|
120
|
-
function j(e, t = {}) {
|
|
121
|
-
const n = /* @__PURE__ */ Object.create(null), r = /* @__PURE__ */ Object.create(null), i = x(e);
|
|
122
|
-
if ((!t || typeof t != "object" || Array.isArray(t)) && i.push({ code: "type", field: "", path: "$.params", message: "参数应为对象" }), i.length) return { ok: !1, values: n, typedValues: r, issues: i };
|
|
123
|
-
V(t, n, r);
|
|
124
|
-
for (const s of e) {
|
|
125
|
-
const o = Object.prototype.hasOwnProperty.call(t, s.field) && t[s.field] !== void 0 ? t[s.field] : s.defaultValue, a = (m, c) => i.push({ code: m, path: `$.params.${s.field}`, field: s.field, message: c });
|
|
126
|
-
if (l(o)) {
|
|
127
|
-
s.required && a("required", "此参数为必填项"), typeof o == "string" && (n[s.field] = o), delete r[s.field];
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
if (typeof o != "string" && !(typeof o == "number" && Number.isFinite(o))) {
|
|
131
|
-
a("type", "参数应为字符串或有限数字");
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
const u = String(o);
|
|
135
|
-
n[s.field] = u, b(s, u).forEach(([m, c]) => a(m, c)), r[s.field] = s.type === "number" && d(u) ? Number(u) : u;
|
|
136
|
-
}
|
|
137
|
-
return i.push(...I(e, n)), { ok: i.length === 0, values: n, typedValues: r, issues: i };
|
|
138
|
-
}
|
|
139
|
-
function I(e, t) {
|
|
140
|
-
return e.flatMap((n) => !l(t[n.field]) && n.dependsOn?.some((r) => l(t[r])) ? [{ code: "dependency", path: `$.params.${n.field}`, field: n.field, message: "请先填写联动依赖的上级参数" }] : []);
|
|
141
|
-
}
|
|
142
|
-
function k(e, t = {}) {
|
|
143
|
-
const n = j(e, t);
|
|
144
|
-
if (!n.ok) throw new y(n.issues);
|
|
145
|
-
return n.values;
|
|
146
|
-
}
|
|
147
|
-
function N(e) {
|
|
148
|
-
const t = {}, n = "(?![\\s\\S])";
|
|
149
|
-
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;
|
|
150
|
-
}
|
|
151
|
-
function P(e) {
|
|
152
|
-
const t = { type: e.type === "number" ? "number" : "string", title: e.label ?? e.field, ...N(e) };
|
|
153
|
-
return e.required && e.type !== "number" && !t.pattern && (t.pattern = "\\S"), e.type === "select" && e.options && (t.enum = e.options.map((n) => n.value)), Object.assign(t, A(e)), e.defaultValue !== void 0 && (e.type !== "number" || e.defaultValue.trim()) && (t.default = e.type === "number" ? Number(e.defaultValue) : e.defaultValue), e.minLength !== void 0 && (t.minLength = e.minLength), e.maxLength !== void 0 && (t.maxLength = e.maxLength), typeof e.min == "number" && (t.minimum = e.min), 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;
|
|
154
|
-
}
|
|
155
|
-
function A(e) {
|
|
156
|
-
return { ...e.optionsSource ? { "x-report-options-source": e.optionsSource } : {}, ...e.dependsOn?.length ? { "x-report-depends-on": [...e.dependsOn] } : {} };
|
|
157
|
-
}
|
|
158
|
-
function F(e) {
|
|
159
|
-
const t = x(e);
|
|
160
|
-
if (t.length) throw new y(t);
|
|
161
|
-
return {
|
|
162
|
-
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
163
|
-
type: "object",
|
|
164
|
-
properties: Object.fromEntries(e.map((n) => [n.field, P(n)])),
|
|
165
|
-
required: e.filter((n) => n.required).map((n) => n.field),
|
|
166
|
-
additionalProperties: !0
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
export {
|
|
170
|
-
y as R,
|
|
171
|
-
k as a,
|
|
172
|
-
f as b,
|
|
173
|
-
h as c,
|
|
174
|
-
j as d,
|
|
175
|
-
Y as e,
|
|
176
|
-
E as f,
|
|
177
|
-
p as i,
|
|
178
|
-
g as p,
|
|
179
|
-
F as r,
|
|
180
|
-
x as v
|
|
181
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const l=require("./style-C22Pbv3T.cjs"),u=require("./computed-C2GD3XcE.cjs");function y(e){if(!e||e.kind==="date")return;const t=e.digits;if(!(t!==void 0&&(!Number.isInteger(t)||t<0||t>100))){if(e.kind==="percent"){const r=t??2;return`0${r?`.${"0".repeat(r)}`:""}%`}return t===void 0?e.thousands?"#,##0.###############":void 0:`${e.thousands?"#,##0":"0"}${t?`.${"0".repeat(t)}`:""}`}}function S(e){const t=/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(e.trim());if(t){const n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Number.isNaN(n.getTime())?null:n}const r=new Date(e);return Number.isNaN(r.getTime())?null:r}function c(e,t){return e.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})}function L(e,t){const r=n=>String(n).padStart(2,"0");return t.replace(/YYYY/g,String(e.getFullYear())).replace(/MM/g,r(e.getMonth()+1)).replace(/DD/g,r(e.getDate())).replace(/hh/g,r(e.getHours())).replace(/mm/g,r(e.getMinutes())).replace(/ss/g,r(e.getSeconds()))}function x(e,t,r){return r!=null?t?c(e,r):e.toFixed(r):t?c(e):String(e)}function g(e){const t=typeof e=="number"?e:Number(String(e).replace(/,/g,""));return Number.isFinite(t)?t:null}function b(e,t){if(e==null||e===""||!t)return String(e??"");switch(t.kind){case"number":{if(typeof e=="string")try{return u.formatDecimal(e,t.digits,t.thousands===!0)}catch{return e}const r=g(e);return r==null?String(e):x(r,t.thousands===!0,t.digits)}case"percent":{if(typeof e=="string")try{return u.formatDecimal(e,t.digits??2,!0,!0)}catch{return e}const r=g(e);return r==null?String(e):`${c(r*100,t.digits??2)}%`}case"date":{const r=t.pattern??"YYYY-MM-DD",n=e instanceof Date?e:S(String(e));return n?L(n,r):String(e)}default:return String(e)}}function p(e,t){const r=e[t.field];if(r==null||r==="")return!1;if(typeof t.value=="number"||t.numeric!==void 0){let a;try{a=u.compareDecimal(u.parseDecimal(r),u.parseDecimal(t.value))}catch{return!1}if(!Number.isFinite(a))return!1;switch(t.op){case">":return a>0;case">=":return a>=0;case"<":return a<0;case"<=":return a<=0;case"==":return a===0;case"!=":return a!==0}}const n=String(r),i=String(t.value);switch(t.op){case"==":return n===i;case"!=":return n!==i;case">":return n>i;case">=":return n>=i;case"<":return n<i;case"<=":return n<=i}return!1}function h(e,t,r,n=e.paddingMm??1){return t.field!==e.tree.labelField?0:Math.min(r.depth*(e.tree.indentMm??3),Math.max(0,t.widthMm-n*2-4))}function D(e,t,r,n){const i=n.tree;(i.input==="nested"||[i.idField,i.parentField].includes(t.field))&&(e.editable=!1),r.hasChildren&&i.parentValues==="leaf-aggregate"&&i.aggregates?.some(a=>a.field===t.field)&&(e.derived=!0,e.editable=!1)}function N(e,t,r){return r==="identifier"||r==="dimension"||r==="date"?"center":r==="measure"?"right":r==="text"?"left":t?.kind==="number"||t?.kind==="percent"?"right":t?.kind==="date"||e instanceof Date||typeof e=="boolean"?"center":typeof e=="number"&&Number.isFinite(e)?"right":"left"}function T(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number")return String(e);if(typeof e=="boolean")return e?"是":"否";if(e instanceof Date)return e.toISOString().slice(0,10);try{return JSON.stringify(e)}catch{return String(e)}}function C(e,t){let r=l.mergeComponentStyles({fontSize:e.fontSizePt??l.DEFAULT_FONT_PT,bold:e.headerBold??!0,align:"center",verticalAlign:"middle",backgroundColor:e.headerBackgroundColor},t.style);return e.headerAlign!==void 0&&(r.align=e.headerAlign),r=l.mergeComponentStyles(r,e.headerStyle),t.headerAlign!==void 0&&(r.align=t.headerAlign),l.mergeComponentStyles(r,t.headerStyle)}function M(e,t,r){(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))&&(e.value=r);const n=t.format?.kind==="number"||t.format?.kind==="percent";t.valueType!==void 0?e.valueType=t.valueType:n&&(e.valueType="number"),t.editable!==void 0&&(e.editable=t.editable);const i=y(t.format);(typeof e.value=="number"||e.value==null)&&i!==void 0&&(e.numberFormat=i)}function F(e,t,r){const n=!!t.visibleWhen&&!p(r,t.visibleWhen),i=n?null:r[t.field],a=t.align??t.style?.align??e.align??"left";let s=l.mergeComponentStyles({fontSize:e.fontSizePt??l.DEFAULT_FONT_PT,verticalAlign:"middle"},t.style);s.align=a==="auto"?N(i,t.format,t.semanticRole):a;const o=t.rules?.find(f=>p(r,f.when));o&&(s=l.mergeComponentStyles(s,o.style));const d={text:t.format?b(i,t.format):T(i),style:s};return M(d,t,i),e.computed?.some(f=>f.field===t.field)&&(d.derived=!0,d.editable=!1),n&&(d.editable=!1),d}function A(e,t,r){const n=F(e,t,r.row),i=h(e,t,r);return t.field===e.tree.labelField&&(n.style={...n.style,align:"left"}),i&&(n.indentMm=i),D(n,t,r,e),n}function k(e){return typeof e=="string"&&/^data:image\/(png|jpe?g);base64,[A-Za-z0-9+/\r\n]+=*$/.test(e)}class m extends Error{constructor(t,r,n,i){super(`${t}: ${r}`),this.path=t,this.rowIndex=n,this.field=i,this.code="report-binding",this.name="ReportBindingError"}}function $(e,t,r={}){const n=r.rowIndex??0,a=`$.datasets.${r.dataset??"label"}[${n}].${t}`,s=Object.getOwnPropertyDescriptor(e,t);if(!s||s.get||s.set)throw new m(a,"字段必须是记录的自有数据字段,不能缺失、使用访问器或从原型继承",n,t);const o=s.value;if(o==null||typeof o=="string"||typeof o=="boolean"||typeof o=="number"&&Number.isFinite(o))return o;throw new m(a,"绑定值应为字符串、有限数字、布尔值或空值",n,t)}function w(e,t,r={}){const n=$(t,e.field,r);return n==null||n===""?e.emptyText??"":`${e.prefix??""}${b(n,e.format)}${e.suffix??""}`}exports.ReportBindingError=m;exports.applyListTreeMetadata=D;exports.evalStyleRule=p;exports.formatValue=b;exports.isLabelImageData=k;exports.listCellText=T;exports.listTreeIndent=h;exports.parseDateLocal=S;exports.readRecordScalar=$;exports.resolveComponentBinding=w;exports.resolveListAutoAlignment=N;exports.resolveListHeaderStyle=C;exports.resolveListSampleCell=F;exports.resolveTreeListSampleCell=A;exports.toExcelNumberFormat=y;exports.toNumber=g;
|