@agile-team/mach-report 2.15.0 → 2.17.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 +21 -12
- package/dist/{ExcelBindingWizard-Bs43BGNp.cjs → ExcelBindingWizard-Bq6FYME6.cjs} +1 -1
- package/dist/{ExcelBindingWizard-BKH1nGNS.js → ExcelBindingWizard-Co1svTsw.js} +3 -3
- package/dist/{ParamEditor-Da4akw6V.cjs → ParamEditor-B5UZRgxv.cjs} +1 -1
- package/dist/{ParamEditor-DoAhzJsm.js → ParamEditor-DNNARyeB.js} +1 -1
- package/dist/{ReportBatchPanel-wP9m9Pj1.cjs → ReportBatchPanel-Ctvs2t_9.cjs} +1 -1
- package/dist/{ReportBatchPanel-BMf6boMA.js → ReportBatchPanel-uQh06usx.js} +3 -3
- package/dist/ReportPreview-BdQawRh0.js +4879 -0
- package/dist/ReportPreview-CJC_-j2I.cjs +6 -0
- package/dist/{ReportTemplateLibrary-Sxr3eD0J.cjs → ReportTemplateLibrary-CnP7_1pH.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-C9wutIiT.js → ReportTemplateLibrary-TIL_Oj2l.js} +1 -1
- package/dist/RuleEditor-DkRjOLlr.js +2141 -0
- package/dist/RuleEditor-h5anGsDB.cjs +1 -0
- package/dist/{TemplateOutlinePanel-JTSR53vJ.cjs → TemplateOutlinePanel-BlLxRrfu.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-D6Bkny59.js → TemplateOutlinePanel-BouxsuqQ.js} +1 -1
- package/dist/{TemplateReusePanel-rVuK1kTz.js → TemplateReusePanel-BEACLPaN.js} +2 -2
- package/dist/{TemplateReusePanel-Kx35S0Ql.cjs → TemplateReusePanel-yxsHSO40.cjs} +1 -1
- package/dist/{TemplateReviewPanel-B0ar9_zf.js → TemplateReviewPanel-B1OGRY2i.js} +1 -1
- package/dist/{TemplateReviewPanel-Dn6X9UmY.cjs → TemplateReviewPanel-D9Cx0m2N.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +65 -1
- package/dist/analytics.d.ts +65 -1
- package/dist/analytics.js +4 -4
- package/dist/artifact-integrity.json +105 -101
- package/dist/assets-BIMVwjQe.js +231 -0
- package/dist/assets-Dfs2ElxI.cjs +1 -0
- package/dist/auto-BIOmtVhk.js +240 -0
- package/dist/auto-DDHflI9v.cjs +1 -0
- package/dist/{batch-BfZHN1do.js → batch-WzDIXJAt.js} +1 -1
- package/dist/{batch-CLpELXBl.cjs → batch-z6Aw5GEY.cjs} +1 -1
- package/dist/codes.d.cts +2 -0
- package/dist/codes.d.ts +2 -0
- package/dist/component-tree-Ca6YYfHq.js +61 -0
- package/dist/component-tree-DkGLEfZC.cjs +1 -0
- package/dist/computed-BW5a8QFk.js +612 -0
- package/dist/computed-C2GD3XcE.cjs +1 -0
- package/dist/config-Dg_o8e7m.cjs +1 -0
- package/dist/{config-BVsJXSqS.js → config-XQ4qrQ7Q.js} +66 -64
- package/dist/dataset-DL83majE.js +161 -0
- package/dist/dataset-IrlXbUvh.cjs +1 -0
- package/dist/designer-D9XAxqSc.js +5178 -0
- package/dist/designer-uCDo5XSK.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +178 -3
- package/dist/designer.d.ts +178 -3
- package/dist/designer.js +1 -1
- package/dist/drill-ByN8COs_.cjs +1 -0
- package/dist/{drill-ByJviLXS.js → drill-CKW3Xtfa.js} +5 -5
- package/dist/encoding-BFMFIc4r.cjs +1 -0
- package/dist/encoding-DP_Eaf0A.js +21 -0
- package/dist/{font-loader-B_UkxpzC.cjs → font-loader-7FWVlykp.cjs} +1 -1
- package/dist/{font-loader-Q3bQjmrI.js → font-loader-CQZowp0I.js} +1 -1
- package/dist/index.cjs +8 -9
- package/dist/index.d.cts +175 -1
- package/dist/index.d.ts +175 -1
- package/dist/index.js +1343 -915
- package/dist/json-snapshot-D7PE1NsU.cjs +2 -0
- package/dist/json-snapshot-DYmEe3sO.js +1779 -0
- package/dist/matrix-JLAXlux-.js +302 -0
- package/dist/matrix-gTHpDTGm.cjs +1 -0
- package/dist/{pdf-CvvrjPQg.cjs → pdf-B8JouyYv.cjs} +48 -50
- package/dist/{pdf-BwNyeGpt.js → pdf-l3ea86di.js} +2734 -2748
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +14 -0
- package/dist/pdf.d.ts +14 -0
- package/dist/pdf.js +2 -2
- package/dist/{plugin-Ca_XZG3l.js → plugin-BBp74CQZ.js} +1 -1
- package/dist/{plugin-DHO7X8z2.cjs → plugin-CtFX9PFG.cjs} +1 -1
- package/dist/prepared-CARicKYh.js +87 -0
- package/dist/prepared-Ch1x_Gog.cjs +1 -0
- package/dist/progress-BXzlVbIp.js +29 -0
- package/dist/progress-DJBd9Rb9.cjs +1 -0
- package/dist/{progress-D-OTpEav.js → progress-Hc2vxoCs.js} +2 -2
- package/dist/protocol-B5A2uom4.cjs +1 -0
- package/dist/protocol-BaiWjq5w.js +90 -0
- package/dist/record-bindings-B86Sur_y.cjs +1 -0
- package/dist/{record-bindings-Do_b3h4V.js → record-bindings-D4TuMzHs.js} +10 -11
- package/dist/{region-binding-workflow-BMhK_TjP.js → region-binding-workflow-BNasF5kz.js} +2 -2
- package/dist/{region-binding-workflow-DIYJdCUr.cjs → region-binding-workflow-O2Cni3mF.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -0
- package/dist/report-encoding-worker.d.ts +1 -0
- package/dist/report-encoding-worker.js +2 -0
- package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
- package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
- package/dist/runtime-DakRXui3.js +170 -0
- package/dist/runtime-dL5ygIfa.cjs +1 -0
- package/dist/sbom.cdx.json +2 -2
- package/dist/server/node.d.cts +132 -1
- package/dist/server/node.d.ts +132 -1
- package/dist/server-node.cjs +5 -1
- package/dist/server-node.js +5177 -463
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +182 -2
- package/dist/server.d.ts +182 -2
- package/dist/server.js +918 -833
- package/dist/sha256-BshdOkCC.cjs +1 -0
- package/dist/sha256-DTG-Gq8i.js +157 -0
- package/dist/style-67OqfNed.js +73 -0
- package/dist/style-C22Pbv3T.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/template-catalog-Dua8h9ZA.cjs +1 -0
- package/dist/{template-catalog-j2B1MJlL.js → template-catalog-wT1fNeAP.js} +10 -10
- package/dist/{template-fragments-DcKeiylI.cjs → template-fragments-BajTajb4.cjs} +1 -1
- package/dist/{template-fragments-BGbQLGlV.js → template-fragments-DmX5XK4N.js} +2 -2
- package/dist/template-registry-CpysHAxy.cjs +1 -0
- package/dist/{template-registry-BtaKPELV.js → template-registry-u11fPd8D.js} +389 -321
- package/dist/{textwrap-DE1kgcJB.js → textwrap-BEIg2w8y.js} +1 -1
- package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
- package/dist/{tree-BX380Rr7.cjs → tree-CLpxYbKa.cjs} +1 -1
- package/dist/{tree-CjVZLRw7.js → tree-DNJorJUf.js} +1 -1
- package/dist/vue/async.d.cts +174 -2
- package/dist/vue/async.d.ts +174 -2
- package/dist/vue/index.d.cts +218 -3
- package/dist/vue/index.d.ts +218 -3
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +7 -7
- package/dist/{workbook-session-BvToI-Fd.js → workbook-session-B8pNW24X.js} +153 -140
- package/dist/{workbook-session-Bjv1YCRK.cjs → workbook-session-DN5LSA5C.cjs} +12 -12
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +84 -1
- package/dist/worker.d.ts +84 -1
- package/dist/worker.js +12 -157
- package/dist/xlsx-node.cjs +33 -33
- package/dist/xlsx-node.js +1282 -1289
- package/dist/xlsx.cjs +4 -3
- package/dist/xlsx.d.cts +90 -2
- package/dist/xlsx.d.ts +90 -2
- package/dist/xlsx.js +279 -259
- package/package.json +6 -3
- package/dist/ReportPreview-ChV19HBp.js +0 -4619
- package/dist/ReportPreview-DbLvvOUT.cjs +0 -6
- package/dist/RuleEditor-C_Clasvd.js +0 -2037
- package/dist/RuleEditor-XhGHK8DE.cjs +0 -1
- package/dist/assets-B9ImAi6_.cjs +0 -1
- package/dist/assets-DEaz4qsp.js +0 -124
- package/dist/batch-BaP6pWDE.cjs +0 -1
- package/dist/batch-CGyt-b2W.js +0 -273
- package/dist/capabilities-CAh2Nrue.cjs +0 -1
- package/dist/capabilities-DskCHs3V.js +0 -69
- package/dist/computed-C-4C2S5h.js +0 -521
- package/dist/computed-CGV2a809.cjs +0 -1
- package/dist/config-D10us76d.cjs +0 -1
- package/dist/data-explanation-B8MZRYVS.js +0 -16
- package/dist/data-explanation-DE55G30w.cjs +0 -1
- package/dist/dataset-BkRmwgeJ.cjs +0 -1
- package/dist/dataset-H5pFuQGU.js +0 -121
- package/dist/defaults-DXhiM1ZD.js +0 -10
- package/dist/defaults-xhmcLLrf.cjs +0 -1
- package/dist/designer-2bDlcNXQ.js +0 -5136
- package/dist/designer-BT7XCdbW.cjs +0 -2
- package/dist/drill-DYTxuL3A.cjs +0 -1
- package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
- package/dist/grid-strokes-DyyG1q_o.js +0 -53
- package/dist/json-snapshot-DFb2eWkf.js +0 -1416
- package/dist/json-snapshot-WWSGlaHG.cjs +0 -2
- package/dist/matrix-CGRGkn5s.js +0 -112
- package/dist/matrix-gEO7ZM_u.cjs +0 -1
- package/dist/prepared-CFy9B75C.cjs +0 -1
- package/dist/prepared-ajM-H-9B.js +0 -69
- package/dist/record-bindings-By_UKZ2g.cjs +0 -1
- package/dist/render-plan-7xpGrCEl.cjs +0 -1
- package/dist/render-plan-Ck6koX9L.js +0 -13
- package/dist/sha256-ArEYjaTI.cjs +0 -1
- package/dist/sha256-DPEuJ3nh.js +0 -155
- package/dist/style-CQ1PK8ZB.js +0 -67
- package/dist/style-UgIJSA1F.cjs +0 -1
- package/dist/template-catalog-FJE_c9Qe.cjs +0 -1
- package/dist/template-registry-Co1zPq5e.cjs +0 -1
- package/dist/textwrap-CWHyzkBH.cjs +0 -4
package/dist/server.js
CHANGED
|
@@ -1,863 +1,709 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { R
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
function V(e = []) {
|
|
16
|
-
return e.map(({ code: t, message: r, severity: s, pageIndex: n, componentIndex: a }) => ({ code: t, message: r, severity: s, path: a < 0 ? `$.pages.${n}` : `$.pages.${n}.components.${a}` }));
|
|
17
|
-
}
|
|
18
|
-
async function ne(e, t, r = Date.now()) {
|
|
19
|
-
const s = e.prepared, n = e.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
|
|
20
|
-
h(e.signal);
|
|
21
|
-
const a = e.pdf?.customFontFaces ?? (e.pdf?.customFontBytes ? { regular: e.pdf.customFontBytes } : void 0), o = n && a ? n.createFontBytesMeasurer(a) : void 0, d = C(e), c = await d.run("encode", async () => {
|
|
22
|
-
let f;
|
|
23
|
-
if (e.format === "pdf") {
|
|
24
|
-
h(e.signal);
|
|
25
|
-
const u = await n.renderPlanToPdf(s.plan, { ...e.pdf, ...o ? { measurer: o } : {}, fidelity: e.fidelity, signal: e.signal, onProgress: (w, p) => d.progress("encode", w, p) });
|
|
26
|
-
f = u.bytes, s.diagnostics.push(...V(u.diagnostics)), s.diagnostics.push(...u.fidelityWarnings.map((w) => ({ code: "pdf-fidelity", message: w, severity: "warning" })), ...u.pageErrors.map((w) => ({ code: "pdf-page", message: w, severity: "error" }))), u.unsupportedTextCount && s.diagnostics.push({ code: "pdf-font", message: `${u.unsupportedTextCount} 段文本包含当前字体不支持的字符`, severity: "warning" });
|
|
27
|
-
} else {
|
|
28
|
-
const { renderPlanToXlsx: u } = await import("@agile-team/mach-report/xlsx");
|
|
29
|
-
h(e.signal);
|
|
30
|
-
const w = await u(s.plan, { ...e.xlsx, fidelity: e.fidelity, signal: e.signal, onProgress: (p, b) => d.progress("encode", p, b) });
|
|
31
|
-
f = new Uint8Array(w.buffer), s.diagnostics.push(...V(w.diagnostics)), s.diagnostics.push(...w.warnings.map((p) => ({ code: "xlsx-fidelity", message: p, severity: "warning" })));
|
|
32
|
-
}
|
|
33
|
-
return h(e.signal), f;
|
|
34
|
-
});
|
|
35
|
-
I(t, "maxOutputBytes", c.byteLength);
|
|
36
|
-
const { plan: i, ...l } = s;
|
|
37
|
-
return { ...l, bytes: c, format: e.format, contentType: e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", stats: { ...l.stats, durationMs: Date.now() - r, outputBytes: c.byteLength } };
|
|
38
|
-
}
|
|
39
|
-
function ae(e) {
|
|
40
|
-
return { ...e, reportIds: [...e.reportIds], ...e.params ? { params: { ...e.params } } : {} };
|
|
41
|
-
}
|
|
42
|
-
function Se(e, t) {
|
|
43
|
-
if (t.length === 0) throw new B("config", "缺少报表 ID");
|
|
44
|
-
return t.map((r) => {
|
|
45
|
-
if (!Object.prototype.hasOwnProperty.call(e, r)) throw new B("config", `未注册报表 ${r}`);
|
|
46
|
-
return e[r];
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function K(e) {
|
|
50
|
-
return e.grid?.cells.reduce((t, r) => t + r.reduce((s, n) => s + (n ? 1 + (n.children?.reduce((a, o) => a + K(o), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
51
|
-
}
|
|
52
|
-
function We(e, t, r) {
|
|
53
|
-
return e.pages.reduce((s, n) => s + n.components.reduce((a, o) => o.kind !== "list" ? a + K(o) : a + De(o, t, r), 0), 0);
|
|
54
|
-
}
|
|
55
|
-
function Ye(e, t = Object.keys(e)) {
|
|
56
|
-
return Se(e, t).map((r, s) => {
|
|
57
|
-
const n = t[s], a = Q(e, [n]);
|
|
58
|
-
return {
|
|
59
|
-
id: n,
|
|
60
|
-
params: JSON.parse(JSON.stringify(a)),
|
|
61
|
-
paramsSchema: Me(a),
|
|
62
|
-
datasetsSchema: Object.fromEntries(Object.entries(r.dataSchema ?? {}).map(([o, d]) => [o, Ae(typeof r.template == "function" ? void 0 : r.template, o, d)])),
|
|
63
|
-
capabilities: {
|
|
64
|
-
save: !!r.provider?.save,
|
|
65
|
-
export: !!r.provider?.export,
|
|
66
|
-
templates: !!r.provider?.templates
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function ke(e, t) {
|
|
72
|
-
Se(e, t.reportIds);
|
|
73
|
-
const r = Z(Q(e, t.reportIds), t.params), s = t.reportIds.flatMap((a) => Z(Q(e, [a]), t.params).issues), n = new Map(s.map((a) => [JSON.stringify(a), a]));
|
|
74
|
-
return { ...r, ok: n.size === 0, issues: [...n.values()] };
|
|
75
|
-
}
|
|
76
|
-
function oe(e, t) {
|
|
77
|
-
const r = be(e.plan);
|
|
78
|
-
if (!r.ok) throw new B("validate", `执行器返回无效计划:${r.errors[0]?.path}`);
|
|
79
|
-
const s = e.plan.pages.length, n = e.plan.pages.reduce((a, o) => a + o.components.reduce((d, c) => d + K(c), 0), 0);
|
|
80
|
-
return I(t, "maxRows", e.stats.rows), I(t, "maxPages", s), I(t, "maxCells", n), { ...e, stats: { ...e.stats, pages: s, cells: n } };
|
|
81
|
-
}
|
|
82
|
-
function ie(e, t) {
|
|
83
|
-
const r = ke(e.reports, t);
|
|
84
|
-
if (!r.ok) throw new he(r.issues);
|
|
85
|
-
}
|
|
86
|
-
function re(e) {
|
|
87
|
-
const t = { maxRows: 1e5, maxPages: 1e4, maxCells: 2e6, maxOutputBytes: 1e8, maxPreparedBytes: 64e6, maxDurationMs: 12e4, ...e.budget };
|
|
88
|
-
Fe(t);
|
|
89
|
-
const r = async (n, a) => {
|
|
90
|
-
const o = Date.now();
|
|
91
|
-
let d = 0, c = 0;
|
|
92
|
-
const i = [], l = {}, f = [], u = Object.fromEntries(Object.entries(e.reports).map(([x, v]) => [x, {
|
|
93
|
-
...v,
|
|
94
|
-
pagination: { ...e.pagination, ...v.pagination, ...a ? { measurer: a } : {} },
|
|
95
|
-
dataValidation: {
|
|
96
|
-
...v.dataValidation,
|
|
97
|
-
maxRows: Math.min(t.maxRows ?? 1e5, v.dataValidation?.maxRows ?? 1 / 0),
|
|
98
|
-
maxCells: Math.min(t.maxCells ?? 2e6, v.dataValidation?.maxCells ?? 1 / 0)
|
|
99
|
-
}
|
|
100
|
-
}])), p = await je(u, { maxPages: t.maxPages, maxCells: t.maxCells, onDatasets: (x, v, E) => {
|
|
101
|
-
try {
|
|
102
|
-
d += Ne(E, v, { maxRows: t.maxRows, signal: n.signal });
|
|
103
|
-
} catch (A) {
|
|
104
|
-
throw A instanceof qe ? new T("budget", A.message, "$.budget.maxRows") : A;
|
|
105
|
-
}
|
|
106
|
-
I(t, "maxRows", d), c += We(E, v, u[x]?.pagination), I(t, "maxCells", c);
|
|
107
|
-
} })({ ...n, params: n.params ?? {}, onWarning: (x) => i.push({ code: "layout", message: x, severity: "warning" }), onQueryResult: (x, v, E = 0) => {
|
|
108
|
-
const A = $e(E, x);
|
|
109
|
-
Object.defineProperty(l, x, { value: { revision: v.revision, sourceToken: v.sourceToken }, enumerable: !0, writable: !0 }), f.push({ reportId: x, reportIndex: E, reportScope: A, ...v.revision === void 0 ? {} : { revision: v.revision }, ...v.sourceToken === void 0 ? {} : { sourceToken: v.sourceToken } }), i.push(...(v.diagnostics ?? []).map((P) => ({ ...P, ...P.target ? { target: {
|
|
110
|
-
...P.target,
|
|
111
|
-
reportScope: A,
|
|
112
|
-
...P.target.tableId ? { tableId: JSON.stringify([E, x, P.target.tableId]) } : {}
|
|
113
|
-
} } : {} })));
|
|
114
|
-
} }).catch((x) => {
|
|
115
|
-
throw x instanceof B && x.cause instanceof Be ? new T("budget", x.cause.message, "$.budget.maxPages") : x instanceof B && x.cause instanceof Je ? new T("budget", x.cause.message, "$.budget.maxCells") : x;
|
|
116
|
-
});
|
|
117
|
-
h(n.signal);
|
|
118
|
-
const b = e.assets ? await C(n).run("assets", () => se(p, { ...e.assets, signal: n.signal })) : { plan: p, diagnostics: [] }, m = b.plan;
|
|
119
|
-
i.push(...V(b.diagnostics));
|
|
120
|
-
const g = m.pages.reduce((x, v) => x + v.components.reduce((E, A) => E + K(A), 0), 0);
|
|
121
|
-
I(t, "maxPages", m.pages.length), I(t, "maxCells", g);
|
|
122
|
-
const k = He(n.pdf), D = e.pagination?.measurer || Object.values(e.reports).some((x) => x.pagination?.measurer);
|
|
123
|
-
return { plan: m, diagnostics: i, revisions: l, sources: f, layout: { textMetrics: k ? "font-bytes" : D ? "provided" : "heuristic", ...k ? { fontFingerprint: k } : {} }, stats: { rows: d, pages: m.pages.length, cells: g, durationMs: Date.now() - o } };
|
|
124
|
-
}, s = async (n) => {
|
|
125
|
-
const a = Date.now();
|
|
126
|
-
if (n.format !== "pdf" && n.format !== "xlsx") throw new B("config", "不支持的报表导出格式");
|
|
127
|
-
const o = n.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
|
|
128
|
-
h(n.signal);
|
|
129
|
-
const d = n.pdf?.customFontFaces ?? (n.pdf?.customFontBytes ? { regular: n.pdf.customFontBytes } : void 0), c = o && d ? o.createFontBytesMeasurer(d) : void 0, i = await r(n, c);
|
|
130
|
-
return h(n.signal), ne({ ...n, prepared: i }, t, a);
|
|
131
|
-
};
|
|
132
|
-
return {
|
|
133
|
-
describe: (n) => Ye(e.reports, n),
|
|
134
|
-
validate: (n) => ke(e.reports, n),
|
|
135
|
-
prepare: (n) => $(n.signal, t.maxDurationMs, async (a) => {
|
|
136
|
-
const { signal: o, onEvent: d, ...c } = ae(n), i = { ...c, ...c.pdf ? { pdf: F(c.pdf) } : {}, taskId: c.taskId ?? G() }, l = d ? (b) => _(d, b, a) : void 0, f = { ...i, signal: a, onEvent: l };
|
|
137
|
-
C(f).runSync("validate", () => ie(e, i));
|
|
138
|
-
let u;
|
|
139
|
-
const w = i.pdf?.customFontFaces ?? (i.pdf?.customFontBytes ? { regular: i.pdf.customFontBytes } : void 0);
|
|
140
|
-
if (!e.executor && w) {
|
|
141
|
-
const b = await import("@agile-team/mach-report/pdf");
|
|
142
|
-
h(a), u = b.createFontBytesMeasurer(w);
|
|
143
|
-
}
|
|
144
|
-
const p = e.executor ? await e.executor.prepare(i, a, l) : await r(f, u);
|
|
145
|
-
return oe(p, t);
|
|
146
|
-
}),
|
|
147
|
-
exportPrepared: (n) => $(n.signal, t.maxDurationMs, async (a) => {
|
|
148
|
-
const o = Date.now(), { signal: d, onEvent: c, ...i } = n, l = oe(_e(n.prepared, t.maxPreparedBytes ?? 64e6, a), t), f = { ...i, xlsx: W(i.xlsx), prepared: l, ...i.pdf ? { pdf: F(i.pdf) } : {}, taskId: i.taskId ?? G() };
|
|
149
|
-
if (f.format !== "pdf" && f.format !== "xlsx") throw new B("config", "不支持的报表导出格式");
|
|
150
|
-
const u = c ? (p) => _(c, p, a) : void 0;
|
|
151
|
-
if (e.executor) {
|
|
152
|
-
if (!e.executor.exportPrepared) throw new B("config", "执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");
|
|
153
|
-
const p = await e.executor.exportPrepared(f, a, u);
|
|
154
|
-
return I(t, "maxRows", p.stats.rows), I(t, "maxPages", p.stats.pages), I(t, "maxCells", p.stats.cells), I(t, "maxOutputBytes", p.bytes.byteLength), { ...p, stats: { ...p.stats, outputBytes: p.bytes.byteLength } };
|
|
155
|
-
}
|
|
156
|
-
const w = { ...f, signal: a, onEvent: u };
|
|
157
|
-
if (C(w).runSync("validate", () => Ve(w)), e.assets) {
|
|
158
|
-
const p = await C(w).run("assets", () => se(l.plan, { ...e.assets, signal: a }));
|
|
159
|
-
l.plan = p.plan, l.diagnostics.push(...V(p.diagnostics));
|
|
160
|
-
}
|
|
161
|
-
return ne(w, t, o);
|
|
162
|
-
}),
|
|
163
|
-
export: (n) => $(n.signal, t.maxDurationMs, async (a) => {
|
|
164
|
-
const { signal: o, onEvent: d, ...c } = ae(n), i = { ...c, xlsx: W(c.xlsx), ...c.pdf ? { pdf: F(c.pdf) } : {}, taskId: c.taskId ?? G() }, l = d ? (w) => _(d, w, a) : void 0, f = { ...i, signal: a, onEvent: l };
|
|
165
|
-
if (C(f).runSync("validate", () => ie(e, i)), i.format !== "pdf" && i.format !== "xlsx") throw new B("config", "不支持的报表导出格式");
|
|
166
|
-
const u = e.executor ? await e.executor.export(i, a, l) : await s(f);
|
|
167
|
-
return I(t, "maxRows", u.stats.rows), I(t, "maxPages", u.stats.pages), I(t, "maxCells", u.stats.cells), I(t, "maxOutputBytes", u.bytes.byteLength), { ...u, stats: { ...u.stats, outputBytes: u.bytes.byteLength } };
|
|
168
|
-
})
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function tr(e = {}) {
|
|
1
|
+
import { c as W } from "./runtime-DakRXui3.js";
|
|
2
|
+
import { R as A, t as h, c as T, p as Re } from "./sha256-DTG-Gq8i.js";
|
|
3
|
+
import { F as Se, s as Y, G as Ie } from "./json-snapshot-DYmEe3sO.js";
|
|
4
|
+
import { R, c as X, s as P, a as H, j as Ee, b as ke, r as Oe } from "./batch-WzDIXJAt.js";
|
|
5
|
+
import { d as rr, e as nr, f as sr, v as ar, g as or } from "./batch-WzDIXJAt.js";
|
|
6
|
+
import { r as Ae, a as Pe } from "./template-catalog-wT1fNeAP.js";
|
|
7
|
+
import { p as $, b as le, v as je } from "./template-registry-u11fPd8D.js";
|
|
8
|
+
import { v as pe, s as ee, a as Te } from "./prepared-CARicKYh.js";
|
|
9
|
+
import { R as Ne, d as Be } from "./param-validation-Do7Eg8Zv.js";
|
|
10
|
+
import { g as we } from "./record-bindings-D4TuMzHs.js";
|
|
11
|
+
import { v as ye } from "./dataset-DL83majE.js";
|
|
12
|
+
import { c as me } from "./media-Y90dHK9z.js";
|
|
13
|
+
import { R as $e } from "./component-tree-Ca6YYfHq.js";
|
|
14
|
+
function zt(e = {}) {
|
|
172
15
|
const t = e.concurrency ?? 1, r = e.maxQueued ?? 20;
|
|
173
|
-
if (!Number.isSafeInteger(t) || t < 1 || !Number.isSafeInteger(r) || r < 0) throw new
|
|
174
|
-
const
|
|
175
|
-
let o = !1,
|
|
176
|
-
const
|
|
177
|
-
for (; !o &&
|
|
16
|
+
if (!Number.isSafeInteger(t) || t < 1 || !Number.isSafeInteger(r) || r < 0) throw new A("budget", "队列并发应为正整数,排队上限应为非负整数");
|
|
17
|
+
const n = [], s = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
18
|
+
let o = !1, u = 0;
|
|
19
|
+
const f = () => {
|
|
20
|
+
for (; !o && s.size < t && n.length; ) n.shift().start();
|
|
178
21
|
};
|
|
179
22
|
return {
|
|
180
23
|
get active() {
|
|
181
|
-
return
|
|
24
|
+
return s.size;
|
|
182
25
|
},
|
|
183
26
|
get pending() {
|
|
184
|
-
return
|
|
27
|
+
return n.length;
|
|
185
28
|
},
|
|
186
|
-
enqueue: (
|
|
187
|
-
if (o) throw new
|
|
188
|
-
if (h(
|
|
189
|
-
const
|
|
190
|
-
if (a.has(
|
|
191
|
-
const
|
|
192
|
-
let
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
}),
|
|
196
|
-
|
|
197
|
-
},
|
|
198
|
-
if (
|
|
199
|
-
const
|
|
200
|
-
|
|
29
|
+
enqueue: (i, d = {}) => {
|
|
30
|
+
if (o) throw new A("closed", "任务队列已关闭");
|
|
31
|
+
if (h(d.signal), s.size >= t && n.length >= r) throw new A("queue-full", "报表任务队列已满");
|
|
32
|
+
const l = d.id ?? `report-${++u}`;
|
|
33
|
+
if (a.has(l)) throw new A("queue-full", "任务 ID 正在执行或排队");
|
|
34
|
+
const p = new AbortController();
|
|
35
|
+
let w = "queued", g, y, m, v;
|
|
36
|
+
const N = new Promise((S, k) => {
|
|
37
|
+
m = S, v = k;
|
|
38
|
+
}), M = () => {
|
|
39
|
+
d.signal?.removeEventListener("abort", C), a.delete(l);
|
|
40
|
+
}, E = (S) => {
|
|
41
|
+
if (w !== "queued" && w !== "running") return;
|
|
42
|
+
const k = w === "queued";
|
|
43
|
+
w = "cancelled", p.abort(S);
|
|
201
44
|
try {
|
|
202
|
-
h(
|
|
45
|
+
h(p.signal);
|
|
203
46
|
} catch (z) {
|
|
204
|
-
|
|
47
|
+
v(z);
|
|
205
48
|
}
|
|
206
|
-
if (
|
|
207
|
-
const z =
|
|
208
|
-
z >= 0 &&
|
|
49
|
+
if (k) {
|
|
50
|
+
const z = n.indexOf(I);
|
|
51
|
+
z >= 0 && n.splice(z, 1), M(), f();
|
|
209
52
|
}
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
},
|
|
215
|
-
cancel:
|
|
53
|
+
}, C = () => E(d.signal?.reason), Z = (S, k) => {
|
|
54
|
+
w === "running" && (!Number.isFinite(S) || S < 0 || k !== void 0 && (!Number.isFinite(k) || k < S) || (g = { completed: S, ...k === void 0 ? {} : { total: k } }));
|
|
55
|
+
}, B = (S) => {
|
|
56
|
+
w !== "running" || p.signal.aborted || (y = { ...S, taskId: l }, S.completed !== void 0 && Z(S.completed, S.total), Se(d.onEvent, y, p.signal));
|
|
57
|
+
}, I = {
|
|
58
|
+
cancel: E,
|
|
216
59
|
start: () => {
|
|
217
|
-
|
|
60
|
+
w === "queued" && (w = "running", s.add(I), Promise.resolve().then(() => (h(p.signal), i({ taskId: l, signal: p.signal, reportProgress: Z, onEvent: B }))).then(
|
|
218
61
|
(S) => {
|
|
219
|
-
|
|
62
|
+
w === "running" && (w = "completed", m(S));
|
|
220
63
|
},
|
|
221
64
|
(S) => {
|
|
222
|
-
|
|
65
|
+
w === "running" && (w = "failed", v(S));
|
|
223
66
|
}
|
|
224
67
|
).finally(() => {
|
|
225
|
-
|
|
68
|
+
s.delete(I), M(), f();
|
|
226
69
|
}));
|
|
227
70
|
}
|
|
228
71
|
};
|
|
229
|
-
return a.add(
|
|
230
|
-
return
|
|
72
|
+
return a.add(l), d.signal?.addEventListener("abort", C, { once: !0 }), d.signal?.aborted ? E(d.signal.reason) : s.size < t ? I.start() : n.push(I), { id: l, get status() {
|
|
73
|
+
return w;
|
|
231
74
|
}, get progress() {
|
|
232
|
-
return
|
|
75
|
+
return g;
|
|
233
76
|
}, get event() {
|
|
234
|
-
return
|
|
235
|
-
}, result:
|
|
77
|
+
return y;
|
|
78
|
+
}, result: N, cancel: E };
|
|
236
79
|
},
|
|
237
|
-
close: (
|
|
80
|
+
close: (i = {}) => {
|
|
238
81
|
o = !0;
|
|
239
|
-
for (const
|
|
240
|
-
if (
|
|
82
|
+
for (const d of [...n]) d.cancel(new A("closed", "任务队列已关闭"));
|
|
83
|
+
if (i.cancelRunning) for (const d of s) d.cancel(new A("closed", "任务队列已关闭"));
|
|
241
84
|
}
|
|
242
85
|
};
|
|
243
86
|
}
|
|
244
|
-
function
|
|
87
|
+
function Me(e) {
|
|
245
88
|
let t, r;
|
|
246
|
-
const
|
|
247
|
-
t =
|
|
89
|
+
const n = new Promise((s, a) => {
|
|
90
|
+
t = s, r = a;
|
|
248
91
|
});
|
|
249
|
-
return
|
|
250
|
-
}), { progress: e, promise:
|
|
92
|
+
return n.catch(() => {
|
|
93
|
+
}), { progress: e, promise: n, resolve: t, reject: r };
|
|
251
94
|
}
|
|
252
|
-
function
|
|
95
|
+
function te(e) {
|
|
253
96
|
const t = Promise.reject(e);
|
|
254
97
|
return t.catch(() => {
|
|
255
98
|
}), t;
|
|
256
99
|
}
|
|
257
|
-
function
|
|
258
|
-
let r,
|
|
259
|
-
function o(
|
|
260
|
-
a ??=
|
|
100
|
+
function De(e, t) {
|
|
101
|
+
let r, n, s = !0, a;
|
|
102
|
+
function o(c) {
|
|
103
|
+
a ??= c ?? new Error("任务心跳更新失败"), n?.reject(a), n = void 0, t(a);
|
|
261
104
|
}
|
|
262
|
-
function
|
|
263
|
-
const
|
|
264
|
-
() =>
|
|
265
|
-
(
|
|
266
|
-
|
|
105
|
+
function u(c) {
|
|
106
|
+
const i = Promise.resolve().then(() => e(c?.progress)).then(
|
|
107
|
+
() => c?.resolve(),
|
|
108
|
+
(d) => {
|
|
109
|
+
c?.reject(d), o(d);
|
|
267
110
|
}
|
|
268
111
|
).finally(() => {
|
|
269
112
|
r = void 0;
|
|
270
|
-
const
|
|
271
|
-
|
|
113
|
+
const d = n;
|
|
114
|
+
n = void 0, d && a === void 0 && u(d);
|
|
272
115
|
});
|
|
273
|
-
r =
|
|
274
|
-
o(
|
|
116
|
+
r = i, i.catch((d) => {
|
|
117
|
+
o(d);
|
|
275
118
|
});
|
|
276
119
|
}
|
|
277
|
-
function c
|
|
278
|
-
if (!
|
|
279
|
-
return
|
|
120
|
+
function f(c) {
|
|
121
|
+
if (!s)
|
|
122
|
+
return te(
|
|
280
123
|
new R("closed", "任务进度上报已结束")
|
|
281
124
|
);
|
|
282
|
-
if (a !== void 0) return
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
return r || (
|
|
125
|
+
if (a !== void 0) return te(a);
|
|
126
|
+
n ? n.progress = c : n = Me(c);
|
|
127
|
+
const i = n;
|
|
128
|
+
return r || (n = void 0, u(i)), i.promise;
|
|
286
129
|
}
|
|
287
130
|
return {
|
|
288
|
-
progress:
|
|
131
|
+
progress: f,
|
|
289
132
|
pulse() {
|
|
290
|
-
|
|
133
|
+
s && !r && a === void 0 && u();
|
|
291
134
|
},
|
|
292
135
|
async finish() {
|
|
293
|
-
for (
|
|
136
|
+
for (s = !1; r; ) await r;
|
|
294
137
|
if (a !== void 0) throw a;
|
|
295
138
|
}
|
|
296
139
|
};
|
|
297
140
|
}
|
|
298
|
-
class
|
|
141
|
+
class re extends R {
|
|
299
142
|
constructor() {
|
|
300
143
|
super("capacity", "任务结果超过独立预算,请保存文件引用");
|
|
301
144
|
}
|
|
302
145
|
}
|
|
303
|
-
function
|
|
304
|
-
const t = e.concurrency ?? 1, r = e.leaseMs ?? 3e4,
|
|
305
|
-
if (![t, r,
|
|
146
|
+
function Je(e) {
|
|
147
|
+
const t = e.concurrency ?? 1, r = e.leaseMs ?? 3e4, n = e.heartbeatMs ?? 1e4, s = e.maxResultBytes ?? 256 * 1024;
|
|
148
|
+
if (![t, r, n, s].every(
|
|
306
149
|
(o) => Number.isSafeInteger(o) && o > 0
|
|
307
|
-
) ||
|
|
150
|
+
) || n * 2 > r)
|
|
308
151
|
throw new R(
|
|
309
152
|
"input",
|
|
310
153
|
"并发、租约、心跳应为正整数,租约至少为心跳的两倍"
|
|
311
154
|
);
|
|
312
|
-
if (
|
|
155
|
+
if (n > 2147483647)
|
|
313
156
|
throw new R(
|
|
314
157
|
"input",
|
|
315
158
|
"心跳间隔超过平台定时器上限(2147483647毫秒)"
|
|
316
159
|
);
|
|
317
|
-
return { concurrency: t, leaseMs: r, heartbeatMs:
|
|
160
|
+
return { concurrency: t, leaseMs: r, heartbeatMs: n, maxResultBytes: s, now: () => {
|
|
318
161
|
const o = (e.now ?? Date.now)();
|
|
319
162
|
if (!Number.isSafeInteger(o) || o < 0)
|
|
320
163
|
throw new R("input", "任务时钟应返回非负整数毫秒");
|
|
321
164
|
return o;
|
|
322
165
|
} };
|
|
323
166
|
}
|
|
324
|
-
async function
|
|
325
|
-
|
|
326
|
-
const
|
|
327
|
-
if (!
|
|
328
|
-
return
|
|
167
|
+
async function F(e, t, r) {
|
|
168
|
+
X(t, r);
|
|
169
|
+
const n = await e.read(t, r);
|
|
170
|
+
if (!n) throw new R("missing", "报表任务不存在");
|
|
171
|
+
return n;
|
|
329
172
|
}
|
|
330
|
-
async function
|
|
331
|
-
const
|
|
332
|
-
for (const a of
|
|
173
|
+
async function q(e, t, r, n = []) {
|
|
174
|
+
const s = { ...t, ...r, revision: t.revision + 1 };
|
|
175
|
+
for (const a of n) delete s[a];
|
|
333
176
|
if (!await e.compareAndSwap(
|
|
334
177
|
t.scope,
|
|
335
178
|
t.id,
|
|
336
179
|
t.revision,
|
|
337
|
-
|
|
180
|
+
s
|
|
338
181
|
))
|
|
339
182
|
throw new R("conflict", "报表任务已被其他请求更新");
|
|
340
|
-
return
|
|
183
|
+
return H(s);
|
|
341
184
|
}
|
|
342
|
-
async function
|
|
185
|
+
async function Ce(e, t, r, n) {
|
|
343
186
|
if (!t.trim() || t.length > 128)
|
|
344
187
|
throw new R("input", "workerId应为1–128位标识");
|
|
345
|
-
for (const
|
|
346
|
-
const a =
|
|
347
|
-
...
|
|
348
|
-
revision:
|
|
188
|
+
for (const s of await e.store.candidates(n, 100)) {
|
|
189
|
+
const a = s.cancelRequested ? {
|
|
190
|
+
...s,
|
|
191
|
+
revision: s.revision + 1,
|
|
349
192
|
status: "cancelled",
|
|
350
|
-
updatedAt:
|
|
193
|
+
updatedAt: n
|
|
351
194
|
} : {
|
|
352
|
-
...
|
|
353
|
-
revision:
|
|
195
|
+
...s,
|
|
196
|
+
revision: s.revision + 1,
|
|
354
197
|
status: "running",
|
|
355
|
-
attempt:
|
|
356
|
-
updatedAt:
|
|
357
|
-
lease: { owner: t, expiresAt:
|
|
198
|
+
attempt: s.attempt + 1,
|
|
199
|
+
updatedAt: n,
|
|
200
|
+
lease: { owner: t, expiresAt: n + r }
|
|
358
201
|
};
|
|
359
202
|
if (a.status === "cancelled" && delete a.lease, await e.store.compareAndSwap(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
203
|
+
s.scope,
|
|
204
|
+
s.id,
|
|
205
|
+
s.revision,
|
|
363
206
|
a
|
|
364
207
|
))
|
|
365
208
|
return a;
|
|
366
209
|
}
|
|
367
210
|
}
|
|
368
|
-
function
|
|
369
|
-
return e.status === "running" && e.attempt ===
|
|
211
|
+
function ne(e, t, r, n) {
|
|
212
|
+
return e.status === "running" && e.attempt === n && e.lease?.owner === t && e.lease.expiresAt > r;
|
|
370
213
|
}
|
|
371
|
-
async function
|
|
372
|
-
const { scope:
|
|
373
|
-
let
|
|
374
|
-
const
|
|
375
|
-
async (
|
|
376
|
-
const
|
|
377
|
-
if (!
|
|
214
|
+
async function qe(e, t, r, n) {
|
|
215
|
+
const { scope: s, id: a } = r, o = r.lease.owner;
|
|
216
|
+
let u;
|
|
217
|
+
const f = De(
|
|
218
|
+
async (y) => {
|
|
219
|
+
const m = await F(e.store, s, a), v = t.now();
|
|
220
|
+
if (!ne(m, o, v, r.attempt))
|
|
378
221
|
throw new R("lease", "报表任务租约已失效");
|
|
379
|
-
if (
|
|
380
|
-
|
|
222
|
+
if (m.cancelRequested) {
|
|
223
|
+
n.abort(new R("closed", "任务已请求取消"));
|
|
381
224
|
return;
|
|
382
225
|
}
|
|
383
|
-
await
|
|
384
|
-
updatedAt:
|
|
385
|
-
lease: { owner: o, expiresAt:
|
|
386
|
-
...
|
|
226
|
+
await q(e.store, m, {
|
|
227
|
+
updatedAt: v,
|
|
228
|
+
lease: { owner: o, expiresAt: v + t.leaseMs },
|
|
229
|
+
...y ? { progress: y } : {}
|
|
387
230
|
});
|
|
388
231
|
},
|
|
389
|
-
(
|
|
390
|
-
|
|
232
|
+
(y) => {
|
|
233
|
+
u = y, n.abort(y);
|
|
391
234
|
}
|
|
392
|
-
),
|
|
393
|
-
completed:
|
|
394
|
-
...
|
|
395
|
-
}),
|
|
396
|
-
|
|
235
|
+
), c = (y, m) => !Number.isFinite(y) || y < 0 || m !== void 0 && (!Number.isFinite(m) || m < y) ? Promise.reject(new R("input", "任务进度无效")) : f.progress({
|
|
236
|
+
completed: y,
|
|
237
|
+
...m === void 0 ? {} : { total: m }
|
|
238
|
+
}), i = setInterval(() => {
|
|
239
|
+
f.pulse();
|
|
397
240
|
}, t.heartbeatMs);
|
|
398
|
-
let
|
|
241
|
+
let d, l;
|
|
399
242
|
try {
|
|
400
|
-
const
|
|
243
|
+
const y = Object.prototype.hasOwnProperty.call(
|
|
401
244
|
e.handlers,
|
|
402
245
|
r.request.kind
|
|
403
246
|
) ? e.handlers[r.request.kind] : void 0;
|
|
404
|
-
if (!
|
|
405
|
-
if (!
|
|
406
|
-
const
|
|
407
|
-
scope:
|
|
247
|
+
if (!y) throw new R("input", "报表任务处理器未注册");
|
|
248
|
+
if (!n.signal.aborted) {
|
|
249
|
+
const m = await y(H(r.request.payload), {
|
|
250
|
+
scope: s,
|
|
408
251
|
taskId: a,
|
|
409
252
|
attempt: r.attempt,
|
|
410
|
-
executionToken: JSON.stringify([
|
|
411
|
-
signal:
|
|
412
|
-
reportProgress:
|
|
253
|
+
executionToken: JSON.stringify([s, a, r.attempt]),
|
|
254
|
+
signal: n.signal,
|
|
255
|
+
reportProgress: c
|
|
413
256
|
});
|
|
414
|
-
if (
|
|
257
|
+
if (d = JSON.parse(P(m)), Ee(d) > t.maxResultBytes) throw new re();
|
|
415
258
|
}
|
|
416
|
-
} catch (
|
|
417
|
-
|
|
259
|
+
} catch (y) {
|
|
260
|
+
l = y ?? new Error("报表任务执行失败");
|
|
418
261
|
} finally {
|
|
419
|
-
clearInterval(
|
|
262
|
+
clearInterval(i), await f.finish().catch(() => {
|
|
420
263
|
});
|
|
421
264
|
}
|
|
422
|
-
const
|
|
423
|
-
if (!
|
|
265
|
+
const p = await F(e.store, s, a), w = t.now();
|
|
266
|
+
if (!ne(p, o, w, r.attempt))
|
|
424
267
|
throw new R("lease", "任务租约已失效,迟到结果不会写回");
|
|
425
|
-
const
|
|
426
|
-
delete
|
|
427
|
-
code:
|
|
428
|
-
message:
|
|
429
|
-
}) : (
|
|
268
|
+
const g = { ...p, updatedAt: w };
|
|
269
|
+
delete g.lease, l ??= u, p.cancelRequested || n.signal.aborted && u === void 0 ? g.status = "cancelled" : l !== void 0 ? (g.status = "failed", g.error = {
|
|
270
|
+
code: l instanceof re ? "result-budget" : l instanceof R ? l.code : "execution",
|
|
271
|
+
message: l instanceof Error ? l.message.slice(0, 500) : "报表任务执行失败"
|
|
272
|
+
}) : (g.status = "completed", g.result = d);
|
|
430
273
|
try {
|
|
431
|
-
|
|
274
|
+
P(g);
|
|
432
275
|
} catch {
|
|
433
|
-
delete
|
|
276
|
+
delete g.result, g.status = "failed", g.error = {
|
|
434
277
|
code: "result-budget",
|
|
435
278
|
message: "任务结果与请求的组合超过存储预算,请保存文件引用而非文件内容"
|
|
436
279
|
};
|
|
437
280
|
}
|
|
438
|
-
return
|
|
281
|
+
return ze(e.store, p, g);
|
|
439
282
|
}
|
|
440
|
-
async function
|
|
283
|
+
async function ze(e, t, r) {
|
|
441
284
|
try {
|
|
442
|
-
return await
|
|
443
|
-
} catch (
|
|
444
|
-
if (!(
|
|
445
|
-
return delete r.result, r.status = "failed", r.error = { code: "result-budget", message: "任务结果超过存储剩余预算,请保存文件引用而非文件内容" },
|
|
285
|
+
return await q(e, t, r, ["lease"]);
|
|
286
|
+
} catch (n) {
|
|
287
|
+
if (!(n instanceof R) || n.code !== "capacity" || r.status !== "completed") throw n;
|
|
288
|
+
return delete r.result, r.status = "failed", r.error = { code: "result-budget", message: "任务结果超过存储剩余预算,请保存文件引用而非文件内容" }, q(e, t, r, ["lease", "result"]);
|
|
446
289
|
}
|
|
447
290
|
}
|
|
448
|
-
async function
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
451
|
-
if (
|
|
452
|
-
return { scope: t, id: r, revision:
|
|
291
|
+
async function se(e, t, r, n) {
|
|
292
|
+
const s = await e.readTombstone?.(t, r);
|
|
293
|
+
if (s) {
|
|
294
|
+
if (s.requestHash !== await ke(n)) throw new R("conflict", "相同任务ID不能提交不同内容(幂等保留期内)");
|
|
295
|
+
return { scope: t, id: r, revision: s.revision, request: H(n), status: s.status, createdAt: s.createdAt, updatedAt: s.updatedAt, attempt: s.attempt, archived: !0 };
|
|
453
296
|
}
|
|
454
297
|
}
|
|
455
|
-
function
|
|
298
|
+
function _t(e) {
|
|
456
299
|
e = { ...e, handlers: { ...e.handlers } };
|
|
457
|
-
const t =
|
|
458
|
-
let
|
|
459
|
-
const o = (
|
|
300
|
+
const t = Je(e), r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
301
|
+
let s = !1, a = 0;
|
|
302
|
+
const o = (c, i) => (X(c, i), e.store.read(c, i));
|
|
460
303
|
return {
|
|
461
|
-
submit: async (
|
|
462
|
-
if (
|
|
304
|
+
submit: async (c) => {
|
|
305
|
+
if (c = { ...c }, X(c.scope, c.id), !Object.prototype.hasOwnProperty.call(e.handlers, c.kind) || typeof e.handlers[c.kind] != "function")
|
|
463
306
|
throw new R("input", "报表任务处理器未注册");
|
|
464
|
-
const
|
|
465
|
-
kind:
|
|
307
|
+
const i = {
|
|
308
|
+
kind: c.kind,
|
|
466
309
|
payload: JSON.parse(
|
|
467
|
-
|
|
310
|
+
P(c.payload, {
|
|
468
311
|
maxNodes: 19e3,
|
|
469
312
|
maxCharacters: 75e4
|
|
470
313
|
})
|
|
471
314
|
)
|
|
472
|
-
},
|
|
473
|
-
if (
|
|
474
|
-
if (
|
|
315
|
+
}, d = await o(c.scope, c.id);
|
|
316
|
+
if (d) {
|
|
317
|
+
if (P(d.request) !== P(i))
|
|
475
318
|
throw new R("conflict", "相同任务ID不能提交不同内容");
|
|
476
|
-
return
|
|
319
|
+
return d;
|
|
477
320
|
}
|
|
478
|
-
const
|
|
479
|
-
if (
|
|
480
|
-
const
|
|
481
|
-
scope:
|
|
482
|
-
id:
|
|
321
|
+
const l = await se(e.store, c.scope, c.id, i);
|
|
322
|
+
if (l) return l;
|
|
323
|
+
const p = t.now(), w = {
|
|
324
|
+
scope: c.scope,
|
|
325
|
+
id: c.id,
|
|
483
326
|
revision: 1,
|
|
484
|
-
request:
|
|
327
|
+
request: i,
|
|
485
328
|
status: "queued",
|
|
486
|
-
createdAt:
|
|
487
|
-
updatedAt:
|
|
329
|
+
createdAt: p,
|
|
330
|
+
updatedAt: p,
|
|
488
331
|
attempt: 0
|
|
489
332
|
};
|
|
490
|
-
if (!await e.store.compareAndSwap(
|
|
491
|
-
const
|
|
492
|
-
if (
|
|
493
|
-
return
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
333
|
+
if (!await e.store.compareAndSwap(c.scope, c.id, null, w)) {
|
|
334
|
+
const g = await o(c.scope, c.id);
|
|
335
|
+
if (g && P(g.request) === P(i))
|
|
336
|
+
return g;
|
|
337
|
+
const y = await se(e.store, c.scope, c.id, i);
|
|
338
|
+
if (y) return y;
|
|
496
339
|
throw new R("conflict", "报表任务提交发生冲突");
|
|
497
340
|
}
|
|
498
|
-
return
|
|
341
|
+
return H(w);
|
|
499
342
|
},
|
|
500
343
|
get: o,
|
|
501
|
-
runNext: (
|
|
502
|
-
if (
|
|
344
|
+
runNext: (c) => {
|
|
345
|
+
if (s)
|
|
503
346
|
return Promise.reject(new R("closed", "报表任务服务已关闭"));
|
|
504
347
|
if (a >= t.concurrency)
|
|
505
348
|
return Promise.reject(
|
|
506
349
|
new R("capacity", "报表任务执行槽位已满")
|
|
507
350
|
);
|
|
508
351
|
a++;
|
|
509
|
-
const
|
|
510
|
-
r.add(
|
|
511
|
-
const
|
|
352
|
+
const i = new AbortController();
|
|
353
|
+
r.add(i);
|
|
354
|
+
const d = (async () => {
|
|
512
355
|
try {
|
|
513
|
-
const
|
|
356
|
+
const l = await Ce(
|
|
514
357
|
e,
|
|
515
|
-
|
|
358
|
+
c,
|
|
516
359
|
t.leaseMs,
|
|
517
360
|
t.now()
|
|
518
361
|
);
|
|
519
|
-
return
|
|
362
|
+
return l?.status === "running" ? await qe(e, t, l, i) : l;
|
|
520
363
|
} finally {
|
|
521
|
-
a--, r.delete(
|
|
364
|
+
a--, r.delete(i);
|
|
522
365
|
}
|
|
523
366
|
})();
|
|
524
|
-
return
|
|
525
|
-
() =>
|
|
526
|
-
() =>
|
|
527
|
-
),
|
|
367
|
+
return n.add(d), d.then(
|
|
368
|
+
() => n.delete(d),
|
|
369
|
+
() => n.delete(d)
|
|
370
|
+
), d;
|
|
528
371
|
},
|
|
529
372
|
get active() {
|
|
530
373
|
return a;
|
|
531
374
|
},
|
|
532
|
-
cancel: async (
|
|
533
|
-
const
|
|
534
|
-
return
|
|
375
|
+
cancel: async (c, i) => {
|
|
376
|
+
const d = await F(e.store, c, i);
|
|
377
|
+
return d.status !== "queued" && d.status !== "running" ? d : q(e.store, d, {
|
|
535
378
|
updatedAt: t.now(),
|
|
536
|
-
...
|
|
379
|
+
...d.status === "queued" ? { status: "cancelled" } : { cancelRequested: !0 }
|
|
537
380
|
});
|
|
538
381
|
},
|
|
539
|
-
retry: async (
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
382
|
+
retry: async (c, i, d) => {
|
|
383
|
+
const l = await F(e.store, c, i);
|
|
384
|
+
if (l.revision !== d || l.status !== "failed")
|
|
542
385
|
throw new R("conflict", "仅可重试当前修订的失败任务");
|
|
543
|
-
const
|
|
544
|
-
...
|
|
386
|
+
const p = {
|
|
387
|
+
...l,
|
|
545
388
|
status: "queued",
|
|
546
389
|
updatedAt: t.now()
|
|
547
390
|
};
|
|
548
|
-
return delete
|
|
391
|
+
return delete p.error, delete p.progress, q(e.store, l, p, ["error", "progress"]);
|
|
549
392
|
},
|
|
550
|
-
prune: async (
|
|
393
|
+
prune: async (c) => {
|
|
551
394
|
if (!e.store.prune || !e.store.readTombstone) throw new R("input", "当前任务适配器未实现可选终态保留能力");
|
|
552
|
-
return e.store.prune({ ...
|
|
395
|
+
return e.store.prune({ ...c, now: t.now() });
|
|
553
396
|
},
|
|
554
397
|
close: async () => {
|
|
555
|
-
|
|
556
|
-
for (const
|
|
557
|
-
|
|
558
|
-
await Promise.allSettled([...
|
|
398
|
+
s = !0;
|
|
399
|
+
for (const c of r)
|
|
400
|
+
c.abort(new R("closed", "任务服务正在关闭"));
|
|
401
|
+
await Promise.allSettled([...n]);
|
|
559
402
|
}
|
|
560
403
|
};
|
|
561
404
|
}
|
|
562
|
-
function
|
|
563
|
-
const r = e.assets,
|
|
564
|
-
if (!(!r && !
|
|
405
|
+
function ge(e, t) {
|
|
406
|
+
const r = e.assets, n = e[t];
|
|
407
|
+
if (!(!r && !n?.assetRenderers && !n?.assetRegistry))
|
|
565
408
|
return {
|
|
566
409
|
...r,
|
|
567
|
-
...
|
|
568
|
-
...
|
|
569
|
-
|
|
570
|
-
|
|
410
|
+
...n?.assetFailure === void 0 ? {} : { assetFailure: n.assetFailure },
|
|
411
|
+
...n?.onDiagnostic === void 0 ? {} : { onDiagnostic: n.onDiagnostic },
|
|
412
|
+
assetRegistry: n?.assetRegistry ?? r?.assetRegistry,
|
|
413
|
+
assetRenderers: { ...r?.assetRenderers, ...n?.assetRenderers },
|
|
414
|
+
assetBudget: { ...r?.assetBudget, ...n?.assetBudget }
|
|
571
415
|
};
|
|
572
416
|
}
|
|
573
|
-
function
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
function
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
417
|
+
function ae(e, t) {
|
|
418
|
+
if (!e || e.code !== "missing-image" || e.format !== "pdf" && e.format !== "xlsx") return !1;
|
|
419
|
+
const r = ge(t, e.format);
|
|
420
|
+
return typeof r?.assetRenderers?.[e.kind] == "function" || !!(e.extension && r?.assetRegistry?.hasExtension(e.extension.id, e.extension.version, e.kind));
|
|
421
|
+
}
|
|
422
|
+
function _e(e, t) {
|
|
423
|
+
const r = Ae(e, t), n = r.issues.filter((a) => !ae(a.diagnostic, t)), s = r.samples.map((a) => ({ ...a, diagnostics: a.diagnostics.filter((o) => !ae(o, t)) }));
|
|
424
|
+
return { ...r, issues: n, samples: s, ok: n.every((a) => a.severity !== "error"), artifacts: [] };
|
|
425
|
+
}
|
|
426
|
+
async function Le(e, t, r, n, s) {
|
|
427
|
+
const a = W({ reports: { sample: { template: r, datasets: e.datasets } }, assets: ge(n, t), budget: {
|
|
428
|
+
maxRows: n.maxSampleRows ?? 1e3,
|
|
429
|
+
maxPages: n.maxPages ?? 100,
|
|
430
|
+
maxCells: n.maxCells ?? 25e4,
|
|
431
|
+
maxOutputBytes: n.maxOutputBytes ?? 2e7,
|
|
432
|
+
maxDurationMs: n.maxDurationMs ?? 3e4
|
|
587
433
|
} });
|
|
588
434
|
try {
|
|
589
|
-
const { result: o, digest:
|
|
590
|
-
const
|
|
591
|
-
if (
|
|
592
|
-
const
|
|
593
|
-
return h(
|
|
435
|
+
const { result: o, digest: u } = await T(n.signal, n.maxDurationMs ?? 3e4, async (f) => {
|
|
436
|
+
const c = await a.export({ reportIds: ["sample"], params: e.params, format: t, signal: f, fidelity: n.strictOutputs ? "strict" : "warn", pdf: n.pdf, xlsx: n.xlsx }), i = c.diagnostics.filter((l) => l.severity !== "info");
|
|
437
|
+
if (n.strictOutputs && i.length) throw new Error(`Strict ${t} encoding found fidelity issues: ${i.slice(0, 3).map((l) => l.message).join("; ")}`);
|
|
438
|
+
const d = await n.digest?.(c.bytes);
|
|
439
|
+
return h(f), await n.onArtifact?.(e.name, c), h(f), { result: c, digest: d };
|
|
594
440
|
});
|
|
595
|
-
|
|
441
|
+
s.artifacts.push({ fixture: e.name, format: t, bytes: o.bytes.byteLength, pages: o.stats.pages, ...u ? { digest: u } : {} }), s.issues.push(...o.diagnostics.map((f) => ({ code: "output", severity: n.strictOutputs || f.severity === "error" ? "error" : "warning", path: "$.template", fixture: e.name, message: `${t}: ${f.message}` })));
|
|
596
442
|
} catch (o) {
|
|
597
|
-
h(
|
|
443
|
+
h(n.signal), s.issues.push({ code: "output", severity: "error", path: "$.template", fixture: e.name, message: `${t}: ${o instanceof Error ? o.message : String(o)}` });
|
|
598
444
|
}
|
|
599
445
|
}
|
|
600
|
-
async function
|
|
446
|
+
async function Lt(e, t = {}) {
|
|
601
447
|
h(t.signal);
|
|
602
|
-
const r =
|
|
448
|
+
const r = _e(e, t);
|
|
603
449
|
if (!r.ok) return r;
|
|
604
|
-
const
|
|
605
|
-
if (!
|
|
450
|
+
const n = $(e).template, s = [...new Set(t.formats ?? ["pdf", "xlsx"])];
|
|
451
|
+
if (!s.length || s.some((a) => a !== "pdf" && a !== "xlsx"))
|
|
606
452
|
return r.issues.push({ code: "output", severity: "error", path: "$.formats", message: "真实文件验收应至少选择PDF/XLSX之一" }), r.ok = !1, r;
|
|
607
453
|
for (const a of t.fixtures ?? [])
|
|
608
|
-
for (const o of
|
|
609
|
-
h(t.signal), !(o !== "pdf" && o !== "xlsx") && await
|
|
454
|
+
for (const o of s)
|
|
455
|
+
h(t.signal), !(o !== "pdf" && o !== "xlsx") && await Le(a, o, n, t, r);
|
|
610
456
|
return r.ok = r.issues.every((a) => a.severity !== "error"), r;
|
|
611
457
|
}
|
|
612
|
-
class
|
|
458
|
+
class b extends Error {
|
|
613
459
|
constructor(t, r) {
|
|
614
460
|
super(r), this.code = t, this.name = "ReportInstanceError";
|
|
615
461
|
}
|
|
616
462
|
}
|
|
617
|
-
function
|
|
618
|
-
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
|
|
463
|
+
function J(e, t) {
|
|
464
|
+
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 b("input", "实例范围应非空,ID 应为安全标识");
|
|
619
465
|
}
|
|
620
|
-
function
|
|
466
|
+
function Fe(e, t) {
|
|
621
467
|
const r = Object.getPrototypeOf(e);
|
|
622
|
-
if (r !== (t ? Array.prototype : Object.prototype) && !(r === null && !t) || Object.getOwnPropertySymbols(e).length) throw new
|
|
623
|
-
if (t && Object.keys(e).some((
|
|
624
|
-
if (Object.getOwnPropertyNames(e).filter((
|
|
468
|
+
if (r !== (t ? Array.prototype : Object.prototype) && !(r === null && !t) || Object.getOwnPropertySymbols(e).length) throw new b("input", "实例应为普通 JSON 对象");
|
|
469
|
+
if (t && Object.keys(e).some((s) => s !== String(Number(s)) || !Number.isSafeInteger(Number(s)) || Number(s) < 0 || Number(s) >= e.length)) throw new b("input", "实例数组不能包含额外属性");
|
|
470
|
+
if (Object.getOwnPropertyNames(e).filter((s) => !(t && s === "length")).length !== Object.keys(e).length) throw new b("input", "实例不能包含不可枚举属性");
|
|
625
471
|
}
|
|
626
|
-
function
|
|
627
|
-
if (!Number.isSafeInteger(e.revision) || e.revision < 1 || typeof e.title != "string" || !e.title.trim() || e.title.length > 512) throw new
|
|
628
|
-
if (typeof e.generatedAt != "string" || !Number.isFinite(Date.parse(e.generatedAt)) || new Date(e.generatedAt).toISOString() !== e.generatedAt) throw new
|
|
629
|
-
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
|
|
472
|
+
function Ve(e) {
|
|
473
|
+
if (!Number.isSafeInteger(e.revision) || e.revision < 1 || typeof e.title != "string" || !e.title.trim() || e.title.length > 512) throw new b("input", "实例修订或标题无效");
|
|
474
|
+
if (typeof e.generatedAt != "string" || !Number.isFinite(Date.parse(e.generatedAt)) || new Date(e.generatedAt).toISOString() !== e.generatedAt) throw new b("input", "实例生成时间应为 ISO UTC 字符串");
|
|
475
|
+
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 b("input", "实例报表 ID 应非空且唯一");
|
|
630
476
|
}
|
|
631
|
-
function
|
|
477
|
+
function He(e) {
|
|
632
478
|
return e === null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" && Number.isFinite(e);
|
|
633
479
|
}
|
|
634
|
-
function
|
|
635
|
-
if (!Number.isSafeInteger(t) || t < 1) throw new
|
|
636
|
-
let r = 0,
|
|
637
|
-
const
|
|
638
|
-
function a(
|
|
639
|
-
if (++r > 1e6 ||
|
|
640
|
-
if (typeof
|
|
641
|
-
throw new
|
|
642
|
-
if (
|
|
643
|
-
if (!
|
|
644
|
-
const
|
|
645
|
-
|
|
646
|
-
const
|
|
647
|
-
for (const
|
|
648
|
-
if (
|
|
649
|
-
const
|
|
650
|
-
if (
|
|
651
|
-
|
|
480
|
+
function he(e, t) {
|
|
481
|
+
if (!Number.isSafeInteger(t) || t < 1) throw new b("input", "实例快照字节预算应为正安全整数");
|
|
482
|
+
let r = 0, n = 0;
|
|
483
|
+
const s = /* @__PURE__ */ new Set();
|
|
484
|
+
function a(u, f) {
|
|
485
|
+
if (++r > 1e6 || f > 64) throw new b("capacity", "实例节点或嵌套深度超过预算");
|
|
486
|
+
if (typeof u == "string" && (n += u.length, n > t))
|
|
487
|
+
throw new b("capacity", "实例文本超过预算");
|
|
488
|
+
if (He(u)) return u;
|
|
489
|
+
if (!u || typeof u != "object" || s.has(u)) throw new b("input", "实例只允许无循环的有限 JSON 值");
|
|
490
|
+
const c = Array.isArray(u);
|
|
491
|
+
Fe(u, c), s.add(u);
|
|
492
|
+
const i = /* @__PURE__ */ Object.create(null);
|
|
493
|
+
for (const d of Object.keys(u)) {
|
|
494
|
+
if (n += d.length, n > t) throw new b("capacity", "实例文本超过预算");
|
|
495
|
+
const l = Object.getOwnPropertyDescriptor(u, d);
|
|
496
|
+
if (l.get || l.set || ["__proto__", "constructor", "prototype"].includes(d)) throw new b("input", "实例不能包含访问器或危险键");
|
|
497
|
+
l.value !== void 0 && (i[d] = a(l.value, f + 1));
|
|
652
498
|
}
|
|
653
|
-
if (
|
|
654
|
-
if (Object.keys(
|
|
655
|
-
return Array.from({ length:
|
|
499
|
+
if (s.delete(u), c) {
|
|
500
|
+
if (Object.keys(i).length !== u.length) throw new b("input", "实例数组不能稀疏或包含额外属性");
|
|
501
|
+
return Array.from({ length: u.length }, (d, l) => i[String(l)]);
|
|
656
502
|
}
|
|
657
|
-
return
|
|
503
|
+
return i;
|
|
658
504
|
}
|
|
659
505
|
const o = JSON.stringify(a(e, 0));
|
|
660
|
-
if (new TextEncoder().encode(o).byteLength > t) throw new
|
|
506
|
+
if (new TextEncoder().encode(o).byteLength > t) throw new b("capacity", "实例快照超过单条字节预算");
|
|
661
507
|
return o;
|
|
662
508
|
}
|
|
663
|
-
function
|
|
664
|
-
const r = JSON.parse(
|
|
665
|
-
|
|
666
|
-
const
|
|
667
|
-
if (Object.keys(r).some((a) => !
|
|
668
|
-
|
|
509
|
+
function G(e, t = 8e6) {
|
|
510
|
+
const r = JSON.parse(he(e, t));
|
|
511
|
+
J(r.scope, r.id);
|
|
512
|
+
const n = /* @__PURE__ */ new Set(["scope", "id", "revision", "title", "generatedAt", "reportIds", "params", "templateRevisions", "sourceRevisions", "plan", "artifacts", "output"]);
|
|
513
|
+
if (Object.keys(r).some((a) => !n.has(a))) throw new b("input", "实例包含未知字段");
|
|
514
|
+
Ve(r);
|
|
669
515
|
for (const a of [r.params, r.templateRevisions, r.sourceRevisions])
|
|
670
|
-
if (!a || typeof a != "object" || Array.isArray(a) || Object.values(a).some((o) => typeof o != "string")) throw new
|
|
671
|
-
if (r.reportIds.some((a) => !r.templateRevisions[a])) throw new
|
|
672
|
-
const
|
|
673
|
-
if (!
|
|
516
|
+
if (!a || typeof a != "object" || Array.isArray(a) || Object.values(a).some((o) => typeof o != "string")) throw new b("input", "实例参数和修订应为字符串字典");
|
|
517
|
+
if (r.reportIds.some((a) => !r.templateRevisions[a])) throw new b("input", "每张报表都应记录生成时的模板修订");
|
|
518
|
+
const s = le(r.plan);
|
|
519
|
+
if (!s.ok) throw new b("input", `实例渲染计划无效:${s.errors[0]?.path}`);
|
|
674
520
|
if (r.output !== void 0) {
|
|
675
|
-
if (!r.output || Object.keys(r.output).some((a) => !["stats", "diagnostics", "layout", "sources"].includes(a))) throw new
|
|
676
|
-
if (
|
|
521
|
+
if (!r.output || Object.keys(r.output).some((a) => !["stats", "diagnostics", "layout", "sources"].includes(a))) throw new b("input", "实例输出元数据只允许统计、诊断和字体度量;不保存来源令牌");
|
|
522
|
+
if (pe({ ...r.output, plan: r.plan, revisions: {} }), r.output.sources?.some((a) => "sourceToken" in a)) throw new b("input", "实例来源清单不保存来源令牌");
|
|
677
523
|
}
|
|
678
|
-
return r.artifacts !== void 0 &&
|
|
524
|
+
return r.artifacts !== void 0 && Ue(r.artifacts), r;
|
|
679
525
|
}
|
|
680
|
-
function
|
|
681
|
-
if (!Array.isArray(e) || e.length > 100) throw new
|
|
526
|
+
function Ue(e) {
|
|
527
|
+
if (!Array.isArray(e) || e.length > 100) throw new b("input", "实例文件列表无效");
|
|
682
528
|
const t = /* @__PURE__ */ new Set();
|
|
683
529
|
for (const r of e) {
|
|
684
|
-
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
|
|
530
|
+
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 b("input", "实例文件应包含唯一存储键、格式、大小和可选 SHA256");
|
|
685
531
|
t.add(r.key);
|
|
686
532
|
}
|
|
687
533
|
}
|
|
688
|
-
function
|
|
689
|
-
const { scope: t, id: r, revision:
|
|
690
|
-
return JSON.parse(JSON.stringify({ scope: t, id: r, revision:
|
|
534
|
+
function Ze(e) {
|
|
535
|
+
const { scope: t, id: r, revision: n, title: s, generatedAt: a, reportIds: o, params: u, templateRevisions: f, sourceRevisions: c } = e;
|
|
536
|
+
return JSON.parse(JSON.stringify({ scope: t, id: r, revision: n, title: s, generatedAt: a, reportIds: o, params: u, templateRevisions: f, sourceRevisions: c }));
|
|
691
537
|
}
|
|
692
|
-
function
|
|
538
|
+
function Ke(e) {
|
|
693
539
|
const t = { maxInstances: 100, maxRevisions: 20, maxBytes: 64e6, maxSnapshotBytes: 8e6, ...e };
|
|
694
|
-
if (Object.values(t).some((r) => !Number.isSafeInteger(r) || r < 1)) throw new
|
|
540
|
+
if (Object.values(t).some((r) => !Number.isSafeInteger(r) || r < 1)) throw new b("input", "实例存储预算应为正安全整数");
|
|
695
541
|
return t;
|
|
696
542
|
}
|
|
697
|
-
function
|
|
698
|
-
const t =
|
|
699
|
-
let
|
|
543
|
+
function Ft(e = {}) {
|
|
544
|
+
const t = Ke(e), r = /* @__PURE__ */ new Map();
|
|
545
|
+
let n = 0;
|
|
700
546
|
return {
|
|
701
|
-
read: async (
|
|
702
|
-
h(
|
|
703
|
-
const
|
|
704
|
-
return
|
|
547
|
+
read: async (s, a, o, u) => {
|
|
548
|
+
h(u), J(s, a);
|
|
549
|
+
const f = r.get(JSON.stringify([s, a])), c = f?.get(o ?? f.size);
|
|
550
|
+
return c ? G(c, t.maxSnapshotBytes) : void 0;
|
|
705
551
|
},
|
|
706
|
-
list: async (
|
|
707
|
-
h(a.signal),
|
|
552
|
+
list: async (s, a = {}) => {
|
|
553
|
+
h(a.signal), J(s, "list");
|
|
708
554
|
const o = a.limit ?? 25;
|
|
709
|
-
if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new
|
|
710
|
-
const
|
|
711
|
-
return { items:
|
|
555
|
+
if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new b("input", "实例每页数量应为 1–100");
|
|
556
|
+
const u = Array.from(r.values(), (f) => f.get(f.size)).filter((f) => f.scope === s && (!a.after || f.id > a.after) && (!a.reportId || f.reportIds.includes(a.reportId))).sort((f, c) => f.id < c.id ? -1 : 1).slice(0, o + 1);
|
|
557
|
+
return { items: u.slice(0, o).map(Ze), ...u.length > o ? { next: u[o - 1].id } : {} };
|
|
712
558
|
},
|
|
713
|
-
compareAndSwap: async (
|
|
714
|
-
h(
|
|
715
|
-
const
|
|
716
|
-
if (
|
|
717
|
-
const
|
|
718
|
-
if ((
|
|
719
|
-
const
|
|
720
|
-
if (
|
|
721
|
-
return
|
|
559
|
+
compareAndSwap: async (s, a, o, u, f) => {
|
|
560
|
+
h(f), J(s, a);
|
|
561
|
+
const c = G(u, t.maxSnapshotBytes);
|
|
562
|
+
if (c.scope !== s || c.id !== a || c.revision !== (o ?? 0) + 1) throw new b("input", "实例身份或修订不一致");
|
|
563
|
+
const i = JSON.stringify([s, a]), d = r.get(i) ?? /* @__PURE__ */ new Map();
|
|
564
|
+
if ((d.size || null) !== o) return !1;
|
|
565
|
+
const l = new TextEncoder().encode(JSON.stringify(c)).byteLength;
|
|
566
|
+
if (d.size >= t.maxRevisions || n + l > t.maxBytes || !d.size && r.size >= t.maxInstances) throw new b("capacity", "实例存储达到预算,请使用持久化归档策略或显式调整容量");
|
|
567
|
+
return d.set(c.revision, c), r.set(i, d), n += l, !0;
|
|
722
568
|
}
|
|
723
569
|
};
|
|
724
570
|
}
|
|
725
|
-
function
|
|
571
|
+
function Xe(e, t = {}) {
|
|
726
572
|
const r = t.maxSnapshotBytes ?? 8e6;
|
|
727
|
-
if (!Number.isSafeInteger(r) || r < 1) throw new
|
|
573
|
+
if (!Number.isSafeInteger(r) || r < 1) throw new b("input", "实例快照字节预算应为正安全整数");
|
|
728
574
|
return {
|
|
729
575
|
read: e.read.bind(e),
|
|
730
576
|
list: e.list.bind(e),
|
|
731
|
-
save: async (
|
|
732
|
-
const a =
|
|
733
|
-
if (a !== null && (!Number.isSafeInteger(a) || a < 1 || a >= Number.MAX_SAFE_INTEGER)) throw new
|
|
734
|
-
const o = JSON.parse(
|
|
735
|
-
if (h(
|
|
736
|
-
return
|
|
577
|
+
save: async (n, s) => {
|
|
578
|
+
const a = s.expectedRevision;
|
|
579
|
+
if (a !== null && (!Number.isSafeInteger(a) || a < 1 || a >= Number.MAX_SAFE_INTEGER)) throw new b("input", "实例预期修订无效");
|
|
580
|
+
const o = JSON.parse(he(n, r)), u = G({ ...o, revision: (a ?? 0) + 1 }, r);
|
|
581
|
+
if (h(s.signal), !await e.compareAndSwap(u.scope, u.id, a, u, s.signal)) throw new b("conflict", "实例已存在或已变化,请显式确认修订后保存");
|
|
582
|
+
return u;
|
|
737
583
|
}
|
|
738
584
|
};
|
|
739
585
|
}
|
|
740
|
-
function
|
|
741
|
-
return
|
|
586
|
+
function Vt(e, t) {
|
|
587
|
+
return P({ reportIds: e, params: t });
|
|
742
588
|
}
|
|
743
|
-
function
|
|
744
|
-
if (!e || typeof e != "object" || Object.getOwnPropertySymbols(e).length) throw new
|
|
589
|
+
function Ge(e) {
|
|
590
|
+
if (!e || typeof e != "object" || Object.getOwnPropertySymbols(e).length) throw new b("input", "生成请求应为普通对象");
|
|
745
591
|
const t = /* @__PURE__ */ Object.create(null);
|
|
746
592
|
let r;
|
|
747
|
-
const
|
|
748
|
-
for (const
|
|
749
|
-
const a = Object.getOwnPropertyDescriptor(e,
|
|
750
|
-
if (!
|
|
751
|
-
|
|
593
|
+
const n = /* @__PURE__ */ new Set(["scope", "id", "title", "reportIds", "params", "expectedRevision", "signal"]);
|
|
594
|
+
for (const s of Object.getOwnPropertyNames(e)) {
|
|
595
|
+
const a = Object.getOwnPropertyDescriptor(e, s);
|
|
596
|
+
if (!n.has(s) || !a.enumerable || a.get || a.set) throw new b("input", "生成请求不能包含未知字段或访问器");
|
|
597
|
+
s === "signal" ? r = a.value : a.value !== void 0 && (t[s] = a.value);
|
|
752
598
|
}
|
|
753
|
-
return { signal: r, request: JSON.parse(
|
|
599
|
+
return { signal: r, request: JSON.parse(P(t)) };
|
|
754
600
|
}
|
|
755
|
-
function
|
|
756
|
-
const t = JSON.parse(
|
|
601
|
+
function Qe(e) {
|
|
602
|
+
const t = JSON.parse(P(e.templateRevisions)), r = ee(e.pdf), n = Xe(e.instances, { maxSnapshotBytes: e.maxSnapshotBytes });
|
|
757
603
|
return {
|
|
758
|
-
async generate(
|
|
759
|
-
const { signal: a, request: o } =
|
|
760
|
-
if (
|
|
761
|
-
const
|
|
762
|
-
if (!
|
|
763
|
-
const
|
|
764
|
-
for (const
|
|
765
|
-
if (typeof t[
|
|
766
|
-
|
|
604
|
+
async generate(s) {
|
|
605
|
+
const { signal: a, request: o } = Ge(s);
|
|
606
|
+
if (J(o.scope, o.id), o.expectedRevision !== null && (!Number.isSafeInteger(o.expectedRevision) || o.expectedRevision < 1)) throw new b("input", "实例预期修订无效");
|
|
607
|
+
const u = e.runtime.validate(o);
|
|
608
|
+
if (!u.ok) throw new Ne(u.issues);
|
|
609
|
+
const f = /* @__PURE__ */ Object.create(null);
|
|
610
|
+
for (const m of o.reportIds) {
|
|
611
|
+
if (typeof t[m] != "string" || !t[m]) throw new TypeError(`报表 ${m} 缺少生成时的模板修订`);
|
|
612
|
+
f[m] = t[m];
|
|
767
613
|
}
|
|
768
614
|
if (h(a), ((await e.instances.read(o.scope, o.id, void 0, a))?.revision ?? null) !== o.expectedRevision)
|
|
769
|
-
throw new
|
|
770
|
-
const
|
|
615
|
+
throw new b("conflict", "实例已存在或已变化,请显式确认修订后生成");
|
|
616
|
+
const i = await e.runtime.prepare({ reportIds: o.reportIds, params: u.values, pdf: r, signal: a });
|
|
771
617
|
h(a);
|
|
772
|
-
const
|
|
773
|
-
for (const [
|
|
774
|
-
const { plan:
|
|
775
|
-
return
|
|
618
|
+
const d = /* @__PURE__ */ Object.create(null);
|
|
619
|
+
for (const [m, v] of Object.entries(i.revisions)) v.revision !== void 0 && (d[m] = v.revision);
|
|
620
|
+
const { plan: l, revisions: p, sources: w, ...g } = i, y = { ...g, ...w ? { sources: w.map(({ sourceToken: m, ...v }) => v) } : {} };
|
|
621
|
+
return n.save({
|
|
776
622
|
scope: o.scope,
|
|
777
623
|
id: o.id,
|
|
778
624
|
title: o.title,
|
|
779
625
|
reportIds: o.reportIds,
|
|
780
|
-
params:
|
|
781
|
-
templateRevisions:
|
|
782
|
-
sourceRevisions:
|
|
626
|
+
params: u.values,
|
|
627
|
+
templateRevisions: f,
|
|
628
|
+
sourceRevisions: d,
|
|
783
629
|
generatedAt: (e.now?.() ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
784
|
-
plan:
|
|
785
|
-
output:
|
|
630
|
+
plan: l,
|
|
631
|
+
output: y
|
|
786
632
|
}, { expectedRevision: o.expectedRevision, signal: a });
|
|
787
633
|
},
|
|
788
|
-
read:
|
|
789
|
-
list:
|
|
634
|
+
read: n.read,
|
|
635
|
+
list: n.list,
|
|
790
636
|
/** Read an immutable saved revision and encode its plan, never re-query the business source. */
|
|
791
|
-
async exportInstance(
|
|
792
|
-
const { scope: a, id: o, revision:
|
|
793
|
-
|
|
794
|
-
const
|
|
795
|
-
if (!
|
|
796
|
-
const
|
|
797
|
-
plan:
|
|
798
|
-
revisions: Object.fromEntries(
|
|
637
|
+
async exportInstance(s) {
|
|
638
|
+
const { scope: a, id: o, revision: u, signal: f, format: c, fidelity: i, taskId: d, correlationId: l, onEvent: p } = s, w = ee(s.pdf ?? r), g = Te(s.xlsx);
|
|
639
|
+
J(a, o), h(f);
|
|
640
|
+
const y = await n.read(a, o, u, f);
|
|
641
|
+
if (!y) throw new b("input", "报表实例不存在");
|
|
642
|
+
const m = {
|
|
643
|
+
plan: y.plan,
|
|
644
|
+
revisions: Object.fromEntries(y.reportIds.map((v) => [v, { revision: y.sourceRevisions[v] }])),
|
|
799
645
|
diagnostics: [{ code: "instance-row-count", severity: "info", message: "历史实例未保存原始取数行数;本次 rows 统计为 0,页面及单元格数由已保存计划校验。" }],
|
|
800
|
-
stats: { rows: 0, pages:
|
|
801
|
-
...
|
|
646
|
+
stats: { rows: 0, pages: y.plan.pages.length, cells: 0, durationMs: 0 },
|
|
647
|
+
...y.output
|
|
802
648
|
};
|
|
803
|
-
return e.runtime.exportPrepared({ prepared:
|
|
649
|
+
return e.runtime.exportPrepared({ prepared: m, format: c, fidelity: i, pdf: w, xlsx: g, signal: f, taskId: d, correlationId: l, onEvent: p });
|
|
804
650
|
},
|
|
805
651
|
/** Instance edits are explicit snapshots; source business persistence remains the Provider.save responsibility. */
|
|
806
|
-
save:
|
|
652
|
+
save: n.save
|
|
807
653
|
};
|
|
808
654
|
}
|
|
809
|
-
function
|
|
655
|
+
function _(e, t, r) {
|
|
810
656
|
if (!Number.isSafeInteger(e) || e < 1 || e > t) throw new RangeError(`${r} 应为 1–${t} 的安全整数`);
|
|
811
657
|
return e;
|
|
812
658
|
}
|
|
813
|
-
function
|
|
659
|
+
function oe(e) {
|
|
814
660
|
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");
|
|
815
661
|
return { key: e.key, format: e.format, bytes: e.bytes, ...e.sha256 ? { sha256: e.sha256 } : {} };
|
|
816
662
|
}
|
|
817
|
-
function
|
|
818
|
-
if (!
|
|
663
|
+
function We(e) {
|
|
664
|
+
if (!je(e).ok || !e.repeat) throw new TypeError("分批生成仅支持有效的逐记录固定标签模板");
|
|
819
665
|
return JSON.parse(JSON.stringify(e));
|
|
820
666
|
}
|
|
821
|
-
function
|
|
667
|
+
function Ye(e) {
|
|
822
668
|
const t = /* @__PURE__ */ new Set(), r = e.repeat;
|
|
823
669
|
r.rowKey && t.add(r.rowKey), typeof r.copies == "object" && t.add(r.copies.field);
|
|
824
|
-
const
|
|
825
|
-
|
|
826
|
-
for (const a of
|
|
670
|
+
const n = (s) => {
|
|
671
|
+
s.binding && t.add(s.binding.field);
|
|
672
|
+
for (const a of s.grid?.cells ?? []) for (const o of a) o?.children?.forEach(n);
|
|
827
673
|
};
|
|
828
|
-
return e.pages.forEach((
|
|
674
|
+
return e.pages.forEach((s) => s.components.forEach((a) => n(a))), [...t];
|
|
829
675
|
}
|
|
830
|
-
function
|
|
831
|
-
if (!e || typeof e != "object" || Array.isArray(e)) throw new TypeError(`标签记录 ${
|
|
832
|
-
const
|
|
676
|
+
function et(e, t, r, n) {
|
|
677
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw new TypeError(`标签记录 ${n} 应为对象`);
|
|
678
|
+
const s = /* @__PURE__ */ Object.create(null);
|
|
833
679
|
for (const a of t) {
|
|
834
|
-
const o =
|
|
835
|
-
if (typeof o == "string" && o.length > 1e6) throw new
|
|
836
|
-
o !== void 0 && (
|
|
680
|
+
const o = we(e, a, { dataset: r, rowIndex: n });
|
|
681
|
+
if (typeof o == "string" && o.length > 1e6) throw new A("budget", "标签字段超过 1 MB 字符预算", `$.datasets.${r}[${n}].${a}`);
|
|
682
|
+
o !== void 0 && (s[a] = o);
|
|
837
683
|
}
|
|
838
|
-
return
|
|
684
|
+
return s;
|
|
839
685
|
}
|
|
840
|
-
function
|
|
841
|
-
const
|
|
842
|
-
if (!
|
|
843
|
-
const a =
|
|
844
|
-
if (!(typeof a == "string" && a.trim() || typeof a == "number" && Number.isFinite(a))) throw new TypeError(`标签记录 ${
|
|
686
|
+
function tt(e, t, r, n) {
|
|
687
|
+
const s = t.repeat;
|
|
688
|
+
if (!s.rowKey) return;
|
|
689
|
+
const a = we(e, s.rowKey, { rowIndex: n, dataset: s.dataset });
|
|
690
|
+
if (!(typeof a == "string" && a.trim() || typeof a == "number" && Number.isFinite(a))) throw new TypeError(`标签记录 ${n} 的业务主键无效`);
|
|
845
691
|
const o = JSON.stringify([typeof a, a]);
|
|
846
|
-
if (r.keys.has(o)) throw new TypeError(`标签记录 ${
|
|
692
|
+
if (r.keys.has(o)) throw new TypeError(`标签记录 ${n} 的业务主键重复(包含先前批次)`);
|
|
847
693
|
r.bytes += o.length * 2 + 64, r.keys.add(o);
|
|
848
694
|
}
|
|
849
|
-
function
|
|
850
|
-
return Object.entries(e).reduce((t, [r,
|
|
695
|
+
function rt(e) {
|
|
696
|
+
return Object.entries(e).reduce((t, [r, n]) => t + 64 + r.length * 2 + (typeof n == "string" ? n.length * 2 : 8), 0);
|
|
851
697
|
}
|
|
852
|
-
function
|
|
698
|
+
function nt(e, t) {
|
|
853
699
|
if (!t) return e;
|
|
854
700
|
for (const r of e.plan.pages) {
|
|
855
|
-
const
|
|
856
|
-
|
|
701
|
+
const n = r.meta?.record;
|
|
702
|
+
n && typeof n == "object" && "rowIndex" in n && typeof n.rowIndex == "number" && (n.rowIndex += t);
|
|
857
703
|
}
|
|
858
704
|
return e;
|
|
859
705
|
}
|
|
860
|
-
async function
|
|
706
|
+
async function st(e, t) {
|
|
861
707
|
if (!e.return) return;
|
|
862
708
|
const r = Promise.resolve(e.return());
|
|
863
709
|
if (t.aborted) {
|
|
@@ -865,406 +711,645 @@ async function St(e, t) {
|
|
|
865
711
|
});
|
|
866
712
|
return;
|
|
867
713
|
}
|
|
868
|
-
await
|
|
869
|
-
}
|
|
870
|
-
async function
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
}), await
|
|
874
|
-
}
|
|
875
|
-
function
|
|
876
|
-
return new Promise((
|
|
877
|
-
let a = !1, o = !1,
|
|
878
|
-
const
|
|
879
|
-
clearTimeout(
|
|
880
|
-
},
|
|
881
|
-
a ||
|
|
714
|
+
await T(t, void 0, () => r);
|
|
715
|
+
}
|
|
716
|
+
async function ie(e, t, r) {
|
|
717
|
+
const n = Promise.resolve().then(() => e.onReceipt?.(t, r));
|
|
718
|
+
n.catch(() => {
|
|
719
|
+
}), await T(r.signal, void 0, () => n);
|
|
720
|
+
}
|
|
721
|
+
function at(e, t, r) {
|
|
722
|
+
return new Promise((n, s) => {
|
|
723
|
+
let a = !1, o = !1, u;
|
|
724
|
+
const f = () => {
|
|
725
|
+
clearTimeout(u), t.removeEventListener("abort", c);
|
|
726
|
+
}, c = () => {
|
|
727
|
+
a || u !== void 0 || (u = setTimeout(() => {
|
|
882
728
|
if (!a) {
|
|
883
|
-
a = !0, o = !0,
|
|
729
|
+
a = !0, o = !0, f();
|
|
884
730
|
try {
|
|
885
731
|
h(t);
|
|
886
|
-
} catch (
|
|
887
|
-
|
|
732
|
+
} catch (i) {
|
|
733
|
+
s(i);
|
|
888
734
|
}
|
|
889
735
|
}
|
|
890
736
|
}, 0));
|
|
891
737
|
};
|
|
892
|
-
e.then((
|
|
738
|
+
e.then((i) => {
|
|
893
739
|
if (o) {
|
|
894
|
-
Promise.resolve().then(() => r(
|
|
740
|
+
Promise.resolve().then(() => r(i)).catch(() => {
|
|
895
741
|
});
|
|
896
742
|
return;
|
|
897
743
|
}
|
|
898
|
-
a || (a = !0,
|
|
899
|
-
}, (
|
|
900
|
-
a || (a = !0,
|
|
901
|
-
}), t.addEventListener("abort",
|
|
744
|
+
a || (a = !0, f(), n(i));
|
|
745
|
+
}, (i) => {
|
|
746
|
+
a || (a = !0, f(), s(i));
|
|
747
|
+
}), t.addEventListener("abort", c, { once: !0 }), t.aborted && c();
|
|
902
748
|
});
|
|
903
749
|
}
|
|
904
|
-
async function
|
|
905
|
-
const r =
|
|
750
|
+
async function Ht(e, t) {
|
|
751
|
+
const r = _(t.batchSize ?? 100, 1e3, "batchSize"), n = _(t.maxRows ?? 1e5, 1e6, "maxRows"), s = _(t.maxChunks ?? 1e3, 1e4, "maxChunks"), a = _(t.maxRetainedBytes ?? 16e6, 64e6, "maxRetainedBytes"), o = We(t.template), u = Ye(o);
|
|
906
752
|
if (!e || typeof e[Symbol.asyncIterator] != "function") throw new TypeError("标签来源应为 AsyncIterable");
|
|
907
|
-
return
|
|
908
|
-
const
|
|
909
|
-
let
|
|
910
|
-
const
|
|
911
|
-
|
|
753
|
+
return T(t.signal, t.runtime?.budget?.maxDurationMs ?? 12e4, async (f) => {
|
|
754
|
+
const c = { rows: 0, chunks: [] }, i = { keys: /* @__PURE__ */ new Set(), bytes: 0 }, d = e[Symbol.asyncIterator]();
|
|
755
|
+
let l = !1, p = !1, w;
|
|
756
|
+
const g = () => w ??= st(d, f), y = () => {
|
|
757
|
+
l || g().catch(() => {
|
|
912
758
|
});
|
|
913
759
|
};
|
|
914
|
-
|
|
760
|
+
f.addEventListener("abort", y, { once: !0 });
|
|
915
761
|
try {
|
|
916
|
-
for (; !
|
|
917
|
-
h(
|
|
918
|
-
const
|
|
919
|
-
let
|
|
920
|
-
for (;
|
|
921
|
-
const
|
|
922
|
-
if (
|
|
923
|
-
|
|
762
|
+
for (; !l; ) {
|
|
763
|
+
h(f);
|
|
764
|
+
const m = [];
|
|
765
|
+
let v = 0;
|
|
766
|
+
for (; m.length < r; ) {
|
|
767
|
+
const I = await T(f, void 0, () => Promise.resolve(d.next()));
|
|
768
|
+
if (I.done) {
|
|
769
|
+
l = !0;
|
|
924
770
|
break;
|
|
925
771
|
}
|
|
926
|
-
if (
|
|
927
|
-
if (
|
|
928
|
-
const S =
|
|
929
|
-
if (
|
|
930
|
-
|
|
772
|
+
if (c.rows + m.length >= n) throw new A("budget", "标签来源行数超过预算", "$.maxRows");
|
|
773
|
+
if (c.chunks.length >= s) throw new A("budget", "标签分块数量超过预算", "$.maxChunks");
|
|
774
|
+
const S = et(I.value, u, o.repeat.dataset, c.rows + m.length);
|
|
775
|
+
if (tt(S, o, i, c.rows + m.length), v += rt(S), i.bytes + v > a) throw new A("budget", "标签当前块字段与全局主键索引超过内存预算", "$.maxRetainedBytes");
|
|
776
|
+
m.push(S);
|
|
931
777
|
}
|
|
932
|
-
if (!
|
|
933
|
-
const
|
|
934
|
-
let
|
|
935
|
-
const
|
|
936
|
-
index:
|
|
937
|
-
rowOffset:
|
|
938
|
-
rowCount:
|
|
939
|
-
signal:
|
|
940
|
-
export: (
|
|
778
|
+
if (!m.length) break;
|
|
779
|
+
const N = W({ ...t.runtime, reports: { labels: { template: o, datasets: { [o.repeat.dataset]: m } } } });
|
|
780
|
+
let M;
|
|
781
|
+
const E = {
|
|
782
|
+
index: c.chunks.length,
|
|
783
|
+
rowOffset: c.rows,
|
|
784
|
+
rowCount: m.length,
|
|
785
|
+
signal: f,
|
|
786
|
+
export: (I) => N.exportPrepared({ pdf: t.pdf, ...I, prepared: M, signal: f })
|
|
941
787
|
};
|
|
942
|
-
let
|
|
943
|
-
const
|
|
788
|
+
let C;
|
|
789
|
+
const B = (await Oe([{ id: `labels-${E.index}`, params: {} }], async () => {
|
|
944
790
|
try {
|
|
945
|
-
|
|
946
|
-
const
|
|
947
|
-
return
|
|
948
|
-
} catch (
|
|
949
|
-
throw
|
|
791
|
+
M = nt(await N.prepare({ reportIds: ["labels"], pdf: t.pdf, signal: f }), E.rowOffset), h(f);
|
|
792
|
+
const I = Promise.resolve(t.execute(M, E)), S = await at(I, f, (k) => ie(t, oe(k), E));
|
|
793
|
+
return oe(S);
|
|
794
|
+
} catch (I) {
|
|
795
|
+
throw C = I, I;
|
|
950
796
|
}
|
|
951
|
-
}, { concurrency: 1, signal:
|
|
952
|
-
if (
|
|
953
|
-
throw h(
|
|
954
|
-
if (
|
|
955
|
-
|
|
797
|
+
}, { concurrency: 1, signal: f, failure: "stop" }))[0];
|
|
798
|
+
if (B.status === "cancelled")
|
|
799
|
+
throw h(f), new Error("标签分批任务已取消");
|
|
800
|
+
if (B.status === "failed") throw C ?? new Error(B.error.message);
|
|
801
|
+
c.chunks.push({ ...B.value, index: E.index, rowOffset: E.rowOffset, rowCount: E.rowCount }), c.rows += m.length, await ie(t, B.value, E);
|
|
956
802
|
}
|
|
957
|
-
return
|
|
958
|
-
} catch (
|
|
959
|
-
throw
|
|
803
|
+
return c;
|
|
804
|
+
} catch (m) {
|
|
805
|
+
throw p = !0, m;
|
|
960
806
|
} finally {
|
|
961
|
-
|
|
962
|
-
if (!
|
|
807
|
+
f.removeEventListener("abort", y), l || await g().catch((m) => {
|
|
808
|
+
if (!p) throw m;
|
|
963
809
|
});
|
|
964
810
|
}
|
|
965
811
|
});
|
|
966
812
|
}
|
|
967
|
-
async function
|
|
968
|
-
const r = t.document().id,
|
|
969
|
-
if (
|
|
813
|
+
async function ot(e, t) {
|
|
814
|
+
const r = t.document().id, n = () => t.editor.saving || t.editor.blocked;
|
|
815
|
+
if (n()) throw new Error("草稿尚未保存,请处理设计器提示后再发布");
|
|
970
816
|
if (t.editor.pendingLocalChanges) {
|
|
971
817
|
const a = t.successfulSaves();
|
|
972
|
-
if (await t.editor.save(), await t.afterSave(), t.successfulSaves() === a || t.editor.pendingLocalChanges ||
|
|
818
|
+
if (await t.editor.save(), await t.afterSave(), t.successfulSaves() === a || t.editor.pendingLocalChanges || n()) throw new Error("草稿尚未保存,请处理设计器提示后再发布");
|
|
973
819
|
}
|
|
974
|
-
const
|
|
975
|
-
if (
|
|
976
|
-
return e.publish(
|
|
820
|
+
const s = t.document();
|
|
821
|
+
if (s.id !== r) throw new b("conflict", "当前模板已切换,请重新确认后发布");
|
|
822
|
+
return e.publish(s.id, { expectedRevision: s.revision ?? null });
|
|
977
823
|
}
|
|
978
|
-
function
|
|
824
|
+
function it(e, t) {
|
|
979
825
|
return {
|
|
980
826
|
async search(r) {
|
|
981
827
|
h(r.signal);
|
|
982
|
-
const
|
|
983
|
-
if (
|
|
984
|
-
const
|
|
985
|
-
for (const a of
|
|
828
|
+
const n = await e.list(r.signal);
|
|
829
|
+
if (n.length > 1e3) throw new RangeError("本地模板连接目录最多 1000 项;更大目录请使用宿主分页查询适配器");
|
|
830
|
+
const s = [];
|
|
831
|
+
for (const a of n) {
|
|
986
832
|
h(r.signal);
|
|
987
|
-
const [o,
|
|
988
|
-
|
|
833
|
+
const [o, u] = await Promise.all([e.get(a.id, { draft: !0, signal: r.signal }), e.get(a.id, { signal: r.signal })]), f = o ?? u;
|
|
834
|
+
f && s.push({ document: f, published: u, draftRevision: o?.revision, publishedRevision: u?.revision, ...t?.($(f)) });
|
|
989
835
|
}
|
|
990
|
-
return
|
|
836
|
+
return Pe(s).search(r);
|
|
991
837
|
},
|
|
992
|
-
async get(r,
|
|
993
|
-
return
|
|
838
|
+
async get(r, n) {
|
|
839
|
+
return n.mode === "published" ? e.get(r, { signal: n.signal }) : await e.get(r, { draft: !0, signal: n.signal }) ?? e.get(r, { signal: n.signal });
|
|
994
840
|
}
|
|
995
841
|
};
|
|
996
842
|
}
|
|
997
|
-
function
|
|
843
|
+
function ct(e = 1e3) {
|
|
998
844
|
if (!Number.isSafeInteger(e) || e < 1 || e > 1e3) throw new RangeError("本地生成意图上限应为 1–1000");
|
|
999
845
|
const t = /* @__PURE__ */ new Map(), r = globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
1000
846
|
return {
|
|
1001
|
-
forCase(
|
|
1002
|
-
if (![
|
|
1003
|
-
const a = JSON.stringify([
|
|
847
|
+
forCase(n, s) {
|
|
848
|
+
if (![n, s].every((f) => typeof f == "string" && f.length > 0 && f.length <= 256)) throw new TypeError("模板与参数组标识无效");
|
|
849
|
+
const a = JSON.stringify([n, s]), o = t.get(a);
|
|
1004
850
|
if (o) return o;
|
|
1005
851
|
if (t.size >= e) throw new RangeError("本地生成意图已达上限,请使用持久化任务服务");
|
|
1006
|
-
const
|
|
1007
|
-
return t.set(a,
|
|
852
|
+
const u = `instance-${r}-${(t.size + 1).toString(36)}`;
|
|
853
|
+
return t.set(a, u), u;
|
|
1008
854
|
}
|
|
1009
855
|
};
|
|
1010
856
|
}
|
|
1011
|
-
function
|
|
1012
|
-
const
|
|
1013
|
-
return e.reportIds.length === 1 && e.reportIds[0] === t.id && Object.keys(e.templateRevisions).length === 1 && e.templateRevisions[t.id] === t.revision && Object.keys(e.params).length ===
|
|
857
|
+
function ft(e, t, r) {
|
|
858
|
+
const n = Object.keys(r);
|
|
859
|
+
return e.reportIds.length === 1 && e.reportIds[0] === t.id && Object.keys(e.templateRevisions).length === 1 && e.templateRevisions[t.id] === t.revision && Object.keys(e.params).length === n.length && n.every((s) => r[s] === e.params[s]);
|
|
1014
860
|
}
|
|
1015
|
-
function
|
|
861
|
+
function ce(e) {
|
|
1016
862
|
return { instanceId: e.id, label: e.title };
|
|
1017
863
|
}
|
|
1018
|
-
function
|
|
1019
|
-
const
|
|
1020
|
-
if (!
|
|
1021
|
-
const
|
|
1022
|
-
async function
|
|
1023
|
-
h(
|
|
1024
|
-
const
|
|
1025
|
-
if (h(
|
|
1026
|
-
if (!
|
|
1027
|
-
return
|
|
864
|
+
function dt(e, t, r) {
|
|
865
|
+
const n = $(e);
|
|
866
|
+
if (!n.revision) throw new Error("请先发布该模板");
|
|
867
|
+
const s = typeof t.data == "function" ? t.data($(n)) : t.data, a = W({ ...t.runtime, reports: { [n.id]: { ...s, template: n.template } } }), o = Qe({ runtime: a, instances: t.instances, templateRevisions: { [n.id]: n.revision }, pdf: t.pdf });
|
|
868
|
+
async function u(f, c, i) {
|
|
869
|
+
h(i);
|
|
870
|
+
const d = await t.instances.read(t.scope, f, void 0, i);
|
|
871
|
+
if (h(i), !!d) {
|
|
872
|
+
if (!ft(d, n, c)) throw new b("conflict", "此参数组已用于其他参数或发布修订,请复制为新任务生成");
|
|
873
|
+
return ce(d);
|
|
1028
874
|
}
|
|
1029
875
|
}
|
|
1030
876
|
return {
|
|
1031
|
-
document:
|
|
1032
|
-
async execute(
|
|
1033
|
-
h(
|
|
1034
|
-
const
|
|
1035
|
-
if (!
|
|
1036
|
-
const
|
|
1037
|
-
if (
|
|
877
|
+
document: $(n),
|
|
878
|
+
async execute(f, { signal: c }) {
|
|
879
|
+
h(c);
|
|
880
|
+
const i = a.validate({ reportIds: [n.id], params: f.params });
|
|
881
|
+
if (!i.ok) throw new Error(i.issues[0]?.message ?? "生成参数无效");
|
|
882
|
+
const d = r(n.id, f.id), l = await u(d, i.values, c);
|
|
883
|
+
if (l) return l;
|
|
1038
884
|
try {
|
|
1039
|
-
return
|
|
885
|
+
return ce(await o.generate({
|
|
1040
886
|
scope: t.scope,
|
|
1041
|
-
id:
|
|
1042
|
-
title: (t.title?.(
|
|
1043
|
-
reportIds: [
|
|
1044
|
-
params:
|
|
887
|
+
id: d,
|
|
888
|
+
title: (t.title?.($(n), f, i.values) ?? `${n.name} · ${f.id}`).slice(0, 512),
|
|
889
|
+
reportIds: [n.id],
|
|
890
|
+
params: i.values,
|
|
1045
891
|
expectedRevision: null,
|
|
1046
|
-
signal:
|
|
892
|
+
signal: c
|
|
1047
893
|
}));
|
|
1048
|
-
} catch (
|
|
1049
|
-
if (
|
|
1050
|
-
const
|
|
1051
|
-
if (
|
|
894
|
+
} catch (p) {
|
|
895
|
+
if (p instanceof b && p.code === "conflict") {
|
|
896
|
+
const w = await u(d, i.values, c);
|
|
897
|
+
if (w) return w;
|
|
1052
898
|
}
|
|
1053
|
-
throw
|
|
899
|
+
throw p;
|
|
1054
900
|
}
|
|
1055
901
|
}
|
|
1056
902
|
};
|
|
1057
903
|
}
|
|
1058
|
-
function
|
|
904
|
+
function Ut(e) {
|
|
1059
905
|
e = { ...e };
|
|
1060
|
-
const t =
|
|
906
|
+
const t = ct(), r = e.instanceId ?? t.forCase;
|
|
1061
907
|
return {
|
|
1062
|
-
catalog: e.catalog ??
|
|
1063
|
-
publish: (
|
|
908
|
+
catalog: e.catalog ?? it(e.templates, e.catalogMetadata),
|
|
909
|
+
publish: (n) => ot(e.templates, n),
|
|
1064
910
|
/** Resolve only a manager-owned publication, then keep that exact revision for this batch. */
|
|
1065
|
-
async batch(
|
|
1066
|
-
const { expectedRevision: a, signal: o } =
|
|
1067
|
-
if (h(o), !
|
|
1068
|
-
if (a !== void 0 &&
|
|
1069
|
-
return
|
|
911
|
+
async batch(n, s = {}) {
|
|
912
|
+
const { expectedRevision: a, signal: o } = s, u = await e.templates.get(n, { signal: o });
|
|
913
|
+
if (h(o), !u?.revision) throw new Error("请先发布该模板");
|
|
914
|
+
if (a !== void 0 && u.revision !== a) throw new b("conflict", "模板发布版本已变化,请重新打开后生成");
|
|
915
|
+
return dt(u, e, r);
|
|
1070
916
|
}
|
|
1071
917
|
};
|
|
1072
918
|
}
|
|
1073
|
-
const
|
|
1074
|
-
function
|
|
919
|
+
const be = "2.17.0";
|
|
920
|
+
function U(e, t) {
|
|
1075
921
|
const r = t?.componentPath;
|
|
1076
|
-
if (!Number.isSafeInteger(t?.pageIndex) || t.pageIndex < 0 || !Array.isArray(r) || r.length < 1 || r.length > 31 || r.length % 3 !== 1 || r.some((
|
|
1077
|
-
let
|
|
1078
|
-
for (let
|
|
1079
|
-
if (!
|
|
1080
|
-
return
|
|
922
|
+
if (!Number.isSafeInteger(t?.pageIndex) || t.pageIndex < 0 || !Array.isArray(r) || r.length < 1 || r.length > 31 || r.length % 3 !== 1 || r.some((s) => !Number.isSafeInteger(s) || s < 0)) throw new TypeError("模板包图片位置无效");
|
|
923
|
+
let n = e.template.pages[t.pageIndex]?.components[r[0]];
|
|
924
|
+
for (let s = 1; n && s < r.length; s += 3) n = n.grid?.cells[r[s]]?.[r[s + 1]]?.children?.[r[s + 2]];
|
|
925
|
+
if (!n || n.kind !== "image" || n.binding) throw new TypeError("模板包图片位置应指向静态图片组件");
|
|
926
|
+
return n;
|
|
1081
927
|
}
|
|
1082
|
-
function
|
|
928
|
+
function ut(e) {
|
|
1083
929
|
const t = ["id", "kind", "mediaType", "bytes", "sha256", "license", "font", "targets"];
|
|
1084
930
|
if (!e || Object.keys(e).some((r) => !t.includes(r))) throw new TypeError("模板资源包含未知字段");
|
|
1085
931
|
if (typeof e.id != "string" || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(e.id)) throw new TypeError("模板资源ID应为安全标识");
|
|
1086
932
|
if (!Number.isSafeInteger(e.bytes) || e.bytes < 1 || e.bytes > 32e6 || !/^[a-f0-9]{64}$/.test(e.sha256)) throw new TypeError("模板资源大小或SHA256无效");
|
|
1087
933
|
if (e.license !== void 0 && (typeof e.license != "string" || e.license.length > 512)) throw new TypeError("模板资源许可说明无效");
|
|
1088
934
|
}
|
|
1089
|
-
function
|
|
1090
|
-
if (
|
|
935
|
+
function lt(e, t) {
|
|
936
|
+
if (ut(e), e.kind === "font") {
|
|
1091
937
|
if (!["font/ttf", "font/otf"].includes(e.mediaType) || e.targets !== void 0) throw new TypeError("字体资源类型无效");
|
|
1092
938
|
const r = e.font;
|
|
1093
|
-
if (!r || typeof r.family != "string" || !r.family.trim() || r.family.length > 128 || !["regular", "bold", "italic", "boldItalic"].includes(r.face) || Object.keys(r).some((
|
|
939
|
+
if (!r || typeof r.family != "string" || !r.family.trim() || r.family.length > 128 || !["regular", "bold", "italic", "boldItalic"].includes(r.face) || Object.keys(r).some((n) => !["family", "face"].includes(n))) throw new TypeError("字体资源需要family和face");
|
|
1094
940
|
return;
|
|
1095
941
|
}
|
|
1096
942
|
if (e.kind !== "image" || !["image/png", "image/jpeg"].includes(e.mediaType) || e.font !== void 0) throw new TypeError("模板图片仅支持PNG/JPEG");
|
|
1097
943
|
if (!Array.isArray(e.targets) || !e.targets.length || e.targets.length > 1e3) throw new TypeError("模板图片需要1–1000个位置");
|
|
1098
944
|
for (const r of e.targets) {
|
|
1099
|
-
if (Object.keys(r).some((
|
|
1100
|
-
|
|
945
|
+
if (Object.keys(r).some((n) => !["pageIndex", "componentPath"].includes(n))) throw new TypeError("模板图片位置包含未知字段");
|
|
946
|
+
U(t, r);
|
|
1101
947
|
}
|
|
1102
948
|
}
|
|
1103
|
-
function
|
|
1104
|
-
const r = (
|
|
949
|
+
function pt(e, t) {
|
|
950
|
+
const r = (n) => n.every((s, a) => e[a] === s);
|
|
1105
951
|
return t === "image/png" ? r([137, 80, 78, 71, 13, 10, 26, 10]) : t === "image/jpeg" ? r([255, 216, 255]) : t === "font/otf" ? r([79, 84, 84, 79]) : r([0, 1, 0, 0]) || r([116, 114, 117, 101]);
|
|
1106
952
|
}
|
|
1107
|
-
function
|
|
953
|
+
function wt(e) {
|
|
1108
954
|
if (!(e instanceof Uint8Array) || !e.byteLength || e.byteLength > 32e6) throw new RangeError("资源摘要只接受1–32MB字节");
|
|
1109
|
-
return
|
|
955
|
+
return Re(e);
|
|
1110
956
|
}
|
|
1111
|
-
function
|
|
1112
|
-
const
|
|
1113
|
-
if (o.imageData && !
|
|
1114
|
-
const
|
|
1115
|
-
|
|
957
|
+
function ve(e, t, r = me()) {
|
|
958
|
+
const n = new Set(t.flatMap((o) => (o.targets ?? []).map((u) => U(e, u)))), s = /* @__PURE__ */ new Map(), a = (o) => {
|
|
959
|
+
if (o.imageData && !n.has(o)) {
|
|
960
|
+
const u = r(o.imageData);
|
|
961
|
+
s.set(u.dataUrl, u.bytes.byteLength);
|
|
1116
962
|
}
|
|
1117
|
-
for (const
|
|
963
|
+
for (const u of o.grid?.cells ?? []) for (const f of u) for (const c of f?.children ?? []) a(c);
|
|
1118
964
|
};
|
|
1119
|
-
for (const o of e.template.pages) for (const
|
|
1120
|
-
return [...
|
|
965
|
+
for (const o of e.template.pages) for (const u of o.components) a(u);
|
|
966
|
+
return [...s.values()].reduce((o, u) => o + u, 0);
|
|
1121
967
|
}
|
|
1122
|
-
function
|
|
968
|
+
function yt(e, t) {
|
|
1123
969
|
let r = "";
|
|
1124
|
-
for (let
|
|
970
|
+
for (let n = 0; n < e.length; n += 16384) r += String.fromCharCode(...e.subarray(n, n + 16384));
|
|
1125
971
|
return `data:${t};base64,${btoa(r)}`;
|
|
1126
972
|
}
|
|
1127
|
-
async function
|
|
1128
|
-
if (!Number.isFinite(
|
|
1129
|
-
return
|
|
1130
|
-
const o = [],
|
|
1131
|
-
|
|
1132
|
-
for (const
|
|
973
|
+
async function mt(e, t, r, n, s = 3e4) {
|
|
974
|
+
if (!Number.isFinite(s) || s < 1 || s > 2147483647) throw new RangeError("模板资源加载超时应为1–2147483647毫秒");
|
|
975
|
+
return T(n, s, async (a) => {
|
|
976
|
+
const o = [], u = me();
|
|
977
|
+
ve(e, t, u);
|
|
978
|
+
for (const f of t) {
|
|
1133
979
|
h(a);
|
|
1134
|
-
const
|
|
1135
|
-
if (h(a), !
|
|
1136
|
-
const
|
|
1137
|
-
if (!
|
|
1138
|
-
if (
|
|
980
|
+
const c = await T(a, void 0, () => Promise.resolve(r(JSON.parse(JSON.stringify(f)), { signal: a })));
|
|
981
|
+
if (h(a), !c || !(c.bytes instanceof Uint8Array) || c.mediaType !== f.mediaType || c.bytes.byteLength !== f.bytes) throw new TypeError(`资源 ${f.id} 的类型或大小与清单不一致`);
|
|
982
|
+
const i = new Uint8Array(c.bytes);
|
|
983
|
+
if (!pt(i, f.mediaType) || wt(i) !== f.sha256) throw new TypeError(`资源 ${f.id} 的文件标识或SHA256与清单不一致`);
|
|
984
|
+
if (f.kind === "font") o.push({ id: f.id, family: f.font.family, face: f.font.face, bytes: i });
|
|
1139
985
|
else {
|
|
1140
|
-
const
|
|
1141
|
-
for (const
|
|
986
|
+
const d = u(yt(i, f.mediaType)).dataUrl;
|
|
987
|
+
for (const l of f.targets) U(e, l).imageData = d;
|
|
1142
988
|
}
|
|
1143
989
|
}
|
|
1144
990
|
return o;
|
|
1145
991
|
});
|
|
1146
992
|
}
|
|
1147
|
-
function
|
|
993
|
+
function fe(e) {
|
|
1148
994
|
if (typeof e != "string" || !/^(0|[1-9]\d{0,5})\.(0|[1-9]\d{0,5})\.(0|[1-9]\d{0,5})$/.test(e)) throw new TypeError("模板包最低版本与运行版本应为正式版本x.y.z");
|
|
1149
995
|
return e.split(".").map(Number);
|
|
1150
996
|
}
|
|
1151
|
-
function
|
|
1152
|
-
const r =
|
|
1153
|
-
for (let
|
|
1154
|
-
if (s
|
|
1155
|
-
if (s
|
|
997
|
+
function gt(e, t) {
|
|
998
|
+
const r = fe(e), n = fe(t);
|
|
999
|
+
for (let s = 0; s < 3; s++) {
|
|
1000
|
+
if (n[s] > r[s]) return;
|
|
1001
|
+
if (n[s] < r[s]) throw new Error(`模板包需要MachReport ${e}或更新版本`);
|
|
1156
1002
|
}
|
|
1157
1003
|
}
|
|
1158
|
-
function
|
|
1159
|
-
const
|
|
1160
|
-
if (!Number.isSafeInteger(
|
|
1161
|
-
return
|
|
1004
|
+
function Q(e, t, r) {
|
|
1005
|
+
const n = e ?? t;
|
|
1006
|
+
if (!Number.isSafeInteger(n) || n < 1 || n > r) throw new RangeError("模板包字节预算无效");
|
|
1007
|
+
return n;
|
|
1162
1008
|
}
|
|
1163
|
-
function
|
|
1009
|
+
function ht(e) {
|
|
1164
1010
|
if (e.contracts !== void 0) {
|
|
1165
1011
|
if (!e.contracts || typeof e.contracts != "object" || Array.isArray(e.contracts) || Object.keys(e.contracts).length > 100) throw new TypeError("模板包字段契约应为最多100个数据集");
|
|
1166
1012
|
for (const [t, r] of Object.entries(e.contracts)) {
|
|
1167
1013
|
if (!t.trim() || t.length > 256) throw new TypeError("模板包数据集名称无效");
|
|
1168
|
-
|
|
1014
|
+
ye([], r);
|
|
1169
1015
|
}
|
|
1170
1016
|
}
|
|
1171
1017
|
}
|
|
1172
|
-
function
|
|
1018
|
+
function bt(e, t) {
|
|
1173
1019
|
if (!e || e.deidentified !== !0 || typeof e.name != "string" || !e.name.trim() || e.name.length > 128) throw new TypeError("样例需要名称和明确的deidentified:true确认");
|
|
1174
|
-
if (Object.keys(e).some((
|
|
1020
|
+
if (Object.keys(e).some((n) => !["name", "deidentified", "datasets", "params"].includes(n))) throw new TypeError("模板包样例包含未知字段");
|
|
1175
1021
|
if (!e.datasets || typeof e.datasets != "object" || Array.isArray(e.datasets)) throw new TypeError("模板包样例数据集无效");
|
|
1176
|
-
if (
|
|
1022
|
+
if (vt(e, t), !Be(t.document.template.params ?? [], e.params).ok) throw new TypeError(`样例 ${e.name} 的参数不符合模板定义`);
|
|
1177
1023
|
}
|
|
1178
|
-
function
|
|
1024
|
+
function vt(e, t) {
|
|
1179
1025
|
let r = 0;
|
|
1180
|
-
for (const
|
|
1181
|
-
if (!Array.isArray(
|
|
1182
|
-
const
|
|
1183
|
-
for (const [
|
|
1026
|
+
for (const s of Object.values(e.datasets))
|
|
1027
|
+
if (!Array.isArray(s) || s.some((a) => !a || typeof a != "object" || Array.isArray(a))) throw new TypeError("模板包样例应为对象行数组");
|
|
1028
|
+
const n = Ie(t.document.template, e.datasets, { maxRows: 1e3 });
|
|
1029
|
+
for (const [s, a] of Object.entries(n)) {
|
|
1184
1030
|
if (r += a.length, r > 1e3) throw new RangeError("模板包每个样例最多1000行");
|
|
1185
|
-
const o = t.contracts?.[
|
|
1186
|
-
if (o && !
|
|
1031
|
+
const o = t.contracts?.[s];
|
|
1032
|
+
if (o && !ye(a, o).ok) throw new TypeError(`样例 ${e.name} 不符合 ${s} 字段契约`);
|
|
1187
1033
|
}
|
|
1188
|
-
for (const
|
|
1034
|
+
for (const s of Object.keys(t.contracts ?? {})) if (!Object.prototype.hasOwnProperty.call(e.datasets, s)) throw new TypeError(`样例 ${e.name} 缺少 ${s} 数据集`);
|
|
1189
1035
|
}
|
|
1190
|
-
function
|
|
1036
|
+
function xt(e) {
|
|
1191
1037
|
if (e.fixtures === void 0) return;
|
|
1192
1038
|
if (!Array.isArray(e.fixtures) || e.fixtures.length > 20) throw new RangeError("模板包最多20个脱敏样例");
|
|
1193
1039
|
const t = /* @__PURE__ */ new Set();
|
|
1194
1040
|
for (const r of e.fixtures) {
|
|
1195
|
-
if (
|
|
1041
|
+
if (bt(r, e), t.has(r.name)) throw new TypeError("模板包样例名称重复");
|
|
1196
1042
|
t.add(r.name);
|
|
1197
1043
|
}
|
|
1198
1044
|
}
|
|
1199
|
-
function
|
|
1045
|
+
function Rt(e, t) {
|
|
1200
1046
|
if (!Array.isArray(e.resources) || e.resources.length > 64) throw new RangeError("模板包最多64个资源依赖");
|
|
1201
|
-
const r = /* @__PURE__ */ new Set(),
|
|
1047
|
+
const r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
|
|
1202
1048
|
let a = 0;
|
|
1203
1049
|
for (const o of e.resources) {
|
|
1204
|
-
if (
|
|
1050
|
+
if (lt(o, e.document), r.has(o.id)) throw new TypeError("模板资源ID重复");
|
|
1205
1051
|
if (r.add(o.id), a += o.bytes, a > t) throw new RangeError("模板包资源总大小超过预算");
|
|
1206
|
-
const
|
|
1207
|
-
if (
|
|
1208
|
-
|
|
1209
|
-
for (const
|
|
1210
|
-
const
|
|
1211
|
-
if (
|
|
1212
|
-
|
|
1052
|
+
const u = o.font && JSON.stringify([o.font.family, o.font.face]);
|
|
1053
|
+
if (u && s.has(u)) throw new TypeError("模板包字体family/face重复");
|
|
1054
|
+
u && s.add(u);
|
|
1055
|
+
for (const f of o.targets ?? []) {
|
|
1056
|
+
const c = JSON.stringify([f.pageIndex, f.componentPath]);
|
|
1057
|
+
if (n.has(c)) throw new TypeError("同一图片位置不能绑定多个资源");
|
|
1058
|
+
n.add(c);
|
|
1213
1059
|
}
|
|
1214
1060
|
}
|
|
1215
|
-
if (a +
|
|
1061
|
+
if (a + ve(e.document, e.resources) > t) throw new RangeError("模板包内嵌与外部资源总大小超过预算");
|
|
1216
1062
|
}
|
|
1217
|
-
function
|
|
1063
|
+
function xe(e, t = {}) {
|
|
1218
1064
|
h(t.signal);
|
|
1219
|
-
const r =
|
|
1065
|
+
const r = Q(t.maxBytes, 8e6, 32e6);
|
|
1220
1066
|
if (typeof e == "string") {
|
|
1221
1067
|
if (e.length > r || new TextEncoder().encode(e).byteLength > r) throw new RangeError("模板包JSON超过预算");
|
|
1222
1068
|
e = JSON.parse(e);
|
|
1223
1069
|
}
|
|
1224
|
-
const
|
|
1225
|
-
if (!
|
|
1226
|
-
return
|
|
1070
|
+
const n = Y(e, { maxBytes: r, check: () => h(t.signal), error: (s, a) => new TypeError(a) });
|
|
1071
|
+
if (!n || typeof n != "object" || Array.isArray(n) || n.schemaVersion !== "1.0" || Object.keys(n).some((s) => !["schemaVersion", "minimumVersion", "document", "contracts", "resources", "fixtures"].includes(s))) throw new TypeError("模板包结构或版本无效");
|
|
1072
|
+
return gt(n.minimumVersion, t.runtimeVersion ?? be), n.document = $(n.document), ht(n), xt(n), Rt(n, Q(t.maxResourceBytes, 32e6, 64e6)), n;
|
|
1227
1073
|
}
|
|
1228
|
-
function
|
|
1229
|
-
const r =
|
|
1230
|
-
for (const
|
|
1231
|
-
return
|
|
1074
|
+
function Zt(e, t = {}) {
|
|
1075
|
+
const r = Y(e, { maxBytes: Q(t.maxBytes, 8e6, 32e6), check: () => h(t.signal), error: (s, a) => new TypeError(a) }), n = xe({ schemaVersion: "1.0", ...r, minimumVersion: r.minimumVersion ?? be, resources: r.resources ?? [] }, t);
|
|
1076
|
+
for (const s of n.resources) for (const a of s.targets ?? []) delete U(n.document, a).imageData;
|
|
1077
|
+
return n;
|
|
1232
1078
|
}
|
|
1233
|
-
async function
|
|
1234
|
-
const { resolve: r, signal:
|
|
1079
|
+
async function Kt(e, t) {
|
|
1080
|
+
const { resolve: r, signal: n, maxDurationMs: s } = t, a = xe(e, t), o = await mt(a.document, a.resources, r, n, s);
|
|
1235
1081
|
return { document: a.document, fonts: o, contracts: a.contracts, fixtures: a.fixtures ?? [] };
|
|
1236
1082
|
}
|
|
1083
|
+
class x extends Error {
|
|
1084
|
+
constructor(t, r) {
|
|
1085
|
+
super(r), this.code = t, this.name = "ReportDocumentError";
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
function St(e = {}) {
|
|
1089
|
+
const t = { maxDocuments: e.maxDocuments ?? 32, maxBytes: e.maxBytes ?? 64e6, maxPages: e.maxPages ?? 1e4, maxPageBytes: e.maxPageBytes ?? 4e6, maxManifestBytes: e.maxManifestBytes ?? 1e6 };
|
|
1090
|
+
if (Object.values(t).some((r) => !Number.isSafeInteger(r) || r < 1)) throw new x("input", "文档预算应为正安全整数");
|
|
1091
|
+
return t;
|
|
1092
|
+
}
|
|
1093
|
+
function j(e, t, r) {
|
|
1094
|
+
if ([e, t, ...r === void 0 ? [] : [r]].some((n) => typeof n != "string" || !n.trim() || n.length > 256)) throw new x("input", "文档 scope、id、version 应为 1–256 位非空字符串");
|
|
1095
|
+
return JSON.stringify([e, t]);
|
|
1096
|
+
}
|
|
1097
|
+
function O(e, t, r) {
|
|
1098
|
+
return Y(e, { maxBytes: t, maxNodes: t, check: () => h(r), error: (n, s) => new x(n === "budget" ? "capacity" : "input", s) });
|
|
1099
|
+
}
|
|
1100
|
+
function D(e) {
|
|
1101
|
+
return new TextEncoder().encode(JSON.stringify(e)).byteLength;
|
|
1102
|
+
}
|
|
1103
|
+
function de(e) {
|
|
1104
|
+
if (!e || e.schemaVersion !== $e || "pages" in e || e.requiresRecalculation !== void 0 && typeof e.requiresRecalculation != "boolean") throw new x("input", "文档计划头应使用当前版本,且不得携带 pages");
|
|
1105
|
+
}
|
|
1106
|
+
function L(e, t) {
|
|
1107
|
+
e.bytes = 0;
|
|
1108
|
+
for (let r = 0; r < 8; r++) {
|
|
1109
|
+
const n = t + D(e);
|
|
1110
|
+
if (n === e.bytes) return;
|
|
1111
|
+
e.bytes = n;
|
|
1112
|
+
}
|
|
1113
|
+
throw new x("capacity", "文档容量统计无效");
|
|
1114
|
+
}
|
|
1115
|
+
function It(e, t, r = []) {
|
|
1116
|
+
const n = /* @__PURE__ */ new Map();
|
|
1117
|
+
let s = 0, a = Promise.resolve();
|
|
1118
|
+
for (const i of r) {
|
|
1119
|
+
const d = j(i.scope, i.id, i.version);
|
|
1120
|
+
if (de(i.plan), n.has(d) || !Number.isSafeInteger(i.bytes) || i.bytes < 0 || !Number.isSafeInteger(i.pageCount) || i.pageCount < 0 || i.pageCount > t.maxPages || !["building", "complete", "failed"].includes(i.state) || i.revision !== i.pageCount + (i.state === "building" ? 0 : 1)) throw new x("input", "文档清单无效");
|
|
1121
|
+
n.set(d, O(i, t.maxManifestBytes)), s += i.bytes;
|
|
1122
|
+
}
|
|
1123
|
+
function o(i, d) {
|
|
1124
|
+
if (s - (d?.bytes ?? 0) + i.bytes > t.maxBytes || !d && n.size >= t.maxDocuments) throw new x("capacity", "文档存储容量已满,请显式清理旧文档");
|
|
1125
|
+
}
|
|
1126
|
+
if (n.size > t.maxDocuments || s > t.maxBytes) throw new x("capacity", "已存文档超过预算");
|
|
1127
|
+
const u = (i) => {
|
|
1128
|
+
const d = a.then(i);
|
|
1129
|
+
return a = d.then(() => {
|
|
1130
|
+
}, () => {
|
|
1131
|
+
}), d;
|
|
1132
|
+
}, f = (i, d, l, p) => {
|
|
1133
|
+
const w = n.get(j(i, d, l));
|
|
1134
|
+
if (!w) throw new x("missing", "文档不存在");
|
|
1135
|
+
if (w.version !== l || p !== void 0 && w.revision !== p) throw new x("conflict", "文档已变化,请重新读取清单");
|
|
1136
|
+
return w;
|
|
1137
|
+
}, c = async (i, d, l) => {
|
|
1138
|
+
const p = O(i, t.maxManifestBytes);
|
|
1139
|
+
return o(p, d), await e.write(p, l), n.set(j(i.scope, i.id), p), s += i.bytes - (d?.bytes ?? 0), O(p, t.maxManifestBytes);
|
|
1140
|
+
};
|
|
1141
|
+
return {
|
|
1142
|
+
create: (i, d) => {
|
|
1143
|
+
const l = O(i, t.maxManifestBytes, d), p = j(l.scope, l.id, l.version);
|
|
1144
|
+
return de(l.plan), u(async () => {
|
|
1145
|
+
if (h(d), n.has(p)) throw new x("conflict", "文档已存在,不可覆盖");
|
|
1146
|
+
const w = { ...l, revision: 0, state: "building", pageCount: 0, bytes: 0 };
|
|
1147
|
+
return L(w, 0), c(w);
|
|
1148
|
+
});
|
|
1149
|
+
},
|
|
1150
|
+
append: (i, d, l, p, w, g) => {
|
|
1151
|
+
const y = O(w, t.maxPageBytes, g), m = le({ pages: [y] });
|
|
1152
|
+
if (!m.ok) throw new x("input", m.errors[0].message);
|
|
1153
|
+
return u(async () => {
|
|
1154
|
+
h(g);
|
|
1155
|
+
const v = f(i, d, l, p);
|
|
1156
|
+
if (v.state !== "building") throw new x("conflict", "已完成文档不可追加");
|
|
1157
|
+
if (v.pageCount >= t.maxPages) throw new x("capacity", "文档页数超过预算");
|
|
1158
|
+
const N = { ...v, revision: p + 1, pageCount: v.pageCount + 1 };
|
|
1159
|
+
return L(N, v.bytes - D(v) + D(y)), c(N, v, { index: v.pageCount, value: y });
|
|
1160
|
+
});
|
|
1161
|
+
},
|
|
1162
|
+
complete: (i, d, l, p, w, g) => {
|
|
1163
|
+
const y = w === void 0 ? void 0 : O(w, t.maxManifestBytes, g);
|
|
1164
|
+
return y && pe({ ...y }), u(async () => {
|
|
1165
|
+
h(g);
|
|
1166
|
+
const m = f(i, d, l, p);
|
|
1167
|
+
if (m.state !== "building") throw new x("conflict", "文档已完成");
|
|
1168
|
+
if (y && y.stats.pages !== m.pageCount) throw new x("input", "准备结果页数与文档页数不一致");
|
|
1169
|
+
const v = { ...m, revision: p + 1, state: "complete", ...y ? { metadata: y } : {} };
|
|
1170
|
+
return L(v, m.bytes - D(m)), c(v, m);
|
|
1171
|
+
});
|
|
1172
|
+
},
|
|
1173
|
+
fail: (i, d, l, p, w) => {
|
|
1174
|
+
const g = O(w, 4096);
|
|
1175
|
+
if (!g || !["cancelled", "generation"].includes(g.code) || typeof g.message != "string" || !g.message.trim() || g.message.length > 1024) throw new x("input", "文档失败状态无效");
|
|
1176
|
+
return u(async () => {
|
|
1177
|
+
const y = f(i, d, l, p);
|
|
1178
|
+
if (y.state !== "building") throw new x("conflict", "终态文档不可变更");
|
|
1179
|
+
const m = { ...y, state: "failed", revision: p + 1, failure: g };
|
|
1180
|
+
return L(m, y.bytes - D(y)), c(m, y);
|
|
1181
|
+
});
|
|
1182
|
+
},
|
|
1183
|
+
read: async (i, d, l) => {
|
|
1184
|
+
h(l);
|
|
1185
|
+
const p = j(i, d);
|
|
1186
|
+
await a, h(l);
|
|
1187
|
+
const w = n.get(p);
|
|
1188
|
+
return w ? O(w, t.maxManifestBytes) : void 0;
|
|
1189
|
+
},
|
|
1190
|
+
readPage: (i, d, l, p, w) => u(async () => {
|
|
1191
|
+
h(w);
|
|
1192
|
+
const g = f(i, d, l);
|
|
1193
|
+
if (!Number.isSafeInteger(p) || p < 0) throw new x("input", "页索引应为非负安全整数");
|
|
1194
|
+
if (p >= g.pageCount) return;
|
|
1195
|
+
const y = await e.readPage(i, d, p);
|
|
1196
|
+
if (h(w), !y) throw new x("missing", "已提交的文档页缺失");
|
|
1197
|
+
return O(y, t.maxPageBytes, w);
|
|
1198
|
+
}),
|
|
1199
|
+
remove: (i, d, l, p) => u(async () => {
|
|
1200
|
+
h(p);
|
|
1201
|
+
const w = j(i, d, l), g = n.get(w);
|
|
1202
|
+
return g ? (f(i, d, l), await e.remove(g), n.delete(w), s -= g.bytes, !0) : !1;
|
|
1203
|
+
})
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
function Xt(e = {}) {
|
|
1207
|
+
const t = /* @__PURE__ */ new Map();
|
|
1208
|
+
return It({
|
|
1209
|
+
write: async (r, n) => {
|
|
1210
|
+
if (!n) return;
|
|
1211
|
+
const s = j(r.scope, r.id), a = t.get(s) ?? [];
|
|
1212
|
+
a[n.index] = n.value, t.set(s, a);
|
|
1213
|
+
},
|
|
1214
|
+
readPage: async (r, n, s) => t.get(j(r, n))?.[s],
|
|
1215
|
+
remove: async (r) => {
|
|
1216
|
+
t.delete(j(r.scope, r.id));
|
|
1217
|
+
}
|
|
1218
|
+
}, St(e));
|
|
1219
|
+
}
|
|
1220
|
+
async function Gt(e, t) {
|
|
1221
|
+
const r = t.fromPage ?? 0, n = t.limit ?? 4, s = t.maxBytes ?? 8e6;
|
|
1222
|
+
if (!Number.isSafeInteger(r) || r < 0 || !Number.isSafeInteger(n) || n < 1 || n > 32 || !Number.isSafeInteger(s) || s < 1) throw new x("input", "页窗口参数无效;每次最多读取 32 页");
|
|
1223
|
+
const a = await e.read(t.scope, t.id, t.signal);
|
|
1224
|
+
if (!a) throw new x("missing", "文档不存在");
|
|
1225
|
+
if (a.version !== t.version) throw new x("conflict", "文档版本已变化");
|
|
1226
|
+
const o = [];
|
|
1227
|
+
let u = 0, f = Math.min(r, a.pageCount);
|
|
1228
|
+
for (; f < Math.min(a.pageCount, r + n); f++) {
|
|
1229
|
+
const c = await e.readPage(t.scope, t.id, t.version, f, t.signal);
|
|
1230
|
+
if (!c) throw new x("missing", "文档页缺失");
|
|
1231
|
+
const i = D(c);
|
|
1232
|
+
if (u + i > s) {
|
|
1233
|
+
if (!o.length) throw new x("capacity", "单页超过读取窗口预算");
|
|
1234
|
+
break;
|
|
1235
|
+
}
|
|
1236
|
+
o.push(c), u += i;
|
|
1237
|
+
}
|
|
1238
|
+
return { manifest: a, pages: o, nextPage: f };
|
|
1239
|
+
}
|
|
1240
|
+
async function Qt(e, t) {
|
|
1241
|
+
const { scope: r, id: n, version: s, signal: a, pages: o } = t, u = t.metadata === void 0 ? void 0 : O(t.metadata, 1e6, a);
|
|
1242
|
+
let f = await e.create({ scope: r, id: n, version: s, plan: t.plan }, a), c;
|
|
1243
|
+
try {
|
|
1244
|
+
const i = Symbol.asyncIterator in o ? o[Symbol.asyncIterator]() : o[Symbol.iterator]();
|
|
1245
|
+
for (c = i; ; ) {
|
|
1246
|
+
const d = await T(a, void 0, () => Promise.resolve(i.next()));
|
|
1247
|
+
if (d.done) break;
|
|
1248
|
+
f = await e.append(r, n, s, f.revision, d.value, a);
|
|
1249
|
+
}
|
|
1250
|
+
return await e.complete(r, n, s, f.revision, u, a);
|
|
1251
|
+
} catch (i) {
|
|
1252
|
+
throw Promise.resolve(c?.return?.()).catch(() => {
|
|
1253
|
+
}), await e.fail(r, n, s, f.revision, a?.aborted ? { code: "cancelled", message: "报表文档生成已取消" } : { code: "generation", message: "报表文档生成失败" }).catch(() => {
|
|
1254
|
+
}), i;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
const Et = "1.0", ue = Object.freeze({ params: 422, validate: 422, fetch: 502, config: 400, input: 400, budget: 413, capacity: 413, timeout: 504, "queue-full": 429, closed: 503, cancelled: 499, "output-fidelity": 422, conflict: 409, missing: 404 });
|
|
1258
|
+
function V(e) {
|
|
1259
|
+
return e && typeof e == "object" ? e : {};
|
|
1260
|
+
}
|
|
1261
|
+
function kt(e) {
|
|
1262
|
+
if (Array.isArray(e))
|
|
1263
|
+
return e.slice(0, 100).map((t) => Object.fromEntries(["code", "path", "field", "message"].flatMap((r) => typeof V(t)[r] == "string" ? [[r, V(t)[r].slice(0, 4096)]] : [])));
|
|
1264
|
+
}
|
|
1265
|
+
function Wt(e, t) {
|
|
1266
|
+
const r = V(e), n = r.name === "AbortError" ? "cancelled" : r.code, s = typeof n == "string" && Object.prototype.hasOwnProperty.call(ue, n) ? n : "internal", a = s === "internal" ? void 0 : kt(r.issues ?? V(r.cause).issues);
|
|
1267
|
+
return { status: ue[s] ?? 500, body: { error: {
|
|
1268
|
+
code: s,
|
|
1269
|
+
message: s === "internal" ? "Report execution failed" : typeof r.message == "string" ? r.message.slice(0, 4096) : "Report request failed",
|
|
1270
|
+
correlationId: t.slice(0, 128),
|
|
1271
|
+
...s !== "internal" && typeof r.path == "string" ? { path: r.path.slice(0, 4096) } : {},
|
|
1272
|
+
...a ? { issues: a } : {}
|
|
1273
|
+
} } };
|
|
1274
|
+
}
|
|
1275
|
+
function K(e, t, r) {
|
|
1276
|
+
return { description: r, headers: { "X-Request-Id": { schema: { type: "string" }, description: "Request correlation identity" } }, content: { [e]: { schema: t } } };
|
|
1277
|
+
}
|
|
1278
|
+
function Ot(e) {
|
|
1279
|
+
return {
|
|
1280
|
+
type: "object",
|
|
1281
|
+
additionalProperties: !1,
|
|
1282
|
+
properties: Object.fromEntries(e.params.map((t) => [t.field, { type: "string" }])),
|
|
1283
|
+
required: e.params.filter((t) => t.required && t.defaultValue === void 0).map((t) => t.field),
|
|
1284
|
+
"x-report-typedSchema": e.paramsSchema
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
function Yt(e, t = {}) {
|
|
1288
|
+
const r = t.basePath ?? "/reports";
|
|
1289
|
+
if (!/^\/[A-Za-z0-9/_-]*[A-Za-z0-9_-]$/.test(r)) throw new Error("OpenAPI basePath 应为不含查询串、参数和尾斜线的绝对路径");
|
|
1290
|
+
const n = {
|
|
1291
|
+
[r]: { get: { operationId: "describeReports", responses: { 200: K("application/json", { type: "array", items: { type: "object" } }, "Authorized report descriptions") } } }
|
|
1292
|
+
}, s = /* @__PURE__ */ new Set();
|
|
1293
|
+
for (const a of e) {
|
|
1294
|
+
if (!a.id.trim() || s.has(a.id) || [".", ".."].includes(a.id)) throw new Error("OpenAPI 报表 ID 应非空、唯一且不是路径跳转段");
|
|
1295
|
+
s.add(a.id);
|
|
1296
|
+
for (const o of ["prepare", "pdf", "xlsx"]) {
|
|
1297
|
+
const u = o === "prepare" ? "prepare" : `export/${o}`, f = o !== "prepare", c = { 200: K(f ? o === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "application/json", f ? { type: "string", format: "binary" } : { type: "object", required: ["plan", "stats", "diagnostics", "revisions"] }, f ? "Report file" : "Prepared report snapshot") };
|
|
1298
|
+
for (const i of [400, 413, 422, 429, 499, 500, 502, 503, 504]) c[String(i)] = K("application/json", { $ref: "#/components/schemas/ReportError" }, "Structured report error");
|
|
1299
|
+
n[`${r}/${encodeURIComponent(a.id)}/${u}`] = { post: {
|
|
1300
|
+
operationId: `report_${s.size}_${o}`,
|
|
1301
|
+
parameters: [{ in: "header", name: "X-Request-Id", schema: { type: "string", pattern: "^[A-Za-z0-9._-]{1,80}$" } }],
|
|
1302
|
+
requestBody: { required: !0, content: { "application/json": { schema: { type: "object", required: ["params"], additionalProperties: !1, properties: { params: Ot(a) } } } } },
|
|
1303
|
+
responses: c,
|
|
1304
|
+
"x-report-datasets": a.datasetsSchema
|
|
1305
|
+
} };
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
return {
|
|
1309
|
+
openapi: "3.1.0",
|
|
1310
|
+
info: { title: t.title ?? "MachReport HTTP", version: t.version ?? Et },
|
|
1311
|
+
paths: n,
|
|
1312
|
+
components: { schemas: { ReportError: { type: "object", required: ["error"], properties: { error: { type: "object", required: ["code", "message", "correlationId"], properties: { code: { type: "string" }, message: { type: "string" }, correlationId: { type: "string" }, path: { type: "string" }, issues: { type: "array", items: { type: "object", additionalProperties: { type: "string" } } } } } } } } }
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1237
1315
|
export {
|
|
1238
|
-
|
|
1316
|
+
Et as REPORT_HTTP_CONTRACT_VERSION,
|
|
1317
|
+
x as ReportDocumentError,
|
|
1318
|
+
b as ReportInstanceError,
|
|
1239
1319
|
R as ReportJobError,
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1320
|
+
A as ReportRuntimeError,
|
|
1321
|
+
J as checkInstanceIdentity,
|
|
1322
|
+
X as checkJobIdentity,
|
|
1323
|
+
H as cloneJob,
|
|
1324
|
+
it as createManagerTemplateCatalog,
|
|
1325
|
+
Xt as createMemoryReportDocumentStore,
|
|
1326
|
+
ct as createMemoryReportInstanceIds,
|
|
1327
|
+
Ft as createMemoryReportInstanceStore,
|
|
1328
|
+
rr as createMemoryReportJobStore,
|
|
1329
|
+
Qe as createReportGenerationService,
|
|
1330
|
+
Xe as createReportInstanceManager,
|
|
1331
|
+
_t as createReportJobService,
|
|
1332
|
+
Yt as createReportOpenApi,
|
|
1333
|
+
W as createReportRuntime,
|
|
1334
|
+
zt as createReportTaskQueue,
|
|
1335
|
+
Zt as createReportTemplatePackage,
|
|
1336
|
+
Ut as createReportWorkflow,
|
|
1337
|
+
xe as parseReportTemplatePackage,
|
|
1338
|
+
Gt as readReportDocumentPages,
|
|
1339
|
+
Wt as reportHttpError,
|
|
1340
|
+
Vt as reportInstanceParameterKey,
|
|
1341
|
+
Ze as reportInstanceSummary,
|
|
1342
|
+
wt as reportPackageResourceDigest,
|
|
1343
|
+
Kt as resolveReportTemplatePackage,
|
|
1344
|
+
Lt as reviewReportPublication,
|
|
1345
|
+
Ht as runLabelStream,
|
|
1346
|
+
Oe as runReportBatch,
|
|
1347
|
+
nr as runnableJob,
|
|
1348
|
+
ot as saveAndPublishReportTemplate,
|
|
1349
|
+
P as serializeJobJson,
|
|
1350
|
+
sr as snapshotReportBatchCases,
|
|
1351
|
+
G as snapshotReportInstance,
|
|
1352
|
+
ar as validateJobRecord,
|
|
1353
|
+
or as validateJobTransition,
|
|
1354
|
+
Qt as writeReportDocument
|
|
1270
1355
|
};
|