@mldong/jeeflow 1.8.53 → 1.8.54

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/engine.d.ts CHANGED
@@ -239,6 +239,7 @@ export declare class EngineImpl implements Engine {
239
239
  /** issues/116:把代理人并入参与者集合——授权人保留、原顺序不动、代理人按参与人顺序追加、去重。
240
240
  * 返回新数组(无代理命中时返回原数组引用,零开销)。 */
241
241
  export declare function mergeAgents(actors: string[], agents: Map<string, string>): string[];
242
+ export declare function unknownEdgeWarning(from: string, to: string): string;
242
243
  /** 会签判定(issue 42,对齐 Java ProcessTaskPerformTypeEnum.codeOf):
243
244
  * '1' / 'ALL' / 'COUNTERSIGN'(大小写不敏感)→ 会签。
244
245
  * 设计器属性面板保存 'ALL' 字符串符合 Java 契约,引擎必须兼容 */
package/dist/engine.js CHANGED
@@ -1167,11 +1167,22 @@ function findNode(flow, id) {
1167
1167
  function findNodeByType(flow, type) {
1168
1168
  return flow.nodes.find(n => n.type === type);
1169
1169
  }
1170
+ export function unknownEdgeWarning(from, to) {
1171
+ return `[jeeflow] WARNING 转移出边的目标节点不在模型里(该节点类型未建档,解析期已跳过),本次流转停在这条边: from=${from}, to=${to}`;
1172
+ }
1170
1173
  function followEdges(flow, sourceId) {
1171
- return flow.edges
1172
- .filter(e => e.sourceNodeId === sourceId)
1173
- .map(e => findNode(flow, e.targetNodeId))
1174
- .filter(Boolean);
1174
+ const out = [];
1175
+ for (const e of flow.edges) {
1176
+ if (e.sourceNodeId !== sourceId)
1177
+ continue;
1178
+ const n = findNode(flow, e.targetNodeId);
1179
+ if (!n) {
1180
+ console.warn(unknownEdgeWarning(sourceId, e.targetNodeId));
1181
+ continue;
1182
+ }
1183
+ out.push(n);
1184
+ }
1185
+ return out;
1175
1186
  }
1176
1187
  function getCsState(vars, nodeId) {
1177
1188
  const actors = vars[`operatorList_${nodeId}`] ?? null;
package/dist/facade.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // (code=0 成功 / 99999999 失败)。操作人约定:args.operator 显式传入。
6
6
  import { dirname as pathDirname, join as pathJoin, sep as pathSep } from 'node:path';
7
7
  import { fileURLToPath } from 'node:url';
8
- import { TaskState, } from './model.js';
8
+ import { TaskState, EXIST_UN_FINISH_INSTANCE, } from './model.js';
9
9
  // issues/142 B 批(spec 06 §2.11):transfer 的 fromActor/toActor 用 cc 侧已落地的那一枚单值判据归一
10
10
  // (旧名 normalizeCcActorValue = 新名 normalizeActorValue,同一函数),不在此另写一份 trim+判空
11
11
  import { normalizeActorValue } from './spi.js';
@@ -634,7 +634,13 @@ export class JeeflowFacade {
634
634
  }
635
635
  /** 删除定义(issues/28:兼容 {ids} 批量与单 {id}) */
636
636
  async defineRemove(args) {
637
- for (const id of idListArgs(args))
637
+ const ids = idListArgs(args);
638
+ // audit8 R110:先对整批做存在性校验再删,避免"前面的删了、后面的被拒"的半删。
639
+ for (const id of ids) {
640
+ if (await this.repo.hasInstancesByDefineId(id))
641
+ throw new Error(EXIST_UN_FINISH_INSTANCE);
642
+ }
643
+ for (const id of ids)
638
644
  await this.repo.removeDefine(id);
639
645
  return {};
640
646
  }
@@ -68,6 +68,7 @@ export declare class JdbcRepository implements ProcessRepository {
68
68
  updateDefine(define: ProcessDefine): Promise<void>;
69
69
  updateDefineState(defineId: string, state: number): Promise<void>;
70
70
  removeDefine(defineId: string): Promise<void>;
71
+ hasInstancesByDefineId(defineId: string): Promise<boolean>;
71
72
  findDefineByName(name: string): Promise<ProcessDefine | null>;
72
73
  private static INSTANCE_COLS;
73
74
  findInstanceById(id: string): Promise<ProcessInstance | null>;
@@ -237,6 +237,16 @@ export class JdbcRepository {
237
237
  await this.done(conn);
238
238
  }
239
239
  }
240
+ async hasInstancesByDefineId(defineId) {
241
+ const conn = await this.c();
242
+ try {
243
+ const row = await conn.fetchOne(this.sql('SELECT COUNT(*) FROM wf_process_instance WHERE process_define_id=?'), [defineId]);
244
+ return Number(Object.values(row)[0] ?? 0) > 0;
245
+ }
246
+ finally {
247
+ await this.done(conn);
248
+ }
249
+ }
240
250
  // findDefineByName 按流程编码查最新一条定义(v1.1.0,deploy 版本管理用)
241
251
  async findDefineByName(name) {
242
252
  const conn = await this.c();
package/dist/memory.d.ts CHANGED
@@ -35,6 +35,7 @@ export declare class MemoryRepository implements ProcessRepository {
35
35
  updateDefine(def: ProcessDefine): Promise<void>;
36
36
  updateDefineState(defineId: string, state: number): Promise<void>;
37
37
  removeDefine(defineId: string): Promise<void>;
38
+ hasInstancesByDefineId(defineId: string): Promise<boolean>;
38
39
  saveInstance(inst: ProcessInstance): Promise<void>;
39
40
  updateInstance(inst: ProcessInstance): Promise<void>;
40
41
  findInstanceById(id: string): Promise<ProcessInstance | null>;
package/dist/memory.js CHANGED
@@ -159,6 +159,13 @@ export class MemoryRepository {
159
159
  async removeDefine(defineId) {
160
160
  this.defines.delete(defineId);
161
161
  }
162
+ async hasInstancesByDefineId(defineId) {
163
+ for (const inst of this.instances.values()) {
164
+ if (String(inst.defineId) === String(defineId))
165
+ return true;
166
+ }
167
+ return false;
168
+ }
162
169
  async saveInstance(inst) {
163
170
  if (!inst.id)
164
171
  inst.id = String(this.seq++);
package/dist/model.d.ts CHANGED
@@ -34,6 +34,7 @@ export interface FlowEdge {
34
34
  value: string;
35
35
  };
36
36
  }
37
+ export declare const EXIST_UN_FINISH_INSTANCE = "\u5B58\u5728\u6B63\u5728\u672A\u5B8C\u6210\u7684\u6D41\u7A0B\u5B9E\u4F8B\uFF0C\u4E0D\u5141\u8BB8\u5220\u9664\uFF01";
37
38
  export declare const TypeStart = "snaker:start";
38
39
  export declare const TypeEnd = "snaker:end";
39
40
  export declare const TypeTask = "snaker:task";
package/dist/model.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // ─── LogicFlow JSON Types ─────────────────────────────────────────────────────
2
2
  // ─── Node Type Constants ──────────────────────────────────────────────────────
3
+ // 删除定义的实例守卫文案(内部码 20010005,逐字沿用 boot2)
4
+ export const EXIST_UN_FINISH_INSTANCE = '存在正在未完成的流程实例,不允许删除!';
3
5
  export const TypeStart = 'snaker:start';
4
6
  export const TypeEnd = 'snaker:end';
5
7
  export const TypeTask = 'snaker:task';
package/dist/spi.d.ts CHANGED
@@ -158,6 +158,7 @@ export interface ProcessRepository {
158
158
  updateDefine(define: ProcessDefine): Promise<void>;
159
159
  updateDefineState(defineId: string, state: number): Promise<void>;
160
160
  removeDefine(defineId: string): Promise<void>;
161
+ hasInstancesByDefineId(defineId: string): Promise<boolean>;
161
162
  findInstanceById(id: string): Promise<ProcessInstance | null>;
162
163
  saveInstance(inst: ProcessInstance): Promise<void>;
163
164
  updateInstance(inst: ProcessInstance): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mldong/jeeflow",
3
- "version": "1.8.53",
3
+ "version": "1.8.54",
4
4
  "description": "jeeflow workflow engine — Node.js / TypeScript implementation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",