@agile-team/mach-report 2.10.0 → 2.11.1
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 +6 -2
- package/dist/ExcelBindingWizard-LWX6G1A2.js +1465 -0
- package/dist/ExcelBindingWizard-a4kslPHF.cjs +1 -0
- package/dist/ParamEditor-BLaE5q5W.js +522 -0
- package/dist/ParamEditor-MBBC7lUE.cjs +1 -0
- package/dist/ReportBatchPanel-B5ClP9tm.js +350 -0
- package/dist/ReportBatchPanel-Dc-SDkYA.cjs +1 -0
- package/dist/ReportPreview-DWXROHBP.cjs +6 -0
- package/dist/ReportPreview-DiNXhQI0.js +4138 -0
- package/dist/ReportTemplateLibrary-5fk5CQBO.cjs +1 -0
- package/dist/ReportTemplateLibrary-BZB-XWjj.js +311 -0
- package/dist/RuleEditor-C2QsOHOs.cjs +1 -0
- package/dist/RuleEditor-D9wQHrkf.js +2024 -0
- package/dist/TemplateReviewPanel-BKofGrV9.js +222 -0
- package/dist/TemplateReviewPanel-DwtOcLue.cjs +1 -0
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +2 -0
- package/dist/analytics.d.ts +2 -0
- package/dist/analytics.js +29 -29
- package/dist/batch-Bt3Fd27Z.cjs +1 -0
- package/dist/batch-mRqhhhjt.js +364 -0
- package/dist/computed-Bvk0W15F.js +521 -0
- package/dist/computed-CGV2a809.cjs +1 -0
- package/dist/config-B612mw0x.js +525 -0
- package/dist/config-BRoLo2oj.cjs +1 -0
- package/dist/designer.cjs +2 -2
- package/dist/designer.d.cts +730 -9
- package/dist/designer.d.ts +730 -9
- package/dist/designer.js +2093 -1785
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +161 -3
- package/dist/index.d.ts +161 -3
- package/dist/index.js +486 -431
- package/dist/injection-keys-Db_DyLkm.cjs +1 -0
- package/dist/injection-keys-e85udZCp.js +7 -0
- package/dist/list-cell-BuYn4tGF.cjs +1 -0
- package/dist/{list-cell-Dxyi7DOw.js → list-cell-ClFra1zS.js} +54 -40
- package/dist/matrix-DVyWiYsd.cjs +1 -0
- package/dist/matrix-yZsGnldA.js +227 -0
- package/dist/param-validation-BlHHXs6u.js +153 -0
- package/dist/param-validation-DCK039V1.cjs +1 -0
- package/dist/pdf.cjs +25 -25
- package/dist/pdf.d.cts +3 -0
- package/dist/pdf.d.ts +3 -0
- package/dist/pdf.js +677 -677
- package/dist/plugin-BDTU4D94.cjs +1 -0
- package/dist/plugin-Cd5G2QQn.js +22 -0
- package/dist/region-binding-workflow-CXDmt9Bs.js +977 -0
- package/dist/region-binding-workflow-DhQvu1co.cjs +3 -0
- package/dist/{report-params-B_VCihAh.js → report-params-B44imUd4.js} +1 -1
- package/dist/{report-params-CjWrjPl6.cjs → report-params-SJfhKgaX.cjs} +1 -1
- package/dist/server/node.d.cts +5 -2
- package/dist/server/node.d.ts +5 -2
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +87 -87
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +201 -2
- package/dist/server.d.ts +201 -2
- package/dist/server.js +557 -658
- package/dist/style.css +1 -1
- package/dist/template-registry-WNXdkiET.js +506 -0
- package/dist/template-registry-ukBGlm8N.cjs +1 -0
- package/dist/template-review-BXp2oyqg.cjs +1 -0
- package/dist/template-review-BdcXSYbx.js +1616 -0
- package/dist/tree-BX380Rr7.cjs +1 -0
- package/dist/tree-CqcQ99NM.js +172 -0
- package/dist/{validate-UUy9yP4K.js → validate-7s0yn6ii.js} +44 -44
- package/dist/validate-DsRiNw8h.cjs +1 -0
- package/dist/vue/async.d.cts +93 -4
- package/dist/vue/async.d.ts +93 -4
- package/dist/vue/index.d.cts +145 -7
- package/dist/vue/index.d.ts +145 -7
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +5 -5
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +116 -113
- package/dist/{workbook-session-B-bW5_yR.js → workbook-session-BKOTwcoq.js} +1 -1
- package/dist/{workbook-session-D7RtdNo0.cjs → workbook-session-CLYLhZWu.cjs} +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +5 -2
- package/dist/worker.d.ts +5 -2
- package/dist/worker.js +1 -1
- package/dist/xlsx.cjs +3 -3
- package/dist/xlsx.d.cts +129 -2
- package/dist/xlsx.d.ts +129 -2
- package/dist/xlsx.js +336 -242
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-CF7RplWm.cjs +0 -1
- package/dist/ExcelBindingWizard-qhwEderR.js +0 -842
- package/dist/ReportPreview-BE1tCHqE.js +0 -4604
- package/dist/ReportPreview-QKRKQOe3.cjs +0 -6
- package/dist/RuleEditor-BA36yIV6.js +0 -1723
- package/dist/RuleEditor-CczJ6mJm.cjs +0 -1
- package/dist/TemplateReviewPanel-CHi4Alqa.cjs +0 -1
- package/dist/TemplateReviewPanel-Dz0G5o83.js +0 -217
- package/dist/binding-preview-BWsdf_z2.cjs +0 -2
- package/dist/binding-preview-DILq0-0f.js +0 -649
- package/dist/decimal-CI1OAczk.js +0 -87
- package/dist/decimal-CQA0xJex.cjs +0 -1
- package/dist/list-cell-CyM1ZlRN.cjs +0 -1
- package/dist/matrix-BbXarwyk.js +0 -661
- package/dist/matrix-Cm65WLLP.cjs +0 -1
- package/dist/param-validation-BWNjLcN0.js +0 -116
- package/dist/param-validation-CiTxFeZ8.cjs +0 -1
- package/dist/plugin-CThk42vJ.cjs +0 -1
- package/dist/plugin-tGn7-5oF.js +0 -25
- package/dist/template-registry-CGWTLtIA.cjs +0 -1
- package/dist/template-registry-DzlQs3OF.js +0 -434
- package/dist/template-review-D1RoNCPw.cjs +0 -1
- package/dist/template-review-fnteXRng.js +0 -1473
- package/dist/validate-Bf6ccFr2.cjs +0 -1
package/dist/matrix-BbXarwyk.js
DELETED
|
@@ -1,661 +0,0 @@
|
|
|
1
|
-
import { d as B, p as h, a as E, m as L, b as O, e as _, c as x } from "./decimal-CI1OAczk.js";
|
|
2
|
-
const P = [
|
|
3
|
-
"sum",
|
|
4
|
-
"count",
|
|
5
|
-
"avg",
|
|
6
|
-
"min",
|
|
7
|
-
"max",
|
|
8
|
-
"weightedAvg"
|
|
9
|
-
];
|
|
10
|
-
function M(r) {
|
|
11
|
-
if (typeof r != "number" || !Number.isFinite(r))
|
|
12
|
-
throw new Error(
|
|
13
|
-
"聚合度量必须是有限数字,不能隐式转换;小数文本请显式选择 decimal"
|
|
14
|
-
);
|
|
15
|
-
return r;
|
|
16
|
-
}
|
|
17
|
-
function v(r, e) {
|
|
18
|
-
return e && Object.prototype.hasOwnProperty.call(r, e) ? r[e] : void 0;
|
|
19
|
-
}
|
|
20
|
-
function T(r) {
|
|
21
|
-
let e = 0, t = 0, n = 0, o = 0, l = 1 / 0, i = -1 / 0;
|
|
22
|
-
const u = (a) => {
|
|
23
|
-
const f = a - n, d = t + f;
|
|
24
|
-
n = d - t - f, t = d;
|
|
25
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
add(a) {
|
|
28
|
-
const f = v(a, r.field);
|
|
29
|
-
if (r.op === "count") {
|
|
30
|
-
(!r.field || f != null) && e++;
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (f == null) return;
|
|
34
|
-
const d = M(f), c = r.op === "weightedAvg" ? v(a, r.weightField) : 1;
|
|
35
|
-
if (c == null) return;
|
|
36
|
-
const s = M(c);
|
|
37
|
-
if (r.op === "weightedAvg" && s < 0)
|
|
38
|
-
throw new Error("加权平均的权重不能为负数");
|
|
39
|
-
["sum", "avg", "weightedAvg"].includes(r.op) && u(d * s), o += s, l = Math.min(l, d), i = Math.max(i, d), e++;
|
|
40
|
-
},
|
|
41
|
-
value() {
|
|
42
|
-
if (r.op === "count") return e;
|
|
43
|
-
if (!e) return null;
|
|
44
|
-
const a = r.op === "min" ? l : r.op === "max" ? i : r.op === "avg" ? t / e : r.op === "weightedAvg" ? o === 0 ? null : t / o : t;
|
|
45
|
-
if (a !== null && !Number.isFinite(a))
|
|
46
|
-
throw new Error("聚合计算溢出");
|
|
47
|
-
return a;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function W(r) {
|
|
52
|
-
let e = 0, t = h("0"), n = h("0"), o, l;
|
|
53
|
-
return {
|
|
54
|
-
add(i) {
|
|
55
|
-
const u = v(i, r.field);
|
|
56
|
-
if (r.op === "count") {
|
|
57
|
-
(!r.field || u != null) && e++;
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (u == null) return;
|
|
61
|
-
const a = r.op === "weightedAvg" ? v(i, r.weightField) : "1";
|
|
62
|
-
if (a == null) return;
|
|
63
|
-
const f = h(u), d = h(a);
|
|
64
|
-
if (r.op === "weightedAvg" && d.coefficient < 0n)
|
|
65
|
-
throw new Error("加权平均的权重不能为负数");
|
|
66
|
-
["sum", "avg", "weightedAvg"].includes(r.op) && (t = E(t, L(f, d))), r.op === "weightedAvg" && (n = E(n, d)), (!o || x(f, o) < 0) && (o = f), (!l || x(f, l) > 0) && (l = f), e++;
|
|
67
|
-
},
|
|
68
|
-
value() {
|
|
69
|
-
if (r.op === "count") return e;
|
|
70
|
-
if (!e || r.op === "weightedAvg" && n.coefficient === 0n)
|
|
71
|
-
return null;
|
|
72
|
-
let i = r.op === "min" ? o : r.op === "max" ? l : t;
|
|
73
|
-
return r.op === "avg" && (i = O(t, h(e), r.digits)), r.op === "weightedAvg" && (i = O(t, n, r.digits)), _(i, r.digits);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function N(r) {
|
|
78
|
-
if (r.digits !== void 0 && B(r.digits), r.numeric !== void 0 && r.numeric !== "number" && r.numeric !== "decimal")
|
|
79
|
-
throw new Error("未知聚合数值模式");
|
|
80
|
-
if (!P.includes(r.op)) throw new Error("未知聚合操作");
|
|
81
|
-
if (r.op !== "count" && !r.field)
|
|
82
|
-
throw new Error("聚合需要度量字段");
|
|
83
|
-
if (r.op === "weightedAvg" && !r.weightField)
|
|
84
|
-
throw new Error("加权平均需要权重字段");
|
|
85
|
-
return r.numeric === "decimal" ? W(r) : T(r);
|
|
86
|
-
}
|
|
87
|
-
function C(r, e) {
|
|
88
|
-
const t = N(e);
|
|
89
|
-
for (const n of r) t.add(n);
|
|
90
|
-
return t.value();
|
|
91
|
-
}
|
|
92
|
-
function b(r, e) {
|
|
93
|
-
return Object.prototype.hasOwnProperty.call(r, e) ? r[e] : void 0;
|
|
94
|
-
}
|
|
95
|
-
function R(r) {
|
|
96
|
-
if (r == null) return "null";
|
|
97
|
-
if (typeof r != "string" && typeof r != "boolean" && !(typeof r == "number" && Number.isFinite(r)))
|
|
98
|
-
throw new Error("交叉表维度应为字符串、布尔、有限数字或空值");
|
|
99
|
-
return JSON.stringify([typeof r, r]);
|
|
100
|
-
}
|
|
101
|
-
function j(r) {
|
|
102
|
-
return r == null ? "" : String(r);
|
|
103
|
-
}
|
|
104
|
-
function p(r, e) {
|
|
105
|
-
const t = r ?? e;
|
|
106
|
-
if (!Number.isInteger(t) || t < 1)
|
|
107
|
-
throw new Error("交叉表预算应为正整数");
|
|
108
|
-
return t;
|
|
109
|
-
}
|
|
110
|
-
function Z(r, e, t, n) {
|
|
111
|
-
const o = t ? 1 : 0;
|
|
112
|
-
if ((r + o) * (e + 1 + o) > n)
|
|
113
|
-
throw new Error(
|
|
114
|
-
"交叉表输出单元格超出 maxCells 预算,请减少维度或服务端预聚合"
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
function H(r, e) {
|
|
118
|
-
if (!Array.isArray(r)) throw new Error("交叉表数据应为对象数组");
|
|
119
|
-
const t = e.aggregate ?? "sum";
|
|
120
|
-
if (!["sum", "count", "avg", "min", "max", "weightedAvg"].includes(t))
|
|
121
|
-
throw new Error("未知交叉表聚合类型");
|
|
122
|
-
if (!e.rowField || !e.columnField || t !== "count" && !e.valueField)
|
|
123
|
-
throw new Error("交叉表需要明确的行维度、列维度和度量字段");
|
|
124
|
-
if (r.length > p(e.maxInputRows, 1e5))
|
|
125
|
-
throw new Error("交叉表输入超出预算,请在服务端预聚合");
|
|
126
|
-
const n = p(e.maxRows, 1e3), o = p(e.maxColumns, 200), l = p(e.maxCells, 2e6), i = () => N({
|
|
127
|
-
op: t,
|
|
128
|
-
field: t === "count" && e.countMode !== "nonNull" ? void 0 : e.valueField,
|
|
129
|
-
weightField: e.weightField,
|
|
130
|
-
numeric: e.numeric,
|
|
131
|
-
digits: e.digits
|
|
132
|
-
}), u = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), d = i();
|
|
133
|
-
for (const s of r) {
|
|
134
|
-
const m = R(b(s, e.rowField)), w = R(b(s, e.columnField));
|
|
135
|
-
if (u.has(w) || u.set(w, j(b(s, e.columnField))), a.has(m) || a.set(m, {
|
|
136
|
-
label: j(b(s, e.rowField)),
|
|
137
|
-
cells: /* @__PURE__ */ new Map(),
|
|
138
|
-
total: i()
|
|
139
|
-
}), u.size > o || a.size > n)
|
|
140
|
-
throw new Error("交叉表维度数量超出预算");
|
|
141
|
-
Z(a.size, u.size, e.totals, l);
|
|
142
|
-
const g = a.get(m);
|
|
143
|
-
g.cells.has(w) || g.cells.set(w, i()), f.has(w) || f.set(w, i());
|
|
144
|
-
for (const F of [
|
|
145
|
-
g.cells.get(w),
|
|
146
|
-
g.total,
|
|
147
|
-
f.get(w),
|
|
148
|
-
d
|
|
149
|
-
])
|
|
150
|
-
F.add(s);
|
|
151
|
-
}
|
|
152
|
-
const c = {
|
|
153
|
-
columns: [
|
|
154
|
-
{
|
|
155
|
-
header: e.rowHeader ?? e.rowField,
|
|
156
|
-
field: "rowLabel",
|
|
157
|
-
semanticRole: "dimension"
|
|
158
|
-
},
|
|
159
|
-
...[...u.values()].map(
|
|
160
|
-
(s, m) => ({
|
|
161
|
-
header: s,
|
|
162
|
-
field: `c${m}`,
|
|
163
|
-
semanticRole: "measure"
|
|
164
|
-
})
|
|
165
|
-
)
|
|
166
|
-
],
|
|
167
|
-
rows: [...a.values()].map((s) => ({
|
|
168
|
-
rowLabel: s.label,
|
|
169
|
-
...Object.fromEntries(
|
|
170
|
-
[...u.keys()].map((m, w) => [
|
|
171
|
-
`c${w}`,
|
|
172
|
-
s.cells.get(m)?.value() ?? (t === "count" ? 0 : null)
|
|
173
|
-
])
|
|
174
|
-
),
|
|
175
|
-
...e.totals ? { total: s.total.value() } : {}
|
|
176
|
-
}))
|
|
177
|
-
};
|
|
178
|
-
return e.totals && (c.columns.push({
|
|
179
|
-
header: "合计",
|
|
180
|
-
field: "total",
|
|
181
|
-
semanticRole: "measure"
|
|
182
|
-
}), r.length && c.rows.push({
|
|
183
|
-
rowLabel: "合计",
|
|
184
|
-
...Object.fromEntries(
|
|
185
|
-
[...u.keys()].map((s, m) => [
|
|
186
|
-
`c${m}`,
|
|
187
|
-
f.get(s)?.value() ?? (t === "count" ? 0 : null)
|
|
188
|
-
])
|
|
189
|
-
),
|
|
190
|
-
total: d.value()
|
|
191
|
-
})), c;
|
|
192
|
-
}
|
|
193
|
-
const K = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
194
|
-
function y(r) {
|
|
195
|
-
if (typeof r != "string" || !r.trim() || K.has(r))
|
|
196
|
-
throw new Error("计算字段应为安全的非空字段名");
|
|
197
|
-
}
|
|
198
|
-
function S(r) {
|
|
199
|
-
return r === null || ["string", "boolean"].includes(typeof r) || typeof r == "number" && Number.isFinite(r);
|
|
200
|
-
}
|
|
201
|
-
function U(r) {
|
|
202
|
-
if (r.some((e) => typeof e != "number" || !Number.isFinite(e)))
|
|
203
|
-
throw new Error("算术参数必须是有限数字;空值和小数文本不会隐式转换");
|
|
204
|
-
return r;
|
|
205
|
-
}
|
|
206
|
-
function V(r, e) {
|
|
207
|
-
const t = U(e);
|
|
208
|
-
let n;
|
|
209
|
-
if (r === "add") n = t.reduce((o, l) => o + l, 0);
|
|
210
|
-
else if (r === "multiply") n = t.reduce((o, l) => o * l, 1);
|
|
211
|
-
else if (r === "subtract") n = t[0] - t[1];
|
|
212
|
-
else {
|
|
213
|
-
if (t[1] === 0) throw new Error("不能除以零");
|
|
214
|
-
n = t[0] / t[1];
|
|
215
|
-
}
|
|
216
|
-
if (!Number.isFinite(n)) throw new Error("计算结果不是有限数字");
|
|
217
|
-
return n;
|
|
218
|
-
}
|
|
219
|
-
function G(r, e, t) {
|
|
220
|
-
const n = e.map(h);
|
|
221
|
-
let o;
|
|
222
|
-
return r === "add" ? o = n.reduce(E) : r === "multiply" ? o = n.reduce(L) : r === "subtract" ? o = E(n[0], {
|
|
223
|
-
...n[1],
|
|
224
|
-
coefficient: -n[1].coefficient
|
|
225
|
-
}) : o = O(n[0], n[1], t), _(o, t);
|
|
226
|
-
}
|
|
227
|
-
function Q(r, e, t) {
|
|
228
|
-
return t.nulls !== "error" && e.some((n) => n == null) || r === "divide" && t.divisionByZero === "null" && (t.numeric === "decimal" ? h(e[1]).coefficient === 0n : e[1] === 0) ? null : t.numeric === "decimal" ? G(r, e, t.digits) : V(r, e);
|
|
229
|
-
}
|
|
230
|
-
function X(r, e) {
|
|
231
|
-
r.field !== void 0 && y(r.field), r.weightField !== void 0 && y(r.weightField);
|
|
232
|
-
const t = {
|
|
233
|
-
op: r.aggregate,
|
|
234
|
-
field: r.field,
|
|
235
|
-
weightField: r.weightField,
|
|
236
|
-
numeric: e.numeric,
|
|
237
|
-
digits: e.digits
|
|
238
|
-
};
|
|
239
|
-
C([], t);
|
|
240
|
-
const n = /* @__PURE__ */ new WeakMap();
|
|
241
|
-
return (o) => {
|
|
242
|
-
let l = n.get(o.rows);
|
|
243
|
-
if (!l) {
|
|
244
|
-
try {
|
|
245
|
-
l = { value: C(o.rows, t) };
|
|
246
|
-
} catch (i) {
|
|
247
|
-
l = {
|
|
248
|
-
error: i instanceof Error ? i : new Error(String(i))
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
n.set(o.rows, l);
|
|
252
|
-
}
|
|
253
|
-
if (l.error) throw l.error;
|
|
254
|
-
return l.value;
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
function Y(r, e) {
|
|
258
|
-
for (const t of r) {
|
|
259
|
-
const n = t(e);
|
|
260
|
-
if (n != null) return n;
|
|
261
|
-
}
|
|
262
|
-
return null;
|
|
263
|
-
}
|
|
264
|
-
function k(r, e = {}, t = { nodes: 0 }, n = 0) {
|
|
265
|
-
if (++t.nodes > 256 || n > 16)
|
|
266
|
-
throw new Error("计算表达式超出深度或节点预算");
|
|
267
|
-
if (!r || typeof r != "object" || Array.isArray(r))
|
|
268
|
-
throw new Error("计算表达式应为声明式对象");
|
|
269
|
-
if ("aggregate" in r) return X(r, e);
|
|
270
|
-
if ("field" in r) {
|
|
271
|
-
y(r.field);
|
|
272
|
-
const o = r.field;
|
|
273
|
-
return ({ row: l }) => Object.prototype.hasOwnProperty.call(l, o) ? l[o] : void 0;
|
|
274
|
-
}
|
|
275
|
-
if ("value" in r) {
|
|
276
|
-
if (!S(r.value))
|
|
277
|
-
throw new Error("常量应为有限 JSON 标量");
|
|
278
|
-
return () => r.value;
|
|
279
|
-
}
|
|
280
|
-
return q(r, e, t, n);
|
|
281
|
-
}
|
|
282
|
-
function q(r, e, t, n) {
|
|
283
|
-
if (!["add", "subtract", "multiply", "divide", "coalesce"].includes(
|
|
284
|
-
r.op
|
|
285
|
-
) || !Array.isArray(r.args))
|
|
286
|
-
throw new Error("未知计算操作");
|
|
287
|
-
if (r.args.length > 256 || Object.keys(r.args).length !== r.args.length)
|
|
288
|
-
throw new Error("计算参数超出预算或包含空位");
|
|
289
|
-
if (r.args.length < 2 || ["subtract", "divide"].includes(r.op) && r.args.length !== 2)
|
|
290
|
-
throw new Error("运算参数数量不正确");
|
|
291
|
-
const o = r.args.map(
|
|
292
|
-
(l) => k(l, e, t, n + 1)
|
|
293
|
-
);
|
|
294
|
-
return r.op === "coalesce" ? (l) => Y(o, l) : (l) => Q(
|
|
295
|
-
r.op,
|
|
296
|
-
o.map((i) => i(l)),
|
|
297
|
-
e
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
function rr(r) {
|
|
301
|
-
k(r);
|
|
302
|
-
const e = /* @__PURE__ */ new Set(), t = (n) => {
|
|
303
|
-
"field" in n && n.field && e.add(n.field), "aggregate" in n && n.weightField && e.add(n.weightField), "args" in n && n.args.forEach(t);
|
|
304
|
-
};
|
|
305
|
-
return t(r), [...e];
|
|
306
|
-
}
|
|
307
|
-
function er(r) {
|
|
308
|
-
if (y(r.field), r.scope !== void 0 && !["row", "group", "dataset"].includes(r.scope))
|
|
309
|
-
throw new Error("未知计算范围");
|
|
310
|
-
if (r.numeric !== void 0 && r.numeric !== "number" && r.numeric !== "decimal")
|
|
311
|
-
throw new Error("未知数值模式");
|
|
312
|
-
if (r.digits !== void 0 && B(r.digits), r.nulls !== void 0 && r.nulls !== "propagate" && r.nulls !== "error")
|
|
313
|
-
throw new Error("未知空值规则");
|
|
314
|
-
if (r.divisionByZero !== void 0 && r.divisionByZero !== "null" && r.divisionByZero !== "error")
|
|
315
|
-
throw new Error("未知除零规则");
|
|
316
|
-
if (r.scope === "group" && (!Array.isArray(r.groupBy) || !r.groupBy.length))
|
|
317
|
-
throw new Error("分组计算需要 groupBy 字段");
|
|
318
|
-
tr(r);
|
|
319
|
-
}
|
|
320
|
-
function tr(r) {
|
|
321
|
-
if (r.groupBy !== void 0) {
|
|
322
|
-
if (!Array.isArray(r.groupBy) || r.groupBy.length > 16)
|
|
323
|
-
throw new Error("计算分组最多 16 级");
|
|
324
|
-
r.groupBy.forEach(y);
|
|
325
|
-
}
|
|
326
|
-
if (r.dependsOn !== void 0) {
|
|
327
|
-
if (!Array.isArray(r.dependsOn) || r.dependsOn.length > 2048)
|
|
328
|
-
throw new Error("计算依赖超出预算");
|
|
329
|
-
r.dependsOn.forEach(y);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
function D(r) {
|
|
333
|
-
return [
|
|
334
|
-
.../* @__PURE__ */ new Set([
|
|
335
|
-
...typeof r.expression == "string" ? r.dependsOn ?? [] : rr(r.expression),
|
|
336
|
-
...r.groupBy ?? []
|
|
337
|
-
])
|
|
338
|
-
];
|
|
339
|
-
}
|
|
340
|
-
function I(r) {
|
|
341
|
-
if (!Array.isArray(r) || r.length > 2048)
|
|
342
|
-
throw new Error("计算字段应为数组且最多2048项");
|
|
343
|
-
const e = /* @__PURE__ */ new Map();
|
|
344
|
-
for (const i of r) {
|
|
345
|
-
if (er(i), e.has(i.field)) throw new Error(`计算字段重复:${i.field}`);
|
|
346
|
-
e.set(i.field, i);
|
|
347
|
-
}
|
|
348
|
-
const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), o = [];
|
|
349
|
-
function l(i) {
|
|
350
|
-
if (!n.has(i.field)) {
|
|
351
|
-
if (t.has(i.field))
|
|
352
|
-
throw new Error(
|
|
353
|
-
`计算字段存在循环依赖:${[...t, i.field].join(" → ")}`
|
|
354
|
-
);
|
|
355
|
-
t.add(i.field);
|
|
356
|
-
for (const u of D(i)) {
|
|
357
|
-
const a = e.get(u);
|
|
358
|
-
a && l(a);
|
|
359
|
-
}
|
|
360
|
-
t.delete(i.field), n.add(i.field), o.push(i);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
return r.forEach(l), o;
|
|
364
|
-
}
|
|
365
|
-
function mr(r) {
|
|
366
|
-
try {
|
|
367
|
-
const e = I(r);
|
|
368
|
-
return {
|
|
369
|
-
valid: !0,
|
|
370
|
-
errors: [],
|
|
371
|
-
order: e.map((t) => t.field),
|
|
372
|
-
fields: r.map((t) => ({
|
|
373
|
-
field: t.field,
|
|
374
|
-
dependencies: D(t),
|
|
375
|
-
scope: t.scope ?? "row"
|
|
376
|
-
}))
|
|
377
|
-
};
|
|
378
|
-
} catch (e) {
|
|
379
|
-
return {
|
|
380
|
-
valid: !1,
|
|
381
|
-
errors: [e instanceof Error ? e.message : String(e)],
|
|
382
|
-
fields: [],
|
|
383
|
-
order: []
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
function dr(r = []) {
|
|
388
|
-
return {
|
|
389
|
-
fields: r.map((e) => ({ ...e })),
|
|
390
|
-
functions: [
|
|
391
|
-
{
|
|
392
|
-
name: "add",
|
|
393
|
-
minArgs: 2,
|
|
394
|
-
maxArgs: 256,
|
|
395
|
-
input: "numeric",
|
|
396
|
-
output: "numeric"
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
name: "subtract",
|
|
400
|
-
minArgs: 2,
|
|
401
|
-
maxArgs: 2,
|
|
402
|
-
input: "numeric",
|
|
403
|
-
output: "numeric"
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
name: "multiply",
|
|
407
|
-
minArgs: 2,
|
|
408
|
-
maxArgs: 256,
|
|
409
|
-
input: "numeric",
|
|
410
|
-
output: "numeric"
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
name: "divide",
|
|
414
|
-
minArgs: 2,
|
|
415
|
-
maxArgs: 2,
|
|
416
|
-
input: "numeric",
|
|
417
|
-
output: "numeric"
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
name: "coalesce",
|
|
421
|
-
minArgs: 2,
|
|
422
|
-
maxArgs: 256,
|
|
423
|
-
input: "scalar",
|
|
424
|
-
output: "scalar"
|
|
425
|
-
}
|
|
426
|
-
],
|
|
427
|
-
operations: ["add", "subtract", "multiply", "divide", "coalesce"],
|
|
428
|
-
aggregates: ["sum", "count", "avg", "min", "max", "weightedAvg"],
|
|
429
|
-
scopes: ["row", "group", "dataset"],
|
|
430
|
-
numericModes: ["number", "decimal"],
|
|
431
|
-
rules: {
|
|
432
|
-
nulls: "propagate",
|
|
433
|
-
aggregateNulls: "skip",
|
|
434
|
-
emptyAggregate: null,
|
|
435
|
-
countEmpty: 0,
|
|
436
|
-
divisionByZero: "error",
|
|
437
|
-
decimalOutput: "string",
|
|
438
|
-
rounding: "half-away-from-zero"
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
function nr(r) {
|
|
443
|
-
return I(r.fields).map((e) => {
|
|
444
|
-
if (typeof e.expression != "string")
|
|
445
|
-
return {
|
|
446
|
-
definition: e,
|
|
447
|
-
read: k(e.expression, e)
|
|
448
|
-
};
|
|
449
|
-
if (!r.formula)
|
|
450
|
-
throw new Error("字符串公式需要显式配置 formula adapter");
|
|
451
|
-
const t = e.expression;
|
|
452
|
-
return {
|
|
453
|
-
definition: e,
|
|
454
|
-
read: (n) => r.formula.evaluate(t, n)
|
|
455
|
-
};
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
function ir(r, e) {
|
|
459
|
-
return JSON.stringify(
|
|
460
|
-
e.map((t) => {
|
|
461
|
-
const n = Object.prototype.hasOwnProperty.call(r, t) ? r[t] : null;
|
|
462
|
-
if (n != null && !S(n))
|
|
463
|
-
throw new Error("分组字段应为有限 JSON 标量");
|
|
464
|
-
return [typeof n, n ?? null];
|
|
465
|
-
})
|
|
466
|
-
);
|
|
467
|
-
}
|
|
468
|
-
function or(r, e) {
|
|
469
|
-
if (e.scope === "dataset") return () => r;
|
|
470
|
-
if (e.scope !== "group") {
|
|
471
|
-
const o = /* @__PURE__ */ new WeakMap();
|
|
472
|
-
return (l) => {
|
|
473
|
-
let i = o.get(l);
|
|
474
|
-
return i || (i = [l], o.set(l, i)), i;
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new WeakMap();
|
|
478
|
-
for (const o of r) {
|
|
479
|
-
const l = ir(o, e.groupBy);
|
|
480
|
-
n.set(o, l);
|
|
481
|
-
const i = t.get(l);
|
|
482
|
-
i ? i.push(o) : t.set(l, [o]);
|
|
483
|
-
}
|
|
484
|
-
return (o) => t.get(n.get(o));
|
|
485
|
-
}
|
|
486
|
-
function lr(r, e) {
|
|
487
|
-
const t = e.maxRows ?? 1e5, n = e.maxCells ?? 2e6;
|
|
488
|
-
if (!Array.isArray(r) || !Number.isSafeInteger(t) || t < 1 || r.length > t)
|
|
489
|
-
throw new Error("计算数据行数超出预算或输入不是数组");
|
|
490
|
-
if (!Array.isArray(e.fields) || e.fields.length > 2048)
|
|
491
|
-
throw new Error("计算字段应为数组且最多2048项");
|
|
492
|
-
if (!Number.isSafeInteger(n) || n < 1 || r.length * e.fields.length > n)
|
|
493
|
-
throw new Error("计算单元格超出 maxCells 预算");
|
|
494
|
-
}
|
|
495
|
-
function z(r) {
|
|
496
|
-
if (r?.aborted) {
|
|
497
|
-
const e = new Error("数据计算已取消");
|
|
498
|
-
throw e.name = "AbortError", e;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
function ar(r, e, t, n, o, l) {
|
|
502
|
-
try {
|
|
503
|
-
const i = r.read({ row: e, rowIndex: t, rows: n });
|
|
504
|
-
if (i !== void 0 && !S(i))
|
|
505
|
-
throw new Error("计算结果应为有限 JSON 标量,异步公式请先在数据源中求值");
|
|
506
|
-
e[r.definition.field] = i ?? null;
|
|
507
|
-
} catch (i) {
|
|
508
|
-
const u = i instanceof Error ? i.message : String(i);
|
|
509
|
-
if (o.onError !== "null")
|
|
510
|
-
throw Object.assign(
|
|
511
|
-
new Error(`第 ${t + 1} 行 ${r.definition.field}:${u}`),
|
|
512
|
-
{ cause: i }
|
|
513
|
-
);
|
|
514
|
-
e[r.definition.field] = null, l.push({ rowIndex: t, field: r.definition.field, message: u });
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
function wr(r, e) {
|
|
518
|
-
lr(r, e), z(e.signal);
|
|
519
|
-
const t = nr(e), n = [], o = r.map((l, i) => {
|
|
520
|
-
if (!l || typeof l != "object" || Array.isArray(l))
|
|
521
|
-
throw new Error(`第 ${i + 1} 行应为对象`);
|
|
522
|
-
return { ...l };
|
|
523
|
-
});
|
|
524
|
-
for (const l of t) {
|
|
525
|
-
const i = or(o, l.definition);
|
|
526
|
-
o.forEach((u, a) => {
|
|
527
|
-
z(e.signal), ar(l, u, a, i(u), e, n);
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
return { rows: o, issues: n };
|
|
531
|
-
}
|
|
532
|
-
function A(r, e) {
|
|
533
|
-
const t = e.map(
|
|
534
|
-
(n) => Object.prototype.hasOwnProperty.call(r, n) ? r[n] : null
|
|
535
|
-
);
|
|
536
|
-
if (t.some(
|
|
537
|
-
(n) => n != null && typeof n != "string" && typeof n != "boolean" && !(typeof n == "number" && Number.isFinite(n))
|
|
538
|
-
))
|
|
539
|
-
throw new Error("矩阵维度必须是有限 JSON 标量");
|
|
540
|
-
return {
|
|
541
|
-
key: JSON.stringify(t.map((n) => [typeof n, n ?? null])),
|
|
542
|
-
label: t.map((n) => n == null ? "" : String(n)).join(" / ")
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
function cr(r) {
|
|
546
|
-
for (const e of [
|
|
547
|
-
"maxRows",
|
|
548
|
-
"maxColumns",
|
|
549
|
-
"maxInputRows",
|
|
550
|
-
"maxCells"
|
|
551
|
-
])
|
|
552
|
-
if (r[e] !== void 0 && (!Number.isSafeInteger(r[e]) || r[e] < 1))
|
|
553
|
-
throw new Error("矩阵预算应为正安全整数");
|
|
554
|
-
for (const e of ["columnWidthMm", "rowWidthMm"])
|
|
555
|
-
if (r[e] !== void 0 && (!Number.isFinite(r[e]) || r[e] <= 0))
|
|
556
|
-
throw new Error("矩阵列宽应为正数");
|
|
557
|
-
}
|
|
558
|
-
function ur(r) {
|
|
559
|
-
if (!r || !Array.isArray(r.rowFields) || !Array.isArray(r.columnFields) || !Array.isArray(r.measures))
|
|
560
|
-
throw new Error("矩阵需要行维度、列维度和度量数组");
|
|
561
|
-
for (const t of [r.rowFields, r.columnFields])
|
|
562
|
-
if (t.some((n) => typeof n != "string" || !n.trim()) || new Set(t).size !== t.length)
|
|
563
|
-
throw new Error("矩阵维度字段应非空且唯一");
|
|
564
|
-
if (cr(r), !r.rowFields.length || !r.columnFields.length || r.rowFields.length > 16 || r.columnFields.length > 16)
|
|
565
|
-
throw new Error("矩阵需要 1–16 个行/列维度");
|
|
566
|
-
if (!r.measures.length || r.measures.length > 32)
|
|
567
|
-
throw new Error("矩阵需要 1–32 个度量");
|
|
568
|
-
if (r.measures.map((t) => {
|
|
569
|
-
if (!t || typeof t != "object") throw new Error("矩阵度量应为对象");
|
|
570
|
-
if (N({
|
|
571
|
-
...t,
|
|
572
|
-
field: t.valueField ?? t.field
|
|
573
|
-
}), t.label !== void 0 && typeof t.label != "string")
|
|
574
|
-
throw new Error("矩阵度量标签应为字符串");
|
|
575
|
-
return t.field;
|
|
576
|
-
}).some((t) => typeof t != "string" || !t.trim()))
|
|
577
|
-
throw new Error("矩阵度量字段应非空");
|
|
578
|
-
}
|
|
579
|
-
function sr(r, e) {
|
|
580
|
-
if (ur(e), !Array.isArray(r) || r.length > (e.maxInputRows ?? 1e5))
|
|
581
|
-
throw new Error("矩阵输入超出预算");
|
|
582
|
-
const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
583
|
-
for (const i of r) {
|
|
584
|
-
if (!i || typeof i != "object" || Array.isArray(i))
|
|
585
|
-
throw new Error("矩阵数据行应为对象");
|
|
586
|
-
if (t.add(A(i, e.rowFields).key), n.add(A(i, e.columnFields).key), t.size > (e.maxRows ?? 1e3) || n.size > (e.maxColumns ?? 200))
|
|
587
|
-
throw new Error("矩阵维度数量超出预算");
|
|
588
|
-
if ((t.size + +!!e.totals) * ((n.size + +!!e.totals) * e.measures.length + 1) > (e.maxCells ?? 2e6))
|
|
589
|
-
throw new Error("矩阵输出超出 maxCells 预算");
|
|
590
|
-
}
|
|
591
|
-
const o = t.size + +(!!e.totals && r.length > 0), l = (n.size + +!!e.totals) * e.measures.length + 1;
|
|
592
|
-
return { rowCount: o, columnCount: l, cells: o * l };
|
|
593
|
-
}
|
|
594
|
-
function $(r, e) {
|
|
595
|
-
let t = e;
|
|
596
|
-
for (; r.some((n) => Object.prototype.hasOwnProperty.call(n, t)); )
|
|
597
|
-
t += "_";
|
|
598
|
-
return t;
|
|
599
|
-
}
|
|
600
|
-
function gr(r, e) {
|
|
601
|
-
sr(r, e);
|
|
602
|
-
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = $(r, "__matrix_row"), l = $(r, "__matrix_column"), i = r.map((c) => {
|
|
603
|
-
const s = A(c, e.rowFields), m = A(c, e.columnFields);
|
|
604
|
-
return t.set(s.key, s.label), n.set(m.key, m.label), { ...c, [o]: s.key, [l]: m.key };
|
|
605
|
-
}), u = e.maxCells ?? 2e6;
|
|
606
|
-
if ((t.size + +!!e.totals) * ((n.size + +!!e.totals) * e.measures.length + 1) > u)
|
|
607
|
-
throw new Error("矩阵输出超出 maxCells 预算");
|
|
608
|
-
const a = e.measures.map(
|
|
609
|
-
(c) => H(i, {
|
|
610
|
-
rowField: o,
|
|
611
|
-
columnField: l,
|
|
612
|
-
valueField: c.valueField ?? c.field,
|
|
613
|
-
aggregate: c.op,
|
|
614
|
-
countMode: "nonNull",
|
|
615
|
-
weightField: c.weightField,
|
|
616
|
-
numeric: c.numeric,
|
|
617
|
-
digits: c.digits,
|
|
618
|
-
totals: e.totals,
|
|
619
|
-
maxRows: e.maxRows,
|
|
620
|
-
maxColumns: e.maxColumns,
|
|
621
|
-
maxInputRows: e.maxInputRows,
|
|
622
|
-
maxCells: u
|
|
623
|
-
})
|
|
624
|
-
), f = a[0].rows.map(
|
|
625
|
-
(c) => ({
|
|
626
|
-
rowLabel: t.get(String(c.rowLabel)) ?? String(c.rowLabel)
|
|
627
|
-
})
|
|
628
|
-
), d = [
|
|
629
|
-
{
|
|
630
|
-
field: "rowLabel",
|
|
631
|
-
header: e.rowHeader ?? e.rowFields.join(" / "),
|
|
632
|
-
semanticRole: "dimension"
|
|
633
|
-
}
|
|
634
|
-
];
|
|
635
|
-
for (let c = 0; c < a.length; c++) {
|
|
636
|
-
const s = a[c], m = e.measures[c];
|
|
637
|
-
for (const w of s.columns.slice(1)) {
|
|
638
|
-
const g = `${w.field}_${c}`;
|
|
639
|
-
d.push({
|
|
640
|
-
...w,
|
|
641
|
-
field: g,
|
|
642
|
-
...m.digits === void 0 ? {} : { format: { kind: "number", digits: m.digits } },
|
|
643
|
-
header: `${n.get(w.header) ?? w.header} · ${m.label ?? `${m.field} (${m.op})`}`
|
|
644
|
-
}), s.rows.forEach((F, J) => {
|
|
645
|
-
f[J][g] = F[w.field];
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
return { rows: f, columns: d };
|
|
650
|
-
}
|
|
651
|
-
export {
|
|
652
|
-
C as a,
|
|
653
|
-
N as b,
|
|
654
|
-
wr as c,
|
|
655
|
-
H as d,
|
|
656
|
-
gr as e,
|
|
657
|
-
sr as f,
|
|
658
|
-
dr as g,
|
|
659
|
-
ur as h,
|
|
660
|
-
mr as v
|
|
661
|
-
};
|