@mldong/jeeflow 1.8.30 → 1.8.32
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.js +44 -14
- package/dist/jdbc/ext.js +13 -0
- package/dist/jdbc/shared.js +23 -0
- package/dist/memory-ext.js +8 -0
- package/dist/memory.js +33 -4
- package/dist/spi.d.ts +18 -0
- package/dist/spi.js +25 -1
- package/package.json +1 -1
package/dist/facade.js
CHANGED
|
@@ -155,7 +155,7 @@ export class JeeflowFacade {
|
|
|
155
155
|
// ── 流程定义 / 实例 ──────────────────────────────────────────────────────
|
|
156
156
|
async startAndExecute(args) {
|
|
157
157
|
const defineId = toId(args.processDefineId);
|
|
158
|
-
const operator =
|
|
158
|
+
const operator = operatorArg(args);
|
|
159
159
|
const flowArgs = {};
|
|
160
160
|
for (const [k, v] of Object.entries(args)) {
|
|
161
161
|
if (k === 'processDefineId' || k === 'operator')
|
|
@@ -302,7 +302,7 @@ export class JeeflowFacade {
|
|
|
302
302
|
// ── 流程任务 ─────────────────────────────────────────────────────────────
|
|
303
303
|
async execute(args) {
|
|
304
304
|
const taskId = toId(args.processTaskId);
|
|
305
|
-
const operator =
|
|
305
|
+
const operator = operatorArg(args);
|
|
306
306
|
const submitType = toInt(args.submitType ?? SUBMIT_AGREE);
|
|
307
307
|
const flowArgs = {};
|
|
308
308
|
for (const [k, v] of Object.entries(args)) {
|
|
@@ -550,7 +550,7 @@ export class JeeflowFacade {
|
|
|
550
550
|
}
|
|
551
551
|
async designSave(args) {
|
|
552
552
|
const ext = this.ext();
|
|
553
|
-
const operator =
|
|
553
|
+
const operator = operatorArg(args);
|
|
554
554
|
const designId = args.id != null ? toId(args.id) : '';
|
|
555
555
|
let design;
|
|
556
556
|
if (!designId) {
|
|
@@ -604,7 +604,12 @@ export class JeeflowFacade {
|
|
|
604
604
|
}
|
|
605
605
|
// ── 委托代理(需扩展仓储) ───────────────────────────────────────────────
|
|
606
606
|
async surrogatePage(args) {
|
|
607
|
-
|
|
607
|
+
// issues/129 案 A 第一层(同档原则):空串/全空白 operator ≡ 缺键 ⇒ **不带**归属过滤。
|
|
608
|
+
// 旧写法 `args.operator != null` 让 "" 变成"带了一个空值过滤",两仓给两种答案
|
|
609
|
+
// (JDBC 侧 `t.operator = ''` 出 0 行、内存侧把条件整条丢掉出全库)。本 action 在 java
|
|
610
|
+
// 门面里不下发归属条件,故回落点不是 user1 而是"与缺键一样不过滤"——只把两档并成一档。
|
|
611
|
+
const opArg = toStr(args.operator).trim();
|
|
612
|
+
const filters = opArg !== '' ? { operator: toStr(args.operator) } : undefined;
|
|
608
613
|
const pageNum = toInt(args.pageNum ?? 1);
|
|
609
614
|
const pageSize = toInt(args.pageSize ?? 10);
|
|
610
615
|
const [rows, total] = await this.ext().pageSurrogates(pageNum, pageSize, filters, parseMQuery(args));
|
|
@@ -613,7 +618,7 @@ export class JeeflowFacade {
|
|
|
613
618
|
}
|
|
614
619
|
async surrogateSave(args) {
|
|
615
620
|
const ext = this.ext();
|
|
616
|
-
const operator =
|
|
621
|
+
const operator = operatorArg(args);
|
|
617
622
|
const surrogateId = args.id != null ? toId(args.id) : '';
|
|
618
623
|
let surrogate;
|
|
619
624
|
if (!surrogateId) {
|
|
@@ -643,7 +648,7 @@ export class JeeflowFacade {
|
|
|
643
648
|
const surrogate = await ext.findSurrogateById(surrogateId);
|
|
644
649
|
if (!surrogate)
|
|
645
650
|
throw new Error('委托记录不存在');
|
|
646
|
-
const operator =
|
|
651
|
+
const operator = operatorArg(args);
|
|
647
652
|
this.applySurrogateFields(surrogate, args, operator);
|
|
648
653
|
await ext.updateSurrogate(surrogate);
|
|
649
654
|
return { id: surrogate.id };
|
|
@@ -850,7 +855,7 @@ export class JeeflowFacade {
|
|
|
850
855
|
}
|
|
851
856
|
async createCCInstance(args) {
|
|
852
857
|
const instanceId = toId(args.processInstanceId);
|
|
853
|
-
const operator =
|
|
858
|
+
const operator = operatorArg(args);
|
|
854
859
|
const actors = toStringList2(args.actorIds);
|
|
855
860
|
if (actors.length === 0)
|
|
856
861
|
throw new Error('actorIds 缺失');
|
|
@@ -862,20 +867,20 @@ export class JeeflowFacade {
|
|
|
862
867
|
}
|
|
863
868
|
async updateCCStatus(args) {
|
|
864
869
|
const instanceId = toId(args.processInstanceId);
|
|
865
|
-
const operator =
|
|
870
|
+
const operator = operatorArg(args);
|
|
866
871
|
await this.repo.updateCcStatus(instanceId, operator);
|
|
867
872
|
}
|
|
868
873
|
// ccList 我的抄送分页(v1.3.0):operator 作为抄送人过滤
|
|
869
874
|
async ccList(args) {
|
|
870
875
|
const pageNum = toInt(args.pageNum ?? 1);
|
|
871
876
|
const pageSize = toInt(args.pageSize ?? 10);
|
|
872
|
-
const actorId =
|
|
877
|
+
const actorId = operatorArg(args);
|
|
873
878
|
const { rows, total } = await this.repo.pageCcInstances(pageNum, pageSize, actorId, parseMQuery(args));
|
|
874
879
|
return pageData(pageNum, pageSize, total, rows.map(r => ccRowToMap(r)));
|
|
875
880
|
}
|
|
876
881
|
async taskDetail(args) {
|
|
877
882
|
const taskId = toId(args.id);
|
|
878
|
-
const operator =
|
|
883
|
+
const operator = operatorArg(args);
|
|
879
884
|
const task = await this.repo.findTaskById(taskId);
|
|
880
885
|
if (!task)
|
|
881
886
|
throw new Error('任务不存在');
|
|
@@ -1125,7 +1130,7 @@ export class JeeflowFacade {
|
|
|
1125
1130
|
async instancePage(args) {
|
|
1126
1131
|
const pageNum = toInt(args.pageNum ?? 1);
|
|
1127
1132
|
const pageSize = toInt(args.pageSize ?? 10);
|
|
1128
|
-
const operator =
|
|
1133
|
+
const operator = operatorArg(args);
|
|
1129
1134
|
const { rows, total } = await this.repo.pageInstances(pageNum, pageSize, operator, parseMQuery(args));
|
|
1130
1135
|
return pageData(pageNum, pageSize, total, rows.map(r => instanceRowToMap(r)));
|
|
1131
1136
|
}
|
|
@@ -1192,14 +1197,14 @@ export class JeeflowFacade {
|
|
|
1192
1197
|
async todoList(args) {
|
|
1193
1198
|
const pageNum = toInt(args.pageNum ?? 1);
|
|
1194
1199
|
const pageSize = toInt(args.pageSize ?? 10);
|
|
1195
|
-
const actorId =
|
|
1200
|
+
const actorId = operatorArg(args);
|
|
1196
1201
|
const { rows, total } = await this.repo.pageTodoTasks(pageNum, pageSize, actorId, parseMQuery(args));
|
|
1197
1202
|
return pageData(pageNum, pageSize, total, rows.map(r => taskRowToMap(r)));
|
|
1198
1203
|
}
|
|
1199
1204
|
async doneList(args) {
|
|
1200
1205
|
const pageNum = toInt(args.pageNum ?? 1);
|
|
1201
1206
|
const pageSize = toInt(args.pageSize ?? 10);
|
|
1202
|
-
const operator =
|
|
1207
|
+
const operator = operatorArg(args);
|
|
1203
1208
|
const { rows, total } = await this.repo.pageDoneTasks(pageNum, pageSize, operator, parseMQuery(args));
|
|
1204
1209
|
return pageData(pageNum, pageSize, total, rows.map(r => taskRowToMap(r)));
|
|
1205
1210
|
}
|
|
@@ -1425,9 +1430,16 @@ function formDataOf(vars, prefix) {
|
|
|
1425
1430
|
* 13 栈里就只有 nestjs 少这些列(issues/122 的机理)。规范 06 §2.4 的时间列是"必出键、空即空串",
|
|
1426
1431
|
* 所以归一放在这一层:所有行投影共用它,逐个补 `?? ''` 迟早漏一处。
|
|
1427
1432
|
*/
|
|
1433
|
+
// issues/133(拍板 B):可空时间列空值出 `null`,不出 ''。
|
|
1434
|
+
// · spec 06-facade.md:93 钉的是"空值返回 null";
|
|
1435
|
+
// · boot2 参考实现的 ProcessTaskVO 直接继承 entity 的 `Date finishTime` ⇒ Jackson 出 null;
|
|
1436
|
+
// · 历史上这里回 ''(commit 448f902)是为绕 issues/122 宿主侧全局剥-null,
|
|
1437
|
+
// 该根因已由 mldong-nestjs `@KeepNullResponse()`(WfController 类级)收口,
|
|
1438
|
+
// 引擎侧不该再替宿主兜底——那会把"键恒在、值 null"的形状换成"值空串",
|
|
1439
|
+
// 前端 `x ? 显示 : 隐藏` 这类判空在 '' 上恒假,等于把缺值伪装成有值。
|
|
1428
1440
|
function fmtTime(v) {
|
|
1429
1441
|
if (v == null)
|
|
1430
|
-
return
|
|
1442
|
+
return null;
|
|
1431
1443
|
const p = (n) => String(n).padStart(2, '0');
|
|
1432
1444
|
return `${v.getFullYear()}-${p(v.getMonth() + 1)}-${p(v.getDate())} ${p(v.getHours())}:${p(v.getMinutes())}:${p(v.getSeconds())}`;
|
|
1433
1445
|
}
|
|
@@ -1599,6 +1611,24 @@ function toStr(v) {
|
|
|
1599
1611
|
return JSON.stringify(v);
|
|
1600
1612
|
return String(v);
|
|
1601
1613
|
}
|
|
1614
|
+
/**
|
|
1615
|
+
* issues/129 案 A 第一层(门面归一化):operator 取值,**空串与缺键同档**。
|
|
1616
|
+
*
|
|
1617
|
+
* 逐字对齐 java `JeeflowFacade.operatorArg`(`s != null && !s.trim().isEmpty() ? s : "user1"`)。
|
|
1618
|
+
* 旧写法 `String(args.operator ?? 'user1')` 的 `??` 只在 null/undefined 兜缺省 ⇒ 显式传
|
|
1619
|
+
* `{"operator":""}` 会原样穿过门面落到仓储,再被仓储「空值不加条件」的通用放行**整条丢掉**
|
|
1620
|
+
* ⇒「我的实例/待办/已办/抄送」读出全库(2026-09-28 实测 node 栈 25 行 vs user1 的 4 行,
|
|
1621
|
+
* 返回行带着 userA/userB/manager/director 等**别人的** operator)。
|
|
1622
|
+
* 归一化放门面是第一层,仓储的归属兜底是第二层(`spi.ts` OWNERSHIP_COLUMNS → memory.ts /
|
|
1623
|
+
* jdbc/shared.ts buildWhere / jdbc/ext.ts buildExtWhere),两层都要在;只留门面那半不算修完。
|
|
1624
|
+
*
|
|
1625
|
+
* ⚠️ 本 helper 不适用撤回(withdraw)/转办(transfer)族——那两处是 issues/114 的
|
|
1626
|
+
* 「operator 硬必填、严禁回落 user1」,保持原样。
|
|
1627
|
+
*/
|
|
1628
|
+
function operatorArg(args) {
|
|
1629
|
+
const s = toStr(args.operator);
|
|
1630
|
+
return s.trim() !== '' ? s : 'user1';
|
|
1631
|
+
}
|
|
1602
1632
|
function toId(v) {
|
|
1603
1633
|
// issue 38 E9:id 全程 string 承载——Java 雪花 id(>2^53)经 Number() 必丢精度。
|
|
1604
1634
|
// 数字输入(JS 安全整数内)转字符串;字符串输入原样保留(含超长雪花 id)。
|
package/dist/jdbc/ext.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// 与 shared.ts 同一套 SqlAdapter / 占位符约定;分页为单表简单过滤(filters 字段名 EQ)。
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
|
+
import { isBlankOwnership, isBlankValue } from '../spi.js';
|
|
5
6
|
import { TsIDGenerator, rowId } from './shared.js';
|
|
6
7
|
import { surrogateIsEffective, surrogateTimeMs } from '../surrogate-rule.js';
|
|
7
8
|
const txStore = new AsyncLocalStorage();
|
|
@@ -117,6 +118,13 @@ export class JdbcProcessExtRepository {
|
|
|
117
118
|
if (!whitelist.has(c.column))
|
|
118
119
|
continue;
|
|
119
120
|
const val = c.value;
|
|
121
|
+
// issues/129 案 A 第二层(与 shared.ts buildWhere 同形,在原有那句通用放行之前):
|
|
122
|
+
// 归属谓词列(委托分页的 t.operator)+ 空值 ⇒ **空页**,不是"这条条件不加"。
|
|
123
|
+
// ⚠️ 只收归属列,下面那句"空值当作没填"是设计名/流程名等**可选过滤**的通用放行,不动。
|
|
124
|
+
if (isBlankOwnership(c.column, c.operator, val)) {
|
|
125
|
+
sql += ' AND 1=0';
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
120
128
|
if (val == null || val === '')
|
|
121
129
|
continue;
|
|
122
130
|
switch (c.operator.toUpperCase()) {
|
|
@@ -238,6 +246,11 @@ export class JdbcProcessExtRepository {
|
|
|
238
246
|
async pageSurrogates(pageNum = 1, pageSize = 10, filters, conditions) {
|
|
239
247
|
let sql = `SELECT ${JdbcProcessExtRepository.SURROGATE_COLS} FROM wf_process_surrogate t WHERE 1=1`;
|
|
240
248
|
let countSql = 'SELECT COUNT(*) FROM wf_process_surrogate t WHERE 1=1';
|
|
249
|
+
// issues/129 案 A 第二层:filters.operator 是归属谓词("这条委托属于谁"),空值 ⇒ **空页**。
|
|
250
|
+
// 与内存仓 memory-ext.ts pageSurrogates 同判据(否则同一个空 operator 两仓一个出 0 行、
|
|
251
|
+
// 一个把条件丢掉出全库);门面已把空串归一化成缺键(surrogatePage),这一道防直连仓储的调用方。
|
|
252
|
+
if ('operator' in (filters ?? {}) && isBlankValue(filters.operator))
|
|
253
|
+
return [[], 0];
|
|
241
254
|
const args = [];
|
|
242
255
|
const args2 = [];
|
|
243
256
|
for (const [col, val] of Object.entries(filters ?? {})) {
|
package/dist/jdbc/shared.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
12
12
|
import { ProcessInstance, ProcessTask } from '../model.js';
|
|
13
13
|
import { TaskState } from '../model.js';
|
|
14
|
+
import { isBlankOwnership, isBlankValue } from '../spi.js';
|
|
14
15
|
// ═══ 列白名单(issues/05-5,与 mldong-boot2 别名一致) ═══
|
|
15
16
|
const TASK_WHITELIST = new Set([
|
|
16
17
|
't.id', 't.task_name', 't.display_name', 't.task_type', 't.perform_type', 't.task_state',
|
|
@@ -460,6 +461,11 @@ export class JdbcRepository {
|
|
|
460
461
|
}
|
|
461
462
|
}
|
|
462
463
|
async pageInstances(pageNum, pageSize, operator, conditions) {
|
|
464
|
+
// issues/129 案 A 第二层:位置参归属过滤(t.operator)为空 ⇒ 空页。
|
|
465
|
+
// 不短路的话 `WHERE t.operator = ''` 会去匹配 operator 列恰为空串的行,与内存仓(空 ⇒ 空页)、
|
|
466
|
+
// 与 java(归属列空值 ⇒ `AND 1=0`)都不同答案;两仓同一份数据必须给同一个结论。
|
|
467
|
+
if (isBlankValue(operator))
|
|
468
|
+
return { rows: [], total: 0 };
|
|
463
469
|
const cond = this.buildWhere(conditions ?? [], INSTANCE_WHITELIST);
|
|
464
470
|
const where = ' FROM wf_process_instance t' +
|
|
465
471
|
' LEFT JOIN wf_process_define pd ON t.process_define_id = pd.id' +
|
|
@@ -485,6 +491,10 @@ export class JdbcRepository {
|
|
|
485
491
|
return this.pageTasks(pageNum, pageSize, true, operator, conditions);
|
|
486
492
|
}
|
|
487
493
|
async pageTasks(pageNum, pageSize, done, filter, conditions) {
|
|
494
|
+
// issues/129 案 A 第二层:位置参归属过滤(done=t.operator / todo=pta.actor_id)为空 ⇒ 空页,
|
|
495
|
+
// 与内存仓同判据(两仓同一份数据一个答案),也让 `= ''` 不去匹配归属列恰为空串的行。
|
|
496
|
+
if (isBlankValue(filter))
|
|
497
|
+
return { rows: [], total: 0 };
|
|
488
498
|
const cond = this.buildWhere(conditions ?? [], TASK_WHITELIST);
|
|
489
499
|
const where = ' FROM wf_process_task t' +
|
|
490
500
|
' LEFT JOIN wf_process_instance pi ON t.process_instance_id = pi.id' +
|
|
@@ -536,6 +546,16 @@ export class JdbcRepository {
|
|
|
536
546
|
if (!whitelist.has(c.column))
|
|
537
547
|
continue; // 不在白名单,丢弃
|
|
538
548
|
const val = c.value;
|
|
549
|
+
// issues/129 案 A 第二层(在**原有那句通用放行之前**,逐字对照 java JdbcProcessRepository.buildWhere):
|
|
550
|
+
// 归属谓词列 + 空值 ⇒ **空页**(`AND 1=0`),绝不能变成"这条条件不加"。
|
|
551
|
+
// 门面已把空串归一化成缺省(facade `operatorArg`),这一道防的是绕过门面直接调仓储的调用方
|
|
552
|
+
// 与将来的门面改动——只留门面那半不算修完(rust 1.0.17 同为两层)。
|
|
553
|
+
// ⚠️ 只收归属列:下面那句"空值当作没填"是 QueryCondition 对 m_LIKE_* 等**可选过滤**的通用放行,
|
|
554
|
+
// 照字面改成"空值即空页"会把可选过滤一起改坏。
|
|
555
|
+
if (isBlankOwnership(c.column, c.operator, val)) {
|
|
556
|
+
sql += ' AND 1=0';
|
|
557
|
+
continue;
|
|
558
|
+
}
|
|
539
559
|
if (val == null || val === '')
|
|
540
560
|
continue;
|
|
541
561
|
switch (c.operator.toUpperCase()) {
|
|
@@ -611,6 +631,9 @@ export class JdbcRepository {
|
|
|
611
631
|
}
|
|
612
632
|
// pageCcInstances 我的抄送分页(v1.3.0):cc 表 join 实例 + 定义,按抄送人过滤(对齐 Java pageCcInstances)
|
|
613
633
|
async pageCcInstances(pageNum, pageSize, actorId, conditions) {
|
|
634
|
+
// issues/129 案 A 第二层:位置参归属过滤(cc.actor_id)为空 ⇒ 空页(与内存仓/java 同判据)
|
|
635
|
+
if (isBlankValue(actorId))
|
|
636
|
+
return { rows: [], total: 0 };
|
|
614
637
|
const cond = this.buildWhere(conditions ?? [], CC_WHITELIST);
|
|
615
638
|
const where = ' FROM wf_process_instance t' +
|
|
616
639
|
' LEFT JOIN wf_process_define pd ON t.process_define_id = pd.id' +
|
package/dist/memory-ext.js
CHANGED
|
@@ -84,6 +84,14 @@ export class MemoryExtRepository {
|
|
|
84
84
|
this.surrogates.delete(id);
|
|
85
85
|
}
|
|
86
86
|
async pageSurrogates(_pageNum = 1, _pageSize = 10, filters, conditions) {
|
|
87
|
+
// issues/129 案 A 第二层:filters 的 operator 键 = 归属谓词列(t.operator),空值 ⇒ **空页**。
|
|
88
|
+
// 原来靠下面那句 `val === '' continue` 把这条条件整条丢掉 ⇒ 空 operator 读出全库委托;
|
|
89
|
+
// 只收归属列——surrogate / process_name / enabled 三个可选过滤仍走"空值当作没填"。
|
|
90
|
+
// conditions 那一路(m_ 条件)由 matchConditions 的归属兜底覆盖(SURROGATE_FIELDS 带 t.operator)。
|
|
91
|
+
const blankOwnershipFilter = Object.entries(filters ?? {})
|
|
92
|
+
.some(([col, val]) => col === 'operator' && (val == null || String(val).trim() === ''));
|
|
93
|
+
if (blankOwnershipFilter)
|
|
94
|
+
return [[], 0];
|
|
87
95
|
const rows = [...this.surrogates.values()].filter(s => {
|
|
88
96
|
for (const [col, val] of Object.entries(filters ?? {})) {
|
|
89
97
|
if (val == null || val === '')
|
package/dist/memory.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TaskState } from './model.js';
|
|
2
2
|
import { cloneInstance, cloneTask } from './model.js';
|
|
3
|
+
import { isBlankOwnership } from './spi.js';
|
|
3
4
|
// ═══ 条件匹配基建(issues/05-5,对齐 JDBC 白名单语义) ═══
|
|
4
5
|
// 行字段映射(列名 → 行属性,白名单列均可匹配)
|
|
5
6
|
const TASK_FIELDS = {
|
|
@@ -35,6 +36,13 @@ export function matchConditions(conditions, fields) {
|
|
|
35
36
|
for (const c of conditions ?? []) {
|
|
36
37
|
const v = fields[c.column];
|
|
37
38
|
const expect = c.value;
|
|
39
|
+
// issues/129 案 A 第二层(在**原有那句通用放行之前**,与 java JdbcProcessRepository.buildWhere 同位置):
|
|
40
|
+
// 归属谓词列 + 空值 ⇒ 空页,绝不折叠成"这条条件不加"。门面已把空串归一化成缺省(facade operatorArg),
|
|
41
|
+
// 这一道防的是绕过门面直连仓储的调用方与下一版门面改动。
|
|
42
|
+
// ⚠️ 只收 OWNERSHIP_COLUMNS 那四列:下面那句 expect == null 放行 + 空串按"没填"处理是
|
|
43
|
+
// m_LIKE_* 等**可选过滤**的通用行为,整体改成"空值即空页"会把可选过滤一起改坏。
|
|
44
|
+
if (isBlankOwnership(c.column, c.operator, expect))
|
|
45
|
+
return false;
|
|
38
46
|
if (v == null || expect == null)
|
|
39
47
|
continue;
|
|
40
48
|
switch (c.operator.toUpperCase()) {
|
|
@@ -92,6 +100,22 @@ export function eqValue(v, expect) {
|
|
|
92
100
|
return v.includes(expect);
|
|
93
101
|
return String(v) === String(expect);
|
|
94
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* issues/129 案 A 第二层 · 位置参归属过滤(内存仓)。
|
|
105
|
+
*
|
|
106
|
+
* 本栈门面把"我是谁"作为**位置参**下发给 pageInstances/pageTodoTasks/pageDoneTasks/pageCcInstances
|
|
107
|
+
* (java 下发的是 `t.operator EQ` 条件,形状不同、义务相同:归属值为空 ⇒ 空页)。
|
|
108
|
+
* 旧写法 `if (operator && …) continue` 把空串折叠成"这条条件不加" ⇒ 绕过门面的调用方一读就是**全库**
|
|
109
|
+
* (issues/129 §2 点名的 node 落点 `src/memory.ts:273` 就是 doneList 那一句)。
|
|
110
|
+
* 现按拍板一律「空(null/undefined/全空白)⇒ 空页」,与 rust 1.0.17 内存仓
|
|
111
|
+
* (`!op.is_empty()` 判据)同形;非空值**原样比较、不 trim**,与 java `t.operator = ?`
|
|
112
|
+
* 及本栈 SQL 侧 `= ?` 的取值口径一致(不借机放宽成模糊匹配)。
|
|
113
|
+
* 返回 null 表示"归属值为空",调用方据此让每一行都不匹配。
|
|
114
|
+
*/
|
|
115
|
+
function ownershipKey(wanted) {
|
|
116
|
+
const op = wanted ?? '';
|
|
117
|
+
return op.trim() === '' ? null : op;
|
|
118
|
+
}
|
|
95
119
|
export class MemoryRepository {
|
|
96
120
|
defines = new Map();
|
|
97
121
|
instances = new Map();
|
|
@@ -270,8 +294,10 @@ export class MemoryRepository {
|
|
|
270
294
|
}
|
|
271
295
|
async pageInstances(pageNum = 1, pageSize = 10, operator, conditions) {
|
|
272
296
|
const rows = [];
|
|
297
|
+
// issues/129 案 A 第二层:归属值为空 ⇒ 空页(原来 `if (operator && …)` 是"空即不过滤",读出全库)
|
|
298
|
+
const op = ownershipKey(operator);
|
|
273
299
|
for (const inst of this.instances.values()) {
|
|
274
|
-
if (
|
|
300
|
+
if (op == null || inst.operator !== op)
|
|
275
301
|
continue;
|
|
276
302
|
const def = this.defines.get(inst.defineId);
|
|
277
303
|
const r = {
|
|
@@ -292,10 +318,11 @@ export class MemoryRepository {
|
|
|
292
318
|
}
|
|
293
319
|
async pageTodoTasks(pageNum = 1, pageSize = 10, actorId, conditions) {
|
|
294
320
|
const rows = [];
|
|
321
|
+
const op = ownershipKey(actorId); // issues/129 案 A 第二层:空 ⇒ 空页,不再"空即不过滤"
|
|
295
322
|
for (const t of this.tasks.values()) {
|
|
296
323
|
if (t.taskState !== TaskState.Doing)
|
|
297
324
|
continue;
|
|
298
|
-
if (
|
|
325
|
+
if (op == null || !(this.actors.get(t.id) ?? []).includes(op))
|
|
299
326
|
continue;
|
|
300
327
|
const r = this.taskRow(t);
|
|
301
328
|
const fields = pickFields(r, TASK_FIELDS);
|
|
@@ -309,10 +336,11 @@ export class MemoryRepository {
|
|
|
309
336
|
}
|
|
310
337
|
async pageDoneTasks(pageNum = 1, pageSize = 10, operator, conditions) {
|
|
311
338
|
const rows = [];
|
|
339
|
+
const op = ownershipKey(operator); // issues/129 案 A 第二层:空 ⇒ 空页(本 issue §2 点名的内存仓落点)
|
|
312
340
|
for (const t of this.tasks.values()) {
|
|
313
341
|
if (t.taskState === TaskState.Doing)
|
|
314
342
|
continue;
|
|
315
|
-
if (
|
|
343
|
+
if (op == null || t.actorId !== op)
|
|
316
344
|
continue;
|
|
317
345
|
const r = this.taskRow(t);
|
|
318
346
|
if (matchConditions(conditions, pickFields(r, TASK_FIELDS)))
|
|
@@ -341,8 +369,9 @@ export class MemoryRepository {
|
|
|
341
369
|
// pageCcInstances 我的抄送分页(v1.3.0):按抄送人 actorId 过滤,join 实例 + 定义
|
|
342
370
|
async pageCcInstances(pageNum = 1, pageSize = 10, actorId, conditions) {
|
|
343
371
|
const rows = [];
|
|
372
|
+
const op = ownershipKey(actorId); // issues/129 案 A 第二层:空 ⇒ 空页(cc.actor_id 为归属列)
|
|
344
373
|
for (const [instId, actors] of this.ccInstances) {
|
|
345
|
-
if (
|
|
374
|
+
if (op == null || !actors.includes(op))
|
|
346
375
|
continue;
|
|
347
376
|
const inst = this.instances.get(instId);
|
|
348
377
|
if (!inst)
|
package/dist/spi.d.ts
CHANGED
|
@@ -4,6 +4,24 @@ export interface QueryCondition {
|
|
|
4
4
|
operator: string;
|
|
5
5
|
value: any;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* 归属谓词列:这几列定义「这条记录属于谁」,空值**绝不能**等于「不过滤」。
|
|
9
|
+
* 取自门面实际下发的那四条(逐字对齐 java `JdbcProcessRepository.OWNERSHIP_COLUMNS`,
|
|
10
|
+
* 本栈列名写法与 java 相同——`wf_process_task.operator` / 实例 join 出的 `pi.operator` /
|
|
11
|
+
* 任务参与者表 `wf_process_task_actor.actor_id` / 抄送表 `wf_process_cc.actor_id`):
|
|
12
|
+
* processInstance/page → t.operator、processTask/todoList → pta.actor_id、
|
|
13
|
+
* processTask/doneList → t.operator(+ pi.operator 带出的实例发起人)、processInstance/ccList → cc.actor_id
|
|
14
|
+
* 口径见 jeeflow-doc `spec/06-facade.md` §2.5。
|
|
15
|
+
*/
|
|
16
|
+
export declare const OWNERSHIP_COLUMNS: ReadonlySet<string>;
|
|
17
|
+
/** 空值判定(对齐 java `val == null || ((String) val).trim().isEmpty()`):null/undefined/全空白串 */
|
|
18
|
+
export declare function isBlankValue(val: unknown): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 归属谓词 + 空值 ⇒ **空页**(issues/129 案 A 第二层)。
|
|
21
|
+
* 只收 `OWNERSHIP_COLUMNS` 上的 EQ 条件:动态 where 里「空值当作没填」那句是 PageQuery 对
|
|
22
|
+
* `m_LIKE_*` 等**可选过滤**的通用放行,整体改掉会把可选过滤一起改坏(spec 06-facade.md §2.5 ⚠️)。
|
|
23
|
+
*/
|
|
24
|
+
export declare function isBlankOwnership(column: string, operator: string, val: unknown): boolean;
|
|
7
25
|
export interface InstanceStatsRow {
|
|
8
26
|
defineId: string;
|
|
9
27
|
state: number;
|
package/dist/spi.js
CHANGED
|
@@ -1 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
// ═══ 归属谓词基建(issues/129 案 A · 第二层「仓储兜底」)═══
|
|
2
|
+
/**
|
|
3
|
+
* 归属谓词列:这几列定义「这条记录属于谁」,空值**绝不能**等于「不过滤」。
|
|
4
|
+
* 取自门面实际下发的那四条(逐字对齐 java `JdbcProcessRepository.OWNERSHIP_COLUMNS`,
|
|
5
|
+
* 本栈列名写法与 java 相同——`wf_process_task.operator` / 实例 join 出的 `pi.operator` /
|
|
6
|
+
* 任务参与者表 `wf_process_task_actor.actor_id` / 抄送表 `wf_process_cc.actor_id`):
|
|
7
|
+
* processInstance/page → t.operator、processTask/todoList → pta.actor_id、
|
|
8
|
+
* processTask/doneList → t.operator(+ pi.operator 带出的实例发起人)、processInstance/ccList → cc.actor_id
|
|
9
|
+
* 口径见 jeeflow-doc `spec/06-facade.md` §2.5。
|
|
10
|
+
*/
|
|
11
|
+
export const OWNERSHIP_COLUMNS = new Set([
|
|
12
|
+
't.operator', 'pi.operator', 'pta.actor_id', 'cc.actor_id',
|
|
13
|
+
]);
|
|
14
|
+
/** 空值判定(对齐 java `val == null || ((String) val).trim().isEmpty()`):null/undefined/全空白串 */
|
|
15
|
+
export function isBlankValue(val) {
|
|
16
|
+
return val == null || (typeof val === 'string' && val.trim() === '');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 归属谓词 + 空值 ⇒ **空页**(issues/129 案 A 第二层)。
|
|
20
|
+
* 只收 `OWNERSHIP_COLUMNS` 上的 EQ 条件:动态 where 里「空值当作没填」那句是 PageQuery 对
|
|
21
|
+
* `m_LIKE_*` 等**可选过滤**的通用放行,整体改掉会把可选过滤一起改坏(spec 06-facade.md §2.5 ⚠️)。
|
|
22
|
+
*/
|
|
23
|
+
export function isBlankOwnership(column, operator, val) {
|
|
24
|
+
return OWNERSHIP_COLUMNS.has(column) && operator.toUpperCase() === 'EQ' && isBlankValue(val);
|
|
25
|
+
}
|