@mldong/jeeflow 1.8.13 → 1.8.15

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 CHANGED
@@ -1,80 +1,80 @@
1
- # jeeflow · Node.js / TypeScript
2
-
3
- [jeeflow](https://jeeflow-doc.mldong.com) 引擎规范的 **TypeScript 实现**。仅依赖 `node:*` 标准库,零外部依赖(引擎核心)。
4
-
5
- > **v1.1.0**:新增管理扩展(流程设计/历史/委托 + `ProcessExtRepository`)与统一门面
6
- > `JeeflowFacade.flow(action, args)`;assignee 变量解析与 `flow.auto`/`flow.admin` 系统代执行对齐 boot2/boot3。
7
-
8
- ```bash
9
- npm install @mldong/jeeflow # 等发布到 npm 后
10
- ```
11
-
12
- ## 快速开始
13
-
14
- ```ts
15
- import { EngineImpl, MemoryRepository } from '@mldong/jeeflow'
16
-
17
- const repo = new MemoryRepository()
18
- const engine = new EngineImpl(repo)
19
-
20
- const def = {
21
- id: '1', name: 'leave', displayName: '请假审批',
22
- content: JSON.stringify({ nodes: [...], edges: [...] })
23
- }
24
- repo.addDefine(def)
25
-
26
- const inst = await engine.startProcessInstanceById(def.id, '张三')
27
- const tasks = await repo.findDoingTasks(inst.id)
28
- await engine.executeProcessTask(tasks[0].id, 'leader')
29
- ```
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
-
53
- ## 运行演示
54
-
55
- ```bash
56
- git clone https://github.com/mldong/jeeflow-node
57
- cd jeeflow-node
58
- npm install
59
- npm run demo # http://localhost:8082
60
- ```
61
-
62
- ## 目录
63
-
64
- | 路径 | 说明 |
65
- |------|------|
66
- | `src/engine.ts` | 引擎核心 |
67
- | `src/model.ts` | 域类型 |
68
- | `src/spi.ts` | SPI 接口 |
69
- | `src/memory.ts` | 内存仓储 |
70
- | `src/jdbc/` | JDBC 多库实现(shared 核心 + mysql/postgres 适配器) |
71
- | `demo/main.ts` | Express 演示 |
72
- | `__tests__/` | 9 项合规测试 |
73
-
74
- ## 节点支持
75
-
76
- 对齐 [SPEC.md](https://jeeflow-doc.mldong.com) v1.0——与 Java/Go 版一致。
77
-
78
- ## License
79
-
80
- Apache-2.0
1
+ # jeeflow · Node.js / TypeScript
2
+
3
+ [jeeflow](https://jeeflow-doc.mldong.com) 引擎规范的 **TypeScript 实现**。仅依赖 `node:*` 标准库,零外部依赖(引擎核心)。
4
+
5
+ > **v1.1.0**:新增管理扩展(流程设计/历史/委托 + `ProcessExtRepository`)与统一门面
6
+ > `JeeflowFacade.flow(action, args)`;assignee 变量解析与 `flow.auto`/`flow.admin` 系统代执行对齐 boot2/boot3。
7
+
8
+ ```bash
9
+ npm install @mldong/jeeflow # 等发布到 npm 后
10
+ ```
11
+
12
+ ## 快速开始
13
+
14
+ ```ts
15
+ import { EngineImpl, MemoryRepository } from '@mldong/jeeflow'
16
+
17
+ const repo = new MemoryRepository()
18
+ const engine = new EngineImpl(repo)
19
+
20
+ const def = {
21
+ id: '1', name: 'leave', displayName: '请假审批',
22
+ content: JSON.stringify({ nodes: [...], edges: [...] })
23
+ }
24
+ repo.addDefine(def)
25
+
26
+ const inst = await engine.startProcessInstanceById(def.id, '张三')
27
+ const tasks = await repo.findDoingTasks(inst.id)
28
+ await engine.executeProcessTask(tasks[0].id, 'leader')
29
+ ```
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
+
53
+ ## 运行演示
54
+
55
+ ```bash
56
+ git clone https://github.com/mldong/jeeflow-node
57
+ cd jeeflow-node
58
+ npm install
59
+ npm run demo # http://localhost:8082
60
+ ```
61
+
62
+ ## 目录
63
+
64
+ | 路径 | 说明 |
65
+ |------|------|
66
+ | `src/engine.ts` | 引擎核心 |
67
+ | `src/model.ts` | 域类型 |
68
+ | `src/spi.ts` | SPI 接口 |
69
+ | `src/memory.ts` | 内存仓储 |
70
+ | `src/jdbc/` | JDBC 多库实现(shared 核心 + mysql/postgres 适配器) |
71
+ | `demo/main.ts` | Express 演示 |
72
+ | `__tests__/` | 9 项合规测试 |
73
+
74
+ ## 节点支持
75
+
76
+ 对齐 [SPEC.md](https://jeeflow-doc.mldong.com) v1.0——与 Java/Go 版一致。
77
+
78
+ ## License
79
+
80
+ Apache-2.0
package/dist/engine.d.ts CHANGED
@@ -14,6 +14,7 @@ export declare const KeyNextNodeOperator = "tf_nextNodeOperator";
14
14
  export declare const KeyProcessStartNextNodeOperator = "f_nextNodeOperator";
15
15
  export declare const KeyAutoExecute = "flow.auto";
16
16
  export declare const KeyAdminID = "flow.admin";
17
+ export declare const KeyAutoGenTitle = "autoGenTitle";
17
18
  export interface Engine {
18
19
  startProcessInstanceById(defineId: string, operator: string, args?: Record<string, any>): Promise<ProcessInstance>;
19
20
  executeProcessTask(taskId: string, operator: string, args?: Record<string, any>): Promise<ProcessInstance>;
@@ -55,6 +56,8 @@ export declare class EngineImpl implements Engine {
55
56
  private resolveActors;
56
57
  private isAllowed;
57
58
  private addUserInfo;
59
+ /** issue 29:自动生成标题(对齐 boot3 FlowUtil.addAutoGenTitle) */
60
+ private addAutoGenTitle;
58
61
  /** 用户提供者访问(issue 41 补强:nodeProgress 姓名解析用) */
59
62
  getUserProvider(): UserProvider | undefined;
60
63
  private nextId;
package/dist/engine.js CHANGED
@@ -15,6 +15,8 @@ export const KeyProcessStartNextNodeOperator = 'f_nextNodeOperator';
15
15
  // v1.0.1:系统代执行 / 超级管理员(对齐 boot3 FlowConst)
16
16
  export const KeyAutoExecute = 'flow.auto';
17
17
  export const KeyAdminID = 'flow.admin';
18
+ // issue 29:自动生成标题(对齐 boot3 FlowConst.AUTO_GEN_TITLE)
19
+ export const KeyAutoGenTitle = 'autoGenTitle';
18
20
  export class EngineImpl {
19
21
  repo;
20
22
  userProv;
@@ -109,6 +111,7 @@ export class EngineImpl {
109
111
  const flow = JSON.parse(content);
110
112
  const vars = { ...args };
111
113
  await this.addUserInfo(operator, vars);
114
+ this.addAutoGenTitle(def.displayName, vars);
112
115
  const now = new Date();
113
116
  // 聚合根工厂创建实例
114
117
  const inst = ProcessInstance.create(this.nextId(), defineId, operator, vars, now);
@@ -476,6 +479,14 @@ export class EngineImpl {
476
479
  if (u.postName)
477
480
  vars[KeyPostName] = u.postName;
478
481
  }
482
+ /** issue 29:自动生成标题(对齐 boot3 FlowUtil.addAutoGenTitle) */
483
+ addAutoGenTitle(displayName, vars) {
484
+ const realName = vars[KeyRealName] || '';
485
+ const now = new Date();
486
+ const pad = (n) => n.toString().padStart(2, '0');
487
+ const timeStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}`;
488
+ vars[KeyAutoGenTitle] = `${realName}的${displayName}-${timeStr}`;
489
+ }
479
490
  /** 用户提供者访问(issue 41 补强:nodeProgress 姓名解析用) */
480
491
  getUserProvider() {
481
492
  return this.userProv;
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
- {
2
- "name": "@mldong/jeeflow",
3
- "version": "1.8.13",
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.15",
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
  }