@mldong/jeeflow 1.8.4 → 1.8.6
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 +23 -1
- package/dist/engine.d.ts +10 -10
- package/dist/engine.js +1 -1
- package/dist/extensions.d.ts +2 -2
- package/dist/facade.d.ts +4 -0
- package/dist/facade.js +61 -11
- package/dist/jdbc/ext.d.ts +5 -5
- package/dist/jdbc/ext.js +9 -9
- package/dist/jdbc/shared.d.ts +19 -15
- package/dist/jdbc/shared.js +38 -30
- package/dist/memory-ext.d.ts +5 -5
- package/dist/memory-ext.js +3 -3
- package/dist/memory.d.ts +13 -13
- package/dist/memory.js +6 -5
- package/dist/model.d.ts +23 -23
- package/dist/persist.d.ts +1 -1
- package/dist/spi.d.ts +19 -19
- package/package.json +47 -47
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ const repo = new MemoryRepository()
|
|
|
18
18
|
const engine = new EngineImpl(repo)
|
|
19
19
|
|
|
20
20
|
const def = {
|
|
21
|
-
id: 1, name: 'leave', displayName: '请假审批',
|
|
21
|
+
id: '1', name: 'leave', displayName: '请假审批',
|
|
22
22
|
content: JSON.stringify({ nodes: [...], edges: [...] })
|
|
23
23
|
}
|
|
24
24
|
repo.addDefine(def)
|
|
@@ -28,6 +28,28 @@ const tasks = await repo.findDoingTasks(inst.id)
|
|
|
28
28
|
await engine.executeProcessTask(tasks[0].id, 'leader')
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
> ⚠️ **id 全程 string(issue 38 E9)**:引擎内部与 API 契约的 id(流程定义/实例/任务/设计)一律为**字符串**。
|
|
32
|
+
> Java 雪花 id(>2^53)超出 JS 安全整数,`Number()` 转换必丢精度;字符串可无损承载,保证四语言同库共享流程。
|
|
33
|
+
|
|
34
|
+
## JDBC(MySQL/PostgreSQL)
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import mysql from 'mysql2/promise'
|
|
38
|
+
import { JdbcRepository, TsIDGenerator, MysqlAdapter } from '@mldong/jeeflow/jdbc'
|
|
39
|
+
|
|
40
|
+
// ⚠️ 必须配置 bigNumberStrings(issue 38 E9):BIGINT 列以 string 返回,
|
|
41
|
+
// 否则 mysql2 默认转 number,Java 雪花 id(>2^53)在驱动层就已丢精度
|
|
42
|
+
const pool = mysql.createPool({
|
|
43
|
+
host: 'localhost', user: 'root', password: '***', database: 'wf',
|
|
44
|
+
supportBigNumbers: true,
|
|
45
|
+
bigNumberStrings: true,
|
|
46
|
+
})
|
|
47
|
+
const repo = new JdbcRepository(new MysqlAdapter(pool), new TsIDGenerator())
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- MySQL 连接池必须带 `supportBigNumbers: true, bigNumberStrings: true`;PostgreSQL 的 int8 默认即字符串,无此要求
|
|
51
|
+
- 引擎侧已做驱动兜底:`rowId()` 把驱动返回的 number/string 统一归一化为 string,未开 `bigNumberStrings` 时小 id(Node 自建)仍可用
|
|
52
|
+
|
|
31
53
|
## 运行演示
|
|
32
54
|
|
|
33
55
|
```bash
|
package/dist/engine.d.ts
CHANGED
|
@@ -15,11 +15,11 @@ export declare const KeyProcessStartNextNodeOperator = "f_nextNodeOperator";
|
|
|
15
15
|
export declare const KeyAutoExecute = "flow.auto";
|
|
16
16
|
export declare const KeyAdminID = "flow.admin";
|
|
17
17
|
export interface Engine {
|
|
18
|
-
startProcessInstanceById(defineId:
|
|
19
|
-
executeProcessTask(taskId:
|
|
20
|
-
executeAndJumpToEnd(taskId:
|
|
21
|
-
executeAndJumpTask(taskId:
|
|
22
|
-
executeAndJumpToFirstTaskNode(taskId:
|
|
18
|
+
startProcessInstanceById(defineId: string, operator: string, args?: Record<string, any>): Promise<ProcessInstance>;
|
|
19
|
+
executeProcessTask(taskId: string, operator: string, args?: Record<string, any>): Promise<ProcessInstance>;
|
|
20
|
+
executeAndJumpToEnd(taskId: string, operator: string, args?: Record<string, any>): Promise<ProcessInstance>;
|
|
21
|
+
executeAndJumpTask(taskId: string, operator: string, args: Record<string, any>, targetTaskName?: string): Promise<ProcessInstance>;
|
|
22
|
+
executeAndJumpToFirstTaskNode(taskId: string, operator: string, args?: Record<string, any>): Promise<ProcessInstance>;
|
|
23
23
|
}
|
|
24
24
|
export declare class EngineImpl implements Engine {
|
|
25
25
|
private repo;
|
|
@@ -41,11 +41,11 @@ export declare class EngineImpl implements Engine {
|
|
|
41
41
|
evalExpr(expr: string, vars: Record<string, any>): Promise<any>;
|
|
42
42
|
private firePost;
|
|
43
43
|
private fireEvent;
|
|
44
|
-
startProcessInstanceById(defineId:
|
|
45
|
-
executeProcessTask(taskId:
|
|
46
|
-
executeAndJumpToEnd(taskId:
|
|
47
|
-
executeAndJumpTask(taskId:
|
|
48
|
-
executeAndJumpToFirstTaskNode(taskId:
|
|
44
|
+
startProcessInstanceById(defineId: string, operator: string, args?: Record<string, any>): Promise<ProcessInstance>;
|
|
45
|
+
executeProcessTask(taskId: string, operator: string, args?: Record<string, any>): Promise<ProcessInstance>;
|
|
46
|
+
executeAndJumpToEnd(taskId: string, operator: string, args?: Record<string, any>): Promise<ProcessInstance>;
|
|
47
|
+
executeAndJumpTask(taskId: string, operator: string, args?: Record<string, any>, targetTaskName?: string): Promise<ProcessInstance>;
|
|
48
|
+
executeAndJumpToFirstTaskNode(taskId: string, operator: string, args?: Record<string, any>): Promise<ProcessInstance>;
|
|
49
49
|
private loadAndCheck;
|
|
50
50
|
private executeNode;
|
|
51
51
|
private evaluateDecision;
|
package/dist/engine.js
CHANGED
|
@@ -473,7 +473,7 @@ export class EngineImpl {
|
|
|
473
473
|
nextId() {
|
|
474
474
|
if (this.idGen)
|
|
475
475
|
return this.idGen.nextId();
|
|
476
|
-
return Date.now() * 1000 + Math.floor(Math.random() * 1000);
|
|
476
|
+
return String(Date.now() * 1000 + Math.floor(Math.random() * 1000));
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
// ─── Pure Functions ──────────────────────────────────────────────────────────
|
package/dist/extensions.d.ts
CHANGED
package/dist/facade.d.ts
CHANGED
|
@@ -46,6 +46,10 @@ export declare class JeeflowFacade {
|
|
|
46
46
|
private surrogateSave;
|
|
47
47
|
private getLastByName;
|
|
48
48
|
private highLight;
|
|
49
|
+
/** 节点成员进度(issue 41,对齐 boot3 highLight):按任务状态 + 会签变量组装
|
|
50
|
+
* nodeProgress——会签节点带 type(PARALLEL/SEQUENTIAL),成员 done/active 标记;
|
|
51
|
+
* 动态参与人节点(无静态 actorIds)不返回;name 缺省(引擎不持有宿主用户体系,前端降级显示 id) */
|
|
52
|
+
private buildNodeProgress;
|
|
49
53
|
private collectPath;
|
|
50
54
|
/** 决策输出边表达式求值(args = 实例变量 + 决策节点前置任务变量) */
|
|
51
55
|
private evalDecisionExpr;
|
package/dist/facade.js
CHANGED
|
@@ -197,7 +197,7 @@ export class JeeflowFacade {
|
|
|
197
197
|
version = (latest.version ?? 0) + 1;
|
|
198
198
|
const operator = String(args.operator ?? 'system');
|
|
199
199
|
const def = {
|
|
200
|
-
id:
|
|
200
|
+
id: '', name, displayName: flow.displayName ?? '', type: flow.type ?? 'approval',
|
|
201
201
|
state: 1, content, version, createTime: new Date(), createUser: operator,
|
|
202
202
|
updateTime: new Date(), updateUser: operator,
|
|
203
203
|
};
|
|
@@ -319,7 +319,7 @@ export class JeeflowFacade {
|
|
|
319
319
|
const hisList = await ext.listDesignHis(designId);
|
|
320
320
|
if (hisList.length === 0 || toStr(hisList[0].content) !== content) {
|
|
321
321
|
await ext.saveDesignHis({
|
|
322
|
-
id:
|
|
322
|
+
id: '', processDesignId: designId, content,
|
|
323
323
|
createTime: new Date(), createUser: String(args.operator ?? 'system'),
|
|
324
324
|
});
|
|
325
325
|
}
|
|
@@ -501,11 +501,11 @@ export class JeeflowFacade {
|
|
|
501
501
|
async designSave(args) {
|
|
502
502
|
const ext = this.ext();
|
|
503
503
|
const operator = String(args.operator ?? 'user1');
|
|
504
|
-
const designId = args.id != null ? toId(args.id) :
|
|
504
|
+
const designId = args.id != null ? toId(args.id) : '';
|
|
505
505
|
let design;
|
|
506
506
|
if (!designId) {
|
|
507
507
|
design = {
|
|
508
|
-
id:
|
|
508
|
+
id: '', name: String(args.name ?? ''), displayName: String(args.displayName ?? ''),
|
|
509
509
|
type: String(args.type ?? 'approval'), icon: String(args.icon ?? ''),
|
|
510
510
|
isDeployed: 0, remark: String(args.remark ?? ''),
|
|
511
511
|
createTime: new Date(), createUser: operator,
|
|
@@ -535,7 +535,7 @@ export class JeeflowFacade {
|
|
|
535
535
|
// 内容快照(设计稿内容存历史表)
|
|
536
536
|
if (args.content != null) {
|
|
537
537
|
await ext.saveDesignHis({
|
|
538
|
-
id:
|
|
538
|
+
id: '', processDesignId: design.id, content: String(args.content),
|
|
539
539
|
createTime: new Date(), createUser: operator,
|
|
540
540
|
});
|
|
541
541
|
}
|
|
@@ -550,11 +550,11 @@ export class JeeflowFacade {
|
|
|
550
550
|
async surrogateSave(args) {
|
|
551
551
|
const ext = this.ext();
|
|
552
552
|
const operator = String(args.operator ?? 'user1');
|
|
553
|
-
const surrogateId = args.id != null ? toId(args.id) :
|
|
553
|
+
const surrogateId = args.id != null ? toId(args.id) : '';
|
|
554
554
|
let surrogate;
|
|
555
555
|
if (!surrogateId) {
|
|
556
556
|
surrogate = {
|
|
557
|
-
id:
|
|
557
|
+
id: '', operator, // 授权人 = 操作人
|
|
558
558
|
surrogate: String(args.surrogate ?? ''), processName: String(args.processName ?? ''),
|
|
559
559
|
enabled: toInt(args.enabled ?? 1),
|
|
560
560
|
createTime: new Date(), createUser: operator,
|
|
@@ -603,14 +603,60 @@ export class JeeflowFacade {
|
|
|
603
603
|
history.push(t.taskName);
|
|
604
604
|
// 路径补全:start 沿边递归(遇活跃节点停止);决策分支按表达式求值过滤(issues/06)
|
|
605
605
|
const def = await this.repo.findDefineById(inst.defineId);
|
|
606
|
+
let nodeProgress = {};
|
|
606
607
|
if (def) {
|
|
607
608
|
try {
|
|
608
609
|
const flow = JSON.parse(toStr(def.content));
|
|
610
|
+
nodeProgress = this.buildNodeProgress(flow, his);
|
|
609
611
|
await this.collectPath(flow, 'start', '', active, history, edges, new Set(), inst.variables ?? {}, his);
|
|
610
612
|
}
|
|
611
613
|
catch { /* ignore */ }
|
|
612
614
|
}
|
|
613
|
-
return { activeNodeNames: active, historyNodeNames: history, historyEdgeNames: edges };
|
|
615
|
+
return { activeNodeNames: active, historyNodeNames: history, historyEdgeNames: edges, nodeProgress };
|
|
616
|
+
}
|
|
617
|
+
/** 节点成员进度(issue 41,对齐 boot3 highLight):按任务状态 + 会签变量组装
|
|
618
|
+
* nodeProgress——会签节点带 type(PARALLEL/SEQUENTIAL),成员 done/active 标记;
|
|
619
|
+
* 动态参与人节点(无静态 actorIds)不返回;name 缺省(引擎不持有宿主用户体系,前端降级显示 id) */
|
|
620
|
+
buildNodeProgress(flow, his) {
|
|
621
|
+
const progress = {};
|
|
622
|
+
const names = [...new Set(his.map(t => t.taskName))];
|
|
623
|
+
for (const name of names) {
|
|
624
|
+
const tasks = his.filter(t => t.taskName === name);
|
|
625
|
+
const vars = tasks[0]?.variables ?? {};
|
|
626
|
+
// 完整办理人列表:会签变量 operatorList_{node} 优先(顺序会签全量),否则任务 actorIds 并集
|
|
627
|
+
let members = Array.isArray(vars[`operatorList_${name}`]) ? vars[`operatorList_${name}`] : null;
|
|
628
|
+
if (!members || members.length === 0) {
|
|
629
|
+
members = [...new Set(tasks.flatMap(t => t.actorIds ?? []))];
|
|
630
|
+
}
|
|
631
|
+
if (!members || members.length === 0)
|
|
632
|
+
continue; // 动态参与人:无静态成员,不返回
|
|
633
|
+
const doneSet = new Set();
|
|
634
|
+
for (const t of tasks) {
|
|
635
|
+
if (t.taskState === TaskState.Done)
|
|
636
|
+
for (const a of t.actorIds ?? [])
|
|
637
|
+
doneSet.add(a);
|
|
638
|
+
}
|
|
639
|
+
const activeActor = tasks.find(t => t.taskState === TaskState.Doing)?.actorIds?.[0];
|
|
640
|
+
const node = (flow.nodes ?? []).find((n) => n.id === name);
|
|
641
|
+
// 会签判定:定义节点属性(引擎创建任务时 performType 未落任务表,取模型为准)
|
|
642
|
+
const nodeProps = node?.properties ?? {};
|
|
643
|
+
const isCountersign = nodeProps.performType === 1 || nodeProps.countersignType != null;
|
|
644
|
+
const item = {
|
|
645
|
+
members: members.map((id) => {
|
|
646
|
+
const m = { id, name: '' };
|
|
647
|
+
if (doneSet.has(id))
|
|
648
|
+
m.done = true;
|
|
649
|
+
else if (id === activeActor)
|
|
650
|
+
m.active = true;
|
|
651
|
+
return m;
|
|
652
|
+
}),
|
|
653
|
+
};
|
|
654
|
+
if (isCountersign && nodeProps.countersignType) {
|
|
655
|
+
item.type = nodeProps.countersignType;
|
|
656
|
+
}
|
|
657
|
+
progress[name] = item;
|
|
658
|
+
}
|
|
659
|
+
return progress;
|
|
614
660
|
}
|
|
615
661
|
async collectPath(flow, nodeId, edgeName, active, history, edges, visited, vars, historyTasks) {
|
|
616
662
|
if (visited.has(nodeId))
|
|
@@ -1079,10 +1125,14 @@ function toStr(v) {
|
|
|
1079
1125
|
return String(v);
|
|
1080
1126
|
}
|
|
1081
1127
|
function toId(v) {
|
|
1082
|
-
|
|
1083
|
-
|
|
1128
|
+
// issue 38 E9:id 全程 string 承载——Java 雪花 id(>2^53)经 Number() 必丢精度。
|
|
1129
|
+
// 数字输入(JS 安全整数内)转字符串;字符串输入原样保留(含超长雪花 id)。
|
|
1130
|
+
if (v == null)
|
|
1084
1131
|
throw new Error('id 缺失或非法');
|
|
1085
|
-
|
|
1132
|
+
const s = String(v).trim();
|
|
1133
|
+
if (!/^\d+$/.test(s) || s === '0')
|
|
1134
|
+
throw new Error('id 缺失或非法');
|
|
1135
|
+
return s;
|
|
1086
1136
|
}
|
|
1087
1137
|
function toStringList2(v) {
|
|
1088
1138
|
if (Array.isArray(v))
|
package/dist/jdbc/ext.d.ts
CHANGED
|
@@ -9,21 +9,21 @@ export declare class JdbcProcessExtRepository implements ProcessExtRepository {
|
|
|
9
9
|
private c;
|
|
10
10
|
private done;
|
|
11
11
|
private static DESIGN_COLS;
|
|
12
|
-
findDesignById(id:
|
|
12
|
+
findDesignById(id: string): Promise<ProcessDesign | null>;
|
|
13
13
|
saveDesign(d: ProcessDesign): Promise<void>;
|
|
14
14
|
updateDesign(d: ProcessDesign): Promise<void>;
|
|
15
|
-
removeDesign(id:
|
|
15
|
+
removeDesign(id: string): Promise<void>;
|
|
16
16
|
pageDesigns(pageNum?: number, pageSize?: number, filters?: Record<string, any>, conditions?: QueryCondition[]): Promise<[ProcessDesign[], number]>;
|
|
17
17
|
private buildExtWhere;
|
|
18
18
|
private static readonly DESIGN_WHITELIST;
|
|
19
19
|
private static readonly SURROGATE_WHITELIST;
|
|
20
20
|
saveDesignHis(his: ProcessDesignHis): Promise<void>;
|
|
21
|
-
listDesignHis(designId:
|
|
21
|
+
listDesignHis(designId: string): Promise<ProcessDesignHis[]>;
|
|
22
22
|
private static SURROGATE_COLS;
|
|
23
|
-
findSurrogateById(id:
|
|
23
|
+
findSurrogateById(id: string): Promise<ProcessSurrogate | null>;
|
|
24
24
|
saveSurrogate(s: ProcessSurrogate): Promise<void>;
|
|
25
25
|
updateSurrogate(s: ProcessSurrogate): Promise<void>;
|
|
26
|
-
removeSurrogate(id:
|
|
26
|
+
removeSurrogate(id: string): Promise<void>;
|
|
27
27
|
pageSurrogates(pageNum?: number, pageSize?: number, filters?: Record<string, any>, conditions?: QueryCondition[]): Promise<[ProcessSurrogate[], number]>;
|
|
28
28
|
getSurrogate(operator: string, processName: string, at?: Date): Promise<ProcessSurrogate | null>;
|
|
29
29
|
private querySurrogate;
|
package/dist/jdbc/ext.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// 与 shared.ts 同一套 SqlAdapter / 占位符约定;分页为单表简单过滤(filters 字段名 EQ)。
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
|
-
import { TsIDGenerator } from './shared.js';
|
|
5
|
+
import { TsIDGenerator, rowId } from './shared.js';
|
|
6
6
|
const txStore = new AsyncLocalStorage();
|
|
7
7
|
export class JdbcProcessExtRepository {
|
|
8
8
|
adapter;
|
|
@@ -174,9 +174,9 @@ export class JdbcProcessExtRepository {
|
|
|
174
174
|
try {
|
|
175
175
|
const rows = await conn.fetchAll(this.sql('SELECT id, process_design_id, content, create_time, create_user FROM wf_process_design_his WHERE process_design_id = ? ORDER BY id DESC'), [designId]);
|
|
176
176
|
return rows.map(r => ({
|
|
177
|
-
id: r.id, processDesignId: r.process_design_id,
|
|
177
|
+
id: rowId(r.id), processDesignId: rowId(r.process_design_id),
|
|
178
178
|
content: r.content ? Buffer.from(r.content).toString('utf8') : '',
|
|
179
|
-
createTime: r.create_time, createUser: r.create_user,
|
|
179
|
+
createTime: r.create_time, createUser: rowId(r.create_user),
|
|
180
180
|
}));
|
|
181
181
|
}
|
|
182
182
|
finally {
|
|
@@ -300,18 +300,18 @@ export class JdbcProcessExtRepository {
|
|
|
300
300
|
// ── 行映射 ───────────────────────────────────────────────────────────────
|
|
301
301
|
mapDesign(row) {
|
|
302
302
|
return {
|
|
303
|
-
id: row.id, name: row.name, displayName: row.display_name, type: row.type,
|
|
303
|
+
id: rowId(row.id), name: row.name, displayName: row.display_name, type: row.type,
|
|
304
304
|
icon: row.icon, isDeployed: row.is_deployed, remark: row.remark,
|
|
305
|
-
createTime: row.create_time, createUser: row.create_user,
|
|
306
|
-
updateTime: row.update_time, updateUser: row.update_user,
|
|
305
|
+
createTime: row.create_time, createUser: rowId(row.create_user),
|
|
306
|
+
updateTime: row.update_time, updateUser: rowId(row.update_user),
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
mapSurrogate(row) {
|
|
310
310
|
return {
|
|
311
|
-
id: row.id, processName: row.process_name, operator: row.operator, surrogate: row.surrogate,
|
|
311
|
+
id: rowId(row.id), processName: row.process_name, operator: row.operator, surrogate: row.surrogate,
|
|
312
312
|
startTime: row.start_time, endTime: row.end_time, enabled: row.enabled,
|
|
313
|
-
createTime: row.create_time, createUser: row.create_user,
|
|
314
|
-
updateTime: row.update_time, updateUser: row.update_user,
|
|
313
|
+
createTime: row.create_time, createUser: rowId(row.create_user),
|
|
314
|
+
updateTime: row.update_time, updateUser: rowId(row.update_user),
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
317
|
}
|
package/dist/jdbc/shared.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { ProcessInstance, ProcessTask, type ProcessDefine, type CcInstanceRow, type DefineRow, type InstanceRow, type TaskRow } from '../model.js';
|
|
2
2
|
import type { IDGenerator, ProcessRepository, QueryCondition } from '../spi.js';
|
|
3
|
-
/** 默认 ID 生成器:时间戳毫秒 + 同毫秒递增序号(对齐 Java nextId
|
|
3
|
+
/** 默认 ID 生成器:时间戳毫秒 + 同毫秒递增序号(对齐 Java nextId 默认实现)——
|
|
4
|
+
* issue 38 E9:返回 string(数字值在 2^53 内精确,转字符串统一承载) */
|
|
4
5
|
export declare class TsIDGenerator implements IDGenerator {
|
|
5
6
|
private last;
|
|
6
7
|
private seq;
|
|
7
|
-
nextId():
|
|
8
|
+
nextId(): string;
|
|
8
9
|
}
|
|
10
|
+
/** 行 id 归一化(issue 38 E9):mysql2 可能返回 number(默认)或 string(bigNumberStrings),
|
|
11
|
+
* 统一转 string,保证引擎内部 id 全字符串、跨驱动一致 */
|
|
12
|
+
export declare function rowId(v: any): string;
|
|
9
13
|
/** 适配器返回的连接包装——最小接口 */
|
|
10
14
|
export interface SqlConnection {
|
|
11
15
|
execute(sql: string, args: any[]): Promise<void>;
|
|
@@ -35,34 +39,34 @@ export declare class JdbcRepository implements ProcessRepository {
|
|
|
35
39
|
private c;
|
|
36
40
|
/** 归还非事务连接(事务连接由 withTx 统一释放) */
|
|
37
41
|
private done;
|
|
38
|
-
findDefineById(id:
|
|
42
|
+
findDefineById(id: string): Promise<ProcessDefine | null>;
|
|
39
43
|
saveDefine(define: ProcessDefine): Promise<void>;
|
|
40
44
|
updateDefine(define: ProcessDefine): Promise<void>;
|
|
41
|
-
updateDefineState(defineId:
|
|
42
|
-
removeDefine(defineId:
|
|
45
|
+
updateDefineState(defineId: string, state: number): Promise<void>;
|
|
46
|
+
removeDefine(defineId: string): Promise<void>;
|
|
43
47
|
findDefineByName(name: string): Promise<ProcessDefine | null>;
|
|
44
48
|
private static INSTANCE_COLS;
|
|
45
|
-
findInstanceById(id:
|
|
49
|
+
findInstanceById(id: string): Promise<ProcessInstance | null>;
|
|
46
50
|
saveInstance(inst: ProcessInstance): Promise<void>;
|
|
47
51
|
updateInstance(inst: ProcessInstance): Promise<void>;
|
|
48
52
|
private static TASK_COLS;
|
|
49
|
-
findTaskById(taskId:
|
|
53
|
+
findTaskById(taskId: string): Promise<ProcessTask | null>;
|
|
50
54
|
saveTask(task: ProcessTask): Promise<void>;
|
|
51
55
|
updateTask(task: ProcessTask): Promise<void>;
|
|
52
56
|
/** 用指定连接更新任务(实例级联时与实例更新同连接) */
|
|
53
57
|
private updateTaskWithConn;
|
|
54
58
|
private findTasksByState;
|
|
55
|
-
findDoingTasks(instanceId:
|
|
56
|
-
findDoneTasks(instanceId:
|
|
57
|
-
findHistoryTasks(instanceId:
|
|
59
|
+
findDoingTasks(instanceId: string, taskNames?: string[]): Promise<ProcessTask[]>;
|
|
60
|
+
findDoneTasks(instanceId: string, taskNames?: string[]): Promise<ProcessTask[]>;
|
|
61
|
+
findHistoryTasks(instanceId: string): Promise<ProcessTask[]>;
|
|
58
62
|
private mapTask;
|
|
59
63
|
private replaceTaskActors;
|
|
60
64
|
private insertTaskActors;
|
|
61
|
-
findTaskActors(taskId:
|
|
62
|
-
addTaskActor(taskId:
|
|
63
|
-
removeTaskActor(taskId:
|
|
64
|
-
createCcInstance(instanceId:
|
|
65
|
-
updateCcStatus(instanceId:
|
|
65
|
+
findTaskActors(taskId: string): Promise<string[]>;
|
|
66
|
+
addTaskActor(taskId: string, actors: string[]): Promise<void>;
|
|
67
|
+
removeTaskActor(taskId: string, actors: string[]): Promise<void>;
|
|
68
|
+
createCcInstance(instanceId: string, creator: string, ...actorIds: string[]): Promise<void>;
|
|
69
|
+
updateCcStatus(instanceId: string, actorId: string): Promise<void>;
|
|
66
70
|
pageDefines(pageNum: number, pageSize: number, conditions?: QueryCondition[]): Promise<{
|
|
67
71
|
rows: DefineRow[];
|
|
68
72
|
total: number;
|
package/dist/jdbc/shared.js
CHANGED
|
@@ -37,7 +37,8 @@ const DEFINE_WHITELIST = new Set([
|
|
|
37
37
|
]);
|
|
38
38
|
// 当前异步上下文绑定的事务连接
|
|
39
39
|
const txStore = new AsyncLocalStorage();
|
|
40
|
-
/** 默认 ID 生成器:时间戳毫秒 + 同毫秒递增序号(对齐 Java nextId
|
|
40
|
+
/** 默认 ID 生成器:时间戳毫秒 + 同毫秒递增序号(对齐 Java nextId 默认实现)——
|
|
41
|
+
* issue 38 E9:返回 string(数字值在 2^53 内精确,转字符串统一承载) */
|
|
41
42
|
export class TsIDGenerator {
|
|
42
43
|
last = 0;
|
|
43
44
|
seq = 0;
|
|
@@ -50,9 +51,14 @@ export class TsIDGenerator {
|
|
|
50
51
|
this.last = now;
|
|
51
52
|
this.seq = 0;
|
|
52
53
|
}
|
|
53
|
-
return now * 1000 + this.seq;
|
|
54
|
+
return String(now * 1000 + this.seq);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
57
|
+
/** 行 id 归一化(issue 38 E9):mysql2 可能返回 number(默认)或 string(bigNumberStrings),
|
|
58
|
+
* 统一转 string,保证引擎内部 id 全字符串、跨驱动一致 */
|
|
59
|
+
export function rowId(v) {
|
|
60
|
+
return v == null ? '' : String(v);
|
|
61
|
+
}
|
|
56
62
|
/** 把核心 SQL 的统一 `?` 占位符转换为适配器风格 */
|
|
57
63
|
export function convertPlaceholder(sql, style) {
|
|
58
64
|
if (style === '$n') {
|
|
@@ -115,8 +121,8 @@ export class JdbcRepository {
|
|
|
115
121
|
id: row.id, name: row.name, displayName: row.display_name, type: row.type,
|
|
116
122
|
state: row.state,
|
|
117
123
|
content: row.content ? Buffer.from(row.content).toString('utf8') : '',
|
|
118
|
-
version: row.version, createTime: row.create_time, createUser: row.create_user,
|
|
119
|
-
updateTime: row.update_time, updateUser: row.update_user,
|
|
124
|
+
version: row.version, createTime: row.create_time, createUser: rowId(row.create_user),
|
|
125
|
+
updateTime: row.update_time, updateUser: rowId(row.update_user),
|
|
120
126
|
};
|
|
121
127
|
}
|
|
122
128
|
finally {
|
|
@@ -180,11 +186,11 @@ export class JdbcRepository {
|
|
|
180
186
|
if (!row)
|
|
181
187
|
return null;
|
|
182
188
|
return {
|
|
183
|
-
id: row.id, name: row.name, displayName: row.display_name, type: row.type,
|
|
189
|
+
id: rowId(row.id), name: row.name, displayName: row.display_name, type: row.type,
|
|
184
190
|
state: row.state,
|
|
185
191
|
content: row.content ? Buffer.from(row.content).toString('utf8') : '',
|
|
186
|
-
version: row.version, createTime: row.create_time, createUser: row.create_user,
|
|
187
|
-
updateTime: row.update_time, updateUser: row.update_user,
|
|
192
|
+
version: row.version, createTime: row.create_time, createUser: rowId(row.create_user),
|
|
193
|
+
updateTime: row.update_time, updateUser: rowId(row.update_user),
|
|
188
194
|
};
|
|
189
195
|
}
|
|
190
196
|
finally {
|
|
@@ -201,11 +207,12 @@ export class JdbcRepository {
|
|
|
201
207
|
if (!row)
|
|
202
208
|
return null;
|
|
203
209
|
const inst = new ProcessInstance({
|
|
204
|
-
id: row.id, parentId: row.parent_id
|
|
210
|
+
id: rowId(row.id), parentId: row.parent_id != null ? rowId(row.parent_id) : undefined,
|
|
211
|
+
defineId: rowId(row.process_define_id),
|
|
205
212
|
state: row.state, parentNodeName: row.parent_node_name, businessNo: row.business_no,
|
|
206
213
|
operator: row.operator, expireTime: row.expire_time,
|
|
207
|
-
createTime: row.create_time, createUser: row.create_user,
|
|
208
|
-
updateTime: row.update_time, updateUser: row.update_user,
|
|
214
|
+
createTime: row.create_time, createUser: rowId(row.create_user),
|
|
215
|
+
updateTime: row.update_time, updateUser: rowId(row.update_user),
|
|
209
216
|
tasks: [],
|
|
210
217
|
});
|
|
211
218
|
inst.variables = row.variable ? JSON.parse(row.variable) : {};
|
|
@@ -318,7 +325,7 @@ export class JdbcRepository {
|
|
|
318
325
|
for (const t of tasks)
|
|
319
326
|
t.actorIds = [];
|
|
320
327
|
for (const r of actorRows) {
|
|
321
|
-
const t = tasks.find(x => x.id === r.process_task_id);
|
|
328
|
+
const t = tasks.find(x => x.id === rowId(r.process_task_id));
|
|
322
329
|
if (t)
|
|
323
330
|
t.actorIds.push(r.actor_id);
|
|
324
331
|
}
|
|
@@ -340,12 +347,13 @@ export class JdbcRepository {
|
|
|
340
347
|
}
|
|
341
348
|
mapTask(row) {
|
|
342
349
|
const task = new ProcessTask({
|
|
343
|
-
id: row.id, processInstanceId: row.process_instance_id, taskName: row.task_name,
|
|
350
|
+
id: rowId(row.id), processInstanceId: rowId(row.process_instance_id), taskName: row.task_name,
|
|
344
351
|
displayName: row.display_name, taskType: row.task_type, performType: row.perform_type,
|
|
345
352
|
taskState: row.task_state, actorId: row.operator, finishTime: row.finish_time,
|
|
346
|
-
expireTime: row.expire_time, formKey: row.form_key,
|
|
347
|
-
|
|
348
|
-
|
|
353
|
+
expireTime: row.expire_time, formKey: row.form_key,
|
|
354
|
+
parentTaskId: row.task_parent_id != null ? rowId(row.task_parent_id) : undefined,
|
|
355
|
+
createTime: row.create_time, createUser: rowId(row.create_user),
|
|
356
|
+
updateTime: row.update_time, updateUser: rowId(row.update_user),
|
|
349
357
|
});
|
|
350
358
|
task.variables = row.variable ? JSON.parse(row.variable) : {};
|
|
351
359
|
task.actorIds = [];
|
|
@@ -435,10 +443,10 @@ export class JdbcRepository {
|
|
|
435
443
|
where + ' ORDER BY t.id DESC LIMIT ? OFFSET ?'), [...cond.params, pageSize, (pageNum - 1) * pageSize]);
|
|
436
444
|
return {
|
|
437
445
|
rows: rows.map(r => ({
|
|
438
|
-
id:
|
|
446
|
+
id: rowId(r.id), name: r.name, displayName: r.display_name, type: r.type,
|
|
439
447
|
state: Number(r.state), version: Number(r.version),
|
|
440
|
-
createTime: r.create_time, createUser: r.create_user
|
|
441
|
-
updateTime: r.update_time, updateUser: r.update_user
|
|
448
|
+
createTime: r.create_time, createUser: rowId(r.create_user),
|
|
449
|
+
updateTime: r.update_time, updateUser: rowId(r.update_user),
|
|
442
450
|
})),
|
|
443
451
|
total,
|
|
444
452
|
};
|
|
@@ -504,12 +512,12 @@ export class JdbcRepository {
|
|
|
504
512
|
catch { /* 忽略坏 JSON */ }
|
|
505
513
|
}
|
|
506
514
|
return {
|
|
507
|
-
id:
|
|
508
|
-
defineId:
|
|
515
|
+
id: rowId(r.id), parentId: r.parent_id != null ? rowId(r.parent_id) : undefined,
|
|
516
|
+
defineId: rowId(r.process_define_id), state: r.state,
|
|
509
517
|
parentNodeName: r.parent_node_name ?? '', businessNo: r.business_no ?? '', operator: r.operator ?? '',
|
|
510
518
|
expireTime: r.expire_time ?? undefined, variables,
|
|
511
|
-
createTime: r.create_time, createUser: r.create_user
|
|
512
|
-
updateTime: r.update_time, updateUser: r.update_user
|
|
519
|
+
createTime: r.create_time, createUser: rowId(r.create_user),
|
|
520
|
+
updateTime: r.update_time, updateUser: rowId(r.update_user),
|
|
513
521
|
defineName: r.name ?? '', defineDisplayName: r.display_name ?? '',
|
|
514
522
|
defineVersion: Number(r.version ?? 0),
|
|
515
523
|
};
|
|
@@ -583,13 +591,13 @@ export class JdbcRepository {
|
|
|
583
591
|
catch { /* 忽略坏 JSON */ }
|
|
584
592
|
}
|
|
585
593
|
return {
|
|
586
|
-
id:
|
|
594
|
+
id: rowId(r.id), processInstanceId: rowId(r.process_instance_id), taskName: r.task_name,
|
|
587
595
|
displayName: r.display_name, taskType: Number(r.task_type), performType: Number(r.perform_type),
|
|
588
596
|
taskState: r.task_state, operator: r.operator ?? '', finishTime: r.finish_time ?? undefined,
|
|
589
597
|
expireTime: r.expire_time ?? undefined, formKey: r.form_key ?? '',
|
|
590
|
-
taskParentId: r.task_parent_id != null ?
|
|
591
|
-
variables, createTime: r.create_time, createUser: r.create_user
|
|
592
|
-
updateTime: r.update_time, updateUser: r.update_user
|
|
598
|
+
taskParentId: r.task_parent_id != null ? rowId(r.task_parent_id) : undefined,
|
|
599
|
+
variables, createTime: r.create_time, createUser: rowId(r.create_user),
|
|
600
|
+
updateTime: r.update_time, updateUser: rowId(r.update_user),
|
|
593
601
|
processDefineName: r.name ?? '', processDefineDisplayName: r.display_name ?? '',
|
|
594
602
|
defineVersion: Number(r.process_define_version ?? 0),
|
|
595
603
|
instanceVariable: r.instance_variable ?? '', instanceCreateTime: r.instance_create_time,
|
|
@@ -628,12 +636,12 @@ export class JdbcRepository {
|
|
|
628
636
|
catch { /* 忽略坏 JSON */ }
|
|
629
637
|
}
|
|
630
638
|
return {
|
|
631
|
-
id:
|
|
632
|
-
defineId:
|
|
639
|
+
id: rowId(r.id), parentId: r.parent_id != null ? rowId(r.parent_id) : undefined,
|
|
640
|
+
defineId: rowId(r.process_define_id), state: r.state,
|
|
633
641
|
parentNodeName: r.parent_node_name ?? '', businessNo: r.business_no ?? '', operator: r.operator ?? '',
|
|
634
642
|
expireTime: r.expire_time ?? undefined, variables,
|
|
635
|
-
createTime: r.create_time, createUser: r.create_user
|
|
636
|
-
updateTime: r.update_time, updateUser: r.update_user
|
|
643
|
+
createTime: r.create_time, createUser: rowId(r.create_user),
|
|
644
|
+
updateTime: r.update_time, updateUser: rowId(r.update_user),
|
|
637
645
|
defineName: r.name ?? '', defineDisplayName: r.display_name ?? '',
|
|
638
646
|
defineVersion: Number(r.version ?? 0),
|
|
639
647
|
};
|
package/dist/memory-ext.d.ts
CHANGED
|
@@ -5,17 +5,17 @@ export declare class MemoryExtRepository implements ProcessExtRepository {
|
|
|
5
5
|
private designHis;
|
|
6
6
|
private surrogates;
|
|
7
7
|
private seq;
|
|
8
|
-
findDesignById(id:
|
|
8
|
+
findDesignById(id: string): Promise<ProcessDesign | null>;
|
|
9
9
|
saveDesign(d: ProcessDesign): Promise<void>;
|
|
10
10
|
updateDesign(d: ProcessDesign): Promise<void>;
|
|
11
|
-
removeDesign(id:
|
|
11
|
+
removeDesign(id: string): Promise<void>;
|
|
12
12
|
pageDesigns(_pageNum?: number, _pageSize?: number, _filters?: Record<string, any>, conditions?: QueryCondition[]): Promise<[ProcessDesign[], number]>;
|
|
13
13
|
saveDesignHis(his: ProcessDesignHis): Promise<void>;
|
|
14
|
-
listDesignHis(designId:
|
|
15
|
-
findSurrogateById(id:
|
|
14
|
+
listDesignHis(designId: string): Promise<ProcessDesignHis[]>;
|
|
15
|
+
findSurrogateById(id: string): Promise<ProcessSurrogate | null>;
|
|
16
16
|
saveSurrogate(s: ProcessSurrogate): Promise<void>;
|
|
17
17
|
updateSurrogate(s: ProcessSurrogate): Promise<void>;
|
|
18
|
-
removeSurrogate(id:
|
|
18
|
+
removeSurrogate(id: string): Promise<void>;
|
|
19
19
|
pageSurrogates(_pageNum?: number, _pageSize?: number, filters?: Record<string, any>, conditions?: QueryCondition[]): Promise<[ProcessSurrogate[], number]>;
|
|
20
20
|
getSurrogate(operator: string, processName: string, at?: Date): Promise<ProcessSurrogate | null>;
|
|
21
21
|
}
|
package/dist/memory-ext.js
CHANGED
|
@@ -28,7 +28,7 @@ export class MemoryExtRepository {
|
|
|
28
28
|
async findDesignById(id) { return this.designs.get(id) ?? null; }
|
|
29
29
|
async saveDesign(d) {
|
|
30
30
|
if (!d.id)
|
|
31
|
-
d.id = this.seq
|
|
31
|
+
d.id = String(this.seq++);
|
|
32
32
|
const now = new Date();
|
|
33
33
|
if (!d.createTime)
|
|
34
34
|
d.createTime = now;
|
|
@@ -51,7 +51,7 @@ export class MemoryExtRepository {
|
|
|
51
51
|
// ── 设计历史 ──
|
|
52
52
|
async saveDesignHis(his) {
|
|
53
53
|
if (!his.id)
|
|
54
|
-
his.id = this.seq
|
|
54
|
+
his.id = String(this.seq++);
|
|
55
55
|
if (!his.createTime)
|
|
56
56
|
his.createTime = new Date();
|
|
57
57
|
const list = this.designHis.get(his.processDesignId) ?? [];
|
|
@@ -65,7 +65,7 @@ export class MemoryExtRepository {
|
|
|
65
65
|
async findSurrogateById(id) { return this.surrogates.get(id) ?? null; }
|
|
66
66
|
async saveSurrogate(s) {
|
|
67
67
|
if (!s.id)
|
|
68
|
-
s.id = this.seq
|
|
68
|
+
s.id = String(this.seq++);
|
|
69
69
|
const now = new Date();
|
|
70
70
|
if (!s.createTime)
|
|
71
71
|
s.createTime = now;
|
package/dist/memory.d.ts
CHANGED
|
@@ -13,26 +13,26 @@ export declare class MemoryRepository implements ProcessRepository {
|
|
|
13
13
|
private ccInstances;
|
|
14
14
|
private seq;
|
|
15
15
|
addDefine(def: ProcessDefine): void;
|
|
16
|
-
findDefineById(id:
|
|
16
|
+
findDefineById(id: string): Promise<ProcessDefine | null>;
|
|
17
17
|
findDefineByName(name: string): Promise<ProcessDefine | null>;
|
|
18
18
|
saveDefine(def: ProcessDefine): Promise<void>;
|
|
19
19
|
updateDefine(def: ProcessDefine): Promise<void>;
|
|
20
|
-
updateDefineState(defineId:
|
|
21
|
-
removeDefine(defineId:
|
|
20
|
+
updateDefineState(defineId: string, state: number): Promise<void>;
|
|
21
|
+
removeDefine(defineId: string): Promise<void>;
|
|
22
22
|
saveInstance(inst: ProcessInstance): Promise<void>;
|
|
23
23
|
updateInstance(inst: ProcessInstance): Promise<void>;
|
|
24
|
-
findInstanceById(id:
|
|
25
|
-
findTaskById(id:
|
|
24
|
+
findInstanceById(id: string): Promise<ProcessInstance | null>;
|
|
25
|
+
findTaskById(id: string): Promise<ProcessTask | null>;
|
|
26
26
|
saveTask(task: ProcessTask): Promise<void>;
|
|
27
27
|
updateTask(task: ProcessTask): Promise<void>;
|
|
28
|
-
findDoingTasks(instanceId:
|
|
29
|
-
findDoneTasks(instanceId:
|
|
30
|
-
findHistoryTasks(instanceId:
|
|
31
|
-
findTaskActors(taskId:
|
|
32
|
-
addTaskActor(taskId:
|
|
33
|
-
removeTaskActor(taskId:
|
|
34
|
-
createCcInstance(instanceId:
|
|
35
|
-
updateCcStatus(_instanceId:
|
|
28
|
+
findDoingTasks(instanceId: string, taskNames?: string[]): Promise<ProcessTask[]>;
|
|
29
|
+
findDoneTasks(instanceId: string, _taskNames?: string[]): Promise<ProcessTask[]>;
|
|
30
|
+
findHistoryTasks(instanceId: string): Promise<ProcessTask[]>;
|
|
31
|
+
findTaskActors(taskId: string): Promise<string[]>;
|
|
32
|
+
addTaskActor(taskId: string, actors: string[]): Promise<void>;
|
|
33
|
+
removeTaskActor(taskId: string, actors: string[]): Promise<void>;
|
|
34
|
+
createCcInstance(instanceId: string, _creator: string, ...actorIds: string[]): Promise<void>;
|
|
35
|
+
updateCcStatus(_instanceId: string, _actorId: string): Promise<void>;
|
|
36
36
|
pageDefines(pageNum?: number, pageSize?: number, conditions?: QueryCondition[]): Promise<{
|
|
37
37
|
rows: DefineRow[];
|
|
38
38
|
total: number;
|
package/dist/memory.js
CHANGED
|
@@ -101,7 +101,7 @@ export class MemoryRepository {
|
|
|
101
101
|
seq = 1;
|
|
102
102
|
addDefine(def) {
|
|
103
103
|
if (!def.id)
|
|
104
|
-
def.id = this.seq
|
|
104
|
+
def.id = String(this.seq++);
|
|
105
105
|
this.defines.set(def.id, def);
|
|
106
106
|
}
|
|
107
107
|
async findDefineById(id) { return this.defines.get(id) ?? null; }
|
|
@@ -109,7 +109,8 @@ export class MemoryRepository {
|
|
|
109
109
|
async findDefineByName(name) {
|
|
110
110
|
let latest = null;
|
|
111
111
|
for (const d of this.defines.values()) {
|
|
112
|
-
|
|
112
|
+
// BigInt 比较:id 为 string(issue 38 E9),大整数数字比较不可靠
|
|
113
|
+
if (d.name === name && (!latest || BigInt(d.id) > BigInt(latest.id)))
|
|
113
114
|
latest = d;
|
|
114
115
|
}
|
|
115
116
|
return latest;
|
|
@@ -117,7 +118,7 @@ export class MemoryRepository {
|
|
|
117
118
|
// ── 定义写操作(v1.0.1,对齐 SPI)──
|
|
118
119
|
async saveDefine(def) {
|
|
119
120
|
if (!def.id)
|
|
120
|
-
def.id = this.seq
|
|
121
|
+
def.id = String(this.seq++);
|
|
121
122
|
this.defines.set(def.id, def);
|
|
122
123
|
}
|
|
123
124
|
async updateDefine(def) {
|
|
@@ -133,7 +134,7 @@ export class MemoryRepository {
|
|
|
133
134
|
}
|
|
134
135
|
async saveInstance(inst) {
|
|
135
136
|
if (!inst.id)
|
|
136
|
-
inst.id = this.seq
|
|
137
|
+
inst.id = String(this.seq++);
|
|
137
138
|
const cp = cloneInstance(inst);
|
|
138
139
|
cp.tasks = [];
|
|
139
140
|
this.instances.set(inst.id, cp);
|
|
@@ -178,7 +179,7 @@ export class MemoryRepository {
|
|
|
178
179
|
}
|
|
179
180
|
async saveTask(task) {
|
|
180
181
|
if (!task.id)
|
|
181
|
-
task.id = this.seq
|
|
182
|
+
task.id = String(this.seq++);
|
|
182
183
|
const cp = cloneTask(task);
|
|
183
184
|
cp.actorIds = [];
|
|
184
185
|
this.tasks.set(task.id, cp);
|
package/dist/model.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const TypeFork = "snaker:fork";
|
|
|
32
32
|
export declare const TypeJoin = "snaker:join";
|
|
33
33
|
export declare const TypeCustom = "snaker:custom";
|
|
34
34
|
export interface ProcessDefine {
|
|
35
|
-
id:
|
|
35
|
+
id: string;
|
|
36
36
|
name: string;
|
|
37
37
|
displayName: string;
|
|
38
38
|
type: string;
|
|
@@ -45,7 +45,7 @@ export interface ProcessDefine {
|
|
|
45
45
|
updateUser: string;
|
|
46
46
|
}
|
|
47
47
|
export interface ProcessDesign {
|
|
48
|
-
id:
|
|
48
|
+
id: string;
|
|
49
49
|
name: string;
|
|
50
50
|
displayName: string;
|
|
51
51
|
type: string;
|
|
@@ -58,14 +58,14 @@ export interface ProcessDesign {
|
|
|
58
58
|
updateUser: string;
|
|
59
59
|
}
|
|
60
60
|
export interface ProcessDesignHis {
|
|
61
|
-
id:
|
|
62
|
-
processDesignId:
|
|
61
|
+
id: string;
|
|
62
|
+
processDesignId: string;
|
|
63
63
|
content: Uint8Array | string;
|
|
64
64
|
createTime: Date;
|
|
65
65
|
createUser: string;
|
|
66
66
|
}
|
|
67
67
|
export interface ProcessSurrogate {
|
|
68
|
-
id:
|
|
68
|
+
id: string;
|
|
69
69
|
processName?: string;
|
|
70
70
|
operator: string;
|
|
71
71
|
surrogate: string;
|
|
@@ -128,9 +128,9 @@ export declare enum CountersignType {
|
|
|
128
128
|
}
|
|
129
129
|
export declare const BusinessNoKey = "BUSINESS_NO";
|
|
130
130
|
export declare class ProcessInstance {
|
|
131
|
-
id:
|
|
132
|
-
parentId?:
|
|
133
|
-
defineId:
|
|
131
|
+
id: string;
|
|
132
|
+
parentId?: string;
|
|
133
|
+
defineId: string;
|
|
134
134
|
state: InstanceState;
|
|
135
135
|
parentNodeName: string;
|
|
136
136
|
businessNo: string;
|
|
@@ -144,7 +144,7 @@ export declare class ProcessInstance {
|
|
|
144
144
|
updateUser: string;
|
|
145
145
|
constructor(data: any);
|
|
146
146
|
/** 工厂——创建流程实例 */
|
|
147
|
-
static create(id:
|
|
147
|
+
static create(id: string, defineId: string, operator: string, vars: Record<string, any>, now: Date): ProcessInstance;
|
|
148
148
|
/** 完成任务(子实体状态转换 + 实例变量合并) */
|
|
149
149
|
completeTask(task: ProcessTask, operator: string, vars: Record<string, any>, now: Date): void;
|
|
150
150
|
/** 废弃单个任务 */
|
|
@@ -164,11 +164,11 @@ export declare class ProcessInstance {
|
|
|
164
164
|
/** 所有任务是否都已完成(join 合并判断) */
|
|
165
165
|
isAllTasksFinished(): boolean;
|
|
166
166
|
/** 创建任务(子实体工厂) */
|
|
167
|
-
createTask(id:
|
|
167
|
+
createTask(id: string, taskName: string, displayName: string, actor: string, operator: string, formKey: string, now: Date): ProcessTask;
|
|
168
168
|
}
|
|
169
169
|
export declare class ProcessTask {
|
|
170
|
-
id:
|
|
171
|
-
processInstanceId:
|
|
170
|
+
id: string;
|
|
171
|
+
processInstanceId: string;
|
|
172
172
|
taskName: string;
|
|
173
173
|
displayName: string;
|
|
174
174
|
taskType: number;
|
|
@@ -179,7 +179,7 @@ export declare class ProcessTask {
|
|
|
179
179
|
finishTime?: Date;
|
|
180
180
|
expireTime?: Date;
|
|
181
181
|
formKey: string;
|
|
182
|
-
parentTaskId?:
|
|
182
|
+
parentTaskId?: string;
|
|
183
183
|
variables: Record<string, any>;
|
|
184
184
|
createTime: Date;
|
|
185
185
|
createUser: string;
|
|
@@ -208,9 +208,9 @@ export interface UserInfo {
|
|
|
208
208
|
postName?: string;
|
|
209
209
|
}
|
|
210
210
|
export interface CcInstanceRow {
|
|
211
|
-
id:
|
|
212
|
-
parentId?:
|
|
213
|
-
defineId:
|
|
211
|
+
id: string;
|
|
212
|
+
parentId?: string;
|
|
213
|
+
defineId: string;
|
|
214
214
|
state: InstanceState;
|
|
215
215
|
parentNodeName: string;
|
|
216
216
|
businessNo: string;
|
|
@@ -226,7 +226,7 @@ export interface CcInstanceRow {
|
|
|
226
226
|
defineVersion: number;
|
|
227
227
|
}
|
|
228
228
|
export interface DefineRow {
|
|
229
|
-
id:
|
|
229
|
+
id: string;
|
|
230
230
|
name: string;
|
|
231
231
|
displayName: string;
|
|
232
232
|
type: string;
|
|
@@ -238,9 +238,9 @@ export interface DefineRow {
|
|
|
238
238
|
updateUser: string;
|
|
239
239
|
}
|
|
240
240
|
export interface InstanceRow {
|
|
241
|
-
id:
|
|
242
|
-
parentId?:
|
|
243
|
-
defineId:
|
|
241
|
+
id: string;
|
|
242
|
+
parentId?: string;
|
|
243
|
+
defineId: string;
|
|
244
244
|
state: InstanceState;
|
|
245
245
|
parentNodeName: string;
|
|
246
246
|
businessNo: string;
|
|
@@ -256,8 +256,8 @@ export interface InstanceRow {
|
|
|
256
256
|
defineVersion: number;
|
|
257
257
|
}
|
|
258
258
|
export interface TaskRow {
|
|
259
|
-
id:
|
|
260
|
-
processInstanceId:
|
|
259
|
+
id: string;
|
|
260
|
+
processInstanceId: string;
|
|
261
261
|
taskName: string;
|
|
262
262
|
displayName: string;
|
|
263
263
|
taskType: number;
|
|
@@ -267,7 +267,7 @@ export interface TaskRow {
|
|
|
267
267
|
finishTime?: Date;
|
|
268
268
|
expireTime?: Date;
|
|
269
269
|
formKey: string;
|
|
270
|
-
taskParentId?:
|
|
270
|
+
taskParentId?: string;
|
|
271
271
|
variables: Record<string, any>;
|
|
272
272
|
createTime: Date;
|
|
273
273
|
createUser: string;
|
package/dist/persist.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export declare class SqliteDynamicTableWriter implements DynamicTableWriter {
|
|
|
61
61
|
private resolveDefaultUser;
|
|
62
62
|
}
|
|
63
63
|
/** 流程定义加载器(用于解析 relTableName / persistMode / 流程 name),通常透传仓库 findDefineById */
|
|
64
|
-
export type DefineLoader = (defineId:
|
|
64
|
+
export type DefineLoader = (defineId: string) => Promise<ProcessDefine | null>;
|
|
65
65
|
/** 持久化模式(流程定义顶层 persistMode,缺省 ARCHIVE) */
|
|
66
66
|
export declare const PersistModeArchive = "ARCHIVE";
|
|
67
67
|
export declare const PersistModeSync = "SYNC";
|
package/dist/spi.d.ts
CHANGED
|
@@ -5,26 +5,26 @@ export interface QueryCondition {
|
|
|
5
5
|
value: any;
|
|
6
6
|
}
|
|
7
7
|
export interface ProcessRepository {
|
|
8
|
-
findDefineById(id:
|
|
8
|
+
findDefineById(id: string): Promise<ProcessDefine | null>;
|
|
9
9
|
findDefineByName(name: string): Promise<ProcessDefine | null>;
|
|
10
10
|
saveDefine(define: ProcessDefine): Promise<void>;
|
|
11
11
|
updateDefine(define: ProcessDefine): Promise<void>;
|
|
12
|
-
updateDefineState(defineId:
|
|
13
|
-
removeDefine(defineId:
|
|
14
|
-
findInstanceById(id:
|
|
12
|
+
updateDefineState(defineId: string, state: number): Promise<void>;
|
|
13
|
+
removeDefine(defineId: string): Promise<void>;
|
|
14
|
+
findInstanceById(id: string): Promise<ProcessInstance | null>;
|
|
15
15
|
saveInstance(inst: ProcessInstance): Promise<void>;
|
|
16
16
|
updateInstance(inst: ProcessInstance): Promise<void>;
|
|
17
|
-
findTaskById(taskId:
|
|
17
|
+
findTaskById(taskId: string): Promise<ProcessTask | null>;
|
|
18
18
|
saveTask(task: ProcessTask): Promise<void>;
|
|
19
19
|
updateTask(task: ProcessTask): Promise<void>;
|
|
20
|
-
findDoingTasks(instanceId:
|
|
21
|
-
findDoneTasks(instanceId:
|
|
22
|
-
findHistoryTasks(instanceId:
|
|
23
|
-
findTaskActors(taskId:
|
|
24
|
-
addTaskActor(taskId:
|
|
25
|
-
removeTaskActor(taskId:
|
|
26
|
-
createCcInstance(instanceId:
|
|
27
|
-
updateCcStatus(instanceId:
|
|
20
|
+
findDoingTasks(instanceId: string, taskNames?: string[]): Promise<ProcessTask[]>;
|
|
21
|
+
findDoneTasks(instanceId: string, taskNames?: string[]): Promise<ProcessTask[]>;
|
|
22
|
+
findHistoryTasks(instanceId: string): Promise<ProcessTask[]>;
|
|
23
|
+
findTaskActors(taskId: string): Promise<string[]>;
|
|
24
|
+
addTaskActor(taskId: string, actors: string[]): Promise<void>;
|
|
25
|
+
removeTaskActor(taskId: string, actors: string[]): Promise<void>;
|
|
26
|
+
createCcInstance(instanceId: string, creator: string, ...actorIds: string[]): Promise<void>;
|
|
27
|
+
updateCcStatus(instanceId: string, actorId: string): Promise<void>;
|
|
28
28
|
pageCcInstances(pageNum: number, pageSize: number, actorId: string, conditions?: QueryCondition[]): Promise<{
|
|
29
29
|
rows: CcInstanceRow[];
|
|
30
30
|
total: number;
|
|
@@ -58,23 +58,23 @@ export interface OrgUserProvider {
|
|
|
58
58
|
findByRole(roleCode: string): Promise<string[]>;
|
|
59
59
|
}
|
|
60
60
|
export interface IDGenerator {
|
|
61
|
-
nextId():
|
|
61
|
+
nextId(): string;
|
|
62
62
|
}
|
|
63
63
|
export interface ExpressionEvaluator {
|
|
64
64
|
eval(expr: string, vars: Record<string, any>): Promise<any>;
|
|
65
65
|
}
|
|
66
66
|
export interface ProcessExtRepository {
|
|
67
|
-
findDesignById(id:
|
|
67
|
+
findDesignById(id: string): Promise<ProcessDesign | null>;
|
|
68
68
|
saveDesign(d: ProcessDesign): Promise<void>;
|
|
69
69
|
updateDesign(d: ProcessDesign): Promise<void>;
|
|
70
|
-
removeDesign(id:
|
|
70
|
+
removeDesign(id: string): Promise<void>;
|
|
71
71
|
pageDesigns(pageNum?: number, pageSize?: number, filters?: Record<string, any>, conditions?: QueryCondition[]): Promise<[ProcessDesign[], number]>;
|
|
72
72
|
saveDesignHis(his: ProcessDesignHis): Promise<void>;
|
|
73
|
-
listDesignHis(designId:
|
|
74
|
-
findSurrogateById(id:
|
|
73
|
+
listDesignHis(designId: string): Promise<ProcessDesignHis[]>;
|
|
74
|
+
findSurrogateById(id: string): Promise<ProcessSurrogate | null>;
|
|
75
75
|
saveSurrogate(s: ProcessSurrogate): Promise<void>;
|
|
76
76
|
updateSurrogate(s: ProcessSurrogate): Promise<void>;
|
|
77
|
-
removeSurrogate(id:
|
|
77
|
+
removeSurrogate(id: string): Promise<void>;
|
|
78
78
|
pageSurrogates(pageNum?: number, pageSize?: number, filters?: Record<string, any>, conditions?: QueryCondition[]): Promise<[ProcessSurrogate[], number]>;
|
|
79
79
|
getSurrogate(operator: string, processName: string, at?: Date): Promise<ProcessSurrogate | null>;
|
|
80
80
|
}
|
package/package.json
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mldong/jeeflow",
|
|
3
|
-
"version": "1.8.
|
|
4
|
-
"description": "jeeflow workflow engine — Node.js / TypeScript implementation",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": "./dist/index.js",
|
|
10
|
-
"./engine": "./dist/engine.js",
|
|
11
|
-
"./model": "./dist/model.js",
|
|
12
|
-
"./spi": "./dist/spi.js",
|
|
13
|
-
"./memory": "./dist/memory.js",
|
|
14
|
-
"./jdbc": "./dist/jdbc/index.js",
|
|
15
|
-
"./mysql": "./dist/jdbc/mysql.js",
|
|
16
|
-
"./postgres": "./dist/jdbc/postgres.js",
|
|
17
|
-
"./jdbc/ext": "./dist/jdbc/ext.js"
|
|
18
|
-
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsc",
|
|
21
|
-
"test": "node --import tsx __tests__/spec.test.ts",
|
|
22
|
-
"demo": "node --import tsx demo/main.ts",
|
|
23
|
-
"prepublishOnly": "npm run build"
|
|
24
|
-
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"workflow",
|
|
27
|
-
"engine",
|
|
28
|
-
"jeeflow",
|
|
29
|
-
"typescript"
|
|
30
|
-
],
|
|
31
|
-
"license": "Apache-2.0",
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@types/express": "^4.17.25",
|
|
34
|
-
"@types/pg": "^8.20.3",
|
|
35
|
-
"express": "^4.22.2",
|
|
36
|
-
"tsx": "^4.19.0",
|
|
37
|
-
"typescript": "^5.5.0"
|
|
38
|
-
},
|
|
39
|
-
"optionalDependencies": {
|
|
40
|
-
"mysql2": "^3.11.0",
|
|
41
|
-
"pg": "^8.13.0"
|
|
42
|
-
},
|
|
43
|
-
"files": [
|
|
44
|
-
"dist",
|
|
45
|
-
"LICENSE",
|
|
46
|
-
"README.md"
|
|
47
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"name": "@mldong/jeeflow",
|
|
3
|
+
"version": "1.8.6",
|
|
4
|
+
"description": "jeeflow workflow engine — Node.js / TypeScript implementation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js",
|
|
10
|
+
"./engine": "./dist/engine.js",
|
|
11
|
+
"./model": "./dist/model.js",
|
|
12
|
+
"./spi": "./dist/spi.js",
|
|
13
|
+
"./memory": "./dist/memory.js",
|
|
14
|
+
"./jdbc": "./dist/jdbc/index.js",
|
|
15
|
+
"./mysql": "./dist/jdbc/mysql.js",
|
|
16
|
+
"./postgres": "./dist/jdbc/postgres.js",
|
|
17
|
+
"./jdbc/ext": "./dist/jdbc/ext.js"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"test": "node --import tsx __tests__/spec.test.ts",
|
|
22
|
+
"demo": "node --import tsx demo/main.ts",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"workflow",
|
|
27
|
+
"engine",
|
|
28
|
+
"jeeflow",
|
|
29
|
+
"typescript"
|
|
30
|
+
],
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/express": "^4.17.25",
|
|
34
|
+
"@types/pg": "^8.20.3",
|
|
35
|
+
"express": "^4.22.2",
|
|
36
|
+
"tsx": "^4.19.0",
|
|
37
|
+
"typescript": "^5.5.0"
|
|
38
|
+
},
|
|
39
|
+
"optionalDependencies": {
|
|
40
|
+
"mysql2": "^3.11.0",
|
|
41
|
+
"pg": "^8.13.0"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"LICENSE",
|
|
46
|
+
"README.md"
|
|
47
|
+
]
|
|
48
48
|
}
|