@agile-team/mach-report 2.5.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +91 -14
  2. package/dist/ReportPreview-Dk-28QAi.js +2946 -0
  3. package/dist/ReportPreview-FSvcBLjH.cjs +6 -0
  4. package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
  5. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  6. package/dist/analytics.cjs +1 -0
  7. package/dist/analytics.d.cts +276 -0
  8. package/dist/analytics.d.ts +276 -0
  9. package/dist/analytics.js +223 -0
  10. package/dist/assets-66UBlhES.cjs +1 -0
  11. package/dist/assets-NVA_sftu.js +163 -0
  12. package/dist/capabilities-CNjIirfo.js +36 -0
  13. package/dist/capabilities-D4xeVYSR.cjs +1 -0
  14. package/dist/designer.cjs +1 -0
  15. package/dist/designer.d.cts +753 -0
  16. package/dist/designer.d.ts +753 -0
  17. package/dist/designer.js +372 -0
  18. package/dist/grid-geometry-BNptEcMm.js +65 -0
  19. package/dist/grid-geometry-CZ_cYB6O.cjs +1 -0
  20. package/dist/index.cjs +8 -5
  21. package/dist/index.d.cts +413 -8
  22. package/dist/index.d.ts +413 -8
  23. package/dist/index.js +1016 -1501
  24. package/dist/param-validation-BWNjLcN0.js +116 -0
  25. package/dist/param-validation-CiTxFeZ8.cjs +1 -0
  26. package/dist/pdf.cjs +48 -48
  27. package/dist/pdf.d.cts +111 -1
  28. package/dist/pdf.d.ts +111 -1
  29. package/dist/pdf.js +3931 -3868
  30. package/dist/{plugin-DMPLDpBY.cjs → plugin-BqBkn_kI.cjs} +1 -1
  31. package/dist/{plugin-DDLcFWlk.js → plugin-Ds10VnQO.js} +2 -2
  32. package/dist/render-plan-CckPEQyf.cjs +1 -0
  33. package/dist/{render-plan-CXBWRog4.js → render-plan-uzZYYSy1.js} +11 -10
  34. package/dist/report-params-B_VCihAh.js +12 -0
  35. package/dist/report-params-CjWrjPl6.cjs +1 -0
  36. package/dist/report-source-B9bENO0F.js +750 -0
  37. package/dist/report-source-BbNkkBDy.cjs +1 -0
  38. package/dist/server/node.d.cts +297 -0
  39. package/dist/server/node.d.ts +297 -0
  40. package/dist/server-node.cjs +1 -0
  41. package/dist/server-node.js +270 -0
  42. package/dist/server.cjs +1 -0
  43. package/dist/server.d.cts +643 -0
  44. package/dist/server.d.ts +643 -0
  45. package/dist/server.js +237 -0
  46. package/dist/style-CpwiOPyB.cjs +1 -0
  47. package/dist/style-Dv5o_x6b.js +67 -0
  48. package/dist/style.css +1 -1
  49. package/dist/template-registry-DWExx0gU.cjs +1 -0
  50. package/dist/template-registry-NpOakidD.js +354 -0
  51. package/dist/textwrap-CnGsEum6.cjs +4 -0
  52. package/dist/textwrap-DOl04hCQ.js +110 -0
  53. package/dist/validate-DfHPD8wX.cjs +1 -0
  54. package/dist/validate-S6CgIm5d.js +148 -0
  55. package/dist/vue/async.d.cts +602 -57
  56. package/dist/vue/async.d.ts +602 -57
  57. package/dist/vue/index.d.cts +1074 -111
  58. package/dist/vue/index.d.ts +1074 -111
  59. package/dist/vue-async.cjs +1 -1
  60. package/dist/vue-async.js +3 -3
  61. package/dist/vue.cjs +1 -1
  62. package/dist/vue.js +167 -82
  63. package/dist/worker.cjs +1 -0
  64. package/dist/worker.d.cts +302 -0
  65. package/dist/worker.d.ts +302 -0
  66. package/dist/worker.js +133 -0
  67. package/dist/xlsx/node.d.cts +47 -0
  68. package/dist/xlsx/node.d.ts +47 -0
  69. package/dist/xlsx-node.cjs +221 -0
  70. package/dist/xlsx-node.js +36409 -0
  71. package/dist/xlsx.cjs +20 -20
  72. package/dist/xlsx.d.cts +78 -1
  73. package/dist/xlsx.d.ts +78 -1
  74. package/dist/xlsx.js +5974 -5831
  75. package/package.json +62 -2
  76. package/dist/ReportPreview-CBKLI--k.js +0 -2188
  77. package/dist/ReportPreview-ClM8h0pM.cjs +0 -6
  78. package/dist/grid-geometry-BNIvw52m.cjs +0 -1
  79. package/dist/grid-geometry-C8hGoe9o.js +0 -130
  80. package/dist/render-plan-CCTL4F9v.cjs +0 -1
  81. package/dist/report-params-B3Fia6JO.js +0 -10
  82. package/dist/report-params-D1gZ1DME.cjs +0 -1
  83. package/dist/textwrap-nH0UYU6D.js +0 -108
  84. package/dist/textwrap-oD-t4b4B.cjs +0 -4
