assistsx-js 0.2.1 → 0.2.3

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.
@@ -0,0 +1,83 @@
1
+ import { S as Step, h as StepImpl, f as StepData } from '../step-DnFA4DEb.mjs';
2
+
3
+ /** 流程步骤执行结果:事件 / 重复 / 结束 / 委托 legacy StepImpl */
4
+ type StepFlowOutcome = {
5
+ type: "event";
6
+ name: string;
7
+ } | {
8
+ type: "repeat";
9
+ } | {
10
+ type: "end";
11
+ } | {
12
+ type: "legacy";
13
+ impl: StepImpl;
14
+ };
15
+ /** 流程步骤实现:只描述 UI 与分支事件,不直接决定下一状态 */
16
+ type FlowStepImpl = (step: Step) => Promise<StepFlowOutcome>;
17
+ /** 单个流程状态定义 */
18
+ interface FlowStateDef {
19
+ run: FlowStepImpl;
20
+ /** 事件名 -> 下一状态名 */
21
+ on: Record<string, string>;
22
+ }
23
+ /** StepFlow 运行配置 */
24
+ interface StepFlowConfig {
25
+ id?: string;
26
+ initial: string;
27
+ states: Record<string, FlowStateDef>;
28
+ /** 写入 step.data.payload 的初始业务数据 */
29
+ data?: StepData;
30
+ }
31
+ /** 库写入 step.data.__flow 的结构 */
32
+ interface StepFlowMeta {
33
+ id?: string;
34
+ state: string;
35
+ }
36
+ /** step.data 推荐结构(payload 用户读写,__flow 库维护) */
37
+ interface StepFlowData {
38
+ payload?: StepData;
39
+ __flow?: StepFlowMeta;
40
+ finishMethod?: StepImpl;
41
+ [key: string]: unknown;
42
+ }
43
+
44
+ /** 产生流程事件,由当前状态的 on 表决定下一状态 */
45
+ declare function flowEvent(name: string): StepFlowOutcome;
46
+ /** 重复当前流程状态(沿用 Step.repeat 语义) */
47
+ declare function flowRepeat(): StepFlowOutcome;
48
+ /** 结束整个流程 */
49
+ declare function flowEnd(): StepFlowOutcome;
50
+
51
+ /** 读取业务 payload(不存在时返回空对象) */
52
+ declare function getFlowPayload<T extends StepData = StepData>(step: Step): T;
53
+ /** 浅合并写入 payload */
54
+ declare function assignFlowPayload(step: Step, partial: StepData): void;
55
+
56
+ /**
57
+ * 为 legacy 步骤(如 app-launch)创建 finishMethod:
58
+ * 应用打开成功后跳回 StepFlow dispatcher 并切换到指定状态。
59
+ */
60
+ declare function createFinishHandoff(dispatcher: StepImpl, nextState: string): StepImpl;
61
+ /**
62
+ * 创建 launch 类流程状态:写入 finishMethod 后委托执行 legacy StepImpl 链。
63
+ */
64
+ declare function createLaunchState(dispatcher: StepImpl, launchImpl: StepImpl, nextState: string,
65
+ /** legacy 步骤从 step.data 读取的字段名(默认与 payload 键一致) */
66
+ legacyDataKeys?: string[]): FlowStateDef;
67
+
68
+ /** 创建流程调度 StepImpl(需先填充 config.states,见 createLaunchState) */
69
+ declare function createFlowDispatcher(config: StepFlowConfig): StepImpl;
70
+ declare function buildFlowInitialData(config: StepFlowConfig): StepFlowData;
71
+ declare class StepFlow {
72
+ /**
73
+ * 按状态机配置运行流程,内部复用 Step.run 与现有步骤循环。
74
+ */
75
+ static run(config: StepFlowConfig, options?: {
76
+ stepId?: string;
77
+ tag?: string;
78
+ delayMs?: number;
79
+ exceptionRetryCountMax?: number;
80
+ }): Promise<Step | undefined>;
81
+ }
82
+
83
+ export { type FlowStateDef, type FlowStepImpl, StepFlow, type StepFlowConfig, type StepFlowData, type StepFlowMeta, type StepFlowOutcome, assignFlowPayload, buildFlowInitialData, createFinishHandoff, createFlowDispatcher, createLaunchState, flowEnd, flowEvent, flowRepeat, getFlowPayload };
@@ -0,0 +1,83 @@
1
+ import { S as Step, h as StepImpl, f as StepData } from '../step-DnFA4DEb.js';
2
+
3
+ /** 流程步骤执行结果:事件 / 重复 / 结束 / 委托 legacy StepImpl */
4
+ type StepFlowOutcome = {
5
+ type: "event";
6
+ name: string;
7
+ } | {
8
+ type: "repeat";
9
+ } | {
10
+ type: "end";
11
+ } | {
12
+ type: "legacy";
13
+ impl: StepImpl;
14
+ };
15
+ /** 流程步骤实现:只描述 UI 与分支事件,不直接决定下一状态 */
16
+ type FlowStepImpl = (step: Step) => Promise<StepFlowOutcome>;
17
+ /** 单个流程状态定义 */
18
+ interface FlowStateDef {
19
+ run: FlowStepImpl;
20
+ /** 事件名 -> 下一状态名 */
21
+ on: Record<string, string>;
22
+ }
23
+ /** StepFlow 运行配置 */
24
+ interface StepFlowConfig {
25
+ id?: string;
26
+ initial: string;
27
+ states: Record<string, FlowStateDef>;
28
+ /** 写入 step.data.payload 的初始业务数据 */
29
+ data?: StepData;
30
+ }
31
+ /** 库写入 step.data.__flow 的结构 */
32
+ interface StepFlowMeta {
33
+ id?: string;
34
+ state: string;
35
+ }
36
+ /** step.data 推荐结构(payload 用户读写,__flow 库维护) */
37
+ interface StepFlowData {
38
+ payload?: StepData;
39
+ __flow?: StepFlowMeta;
40
+ finishMethod?: StepImpl;
41
+ [key: string]: unknown;
42
+ }
43
+
44
+ /** 产生流程事件,由当前状态的 on 表决定下一状态 */
45
+ declare function flowEvent(name: string): StepFlowOutcome;
46
+ /** 重复当前流程状态(沿用 Step.repeat 语义) */
47
+ declare function flowRepeat(): StepFlowOutcome;
48
+ /** 结束整个流程 */
49
+ declare function flowEnd(): StepFlowOutcome;
50
+
51
+ /** 读取业务 payload(不存在时返回空对象) */
52
+ declare function getFlowPayload<T extends StepData = StepData>(step: Step): T;
53
+ /** 浅合并写入 payload */
54
+ declare function assignFlowPayload(step: Step, partial: StepData): void;
55
+
56
+ /**
57
+ * 为 legacy 步骤(如 app-launch)创建 finishMethod:
58
+ * 应用打开成功后跳回 StepFlow dispatcher 并切换到指定状态。
59
+ */
60
+ declare function createFinishHandoff(dispatcher: StepImpl, nextState: string): StepImpl;
61
+ /**
62
+ * 创建 launch 类流程状态:写入 finishMethod 后委托执行 legacy StepImpl 链。
63
+ */
64
+ declare function createLaunchState(dispatcher: StepImpl, launchImpl: StepImpl, nextState: string,
65
+ /** legacy 步骤从 step.data 读取的字段名(默认与 payload 键一致) */
66
+ legacyDataKeys?: string[]): FlowStateDef;
67
+
68
+ /** 创建流程调度 StepImpl(需先填充 config.states,见 createLaunchState) */
69
+ declare function createFlowDispatcher(config: StepFlowConfig): StepImpl;
70
+ declare function buildFlowInitialData(config: StepFlowConfig): StepFlowData;
71
+ declare class StepFlow {
72
+ /**
73
+ * 按状态机配置运行流程,内部复用 Step.run 与现有步骤循环。
74
+ */
75
+ static run(config: StepFlowConfig, options?: {
76
+ stepId?: string;
77
+ tag?: string;
78
+ delayMs?: number;
79
+ exceptionRetryCountMax?: number;
80
+ }): Promise<Step | undefined>;
81
+ }
82
+
83
+ export { type FlowStateDef, type FlowStepImpl, StepFlow, type StepFlowConfig, type StepFlowData, type StepFlowMeta, type StepFlowOutcome, assignFlowPayload, buildFlowInitialData, createFinishHandoff, createFlowDispatcher, createLaunchState, flowEnd, flowEvent, flowRepeat, getFlowPayload };