@mldong/jeeflow 1.2.0 → 1.3.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/facade.d.ts CHANGED
@@ -28,6 +28,7 @@ export declare class JeeflowFacade {
28
28
  private getAssigneeTextData;
29
29
  private createCCInstance;
30
30
  private updateCCStatus;
31
+ private ccList;
31
32
  private taskDetail;
32
33
  private jumpAbleTaskNameList;
33
34
  private candidatePage;
package/dist/facade.js CHANGED
@@ -80,7 +80,7 @@ export class JeeflowFacade {
80
80
  case 'processInstance/updateCCStatus':
81
81
  return this.updateCCStatus(args);
82
82
  case 'processInstance/ccList':
83
- throw new Error('ccList 需要核心分页 SPI(pageCcInstances),当前语言 1.3.0 补齐');
83
+ return this.ccList(args);
84
84
  case 'processTask/detail':
85
85
  return this.taskDetail(args);
86
86
  case 'processTask/jumpAbleTaskNameList':
@@ -419,6 +419,14 @@ export class JeeflowFacade {
419
419
  const operator = String(args.operator ?? 'user1');
420
420
  await this.repo.updateCcStatus(instanceId, operator);
421
421
  }
422
+ // ccList 我的抄送分页(v1.3.0):operator 作为抄送人过滤
423
+ async ccList(args) {
424
+ const pageNum = toInt(args.pageNum ?? 1);
425
+ const pageSize = toInt(args.pageSize ?? 10);
426
+ const actorId = String(args.operator ?? 'user1');
427
+ const { rows, total } = await this.repo.pageCcInstances(pageNum, pageSize, actorId);
428
+ return { rows, recordCount: total };
429
+ }
422
430
  async taskDetail(args) {
423
431
  const taskId = toId(args.id);
424
432
  const operator = String(args.operator ?? 'user1');
@@ -1,4 +1,4 @@
1
- import { ProcessInstance, ProcessTask, type ProcessDefine } from '../model.js';
1
+ import { ProcessInstance, ProcessTask, type ProcessDefine, type CcInstanceRow } from '../model.js';
2
2
  import type { IDGenerator, ProcessRepository } from '../spi.js';
3
3
  /** 默认 ID 生成器:时间戳毫秒 + 同毫秒递增序号(对齐 Java nextId 默认实现) */
4
4
  export declare class TsIDGenerator implements IDGenerator {
@@ -63,4 +63,9 @@ export declare class JdbcRepository implements ProcessRepository {
63
63
  removeTaskActor(taskId: number, actors: string[]): Promise<void>;
64
64
  createCcInstance(instanceId: number, creator: string, ...actorIds: string[]): Promise<void>;
65
65
  updateCcStatus(instanceId: number, actorId: string): Promise<void>;
66
+ pageCcInstances(pageNum: number, pageSize: number, actorId: string): Promise<{
67
+ rows: CcInstanceRow[];
68
+ total: number;
69
+ }>;
70
+ private mapCcRow;
66
71
  }
@@ -349,9 +349,17 @@ export class JdbcRepository {
349
349
  }
350
350
  }
351
351
  async addTaskActor(taskId, actors) {
352
+ if (actors.length === 0)
353
+ return;
354
+ // 追加语义(对齐 boot2/boot3,issues/03):查已有参与者,去重后仅插入新增,不清空原参与者
355
+ const existing = await this.findTaskActors(taskId);
356
+ const seen = new Set(existing);
357
+ const toAdd = actors.filter(a => !seen.has(a));
358
+ if (toAdd.length === 0)
359
+ return;
352
360
  const conn = await this.c();
353
361
  try {
354
- await this.insertTaskActors(conn, taskId, actors);
362
+ await this.insertTaskActors(conn, taskId, toAdd);
355
363
  }
356
364
  finally {
357
365
  await this.done(conn);
@@ -391,4 +399,46 @@ export class JdbcRepository {
391
399
  await this.done(conn);
392
400
  }
393
401
  }
402
+ // pageCcInstances 我的抄送分页(v1.3.0):cc 表 join 实例 + 定义,按抄送人过滤(对齐 Java pageCcInstances)
403
+ async pageCcInstances(pageNum, pageSize, actorId) {
404
+ const where = ' FROM wf_process_instance t' +
405
+ ' LEFT JOIN wf_process_define pd ON t.process_define_id = pd.id' +
406
+ ' LEFT JOIN wf_process_cc_instance cc ON t.id = cc.process_instance_id' +
407
+ ' WHERE cc.actor_id = ?';
408
+ const cols = 't.id, t.parent_id, t.process_define_id, t.state, t.parent_node_name, t.business_no,' +
409
+ ' t.operator, t.expire_time, t.variable, t.create_time, t.create_user, t.update_time, t.update_user,' +
410
+ ' pd.name, pd.display_name, pd.version';
411
+ const conn = await this.c();
412
+ try {
413
+ const countRow = await conn.fetchOne(this.sql('SELECT COUNT(*) ' + where), [actorId]);
414
+ const total = Number(Object.values(countRow)[0] ?? 0);
415
+ const rows = await conn.fetchAll(this.sql(`SELECT ${cols}${where} ORDER BY t.id ASC LIMIT ? OFFSET ?`), [actorId, pageSize, (pageNum - 1) * pageSize]);
416
+ return {
417
+ rows: rows.map(r => this.mapCcRow(r)),
418
+ total,
419
+ };
420
+ }
421
+ finally {
422
+ await this.done(conn);
423
+ }
424
+ }
425
+ mapCcRow(r) {
426
+ let variables = {};
427
+ if (r.variable) {
428
+ try {
429
+ variables = JSON.parse(r.variable);
430
+ }
431
+ catch { /* 忽略坏 JSON */ }
432
+ }
433
+ return {
434
+ id: Number(r.id), parentId: r.parent_id != null ? Number(r.parent_id) : undefined,
435
+ defineId: Number(r.process_define_id), state: r.state,
436
+ parentNodeName: r.parent_node_name ?? '', businessNo: r.business_no ?? '', operator: r.operator ?? '',
437
+ expireTime: r.expire_time ?? undefined, variables,
438
+ createTime: r.create_time, createUser: r.create_user ?? '',
439
+ updateTime: r.update_time, updateUser: r.update_user ?? '',
440
+ defineName: r.name ?? '', defineDisplayName: r.display_name ?? '',
441
+ defineVersion: Number(r.version ?? 0),
442
+ };
443
+ }
394
444
  }
package/dist/memory.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProcessDefine } from './model.js';
1
+ import type { CcInstanceRow, ProcessDefine } from './model.js';
2
2
  import { type ProcessInstance, type ProcessTask } from './model.js';
3
3
  import type { ProcessRepository } from './spi.js';
4
4
  export declare class MemoryRepository implements ProcessRepository {
@@ -6,6 +6,7 @@ export declare class MemoryRepository implements ProcessRepository {
6
6
  private instances;
7
7
  private tasks;
8
8
  private actors;
9
+ private ccInstances;
9
10
  private seq;
10
11
  addDefine(def: ProcessDefine): void;
11
12
  findDefineById(id: number): Promise<ProcessDefine | null>;
@@ -26,8 +27,12 @@ export declare class MemoryRepository implements ProcessRepository {
26
27
  findTaskActors(taskId: number): Promise<string[]>;
27
28
  addTaskActor(taskId: number, actors: string[]): Promise<void>;
28
29
  removeTaskActor(taskId: number, actors: string[]): Promise<void>;
29
- createCcInstance(..._args: any[]): Promise<void>;
30
- updateCcStatus(..._args: any[]): Promise<void>;
30
+ createCcInstance(instanceId: number, _creator: string, ...actorIds: string[]): Promise<void>;
31
+ updateCcStatus(_instanceId: number, _actorId: string): Promise<void>;
32
+ pageCcInstances(pageNum: number | undefined, pageSize: number | undefined, actorId: string): Promise<{
33
+ rows: CcInstanceRow[];
34
+ total: number;
35
+ }>;
31
36
  allDefines(): ProcessDefine[];
32
37
  allInstances(): ProcessInstance[];
33
38
  allTasks(): ProcessTask[];
package/dist/memory.js CHANGED
@@ -4,6 +4,7 @@ export class MemoryRepository {
4
4
  instances = new Map();
5
5
  tasks = new Map();
6
6
  actors = new Map();
7
+ ccInstances = new Map();
7
8
  seq = 1;
8
9
  addDefine(def) {
9
10
  if (!def.id)
@@ -149,8 +150,42 @@ export class MemoryRepository {
149
150
  const remove = new Set(actors);
150
151
  this.actors.set(taskId, (this.actors.get(taskId) ?? []).filter(a => !remove.has(a)));
151
152
  }
152
- async createCcInstance(..._args) { }
153
- async updateCcStatus(..._args) { }
153
+ async createCcInstance(instanceId, _creator, ...actorIds) {
154
+ const existing = this.ccInstances.get(instanceId) ?? [];
155
+ const seen = new Set(existing);
156
+ for (const a of actorIds) {
157
+ if (!seen.has(a)) {
158
+ existing.push(a);
159
+ seen.add(a);
160
+ }
161
+ }
162
+ this.ccInstances.set(instanceId, existing);
163
+ }
164
+ async updateCcStatus(_instanceId, _actorId) { }
165
+ // pageCcInstances 我的抄送分页(v1.3.0):按抄送人 actorId 过滤,join 实例 + 定义
166
+ async pageCcInstances(pageNum = 1, pageSize = 10, actorId) {
167
+ const rows = [];
168
+ for (const [instId, actors] of this.ccInstances) {
169
+ if (actorId && !actors.includes(actorId))
170
+ continue;
171
+ const inst = this.instances.get(instId);
172
+ if (!inst)
173
+ continue;
174
+ const def = this.defines.get(inst.defineId);
175
+ rows.push({
176
+ id: inst.id, parentId: inst.parentId, defineId: inst.defineId, state: inst.state,
177
+ parentNodeName: inst.parentNodeName, businessNo: inst.businessNo, operator: inst.operator,
178
+ expireTime: inst.expireTime, variables: { ...inst.variables },
179
+ createTime: inst.createTime, createUser: inst.createUser,
180
+ updateTime: inst.updateTime, updateUser: inst.updateUser,
181
+ defineName: def?.name ?? '', defineDisplayName: def?.displayName ?? '',
182
+ defineVersion: def?.version ?? 0,
183
+ });
184
+ }
185
+ const total = rows.length;
186
+ const start = (pageNum - 1) * pageSize;
187
+ return { rows: rows.slice(start, start + pageSize), total };
188
+ }
154
189
  allDefines() { return [...this.defines.values()]; }
155
190
  allInstances() { return [...this.instances.values()]; }
156
191
  allTasks() {
package/dist/model.d.ts CHANGED
@@ -168,3 +168,21 @@ export interface UserInfo {
168
168
  postId?: string;
169
169
  postName?: string;
170
170
  }
171
+ export interface CcInstanceRow {
172
+ id: number;
173
+ parentId?: number;
174
+ defineId: number;
175
+ state: InstanceState;
176
+ parentNodeName: string;
177
+ businessNo: string;
178
+ operator: string;
179
+ expireTime?: Date;
180
+ variables: Record<string, any>;
181
+ createTime: Date;
182
+ createUser: string;
183
+ updateTime: Date;
184
+ updateUser: string;
185
+ defineName: string;
186
+ defineDisplayName: string;
187
+ defineVersion: number;
188
+ }
package/dist/spi.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProcessDefine, ProcessDesign, ProcessDesignHis, ProcessInstance, ProcessSurrogate, ProcessTask, UserInfo } from './model.js';
1
+ import type { CcInstanceRow, ProcessDefine, ProcessDesign, ProcessDesignHis, ProcessInstance, ProcessSurrogate, ProcessTask, UserInfo } from './model.js';
2
2
  export interface ProcessRepository {
3
3
  findDefineById(id: number): Promise<ProcessDefine | null>;
4
4
  findDefineByName(name: string): Promise<ProcessDefine | null>;
@@ -20,6 +20,10 @@ export interface ProcessRepository {
20
20
  removeTaskActor(taskId: number, actors: string[]): Promise<void>;
21
21
  createCcInstance(instanceId: number, creator: string, ...actorIds: string[]): Promise<void>;
22
22
  updateCcStatus(instanceId: number, actorId: string): Promise<void>;
23
+ pageCcInstances(pageNum: number, pageSize: number, actorId: string): Promise<{
24
+ rows: CcInstanceRow[];
25
+ total: number;
26
+ }>;
23
27
  }
24
28
  export interface UserProvider {
25
29
  getUser(userId: string): Promise<UserInfo | null>;
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "@mldong/jeeflow",
3
- "version": "1.2.0",
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
- },
18
- "scripts": {
19
- "build": "tsc",
20
- "test": "node --import tsx __tests__/spec.test.ts",
21
- "demo": "node --import tsx demo/main.ts",
22
- "prepublishOnly": "npm run build"
23
- },
24
- "keywords": [
25
- "workflow",
26
- "engine",
27
- "jeeflow",
28
- "typescript"
29
- ],
30
- "license": "Apache-2.0",
31
- "devDependencies": {
32
- "@types/pg": "^8.20.3",
33
- "tsx": "^4.19.0",
34
- "typescript": "^5.5.0"
35
- },
36
- "optionalDependencies": {
37
- "mysql2": "^3.11.0",
38
- "pg": "^8.13.0"
39
- },
40
- "files": [
41
- "dist",
42
- "LICENSE",
43
- "README.md"
44
- ]
45
- }
1
+ {
2
+ "name": "@mldong/jeeflow",
3
+ "version": "1.3.0",
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
+ },
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "test": "node --import tsx __tests__/spec.test.ts",
21
+ "demo": "node --import tsx demo/main.ts",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "workflow",
26
+ "engine",
27
+ "jeeflow",
28
+ "typescript"
29
+ ],
30
+ "license": "Apache-2.0",
31
+ "devDependencies": {
32
+ "@types/pg": "^8.20.3",
33
+ "tsx": "^4.19.0",
34
+ "typescript": "^5.5.0"
35
+ },
36
+ "optionalDependencies": {
37
+ "mysql2": "^3.11.0",
38
+ "pg": "^8.13.0"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "LICENSE",
43
+ "README.md"
44
+ ]
45
+ }