@agile-team/mach-report 2.10.0 → 2.11.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 +6 -2
- package/dist/ExcelBindingWizard-CjIiVox-.cjs +1 -0
- package/dist/ExcelBindingWizard-Dxm-K5HL.js +1240 -0
- package/dist/ParamEditor-D-Hf5xfO.cjs +1 -0
- package/dist/ParamEditor-DRGxzxeO.js +381 -0
- package/dist/ReportBatchPanel-BYgg0EDB.cjs +1 -0
- package/dist/ReportBatchPanel-Bby5yLzU.js +287 -0
- package/dist/ReportPreview-DWXROHBP.cjs +6 -0
- package/dist/ReportPreview-DiNXhQI0.js +4138 -0
- package/dist/ReportTemplateLibrary-C6CO7YCT.cjs +1 -0
- package/dist/ReportTemplateLibrary-DfzDXRvr.js +260 -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 +659 -9
- package/dist/designer.d.ts +659 -9
- package/dist/designer.js +2030 -1824
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +147 -3
- package/dist/index.d.ts +147 -3
- package/dist/index.js +639 -592
- 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
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
class m extends Error {
|
|
2
|
+
constructor(t, n, r) {
|
|
3
|
+
super(n), this.code = t, this.path = r, this.name = "ReportRuntimeError";
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
function S(e) {
|
|
7
|
+
if (!e?.aborted) return;
|
|
8
|
+
if (e.reason instanceof m) throw e.reason;
|
|
9
|
+
const t = new Error("报表执行已取消");
|
|
10
|
+
throw t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
|
|
11
|
+
}
|
|
12
|
+
function Z(e, t, n) {
|
|
13
|
+
if (!Number.isFinite(n) || n < 0) throw new m("budget", `${t} 的执行统计无效`, `$.budget.${t}`);
|
|
14
|
+
const r = e[t];
|
|
15
|
+
if (r !== void 0 && n > r) throw new m("budget", `${t} 超出预算 ${r}(实际 ${n})`, `$.budget.${t}`);
|
|
16
|
+
}
|
|
17
|
+
function F(e) {
|
|
18
|
+
for (const [t, n] of Object.entries(e)) {
|
|
19
|
+
if (n !== void 0 && (!Number.isFinite(n) || n <= 0)) throw new m("budget", `${t} 应为正有限数字`, `$.budget.${t}`);
|
|
20
|
+
if (t !== "maxDurationMs" && n !== void 0 && !Number.isSafeInteger(n)) throw new m("budget", `${t} 应为正安全整数`, `$.budget.${t}`);
|
|
21
|
+
if (t === "maxDurationMs" && n !== void 0 && n > 2147483647) throw new m("budget", "maxDurationMs 不能超过 2147483647", `$.budget.${t}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function V(e, t, n) {
|
|
25
|
+
const r = new AbortController(), s = () => r.abort(e?.reason);
|
|
26
|
+
e?.addEventListener("abort", s, { once: !0 }), e?.aborted && s();
|
|
27
|
+
const a = Date.now(), c = t === void 0 ? void 0 : setTimeout(() => r.abort(new m("timeout", `报表执行超过 ${t}ms`)), t);
|
|
28
|
+
let d;
|
|
29
|
+
try {
|
|
30
|
+
S(r.signal);
|
|
31
|
+
const g = new Promise((u, i) => {
|
|
32
|
+
d = () => {
|
|
33
|
+
try {
|
|
34
|
+
S(r.signal);
|
|
35
|
+
} catch (w) {
|
|
36
|
+
i(w);
|
|
37
|
+
}
|
|
38
|
+
}, r.signal.addEventListener("abort", d, { once: !0 });
|
|
39
|
+
}), o = await Promise.race([n(r.signal), g]);
|
|
40
|
+
if (S(r.signal), t !== void 0 && Date.now() - a > t) throw new m("timeout", `报表执行超过 ${t}ms`);
|
|
41
|
+
return o;
|
|
42
|
+
} finally {
|
|
43
|
+
c !== void 0 && clearTimeout(c), d && r.signal.removeEventListener("abort", d), e?.removeEventListener("abort", s);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const B = new Uint32Array([
|
|
47
|
+
1116352408,
|
|
48
|
+
1899447441,
|
|
49
|
+
3049323471,
|
|
50
|
+
3921009573,
|
|
51
|
+
961987163,
|
|
52
|
+
1508970993,
|
|
53
|
+
2453635748,
|
|
54
|
+
2870763221,
|
|
55
|
+
3624381080,
|
|
56
|
+
310598401,
|
|
57
|
+
607225278,
|
|
58
|
+
1426881987,
|
|
59
|
+
1925078388,
|
|
60
|
+
2162078206,
|
|
61
|
+
2614888103,
|
|
62
|
+
3248222580,
|
|
63
|
+
3835390401,
|
|
64
|
+
4022224774,
|
|
65
|
+
264347078,
|
|
66
|
+
604807628,
|
|
67
|
+
770255983,
|
|
68
|
+
1249150122,
|
|
69
|
+
1555081692,
|
|
70
|
+
1996064986,
|
|
71
|
+
2554220882,
|
|
72
|
+
2821834349,
|
|
73
|
+
2952996808,
|
|
74
|
+
3210313671,
|
|
75
|
+
3336571891,
|
|
76
|
+
3584528711,
|
|
77
|
+
113926993,
|
|
78
|
+
338241895,
|
|
79
|
+
666307205,
|
|
80
|
+
773529912,
|
|
81
|
+
1294757372,
|
|
82
|
+
1396182291,
|
|
83
|
+
1695183700,
|
|
84
|
+
1986661051,
|
|
85
|
+
2177026350,
|
|
86
|
+
2456956037,
|
|
87
|
+
2730485921,
|
|
88
|
+
2820302411,
|
|
89
|
+
3259730800,
|
|
90
|
+
3345764771,
|
|
91
|
+
3516065817,
|
|
92
|
+
3600352804,
|
|
93
|
+
4094571909,
|
|
94
|
+
275423344,
|
|
95
|
+
430227734,
|
|
96
|
+
506948616,
|
|
97
|
+
659060556,
|
|
98
|
+
883997877,
|
|
99
|
+
958139571,
|
|
100
|
+
1322822218,
|
|
101
|
+
1537002063,
|
|
102
|
+
1747873779,
|
|
103
|
+
1955562222,
|
|
104
|
+
2024104815,
|
|
105
|
+
2227730452,
|
|
106
|
+
2361852424,
|
|
107
|
+
2428436474,
|
|
108
|
+
2756734187,
|
|
109
|
+
3204031479,
|
|
110
|
+
3329325298
|
|
111
|
+
]), y = (e, t) => e >>> t | e << 32 - t;
|
|
112
|
+
function E(e, t, n) {
|
|
113
|
+
const r = new DataView(e.buffer, e.byteOffset + t, 64);
|
|
114
|
+
for (let s = 0; s < 16; s++) n[s] = r.getUint32(s * 4);
|
|
115
|
+
for (let s = 16; s < 64; s++) {
|
|
116
|
+
const a = n[s - 15], c = n[s - 2], d = y(a, 7) ^ y(a, 18) ^ a >>> 3, g = y(c, 17) ^ y(c, 19) ^ c >>> 10;
|
|
117
|
+
n[s] = n[s - 16] + d + n[s - 7] + g;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function O(e, t) {
|
|
121
|
+
let n = e[0], r = e[1], s = e[2], a = e[3], c = e[4], d = e[5], g = e[6], o = e[7];
|
|
122
|
+
for (let u = 0; u < 64; u++) {
|
|
123
|
+
const i = y(c, 6) ^ y(c, 11) ^ y(c, 25), w = c & d ^ ~c & g, f = o + i + w + B[u] + t[u] >>> 0, b = y(n, 2) ^ y(n, 13) ^ y(n, 22), h = n & r ^ n & s ^ r & s, A = b + h >>> 0;
|
|
124
|
+
o = g, g = d, d = c, c = a + f >>> 0, a = s, s = r, r = n, n = f + A >>> 0;
|
|
125
|
+
}
|
|
126
|
+
e[0] = e[0] + n, e[1] = e[1] + r, e[2] = e[2] + s, e[3] = e[3] + a, e[4] = e[4] + c, e[5] = e[5] + d, e[6] = e[6] + g, e[7] = e[7] + o;
|
|
127
|
+
}
|
|
128
|
+
function j(e) {
|
|
129
|
+
const t = new Uint8Array(Math.ceil((e.byteLength + 9) / 64) * 64);
|
|
130
|
+
t.set(e), t[e.byteLength] = 128;
|
|
131
|
+
const n = new DataView(t.buffer);
|
|
132
|
+
return n.setUint32(t.length - 8, Math.floor(e.byteLength / 536870912)), n.setUint32(t.length - 4, e.byteLength * 8 >>> 0), t;
|
|
133
|
+
}
|
|
134
|
+
const J = () => new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), $ = (e) => Array.from(e, (t) => t.toString(16).padStart(8, "0")).join("");
|
|
135
|
+
async function I(e) {
|
|
136
|
+
const t = j(e), n = J(), r = new Uint32Array(64);
|
|
137
|
+
for (let s = 0; s < t.length; s += 64)
|
|
138
|
+
s > 0 && s % 262144 === 0 && await new Promise((a) => setTimeout(a, 0)), E(t, s, r), O(n, r);
|
|
139
|
+
return $(n);
|
|
140
|
+
}
|
|
141
|
+
function q(e = {}) {
|
|
142
|
+
const t = {
|
|
143
|
+
maxRecords: e.maxRecords ?? 1e4,
|
|
144
|
+
maxBytes: e.maxBytes ?? 67108864,
|
|
145
|
+
maxResultBytes: e.maxResultBytes ?? 262144,
|
|
146
|
+
controlReserveBytes: e.controlReserveBytes ?? 4096,
|
|
147
|
+
maxTombstones: e.maxTombstones ?? 1e4,
|
|
148
|
+
maxTombstoneBytes: e.maxTombstoneBytes ?? 16777216
|
|
149
|
+
};
|
|
150
|
+
if (!Object.values(t).every((n) => Number.isSafeInteger(n) && n > 0) || t.controlReserveBytes < 4096) throw new l("input", "任务容量应为正整数,控制状态预留至少4096字节");
|
|
151
|
+
return t;
|
|
152
|
+
}
|
|
153
|
+
function v(e) {
|
|
154
|
+
return new TextEncoder().encode(p(e)).byteLength;
|
|
155
|
+
}
|
|
156
|
+
function N(e, t) {
|
|
157
|
+
const n = { scope: e.scope, id: e.id, revision: 1, request: e.request, status: "queued", createdAt: e.createdAt, updatedAt: e.createdAt, attempt: 0 }, r = { ...e };
|
|
158
|
+
delete r.result;
|
|
159
|
+
const s = e.result === void 0 ? 0 : v(e.result);
|
|
160
|
+
if (s > t.maxResultBytes) throw new l("capacity", "任务结果超过独立预算,请保存文件引用");
|
|
161
|
+
return Math.max(v(n) + t.controlReserveBytes, v(r)) + s;
|
|
162
|
+
}
|
|
163
|
+
function R(e) {
|
|
164
|
+
return e.status !== "queued" && e.status !== "running";
|
|
165
|
+
}
|
|
166
|
+
function T(e) {
|
|
167
|
+
const t = { ...e, tombstoneRetentionMs: e.tombstoneRetentionMs ?? 6048e5, limit: e.limit ?? 100 };
|
|
168
|
+
if (![t.now, t.terminalBefore].every((n) => Number.isSafeInteger(n) && n >= 0) || t.terminalBefore > t.now) throw new l("input", "终态清理时间应为不超过当前时间的非负整数");
|
|
169
|
+
if (![t.tombstoneRetentionMs, t.limit].every((n) => Number.isSafeInteger(n) && n > 0) || !Number.isSafeInteger(t.now + t.tombstoneRetentionMs)) throw new l("input", "幂等保留期与清理批量应为正整数");
|
|
170
|
+
return t;
|
|
171
|
+
}
|
|
172
|
+
async function D(e) {
|
|
173
|
+
const t = new TextEncoder().encode(p(e)), n = globalThis.crypto?.subtle;
|
|
174
|
+
if (!n) return I(t);
|
|
175
|
+
const r = await n.digest("SHA-256", t);
|
|
176
|
+
return Array.from(new Uint8Array(r), (s) => s.toString(16).padStart(2, "0")).join("");
|
|
177
|
+
}
|
|
178
|
+
async function L(e, t) {
|
|
179
|
+
if (!R(e)) throw new l("input", "只能归档终态任务");
|
|
180
|
+
return { scope: e.scope, id: e.id, revision: e.revision, status: e.status, createdAt: e.createdAt, updatedAt: e.updatedAt, attempt: e.attempt, requestHash: await D(e.request), expiresAt: t };
|
|
181
|
+
}
|
|
182
|
+
class l extends Error {
|
|
183
|
+
constructor(t, n) {
|
|
184
|
+
super(n), this.code = t, this.name = "ReportJobError";
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function P(e, t) {
|
|
188
|
+
if (typeof e != "string" || !e.trim() || e.length > 256 || typeof t != "string" || t !== t.trim() || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(t)) throw new l("input", "任务范围应非空,ID应为1–128位安全标识");
|
|
189
|
+
}
|
|
190
|
+
function M(e) {
|
|
191
|
+
const t = Array.isArray(e), n = Object.getPrototypeOf(e), r = Object.keys(e);
|
|
192
|
+
if (n !== (t ? Array.prototype : Object.prototype) && !(n === null && !t)) throw new l("input", "任务对象应为普通 JSON 对象");
|
|
193
|
+
if (Object.getOwnPropertySymbols(e).length) throw new l("input", "任务不能包含Symbol");
|
|
194
|
+
if (Object.getOwnPropertyNames(e).filter((a) => !(t && a === "length")).length !== r.length) throw new l("input", "任务不能包含不可枚举属性");
|
|
195
|
+
if (t && (r.length !== e.length || r.some((a) => a !== String(Number(a)) || !Number.isSafeInteger(Number(a)) || Number(a) < 0 || Number(a) >= e.length))) throw new l("input", "任务数组不能稀疏或包含额外属性");
|
|
196
|
+
return r.sort();
|
|
197
|
+
}
|
|
198
|
+
function C(e, t) {
|
|
199
|
+
const n = Object.getOwnPropertyDescriptor(e, t);
|
|
200
|
+
if (["__proto__", "prototype", "constructor"].includes(t) || n.get || n.set) throw new l("input", "任务不能包含危险键或访问器");
|
|
201
|
+
return n.value;
|
|
202
|
+
}
|
|
203
|
+
function p(e, t = {}) {
|
|
204
|
+
const n = t.maxNodes ?? 2e4, r = t.maxCharacters ?? 1e6;
|
|
205
|
+
if (!Number.isSafeInteger(n) || n < 1 || n > 2e4 || !Number.isSafeInteger(r) || r < 1 || r > 1e6) throw new l("input", "任务JSON预算无效");
|
|
206
|
+
let s = 0, a = 0;
|
|
207
|
+
const c = /* @__PURE__ */ new Set();
|
|
208
|
+
function d(o, u) {
|
|
209
|
+
if (++s > n || u > 32) throw new l("input", "任务数据超过节点或深度预算");
|
|
210
|
+
if (typeof o == "string") {
|
|
211
|
+
if (a += o.length, a > r) throw new l("input", "任务文本超过预算");
|
|
212
|
+
return o;
|
|
213
|
+
}
|
|
214
|
+
if (o === null || typeof o == "boolean" || typeof o == "number" && Number.isFinite(o)) return o;
|
|
215
|
+
if (!o || typeof o != "object" || c.has(o)) throw new l("input", "任务只允许无循环的有限 JSON 值");
|
|
216
|
+
const i = Array.isArray(o), w = M(o);
|
|
217
|
+
c.add(o);
|
|
218
|
+
const f = /* @__PURE__ */ Object.create(null);
|
|
219
|
+
for (const b of w) {
|
|
220
|
+
if (a += b.length, a > r) throw new l("input", "任务文本超过预算");
|
|
221
|
+
f[b] = d(C(o, b), u + 1);
|
|
222
|
+
}
|
|
223
|
+
return c.delete(o), i ? Array.from({ length: o.length }, (b, h) => f[String(h)]) : f;
|
|
224
|
+
}
|
|
225
|
+
const g = JSON.stringify(d(e, 0));
|
|
226
|
+
if (g.length > r) throw new l("input", "任务序列化数据超过字符预算");
|
|
227
|
+
return g;
|
|
228
|
+
}
|
|
229
|
+
function x(e) {
|
|
230
|
+
return JSON.parse(JSON.stringify(e));
|
|
231
|
+
}
|
|
232
|
+
function U(e, t, n, r) {
|
|
233
|
+
if (P(t, n), e.scope !== t || e.id !== n || e.revision !== (r ?? 0) + 1 || !Number.isSafeInteger(e.revision)) throw new l("input", "任务身份或修订不匹配");
|
|
234
|
+
if (![e.createdAt, e.updatedAt, e.attempt].every((s) => Number.isSafeInteger(s) && s >= 0) || !["queued", "running", "completed", "failed", "cancelled"].includes(e.status)) throw new l("input", "任务状态无效");
|
|
235
|
+
if (e.lease && (!e.lease.owner || !Number.isSafeInteger(e.lease.expiresAt))) throw new l("input", "任务租约无效");
|
|
236
|
+
if (!e.request || typeof e.request.kind != "string" || !e.request.kind.trim() || e.request.kind.length > 128) throw new l("input", "任务类型无效");
|
|
237
|
+
p(e.request.payload, { maxNodes: 19e3, maxCharacters: 75e4 }), p(e);
|
|
238
|
+
}
|
|
239
|
+
function z(e, t) {
|
|
240
|
+
if (e && (e.createdAt !== t.createdAt || p(e.request) !== p(t.request))) throw new l("input", "任务创建时间与请求不可变更,请使用新任务ID");
|
|
241
|
+
}
|
|
242
|
+
function _(e, t) {
|
|
243
|
+
return e.status === "queued" || e.status === "running" && (e.lease?.expiresAt ?? 0) <= t;
|
|
244
|
+
}
|
|
245
|
+
function K(e = {}) {
|
|
246
|
+
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = q(e);
|
|
247
|
+
let s = 0, a = 0, c = Promise.resolve();
|
|
248
|
+
const d = (o, u) => JSON.stringify([o, u]), g = (o) => {
|
|
249
|
+
const u = c.then(o);
|
|
250
|
+
return c = u.then(() => {
|
|
251
|
+
}, () => {
|
|
252
|
+
}), u;
|
|
253
|
+
};
|
|
254
|
+
return {
|
|
255
|
+
read: async (o, u) => {
|
|
256
|
+
await c;
|
|
257
|
+
const i = t.get(d(o, u));
|
|
258
|
+
return i ? x(i) : void 0;
|
|
259
|
+
},
|
|
260
|
+
readTombstone: async (o, u) => {
|
|
261
|
+
await c;
|
|
262
|
+
const i = n.get(d(o, u));
|
|
263
|
+
return i ? x(i) : void 0;
|
|
264
|
+
},
|
|
265
|
+
candidates: async (o, u) => (await c, Array.from(t.values()).filter((i) => _(i, o)).sort((i, w) => i.createdAt - w.createdAt).slice(0, u).map(x)),
|
|
266
|
+
compareAndSwap: async (o, u, i, w) => {
|
|
267
|
+
U(w, o, u, i);
|
|
268
|
+
const f = x(w);
|
|
269
|
+
return g(async () => {
|
|
270
|
+
const b = d(o, u), h = t.get(b);
|
|
271
|
+
if ((h?.revision ?? null) !== i || n.has(b)) return !1;
|
|
272
|
+
z(h, f);
|
|
273
|
+
const A = s - (h ? N(h, r) : 0) + N(f, r);
|
|
274
|
+
if (A > r.maxBytes || !h && t.size >= r.maxRecords) throw new l("capacity", "任务容量已满,请清理终态任务或扩大显式预算");
|
|
275
|
+
return t.set(b, f), s = A, !0;
|
|
276
|
+
});
|
|
277
|
+
},
|
|
278
|
+
prune: async (o) => {
|
|
279
|
+
const u = T(o);
|
|
280
|
+
return g(async () => {
|
|
281
|
+
const i = { archived: 0, expired: 0 };
|
|
282
|
+
for (const [w, f] of n)
|
|
283
|
+
f.expiresAt > u.now || i.expired >= u.limit || (n.delete(w), a -= v(f), i.expired++);
|
|
284
|
+
for (const [w, f] of t) {
|
|
285
|
+
if (!R(f) || f.updatedAt > u.terminalBefore || i.archived + i.expired >= u.limit) continue;
|
|
286
|
+
const b = await L(f, u.now + u.tombstoneRetentionMs), h = v(b);
|
|
287
|
+
if (n.size >= r.maxTombstones || a + h > r.maxTombstoneBytes) break;
|
|
288
|
+
n.set(w, b), a += h, t.delete(w), s -= N(f, r), i.archived++;
|
|
289
|
+
}
|
|
290
|
+
return i;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function k(e, t = 100) {
|
|
296
|
+
if (!Number.isSafeInteger(t) || t < 1 || t > 1e3 || !Array.isArray(e) || e.length > t) throw new RangeError("批量参数应包含 1–maxCases 条,maxCases 最大为 1000");
|
|
297
|
+
const n = JSON.parse(p(e)), r = /* @__PURE__ */ new Set();
|
|
298
|
+
for (const s of n) {
|
|
299
|
+
if (!s || typeof s.id != "string" || s.id !== s.id.trim() || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(s.id) || r.has(s.id)) throw new TypeError("批量行 ID 应唯一且为安全标识");
|
|
300
|
+
if (!s.params || Array.isArray(s.params) || typeof s.params != "object" || Object.values(s.params).some((a) => typeof a != "string")) throw new TypeError("批量参数应为字符串字典");
|
|
301
|
+
r.add(s.id);
|
|
302
|
+
}
|
|
303
|
+
return n;
|
|
304
|
+
}
|
|
305
|
+
function H(e, t) {
|
|
306
|
+
if (!t) return;
|
|
307
|
+
const n = { completed: 0, total: e.length, failed: 0, cancelled: 0 };
|
|
308
|
+
for (const r of e)
|
|
309
|
+
r && (n.completed++, r.status === "failed" && n.failed++, r.status === "cancelled" && n.cancelled++);
|
|
310
|
+
try {
|
|
311
|
+
t(n);
|
|
312
|
+
} catch {
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
async function W(e, t, n = {}) {
|
|
316
|
+
const r = n.concurrency ?? 2;
|
|
317
|
+
if (!Number.isSafeInteger(r) || r < 1 || r > 16) throw new RangeError("批量并发应为 1–16");
|
|
318
|
+
if (n.failure !== void 0 && n.failure !== "continue" && n.failure !== "stop") throw new TypeError("批量失败策略无效");
|
|
319
|
+
const s = k(e, n.maxCases ?? 100);
|
|
320
|
+
if (!s.length) throw new RangeError("批量生成至少需要一组参数");
|
|
321
|
+
const a = Array.from({ length: s.length }), c = new AbortController(), d = () => c.abort(n.signal?.reason);
|
|
322
|
+
n.signal?.addEventListener("abort", d, { once: !0 }), n.signal?.aborted && d();
|
|
323
|
+
let g = 0, o = !1;
|
|
324
|
+
async function u() {
|
|
325
|
+
for (; g < s.length; ) {
|
|
326
|
+
const i = g++, w = s[i], f = { id: w.id, index: i };
|
|
327
|
+
if (o || c.signal.aborted) a[i] = { ...f, status: "cancelled" };
|
|
328
|
+
else
|
|
329
|
+
try {
|
|
330
|
+
S(c.signal);
|
|
331
|
+
const b = await t(w, { index: i, signal: c.signal });
|
|
332
|
+
a[i] = { ...f, status: "completed", value: b };
|
|
333
|
+
} catch (b) {
|
|
334
|
+
c.signal.aborted ? a[i] = { ...f, status: "cancelled" } : (a[i] = { ...f, status: "failed", error: { name: b instanceof Error ? b.name : "Error", message: b instanceof Error ? b.message : String(b) } }, n.failure === "stop" && (o = !0));
|
|
335
|
+
}
|
|
336
|
+
H(a, n.onProgress);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
try {
|
|
340
|
+
await Promise.all(Array.from({ length: Math.min(r, s.length) }, u));
|
|
341
|
+
} finally {
|
|
342
|
+
n.signal?.removeEventListener("abort", d);
|
|
343
|
+
}
|
|
344
|
+
return a;
|
|
345
|
+
}
|
|
346
|
+
export {
|
|
347
|
+
m as R,
|
|
348
|
+
Z as a,
|
|
349
|
+
l as b,
|
|
350
|
+
V as c,
|
|
351
|
+
P as d,
|
|
352
|
+
x as e,
|
|
353
|
+
D as f,
|
|
354
|
+
K as g,
|
|
355
|
+
_ as h,
|
|
356
|
+
k as i,
|
|
357
|
+
v as j,
|
|
358
|
+
U as k,
|
|
359
|
+
z as l,
|
|
360
|
+
W as r,
|
|
361
|
+
p as s,
|
|
362
|
+
S as t,
|
|
363
|
+
F as v
|
|
364
|
+
};
|