@agile-team/mach-report 0.5.0 → 0.7.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/dist/ReportPreview-CrVeTKu1.cjs +6 -0
- package/dist/ReportPreview-DgsOdO4y.js +559 -0
- package/dist/_commonjsHelpers-DKOUU3wS.cjs +1 -0
- package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
- package/dist/builder/template-builder.d.ts +53 -0
- package/dist/compat/jh4j-template.d.ts +12 -0
- package/dist/defaults.d.ts +27 -0
- package/dist/index.cjs +6 -1663
- package/dist/index.d.cts +13 -344
- package/dist/index.d.ts +13 -344
- package/dist/index.js +744 -1415
- package/dist/layout/paginate.d.ts +51 -0
- package/dist/layout/textwrap.d.ts +36 -0
- package/dist/manager/api.d.ts +45 -0
- package/dist/manager/index.d.ts +2 -0
- package/dist/manager/types.d.ts +50 -0
- package/dist/manager.cjs +1 -122
- package/dist/manager.d.cts +5 -97
- package/dist/manager.d.ts +5 -97
- package/dist/manager.js +66 -81
- package/dist/pdf/font-loader.d.ts +5 -0
- package/dist/pdf/index.d.ts +2 -0
- package/dist/pdf/render-pdf.d.ts +25 -0
- package/dist/pdf.cjs +84 -52530
- package/dist/pdf.d.cts +4 -31
- package/dist/pdf.d.ts +4 -31
- package/dist/pdf.js +22843 -39218
- package/dist/plugin-Cl-IqCqx.cjs +1 -0
- package/dist/plugin-Dp3kKWiQ.js +92 -0
- package/dist/render/canvas.d.ts +61 -0
- package/dist/render/dom.d.ts +10 -0
- package/dist/render/grid-geometry.d.ts +41 -0
- package/dist/render/style.d.ts +33 -0
- package/dist/render/window.d.ts +23 -0
- package/dist/schema/render-plan.d.ts +96 -0
- package/dist/schema/validate.d.ts +15 -0
- package/dist/sql/ast-check.d.ts +14 -0
- package/dist/sql/compile.d.ts +31 -0
- package/dist/sql/expr.d.ts +21 -0
- package/dist/sql/index.d.ts +4 -0
- package/dist/sql/tokenizer.d.ts +25 -0
- package/dist/sql.cjs +68 -45207
- package/dist/sql.d.cts +3 -93
- package/dist/sql.d.ts +3 -93
- package/dist/sql.js +37213 -41613
- package/dist/style-B3vxGDZd.cjs +3 -0
- package/dist/style-B7Xfo5I-.js +255 -0
- package/dist/style.css +1 -0
- package/dist/units.d.ts +11 -0
- package/dist/vue/ReportPreview.d.ts +165 -0
- package/dist/vue/ReportToolbar.d.ts +25 -0
- package/dist/vue/adapters.d.ts +40 -0
- package/dist/vue/async.d.cts +275 -0
- package/dist/vue/async.d.ts +275 -0
- package/dist/vue/composables/usePageWindow.d.ts +28 -0
- package/dist/vue/composables/usePrintExport.d.ts +19 -0
- package/dist/vue/composables/useZoom.d.ts +15 -0
- package/dist/vue/config.d.ts +79 -0
- package/dist/vue/controller.d.ts +24 -0
- package/dist/vue/errors.d.ts +16 -0
- package/dist/vue/index.d.cts +13 -0
- package/dist/vue/index.d.ts +13 -0
- package/dist/vue/injection-keys.d.ts +14 -0
- package/dist/vue/local-adapter.d.ts +12 -0
- package/dist/vue/pdf-exporter.d.ts +13 -0
- package/dist/vue/plugin.d.ts +294 -0
- package/dist/vue-async.cjs +1 -0
- package/dist/vue-async.js +17 -0
- package/dist/vue.cjs +1 -0
- package/dist/vue.js +53 -0
- package/package.json +44 -6
- package/dist/textwrap-DWzM7pt1.d.cts +0 -135
- package/dist/textwrap-DWzM7pt1.d.ts +0 -135
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ComponentStyle, PlanComponent, RenderPlan } from '../schema/render-plan';
|
|
2
|
+
import { measureTextMm, wrapText, TextMeasurer } from './textwrap';
|
|
3
|
+
export interface ListColumn {
|
|
4
|
+
header: string;
|
|
5
|
+
field: string;
|
|
6
|
+
widthMm: number;
|
|
7
|
+
style?: ComponentStyle;
|
|
8
|
+
}
|
|
9
|
+
export interface ListComponent {
|
|
10
|
+
kind: "list";
|
|
11
|
+
id?: string;
|
|
12
|
+
leftMm: number;
|
|
13
|
+
topMm: number;
|
|
14
|
+
widthMm: number;
|
|
15
|
+
dataset: string;
|
|
16
|
+
columns: ListColumn[];
|
|
17
|
+
fontSizePt?: number;
|
|
18
|
+
headerBold?: boolean;
|
|
19
|
+
rowHeightMm?: number;
|
|
20
|
+
paddingMm?: number;
|
|
21
|
+
headerEveryPage?: boolean;
|
|
22
|
+
headerBackgroundColor?: string;
|
|
23
|
+
border?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export type TemplateComponent = PlanComponent | ListComponent;
|
|
26
|
+
export interface TemplatePage {
|
|
27
|
+
widthMm: number;
|
|
28
|
+
heightMm: number;
|
|
29
|
+
marginTopMm?: number;
|
|
30
|
+
marginBottomMm?: number;
|
|
31
|
+
marginLeftMm?: number;
|
|
32
|
+
marginRightMm?: number;
|
|
33
|
+
components: TemplateComponent[];
|
|
34
|
+
}
|
|
35
|
+
export interface ReportTemplate {
|
|
36
|
+
schemaVersion?: string;
|
|
37
|
+
pages: TemplatePage[];
|
|
38
|
+
}
|
|
39
|
+
export type DatasetRows = Record<string, Record<string, unknown>[]>;
|
|
40
|
+
export interface PaginateOptions {
|
|
41
|
+
/** 每行额外占高(mm),压测专用钩子 */
|
|
42
|
+
mmPerRow?: number;
|
|
43
|
+
/** 文本测量器(默认启发式;浏览器端可注入 canvas 测量校准) */
|
|
44
|
+
measurer?: TextMeasurer;
|
|
45
|
+
}
|
|
46
|
+
export interface PaginateResult {
|
|
47
|
+
plan: RenderPlan;
|
|
48
|
+
warnings: string[];
|
|
49
|
+
}
|
|
50
|
+
export declare function paginateTemplate(template: ReportTemplate, datasets: DatasetRows, optionsOrMmPerRow?: number | PaginateOptions): PaginateResult;
|
|
51
|
+
export { measureTextMm, wrapText };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文本测量与折行(分页/Canvas/PDF 共用的唯一折行真相源)。
|
|
3
|
+
*
|
|
4
|
+
* 测量模型可注入(TextMeasurer):
|
|
5
|
+
* - 默认 createHeuristicMeasurer():CJK/拉丁宽度启发式(零依赖、Node 可用)
|
|
6
|
+
* - 浏览器端可注入 createCanvasMeasurer()(真字体 metrics,消除三端折行差异)
|
|
7
|
+
*/
|
|
8
|
+
export interface TextMeasureOptions {
|
|
9
|
+
fontSizePt: number;
|
|
10
|
+
bold?: boolean;
|
|
11
|
+
letterSpacingPt?: number;
|
|
12
|
+
}
|
|
13
|
+
/** 宽度测量接口:返回文本在给定字号下的宽度(mm)。实现必须无副作用、可缓存。 */
|
|
14
|
+
export interface TextMeasurer {
|
|
15
|
+
measureMm(text: string, options: TextMeasureOptions): number;
|
|
16
|
+
}
|
|
17
|
+
export declare function charWidthEm(ch: string): number;
|
|
18
|
+
/** 启发式测量器:宽度模型与 jh4j 近似口径一致(默认实现) */
|
|
19
|
+
export declare const heuristicMeasurer: TextMeasurer;
|
|
20
|
+
/** 兼容旧 API:默认启发式测量 */
|
|
21
|
+
export declare function createHeuristicMeasurer(): TextMeasurer;
|
|
22
|
+
export declare function measureTextMm(text: string, options: TextMeasureOptions): number;
|
|
23
|
+
/**
|
|
24
|
+
* 浏览器 Canvas 测量器:用真实字体 metrics 校准宽度(可选注入)。
|
|
25
|
+
* 无 2D 环境时自动回退启发式(Node/SSR 安全)。
|
|
26
|
+
*/
|
|
27
|
+
export declare function createCanvasMeasurer(getCtx2d: () => CanvasRenderingContext2D | null): TextMeasurer;
|
|
28
|
+
/**
|
|
29
|
+
* 文本折行:
|
|
30
|
+
* - CJK 字符任意位置可断(与既有行为一致)
|
|
31
|
+
* - 连续拉丁/数字串视为一个词,仅在词间(空格/CJK 边界)断行;
|
|
32
|
+
* 单词本身超宽时按字符硬拆(兜底,不无限溢出)
|
|
33
|
+
* - 换行符强制断行;行首不保留折行产生的空格
|
|
34
|
+
* - 可注入 TextMeasurer(默认启发式)
|
|
35
|
+
*/
|
|
36
|
+
export declare function wrapText(text: string, maxWidthMm: number, options: TextMeasureOptions, measurer?: TextMeasurer): string[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DatasetRecord, ImportStrategy, PageResult, ParamRecord, ReportRecord, RequestFn } from './types';
|
|
2
|
+
export declare function createReportAdminClient(options: {
|
|
3
|
+
request: RequestFn;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}): {
|
|
6
|
+
/** 模板列表(分页) */
|
|
7
|
+
listReports(query?: {
|
|
8
|
+
current?: number;
|
|
9
|
+
size?: number;
|
|
10
|
+
directoryId?: string;
|
|
11
|
+
keyword?: string;
|
|
12
|
+
}): Promise<PageResult<ReportRecord>>;
|
|
13
|
+
/** 模板详情(content 为 jh4j 私有模板 JSON 字符串,可喂给 importJh4jTemplateContent) */
|
|
14
|
+
getReport(id: string): Promise<ReportRecord>;
|
|
15
|
+
/** 保存模板(jh4j:PUT,body {id, code, name, content}) */
|
|
16
|
+
updateReport(input: {
|
|
17
|
+
id: string;
|
|
18
|
+
code?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
content: string;
|
|
21
|
+
}): Promise<unknown>;
|
|
22
|
+
/** 导出模板定义包(body = ID 数组,返回 ZIP blob) */
|
|
23
|
+
exportDefinition(ids: string[]): Promise<unknown>;
|
|
24
|
+
/** 导入模板定义包(multipart: file + strategy) */
|
|
25
|
+
importDefinition(file: File | Blob, strategy: ImportStrategy): Promise<unknown>;
|
|
26
|
+
/** 数据集列表 */
|
|
27
|
+
listDatasets(reportId: string): Promise<PageResult<DatasetRecord>>;
|
|
28
|
+
/** 参数列表 */
|
|
29
|
+
listParams(reportId: string): Promise<PageResult<ParamRecord>>;
|
|
30
|
+
/** 模板锁:进入设计器前获取(40s 心跳由 holdLock 驱动) */
|
|
31
|
+
acquireLock(reportId: string): Promise<unknown>;
|
|
32
|
+
lockHeartbeat(reportId: string): Promise<unknown>;
|
|
33
|
+
releaseLock(reportId: string): Promise<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* 持锁执行:acquire → fn(期间自动心跳)→ release(finally)。
|
|
36
|
+
* 返回 fn 的结果;获取锁失败时抛 ReportAdminError。
|
|
37
|
+
* 心跳连续失败(默认 2 次)视为锁丢失:触发 onLockLost 回调并停止心跳,
|
|
38
|
+
* fn 继续执行(避免中途丢弃用户编辑),由调用方决定是否提示/中止。
|
|
39
|
+
*/
|
|
40
|
+
holdLock<T>(reportId: string, fn: () => Promise<T>, options?: {
|
|
41
|
+
onLockLost?: (reason: string) => void;
|
|
42
|
+
heartbeatFailLimit?: number;
|
|
43
|
+
}): Promise<T>;
|
|
44
|
+
};
|
|
45
|
+
export type ReportAdminClient = ReturnType<typeof createReportAdminClient>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface ReportRecord {
|
|
2
|
+
id: string;
|
|
3
|
+
code?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
publishStatus?: string;
|
|
6
|
+
directoryId?: string;
|
|
7
|
+
updateTime?: string;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface PageResult<T> {
|
|
11
|
+
records: T[];
|
|
12
|
+
total?: number;
|
|
13
|
+
current?: number;
|
|
14
|
+
size?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface DatasetRecord {
|
|
17
|
+
id?: string;
|
|
18
|
+
reportId?: string;
|
|
19
|
+
code?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
datasourceCode?: string;
|
|
23
|
+
sqlText?: string;
|
|
24
|
+
apiUrl?: string;
|
|
25
|
+
fields?: unknown[];
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
export interface ParamRecord {
|
|
29
|
+
id?: string;
|
|
30
|
+
reportId?: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
defaultValue?: string;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
export type ImportStrategy = "overwrite" | "skip";
|
|
36
|
+
export type RequestFn = (config: {
|
|
37
|
+
url: string;
|
|
38
|
+
method: string;
|
|
39
|
+
params?: Record<string, unknown>;
|
|
40
|
+
data?: unknown;
|
|
41
|
+
}) => Promise<unknown>;
|
|
42
|
+
export interface ApiResponse<T = unknown> {
|
|
43
|
+
code?: number;
|
|
44
|
+
message?: string;
|
|
45
|
+
data?: T;
|
|
46
|
+
}
|
|
47
|
+
export declare class ReportAdminError extends Error {
|
|
48
|
+
readonly url: string;
|
|
49
|
+
constructor(message: string, url: string);
|
|
50
|
+
}
|
package/dist/manager.cjs
CHANGED
|
@@ -1,122 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// src/manager/types.ts
|
|
4
|
-
var ReportAdminError = class extends Error {
|
|
5
|
-
constructor(message, url) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.url = url;
|
|
8
|
-
this.name = "ReportAdminError";
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// src/manager/api.ts
|
|
13
|
-
var BASE = "/report/codePrintReport";
|
|
14
|
-
var LOCK_BASE = "/report/codePrintReportLock";
|
|
15
|
-
function unwrap(response, url) {
|
|
16
|
-
const body = response;
|
|
17
|
-
if (body && body.code != null && body.code !== 200) {
|
|
18
|
-
throw new ReportAdminError(String(body.message || "\u8BF7\u6C42\u5931\u8D25"), url);
|
|
19
|
-
}
|
|
20
|
-
return body?.data ?? body;
|
|
21
|
-
}
|
|
22
|
-
function createReportAdminClient(options) {
|
|
23
|
-
const { request } = options;
|
|
24
|
-
const base = options.baseUrl ?? "";
|
|
25
|
-
return {
|
|
26
|
-
/** 模板列表(分页) */
|
|
27
|
-
async listReports(query = {}) {
|
|
28
|
-
const url = `${base}${BASE}/list`;
|
|
29
|
-
return unwrap(
|
|
30
|
-
await request({ url, method: "get", params: { current: 1, size: 20, ...query } }),
|
|
31
|
-
url
|
|
32
|
-
);
|
|
33
|
-
},
|
|
34
|
-
/** 模板详情(content 为 jh4j 私有模板 JSON 字符串,可喂给 importJh4jTemplateContent) */
|
|
35
|
-
async getReport(id) {
|
|
36
|
-
const url = `${base}${BASE}/getById`;
|
|
37
|
-
return unwrap(await request({ url, method: "get", params: { id } }), url);
|
|
38
|
-
},
|
|
39
|
-
/** 保存模板(jh4j:PUT,body {id, code, name, content}) */
|
|
40
|
-
async updateReport(input) {
|
|
41
|
-
const url = `${base}${BASE}/update`;
|
|
42
|
-
return unwrap(await request({ url, method: "put", data: input }), url);
|
|
43
|
-
},
|
|
44
|
-
/** 导出模板定义包(body = ID 数组,返回 ZIP blob) */
|
|
45
|
-
async exportDefinition(ids) {
|
|
46
|
-
const url = `${base}${BASE}/exportDefinition`;
|
|
47
|
-
return request({ url, method: "post", data: ids });
|
|
48
|
-
},
|
|
49
|
-
/** 导入模板定义包(multipart: file + strategy) */
|
|
50
|
-
async importDefinition(file, strategy) {
|
|
51
|
-
const url = `${base}${BASE}/importDefinition`;
|
|
52
|
-
const form = new FormData();
|
|
53
|
-
form.append("file", file);
|
|
54
|
-
form.append("strategy", strategy);
|
|
55
|
-
return request({ url, method: "post", data: form });
|
|
56
|
-
},
|
|
57
|
-
/** 数据集列表 */
|
|
58
|
-
async listDatasets(reportId) {
|
|
59
|
-
const url = `${base}${BASE}Ds/list`;
|
|
60
|
-
return unwrap(
|
|
61
|
-
await request({ url, method: "get", params: { reportId, current: 1, size: 999 } }),
|
|
62
|
-
url
|
|
63
|
-
);
|
|
64
|
-
},
|
|
65
|
-
/** 参数列表 */
|
|
66
|
-
async listParams(reportId) {
|
|
67
|
-
const url = `${base}${BASE}Param/list`;
|
|
68
|
-
return unwrap(
|
|
69
|
-
await request({ url, method: "get", params: { reportId, current: 1, size: 999 } }),
|
|
70
|
-
url
|
|
71
|
-
);
|
|
72
|
-
},
|
|
73
|
-
/** 模板锁:进入设计器前获取(40s 心跳由 holdLock 驱动) */
|
|
74
|
-
async acquireLock(reportId) {
|
|
75
|
-
const url = `${base}${LOCK_BASE}/acquire`;
|
|
76
|
-
return unwrap(await request({ url, method: "post", data: { reportId } }), url);
|
|
77
|
-
},
|
|
78
|
-
async lockHeartbeat(reportId) {
|
|
79
|
-
const url = `${base}${LOCK_BASE}/heartbeat`;
|
|
80
|
-
return unwrap(await request({ url, method: "post", data: { reportId } }), url);
|
|
81
|
-
},
|
|
82
|
-
async releaseLock(reportId) {
|
|
83
|
-
const url = `${base}${LOCK_BASE}/release`;
|
|
84
|
-
return unwrap(await request({ url, method: "post", data: { reportId } }), url);
|
|
85
|
-
},
|
|
86
|
-
/**
|
|
87
|
-
* 持锁执行:acquire → fn(期间自动心跳)→ release(finally)。
|
|
88
|
-
* 返回 fn 的结果;获取锁失败时抛 ReportAdminError。
|
|
89
|
-
* 心跳连续失败(默认 2 次)视为锁丢失:触发 onLockLost 回调并停止心跳,
|
|
90
|
-
* fn 继续执行(避免中途丢弃用户编辑),由调用方决定是否提示/中止。
|
|
91
|
-
*/
|
|
92
|
-
async holdLock(reportId, fn, options2 = {}) {
|
|
93
|
-
await this.acquireLock(reportId);
|
|
94
|
-
const failLimit = Math.max(1, options2.heartbeatFailLimit ?? 2);
|
|
95
|
-
let consecutiveFailures = 0;
|
|
96
|
-
let lockLost = false;
|
|
97
|
-
const timer = setInterval(() => {
|
|
98
|
-
void this.lockHeartbeat(reportId).then(() => {
|
|
99
|
-
consecutiveFailures = 0;
|
|
100
|
-
}).catch((e) => {
|
|
101
|
-
consecutiveFailures++;
|
|
102
|
-
if (!lockLost && consecutiveFailures >= failLimit) {
|
|
103
|
-
lockLost = true;
|
|
104
|
-
options2.onLockLost?.(
|
|
105
|
-
`\u6A21\u677F\u9501\u5FC3\u8DF3\u8FDE\u7EED ${consecutiveFailures} \u6B21\u5931\u8D25\uFF08${e instanceof Error ? e.message : String(e)}\uFF09\uFF0C\u9501\u53EF\u80FD\u5DF2\u88AB\u91CA\u653E`
|
|
106
|
-
);
|
|
107
|
-
clearInterval(timer);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}, 4e4);
|
|
111
|
-
try {
|
|
112
|
-
return await fn();
|
|
113
|
-
} finally {
|
|
114
|
-
clearInterval(timer);
|
|
115
|
-
await this.releaseLock(reportId).catch(() => void 0);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
exports.ReportAdminError = ReportAdminError;
|
|
122
|
-
exports.createReportAdminClient = createReportAdminClient;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class h extends Error{constructor(a,r){super(a),this.url=r,this.name="ReportAdminError"}}const o="/report/codePrintReport",d="/report/codePrintReportLock";function n(s,a){const r=s;if(r&&r.code!=null&&r.code!==200)throw new h(String(r.message||"请求失败"),a);return r?.data??r}function $(s){const{request:a}=s,r=s.baseUrl??"";return{async listReports(e={}){const t=`${r}${o}/list`;return n(await a({url:t,method:"get",params:{current:1,size:20,...e}}),t)},async getReport(e){const t=`${r}${o}/getById`;return n(await a({url:t,method:"get",params:{id:e}}),t)},async updateReport(e){const t=`${r}${o}/update`;return n(await a({url:t,method:"put",data:e}),t)},async exportDefinition(e){const t=`${r}${o}/exportDefinition`;return a({url:t,method:"post",data:e})},async importDefinition(e,t){const c=`${r}${o}/importDefinition`,i=new FormData;return i.append("file",e),i.append("strategy",t),a({url:c,method:"post",data:i})},async listDatasets(e){const t=`${r}${o}Ds/list`;return n(await a({url:t,method:"get",params:{reportId:e,current:1,size:999}}),t)},async listParams(e){const t=`${r}${o}Param/list`;return n(await a({url:t,method:"get",params:{reportId:e,current:1,size:999}}),t)},async acquireLock(e){const t=`${r}${d}/acquire`;return n(await a({url:t,method:"post",data:{reportId:e}}),t)},async lockHeartbeat(e){const t=`${r}${d}/heartbeat`;return n(await a({url:t,method:"post",data:{reportId:e}}),t)},async releaseLock(e){const t=`${r}${d}/release`;return n(await a({url:t,method:"post",data:{reportId:e}}),t)},async holdLock(e,t,c={}){await this.acquireLock(e);const i=Math.max(1,c.heartbeatFailLimit??2);let l=0,m=!1;const p=setInterval(()=>{this.lockHeartbeat(e).then(()=>{l=0}).catch(u=>{l++,!m&&l>=i&&(m=!0,c.onLockLost?.(`模板锁心跳连续 ${l} 次失败(${u instanceof Error?u.message:String(u)}),锁可能已被释放`),clearInterval(p))})},4e4);try{return await t()}finally{clearInterval(p),await this.releaseLock(e).catch(()=>{})}}}}exports.ReportAdminError=h;exports.createReportAdminClient=$;
|
package/dist/manager.d.cts
CHANGED
|
@@ -1,97 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
directoryId?: string;
|
|
7
|
-
updateTime?: string;
|
|
8
|
-
[key: string]: unknown;
|
|
9
|
-
}
|
|
10
|
-
interface PageResult<T> {
|
|
11
|
-
records: T[];
|
|
12
|
-
total?: number;
|
|
13
|
-
current?: number;
|
|
14
|
-
size?: number;
|
|
15
|
-
}
|
|
16
|
-
interface DatasetRecord {
|
|
17
|
-
id?: string;
|
|
18
|
-
reportId?: string;
|
|
19
|
-
code?: string;
|
|
20
|
-
name?: string;
|
|
21
|
-
type?: string;
|
|
22
|
-
datasourceCode?: string;
|
|
23
|
-
sqlText?: string;
|
|
24
|
-
apiUrl?: string;
|
|
25
|
-
fields?: unknown[];
|
|
26
|
-
[key: string]: unknown;
|
|
27
|
-
}
|
|
28
|
-
interface ParamRecord {
|
|
29
|
-
id?: string;
|
|
30
|
-
reportId?: string;
|
|
31
|
-
name?: string;
|
|
32
|
-
defaultValue?: string;
|
|
33
|
-
[key: string]: unknown;
|
|
34
|
-
}
|
|
35
|
-
type ImportStrategy = "overwrite" | "skip";
|
|
36
|
-
type RequestFn = (config: {
|
|
37
|
-
url: string;
|
|
38
|
-
method: string;
|
|
39
|
-
params?: Record<string, unknown>;
|
|
40
|
-
data?: unknown;
|
|
41
|
-
}) => Promise<unknown>;
|
|
42
|
-
interface ApiResponse<T = unknown> {
|
|
43
|
-
code?: number;
|
|
44
|
-
message?: string;
|
|
45
|
-
data?: T;
|
|
46
|
-
}
|
|
47
|
-
declare class ReportAdminError extends Error {
|
|
48
|
-
readonly url: string;
|
|
49
|
-
constructor(message: string, url: string);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
declare function createReportAdminClient(options: {
|
|
53
|
-
request: RequestFn;
|
|
54
|
-
baseUrl?: string;
|
|
55
|
-
}): {
|
|
56
|
-
/** 模板列表(分页) */
|
|
57
|
-
listReports(query?: {
|
|
58
|
-
current?: number;
|
|
59
|
-
size?: number;
|
|
60
|
-
directoryId?: string;
|
|
61
|
-
keyword?: string;
|
|
62
|
-
}): Promise<PageResult<ReportRecord>>;
|
|
63
|
-
/** 模板详情(content 为 jh4j 私有模板 JSON 字符串,可喂给 importJh4jTemplateContent) */
|
|
64
|
-
getReport(id: string): Promise<ReportRecord>;
|
|
65
|
-
/** 保存模板(jh4j:PUT,body {id, code, name, content}) */
|
|
66
|
-
updateReport(input: {
|
|
67
|
-
id: string;
|
|
68
|
-
code?: string;
|
|
69
|
-
name?: string;
|
|
70
|
-
content: string;
|
|
71
|
-
}): Promise<unknown>;
|
|
72
|
-
/** 导出模板定义包(body = ID 数组,返回 ZIP blob) */
|
|
73
|
-
exportDefinition(ids: string[]): Promise<unknown>;
|
|
74
|
-
/** 导入模板定义包(multipart: file + strategy) */
|
|
75
|
-
importDefinition(file: File | Blob, strategy: ImportStrategy): Promise<unknown>;
|
|
76
|
-
/** 数据集列表 */
|
|
77
|
-
listDatasets(reportId: string): Promise<PageResult<DatasetRecord>>;
|
|
78
|
-
/** 参数列表 */
|
|
79
|
-
listParams(reportId: string): Promise<PageResult<ParamRecord>>;
|
|
80
|
-
/** 模板锁:进入设计器前获取(40s 心跳由 holdLock 驱动) */
|
|
81
|
-
acquireLock(reportId: string): Promise<unknown>;
|
|
82
|
-
lockHeartbeat(reportId: string): Promise<unknown>;
|
|
83
|
-
releaseLock(reportId: string): Promise<unknown>;
|
|
84
|
-
/**
|
|
85
|
-
* 持锁执行:acquire → fn(期间自动心跳)→ release(finally)。
|
|
86
|
-
* 返回 fn 的结果;获取锁失败时抛 ReportAdminError。
|
|
87
|
-
* 心跳连续失败(默认 2 次)视为锁丢失:触发 onLockLost 回调并停止心跳,
|
|
88
|
-
* fn 继续执行(避免中途丢弃用户编辑),由调用方决定是否提示/中止。
|
|
89
|
-
*/
|
|
90
|
-
holdLock<T>(reportId: string, fn: () => Promise<T>, options?: {
|
|
91
|
-
onLockLost?: (reason: string) => void;
|
|
92
|
-
heartbeatFailLimit?: number;
|
|
93
|
-
}): Promise<T>;
|
|
94
|
-
};
|
|
95
|
-
type ReportAdminClient = ReturnType<typeof createReportAdminClient>;
|
|
96
|
-
|
|
97
|
-
export { type ApiResponse, type DatasetRecord, type ImportStrategy, type PageResult, type ParamRecord, type ReportAdminClient, ReportAdminError, type ReportRecord, type RequestFn, createReportAdminClient };
|
|
1
|
+
/**
|
|
2
|
+
* 管理端 API 子路径入口(@agile-team/mach-report/manager):
|
|
3
|
+
* 模板/数据集/参数/导入导出/模板锁(接口面对齐 jh4j 逆向结果)。
|
|
4
|
+
*/
|
|
5
|
+
export * from './manager/index';
|
package/dist/manager.d.ts
CHANGED
|
@@ -1,97 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
directoryId?: string;
|
|
7
|
-
updateTime?: string;
|
|
8
|
-
[key: string]: unknown;
|
|
9
|
-
}
|
|
10
|
-
interface PageResult<T> {
|
|
11
|
-
records: T[];
|
|
12
|
-
total?: number;
|
|
13
|
-
current?: number;
|
|
14
|
-
size?: number;
|
|
15
|
-
}
|
|
16
|
-
interface DatasetRecord {
|
|
17
|
-
id?: string;
|
|
18
|
-
reportId?: string;
|
|
19
|
-
code?: string;
|
|
20
|
-
name?: string;
|
|
21
|
-
type?: string;
|
|
22
|
-
datasourceCode?: string;
|
|
23
|
-
sqlText?: string;
|
|
24
|
-
apiUrl?: string;
|
|
25
|
-
fields?: unknown[];
|
|
26
|
-
[key: string]: unknown;
|
|
27
|
-
}
|
|
28
|
-
interface ParamRecord {
|
|
29
|
-
id?: string;
|
|
30
|
-
reportId?: string;
|
|
31
|
-
name?: string;
|
|
32
|
-
defaultValue?: string;
|
|
33
|
-
[key: string]: unknown;
|
|
34
|
-
}
|
|
35
|
-
type ImportStrategy = "overwrite" | "skip";
|
|
36
|
-
type RequestFn = (config: {
|
|
37
|
-
url: string;
|
|
38
|
-
method: string;
|
|
39
|
-
params?: Record<string, unknown>;
|
|
40
|
-
data?: unknown;
|
|
41
|
-
}) => Promise<unknown>;
|
|
42
|
-
interface ApiResponse<T = unknown> {
|
|
43
|
-
code?: number;
|
|
44
|
-
message?: string;
|
|
45
|
-
data?: T;
|
|
46
|
-
}
|
|
47
|
-
declare class ReportAdminError extends Error {
|
|
48
|
-
readonly url: string;
|
|
49
|
-
constructor(message: string, url: string);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
declare function createReportAdminClient(options: {
|
|
53
|
-
request: RequestFn;
|
|
54
|
-
baseUrl?: string;
|
|
55
|
-
}): {
|
|
56
|
-
/** 模板列表(分页) */
|
|
57
|
-
listReports(query?: {
|
|
58
|
-
current?: number;
|
|
59
|
-
size?: number;
|
|
60
|
-
directoryId?: string;
|
|
61
|
-
keyword?: string;
|
|
62
|
-
}): Promise<PageResult<ReportRecord>>;
|
|
63
|
-
/** 模板详情(content 为 jh4j 私有模板 JSON 字符串,可喂给 importJh4jTemplateContent) */
|
|
64
|
-
getReport(id: string): Promise<ReportRecord>;
|
|
65
|
-
/** 保存模板(jh4j:PUT,body {id, code, name, content}) */
|
|
66
|
-
updateReport(input: {
|
|
67
|
-
id: string;
|
|
68
|
-
code?: string;
|
|
69
|
-
name?: string;
|
|
70
|
-
content: string;
|
|
71
|
-
}): Promise<unknown>;
|
|
72
|
-
/** 导出模板定义包(body = ID 数组,返回 ZIP blob) */
|
|
73
|
-
exportDefinition(ids: string[]): Promise<unknown>;
|
|
74
|
-
/** 导入模板定义包(multipart: file + strategy) */
|
|
75
|
-
importDefinition(file: File | Blob, strategy: ImportStrategy): Promise<unknown>;
|
|
76
|
-
/** 数据集列表 */
|
|
77
|
-
listDatasets(reportId: string): Promise<PageResult<DatasetRecord>>;
|
|
78
|
-
/** 参数列表 */
|
|
79
|
-
listParams(reportId: string): Promise<PageResult<ParamRecord>>;
|
|
80
|
-
/** 模板锁:进入设计器前获取(40s 心跳由 holdLock 驱动) */
|
|
81
|
-
acquireLock(reportId: string): Promise<unknown>;
|
|
82
|
-
lockHeartbeat(reportId: string): Promise<unknown>;
|
|
83
|
-
releaseLock(reportId: string): Promise<unknown>;
|
|
84
|
-
/**
|
|
85
|
-
* 持锁执行:acquire → fn(期间自动心跳)→ release(finally)。
|
|
86
|
-
* 返回 fn 的结果;获取锁失败时抛 ReportAdminError。
|
|
87
|
-
* 心跳连续失败(默认 2 次)视为锁丢失:触发 onLockLost 回调并停止心跳,
|
|
88
|
-
* fn 继续执行(避免中途丢弃用户编辑),由调用方决定是否提示/中止。
|
|
89
|
-
*/
|
|
90
|
-
holdLock<T>(reportId: string, fn: () => Promise<T>, options?: {
|
|
91
|
-
onLockLost?: (reason: string) => void;
|
|
92
|
-
heartbeatFailLimit?: number;
|
|
93
|
-
}): Promise<T>;
|
|
94
|
-
};
|
|
95
|
-
type ReportAdminClient = ReturnType<typeof createReportAdminClient>;
|
|
96
|
-
|
|
97
|
-
export { type ApiResponse, type DatasetRecord, type ImportStrategy, type PageResult, type ParamRecord, type ReportAdminClient, ReportAdminError, type ReportRecord, type RequestFn, createReportAdminClient };
|
|
1
|
+
/**
|
|
2
|
+
* 管理端 API 子路径入口(@agile-team/mach-report/manager):
|
|
3
|
+
* 模板/数据集/参数/导入导出/模板锁(接口面对齐 jh4j 逆向结果)。
|
|
4
|
+
*/
|
|
5
|
+
export * from './manager/index';
|