@agile-team/mach-report 2.0.0 → 2.2.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.
Files changed (87) hide show
  1. package/LICENSE +2 -4
  2. package/LICENSING.md +15 -0
  3. package/README.md +317 -76
  4. package/dist/ReportPreview-BWrQCj9M.js +1643 -0
  5. package/dist/ReportPreview-DY0PGGqF.cjs +6 -0
  6. package/dist/grid-geometry-DBH9ExuY.cjs +1 -0
  7. package/dist/grid-geometry-DONcjshk.js +130 -0
  8. package/dist/index.cjs +5 -5
  9. package/dist/index.d.cts +806 -13
  10. package/dist/index.d.ts +806 -13
  11. package/dist/index.js +1170 -653
  12. package/dist/page-window-index-CIuT4BAv.js +43 -0
  13. package/dist/page-window-index-DEjnM6IB.cjs +1 -0
  14. package/dist/pdf.cjs +48 -48
  15. package/dist/pdf.d.cts +159 -6
  16. package/dist/pdf.d.ts +159 -6
  17. package/dist/pdf.js +3542 -3466
  18. package/dist/plugin-BMoMUxrw.cjs +1 -0
  19. package/dist/plugin-CAcNe0FT.js +25 -0
  20. package/dist/report-params-B3Fia6JO.js +10 -0
  21. package/dist/report-params-D1gZ1DME.cjs +1 -0
  22. package/dist/sql.cjs +65 -64
  23. package/dist/sql.d.cts +109 -5
  24. package/dist/sql.d.ts +109 -5
  25. package/dist/sql.js +7947 -7922
  26. package/dist/style.css +1 -1
  27. package/dist/textwrap-DdaewxAd.js +117 -0
  28. package/dist/textwrap-DqiFwAV3.cjs +3 -0
  29. package/dist/vue/async.d.cts +820 -320
  30. package/dist/vue/async.d.ts +820 -320
  31. package/dist/vue/index.d.cts +1374 -14
  32. package/dist/vue/index.d.ts +1374 -14
  33. package/dist/vue-async.cjs +1 -1
  34. package/dist/vue-async.js +11 -12
  35. package/dist/vue.cjs +1 -1
  36. package/dist/vue.js +129 -49
  37. package/dist/xlsx.cjs +21 -21
  38. package/dist/xlsx.d.cts +2300 -5
  39. package/dist/xlsx.d.ts +2300 -5
  40. package/dist/xlsx.js +6390 -6347
  41. package/package.json +8 -3
  42. package/dist/ReportPreview-Cr0IH1Rz.cjs +0 -6
  43. package/dist/ReportPreview-DwknBgsJ.js +0 -1266
  44. package/dist/builder/template-builder.d.ts +0 -69
  45. package/dist/defaults.d.ts +0 -23
  46. package/dist/format.d.ts +0 -48
  47. package/dist/grid-geometry-BXpOxznT.cjs +0 -1
  48. package/dist/grid-geometry-Bs8QXz1X.js +0 -65
  49. package/dist/layout/paginate.d.ts +0 -97
  50. package/dist/layout/textwrap.d.ts +0 -36
  51. package/dist/pdf/font-loader.d.ts +0 -6
  52. package/dist/pdf/index.d.ts +0 -2
  53. package/dist/pdf/render-pdf.d.ts +0 -25
  54. package/dist/plugin-Cj3c2wJc.cjs +0 -1
  55. package/dist/plugin-DJf_6_fl.js +0 -18
  56. package/dist/render/canvas.d.ts +0 -76
  57. package/dist/render/dom.d.ts +0 -10
  58. package/dist/render/grid-geometry.d.ts +0 -41
  59. package/dist/render/style.d.ts +0 -33
  60. package/dist/render/window.d.ts +0 -23
  61. package/dist/schema/render-plan.d.ts +0 -88
  62. package/dist/schema/validate.d.ts +0 -15
  63. package/dist/sql/ast-check.d.ts +0 -14
  64. package/dist/sql/compile.d.ts +0 -31
  65. package/dist/sql/expr.d.ts +0 -21
  66. package/dist/sql/index.d.ts +0 -4
  67. package/dist/sql/tokenizer.d.ts +0 -25
  68. package/dist/style-CFZ-HE2s.cjs +0 -3
  69. package/dist/style-DnmtG7Gl.js +0 -180
  70. package/dist/units.d.ts +0 -11
  71. package/dist/vue/ReportParamPanel.d.ts +0 -19
  72. package/dist/vue/ReportPreview.d.ts +0 -200
  73. package/dist/vue/ReportToolbar.d.ts +0 -42
  74. package/dist/vue/adapters.d.ts +0 -34
  75. package/dist/vue/composables/useHighlight.d.ts +0 -8
  76. package/dist/vue/composables/usePageWindow.d.ts +0 -25
  77. package/dist/vue/composables/usePrintExport.d.ts +0 -40
  78. package/dist/vue/composables/useReportSearch.d.ts +0 -73
  79. package/dist/vue/composables/useZoom.d.ts +0 -15
  80. package/dist/vue/config.d.ts +0 -108
  81. package/dist/vue/controller.d.ts +0 -29
  82. package/dist/vue/errors.d.ts +0 -16
  83. package/dist/vue/injection-keys.d.ts +0 -14
  84. package/dist/vue/local-adapter.d.ts +0 -11
  85. package/dist/vue/pdf-exporter.d.ts +0 -13
  86. package/dist/vue/plugin.d.ts +0 -332
  87. package/dist/xlsx/render-xlsx.d.ts +0 -20