@@ -0,0 +1,116 @@
1
+ class l extends Error {
2
+ constructor(e) {
3
+ super(e.map((i) => `${i.field}: ${i.message}`).join("; ")), this.issues = e, this.code = "params", this.name = "ReportParamValidationError";
4
+ }
5
+ }
6
+ function c(t) {
7
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(t) || t.startsWith("0000-")) return !1;
8
+ const e = /* @__PURE__ */ new Date(`${t}T00:00:00.000Z`);
9
+ return Number.isFinite(e.getTime()) && e.toISOString().slice(0, 10) === t;
10
+ }
11
+ function h(t) {
12
+ return /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(t) && Number.isFinite(Number(t));
13
+ }
14
+ function y(t, e) {
15
+ if (t.type === "number" && !h(e)) return [["type", "应为有限数字"]];
16
+ if (t.type === "date" && !c(e)) return [["type", "应为有效的 YYYY-MM-DD 日期"]];
17
+ const i = [];
18
+ t.type === "select" && t.options && !t.options.some((r) => r.value === e) && i.push(["option", "不在允许的选项中"]);
19
+ const n = Array.from(e).length;
20
+ t.minLength !== void 0 && n < t.minLength && i.push(["minLength", `至少 ${t.minLength} 个字符`]), t.maxLength !== void 0 && n > t.maxLength && i.push(["maxLength", `最多 ${t.maxLength} 个字符`]);
21
+ const s = t.type === "number" ? Number(e) : e;
22
+ return t.min !== void 0 && s < t.min && i.push(["minimum", `不能小于 ${t.min}`]), t.max !== void 0 && s > t.max && i.push(["maximum", `不能大于 ${t.max}`]), i;
23
+ }
24
+ function g(t) {
25
+ const e = [];
26
+ for (const s of ["min", "max"]) {
27
+ const r = t[s];
28
+ if (r === void 0) continue;
29
+ (t.type === "date" ? typeof r == "string" && c(r) : t.type === "number" && typeof r == "number" && Number.isFinite(r)) || e.push(`${s} 应为 number 的有限数字边界或 date 的有效日期边界`);
30
+ }
31
+ const i = typeof t.min == "number" && typeof t.max == "number" && t.min > t.max, n = typeof t.min == "string" && typeof t.max == "string" && t.min > t.max;
32
+ return (i || n) && e.push("最小边界不能大于最大边界"), [...e, ...f(t)];
33
+ }
34
+ function f(t) {
35
+ const e = [];
36
+ t.type === "number" && (t.minLength !== void 0 || t.maxLength !== void 0) && e.push("number 参数使用 min/max 而不是文本长度约束");
37
+ for (const i of ["minLength", "maxLength"]) {
38
+ const n = t[i];
39
+ n !== void 0 && (!Number.isSafeInteger(n) || n < 0) && e.push(`${i} 应为非负整数`);
40
+ }
41
+ return typeof t.minLength == "number" && typeof t.maxLength == "number" && t.minLength > t.maxLength && e.push("最小长度不能大于最大长度"), e;
42
+ }
43
+ function b(t) {
44
+ if (!Array.isArray(t)) return [{ code: "definition", field: "", path: "$.paramDefs", message: "参数定义应为数组" }];
45
+ const e = /* @__PURE__ */ new Set();
46
+ return t.flatMap((i, n) => {
47
+ const s = i && typeof i.field == "string" ? i.field : "";
48
+ return L(i, e).map((a) => ({ code: "definition", field: s, path: `$.paramDefs.${n}`, message: a }));
49
+ });
50
+ }
51
+ function x(t) {
52
+ return Array.isArray(t) && t.every((e) => !!e && typeof e == "object" && typeof e.value == "string" && typeof e.label == "string");
53
+ }
54
+ function v(t) {
55
+ const e = [];
56
+ return t.type !== void 0 && !["text", "number", "date", "select"].includes(t.type) && e.push("未知参数类型"), t.label !== void 0 && typeof t.label != "string" && e.push("参数标签应为字符串"), t.required !== void 0 && typeof t.required != "boolean" && e.push("required 应为布尔值"), t.defaultValue !== void 0 && typeof t.defaultValue != "string" && e.push("默认值应为字符串"), t.options !== void 0 && !x(t.options) && e.push("选项应为包含字符串 label/value 的数组"), e;
57
+ }
58
+ function L(t, e) {
59
+ if (!t || typeof t != "object" || Array.isArray(t)) return ["参数定义项应为对象"];
60
+ const i = v(t);
61
+ return typeof t.field != "string" || !t.field.trim() || e.has(t.field) ? i.push("参数名应为非空且不重复的字符串") : e.add(t.field), i.length || (i.push(...g(t)), i.length) || (t.options && new Set(t.options.map((n) => n.value)).size !== t.options.length && i.push("选项值不能重复"), t.defaultValue !== void 0 && (t.required && !t.defaultValue.trim() ? i.push("必填参数的默认值不能为空") : t.defaultValue.trim() && i.push(...y(t, t.defaultValue).map(([, n]) => `默认值${n}`)))), i;
62
+ }
63
+ function $(t, e, i) {
64
+ for (const [n, s] of Object.entries(t))
65
+ (typeof s == "string" || typeof s == "number" && Number.isFinite(s)) && (Object.defineProperty(e, n, { value: String(s), writable: !0, enumerable: !0, configurable: !0 }), Object.defineProperty(i, n, { value: s, writable: !0, enumerable: !0, configurable: !0 }));
66
+ }
67
+ function d(t) {
68
+ return t == null || typeof t == "string" && !t.trim();
69
+ }
70
+ function V(t, e = {}) {
71
+ const i = /* @__PURE__ */ Object.create(null), n = /* @__PURE__ */ Object.create(null), s = b(t);
72
+ if ((!e || typeof e != "object" || Array.isArray(e)) && s.push({ code: "type", field: "", path: "$.params", message: "参数应为对象" }), s.length) return { ok: !1, values: i, typedValues: n, issues: s };
73
+ $(e, i, n);
74
+ for (const r of t) {
75
+ const a = Object.prototype.hasOwnProperty.call(e, r.field) && e[r.field] !== void 0 ? e[r.field] : r.defaultValue, u = (m, p) => s.push({ code: m, path: `$.params.${r.field}`, field: r.field, message: p });
76
+ if (d(a)) {
77
+ r.required && u("required", "此参数为必填项"), typeof a == "string" && (i[r.field] = a), delete n[r.field];
78
+ continue;
79
+ }
80
+ if (typeof a != "string" && !(typeof a == "number" && Number.isFinite(a))) {
81
+ u("type", "参数应为字符串或有限数字");
82
+ continue;
83
+ }
84
+ const o = String(a);
85
+ i[r.field] = o, y(r, o).forEach(([m, p]) => u(m, p)), n[r.field] = r.type === "number" && h(o) ? Number(o) : o;
86
+ }
87
+ return { ok: s.length === 0, values: i, typedValues: n, issues: s };
88
+ }
89
+ function w(t, e = {}) {
90
+ const i = V(t, e);
91
+ if (!i.ok) throw new l(i.issues);
92
+ return i.values;
93
+ }
94
+ function j(t) {
95
+ const e = { type: t.type === "number" ? "number" : "string", title: t.label ?? t.field };
96
+ return t.type === "date" && (e.format = "date"), t.required && t.type !== "number" && (e.pattern = "\\S"), t.type === "select" && t.options && (e.enum = t.options.map((i) => i.value)), t.defaultValue !== void 0 && (t.type !== "number" || t.defaultValue.trim()) && (e.default = t.type === "number" ? Number(t.defaultValue) : t.defaultValue), t.minLength !== void 0 && (e.minLength = t.minLength), t.maxLength !== void 0 && (e.maxLength = t.maxLength), typeof t.min == "number" && (e.minimum = t.min), typeof t.max == "number" && (e.maximum = t.max), typeof t.min == "string" && (e["x-report-minimum"] = t.min), typeof t.max == "string" && (e["x-report-maximum"] = t.max), e;
97
+ }
98
+ function O(t) {
99
+ const e = b(t);
100
+ if (e.length) throw new l(e);
101
+ return {
102
+ $schema: "https://json-schema.org/draft/2020-12/schema",
103
+ type: "object",
104
+ properties: Object.fromEntries(t.map((i) => [i.field, j(i)])),
105
+ required: t.filter((i) => i.required).map((i) => i.field),
106
+ additionalProperties: !0
107
+ };
108
+ }
109
+ export {
110
+ l as R,
111
+ w as a,
112
+ V as b,
113
+ c as i,
114
+ O as r,
115
+ b as v
116
+ };
@@ -0,0 +1 @@
1
+ "use strict";class l extends Error{constructor(e){super(e.map(i=>`${i.field}: ${i.message}`).join("; ")),this.issues=e,this.code="params",this.name="ReportParamValidationError"}}function c(t){if(!/^\d{4}-\d{2}-\d{2}$/.test(t)||t.startsWith("0000-"))return!1;const e=new Date(`${t}T00:00:00.000Z`);return Number.isFinite(e.getTime())&&e.toISOString().slice(0,10)===t}function y(t){return/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(t)&&Number.isFinite(Number(t))}function b(t,e){if(t.type==="number"&&!y(e))return[["type","应为有限数字"]];if(t.type==="date"&&!c(e))return[["type","应为有效的 YYYY-MM-DD 日期"]];const i=[];t.type==="select"&&t.options&&!t.options.some(n=>n.value===e)&&i.push(["option","不在允许的选项中"]);const r=Array.from(e).length;t.minLength!==void 0&&r<t.minLength&&i.push(["minLength",`至少 ${t.minLength} 个字符`]),t.maxLength!==void 0&&r>t.maxLength&&i.push(["maxLength",`最多 ${t.maxLength} 个字符`]);const s=t.type==="number"?Number(e):e;return t.min!==void 0&&s<t.min&&i.push(["minimum",`不能小于 ${t.min}`]),t.max!==void 0&&s>t.max&&i.push(["maximum",`不能大于 ${t.max}`]),i}function f(t){const e=[];for(const s of["min","max"]){const n=t[s];if(n===void 0)continue;(t.type==="date"?typeof n=="string"&&c(n):t.type==="number"&&typeof n=="number"&&Number.isFinite(n))||e.push(`${s} 应为 number 的有限数字边界或 date 的有效日期边界`)}const i=typeof t.min=="number"&&typeof t.max=="number"&&t.min>t.max,r=typeof t.min=="string"&&typeof t.max=="string"&&t.min>t.max;return(i||r)&&e.push("最小边界不能大于最大边界"),[...e,...x(t)]}function x(t){const e=[];t.type==="number"&&(t.minLength!==void 0||t.maxLength!==void 0)&&e.push("number 参数使用 min/max 而不是文本长度约束");for(const i of["minLength","maxLength"]){const r=t[i];r!==void 0&&(!Number.isSafeInteger(r)||r<0)&&e.push(`${i} 应为非负整数`)}return typeof t.minLength=="number"&&typeof t.maxLength=="number"&&t.minLength>t.maxLength&&e.push("最小长度不能大于最大长度"),e}function h(t){if(!Array.isArray(t))return[{code:"definition",field:"",path:"$.paramDefs",message:"参数定义应为数组"}];const e=new Set;return t.flatMap((i,r)=>{const s=i&&typeof i.field=="string"?i.field:"";return d(i,e).map(a=>({code:"definition",field:s,path:`$.paramDefs.${r}`,message:a}))})}function v(t){return Array.isArray(t)&&t.every(e=>!!e&&typeof e=="object"&&typeof e.value=="string"&&typeof e.label=="string")}function L(t){const e=[];return t.type!==void 0&&!["text","number","date","select"].includes(t.type)&&e.push("未知参数类型"),t.label!==void 0&&typeof t.label!="string"&&e.push("参数标签应为字符串"),t.required!==void 0&&typeof t.required!="boolean"&&e.push("required 应为布尔值"),t.defaultValue!==void 0&&typeof t.defaultValue!="string"&&e.push("默认值应为字符串"),t.options!==void 0&&!v(t.options)&&e.push("选项应为包含字符串 label/value 的数组"),e}function d(t,e){if(!t||typeof t!="object"||Array.isArray(t))return["参数定义项应为对象"];const i=L(t);return typeof t.field!="string"||!t.field.trim()||e.has(t.field)?i.push("参数名应为非空且不重复的字符串"):e.add(t.field),i.length||(i.push(...f(t)),i.length)||(t.options&&new Set(t.options.map(r=>r.value)).size!==t.options.length&&i.push("选项值不能重复"),t.defaultValue!==void 0&&(t.required&&!t.defaultValue.trim()?i.push("必填参数的默认值不能为空"):t.defaultValue.trim()&&i.push(...b(t,t.defaultValue).map(([,r])=>`默认值${r}`)))),i}function $(t,e,i){for(const[r,s]of Object.entries(t))(typeof s=="string"||typeof s=="number"&&Number.isFinite(s))&&(Object.defineProperty(e,r,{value:String(s),writable:!0,enumerable:!0,configurable:!0}),Object.defineProperty(i,r,{value:s,writable:!0,enumerable:!0,configurable:!0}))}function V(t){return t==null||typeof t=="string"&&!t.trim()}function g(t,e={}){const i=Object.create(null),r=Object.create(null),s=h(t);if((!e||typeof e!="object"||Array.isArray(e))&&s.push({code:"type",field:"",path:"$.params",message:"参数应为对象"}),s.length)return{ok:!1,values:i,typedValues:r,issues:s};$(e,i,r);for(const n of t){const a=Object.prototype.hasOwnProperty.call(e,n.field)&&e[n.field]!==void 0?e[n.field]:n.defaultValue,u=(m,p)=>s.push({code:m,path:`$.params.${n.field}`,field:n.field,message:p});if(V(a)){n.required&&u("required","此参数为必填项"),typeof a=="string"&&(i[n.field]=a),delete r[n.field];continue}if(typeof a!="string"&&!(typeof a=="number"&&Number.isFinite(a))){u("type","参数应为字符串或有限数字");continue}const o=String(a);i[n.field]=o,b(n,o).forEach(([m,p])=>u(m,p)),r[n.field]=n.type==="number"&&y(o)?Number(o):o}return{ok:s.length===0,values:i,typedValues:r,issues:s}}function P(t,e={}){const i=g(t,e);if(!i.ok)throw new l(i.issues);return i.values}function j(t){const e={type:t.type==="number"?"number":"string",title:t.label??t.field};return t.type==="date"&&(e.format="date"),t.required&&t.type!=="number"&&(e.pattern="\\S"),t.type==="select"&&t.options&&(e.enum=t.options.map(i=>i.value)),t.defaultValue!==void 0&&(t.type!=="number"||t.defaultValue.trim())&&(e.default=t.type==="number"?Number(t.defaultValue):t.defaultValue),t.minLength!==void 0&&(e.minLength=t.minLength),t.maxLength!==void 0&&(e.maxLength=t.maxLength),typeof t.min=="number"&&(e.minimum=t.min),typeof t.max=="number"&&(e.maximum=t.max),typeof t.min=="string"&&(e["x-report-minimum"]=t.min),typeof t.max=="string"&&(e["x-report-maximum"]=t.max),e}function N(t){const e=h(t);if(e.length)throw new l(e);return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",properties:Object.fromEntries(t.map(i=>[i.field,j(i)])),required:t.filter(i=>i.required).map(i=>i.field),additionalProperties:!0}}exports.ReportParamValidationError=l;exports.assertReportParams=P;exports.isReportDate=c;exports.reportParamsJsonSchema=N;exports.validateReportParamDefinitions=h;exports.validateReportParams=g;