@agile-team/mach-report 2.12.0 → 2.14.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 +27 -3
- package/dist/ExcelBindingWizard-CLT2p7P3.cjs +1 -0
- package/dist/ExcelBindingWizard-CvsWR8Ga.js +1485 -0
- package/dist/{ParamEditor-BLaE5q5W.js → ParamEditor-CflQV3eQ.js} +191 -187
- package/dist/ParamEditor-vIDzvpPV.cjs +1 -0
- package/dist/ReportBatchPanel-DkxTzBkD.cjs +1 -0
- package/dist/{ReportBatchPanel-B5ClP9tm.js → ReportBatchPanel-LqVgiqp7.js} +3 -3
- package/dist/ReportPreview-CvbqLUzM.cjs +6 -0
- package/dist/ReportPreview-D_ywJ_-H.js +4533 -0
- package/dist/{ReportTemplateLibrary-BZB-XWjj.js → ReportTemplateLibrary-MjWEtc7X.js} +1 -1
- package/dist/ReportTemplateLibrary-cQ1sqNYo.cjs +1 -0
- package/dist/RuleEditor-BaR6xUiI.cjs +1 -0
- package/dist/RuleEditor-ChuXMlei.js +2037 -0
- package/dist/TemplateOutlinePanel-BHKP89Xz.cjs +1 -0
- package/dist/TemplateOutlinePanel-Dci6aRn1.js +96 -0
- package/dist/TemplateReusePanel-B7Gmyc1z.js +388 -0
- package/dist/TemplateReusePanel-CY5eO2Sh.cjs +1 -0
- package/dist/TemplateReviewPanel-DjlX3xpt.js +592 -0
- package/dist/TemplateReviewPanel-JvZe9_4G.cjs +1 -0
- package/dist/{batch-mRqhhhjt.js → batch-DzaTNLWI.js} +23 -16
- package/dist/batch-xMkqYiTr.cjs +1 -0
- package/dist/config-0UIohTS7.cjs +1 -0
- package/dist/{config-B612mw0x.js → config-Dt9NtCPl.js} +227 -186
- package/dist/data-explanation-BktvER5B.cjs +1 -0
- package/dist/data-explanation-C_J6jYNi.js +16 -0
- package/dist/designer-Ci1LizA9.js +5020 -0
- package/dist/designer-rtmVIIdN.cjs +2 -0
- package/dist/designer.cjs +1 -2
- package/dist/designer.d.cts +306 -3
- package/dist/designer.d.ts +306 -3
- package/dist/designer.js +21 -4266
- package/dist/font-loader-DHto6Lra.js +297 -0
- package/dist/font-loader-vhCT8znW.cjs +1 -0
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +182 -1
- package/dist/index.d.ts +182 -1
- package/dist/index.js +728 -628
- package/dist/{template-review-BzpcI-tR.js → json-snapshot-BeFT3Tso.js} +867 -637
- package/dist/json-snapshot-D1NTP2oI.cjs +2 -0
- package/dist/pdf-8UPQebOE.js +36288 -0
- package/dist/pdf-AyJGb22z.cjs +101 -0
- package/dist/pdf.cjs +1 -101
- package/dist/pdf.js +9 -36579
- package/dist/plugin-BGKf-Tqg.js +22 -0
- package/dist/{plugin-BDTU4D94.cjs → plugin-CktLH_Iy.cjs} +1 -1
- package/dist/{region-binding-workflow-CcUq8W2Q.js → region-binding-workflow-DEJbhpCv.js} +1 -1
- package/dist/server/node.d.cts +46 -11
- package/dist/server/node.d.ts +46 -11
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +294 -280
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +107 -12
- package/dist/server.d.ts +107 -12
- package/dist/server.js +713 -453
- package/dist/style.css +1 -1
- package/dist/template-bindings-BJR4k7qZ.cjs +1 -0
- package/dist/template-bindings-Daui7hLF.js +252 -0
- package/dist/template-fragments-CLkGo6To.js +187 -0
- package/dist/template-fragments-DFUpq5QM.cjs +1 -0
- package/dist/template-outline-B3xVkzSv.cjs +1 -0
- package/dist/template-outline-CFenM1PV.js +88 -0
- package/dist/{template-registry-BjE1VS6g.js → template-registry-COXDEJEM.js} +1 -1
- package/dist/{useLocalDraft-C07SYRnC.js → useLocalDraft-BnhcxXk_.js} +1 -1
- package/dist/{useLocalDraft-Yiw1wFgI.cjs → useLocalDraft-CioIfDb6.cjs} +1 -1
- package/dist/{validate-DbgEM1Hh.js → validate-CkQBWCeg.js} +3 -3
- package/dist/vue/async.d.cts +72 -2
- package/dist/vue/async.d.ts +72 -2
- package/dist/vue/index.d.cts +124 -5
- package/dist/vue/index.d.ts +124 -5
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +5 -5
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +78 -71
- package/dist/{workbook-session-BPb3TMnT.js → workbook-session-BfK1yHOO.js} +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +46 -11
- package/dist/worker.d.ts +46 -11
- package/dist/worker.js +59 -55
- package/dist/xlsx.js +3 -3
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-CeAf4QSE.js +0 -1465
- package/dist/ExcelBindingWizard-y0mT-AHR.cjs +0 -1
- package/dist/ParamEditor-MBBC7lUE.cjs +0 -1
- package/dist/ReportBatchPanel-Dc-SDkYA.cjs +0 -1
- package/dist/ReportPreview-DWXROHBP.cjs +0 -6
- package/dist/ReportPreview-DiNXhQI0.js +0 -4138
- package/dist/ReportTemplateLibrary-5fk5CQBO.cjs +0 -1
- package/dist/RuleEditor-ChRzNQuF.cjs +0 -1
- package/dist/RuleEditor-DzAmW5YH.js +0 -2024
- package/dist/TemplateReviewPanel-BKofGrV9.js +0 -222
- package/dist/TemplateReviewPanel-DwtOcLue.cjs +0 -1
- package/dist/batch-Bt3Fd27Z.cjs +0 -1
- package/dist/config-BRoLo2oj.cjs +0 -1
- package/dist/plugin-Cd5G2QQn.js +0 -22
- package/dist/record-bindings-By_UKZ2g.cjs +0 -1
- package/dist/record-bindings-D-5jQlTj.js +0 -196
- package/dist/template-review-BfCC8Ng9.cjs +0 -2
package/dist/server.js
CHANGED
|
@@ -1,34 +1,110 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { g as
|
|
3
|
-
import { d as
|
|
4
|
-
import { v as
|
|
5
|
-
import { g as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { T as
|
|
9
|
-
import { r as
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { R as P, s as xe, C as Re, l as Se, E as Ie, b as Oe, P as Pe, n as ke, z as Ae } from "./json-snapshot-BeFT3Tso.js";
|
|
2
|
+
import { g as X } from "./report-params-B44imUd4.js";
|
|
3
|
+
import { d as Z, r as Be, R as le } from "./param-validation-BlHHXs6u.js";
|
|
4
|
+
import { t as v, a as O, R as k, p as Y, v as Ee, c as j, b as x, d as Q, s as F, e as U, j as Ne, f as Fe, r as je } from "./batch-DzaTNLWI.js";
|
|
5
|
+
import { g as Ft, h as jt, i as Mt, k as $t, l as Jt } from "./batch-DzaTNLWI.js";
|
|
6
|
+
import { v as fe } from "./validate-CkQBWCeg.js";
|
|
7
|
+
import { c as $, r as V, n as q } from "./task-events-Dpsvf_t2.js";
|
|
8
|
+
import { T as Me } from "./tree-CqcQ99NM.js";
|
|
9
|
+
import { r as ee } from "./assets-Q0wUwNrV.js";
|
|
10
|
+
import { h as $e } from "./data-explanation-C_J6jYNi.js";
|
|
11
|
+
import { p as Je, v as Ce } from "./template-registry-COXDEJEM.js";
|
|
12
|
+
import { h as pe } from "./template-bindings-Daui7hLF.js";
|
|
13
|
+
function z(e = []) {
|
|
14
|
+
return e.map(({ code: t, message: r, severity: a, pageIndex: s, componentIndex: n }) => ({ code: t, message: r, severity: a, path: `$.pages.${s}.components.${n}` }));
|
|
15
|
+
}
|
|
16
|
+
async function te(e, t, r = Date.now()) {
|
|
17
|
+
const a = e.prepared, s = e.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
|
|
18
|
+
v(e.signal);
|
|
19
|
+
const n = e.pdf?.customFontFaces ?? (e.pdf?.customFontBytes ? { regular: e.pdf.customFontBytes } : void 0), o = s && n ? s.createFontBytesMeasurer(n) : void 0, d = $(e), c = await d.run("encode", async () => {
|
|
20
|
+
let u;
|
|
21
|
+
if (e.format === "pdf") {
|
|
22
|
+
v(e.signal);
|
|
23
|
+
const l = await s.renderPlanToPdf(a.plan, { ...e.pdf, ...o ? { measurer: o } : {}, fidelity: e.fidelity, signal: e.signal, onProgress: (w, p) => d.progress("encode", w, p) });
|
|
24
|
+
u = l.bytes, a.diagnostics.push(...z(l.diagnostics)), a.diagnostics.push(...l.fidelityWarnings.map((w) => ({ code: "pdf-fidelity", message: w, severity: "warning" })), ...l.pageErrors.map((w) => ({ code: "pdf-page", message: w, severity: "error" }))), l.unsupportedTextCount && a.diagnostics.push({ code: "pdf-font", message: `${l.unsupportedTextCount} 段文本包含当前字体不支持的字符`, severity: "warning" });
|
|
25
|
+
} else {
|
|
26
|
+
const { renderPlanToXlsx: l } = await import("@agile-team/mach-report/xlsx");
|
|
27
|
+
v(e.signal);
|
|
28
|
+
const w = await l(a.plan, { ...e.xlsx, fidelity: e.fidelity, signal: e.signal, onProgress: (p, g) => d.progress("encode", p, g) });
|
|
29
|
+
u = new Uint8Array(w.buffer), a.diagnostics.push(...z(w.diagnostics)), a.diagnostics.push(...w.warnings.map((p) => ({ code: "xlsx-fidelity", message: p, severity: "warning" })));
|
|
30
|
+
}
|
|
31
|
+
return v(e.signal), u;
|
|
32
|
+
});
|
|
33
|
+
O(t, "maxOutputBytes", c.byteLength);
|
|
34
|
+
const { plan: i, ...f } = a;
|
|
35
|
+
return { ...f, bytes: c, format: e.format, contentType: e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", stats: { ...f.stats, durationMs: Date.now() - r, outputBytes: c.byteLength } };
|
|
36
|
+
}
|
|
37
|
+
function G(e) {
|
|
38
|
+
return e && { ...e };
|
|
39
|
+
}
|
|
40
|
+
function C(e) {
|
|
41
|
+
if (!e) return;
|
|
42
|
+
const t = (r) => {
|
|
43
|
+
if (!(r instanceof Uint8Array) && !(r instanceof ArrayBuffer)) throw new P("validate", "字体应为 Uint8Array 或 ArrayBuffer");
|
|
44
|
+
if (r.byteLength > 32e6) throw new k("budget", "单份字体超过 32 MB", "$.pdf");
|
|
45
|
+
return new Uint8Array(r instanceof Uint8Array ? r : new Uint8Array(r));
|
|
46
|
+
};
|
|
47
|
+
if (e.customFontFaces) {
|
|
48
|
+
const r = e.customFontFaces;
|
|
49
|
+
return { customFontName: e.customFontName, customFontFaces: { regular: t(r.regular), ...r.bold ? { bold: t(r.bold) } : {}, ...r.italic ? { italic: t(r.italic) } : {}, ...r.boldItalic ? { boldItalic: t(r.boldItalic) } : {} } };
|
|
50
|
+
}
|
|
51
|
+
return { customFontName: e.customFontName, ...e.customFontBytes ? { customFontBytes: t(e.customFontBytes) } : {} };
|
|
52
|
+
}
|
|
53
|
+
function we(e) {
|
|
54
|
+
const t = e?.customFontFaces ?? (e?.customFontBytes ? { regular: e.customFontBytes } : void 0);
|
|
55
|
+
if (!t) return;
|
|
56
|
+
const r = ["regular", "bold", "italic", "boldItalic"].map((a) => {
|
|
57
|
+
const s = t[a];
|
|
58
|
+
if (!s) return [a, null];
|
|
59
|
+
const n = s instanceof Uint8Array ? s : new Uint8Array(s);
|
|
60
|
+
if (n.byteLength > 32e6) throw new k("budget", "单份字体超过 32 MB", "$.pdf");
|
|
61
|
+
return [a, Y(n)];
|
|
62
|
+
});
|
|
63
|
+
return Y(new TextEncoder().encode(JSON.stringify(r)));
|
|
64
|
+
}
|
|
65
|
+
function De(e, t, r) {
|
|
66
|
+
const a = xe(e, {
|
|
67
|
+
maxBytes: t,
|
|
68
|
+
check: () => v(r),
|
|
69
|
+
error: (s, n) => s === "budget" ? new k("budget", n, "$.budget.maxPreparedBytes") : new P("validate", n)
|
|
70
|
+
});
|
|
71
|
+
return ge(a), a;
|
|
72
|
+
}
|
|
73
|
+
function ge(e) {
|
|
74
|
+
if (!e?.stats || ["rows", "pages", "cells"].some((t) => !Number.isSafeInteger(e.stats[t]) || e.stats[t] < 0) || !Number.isFinite(e.stats.durationMs) || e.stats.durationMs < 0) throw new P("validate", "准备结果统计无效");
|
|
75
|
+
if (!Array.isArray(e.diagnostics) || e.diagnostics.some((t) => !t || typeof t.code != "string" || typeof t.message != "string" || !["info", "warning", "error"].includes(t.severity) || !$e(t))) throw new P("validate", "准备结果诊断无效");
|
|
76
|
+
if (!e.revisions || typeof e.revisions != "object" || Array.isArray(e.revisions) || Object.values(e.revisions).some((t) => !t || typeof t != "object" || t.revision !== void 0 && typeof t.revision != "string" || t.sourceToken !== void 0 && typeof t.sourceToken != "string")) throw new P("validate", "准备结果修订无效");
|
|
77
|
+
if (e.layout && (!["heuristic", "provided", "font-bytes"].includes(e.layout.textMetrics) || e.layout.fontFingerprint !== void 0 && !/^[a-f0-9]{64}$/.test(e.layout.fontFingerprint))) throw new P("validate", "准备结果字体度量标识无效");
|
|
78
|
+
}
|
|
79
|
+
function Te(e) {
|
|
80
|
+
if (e.format !== "pdf") return;
|
|
81
|
+
const t = e.prepared.layout?.fontFingerprint, r = we(e.pdf);
|
|
82
|
+
if (t === r && (t !== void 0 || e.prepared.layout?.textMetrics === "heuristic" && !r)) return;
|
|
83
|
+
const a = "已准备计划的字体度量无法与本次 PDF 字体确认一致;保持现有分页,未重新查询或排版。请在 prepare 和 exportPrepared 提供相同字体字节。";
|
|
84
|
+
if (e.fidelity === "strict") throw new P("validate", a);
|
|
85
|
+
e.prepared.diagnostics.push({ code: "prepared-font-metrics", severity: "warning", message: a });
|
|
86
|
+
}
|
|
87
|
+
function me(e, t) {
|
|
88
|
+
if (t.length === 0) throw new P("config", "缺少报表 ID");
|
|
13
89
|
return t.map((r) => {
|
|
14
|
-
if (!Object.prototype.hasOwnProperty.call(e, r)) throw new
|
|
90
|
+
if (!Object.prototype.hasOwnProperty.call(e, r)) throw new P("config", `未注册报表 ${r}`);
|
|
15
91
|
return e[r];
|
|
16
92
|
});
|
|
17
93
|
}
|
|
18
|
-
function
|
|
19
|
-
return e.grid?.cells.reduce((t, r) => t + r.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((n,
|
|
94
|
+
function H(e) {
|
|
95
|
+
return e.grid?.cells.reduce((t, r) => t + r.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((n, o) => n + H(o), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
20
96
|
}
|
|
21
|
-
function
|
|
22
|
-
return e.pages.reduce((a, s) => a + s.components.reduce((n,
|
|
97
|
+
function Le(e, t, r) {
|
|
98
|
+
return e.pages.reduce((a, s) => a + s.components.reduce((n, o) => o.kind !== "list" ? n + H(o) : n + ke(o, t, r), 0), 0);
|
|
23
99
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
26
|
-
const s = t[a], n =
|
|
100
|
+
function qe(e, t = Object.keys(e)) {
|
|
101
|
+
return me(e, t).map((r, a) => {
|
|
102
|
+
const s = t[a], n = X(e, [s]);
|
|
27
103
|
return {
|
|
28
104
|
id: s,
|
|
29
105
|
params: JSON.parse(JSON.stringify(n)),
|
|
30
|
-
paramsSchema:
|
|
31
|
-
datasetsSchema: Object.fromEntries(Object.entries(r.dataSchema ?? {}).map(([
|
|
106
|
+
paramsSchema: Be(n),
|
|
107
|
+
datasetsSchema: Object.fromEntries(Object.entries(r.dataSchema ?? {}).map(([o, d]) => [o, Re(typeof r.template == "function" ? void 0 : r.template, o, d)])),
|
|
32
108
|
capabilities: {
|
|
33
109
|
save: !!r.provider?.save,
|
|
34
110
|
export: !!r.provider?.export,
|
|
@@ -37,104 +113,108 @@ function Re(e, t = Object.keys(e)) {
|
|
|
37
113
|
};
|
|
38
114
|
});
|
|
39
115
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
const r = X(
|
|
116
|
+
function ye(e, t) {
|
|
117
|
+
me(e, t.reportIds);
|
|
118
|
+
const r = Z(X(e, t.reportIds), t.params), a = t.reportIds.flatMap((n) => Z(X(e, [n]), t.params).issues), s = new Map(a.map((n) => [JSON.stringify(n), n]));
|
|
43
119
|
return { ...r, ok: s.size === 0, issues: [...s.values()] };
|
|
44
120
|
}
|
|
45
|
-
function
|
|
46
|
-
const r =
|
|
47
|
-
if (!r.ok) throw new
|
|
48
|
-
const a = e.plan.pages.length, s = e.plan.pages.reduce((n,
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
function U(e, t) {
|
|
52
|
-
const r = ne(e.reports, t);
|
|
53
|
-
if (!r.ok) throw new te(r.issues);
|
|
121
|
+
function re(e, t) {
|
|
122
|
+
const r = fe(e.plan);
|
|
123
|
+
if (!r.ok) throw new P("validate", `执行器返回无效计划:${r.errors[0]?.path}`);
|
|
124
|
+
const a = e.plan.pages.length, s = e.plan.pages.reduce((n, o) => n + o.components.reduce((d, c) => d + H(c), 0), 0);
|
|
125
|
+
return O(t, "maxRows", e.stats.rows), O(t, "maxPages", a), O(t, "maxCells", s), { ...e, stats: { ...e.stats, pages: a, cells: s } };
|
|
54
126
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
127
|
+
function se(e, t) {
|
|
128
|
+
const r = ye(e.reports, t);
|
|
129
|
+
if (!r.ok) throw new le(r.issues);
|
|
57
130
|
}
|
|
58
|
-
function
|
|
59
|
-
const t = { maxRows: 1e5, maxPages: 1e4, maxCells: 2e6, maxOutputBytes: 1e8, maxDurationMs: 12e4, ...e.budget };
|
|
60
|
-
|
|
131
|
+
function he(e) {
|
|
132
|
+
const t = { maxRows: 1e5, maxPages: 1e4, maxCells: 2e6, maxOutputBytes: 1e8, maxPreparedBytes: 64e6, maxDurationMs: 12e4, ...e.budget };
|
|
133
|
+
Ee(t);
|
|
61
134
|
const r = async (s, n) => {
|
|
62
|
-
const
|
|
63
|
-
let
|
|
64
|
-
const
|
|
65
|
-
...
|
|
66
|
-
pagination: { ...e.pagination, ...
|
|
135
|
+
const o = Date.now();
|
|
136
|
+
let d = 0, c = 0;
|
|
137
|
+
const i = [], f = {}, u = Object.fromEntries(Object.entries(e.reports).map(([b, S]) => [b, {
|
|
138
|
+
...S,
|
|
139
|
+
pagination: { ...e.pagination, ...S.pagination, ...n ? { measurer: n } : {} },
|
|
67
140
|
dataValidation: {
|
|
68
|
-
...
|
|
69
|
-
maxRows: Math.min(t.maxRows ?? 1e5,
|
|
70
|
-
maxCells: Math.min(t.maxCells ?? 2e6,
|
|
141
|
+
...S.dataValidation,
|
|
142
|
+
maxRows: Math.min(t.maxRows ?? 1e5, S.dataValidation?.maxRows ?? 1 / 0),
|
|
143
|
+
maxCells: Math.min(t.maxCells ?? 2e6, S.dataValidation?.maxCells ?? 1 / 0)
|
|
71
144
|
}
|
|
72
|
-
}])),
|
|
145
|
+
}])), w = await Se(u, { maxPages: t.maxPages, maxCells: t.maxCells, onDatasets: (b, S, I) => {
|
|
73
146
|
try {
|
|
74
|
-
|
|
75
|
-
} catch (
|
|
76
|
-
throw
|
|
147
|
+
d += Ie(I, S, { maxRows: t.maxRows, signal: s.signal });
|
|
148
|
+
} catch (E) {
|
|
149
|
+
throw E instanceof Me ? new k("budget", E.message, "$.budget.maxRows") : E;
|
|
77
150
|
}
|
|
78
|
-
|
|
79
|
-
} })({ ...s, params: s.params ?? {}, onWarning: (
|
|
80
|
-
Object.defineProperty(
|
|
81
|
-
} }).catch((
|
|
82
|
-
throw
|
|
151
|
+
O(t, "maxRows", d), c += Le(I, S, u[b]?.pagination), O(t, "maxCells", c);
|
|
152
|
+
} })({ ...s, params: s.params ?? {}, onWarning: (b) => i.push({ code: "layout", message: b, severity: "warning" }), onQueryResult: (b, S) => {
|
|
153
|
+
Object.defineProperty(f, b, { value: { revision: S.revision, sourceToken: S.sourceToken }, enumerable: !0, writable: !0 }), i.push(...S.diagnostics ?? []);
|
|
154
|
+
} }).catch((b) => {
|
|
155
|
+
throw b instanceof P && b.cause instanceof Oe ? new k("budget", b.cause.message, "$.budget.maxPages") : b instanceof P && b.cause instanceof Pe ? new k("budget", b.cause.message, "$.budget.maxCells") : b;
|
|
83
156
|
});
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
157
|
+
v(s.signal);
|
|
158
|
+
const p = e.assets ? await $(s).run("assets", () => ee(w, { ...e.assets, signal: s.signal })) : { plan: w, diagnostics: [] }, g = p.plan;
|
|
159
|
+
i.push(...z(p.diagnostics));
|
|
160
|
+
const m = g.pages.reduce((b, S) => b + S.components.reduce((I, E) => I + H(E), 0), 0);
|
|
161
|
+
O(t, "maxPages", g.pages.length), O(t, "maxCells", m);
|
|
162
|
+
const y = we(s.pdf), A = e.pagination?.measurer || Object.values(e.reports).some((b) => b.pagination?.measurer);
|
|
163
|
+
return { plan: g, diagnostics: i, revisions: f, layout: { textMetrics: y ? "font-bytes" : A ? "provided" : "heuristic", ...y ? { fontFingerprint: y } : {} }, stats: { rows: d, pages: g.pages.length, cells: m, durationMs: Date.now() - o } };
|
|
89
164
|
}, a = async (s) => {
|
|
90
165
|
const n = Date.now();
|
|
91
|
-
if (s.format !== "pdf" && s.format !== "xlsx") throw new
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
const d = C(s), c = await d.run("encode", async () => {
|
|
97
|
-
let h;
|
|
98
|
-
if (s.format === "pdf") {
|
|
99
|
-
x(s.signal);
|
|
100
|
-
const w = await i.renderPlanToPdf(o.plan, { ...s.pdf, ...f ? { measurer: f } : {}, fidelity: s.fidelity, signal: s.signal, onProgress: (g, p) => d.progress("encode", g, p) });
|
|
101
|
-
h = w.bytes, o.diagnostics.push(...q(w.diagnostics)), o.diagnostics.push(...w.fidelityWarnings.map((g) => ({ code: "pdf-fidelity", message: g, severity: "warning" })), ...w.pageErrors.map((g) => ({ code: "pdf-page", message: g, severity: "error" }))), w.unsupportedTextCount && o.diagnostics.push({ code: "pdf-font", message: `${w.unsupportedTextCount} 段文本包含当前字体不支持的字符`, severity: "warning" });
|
|
102
|
-
} else {
|
|
103
|
-
const { renderPlanToXlsx: w } = await import("@agile-team/mach-report/xlsx");
|
|
104
|
-
x(s.signal);
|
|
105
|
-
const g = await w(o.plan, { ...s.xlsx, fidelity: s.fidelity, signal: s.signal, onProgress: (p, v) => d.progress("encode", p, v) });
|
|
106
|
-
h = new Uint8Array(g.buffer), o.diagnostics.push(...q(g.diagnostics)), o.diagnostics.push(...g.warnings.map((p) => ({ code: "xlsx-fidelity", message: p, severity: "warning" })));
|
|
107
|
-
}
|
|
108
|
-
return x(s.signal), h;
|
|
109
|
-
});
|
|
110
|
-
R(t, "maxOutputBytes", c.byteLength);
|
|
111
|
-
const { plan: u, ...y } = o;
|
|
112
|
-
return { ...y, bytes: c, format: s.format, contentType: s.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", stats: { ...y.stats, durationMs: Date.now() - n, outputBytes: c.byteLength } };
|
|
166
|
+
if (s.format !== "pdf" && s.format !== "xlsx") throw new P("config", "不支持的报表导出格式");
|
|
167
|
+
const o = s.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
|
|
168
|
+
v(s.signal);
|
|
169
|
+
const d = s.pdf?.customFontFaces ?? (s.pdf?.customFontBytes ? { regular: s.pdf.customFontBytes } : void 0), c = o && d ? o.createFontBytesMeasurer(d) : void 0, i = await r(s, c);
|
|
170
|
+
return v(s.signal), te({ ...s, prepared: i }, t, n);
|
|
113
171
|
};
|
|
114
172
|
return {
|
|
115
|
-
describe: (s) =>
|
|
116
|
-
validate: (s) =>
|
|
117
|
-
prepare: (s) =>
|
|
118
|
-
const { signal:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
173
|
+
describe: (s) => qe(e.reports, s),
|
|
174
|
+
validate: (s) => ye(e.reports, s),
|
|
175
|
+
prepare: (s) => j(s.signal, t.maxDurationMs, async (n) => {
|
|
176
|
+
const { signal: o, onEvent: d, ...c } = s, i = { ...c, ...c.pdf ? { pdf: C(c.pdf) } : {}, taskId: c.taskId ?? V() }, f = d ? (g) => q(d, g, n) : void 0, u = { ...i, signal: n, onEvent: f };
|
|
177
|
+
$(u).runSync("validate", () => se(e, i));
|
|
178
|
+
let l;
|
|
179
|
+
const w = i.pdf?.customFontFaces ?? (i.pdf?.customFontBytes ? { regular: i.pdf.customFontBytes } : void 0);
|
|
180
|
+
if (!e.executor && w) {
|
|
181
|
+
const g = await import("@agile-team/mach-report/pdf");
|
|
182
|
+
v(n), l = g.createFontBytesMeasurer(w);
|
|
183
|
+
}
|
|
184
|
+
const p = e.executor ? await e.executor.prepare(i, n, f) : await r(u, l);
|
|
185
|
+
return re(p, t);
|
|
122
186
|
}),
|
|
123
|
-
|
|
124
|
-
const { signal:
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
127
|
-
|
|
187
|
+
exportPrepared: (s) => j(s.signal, t.maxDurationMs, async (n) => {
|
|
188
|
+
const o = Date.now(), { signal: d, onEvent: c, ...i } = s, f = re(De(s.prepared, t.maxPreparedBytes ?? 64e6, n), t), u = { ...i, xlsx: G(i.xlsx), prepared: f, ...i.pdf ? { pdf: C(i.pdf) } : {}, taskId: i.taskId ?? V() };
|
|
189
|
+
if (u.format !== "pdf" && u.format !== "xlsx") throw new P("config", "不支持的报表导出格式");
|
|
190
|
+
const l = c ? (p) => q(c, p, n) : void 0;
|
|
191
|
+
if (e.executor) {
|
|
192
|
+
if (!e.executor.exportPrepared) throw new P("config", "执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");
|
|
193
|
+
const p = await e.executor.exportPrepared(u, n, l);
|
|
194
|
+
return O(t, "maxRows", p.stats.rows), O(t, "maxPages", p.stats.pages), O(t, "maxCells", p.stats.cells), O(t, "maxOutputBytes", p.bytes.byteLength), { ...p, stats: { ...p.stats, outputBytes: p.bytes.byteLength } };
|
|
195
|
+
}
|
|
196
|
+
const w = { ...u, signal: n, onEvent: l };
|
|
197
|
+
if ($(w).runSync("validate", () => Te(w)), e.assets) {
|
|
198
|
+
const p = await $(w).run("assets", () => ee(f.plan, { ...e.assets, signal: n }));
|
|
199
|
+
f.plan = p.plan, f.diagnostics.push(...z(p.diagnostics));
|
|
200
|
+
}
|
|
201
|
+
return te(w, t, o);
|
|
202
|
+
}),
|
|
203
|
+
export: (s) => j(s.signal, t.maxDurationMs, async (n) => {
|
|
204
|
+
const { signal: o, onEvent: d, ...c } = s, i = { ...c, xlsx: G(c.xlsx), ...c.pdf ? { pdf: C(c.pdf) } : {}, taskId: c.taskId ?? V() }, f = d ? (w) => q(d, w, n) : void 0, u = { ...i, signal: n, onEvent: f };
|
|
205
|
+
if ($(u).runSync("validate", () => se(e, i)), i.format !== "pdf" && i.format !== "xlsx") throw new P("config", "不支持的报表导出格式");
|
|
206
|
+
const l = e.executor ? await e.executor.export(i, n, f) : await a(u);
|
|
207
|
+
return O(t, "maxRows", l.stats.rows), O(t, "maxPages", l.stats.pages), O(t, "maxCells", l.stats.cells), O(t, "maxOutputBytes", l.bytes.byteLength), { ...l, stats: { ...l.stats, outputBytes: l.bytes.byteLength } };
|
|
128
208
|
})
|
|
129
209
|
};
|
|
130
210
|
}
|
|
131
|
-
function
|
|
211
|
+
function St(e = {}) {
|
|
132
212
|
const t = e.concurrency ?? 1, r = e.maxQueued ?? 20;
|
|
133
|
-
if (!Number.isSafeInteger(t) || t < 1 || !Number.isSafeInteger(r) || r < 0) throw new
|
|
213
|
+
if (!Number.isSafeInteger(t) || t < 1 || !Number.isSafeInteger(r) || r < 0) throw new k("budget", "队列并发应为正整数,排队上限应为非负整数");
|
|
134
214
|
const a = [], s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
135
|
-
let
|
|
136
|
-
const
|
|
137
|
-
for (; !
|
|
215
|
+
let o = !1, d = 0;
|
|
216
|
+
const c = () => {
|
|
217
|
+
for (; !o && s.size < t && a.length; ) a.shift().start();
|
|
138
218
|
};
|
|
139
219
|
return {
|
|
140
220
|
get active() {
|
|
@@ -143,65 +223,65 @@ function Ze(e = {}) {
|
|
|
143
223
|
get pending() {
|
|
144
224
|
return a.length;
|
|
145
225
|
},
|
|
146
|
-
enqueue: (
|
|
147
|
-
if (
|
|
148
|
-
if (
|
|
149
|
-
const
|
|
150
|
-
if (n.has(
|
|
151
|
-
const
|
|
152
|
-
let
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
}),
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
if (
|
|
159
|
-
const
|
|
160
|
-
|
|
226
|
+
enqueue: (f, u = {}) => {
|
|
227
|
+
if (o) throw new k("closed", "任务队列已关闭");
|
|
228
|
+
if (v(u.signal), s.size >= t && a.length >= r) throw new k("queue-full", "报表任务队列已满");
|
|
229
|
+
const l = u.id ?? `report-${++d}`;
|
|
230
|
+
if (n.has(l)) throw new k("queue-full", "任务 ID 正在执行或排队");
|
|
231
|
+
const w = new AbortController();
|
|
232
|
+
let p = "queued", g, m, y, A;
|
|
233
|
+
const b = new Promise((R, N) => {
|
|
234
|
+
y = R, A = N;
|
|
235
|
+
}), S = () => {
|
|
236
|
+
u.signal?.removeEventListener("abort", E), n.delete(l);
|
|
237
|
+
}, I = (R) => {
|
|
238
|
+
if (p !== "queued" && p !== "running") return;
|
|
239
|
+
const N = p === "queued";
|
|
240
|
+
p = "cancelled", w.abort(R);
|
|
161
241
|
try {
|
|
162
|
-
|
|
163
|
-
} catch (
|
|
164
|
-
|
|
242
|
+
v(w.signal);
|
|
243
|
+
} catch (T) {
|
|
244
|
+
A(T);
|
|
165
245
|
}
|
|
166
|
-
if (
|
|
167
|
-
const
|
|
168
|
-
|
|
246
|
+
if (N) {
|
|
247
|
+
const T = a.indexOf(B);
|
|
248
|
+
T >= 0 && a.splice(T, 1), S(), c();
|
|
169
249
|
}
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
},
|
|
175
|
-
cancel:
|
|
250
|
+
}, E = () => I(u.signal?.reason), K = (R, N) => {
|
|
251
|
+
p === "running" && (!Number.isFinite(R) || R < 0 || N !== void 0 && (!Number.isFinite(N) || N < R) || (g = { completed: R, ...N === void 0 ? {} : { total: N } }));
|
|
252
|
+
}, M = (R) => {
|
|
253
|
+
p !== "running" || w.signal.aborted || (m = { ...R, taskId: l }, R.completed !== void 0 && K(R.completed, R.total), q(u.onEvent, m, w.signal));
|
|
254
|
+
}, B = {
|
|
255
|
+
cancel: I,
|
|
176
256
|
start: () => {
|
|
177
|
-
|
|
178
|
-
(
|
|
179
|
-
|
|
257
|
+
p === "queued" && (p = "running", s.add(B), Promise.resolve().then(() => (v(w.signal), f({ taskId: l, signal: w.signal, reportProgress: K, onEvent: M }))).then(
|
|
258
|
+
(R) => {
|
|
259
|
+
p === "running" && (p = "completed", y(R));
|
|
180
260
|
},
|
|
181
|
-
(
|
|
182
|
-
|
|
261
|
+
(R) => {
|
|
262
|
+
p === "running" && (p = "failed", A(R));
|
|
183
263
|
}
|
|
184
264
|
).finally(() => {
|
|
185
|
-
s.delete(
|
|
265
|
+
s.delete(B), S(), c();
|
|
186
266
|
}));
|
|
187
267
|
}
|
|
188
268
|
};
|
|
189
|
-
return n.add(
|
|
190
|
-
return
|
|
269
|
+
return n.add(l), u.signal?.addEventListener("abort", E, { once: !0 }), u.signal?.aborted ? I(u.signal.reason) : s.size < t ? B.start() : a.push(B), { id: l, get status() {
|
|
270
|
+
return p;
|
|
191
271
|
}, get progress() {
|
|
192
|
-
return w;
|
|
193
|
-
}, get event() {
|
|
194
272
|
return g;
|
|
195
|
-
},
|
|
273
|
+
}, get event() {
|
|
274
|
+
return m;
|
|
275
|
+
}, result: b, cancel: I };
|
|
196
276
|
},
|
|
197
|
-
close: (
|
|
198
|
-
|
|
199
|
-
for (const
|
|
200
|
-
if (
|
|
277
|
+
close: (f = {}) => {
|
|
278
|
+
o = !0;
|
|
279
|
+
for (const u of [...a]) u.cancel(new k("closed", "任务队列已关闭"));
|
|
280
|
+
if (f.cancelRunning) for (const u of s) u.cancel(new k("closed", "任务队列已关闭"));
|
|
201
281
|
}
|
|
202
282
|
};
|
|
203
283
|
}
|
|
204
|
-
function
|
|
284
|
+
function ze(e) {
|
|
205
285
|
let t, r;
|
|
206
286
|
const a = new Promise((s, n) => {
|
|
207
287
|
t = s, r = n;
|
|
@@ -209,45 +289,45 @@ function Ae(e) {
|
|
|
209
289
|
return a.catch(() => {
|
|
210
290
|
}), { progress: e, promise: a, resolve: t, reject: r };
|
|
211
291
|
}
|
|
212
|
-
function
|
|
292
|
+
function ne(e) {
|
|
213
293
|
const t = Promise.reject(e);
|
|
214
294
|
return t.catch(() => {
|
|
215
295
|
}), t;
|
|
216
296
|
}
|
|
217
|
-
function
|
|
297
|
+
function _e(e, t) {
|
|
218
298
|
let r, a, s = !0, n;
|
|
219
|
-
function i
|
|
220
|
-
n ??=
|
|
299
|
+
function o(i) {
|
|
300
|
+
n ??= i ?? new Error("任务心跳更新失败"), a?.reject(n), a = void 0, t(n);
|
|
221
301
|
}
|
|
222
|
-
function
|
|
223
|
-
const
|
|
224
|
-
() =>
|
|
225
|
-
(
|
|
226
|
-
|
|
302
|
+
function d(i) {
|
|
303
|
+
const f = Promise.resolve().then(() => e(i?.progress)).then(
|
|
304
|
+
() => i?.resolve(),
|
|
305
|
+
(u) => {
|
|
306
|
+
i?.reject(u), o(u);
|
|
227
307
|
}
|
|
228
308
|
).finally(() => {
|
|
229
309
|
r = void 0;
|
|
230
|
-
const
|
|
231
|
-
a = void 0,
|
|
310
|
+
const u = a;
|
|
311
|
+
a = void 0, u && n === void 0 && d(u);
|
|
232
312
|
});
|
|
233
|
-
r =
|
|
234
|
-
|
|
313
|
+
r = f, f.catch((u) => {
|
|
314
|
+
o(u);
|
|
235
315
|
});
|
|
236
316
|
}
|
|
237
|
-
function
|
|
317
|
+
function c(i) {
|
|
238
318
|
if (!s)
|
|
239
|
-
return
|
|
240
|
-
new
|
|
319
|
+
return ne(
|
|
320
|
+
new x("closed", "任务进度上报已结束")
|
|
241
321
|
);
|
|
242
|
-
if (n !== void 0) return
|
|
243
|
-
a ? a.progress =
|
|
244
|
-
const
|
|
245
|
-
return r || (a = void 0,
|
|
322
|
+
if (n !== void 0) return ne(n);
|
|
323
|
+
a ? a.progress = i : a = ze(i);
|
|
324
|
+
const f = a;
|
|
325
|
+
return r || (a = void 0, d(f)), f.promise;
|
|
246
326
|
}
|
|
247
327
|
return {
|
|
248
|
-
progress:
|
|
328
|
+
progress: c,
|
|
249
329
|
pulse() {
|
|
250
|
-
s && !r && n === void 0 &&
|
|
330
|
+
s && !r && n === void 0 && d();
|
|
251
331
|
},
|
|
252
332
|
async finish() {
|
|
253
333
|
for (s = !1; r; ) await r;
|
|
@@ -255,39 +335,39 @@ function Pe(e, t) {
|
|
|
255
335
|
}
|
|
256
336
|
};
|
|
257
337
|
}
|
|
258
|
-
class
|
|
338
|
+
class ae extends x {
|
|
259
339
|
constructor() {
|
|
260
340
|
super("capacity", "任务结果超过独立预算,请保存文件引用");
|
|
261
341
|
}
|
|
262
342
|
}
|
|
263
|
-
function
|
|
343
|
+
function Ue(e) {
|
|
264
344
|
const t = e.concurrency ?? 1, r = e.leaseMs ?? 3e4, a = e.heartbeatMs ?? 1e4, s = e.maxResultBytes ?? 256 * 1024;
|
|
265
345
|
if (![t, r, a, s].every(
|
|
266
|
-
(
|
|
346
|
+
(o) => Number.isSafeInteger(o) && o > 0
|
|
267
347
|
) || a * 2 > r)
|
|
268
|
-
throw new
|
|
348
|
+
throw new x(
|
|
269
349
|
"input",
|
|
270
350
|
"并发、租约、心跳应为正整数,租约至少为心跳的两倍"
|
|
271
351
|
);
|
|
272
352
|
if (a > 2147483647)
|
|
273
|
-
throw new
|
|
353
|
+
throw new x(
|
|
274
354
|
"input",
|
|
275
355
|
"心跳间隔超过平台定时器上限(2147483647毫秒)"
|
|
276
356
|
);
|
|
277
357
|
return { concurrency: t, leaseMs: r, heartbeatMs: a, maxResultBytes: s, now: () => {
|
|
278
|
-
const
|
|
279
|
-
if (!Number.isSafeInteger(
|
|
280
|
-
throw new
|
|
281
|
-
return
|
|
358
|
+
const o = (e.now ?? Date.now)();
|
|
359
|
+
if (!Number.isSafeInteger(o) || o < 0)
|
|
360
|
+
throw new x("input", "任务时钟应返回非负整数毫秒");
|
|
361
|
+
return o;
|
|
282
362
|
} };
|
|
283
363
|
}
|
|
284
|
-
async function
|
|
285
|
-
|
|
364
|
+
async function _(e, t, r) {
|
|
365
|
+
Q(t, r);
|
|
286
366
|
const a = await e.read(t, r);
|
|
287
|
-
if (!a) throw new
|
|
367
|
+
if (!a) throw new x("missing", "报表任务不存在");
|
|
288
368
|
return a;
|
|
289
369
|
}
|
|
290
|
-
async function
|
|
370
|
+
async function D(e, t, r, a = []) {
|
|
291
371
|
const s = { ...t, ...r, revision: t.revision + 1 };
|
|
292
372
|
for (const n of a) delete s[n];
|
|
293
373
|
if (!await e.compareAndSwap(
|
|
@@ -296,12 +376,12 @@ async function B(e, t, r, a = []) {
|
|
|
296
376
|
t.revision,
|
|
297
377
|
s
|
|
298
378
|
))
|
|
299
|
-
throw new
|
|
300
|
-
return
|
|
379
|
+
throw new x("conflict", "报表任务已被其他请求更新");
|
|
380
|
+
return U(s);
|
|
301
381
|
}
|
|
302
|
-
async function
|
|
382
|
+
async function He(e, t, r, a) {
|
|
303
383
|
if (!t.trim() || t.length > 128)
|
|
304
|
-
throw new
|
|
384
|
+
throw new x("input", "workerId应为1–128位标识");
|
|
305
385
|
for (const s of await e.store.candidates(a, 100)) {
|
|
306
386
|
const n = s.cancelRequested ? {
|
|
307
387
|
...s,
|
|
@@ -325,199 +405,199 @@ async function je(e, t, r, a) {
|
|
|
325
405
|
return n;
|
|
326
406
|
}
|
|
327
407
|
}
|
|
328
|
-
function
|
|
408
|
+
function oe(e, t, r, a) {
|
|
329
409
|
return e.status === "running" && e.attempt === a && e.lease?.owner === t && e.lease.expiresAt > r;
|
|
330
410
|
}
|
|
331
|
-
async function
|
|
332
|
-
const { scope: s, id: n } = r,
|
|
333
|
-
let
|
|
334
|
-
const
|
|
335
|
-
async (
|
|
336
|
-
const
|
|
337
|
-
if (!
|
|
338
|
-
throw new
|
|
339
|
-
if (
|
|
340
|
-
a.abort(new
|
|
411
|
+
async function Ke(e, t, r, a) {
|
|
412
|
+
const { scope: s, id: n } = r, o = r.lease.owner;
|
|
413
|
+
let d;
|
|
414
|
+
const c = _e(
|
|
415
|
+
async (m) => {
|
|
416
|
+
const y = await _(e.store, s, n), A = t.now();
|
|
417
|
+
if (!oe(y, o, A, r.attempt))
|
|
418
|
+
throw new x("lease", "报表任务租约已失效");
|
|
419
|
+
if (y.cancelRequested) {
|
|
420
|
+
a.abort(new x("closed", "任务已请求取消"));
|
|
341
421
|
return;
|
|
342
422
|
}
|
|
343
|
-
await
|
|
344
|
-
updatedAt:
|
|
345
|
-
lease: { owner:
|
|
346
|
-
...
|
|
423
|
+
await D(e.store, y, {
|
|
424
|
+
updatedAt: A,
|
|
425
|
+
lease: { owner: o, expiresAt: A + t.leaseMs },
|
|
426
|
+
...m ? { progress: m } : {}
|
|
347
427
|
});
|
|
348
428
|
},
|
|
349
|
-
(
|
|
350
|
-
|
|
429
|
+
(m) => {
|
|
430
|
+
d = m, a.abort(m);
|
|
351
431
|
}
|
|
352
|
-
),
|
|
353
|
-
completed:
|
|
354
|
-
...
|
|
355
|
-
}),
|
|
356
|
-
|
|
432
|
+
), i = (m, y) => !Number.isFinite(m) || m < 0 || y !== void 0 && (!Number.isFinite(y) || y < m) ? Promise.reject(new x("input", "任务进度无效")) : c.progress({
|
|
433
|
+
completed: m,
|
|
434
|
+
...y === void 0 ? {} : { total: y }
|
|
435
|
+
}), f = setInterval(() => {
|
|
436
|
+
c.pulse();
|
|
357
437
|
}, t.heartbeatMs);
|
|
358
|
-
let
|
|
438
|
+
let u, l;
|
|
359
439
|
try {
|
|
360
|
-
const
|
|
440
|
+
const m = Object.prototype.hasOwnProperty.call(
|
|
361
441
|
e.handlers,
|
|
362
442
|
r.request.kind
|
|
363
443
|
) ? e.handlers[r.request.kind] : void 0;
|
|
364
|
-
if (!
|
|
444
|
+
if (!m) throw new x("input", "报表任务处理器未注册");
|
|
365
445
|
if (!a.signal.aborted) {
|
|
366
|
-
const
|
|
446
|
+
const y = await m(U(r.request.payload), {
|
|
367
447
|
scope: s,
|
|
368
448
|
taskId: n,
|
|
369
449
|
signal: a.signal,
|
|
370
|
-
reportProgress:
|
|
450
|
+
reportProgress: i
|
|
371
451
|
});
|
|
372
|
-
if (
|
|
452
|
+
if (u = JSON.parse(F(y)), Ne(u) > t.maxResultBytes) throw new ae();
|
|
373
453
|
}
|
|
374
|
-
} catch (
|
|
375
|
-
|
|
454
|
+
} catch (m) {
|
|
455
|
+
l = m ?? new Error("报表任务执行失败");
|
|
376
456
|
} finally {
|
|
377
|
-
clearInterval(
|
|
457
|
+
clearInterval(f), await c.finish().catch(() => {
|
|
378
458
|
});
|
|
379
459
|
}
|
|
380
|
-
const
|
|
381
|
-
if (!
|
|
382
|
-
throw new
|
|
383
|
-
const
|
|
384
|
-
delete
|
|
385
|
-
code:
|
|
386
|
-
message:
|
|
387
|
-
}) : (
|
|
460
|
+
const w = await _(e.store, s, n), p = t.now();
|
|
461
|
+
if (!oe(w, o, p, r.attempt))
|
|
462
|
+
throw new x("lease", "任务租约已失效,迟到结果不会写回");
|
|
463
|
+
const g = { ...w, updatedAt: p };
|
|
464
|
+
delete g.lease, l ??= d, w.cancelRequested || a.signal.aborted && d === void 0 ? g.status = "cancelled" : l !== void 0 ? (g.status = "failed", g.error = {
|
|
465
|
+
code: l instanceof ae ? "result-budget" : l instanceof x ? l.code : "execution",
|
|
466
|
+
message: l instanceof Error ? l.message.slice(0, 500) : "报表任务执行失败"
|
|
467
|
+
}) : (g.status = "completed", g.result = u);
|
|
388
468
|
try {
|
|
389
|
-
|
|
469
|
+
F(g);
|
|
390
470
|
} catch {
|
|
391
|
-
delete
|
|
471
|
+
delete g.result, g.status = "failed", g.error = {
|
|
392
472
|
code: "result-budget",
|
|
393
473
|
message: "任务结果与请求的组合超过存储预算,请保存文件引用而非文件内容"
|
|
394
474
|
};
|
|
395
475
|
}
|
|
396
|
-
return
|
|
476
|
+
return Ve(e.store, w, g);
|
|
397
477
|
}
|
|
398
|
-
async function
|
|
478
|
+
async function Ve(e, t, r) {
|
|
399
479
|
try {
|
|
400
|
-
return await
|
|
480
|
+
return await D(e, t, r, ["lease"]);
|
|
401
481
|
} catch (a) {
|
|
402
|
-
if (!(a instanceof
|
|
403
|
-
return delete r.result, r.status = "failed", r.error = { code: "result-budget", message: "任务结果超过存储剩余预算,请保存文件引用而非文件内容" },
|
|
482
|
+
if (!(a instanceof x) || a.code !== "capacity" || r.status !== "completed") throw a;
|
|
483
|
+
return delete r.result, r.status = "failed", r.error = { code: "result-budget", message: "任务结果超过存储剩余预算,请保存文件引用而非文件内容" }, D(e, t, r, ["lease", "result"]);
|
|
404
484
|
}
|
|
405
485
|
}
|
|
406
|
-
async function
|
|
486
|
+
async function ie(e, t, r, a) {
|
|
407
487
|
const s = await e.readTombstone?.(t, r);
|
|
408
488
|
if (s) {
|
|
409
|
-
if (s.requestHash !== await
|
|
410
|
-
return { scope: t, id: r, revision: s.revision, request:
|
|
489
|
+
if (s.requestHash !== await Fe(a)) throw new x("conflict", "相同任务ID不能提交不同内容(幂等保留期内)");
|
|
490
|
+
return { scope: t, id: r, revision: s.revision, request: U(a), status: s.status, createdAt: s.createdAt, updatedAt: s.updatedAt, attempt: s.attempt, archived: !0 };
|
|
411
491
|
}
|
|
412
492
|
}
|
|
413
|
-
function
|
|
493
|
+
function It(e) {
|
|
414
494
|
e = { ...e, handlers: { ...e.handlers } };
|
|
415
|
-
const t =
|
|
495
|
+
const t = Ue(e), r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
416
496
|
let s = !1, n = 0;
|
|
417
|
-
const
|
|
497
|
+
const o = (i, f) => (Q(i, f), e.store.read(i, f));
|
|
418
498
|
return {
|
|
419
|
-
submit: async (
|
|
420
|
-
if (
|
|
421
|
-
throw new
|
|
422
|
-
const
|
|
423
|
-
kind:
|
|
499
|
+
submit: async (i) => {
|
|
500
|
+
if (i = { ...i }, Q(i.scope, i.id), !Object.prototype.hasOwnProperty.call(e.handlers, i.kind) || typeof e.handlers[i.kind] != "function")
|
|
501
|
+
throw new x("input", "报表任务处理器未注册");
|
|
502
|
+
const f = {
|
|
503
|
+
kind: i.kind,
|
|
424
504
|
payload: JSON.parse(
|
|
425
|
-
|
|
505
|
+
F(i.payload, {
|
|
426
506
|
maxNodes: 19e3,
|
|
427
507
|
maxCharacters: 75e4
|
|
428
508
|
})
|
|
429
509
|
)
|
|
430
|
-
},
|
|
431
|
-
if (
|
|
432
|
-
if (
|
|
433
|
-
throw new
|
|
434
|
-
return
|
|
510
|
+
}, u = await o(i.scope, i.id);
|
|
511
|
+
if (u) {
|
|
512
|
+
if (F(u.request) !== F(f))
|
|
513
|
+
throw new x("conflict", "相同任务ID不能提交不同内容");
|
|
514
|
+
return u;
|
|
435
515
|
}
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
const
|
|
439
|
-
scope:
|
|
440
|
-
id:
|
|
516
|
+
const l = await ie(e.store, i.scope, i.id, f);
|
|
517
|
+
if (l) return l;
|
|
518
|
+
const w = t.now(), p = {
|
|
519
|
+
scope: i.scope,
|
|
520
|
+
id: i.id,
|
|
441
521
|
revision: 1,
|
|
442
|
-
request:
|
|
522
|
+
request: f,
|
|
443
523
|
status: "queued",
|
|
444
|
-
createdAt:
|
|
445
|
-
updatedAt:
|
|
524
|
+
createdAt: w,
|
|
525
|
+
updatedAt: w,
|
|
446
526
|
attempt: 0
|
|
447
527
|
};
|
|
448
|
-
if (!await e.store.compareAndSwap(
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
451
|
-
return
|
|
452
|
-
const
|
|
453
|
-
if (
|
|
454
|
-
throw new
|
|
528
|
+
if (!await e.store.compareAndSwap(i.scope, i.id, null, p)) {
|
|
529
|
+
const g = await o(i.scope, i.id);
|
|
530
|
+
if (g && F(g.request) === F(f))
|
|
531
|
+
return g;
|
|
532
|
+
const m = await ie(e.store, i.scope, i.id, f);
|
|
533
|
+
if (m) return m;
|
|
534
|
+
throw new x("conflict", "报表任务提交发生冲突");
|
|
455
535
|
}
|
|
456
|
-
return
|
|
536
|
+
return U(p);
|
|
457
537
|
},
|
|
458
|
-
get:
|
|
459
|
-
runNext: (
|
|
538
|
+
get: o,
|
|
539
|
+
runNext: (i) => {
|
|
460
540
|
if (s)
|
|
461
|
-
return Promise.reject(new
|
|
541
|
+
return Promise.reject(new x("closed", "报表任务服务已关闭"));
|
|
462
542
|
if (n >= t.concurrency)
|
|
463
543
|
return Promise.reject(
|
|
464
|
-
new
|
|
544
|
+
new x("capacity", "报表任务执行槽位已满")
|
|
465
545
|
);
|
|
466
546
|
n++;
|
|
467
|
-
const
|
|
468
|
-
r.add(
|
|
469
|
-
const
|
|
547
|
+
const f = new AbortController();
|
|
548
|
+
r.add(f);
|
|
549
|
+
const u = (async () => {
|
|
470
550
|
try {
|
|
471
|
-
const
|
|
551
|
+
const l = await He(
|
|
472
552
|
e,
|
|
473
|
-
|
|
553
|
+
i,
|
|
474
554
|
t.leaseMs,
|
|
475
555
|
t.now()
|
|
476
556
|
);
|
|
477
|
-
return
|
|
557
|
+
return l?.status === "running" ? await Ke(e, t, l, f) : l;
|
|
478
558
|
} finally {
|
|
479
|
-
n--, r.delete(
|
|
559
|
+
n--, r.delete(f);
|
|
480
560
|
}
|
|
481
561
|
})();
|
|
482
|
-
return a.add(
|
|
483
|
-
() => a.delete(
|
|
484
|
-
() => a.delete(
|
|
485
|
-
),
|
|
562
|
+
return a.add(u), u.then(
|
|
563
|
+
() => a.delete(u),
|
|
564
|
+
() => a.delete(u)
|
|
565
|
+
), u;
|
|
486
566
|
},
|
|
487
567
|
get active() {
|
|
488
568
|
return n;
|
|
489
569
|
},
|
|
490
|
-
cancel: async (
|
|
491
|
-
const
|
|
492
|
-
return
|
|
570
|
+
cancel: async (i, f) => {
|
|
571
|
+
const u = await _(e.store, i, f);
|
|
572
|
+
return u.status !== "queued" && u.status !== "running" ? u : D(e.store, u, {
|
|
493
573
|
updatedAt: t.now(),
|
|
494
|
-
...
|
|
574
|
+
...u.status === "queued" ? { status: "cancelled" } : { cancelRequested: !0 }
|
|
495
575
|
});
|
|
496
576
|
},
|
|
497
|
-
retry: async (
|
|
498
|
-
const
|
|
499
|
-
if (
|
|
500
|
-
throw new
|
|
501
|
-
const
|
|
502
|
-
...
|
|
577
|
+
retry: async (i, f, u) => {
|
|
578
|
+
const l = await _(e.store, i, f);
|
|
579
|
+
if (l.revision !== u || l.status !== "failed")
|
|
580
|
+
throw new x("conflict", "仅可重试当前修订的失败任务");
|
|
581
|
+
const w = {
|
|
582
|
+
...l,
|
|
503
583
|
status: "queued",
|
|
504
584
|
updatedAt: t.now()
|
|
505
585
|
};
|
|
506
|
-
return delete
|
|
586
|
+
return delete w.error, delete w.progress, D(e.store, l, w, ["error", "progress"]);
|
|
507
587
|
},
|
|
508
|
-
prune: async (
|
|
509
|
-
if (!e.store.prune || !e.store.readTombstone) throw new
|
|
510
|
-
return e.store.prune({ ...
|
|
588
|
+
prune: async (i) => {
|
|
589
|
+
if (!e.store.prune || !e.store.readTombstone) throw new x("input", "当前任务适配器未实现可选终态保留能力");
|
|
590
|
+
return e.store.prune({ ...i, now: t.now() });
|
|
511
591
|
},
|
|
512
592
|
close: async () => {
|
|
513
593
|
s = !0;
|
|
514
|
-
for (const
|
|
515
|
-
|
|
594
|
+
for (const i of r)
|
|
595
|
+
i.abort(new x("closed", "任务服务正在关闭"));
|
|
516
596
|
await Promise.allSettled([...a]);
|
|
517
597
|
}
|
|
518
598
|
};
|
|
519
599
|
}
|
|
520
|
-
function
|
|
600
|
+
function ve(e, t) {
|
|
521
601
|
const r = e.assets, a = e[t];
|
|
522
602
|
if (!(!r && !a?.assetRenderers))
|
|
523
603
|
return {
|
|
@@ -528,15 +608,15 @@ function ae(e, t) {
|
|
|
528
608
|
assetBudget: { ...r?.assetBudget, ...a?.assetBudget }
|
|
529
609
|
};
|
|
530
610
|
}
|
|
531
|
-
function
|
|
532
|
-
return !e || e.code !== "missing-image" || e.format !== "pdf" && e.format !== "xlsx" ? !1 : typeof
|
|
611
|
+
function ce(e, t) {
|
|
612
|
+
return !e || e.code !== "missing-image" || e.format !== "pdf" && e.format !== "xlsx" ? !1 : typeof ve(t, e.format)?.assetRenderers?.[e.kind] == "function";
|
|
533
613
|
}
|
|
534
|
-
function
|
|
535
|
-
const r =
|
|
614
|
+
function Xe(e, t) {
|
|
615
|
+
const r = Ae(e, t), a = r.issues.filter((n) => !ce(n.diagnostic, t)), s = r.samples.map((n) => ({ ...n, diagnostics: n.diagnostics.filter((o) => !ce(o, t)) }));
|
|
536
616
|
return { ...r, issues: a, samples: s, ok: a.every((n) => n.severity !== "error"), artifacts: [] };
|
|
537
617
|
}
|
|
538
|
-
async function
|
|
539
|
-
const n =
|
|
618
|
+
async function Qe(e, t, r, a, s) {
|
|
619
|
+
const n = he({ reports: { sample: { template: r, datasets: e.datasets } }, assets: ve(a, t), budget: {
|
|
540
620
|
maxRows: a.maxSampleRows ?? 1e3,
|
|
541
621
|
maxPages: a.maxPages ?? 100,
|
|
542
622
|
maxCells: a.maxCells ?? 25e4,
|
|
@@ -544,227 +624,407 @@ async function Je(e, t, r, a, s) {
|
|
|
544
624
|
maxDurationMs: a.maxDurationMs ?? 3e4
|
|
545
625
|
} });
|
|
546
626
|
try {
|
|
547
|
-
const { result:
|
|
548
|
-
const
|
|
549
|
-
if (a.strictOutputs &&
|
|
550
|
-
const
|
|
551
|
-
return
|
|
627
|
+
const { result: o, digest: d } = await j(a.signal, a.maxDurationMs ?? 3e4, async (c) => {
|
|
628
|
+
const i = await n.export({ reportIds: ["sample"], params: e.params, format: t, signal: c, fidelity: a.strictOutputs ? "strict" : "warn", pdf: a.pdf, xlsx: a.xlsx }), f = i.diagnostics.filter((l) => l.severity !== "info");
|
|
629
|
+
if (a.strictOutputs && f.length) throw new Error(`Strict ${t} encoding found fidelity issues: ${f.slice(0, 3).map((l) => l.message).join("; ")}`);
|
|
630
|
+
const u = await a.digest?.(i.bytes);
|
|
631
|
+
return v(c), await a.onArtifact?.(e.name, i), v(c), { result: i, digest: u };
|
|
552
632
|
});
|
|
553
|
-
s.artifacts.push({ fixture: e.name, format: t, bytes:
|
|
554
|
-
} catch (
|
|
555
|
-
|
|
633
|
+
s.artifacts.push({ fixture: e.name, format: t, bytes: o.bytes.byteLength, pages: o.stats.pages, ...d ? { digest: d } : {} }), s.issues.push(...o.diagnostics.map((c) => ({ code: "output", severity: a.strictOutputs || c.severity === "error" ? "error" : "warning", path: "$.template", fixture: e.name, message: `${t}: ${c.message}` })));
|
|
634
|
+
} catch (o) {
|
|
635
|
+
v(a.signal), s.issues.push({ code: "output", severity: "error", path: "$.template", fixture: e.name, message: `${t}: ${o instanceof Error ? o.message : String(o)}` });
|
|
556
636
|
}
|
|
557
637
|
}
|
|
558
|
-
async function
|
|
559
|
-
|
|
560
|
-
const r =
|
|
638
|
+
async function Ot(e, t = {}) {
|
|
639
|
+
v(t.signal);
|
|
640
|
+
const r = Xe(e, t);
|
|
561
641
|
if (!r.ok) return r;
|
|
562
|
-
const a =
|
|
642
|
+
const a = Je(e).template, s = [...new Set(t.formats ?? ["pdf", "xlsx"])];
|
|
563
643
|
if (!s.length || s.some((n) => n !== "pdf" && n !== "xlsx"))
|
|
564
644
|
return r.issues.push({ code: "output", severity: "error", path: "$.formats", message: "真实文件验收应至少选择PDF/XLSX之一" }), r.ok = !1, r;
|
|
565
645
|
for (const n of t.fixtures ?? [])
|
|
566
|
-
for (const
|
|
567
|
-
|
|
646
|
+
for (const o of s)
|
|
647
|
+
v(t.signal), !(o !== "pdf" && o !== "xlsx") && await Qe(n, o, a, t, r);
|
|
568
648
|
return r.ok = r.issues.every((n) => n.severity !== "error"), r;
|
|
569
649
|
}
|
|
570
|
-
class
|
|
650
|
+
class h extends Error {
|
|
571
651
|
constructor(t, r) {
|
|
572
652
|
super(r), this.code = t, this.name = "ReportInstanceError";
|
|
573
653
|
}
|
|
574
654
|
}
|
|
575
|
-
function
|
|
576
|
-
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
|
|
655
|
+
function J(e, t) {
|
|
656
|
+
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 h("input", "实例范围应非空,ID 应为安全标识");
|
|
577
657
|
}
|
|
578
|
-
function
|
|
658
|
+
function Ge(e, t) {
|
|
579
659
|
const r = Object.getPrototypeOf(e);
|
|
580
|
-
if (r !== (t ? Array.prototype : Object.prototype) && !(r === null && !t) || Object.getOwnPropertySymbols(e).length) throw new
|
|
581
|
-
if (t && Object.keys(e).some((s) => s !== String(Number(s)) || !Number.isSafeInteger(Number(s)) || Number(s) < 0 || Number(s) >= e.length)) throw new
|
|
582
|
-
if (Object.getOwnPropertyNames(e).filter((s) => !(t && s === "length")).length !== Object.keys(e).length) throw new
|
|
660
|
+
if (r !== (t ? Array.prototype : Object.prototype) && !(r === null && !t) || Object.getOwnPropertySymbols(e).length) throw new h("input", "实例应为普通 JSON 对象");
|
|
661
|
+
if (t && Object.keys(e).some((s) => s !== String(Number(s)) || !Number.isSafeInteger(Number(s)) || Number(s) < 0 || Number(s) >= e.length)) throw new h("input", "实例数组不能包含额外属性");
|
|
662
|
+
if (Object.getOwnPropertyNames(e).filter((s) => !(t && s === "length")).length !== Object.keys(e).length) throw new h("input", "实例不能包含不可枚举属性");
|
|
583
663
|
}
|
|
584
|
-
function
|
|
585
|
-
if (!Number.isSafeInteger(e.revision) || e.revision < 1 || typeof e.title != "string" || !e.title.trim() || e.title.length > 512) throw new
|
|
586
|
-
if (typeof e.generatedAt != "string" || !Number.isFinite(Date.parse(e.generatedAt)) || new Date(e.generatedAt).toISOString() !== e.generatedAt) throw new
|
|
587
|
-
if (!Array.isArray(e.reportIds) || !e.reportIds.length || e.reportIds.length > 100 || e.reportIds.some((t) => typeof t != "string" || !t.trim()) || new Set(e.reportIds).size !== e.reportIds.length) throw new
|
|
664
|
+
function We(e) {
|
|
665
|
+
if (!Number.isSafeInteger(e.revision) || e.revision < 1 || typeof e.title != "string" || !e.title.trim() || e.title.length > 512) throw new h("input", "实例修订或标题无效");
|
|
666
|
+
if (typeof e.generatedAt != "string" || !Number.isFinite(Date.parse(e.generatedAt)) || new Date(e.generatedAt).toISOString() !== e.generatedAt) throw new h("input", "实例生成时间应为 ISO UTC 字符串");
|
|
667
|
+
if (!Array.isArray(e.reportIds) || !e.reportIds.length || e.reportIds.length > 100 || e.reportIds.some((t) => typeof t != "string" || !t.trim()) || new Set(e.reportIds).size !== e.reportIds.length) throw new h("input", "实例报表 ID 应非空且唯一");
|
|
588
668
|
}
|
|
589
|
-
function
|
|
669
|
+
function Ze(e) {
|
|
590
670
|
return e === null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" && Number.isFinite(e);
|
|
591
671
|
}
|
|
592
|
-
function
|
|
593
|
-
if (!Number.isSafeInteger(t) || t < 1) throw new
|
|
672
|
+
function be(e, t) {
|
|
673
|
+
if (!Number.isSafeInteger(t) || t < 1) throw new h("input", "实例快照字节预算应为正安全整数");
|
|
594
674
|
let r = 0, a = 0;
|
|
595
675
|
const s = /* @__PURE__ */ new Set();
|
|
596
|
-
function n(
|
|
597
|
-
if (++r > 1e6 ||
|
|
598
|
-
if (typeof
|
|
599
|
-
throw new
|
|
600
|
-
if (
|
|
601
|
-
if (!
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
const
|
|
605
|
-
for (const
|
|
606
|
-
if (a +=
|
|
607
|
-
const
|
|
608
|
-
if (
|
|
609
|
-
|
|
676
|
+
function n(d, c) {
|
|
677
|
+
if (++r > 1e6 || c > 64) throw new h("capacity", "实例节点或嵌套深度超过预算");
|
|
678
|
+
if (typeof d == "string" && (a += d.length, a > t))
|
|
679
|
+
throw new h("capacity", "实例文本超过预算");
|
|
680
|
+
if (Ze(d)) return d;
|
|
681
|
+
if (!d || typeof d != "object" || s.has(d)) throw new h("input", "实例只允许无循环的有限 JSON 值");
|
|
682
|
+
const i = Array.isArray(d);
|
|
683
|
+
Ge(d, i), s.add(d);
|
|
684
|
+
const f = /* @__PURE__ */ Object.create(null);
|
|
685
|
+
for (const u of Object.keys(d)) {
|
|
686
|
+
if (a += u.length, a > t) throw new h("capacity", "实例文本超过预算");
|
|
687
|
+
const l = Object.getOwnPropertyDescriptor(d, u);
|
|
688
|
+
if (l.get || l.set || ["__proto__", "constructor", "prototype"].includes(u)) throw new h("input", "实例不能包含访问器或危险键");
|
|
689
|
+
l.value !== void 0 && (f[u] = n(l.value, c + 1));
|
|
610
690
|
}
|
|
611
|
-
if (s.delete(
|
|
612
|
-
if (Object.keys(
|
|
613
|
-
return Array.from({ length:
|
|
691
|
+
if (s.delete(d), i) {
|
|
692
|
+
if (Object.keys(f).length !== d.length) throw new h("input", "实例数组不能稀疏或包含额外属性");
|
|
693
|
+
return Array.from({ length: d.length }, (u, l) => f[String(l)]);
|
|
614
694
|
}
|
|
615
|
-
return
|
|
695
|
+
return f;
|
|
616
696
|
}
|
|
617
|
-
const
|
|
618
|
-
if (new TextEncoder().encode(
|
|
619
|
-
return
|
|
620
|
-
}
|
|
621
|
-
function
|
|
622
|
-
const r = JSON.parse(
|
|
623
|
-
|
|
624
|
-
const a = /* @__PURE__ */ new Set(["scope", "id", "revision", "title", "generatedAt", "reportIds", "params", "templateRevisions", "sourceRevisions", "plan", "artifacts"]);
|
|
625
|
-
if (Object.keys(r).some((n) => !a.has(n))) throw new
|
|
626
|
-
|
|
697
|
+
const o = JSON.stringify(n(e, 0));
|
|
698
|
+
if (new TextEncoder().encode(o).byteLength > t) throw new h("capacity", "实例快照超过单条字节预算");
|
|
699
|
+
return o;
|
|
700
|
+
}
|
|
701
|
+
function W(e, t = 8e6) {
|
|
702
|
+
const r = JSON.parse(be(e, t));
|
|
703
|
+
J(r.scope, r.id);
|
|
704
|
+
const a = /* @__PURE__ */ new Set(["scope", "id", "revision", "title", "generatedAt", "reportIds", "params", "templateRevisions", "sourceRevisions", "plan", "artifacts", "output"]);
|
|
705
|
+
if (Object.keys(r).some((n) => !a.has(n))) throw new h("input", "实例包含未知字段");
|
|
706
|
+
We(r);
|
|
627
707
|
for (const n of [r.params, r.templateRevisions, r.sourceRevisions])
|
|
628
|
-
if (!n || typeof n != "object" || Array.isArray(n) || Object.values(n).some((
|
|
629
|
-
if (r.reportIds.some((n) => !r.templateRevisions[n])) throw new
|
|
630
|
-
const s =
|
|
631
|
-
if (!s.ok) throw new
|
|
632
|
-
|
|
708
|
+
if (!n || typeof n != "object" || Array.isArray(n) || Object.values(n).some((o) => typeof o != "string")) throw new h("input", "实例参数和修订应为字符串字典");
|
|
709
|
+
if (r.reportIds.some((n) => !r.templateRevisions[n])) throw new h("input", "每张报表都应记录生成时的模板修订");
|
|
710
|
+
const s = fe(r.plan);
|
|
711
|
+
if (!s.ok) throw new h("input", `实例渲染计划无效:${s.errors[0]?.path}`);
|
|
712
|
+
if (r.output !== void 0) {
|
|
713
|
+
if (!r.output || Object.keys(r.output).some((n) => !["stats", "diagnostics", "layout"].includes(n))) throw new h("input", "实例输出元数据只允许统计、诊断和字体度量;不保存来源令牌");
|
|
714
|
+
ge({ ...r.output, plan: r.plan, revisions: {} });
|
|
715
|
+
}
|
|
716
|
+
return r.artifacts !== void 0 && Ye(r.artifacts), r;
|
|
633
717
|
}
|
|
634
|
-
function
|
|
635
|
-
if (!Array.isArray(e) || e.length > 100) throw new
|
|
718
|
+
function Ye(e) {
|
|
719
|
+
if (!Array.isArray(e) || e.length > 100) throw new h("input", "实例文件列表无效");
|
|
636
720
|
const t = /* @__PURE__ */ new Set();
|
|
637
721
|
for (const r of e) {
|
|
638
|
-
if (!r || typeof r.key != "string" || !r.key.trim() || r.key.length > 1024 || t.has(r.key) || !["pdf", "xlsx"].includes(r.format) || !Number.isSafeInteger(r.bytes) || r.bytes < 0 || r.sha256 !== void 0 && (typeof r.sha256 != "string" || r.sha256.length !== 64 || !/^[a-f0-9]{64}$/i.test(r.sha256))) throw new
|
|
722
|
+
if (!r || typeof r.key != "string" || !r.key.trim() || r.key.length > 1024 || t.has(r.key) || !["pdf", "xlsx"].includes(r.format) || !Number.isSafeInteger(r.bytes) || r.bytes < 0 || r.sha256 !== void 0 && (typeof r.sha256 != "string" || r.sha256.length !== 64 || !/^[a-f0-9]{64}$/i.test(r.sha256))) throw new h("input", "实例文件应包含唯一存储键、格式、大小和可选 SHA256");
|
|
639
723
|
t.add(r.key);
|
|
640
724
|
}
|
|
641
725
|
}
|
|
642
|
-
function
|
|
643
|
-
const { scope: t, id: r, revision: a, title: s, generatedAt: n, reportIds:
|
|
644
|
-
return JSON.parse(JSON.stringify({ scope: t, id: r, revision: a, title: s, generatedAt: n, reportIds:
|
|
726
|
+
function et(e) {
|
|
727
|
+
const { scope: t, id: r, revision: a, title: s, generatedAt: n, reportIds: o, params: d, templateRevisions: c, sourceRevisions: i } = e;
|
|
728
|
+
return JSON.parse(JSON.stringify({ scope: t, id: r, revision: a, title: s, generatedAt: n, reportIds: o, params: d, templateRevisions: c, sourceRevisions: i }));
|
|
645
729
|
}
|
|
646
|
-
function
|
|
730
|
+
function tt(e) {
|
|
647
731
|
const t = { maxInstances: 100, maxRevisions: 20, maxBytes: 64e6, maxSnapshotBytes: 8e6, ...e };
|
|
648
|
-
if (Object.values(t).some((r) => !Number.isSafeInteger(r) || r < 1)) throw new
|
|
732
|
+
if (Object.values(t).some((r) => !Number.isSafeInteger(r) || r < 1)) throw new h("input", "实例存储预算应为正安全整数");
|
|
649
733
|
return t;
|
|
650
734
|
}
|
|
651
|
-
function
|
|
652
|
-
const t =
|
|
735
|
+
function Pt(e = {}) {
|
|
736
|
+
const t = tt(e), r = /* @__PURE__ */ new Map();
|
|
653
737
|
let a = 0;
|
|
654
738
|
return {
|
|
655
|
-
read: async (s, n,
|
|
656
|
-
|
|
657
|
-
const
|
|
658
|
-
return
|
|
739
|
+
read: async (s, n, o, d) => {
|
|
740
|
+
v(d), J(s, n);
|
|
741
|
+
const c = r.get(JSON.stringify([s, n])), i = c?.get(o ?? c.size);
|
|
742
|
+
return i ? W(i, t.maxSnapshotBytes) : void 0;
|
|
659
743
|
},
|
|
660
744
|
list: async (s, n = {}) => {
|
|
661
|
-
|
|
662
|
-
const
|
|
663
|
-
if (!Number.isSafeInteger(
|
|
664
|
-
const
|
|
665
|
-
return { items:
|
|
745
|
+
v(n.signal), J(s, "list");
|
|
746
|
+
const o = n.limit ?? 25;
|
|
747
|
+
if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new h("input", "实例每页数量应为 1–100");
|
|
748
|
+
const d = Array.from(r.values(), (c) => c.get(c.size)).filter((c) => c.scope === s && (!n.after || c.id > n.after) && (!n.reportId || c.reportIds.includes(n.reportId))).sort((c, i) => c.id < i.id ? -1 : 1).slice(0, o + 1);
|
|
749
|
+
return { items: d.slice(0, o).map(et), ...d.length > o ? { next: d[o - 1].id } : {} };
|
|
666
750
|
},
|
|
667
|
-
compareAndSwap: async (s, n,
|
|
668
|
-
|
|
669
|
-
const
|
|
670
|
-
if (
|
|
671
|
-
const
|
|
672
|
-
if ((
|
|
673
|
-
const
|
|
674
|
-
if (
|
|
675
|
-
return
|
|
751
|
+
compareAndSwap: async (s, n, o, d, c) => {
|
|
752
|
+
v(c), J(s, n);
|
|
753
|
+
const i = W(d, t.maxSnapshotBytes);
|
|
754
|
+
if (i.scope !== s || i.id !== n || i.revision !== (o ?? 0) + 1) throw new h("input", "实例身份或修订不一致");
|
|
755
|
+
const f = JSON.stringify([s, n]), u = r.get(f) ?? /* @__PURE__ */ new Map();
|
|
756
|
+
if ((u.size || null) !== o) return !1;
|
|
757
|
+
const l = new TextEncoder().encode(JSON.stringify(i)).byteLength;
|
|
758
|
+
if (u.size >= t.maxRevisions || a + l > t.maxBytes || !u.size && r.size >= t.maxInstances) throw new h("capacity", "实例存储达到预算,请使用持久化归档策略或显式调整容量");
|
|
759
|
+
return u.set(i.revision, i), r.set(f, u), a += l, !0;
|
|
676
760
|
}
|
|
677
761
|
};
|
|
678
762
|
}
|
|
679
|
-
function
|
|
763
|
+
function rt(e, t = {}) {
|
|
680
764
|
const r = t.maxSnapshotBytes ?? 8e6;
|
|
681
|
-
if (!Number.isSafeInteger(r) || r < 1) throw new
|
|
765
|
+
if (!Number.isSafeInteger(r) || r < 1) throw new h("input", "实例快照字节预算应为正安全整数");
|
|
682
766
|
return {
|
|
683
767
|
read: e.read.bind(e),
|
|
684
768
|
list: e.list.bind(e),
|
|
685
769
|
save: async (a, s) => {
|
|
686
770
|
const n = s.expectedRevision;
|
|
687
|
-
if (n !== null && (!Number.isSafeInteger(n) || n < 1 || n >= Number.MAX_SAFE_INTEGER)) throw new
|
|
688
|
-
const
|
|
689
|
-
if (
|
|
690
|
-
return
|
|
771
|
+
if (n !== null && (!Number.isSafeInteger(n) || n < 1 || n >= Number.MAX_SAFE_INTEGER)) throw new h("input", "实例预期修订无效");
|
|
772
|
+
const o = JSON.parse(be(a, r)), d = W({ ...o, revision: (n ?? 0) + 1 }, r);
|
|
773
|
+
if (v(s.signal), !await e.compareAndSwap(d.scope, d.id, n, d, s.signal)) throw new h("conflict", "实例已存在或已变化,请显式确认修订后保存");
|
|
774
|
+
return d;
|
|
691
775
|
}
|
|
692
776
|
};
|
|
693
777
|
}
|
|
694
|
-
function
|
|
695
|
-
return
|
|
778
|
+
function kt(e, t) {
|
|
779
|
+
return F({ reportIds: e, params: t });
|
|
696
780
|
}
|
|
697
|
-
function
|
|
698
|
-
if (!e || typeof e != "object" || Object.getOwnPropertySymbols(e).length) throw new
|
|
781
|
+
function st(e) {
|
|
782
|
+
if (!e || typeof e != "object" || Object.getOwnPropertySymbols(e).length) throw new h("input", "生成请求应为普通对象");
|
|
699
783
|
const t = /* @__PURE__ */ Object.create(null);
|
|
700
784
|
let r;
|
|
701
785
|
const a = /* @__PURE__ */ new Set(["scope", "id", "title", "reportIds", "params", "expectedRevision", "signal"]);
|
|
702
786
|
for (const s of Object.getOwnPropertyNames(e)) {
|
|
703
787
|
const n = Object.getOwnPropertyDescriptor(e, s);
|
|
704
|
-
if (!a.has(s) || !n.enumerable || n.get || n.set) throw new
|
|
788
|
+
if (!a.has(s) || !n.enumerable || n.get || n.set) throw new h("input", "生成请求不能包含未知字段或访问器");
|
|
705
789
|
s === "signal" ? r = n.value : n.value !== void 0 && (t[s] = n.value);
|
|
706
790
|
}
|
|
707
|
-
return { signal: r, request: JSON.parse(
|
|
791
|
+
return { signal: r, request: JSON.parse(F(t)) };
|
|
708
792
|
}
|
|
709
|
-
function
|
|
710
|
-
const t = JSON.parse(
|
|
793
|
+
function At(e) {
|
|
794
|
+
const t = JSON.parse(F(e.templateRevisions)), r = C(e.pdf), a = rt(e.instances, { maxSnapshotBytes: e.maxSnapshotBytes });
|
|
711
795
|
return {
|
|
712
|
-
async generate(
|
|
713
|
-
const { signal:
|
|
714
|
-
if (
|
|
715
|
-
const
|
|
716
|
-
if (!
|
|
717
|
-
const
|
|
718
|
-
for (const
|
|
719
|
-
if (typeof t[
|
|
720
|
-
|
|
796
|
+
async generate(s) {
|
|
797
|
+
const { signal: n, request: o } = st(s);
|
|
798
|
+
if (J(o.scope, o.id), o.expectedRevision !== null && (!Number.isSafeInteger(o.expectedRevision) || o.expectedRevision < 1)) throw new h("input", "实例预期修订无效");
|
|
799
|
+
const d = e.runtime.validate(o);
|
|
800
|
+
if (!d.ok) throw new le(d.issues);
|
|
801
|
+
const c = /* @__PURE__ */ Object.create(null);
|
|
802
|
+
for (const g of o.reportIds) {
|
|
803
|
+
if (typeof t[g] != "string" || !t[g]) throw new TypeError(`报表 ${g} 缺少生成时的模板修订`);
|
|
804
|
+
c[g] = t[g];
|
|
721
805
|
}
|
|
722
|
-
if (
|
|
723
|
-
throw new
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
const
|
|
727
|
-
for (const [
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
806
|
+
if (v(n), ((await e.instances.read(o.scope, o.id, void 0, n))?.revision ?? null) !== o.expectedRevision)
|
|
807
|
+
throw new h("conflict", "实例已存在或已变化,请显式确认修订后生成");
|
|
808
|
+
const f = await e.runtime.prepare({ reportIds: o.reportIds, params: d.values, pdf: r, signal: n });
|
|
809
|
+
v(n);
|
|
810
|
+
const u = /* @__PURE__ */ Object.create(null);
|
|
811
|
+
for (const [g, m] of Object.entries(f.revisions)) m.revision !== void 0 && (u[g] = m.revision);
|
|
812
|
+
const { plan: l, revisions: w, ...p } = f;
|
|
813
|
+
return a.save({
|
|
814
|
+
scope: o.scope,
|
|
815
|
+
id: o.id,
|
|
816
|
+
title: o.title,
|
|
817
|
+
reportIds: o.reportIds,
|
|
818
|
+
params: d.values,
|
|
819
|
+
templateRevisions: c,
|
|
820
|
+
sourceRevisions: u,
|
|
736
821
|
generatedAt: (e.now?.() ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
737
|
-
plan:
|
|
738
|
-
|
|
822
|
+
plan: l,
|
|
823
|
+
output: p
|
|
824
|
+
}, { expectedRevision: o.expectedRevision, signal: n });
|
|
825
|
+
},
|
|
826
|
+
read: a.read,
|
|
827
|
+
list: a.list,
|
|
828
|
+
/** Read an immutable saved revision and encode its plan, never re-query the business source. */
|
|
829
|
+
async exportInstance(s) {
|
|
830
|
+
const { scope: n, id: o, revision: d, signal: c, format: i, fidelity: f, taskId: u, correlationId: l, onEvent: w } = s, p = C(s.pdf ?? r), g = G(s.xlsx);
|
|
831
|
+
J(n, o), v(c);
|
|
832
|
+
const m = await a.read(n, o, d, c);
|
|
833
|
+
if (!m) throw new h("input", "报表实例不存在");
|
|
834
|
+
const y = {
|
|
835
|
+
plan: m.plan,
|
|
836
|
+
revisions: Object.fromEntries(m.reportIds.map((A) => [A, { revision: m.sourceRevisions[A] }])),
|
|
837
|
+
diagnostics: [{ code: "instance-row-count", severity: "info", message: "历史实例未保存原始取数行数;本次 rows 统计为 0,页面及单元格数由已保存计划校验。" }],
|
|
838
|
+
stats: { rows: 0, pages: m.plan.pages.length, cells: 0, durationMs: 0 },
|
|
839
|
+
...m.output
|
|
840
|
+
};
|
|
841
|
+
return e.runtime.exportPrepared({ prepared: y, format: i, fidelity: f, pdf: p, xlsx: g, signal: c, taskId: u, correlationId: l, onEvent: w });
|
|
739
842
|
},
|
|
740
|
-
read: r.read,
|
|
741
|
-
list: r.list,
|
|
742
843
|
/** Instance edits are explicit snapshots; source business persistence remains the Provider.save responsibility. */
|
|
743
|
-
save:
|
|
844
|
+
save: a.save
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
function L(e, t, r) {
|
|
848
|
+
if (!Number.isSafeInteger(e) || e < 1 || e > t) throw new RangeError(`${r} 应为 1–${t} 的安全整数`);
|
|
849
|
+
return e;
|
|
850
|
+
}
|
|
851
|
+
function ue(e) {
|
|
852
|
+
if (!e || typeof e.key != "string" || !e.key.trim() || e.key.length > 1024 || !["pdf", "xlsx"].includes(e.format) || !Number.isSafeInteger(e.bytes) || e.bytes < 0 || e.sha256 !== void 0 && !/^[a-f0-9]{64}$/i.test(e.sha256)) throw new TypeError("分批归档回执应包含存储键、格式、大小和可选 SHA256");
|
|
853
|
+
return { key: e.key, format: e.format, bytes: e.bytes, ...e.sha256 ? { sha256: e.sha256 } : {} };
|
|
854
|
+
}
|
|
855
|
+
function nt(e) {
|
|
856
|
+
if (!Ce(e).ok || !e.repeat) throw new TypeError("分批生成仅支持有效的逐记录固定标签模板");
|
|
857
|
+
return JSON.parse(JSON.stringify(e));
|
|
858
|
+
}
|
|
859
|
+
function at(e) {
|
|
860
|
+
const t = /* @__PURE__ */ new Set(), r = e.repeat;
|
|
861
|
+
r.rowKey && t.add(r.rowKey), typeof r.copies == "object" && t.add(r.copies.field);
|
|
862
|
+
const a = (s) => {
|
|
863
|
+
s.binding && t.add(s.binding.field);
|
|
864
|
+
for (const n of s.grid?.cells ?? []) for (const o of n) o?.children?.forEach(a);
|
|
744
865
|
};
|
|
866
|
+
return e.pages.forEach((s) => s.components.forEach((n) => a(n))), [...t];
|
|
867
|
+
}
|
|
868
|
+
function ot(e, t, r, a) {
|
|
869
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw new TypeError(`标签记录 ${a} 应为对象`);
|
|
870
|
+
const s = /* @__PURE__ */ Object.create(null);
|
|
871
|
+
for (const n of t) {
|
|
872
|
+
const o = pe(e, n, { dataset: r, rowIndex: a });
|
|
873
|
+
if (typeof o == "string" && o.length > 1e6) throw new k("budget", "标签字段超过 1 MB 字符预算", `$.datasets.${r}[${a}].${n}`);
|
|
874
|
+
o !== void 0 && (s[n] = o);
|
|
875
|
+
}
|
|
876
|
+
return s;
|
|
877
|
+
}
|
|
878
|
+
function it(e, t, r, a) {
|
|
879
|
+
const s = t.repeat;
|
|
880
|
+
if (!s.rowKey) return;
|
|
881
|
+
const n = pe(e, s.rowKey, { rowIndex: a, dataset: s.dataset });
|
|
882
|
+
if (!(typeof n == "string" && n.trim() || typeof n == "number" && Number.isFinite(n))) throw new TypeError(`标签记录 ${a} 的业务主键无效`);
|
|
883
|
+
const o = JSON.stringify([typeof n, n]);
|
|
884
|
+
if (r.keys.has(o)) throw new TypeError(`标签记录 ${a} 的业务主键重复(包含先前批次)`);
|
|
885
|
+
r.bytes += o.length * 2 + 64, r.keys.add(o);
|
|
886
|
+
}
|
|
887
|
+
function ct(e) {
|
|
888
|
+
return Object.entries(e).reduce((t, [r, a]) => t + 64 + r.length * 2 + (typeof a == "string" ? a.length * 2 : 8), 0);
|
|
889
|
+
}
|
|
890
|
+
function ut(e, t) {
|
|
891
|
+
if (!t) return e;
|
|
892
|
+
for (const r of e.plan.pages) {
|
|
893
|
+
const a = r.meta?.record;
|
|
894
|
+
a && typeof a == "object" && "rowIndex" in a && typeof a.rowIndex == "number" && (a.rowIndex += t);
|
|
895
|
+
}
|
|
896
|
+
return e;
|
|
897
|
+
}
|
|
898
|
+
async function dt(e, t) {
|
|
899
|
+
if (!e.return) return;
|
|
900
|
+
const r = Promise.resolve(e.return());
|
|
901
|
+
if (t.aborted) {
|
|
902
|
+
r.catch(() => {
|
|
903
|
+
});
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
await j(t, void 0, () => r);
|
|
907
|
+
}
|
|
908
|
+
async function de(e, t, r) {
|
|
909
|
+
const a = Promise.resolve().then(() => e.onReceipt?.(t, r));
|
|
910
|
+
a.catch(() => {
|
|
911
|
+
}), await j(r.signal, void 0, () => a);
|
|
912
|
+
}
|
|
913
|
+
function lt(e, t, r) {
|
|
914
|
+
return new Promise((a, s) => {
|
|
915
|
+
let n = !1, o = !1, d;
|
|
916
|
+
const c = () => {
|
|
917
|
+
clearTimeout(d), t.removeEventListener("abort", i);
|
|
918
|
+
}, i = () => {
|
|
919
|
+
n || d !== void 0 || (d = setTimeout(() => {
|
|
920
|
+
if (!n) {
|
|
921
|
+
n = !0, o = !0, c();
|
|
922
|
+
try {
|
|
923
|
+
v(t);
|
|
924
|
+
} catch (f) {
|
|
925
|
+
s(f);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}, 0));
|
|
929
|
+
};
|
|
930
|
+
e.then((f) => {
|
|
931
|
+
if (o) {
|
|
932
|
+
Promise.resolve().then(() => r(f)).catch(() => {
|
|
933
|
+
});
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
n || (n = !0, c(), a(f));
|
|
937
|
+
}, (f) => {
|
|
938
|
+
n || (n = !0, c(), s(f));
|
|
939
|
+
}), t.addEventListener("abort", i, { once: !0 }), t.aborted && i();
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
async function Bt(e, t) {
|
|
943
|
+
const r = L(t.batchSize ?? 100, 1e3, "batchSize"), a = L(t.maxRows ?? 1e5, 1e6, "maxRows"), s = L(t.maxChunks ?? 1e3, 1e4, "maxChunks"), n = L(t.maxRetainedBytes ?? 16e6, 64e6, "maxRetainedBytes"), o = nt(t.template), d = at(o);
|
|
944
|
+
if (!e || typeof e[Symbol.asyncIterator] != "function") throw new TypeError("标签来源应为 AsyncIterable");
|
|
945
|
+
return j(t.signal, t.runtime?.budget?.maxDurationMs ?? 12e4, async (c) => {
|
|
946
|
+
const i = { rows: 0, chunks: [] }, f = { keys: /* @__PURE__ */ new Set(), bytes: 0 }, u = e[Symbol.asyncIterator]();
|
|
947
|
+
let l = !1, w = !1, p;
|
|
948
|
+
const g = () => p ??= dt(u, c), m = () => {
|
|
949
|
+
l || g().catch(() => {
|
|
950
|
+
});
|
|
951
|
+
};
|
|
952
|
+
c.addEventListener("abort", m, { once: !0 });
|
|
953
|
+
try {
|
|
954
|
+
for (; !l; ) {
|
|
955
|
+
v(c);
|
|
956
|
+
const y = [];
|
|
957
|
+
let A = 0;
|
|
958
|
+
for (; y.length < r; ) {
|
|
959
|
+
const B = await j(c, void 0, () => Promise.resolve(u.next()));
|
|
960
|
+
if (B.done) {
|
|
961
|
+
l = !0;
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
if (i.rows + y.length >= a) throw new k("budget", "标签来源行数超过预算", "$.maxRows");
|
|
965
|
+
if (i.chunks.length >= s) throw new k("budget", "标签分块数量超过预算", "$.maxChunks");
|
|
966
|
+
const R = ot(B.value, d, o.repeat.dataset, i.rows + y.length);
|
|
967
|
+
if (it(R, o, f, i.rows + y.length), A += ct(R), f.bytes + A > n) throw new k("budget", "标签当前块字段与全局主键索引超过内存预算", "$.maxRetainedBytes");
|
|
968
|
+
y.push(R);
|
|
969
|
+
}
|
|
970
|
+
if (!y.length) break;
|
|
971
|
+
const b = he({ ...t.runtime, reports: { labels: { template: o, datasets: { [o.repeat.dataset]: y } } } });
|
|
972
|
+
let S;
|
|
973
|
+
const I = {
|
|
974
|
+
index: i.chunks.length,
|
|
975
|
+
rowOffset: i.rows,
|
|
976
|
+
rowCount: y.length,
|
|
977
|
+
signal: c,
|
|
978
|
+
export: (B) => b.exportPrepared({ pdf: t.pdf, ...B, prepared: S, signal: c })
|
|
979
|
+
};
|
|
980
|
+
let E;
|
|
981
|
+
const M = (await je([{ id: `labels-${I.index}`, params: {} }], async () => {
|
|
982
|
+
try {
|
|
983
|
+
S = ut(await b.prepare({ reportIds: ["labels"], pdf: t.pdf, signal: c }), I.rowOffset), v(c);
|
|
984
|
+
const B = Promise.resolve(t.execute(S, I)), R = await lt(B, c, (N) => de(t, ue(N), I));
|
|
985
|
+
return ue(R);
|
|
986
|
+
} catch (B) {
|
|
987
|
+
throw E = B, B;
|
|
988
|
+
}
|
|
989
|
+
}, { concurrency: 1, signal: c, failure: "stop" }))[0];
|
|
990
|
+
if (M.status === "cancelled")
|
|
991
|
+
throw v(c), new Error("标签分批任务已取消");
|
|
992
|
+
if (M.status === "failed") throw E ?? new Error(M.error.message);
|
|
993
|
+
i.chunks.push({ ...M.value, index: I.index, rowOffset: I.rowOffset, rowCount: I.rowCount }), i.rows += y.length, await de(t, M.value, I);
|
|
994
|
+
}
|
|
995
|
+
return i;
|
|
996
|
+
} catch (y) {
|
|
997
|
+
throw w = !0, y;
|
|
998
|
+
} finally {
|
|
999
|
+
c.removeEventListener("abort", m), l || await g().catch((y) => {
|
|
1000
|
+
if (!w) throw y;
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
745
1004
|
}
|
|
746
1005
|
export {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
1006
|
+
h as ReportInstanceError,
|
|
1007
|
+
x as ReportJobError,
|
|
1008
|
+
k as ReportRuntimeError,
|
|
1009
|
+
J as checkInstanceIdentity,
|
|
1010
|
+
Q as checkJobIdentity,
|
|
1011
|
+
U as cloneJob,
|
|
1012
|
+
Pt as createMemoryReportInstanceStore,
|
|
1013
|
+
Ft as createMemoryReportJobStore,
|
|
1014
|
+
At as createReportGenerationService,
|
|
1015
|
+
rt as createReportInstanceManager,
|
|
1016
|
+
It as createReportJobService,
|
|
1017
|
+
he as createReportRuntime,
|
|
1018
|
+
St as createReportTaskQueue,
|
|
1019
|
+
kt as reportInstanceParameterKey,
|
|
1020
|
+
et as reportInstanceSummary,
|
|
1021
|
+
Ot as reviewReportPublication,
|
|
1022
|
+
Bt as runLabelStream,
|
|
1023
|
+
je as runReportBatch,
|
|
1024
|
+
jt as runnableJob,
|
|
1025
|
+
F as serializeJobJson,
|
|
1026
|
+
Mt as snapshotReportBatchCases,
|
|
1027
|
+
W as snapshotReportInstance,
|
|
1028
|
+
$t as validateJobRecord,
|
|
1029
|
+
Jt as validateJobTransition
|
|
770
1030
|
};
|