@mldong/jeeflow 1.8.64 → 1.8.66
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/action-permission.d.ts +1 -1
- package/dist/action-permission.js +4 -1
- package/dist/addsign.d.ts +14 -2
- package/dist/addsign.js +25 -3
- package/dist/aidant.d.ts +86 -0
- package/dist/aidant.js +231 -0
- package/dist/collect.d.ts +3 -0
- package/dist/collect.js +8 -1
- package/dist/engine.d.ts +52 -16
- package/dist/engine.js +343 -18
- package/dist/facade.d.ts +14 -0
- package/dist/facade.js +53 -0
- package/dist/jdbc/shared.d.ts +3 -0
- package/dist/jdbc/shared.js +13 -0
- package/dist/spi.d.ts +21 -0
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@ export interface ActionPermissionProvider {
|
|
|
8
8
|
permissionCodes(action: string): string[] | null;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* OR 规则表(对齐 java DefaultActionPermissionProvider.OR_RULES,
|
|
11
|
+
* OR 规则表(对齐 java DefaultActionPermissionProvider.OR_RULES,8 条——
|
|
12
12
|
* boot3 `@SaCheckPermission(value={...}, mode=OR)` 语义的 action,任选其一即有权)。
|
|
13
13
|
* 条目数在测试里钉死:加一条规则要八栈同批改。
|
|
14
14
|
*/
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// laravel WfPermission.php/salvo wf_permission.rs/csharp WfEndpoints.cs),
|
|
15
15
|
// 新 action 或粒度调整要改十处+引擎,且"只用引擎、自写集成层"的客户跨栈读出两套码。
|
|
16
16
|
/**
|
|
17
|
-
* OR 规则表(对齐 java DefaultActionPermissionProvider.OR_RULES,
|
|
17
|
+
* OR 规则表(对齐 java DefaultActionPermissionProvider.OR_RULES,8 条——
|
|
18
18
|
* boot3 `@SaCheckPermission(value={...}, mode=OR)` 语义的 action,任选其一即有权)。
|
|
19
19
|
* 条目数在测试里钉死:加一条规则要八栈同批改。
|
|
20
20
|
*/
|
|
@@ -30,6 +30,9 @@ export const ACTION_PERMISSION_OR_RULES = Object.freeze({
|
|
|
30
30
|
// 按引擎判据本来就必然是该行参与者(=有办理权的人),拆独立码实际给不出去。
|
|
31
31
|
'processTask/recall': Object.freeze(['wf:processTask:execute']),
|
|
32
32
|
'processTask/revokeDynamicCountersign': Object.freeze(['wf:processTask:execute']),
|
|
33
|
+
// issues/253 动态协办:照 246/247 B 案惯例复用"办理"这枚码,不建按钮种子行——
|
|
34
|
+
// 派生协办的主体按引擎判据本来就必然是主办行名册内的人(=有办理权的人)。
|
|
35
|
+
'processTask/aidant': Object.freeze(['wf:processTask:execute']),
|
|
33
36
|
});
|
|
34
37
|
/**
|
|
35
38
|
* 放行清单(对齐 java NO_PERM_ACTIONS,11 条——boot3 无权限注解的 action,登录即可)。
|
package/dist/addsign.d.ts
CHANGED
|
@@ -32,6 +32,13 @@ export declare function parseMaxRounds(value: unknown, nodeName: string): number
|
|
|
32
32
|
export declare function allowAddSignOf(node: FlowNode | undefined): boolean;
|
|
33
33
|
/** 读某节点轮次上限。 */
|
|
34
34
|
export declare function maxRoundsOf(node: FlowNode | undefined): number;
|
|
35
|
+
/**
|
|
36
|
+
* 节点级 taskType 协办档判定(规范 02 §4.4,issues/252):本栈建单恒落 taskType=0、
|
|
37
|
+
* 没有 java 那枚 taskType codeOf 容错表,判定照 isCountersign 同尺(String+trim+toUpperCase,
|
|
38
|
+
* 大小写不敏感):1/"1"/"协办"/"SECONDARY" ⇒ 协办;其余值维持既有静默回落主办
|
|
39
|
+
* (issues/245 口径,不扩成 fail-fast)。
|
|
40
|
+
*/
|
|
41
|
+
export declare function isSecondaryTaskType(v: unknown): boolean;
|
|
35
42
|
/**
|
|
36
43
|
* 解析期硬校验(规范 02 §4.3/§4.4)——本栈没有 java 那一层 `ModelParser`(`JSON.parse(content)`
|
|
37
44
|
* 直接当 FlowModel 用),故落点=引擎每次读定义的解析口(`engine.ts` 的 `loadFlowModel`)+
|
|
@@ -42,7 +49,9 @@ export declare function maxRoundsOf(node: FlowNode | undefined): number;
|
|
|
42
49
|
* (90469a2/ffe2749)。后两段的本体在 `recall.ts`/`collect.ts`(各自的开关与禁配各自守),
|
|
43
50
|
* 本函数是三段共用的那一个入口——与 java 一样"读一次定义只校一次",不留第二个调用面。</p>
|
|
44
51
|
*
|
|
45
|
-
* <p
|
|
52
|
+
* <p>本段四条:⓪ 节点级 `taskType=1`(协办)禁配(issues/252,先于开关解析——java 同判据
|
|
53
|
+
* 在 TaskParser 读 taskType 处);① 两键非法值;② 会签节点配 `allowAddSign`;③ 首任务节点配
|
|
54
|
+
* `allowAddSign`。</p>
|
|
46
55
|
*/
|
|
47
56
|
export declare function checkFlowConfig(flow: FlowModel): void;
|
|
48
57
|
/**
|
|
@@ -65,7 +74,10 @@ export declare function nextOperatorPresent(args: Record<string, any> | null | u
|
|
|
65
74
|
* ——同传时它是死参数。静默择一=用户选的"下一节点处理人"无声消失,报错是把它变响话。</p>
|
|
66
75
|
*/
|
|
67
76
|
export declare function validateSubmission(flow: FlowModel, task: ProcessTask, args: Record<string, any> | null | undefined, operator: string): void;
|
|
68
|
-
/** 本节点是否还有未完成任务(刚办结那条此刻已是 DONE,不计入)。
|
|
77
|
+
/** 本节点是否还有未完成任务(刚办结那条此刻已是 DONE,不计入)。
|
|
78
|
+
* issues/253:协办行(task_type=1)不算"兄弟待办"——它不驱动流程、不是接力链的一环,
|
|
79
|
+
* 算进来会让 waitCompletion=false 的主办在加签/征询节点上被协办行挡住推进(规范 04
|
|
80
|
+
* 「缺省 false 主办可随时推进」)。协办行的等待由 `aidant.gateWait` 单独裁决。 */
|
|
69
81
|
export declare function hasDoingOnNode(inst: ProcessInstance | null | undefined, nodeName: string): boolean;
|
|
70
82
|
/**
|
|
71
83
|
* 废弃本节点未完成的加签任务(拒绝/退回发起人时调用,不留孤儿待办)。
|
package/dist/addsign.js
CHANGED
|
@@ -22,6 +22,8 @@ import { TypeTask } from './model.js';
|
|
|
22
22
|
// ESM 环里没有任何"求值期解引用",模块实例化顺序怎么排都不撞 TDZ。
|
|
23
23
|
import { checkRecallFlowConfig } from './recall.js';
|
|
24
24
|
import { checkCollectFlowConfig, dynamicCountersignOf } from './collect.js';
|
|
25
|
+
// issues/253:协办行排除判据(与 collect.ts 同款跨模块引用——函数体内取用,求值期不碰)
|
|
26
|
+
import { isAidantRow } from './aidant.js';
|
|
25
27
|
/** 节点属性键:后加签开关(`properties` 平铺层,缺省 false) */
|
|
26
28
|
export const PROP_ALLOW_ADD_SIGN = 'allowAddSign';
|
|
27
29
|
/** 节点属性键:加签轮次上限(0=不限,缺省 0) */
|
|
@@ -104,6 +106,16 @@ export function allowAddSignOf(node) {
|
|
|
104
106
|
export function maxRoundsOf(node) {
|
|
105
107
|
return node ? parseMaxRounds(node.properties?.[PROP_ADD_SIGN_MAX_ROUNDS], node.id) : 0;
|
|
106
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* 节点级 taskType 协办档判定(规范 02 §4.4,issues/252):本栈建单恒落 taskType=0、
|
|
111
|
+
* 没有 java 那枚 taskType codeOf 容错表,判定照 isCountersign 同尺(String+trim+toUpperCase,
|
|
112
|
+
* 大小写不敏感):1/"1"/"协办"/"SECONDARY" ⇒ 协办;其余值维持既有静默回落主办
|
|
113
|
+
* (issues/245 口径,不扩成 fail-fast)。
|
|
114
|
+
*/
|
|
115
|
+
export function isSecondaryTaskType(v) {
|
|
116
|
+
const s = String(v ?? '').trim().toUpperCase();
|
|
117
|
+
return s === '1' || s === 'SECONDARY' || s === '协办';
|
|
118
|
+
}
|
|
107
119
|
/**
|
|
108
120
|
* 解析期硬校验(规范 02 §4.3/§4.4)——本栈没有 java 那一层 `ModelParser`(`JSON.parse(content)`
|
|
109
121
|
* 直接当 FlowModel 用),故落点=引擎每次读定义的解析口(`engine.ts` 的 `loadFlowModel`)+
|
|
@@ -114,12 +126,19 @@ export function maxRoundsOf(node) {
|
|
|
114
126
|
* (90469a2/ffe2749)。后两段的本体在 `recall.ts`/`collect.ts`(各自的开关与禁配各自守),
|
|
115
127
|
* 本函数是三段共用的那一个入口——与 java 一样"读一次定义只校一次",不留第二个调用面。</p>
|
|
116
128
|
*
|
|
117
|
-
* <p
|
|
129
|
+
* <p>本段四条:⓪ 节点级 `taskType=1`(协办)禁配(issues/252,先于开关解析——java 同判据
|
|
130
|
+
* 在 TaskParser 读 taskType 处);① 两键非法值;② 会签节点配 `allowAddSign`;③ 首任务节点配
|
|
131
|
+
* `allowAddSign`。</p>
|
|
118
132
|
*/
|
|
119
133
|
export function checkFlowConfig(flow) {
|
|
120
134
|
const tasks = (flow?.nodes ?? []).filter(n => n.type === TypeTask);
|
|
121
135
|
// ① 键的合法性:每个任务节点都判(与 java TaskParser 逐节点解析同档),不是只判开了开关的
|
|
122
136
|
for (const n of tasks) {
|
|
137
|
+
// 节点级协办禁配(规范 02 §4.4,issues/252):协办档只由运行期 processTask/aidant 派生
|
|
138
|
+
// (issues/253),snaker 原义下协办节点办结不驱动且跳转同闸,节点级配了就是流程悬挂陷阱。
|
|
139
|
+
if (isSecondaryTaskType(n.properties?.taskType)) {
|
|
140
|
+
throw new Error(`节点[${n.id}]不允许配置协办任务类型(taskType=1)`);
|
|
141
|
+
}
|
|
123
142
|
parseAllow(n.properties?.[PROP_ALLOW_ADD_SIGN], n.id);
|
|
124
143
|
parseMaxRounds(n.properties?.[PROP_ADD_SIGN_MAX_ROUNDS], n.id);
|
|
125
144
|
}
|
|
@@ -200,11 +219,14 @@ export function validateSubmission(flow, task, args, operator) {
|
|
|
200
219
|
}
|
|
201
220
|
}
|
|
202
221
|
// ─── 推进闸与废弃 ──────────────────────────────────────────────────────────────
|
|
203
|
-
/** 本节点是否还有未完成任务(刚办结那条此刻已是 DONE,不计入)。
|
|
222
|
+
/** 本节点是否还有未完成任务(刚办结那条此刻已是 DONE,不计入)。
|
|
223
|
+
* issues/253:协办行(task_type=1)不算"兄弟待办"——它不驱动流程、不是接力链的一环,
|
|
224
|
+
* 算进来会让 waitCompletion=false 的主办在加签/征询节点上被协办行挡住推进(规范 04
|
|
225
|
+
* 「缺省 false 主办可随时推进」)。协办行的等待由 `aidant.gateWait` 单独裁决。 */
|
|
204
226
|
export function hasDoingOnNode(inst, nodeName) {
|
|
205
227
|
if (!inst || !nodeName)
|
|
206
228
|
return false;
|
|
207
|
-
return (inst.tasks ?? []).some(t => t.taskName === nodeName && t.isDoing());
|
|
229
|
+
return (inst.tasks ?? []).some(t => t.taskName === nodeName && t.isDoing() && !isAidantRow(t));
|
|
208
230
|
}
|
|
209
231
|
/**
|
|
210
232
|
* 废弃本节点未完成的加签任务(拒绝/退回发起人时调用,不留孤儿待办)。
|
package/dist/aidant.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type ProcessTask } from './model.js';
|
|
2
|
+
/**
|
|
3
|
+
* 动态协办账本:`{round, fromActor, toActors, reason, time, operator}` 只追加,落**主办行**变量
|
|
4
|
+
* (形状照 `tf_addSignHistory`,键序锁定、time 为 §2.4 字符串)。离开节点清场未办结协办行时
|
|
5
|
+
* 追加一条带 `abandoned: true` 的条目(照征询撤回的 `revoked`)。
|
|
6
|
+
*/
|
|
7
|
+
export declare const KeyAidantHistory = "tf_aidantHistory";
|
|
8
|
+
/** 派生原因(选填,字符串):盖每条协办行(单行出证自足);**不占 `tf_approvalComment`**。 */
|
|
9
|
+
export declare const KeyAidantReason = "tf_aidantReason";
|
|
10
|
+
/**
|
|
11
|
+
* 等待闸开关:派生时把 `waitCompletion` 盖在**主办行**变量上,缺省 false=主办不等协办办结
|
|
12
|
+
* 即可推进。`tf_` 前缀使实例合并自动剥键(不传播,与 `tf_allowRecall` 同通道);
|
|
13
|
+
* 投影 `ext.aidant.wait` 同源。
|
|
14
|
+
*/
|
|
15
|
+
export declare const KeyAidantWait = "tf_aidantWait";
|
|
16
|
+
export declare const MSG_NO_ACTORS = "actorIds \u5FC5\u586B";
|
|
17
|
+
export declare const MSG_NO_PERMISSION = "\u65E0\u6743\u9650\u6D3E\u751F\u534F\u529E\u4EFB\u52A1";
|
|
18
|
+
export declare const MSG_NOT_DOING = "\u4EFB\u52A1\u975E\u8FDB\u884C\u4E2D\uFF0C\u4E0D\u53EF\u6D3E\u751F\u534F\u529E";
|
|
19
|
+
export declare const MSG_DUPLICATE = "\u8BE5\u4EBA\u5DF2\u6709\u672A\u529E\u7ED3\u7684\u534F\u529E\u4EFB\u52A1";
|
|
20
|
+
export declare const MSG_NO_RECURSION = "\u534F\u529E\u4EFB\u52A1\u4E0D\u80FD\u518D\u6D3E\u751F\u534F\u529E";
|
|
21
|
+
export declare const MSG_TASK_NOT_FOUND = "\u4EFB\u52A1\u4E0D\u5B58\u5728";
|
|
22
|
+
export declare const msgWaitPending: (taskName: string, submitted: number, total: number) => string;
|
|
23
|
+
/** 协办行判定=`task_type=1`(SECONDARY)。这是两族子行唯一的分辨判据。 */
|
|
24
|
+
export declare function isAidantRow(row: ProcessTask | null | undefined): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 协办行=parent 指向主办行**且同节点同名且 task_type=1** 的行。
|
|
27
|
+
* 同名过滤与 task_type 过滤都不可省,理由见文件头「与征询的分辨判据」段。
|
|
28
|
+
*/
|
|
29
|
+
export declare function aidantRows(tasks: ProcessTask[], host: ProcessTask | null | undefined): ProcessTask[];
|
|
30
|
+
/**
|
|
31
|
+
* 等待闸原料:在册协办行总数与已办结(FINISHED)数——**已废弃(99) 行(离开节点清场的)
|
|
32
|
+
* 不算在册**(规范 04「计数跳过已废弃(99) 行」)。返回 `[total, submitted]`。
|
|
33
|
+
*/
|
|
34
|
+
export declare function countAidant(tasks: ProcessTask[], host: ProcessTask): [number, number];
|
|
35
|
+
/** 未办结协办行(DOING)——等待闸的判据集合,也是离开节点时的清场集合。 */
|
|
36
|
+
export declare function pendingAidant(tasks: ProcessTask[], host: ProcessTask): ProcessTask[];
|
|
37
|
+
/**
|
|
38
|
+
* 等待闸开关(`waitCompletion`):派生时盖在**主办行**变量上,缺省 false=不等。
|
|
39
|
+
* 多轮派生时后一次的值生效(投影 `ext.aidant.wait` 同源)。
|
|
40
|
+
*
|
|
41
|
+
* 非法值按缺省 false(照 java `Boolean.parseBoolean`:只认 "true",大小写不敏感)——
|
|
42
|
+
* 契约只定义了 bool 档,**不为非法值新造文案**(协办六行之外不加第七行)。
|
|
43
|
+
*/
|
|
44
|
+
export declare function waitOf(host: ProcessTask | null | undefined): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 等待闸(规范 04「推进闸与等待闸」):`waitCompletion=true` 时主办行办结前判
|
|
47
|
+
* "不存在 DOING 协办行",未齐 ⇒ 逐字文案报错、零写入。协办行自身不受本闸约束
|
|
48
|
+
* (它办结本来就不驱动流程);`waitCompletion=false`(缺省)原样放行。
|
|
49
|
+
*
|
|
50
|
+
* 必须由引擎排在 `completeTask` **之前**——内存仓储无回滚,判据后置时"报错"那一次调用
|
|
51
|
+
* 结束后主办待办已经消失(与后加签/退回守卫同一规矩)。
|
|
52
|
+
*/
|
|
53
|
+
export declare function gateWait(tasks: ProcessTask[], host: ProcessTask | null | undefined): void;
|
|
54
|
+
/**
|
|
55
|
+
* 从行集合里剔掉协办行(task_type=1)——会签合并计数与"本节点还有兄弟待办"判据共用这一枚
|
|
56
|
+
* (规范 04「不计入会签合并计数」+「缺省 false 主办可随时推进」)。
|
|
57
|
+
*/
|
|
58
|
+
export declare function filterOutAidant(tasks: ProcessTask[]): ProcessTask[];
|
|
59
|
+
/** 读账本(测试与投影用);无该键/脏值 ⇒ 空表。 */
|
|
60
|
+
export declare function historyOf(task: ProcessTask | null | undefined): Record<string, any>[];
|
|
61
|
+
/**
|
|
62
|
+
* 主办行当前轮次=账本末条 `round`(每次派生追加一条=轮次推进;**清场记账不消耗轮次**)。
|
|
63
|
+
*/
|
|
64
|
+
export declare function lastRound(host: ProcessTask | null | undefined): number;
|
|
65
|
+
/**
|
|
66
|
+
* 派生账本追加(只追加不覆盖),落**主办行**变量;六键
|
|
67
|
+
* `{round, fromActor, toActors, reason, time, operator}`(规范 06 §2.7),
|
|
68
|
+
* `reason` 空串兜底、`time` 一律 §2.4 字符串。
|
|
69
|
+
*
|
|
70
|
+
* 主办行在派生时不办结,`completeTask` 的变量合并是并入而非整体替换,故账本能活到主办办结
|
|
71
|
+
* 之后(与转办/征询账本同一条存活理由)。
|
|
72
|
+
* ⚠️ 调用方随后必须把主办行**再落一次库**(快照仓储纪律,同 `appendCollectHistory`)。
|
|
73
|
+
*/
|
|
74
|
+
export declare function appendAidantHistory(host: ProcessTask, operator: string, toActors: string[], round: number, reason: string, now: Date): void;
|
|
75
|
+
/**
|
|
76
|
+
* 清场账本追加:`abandoned: true` 标记本条是"离开节点废弃"(形状照征询撤回条目的
|
|
77
|
+
* `revoked: true`),六键原序不动,`toActors`=被废弃的人。
|
|
78
|
+
*/
|
|
79
|
+
export declare function appendAbandonHistory(host: ProcessTask, operator: string, abandonedActors: (string | null)[], round: number, now: Date): void;
|
|
80
|
+
/**
|
|
81
|
+
* 投影(规范 06 §2.7):主办行 `ext.aidant`
|
|
82
|
+
* =`{active, round, total, submitted, actors:[{actor, taskId, state}], wait}`;无协办行 ⇒ null
|
|
83
|
+
* (门面那侧"不写键")。从 `task_parent_id`+`task_type` **现算**、不落新存储,
|
|
84
|
+
* 跳过 99 废弃行(清场的行不进投影,与征询投影同口径)。
|
|
85
|
+
*/
|
|
86
|
+
export declare function buildProjection(tasks: ProcessTask[], host: ProcessTask): Record<string, any> | null;
|
package/dist/aidant.js
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 动态协办(aidant,issues/253)——协办行识别、等待闸计数、投影、轮次与追加式账本的
|
|
3
|
+
* 纯函数家族(Node 栈)。
|
|
4
|
+
*
|
|
5
|
+
* 判据出处:规范 04「动态协办(aidant)」整节(派生规则/推进闸与等待闸/协办行能力与边界/
|
|
6
|
+
* 留痕与投影)+规范 06 §2.7 协议键与 §processTask/aidant、文末跨栈统一失败文案表「协办六行」。
|
|
7
|
+
* 本能力**无节点开关**(节点级 `taskType=1` 解析期禁配,issues/252)、不新增节点类型、
|
|
8
|
+
* 不新增 submitType 档、无 DDL(协办行即普通任务行)、不新增事件码(协办行建/结走既有码 3/5)。
|
|
9
|
+
*
|
|
10
|
+
* 形状基准=jeeflow-java 参考实现(issues/253 实施轮工作树现读)的 `core/AidantSupport.java`
|
|
11
|
+
* (纯函数家族)+ `core/JeeflowEngineImpl.aidantTask`/`completeAidantWithoutDrive`/
|
|
12
|
+
* `prepareExecution` 里的 `gateWait` + `model/TaskModel.abandonAidantOnLeave` +
|
|
13
|
+
* `handler/impl/CountersignHandler`(会签合并显式排除协办行);
|
|
14
|
+
* `jeeflow-go/engine/aidant.go` 与 `jeeflow-python/jeeflow/aidant.py` 是同一条移植腿的另两份样本。
|
|
15
|
+
*
|
|
16
|
+
* 语义一句话:主办把"这活"交给别人干——按人派生 `task_type=1` 的协办子行,**主办行原样保留
|
|
17
|
+
* DOING**;协办行办结不驱动流程,节点推进仍由主办行办结触发。与征询的本质差异:征询收的是
|
|
18
|
+
* "意见"且**强制等收齐**;协办交的是"活",**等不等由派生参数 waitCompletion 决定**(缺省 false=不等)。
|
|
19
|
+
*
|
|
20
|
+
* # 与征询的分辨判据=task_type(别简化)
|
|
21
|
+
*
|
|
22
|
+
* 两族子行都是 parent 指向主办行+同节点同名:协办行 `task_type=1`、征询成员行 `task_type=0`。
|
|
23
|
+
* 等待闸只数协办行、征询收齐闸只数成员行,各数各的(规范 04「与征询允许同节点并存」)。
|
|
24
|
+
* **同名过滤不可省**:主办办结推进后,下一节点行的 parent 同样是主办行 id(建单不变量),
|
|
25
|
+
* 只认 parent 会把下游行误当协办行——清场腿会误废弃它们。
|
|
26
|
+
*
|
|
27
|
+
* 本模块只做纯函数(判据/账本/投影),派生腿与闸门在 `engine.ts`、门面归一在 `facade.ts`
|
|
28
|
+
* ——与 java 的 AidantSupport / JeeflowEngineImpl / JeeflowFacade 三层分工同构。
|
|
29
|
+
*/
|
|
30
|
+
import { formatAddSignTime } from './addsign.js';
|
|
31
|
+
import { TaskState, TaskType } from './model.js';
|
|
32
|
+
// ─── 键名(逐字对齐 Java FlowConst / AidantSupport) ──────────────────────────
|
|
33
|
+
/**
|
|
34
|
+
* 动态协办账本:`{round, fromActor, toActors, reason, time, operator}` 只追加,落**主办行**变量
|
|
35
|
+
* (形状照 `tf_addSignHistory`,键序锁定、time 为 §2.4 字符串)。离开节点清场未办结协办行时
|
|
36
|
+
* 追加一条带 `abandoned: true` 的条目(照征询撤回的 `revoked`)。
|
|
37
|
+
*/
|
|
38
|
+
export const KeyAidantHistory = 'tf_aidantHistory';
|
|
39
|
+
/** 派生原因(选填,字符串):盖每条协办行(单行出证自足);**不占 `tf_approvalComment`**。 */
|
|
40
|
+
export const KeyAidantReason = 'tf_aidantReason';
|
|
41
|
+
/**
|
|
42
|
+
* 等待闸开关:派生时把 `waitCompletion` 盖在**主办行**变量上,缺省 false=主办不等协办办结
|
|
43
|
+
* 即可推进。`tf_` 前缀使实例合并自动剥键(不传播,与 `tf_allowRecall` 同通道);
|
|
44
|
+
* 投影 `ext.aidant.wait` 同源。
|
|
45
|
+
*/
|
|
46
|
+
export const KeyAidantWait = 'tf_aidantWait';
|
|
47
|
+
// ─── 逐字判据文案(跨栈统一;规范 06 文末失败文案表「协办六行」+等待闸那句) ────
|
|
48
|
+
export const MSG_NO_ACTORS = 'actorIds 必填';
|
|
49
|
+
export const MSG_NO_PERMISSION = '无权限派生协办任务';
|
|
50
|
+
export const MSG_NOT_DOING = '任务非进行中,不可派生协办';
|
|
51
|
+
export const MSG_DUPLICATE = '该人已有未办结的协办任务';
|
|
52
|
+
export const MSG_NO_RECURSION = '协办任务不能再派生协办';
|
|
53
|
+
export const MSG_TASK_NOT_FOUND = '任务不存在';
|
|
54
|
+
export const msgWaitPending = (taskName, submitted, total) => `节点[${taskName}]协办未办结(已办结 ${submitted}/${total}),不能办理`;
|
|
55
|
+
// ─── 协办行识别(纯函数) ─────────────────────────────────────────────────────
|
|
56
|
+
/** 协办行判定=`task_type=1`(SECONDARY)。这是两族子行唯一的分辨判据。 */
|
|
57
|
+
export function isAidantRow(row) {
|
|
58
|
+
return !!row && Number(row.taskType) === TaskType.Secondary;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 协办行=parent 指向主办行**且同节点同名且 task_type=1** 的行。
|
|
62
|
+
* 同名过滤与 task_type 过滤都不可省,理由见文件头「与征询的分辨判据」段。
|
|
63
|
+
*/
|
|
64
|
+
export function aidantRows(tasks, host) {
|
|
65
|
+
const out = [];
|
|
66
|
+
if (!host || !host.id)
|
|
67
|
+
return out;
|
|
68
|
+
for (const t of tasks ?? []) {
|
|
69
|
+
if (isAidantRow(t) && t.parentTaskId === host.id && t.taskName === host.taskName)
|
|
70
|
+
out.push(t);
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 等待闸原料:在册协办行总数与已办结(FINISHED)数——**已废弃(99) 行(离开节点清场的)
|
|
76
|
+
* 不算在册**(规范 04「计数跳过已废弃(99) 行」)。返回 `[total, submitted]`。
|
|
77
|
+
*/
|
|
78
|
+
export function countAidant(tasks, host) {
|
|
79
|
+
let total = 0;
|
|
80
|
+
let submitted = 0;
|
|
81
|
+
for (const t of aidantRows(tasks, host)) {
|
|
82
|
+
if (t.taskState === TaskState.Abandoned)
|
|
83
|
+
continue;
|
|
84
|
+
total++;
|
|
85
|
+
if (t.isFinished())
|
|
86
|
+
submitted++;
|
|
87
|
+
}
|
|
88
|
+
return [total, submitted];
|
|
89
|
+
}
|
|
90
|
+
/** 未办结协办行(DOING)——等待闸的判据集合,也是离开节点时的清场集合。 */
|
|
91
|
+
export function pendingAidant(tasks, host) {
|
|
92
|
+
return aidantRows(tasks, host).filter(t => t.isDoing());
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 等待闸开关(`waitCompletion`):派生时盖在**主办行**变量上,缺省 false=不等。
|
|
96
|
+
* 多轮派生时后一次的值生效(投影 `ext.aidant.wait` 同源)。
|
|
97
|
+
*
|
|
98
|
+
* 非法值按缺省 false(照 java `Boolean.parseBoolean`:只认 "true",大小写不敏感)——
|
|
99
|
+
* 契约只定义了 bool 档,**不为非法值新造文案**(协办六行之外不加第七行)。
|
|
100
|
+
*/
|
|
101
|
+
export function waitOf(host) {
|
|
102
|
+
if (!host)
|
|
103
|
+
return false;
|
|
104
|
+
const v = host.variables?.[KeyAidantWait];
|
|
105
|
+
if (v === null || v === undefined)
|
|
106
|
+
return false;
|
|
107
|
+
if (typeof v === 'boolean')
|
|
108
|
+
return v;
|
|
109
|
+
return String(v).trim().toLowerCase() === 'true';
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 等待闸(规范 04「推进闸与等待闸」):`waitCompletion=true` 时主办行办结前判
|
|
113
|
+
* "不存在 DOING 协办行",未齐 ⇒ 逐字文案报错、零写入。协办行自身不受本闸约束
|
|
114
|
+
* (它办结本来就不驱动流程);`waitCompletion=false`(缺省)原样放行。
|
|
115
|
+
*
|
|
116
|
+
* 必须由引擎排在 `completeTask` **之前**——内存仓储无回滚,判据后置时"报错"那一次调用
|
|
117
|
+
* 结束后主办待办已经消失(与后加签/退回守卫同一规矩)。
|
|
118
|
+
*/
|
|
119
|
+
export function gateWait(tasks, host) {
|
|
120
|
+
if (!host || isAidantRow(host) || !waitOf(host))
|
|
121
|
+
return;
|
|
122
|
+
if (pendingAidant(tasks, host).length === 0)
|
|
123
|
+
return;
|
|
124
|
+
const [total, submitted] = countAidant(tasks, host);
|
|
125
|
+
throw new Error(msgWaitPending(host.taskName, submitted, total));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 从行集合里剔掉协办行(task_type=1)——会签合并计数与"本节点还有兄弟待办"判据共用这一枚
|
|
129
|
+
* (规范 04「不计入会签合并计数」+「缺省 false 主办可随时推进」)。
|
|
130
|
+
*/
|
|
131
|
+
export function filterOutAidant(tasks) {
|
|
132
|
+
return (tasks ?? []).filter(t => !isAidantRow(t));
|
|
133
|
+
}
|
|
134
|
+
// ─── 轮次与账本 ───────────────────────────────────────────────────────────────
|
|
135
|
+
/** 读账本(测试与投影用);无该键/脏值 ⇒ 空表。 */
|
|
136
|
+
export function historyOf(task) {
|
|
137
|
+
const v = task?.variables?.[KeyAidantHistory];
|
|
138
|
+
return Array.isArray(v) ? v : [];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* 主办行当前轮次=账本末条 `round`(每次派生追加一条=轮次推进;**清场记账不消耗轮次**)。
|
|
142
|
+
*/
|
|
143
|
+
export function lastRound(host) {
|
|
144
|
+
const history = historyOf(host);
|
|
145
|
+
for (let i = history.length - 1; i >= 0; i--) {
|
|
146
|
+
const r = Number(history[i]?.round);
|
|
147
|
+
if (Number.isFinite(r) && r > 0)
|
|
148
|
+
return r;
|
|
149
|
+
}
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* 派生账本追加(只追加不覆盖),落**主办行**变量;六键
|
|
154
|
+
* `{round, fromActor, toActors, reason, time, operator}`(规范 06 §2.7),
|
|
155
|
+
* `reason` 空串兜底、`time` 一律 §2.4 字符串。
|
|
156
|
+
*
|
|
157
|
+
* 主办行在派生时不办结,`completeTask` 的变量合并是并入而非整体替换,故账本能活到主办办结
|
|
158
|
+
* 之后(与转办/征询账本同一条存活理由)。
|
|
159
|
+
* ⚠️ 调用方随后必须把主办行**再落一次库**(快照仓储纪律,同 `appendCollectHistory`)。
|
|
160
|
+
*/
|
|
161
|
+
export function appendAidantHistory(host, operator, toActors, round, reason, now) {
|
|
162
|
+
append(host, baseEntry(operator, toActors, round, reason, now));
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* 清场账本追加:`abandoned: true` 标记本条是"离开节点废弃"(形状照征询撤回条目的
|
|
166
|
+
* `revoked: true`),六键原序不动,`toActors`=被废弃的人。
|
|
167
|
+
*/
|
|
168
|
+
export function appendAbandonHistory(host, operator, abandonedActors, round, now) {
|
|
169
|
+
const entry = baseEntry(operator, [], round, '', now);
|
|
170
|
+
entry.toActors = [...abandonedActors];
|
|
171
|
+
entry.abandoned = true;
|
|
172
|
+
append(host, entry);
|
|
173
|
+
}
|
|
174
|
+
/** 账本条目六键固定 camelCase(`round, fromActor, toActors, reason, time, operator`),照 java 键序。 */
|
|
175
|
+
function baseEntry(operator, toActors, round, reason, now) {
|
|
176
|
+
return {
|
|
177
|
+
round,
|
|
178
|
+
fromActor: operator,
|
|
179
|
+
toActors: [...toActors],
|
|
180
|
+
reason: reason ?? '',
|
|
181
|
+
time: formatAddSignTime(now),
|
|
182
|
+
operator,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function append(host, entry) {
|
|
186
|
+
if (!host)
|
|
187
|
+
return;
|
|
188
|
+
const vars = host.variables;
|
|
189
|
+
if (!vars)
|
|
190
|
+
return;
|
|
191
|
+
const history = Array.isArray(vars[KeyAidantHistory])
|
|
192
|
+
? [...vars[KeyAidantHistory]]
|
|
193
|
+
: [];
|
|
194
|
+
history.push(entry);
|
|
195
|
+
vars[KeyAidantHistory] = history;
|
|
196
|
+
}
|
|
197
|
+
// ─── 投影 ─────────────────────────────────────────────────────────────────────
|
|
198
|
+
/**
|
|
199
|
+
* 投影(规范 06 §2.7):主办行 `ext.aidant`
|
|
200
|
+
* =`{active, round, total, submitted, actors:[{actor, taskId, state}], wait}`;无协办行 ⇒ null
|
|
201
|
+
* (门面那侧"不写键")。从 `task_parent_id`+`task_type` **现算**、不落新存储,
|
|
202
|
+
* 跳过 99 废弃行(清场的行不进投影,与征询投影同口径)。
|
|
203
|
+
*/
|
|
204
|
+
export function buildProjection(tasks, host) {
|
|
205
|
+
const rows = aidantRows(tasks, host);
|
|
206
|
+
if (rows.length === 0)
|
|
207
|
+
return null;
|
|
208
|
+
let total = 0;
|
|
209
|
+
let submitted = 0;
|
|
210
|
+
const actors = [];
|
|
211
|
+
for (const t of rows) {
|
|
212
|
+
if (t.taskState === TaskState.Abandoned)
|
|
213
|
+
continue;
|
|
214
|
+
total++;
|
|
215
|
+
if (t.isFinished())
|
|
216
|
+
submitted++;
|
|
217
|
+
actors.push({
|
|
218
|
+
actor: t.actorIds && t.actorIds.length > 0 ? t.actorIds[0] : null,
|
|
219
|
+
taskId: t.id,
|
|
220
|
+
state: t.taskState,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
active: submitted < total,
|
|
225
|
+
round: lastRound(host),
|
|
226
|
+
total,
|
|
227
|
+
submitted,
|
|
228
|
+
actors,
|
|
229
|
+
wait: waitOf(host),
|
|
230
|
+
};
|
|
231
|
+
}
|
package/dist/collect.d.ts
CHANGED
|
@@ -41,11 +41,14 @@ export declare function checkCollectFlowConfig(flow: FlowModel): void;
|
|
|
41
41
|
/**
|
|
42
42
|
* 成员行=parent 指向主办行**且同节点同名**的行(成员不能再拉人 ⇒ 无更深层级)。
|
|
43
43
|
* 同名过滤不可省,理由见文件头「成员行识别」段。
|
|
44
|
+
* issues/253:协办行(task_type=1)也满足 parent+同名,但它属另一族——征询收齐闸只数
|
|
45
|
+
* 征询成员行(task_type=0),两闸各数各的(规范 04「与征询允许同节点并存」)。
|
|
44
46
|
*/
|
|
45
47
|
export declare function memberRows(tasks: ProcessTask[], host: ProcessTask | null | undefined): ProcessTask[];
|
|
46
48
|
/**
|
|
47
49
|
* 成员行判定:parent 指向**同节点同名**行(成员行禁带拉人参数的判据)。
|
|
48
50
|
* 无 parent(空/'0')的行一律 false——普通建单那条不是成员。
|
|
51
|
+
* issues/253:协办行(task_type=1)不是征询成员行——两族靠 task_type 分辨。
|
|
49
52
|
*/
|
|
50
53
|
export declare function isMemberRow(tasks: ProcessTask[], row: ProcessTask | null | undefined): boolean;
|
|
51
54
|
/** 未答成员行(DOING):闸门判据的原料,也是撤回接口的废弃集合。 */
|
package/dist/collect.js
CHANGED
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
import { isFirstTaskName, isCountersign } from './engine.js';
|
|
31
31
|
import { parseAllow, allowAddSignOf, historyOf, KeyAddSignHistory, formatAddSignTime } from './addsign.js';
|
|
32
32
|
import { TaskState, TypeTask } from './model.js';
|
|
33
|
+
// issues/253:协办行排除判据(两族子行靠 task_type 分辨;函数体内取用,求值期不碰)
|
|
34
|
+
import { isAidantRow } from './aidant.js';
|
|
33
35
|
/** 节点属性键:动态会签(征询模式)开关(`properties` 平铺层,缺省 false) */
|
|
34
36
|
export const PROP_DYNAMIC_COUNTERSIGN = 'dynamicCountersign';
|
|
35
37
|
/**
|
|
@@ -96,13 +98,15 @@ export function checkCollectFlowConfig(flow) {
|
|
|
96
98
|
/**
|
|
97
99
|
* 成员行=parent 指向主办行**且同节点同名**的行(成员不能再拉人 ⇒ 无更深层级)。
|
|
98
100
|
* 同名过滤不可省,理由见文件头「成员行识别」段。
|
|
101
|
+
* issues/253:协办行(task_type=1)也满足 parent+同名,但它属另一族——征询收齐闸只数
|
|
102
|
+
* 征询成员行(task_type=0),两闸各数各的(规范 04「与征询允许同节点并存」)。
|
|
99
103
|
*/
|
|
100
104
|
export function memberRows(tasks, host) {
|
|
101
105
|
const out = [];
|
|
102
106
|
if (!host || !host.id)
|
|
103
107
|
return out;
|
|
104
108
|
for (const t of tasks ?? []) {
|
|
105
|
-
if (t.parentTaskId === host.id && t.taskName === host.taskName)
|
|
109
|
+
if (t.parentTaskId === host.id && t.taskName === host.taskName && !isAidantRow(t))
|
|
106
110
|
out.push(t);
|
|
107
111
|
}
|
|
108
112
|
return out;
|
|
@@ -110,10 +114,13 @@ export function memberRows(tasks, host) {
|
|
|
110
114
|
/**
|
|
111
115
|
* 成员行判定:parent 指向**同节点同名**行(成员行禁带拉人参数的判据)。
|
|
112
116
|
* 无 parent(空/'0')的行一律 false——普通建单那条不是成员。
|
|
117
|
+
* issues/253:协办行(task_type=1)不是征询成员行——两族靠 task_type 分辨。
|
|
113
118
|
*/
|
|
114
119
|
export function isMemberRow(tasks, row) {
|
|
115
120
|
if (!row || !row.parentTaskId || row.parentTaskId === '0')
|
|
116
121
|
return false;
|
|
122
|
+
if (isAidantRow(row))
|
|
123
|
+
return false;
|
|
117
124
|
for (const t of tasks ?? []) {
|
|
118
125
|
if (t.id === row.parentTaskId && t.taskName === row.taskName)
|
|
119
126
|
return true;
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type FlowModel, type FlowNode, ProcessInstance, type ProcessTask } from './model.js';
|
|
2
2
|
import type { ProcessRepository, ProcessExtRepository, UserProvider, IDGenerator, ExpressionEvaluator } from './spi.js';
|
|
3
|
+
import type { TimeActionSink } from './spi.js';
|
|
3
4
|
import { type EngineExtensions, type ProcessEvent } from './extensions.js';
|
|
4
5
|
import { HandlerRegistry } from './registry.js';
|
|
5
6
|
export declare const KeySubmitType = "submitType";
|
|
@@ -66,6 +67,10 @@ export interface EngineOptions {
|
|
|
66
67
|
surrogateRepository?: SurrogateLookup | null;
|
|
67
68
|
/** 委托自动生效开关,**默认 true(引擎内置开启)**;显式传 false → 回到"仅台账"行为 */
|
|
68
69
|
surrogateEnabled?: boolean;
|
|
70
|
+
/** 时限动作凭证(spec 04);不传 = 全部时限动作静默跳过 */
|
|
71
|
+
timeActionSink?: TimeActionSink;
|
|
72
|
+
/** 引擎时钟(spec 04 · 时间基准);不传 = this.now() */
|
|
73
|
+
clock?: () => Date;
|
|
69
74
|
}
|
|
70
75
|
export declare class EngineImpl implements Engine {
|
|
71
76
|
#private;
|
|
@@ -78,6 +83,10 @@ export declare class EngineImpl implements Engine {
|
|
|
78
83
|
private ext?;
|
|
79
84
|
private registry?;
|
|
80
85
|
private surrogateRepo?;
|
|
86
|
+
/** 时限动作凭证(spec 04):不传=全部时限动作静默跳过 */
|
|
87
|
+
private timeActionSink?;
|
|
88
|
+
/** 引擎时钟(spec 04):不传=系统钟 */
|
|
89
|
+
private clock;
|
|
81
90
|
private surrogateOn;
|
|
82
91
|
constructor(repo: ProcessRepository, userProv?: UserProvider | undefined, idGen?: IDGenerator | undefined, exprEval?: ExpressionEvaluator | undefined, opts?: EngineOptions);
|
|
83
92
|
/**
|
|
@@ -196,6 +205,38 @@ export declare class EngineImpl implements Engine {
|
|
|
196
205
|
*/
|
|
197
206
|
recallTask(taskId: string, operator: string): Promise<ProcessTask>;
|
|
198
207
|
private recallTaskInner;
|
|
208
|
+
/**
|
|
209
|
+
* 动态协办(issues/253,规范 04 · 动态协办):主办把"这活"交给别人干——按人派生
|
|
210
|
+
* `task_type=1` 协办子行,**主办行原样保留 DOING**,节点推进仍由主办行办结触发。
|
|
211
|
+
*
|
|
212
|
+
* 判据全部排在任何状态变更之前(报错即零写入——与后加签/征询/撤回同一规矩):
|
|
213
|
+
* 任务存在 → 禁递归(协办行不能再派生)→ 主办行 DOING → actorIds 非空 → 名册鉴权
|
|
214
|
+
* (auto/admin 例外)→ 逐人去重(该人已有本主办行下未办结协办行)。
|
|
215
|
+
* 落库顺序:协办行既有建单腿(委托并入 → saveTask → 码 3)→ 主办行盖 wait 开关+账本 updateTask。
|
|
216
|
+
* 建单形状照征询成员行腿(`createCollectMemberRows`),另落 task_type=1/performType=NORMAL。
|
|
217
|
+
*/
|
|
218
|
+
aidantTask(taskId: string, actorIds: string[], reason: string, waitCompletion: boolean, operator: string): Promise<ProcessTask[]>;
|
|
219
|
+
private aidantTaskInner;
|
|
220
|
+
/**
|
|
221
|
+
* 协办行办结的**推进闸**(issues/253,规范 04「推进闸与等待闸」;参照 snaker
|
|
222
|
+
* `SnakerEngineImpl.execute` 的「协办任务完成不产生执行对象」):只完成任务行
|
|
223
|
+
* (`prepareExecuteTask` 内含 completeTask/updateTask/fire 码 5 或 6),
|
|
224
|
+
* **不跑节点执行、不跑输出变迁**,本次动作产出列表为空(无 saveTask ⇒ ALS sink 空)。
|
|
225
|
+
*
|
|
226
|
+
* 四入口同闸:executeProcessTask/executeAndJumpTask/executeAndJumpToEnd/
|
|
227
|
+
* executeAndJumpToFirstTaskNode——协办行任何 submitType 都不得驱动流程。
|
|
228
|
+
*/
|
|
229
|
+
private completeAidantWithoutDrive;
|
|
230
|
+
/**
|
|
231
|
+
* 离开节点时清场未办结协办行(规范 04:waitCompletion=false 时主办可随时推进,未办结协办行
|
|
232
|
+
* 随废弃腿清场、账本记废弃,不留孤儿待办)。
|
|
233
|
+
*
|
|
234
|
+
* 只对协办行(task_type=1)动手,且**不要求节点开任何开关**——协办无节点开关,普通节点上的
|
|
235
|
+
* 协办行同样要清(这是与 `abandonAddSignDoing` 的关键差别,后者有双开关守卫)。按 parent 分组,
|
|
236
|
+
* 废弃事实追加到各自主办行的账本上。幂等:已废弃(99)/已办结(20) 的行不再命中,重复调用不重复
|
|
237
|
+
* 记账。返回实际废弃的行数。
|
|
238
|
+
*/
|
|
239
|
+
private abandonAidantOnNode;
|
|
199
240
|
private prepareExecuteTask;
|
|
200
241
|
private isFirstTaskNode;
|
|
201
242
|
/**
|
|
@@ -298,6 +339,14 @@ export declare class EngineImpl implements Engine {
|
|
|
298
339
|
* 未配置查询源、显式关闭、无参与人 → 空映射(= 原样参与者,不打断建单);
|
|
299
340
|
* 单条查询异常只记录不传播(委托是增强能力,建单主流程不得被拖崩)。
|
|
300
341
|
*/
|
|
342
|
+
private now;
|
|
343
|
+
private lockInstance;
|
|
344
|
+
private cancelTaskTimeActions;
|
|
345
|
+
private cancelInstanceTimeActions;
|
|
346
|
+
/** 建单侧动作行:autoExecute=Y→AUTO_COMPLETE;有效 reminderTime→首条 REMIND。 */
|
|
347
|
+
private scheduleTimeActions;
|
|
348
|
+
/** 任务完成(state 落 20)插入 CALLBACK(dueAt=now)。 */
|
|
349
|
+
private insertCallbackAction;
|
|
301
350
|
private surrogateAgents;
|
|
302
351
|
private loadAndCheck;
|
|
303
352
|
private executeNode;
|
|
@@ -369,21 +418,8 @@ export declare function unknownEdgeWarning(from: string, to: string): string;
|
|
|
369
418
|
* 设计器属性面板保存 'ALL' 字符串符合 Java 契约,引擎必须兼容 */
|
|
370
419
|
export declare function isCountersign(v: any): boolean;
|
|
371
420
|
/**
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
* 三档语义,**顺序不能变**:
|
|
375
|
-
* 1. `args` 里存在键名等于 expr 原串的项 ⇒ 取该项的值:Date / 毫秒时间戳 / `"yyyy-MM-dd HH:mm:ss"`
|
|
376
|
-
* → 该时刻;字符串解析失败 → **null**(不是 now);其它类型(布尔/数组/对象/小数)→ **落穿**到下面两档
|
|
377
|
-
* (Java/C# 都是落穿,不许当"解析失败"提前 return null)。
|
|
378
|
-
* 2. 否则 expr 以 `s`/`m`/`h`/`d` 结尾且前缀是整数 ⇒ now + N 秒/分/时/天(`d` 走**日历加天**,不乘 86400 秒)。
|
|
379
|
-
* 前缀**允许两端空白**(issues/137 E · owner 拍"统一 trim"):`intPrefix` 在判整数前裁掉
|
|
380
|
-
* `expr.slice(0, -1)` 的两端空白 ⇒ `" 2h"`、`"2 h"` 照样算得出;裁的边界只到前缀,末位单位符那一位
|
|
381
|
-
* (下面 `expr.charAt(expr.length - 1)`)**不跟着 trim** ⇒ `"2h "` 仍按误配落穿。
|
|
382
|
-
* 3. 否则把 expr 本身按 `"yyyy-MM-dd HH:mm:ss"` 解析 → 时刻;失败 → null。
|
|
383
|
-
* ⚠️ 档 1 的键名与档 3 的串本身**都不 trim**:那是键名/时间串本身,裁它会改的是另一件事。
|
|
384
|
-
*
|
|
385
|
-
* ⚠️ 任何一档都不得退回 now()——"算不出来就写当前时间"正是 issues/126 的病灶(建单即逾期,逾期统计恒失真)。
|
|
386
|
-
*
|
|
387
|
-
* @param now 取时基准=**本栈写 createTime 用的同一个 Date**(本栈无时钟槽,与 Java 直接用系统钟同档)
|
|
421
|
+
* 首次提醒时刻(规范 02 §4.5):变量 → 相对量(锚点=任务创建时刻)→ 严格 HH:mm → 绝对。
|
|
422
|
+
* 任何一档都不得回落"当前时刻"或 expireTime。
|
|
388
423
|
*/
|
|
424
|
+
export declare function firstReminderTime(expr: string, args: Record<string, any> | undefined, createTime: Date): Date | null;
|
|
389
425
|
export declare function processTime(expr: string, args: Record<string, any> | undefined, now: Date): Date | null;
|