package/dist/sql.d.cts CHANGED
@@ -1,5 +1,109 @@
1
- /**
2
- * 动态 SQL 子路径入口(@agile-team/mach-report/sql):
3
- * 动态 SQL 编译、参数化渲染与 AST/词法双层单 SELECT 校验。
4
- */
5
- export * from './sql/index';
1
+ /**
2
+ * 单 SELECT 结构校验(词法层;AST 级校验见 ast-check.ts 双保险):
3
+ * - 去注释后必须以 select 或 with 开头
4
+ * - 语句内除末尾外不允许出现分号
5
+ * - 顶层禁止 DML/DDL/调用关键字(字符串字面量内容不参与匹配)
6
+ */
7
+ export declare function assertSingleSelect(sql: string): void;
8
+
9
+ /**
10
+ * AST 深度校验(双保险策略):
11
+ * 1. node-sql-parser(MySQL 方言,支持 ? 占位符)AST 顶层必须为 SELECT/集合运算
12
+ * 2. AST 通过后再叠加词法校验(MySQL 方言把 SELECT INTO 解析为别名,AST 层不可见,
13
+ * 由词法层兜底拦截)
14
+ * AST 解析失败(方言不兼容)自动降级为纯词法校验,返回 degraded=true。
15
+ */
16
+ export declare function assertSingleSelectAst(sql: string): AstCheckResult;
17
+
18
+ export declare interface AstCheckResult {
19
+ ok: boolean;
20
+ /** ast 深度校验是否执行(方言不支持时降级词法) */
21
+ degraded: boolean;
22
+ message?: string;
23
+ }
24
+
25
+ export declare interface CompiledSql {
26
+ original: string;
27
+ /** 参数名集合(bind 与 subst 并集) */
28
+ paramNames: string[];
29
+ render(params: Record<string, unknown>): RenderedSql;
30
+ }
31
+
32
+ export declare function compileDynamicSql(source: string): CompiledSql;
33
+
34
+ /**
35
+ * 求值动态 SQL 条件表达式(用于 {if(cond, a, b)} 的 cond 与操作数):
36
+ * - #param 引用(渲染时被替换为参数值;此实现按值求值)
37
+ * - "..." 字符串字面量(仅双引号)
38
+ * - isEmpty(x)、isNotEmpty(x)
39
+ * - == / != 比较
40
+ * - + 拼接
41
+ */
42
+ export declare function evalExpr(input: string, ctx: ExprContext): unknown;
43
+
44
+ export declare interface ExprContext {
45
+ params: Record<string, unknown>;
46
+ }
47
+
48
+ export declare class ExprError extends Error {
49
+ constructor(message: string);
50
+ }
51
+
52
+ /** {if(cond, whenTrue, whenFalse)} 的参数拆分(2 或 3 段) */
53
+ export declare function parseIfArgs(inner: string): {
54
+ cond: string;
55
+ whenTrue: string;
56
+ whenFalse: string;
57
+ };
58
+
59
+ /** 便捷入口:编译 + 渲染 + 校验一体 */
60
+ export declare function renderDynamicSql(source: string, params: Record<string, unknown>): RenderedSql;
61
+
62
+ export declare interface RenderedSql {
63
+ sql: string;
64
+ binds: unknown[];
65
+ warnings: string[];
66
+ }
67
+
68
+ /** 按顶层逗号拆分(忽略双引号内与括号/花括号内) */
69
+ export declare function splitTopLevel(input: string): string[];
70
+
71
+ export declare class SqlSyntaxError extends Error {
72
+ readonly position: number;
73
+ readonly source: string;
74
+ constructor(message: string, position: number, source: string);
75
+ }
76
+
77
+ export declare class SqlValidationError extends Error {
78
+ readonly sql: string;
79
+ constructor(message: string, sql: string);
80
+ }
81
+
82
+ /**
83
+ * 去注释:-- 行注释、# 行注释(仅行首/空白后,且排除 #{ 绑定占位)、/* 块注释。
84
+ * 注意:此函数用于校验口径,输出会折叠空白。
85
+ */
86
+ export declare function stripSqlComments(sql: string): string;
87
+
88
+ export declare interface Token {
89
+ type: TokenType;
90
+ text: string;
91
+ /** bind/subst 参数名;if 表达式源码 */
92
+ value?: string;
93
+ start: number;
94
+ end: number;
95
+ }
96
+
97
+ /**
98
+ * 扫描动态 SQL,产出 token 流:
99
+ * - literal: 纯 SQL 文本(已反转义 \{ \})
100
+ * - bind: #{name}
101
+ * - subst: ${name}
102
+ * - if: {if(expr, a, b)} —— value 为去壳后的参数串
103
+ * - escape: \{ 或 \}
104
+ */
105
+ export declare function tokenize(sql: string): Token[];
106
+
107
+ export declare type TokenType = "literal" | "bind" | "subst" | "if" | "escape";
108
+
109
+ export { }
package/dist/sql.d.ts CHANGED
@@ -1,5 +1,109 @@
1
- /**
2
- * 动态 SQL 子路径入口(@agile-team/mach-report/sql):
3
- * 动态 SQL 编译、参数化渲染与 AST/词法双层单 SELECT 校验。
4
- */
5
- export * from './sql/index';
1
+ /**
2
+ * 单 SELECT 结构校验(词法层;AST 级校验见 ast-check.ts 双保险):
3
+ * - 去注释后必须以 select 或 with 开头
4
+ * - 语句内除末尾外不允许出现分号
5
+ * - 顶层禁止 DML/DDL/调用关键字(字符串字面量内容不参与匹配)
6
+ */
7
+ export declare function assertSingleSelect(sql: string): void;
8
+
9
+ /**
10
+ * AST 深度校验(双保险策略):
11
+ * 1. node-sql-parser(MySQL 方言,支持 ? 占位符)AST 顶层必须为 SELECT/集合运算
12
+ * 2. AST 通过后再叠加词法校验(MySQL 方言把 SELECT INTO 解析为别名,AST 层不可见,
13
+ * 由词法层兜底拦截)
14
+ * AST 解析失败(方言不兼容)自动降级为纯词法校验,返回 degraded=true。
15
+ */
16
+ export declare function assertSingleSelectAst(sql: string): AstCheckResult;
17
+
18
+ export declare interface AstCheckResult {
19
+ ok: boolean;
20
+ /** ast 深度校验是否执行(方言不支持时降级词法) */
21
+ degraded: boolean;
22
+ message?: string;
23
+ }
24
+
25
+ export declare interface CompiledSql {
26
+ original: string;
27
+ /** 参数名集合(bind 与 subst 并集) */
28
+ paramNames: string[];
29
+ render(params: Record<string, unknown>): RenderedSql;
30
+ }
31
+
32
+ export declare function compileDynamicSql(source: string): CompiledSql;
33
+
34
+ /**
35
+ * 求值动态 SQL 条件表达式(用于 {if(cond, a, b)} 的 cond 与操作数):
36
+ * - #param 引用(渲染时被替换为参数值;此实现按值求值)
37
+ * - "..." 字符串字面量(仅双引号)
38
+ * - isEmpty(x)、isNotEmpty(x)
39
+ * - == / != 比较
40
+ * - + 拼接
41
+ */
42
+ export declare function evalExpr(input: string, ctx: ExprContext): unknown;
43
+
44
+ export declare interface ExprContext {
45
+ params: Record<string, unknown>;
46
+ }
47
+
48
+ export declare class ExprError extends Error {
49
+ constructor(message: string);
50
+ }
51
+
52
+ /** {if(cond, whenTrue, whenFalse)} 的参数拆分(2 或 3 段) */
53
+ export declare function parseIfArgs(inner: string): {
54
+ cond: string;
55
+ whenTrue: string;
56
+ whenFalse: string;
57
+ };
58
+
59
+ /** 便捷入口:编译 + 渲染 + 校验一体 */
60
+ export declare function renderDynamicSql(source: string, params: Record<string, unknown>): RenderedSql;
61
+
62
+ export declare interface RenderedSql {
63
+ sql: string;
64
+ binds: unknown[];
65
+ warnings: string[];
66
+ }
67
+
68
+ /** 按顶层逗号拆分(忽略双引号内与括号/花括号内) */
69
+ export declare function splitTopLevel(input: string): string[];
70
+
71
+ export declare class SqlSyntaxError extends Error {
72
+ readonly position: number;
73
+ readonly source: string;
74
+ constructor(message: string, position: number, source: string);
75
+ }
76
+
77
+ export declare class SqlValidationError extends Error {
78
+ readonly sql: string;
79
+ constructor(message: string, sql: string);
80
+ }
81
+
82
+ /**
83
+ * 去注释:-- 行注释、# 行注释(仅行首/空白后,且排除 #{ 绑定占位)、/* 块注释。
84
+ * 注意:此函数用于校验口径,输出会折叠空白。
85
+ */
86
+ export declare function stripSqlComments(sql: string): string;
87
+
88
+ export declare interface Token {
89
+ type: TokenType;
90
+ text: string;
91
+ /** bind/subst 参数名;if 表达式源码 */
92
+ value?: string;
93
+ start: number;
94
+ end: number;
95
+ }
96
+
97
+ /**
98
+ * 扫描动态 SQL,产出 token 流:
99
+ * - literal: 纯 SQL 文本(已反转义 \{ \})
100
+ * - bind: #{name}
101
+ * - subst: ${name}
102
+ * - if: {if(expr, a, b)} —— value 为去壳后的参数串
103
+ * - escape: \{ 或 \}
104
+ */
105
+ export declare function tokenize(sql: string): Token[];
106
+
107
+ export declare type TokenType = "literal" | "bind" | "subst" | "if" | "escape";
108
+
109
+ export { }