@wooksjs/event-wf 0.4.11 → 0.4.12

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/index.cjs CHANGED
@@ -24,11 +24,6 @@ function resumeWfContext(data, options) {
24
24
  options,
25
25
  });
26
26
  }
27
- /**
28
- * Wrapper on top of useEventContext that provides
29
- * proper context types for WF event
30
- * @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
31
- */
32
27
  function useWFContext() {
33
28
  return eventCore.useEventContext('WF');
34
29
  }
@@ -108,7 +103,6 @@ class WooksWf extends wooks.WooksAdapterBase {
108
103
  spy(...args);
109
104
  }
110
105
  if (firstStep && args[0] === 'step') {
111
- // cleanup input after the first step
112
106
  firstStep = false;
113
107
  restoreCtx();
114
108
  const { store } = useWFContext();
@@ -170,12 +164,6 @@ class WooksWf extends wooks.WooksAdapterBase {
170
164
  }
171
165
  }
172
166
  }
173
- /**
174
- * Factory for WooksWf App
175
- * @param opts TWooksWfOptions
176
- * @param wooks Wooks | WooksAdapterBase
177
- * @returns WooksWf
178
- */
179
167
  function createWfApp(opts, wooks) {
180
168
  return new WooksWf(opts, wooks);
181
169
  }
package/dist/index.d.ts CHANGED
@@ -1,162 +1,144 @@
1
- import { Step } from '@prostojs/wf';
2
- import { TConsoleBase } from '@prostojs/logger';
3
- import { TEmpty } from '@wooksjs/event-core';
4
- import { TEventOptions } from '@wooksjs/event-core';
5
- import { TFlowOutput } from '@prostojs/wf';
6
- import { TGenericContextStore } from '@wooksjs/event-core';
7
- import { TProstoRouterPathHandle } from '@prostojs/router';
8
- import { TStepHandler } from '@prostojs/wf';
9
- import { TWooksHandler } from 'wooks';
10
- import { TWooksOptions } from 'wooks';
11
- import { TWorkflowSchema } from '@prostojs/wf';
12
- import { TWorkflowSpy } from '@prostojs/wf';
13
- import { Wooks } from 'wooks';
14
- import { WooksAdapterBase } from 'wooks';
15
- import { Workflow } from '@prostojs/wf';
16
-
17
- /**
18
- * Factory for WooksWf App
19
- * @param opts TWooksWfOptions
20
- * @param wooks Wooks | WooksAdapterBase
21
- * @returns WooksWf
22
- */
23
- export declare function createWfApp<T>(opts?: TWooksWfOptions, wooks?: Wooks | WooksAdapterBase): WooksWf<T>;
24
-
25
- export declare function createWfContext(data: Omit<TWFEventData, 'type'>, options: TEventOptions): {
26
- getCtx: () => TWFContextStore & TGenericContextStore<TWFEventData>;
27
- restoreCtx: () => TGenericContextStore<TEmpty>;
28
- clearCtx: () => null;
29
- store: <K extends "resume" | keyof TGenericContextStore<TWFEventData>>(key: K) => {
30
- value: (TWFContextStore & TGenericContextStore<TWFEventData>)[K];
31
- hook: <K2 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2) => {
32
- value: Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K][K2];
33
- isDefined: boolean;
34
- };
35
- init: <K2_1 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2_1, getter: () => Required<Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>[K2_1]) => Required<Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>[K2_1];
36
- set: <K2_2 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2_2, v: Required<(TWFContextStore & TGenericContextStore<TWFEventData>)[K]>[K2_2]) => Required<(TWFContextStore & TGenericContextStore<TWFEventData>)[K]>[K2_2];
37
- get: <K2_3 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2_3) => Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K][K2_3];
38
- has: <K2_4 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2_4) => boolean;
39
- del: <K2_5 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2_5) => void;
40
- entries: () => [string, unknown][];
41
- clear: () => void;
42
- };
43
- getStore: <K_1 extends "resume" | keyof TGenericContextStore<TWFEventData>>(key: K_1) => (TWFContextStore & TGenericContextStore<TWFEventData>)[K_1];
44
- setStore: <K_2 extends "resume" | keyof TGenericContextStore<TWFEventData>>(key: K_2, v: (TWFContextStore & TGenericContextStore<TWFEventData>)[K_2]) => void;
45
- };
46
-
47
- export declare function resumeWfContext(data: Omit<TWFEventData, 'type'>, options: TEventOptions): {
48
- getCtx: () => TWFContextStore & TGenericContextStore<TWFEventData>;
49
- restoreCtx: () => TGenericContextStore<TEmpty>;
50
- clearCtx: () => null;
51
- store: <K extends "resume" | keyof TGenericContextStore<TWFEventData>>(key: K) => {
52
- value: (TWFContextStore & TGenericContextStore<TWFEventData>)[K];
53
- hook: <K2 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2) => {
54
- value: Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K][K2];
55
- isDefined: boolean;
56
- };
57
- init: <K2_1 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2_1, getter: () => Required<Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>[K2_1]) => Required<Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>[K2_1];
58
- set: <K2_2 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2_2, v: Required<(TWFContextStore & TGenericContextStore<TWFEventData>)[K]>[K2_2]) => Required<(TWFContextStore & TGenericContextStore<TWFEventData>)[K]>[K2_2];
59
- get: <K2_3 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2_3) => Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K][K2_3];
60
- has: <K2_4 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2_4) => boolean;
61
- del: <K2_5 extends keyof Required<TWFContextStore & TGenericContextStore<TWFEventData>>[K]>(key2: K2_5) => void;
62
- entries: () => [string, unknown][];
63
- clear: () => void;
64
- };
65
- getStore: <K_1 extends "resume" | keyof TGenericContextStore<TWFEventData>>(key: K_1) => (TWFContextStore & TGenericContextStore<TWFEventData>)[K_1];
66
- setStore: <K_2 extends "resume" | keyof TGenericContextStore<TWFEventData>>(key: K_2, v: (TWFContextStore & TGenericContextStore<TWFEventData>)[K_2]) => void;
67
- };
68
-
69
- export { TStepHandler }
70
-
71
- export declare interface TWFContextStore {
72
- resume: boolean;
73
- }
74
-
75
- export declare interface TWFEventData {
76
- schemaId: string;
77
- inputContext: unknown;
78
- indexes?: number[];
79
- input?: unknown;
80
- type: 'WF';
81
- }
82
-
83
- export declare interface TWooksWfOptions {
84
- onError?(e: Error): void;
85
- onNotFound?: TWooksHandler<unknown>;
86
- onUnknownFlow?: (schemaId: string, raiseError: () => void) => unknown;
87
- logger?: TConsoleBase;
88
- eventOptions?: TEventOptions;
89
- router?: TWooksOptions['router'];
90
- }
91
-
92
- export { TWorkflowSchema }
93
-
94
- /**
95
- * Wrapper on top of useEventContext that provides
96
- * proper context types for WF event
97
- * @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
98
- */
99
- export declare function useWFContext<T extends TEmpty>(): {
100
- getCtx: () => TWFContextStore & T & TGenericContextStore<TWFEventData>;
101
- restoreCtx: () => TGenericContextStore<TEmpty>;
102
- clearCtx: () => null;
103
- store: <K extends "resume" | keyof TGenericContextStore<TWFEventData> | keyof T>(key: K) => {
104
- value: (TWFContextStore & T & TGenericContextStore<TWFEventData>)[K];
105
- hook: <K2 extends keyof Required<TWFContextStore & T & TGenericContextStore<TWFEventData>>[K]>(key2: K2) => {
106
- value: Required<TWFContextStore & T & TGenericContextStore<TWFEventData>>[K][K2];
107
- isDefined: boolean;
108
- };
109
- init: <K2_1 extends keyof Required<TWFContextStore & T & TGenericContextStore<TWFEventData>>[K]>(key2: K2_1, getter: () => Required<Required<TWFContextStore & T & TGenericContextStore<TWFEventData>>[K]>[K2_1]) => Required<Required<TWFContextStore & T & TGenericContextStore<TWFEventData>>[K]>[K2_1];
110
- set: <K2_2 extends keyof Required<TWFContextStore & T & TGenericContextStore<TWFEventData>>[K]>(key2: K2_2, v: Required<(TWFContextStore & T & TGenericContextStore<TWFEventData>)[K]>[K2_2]) => Required<(TWFContextStore & T & TGenericContextStore<TWFEventData>)[K]>[K2_2];
111
- get: <K2_3 extends keyof Required<TWFContextStore & T & TGenericContextStore<TWFEventData>>[K]>(key2: K2_3) => Required<TWFContextStore & T & TGenericContextStore<TWFEventData>>[K][K2_3];
112
- has: <K2_4 extends keyof Required<TWFContextStore & T & TGenericContextStore<TWFEventData>>[K]>(key2: K2_4) => boolean;
113
- del: <K2_5 extends keyof Required<TWFContextStore & T & TGenericContextStore<TWFEventData>>[K]>(key2: K2_5) => void;
114
- entries: () => [string, unknown][];
115
- clear: () => void;
116
- };
117
- getStore: <K_1 extends "resume" | keyof TGenericContextStore<TWFEventData> | keyof T>(key: K_1) => (TWFContextStore & T & TGenericContextStore<TWFEventData>)[K_1];
118
- setStore: <K_2 extends "resume" | keyof TGenericContextStore<TWFEventData> | keyof T>(key: K_2, v: (TWFContextStore & T & TGenericContextStore<TWFEventData>)[K_2]) => void;
119
- };
120
-
121
- export declare function useWfState(): {
122
- ctx: <T>() => T;
123
- input: <I>() => I | undefined;
124
- schemaId: string;
125
- indexes: () => number[] | undefined;
126
- resume: boolean;
127
- };
128
-
129
- export declare const wfShortcuts: {
130
- flow: string;
131
- step: string;
132
- };
133
-
134
- export declare class WooksWf<T> extends WooksAdapterBase {
135
- protected opts?: TWooksWfOptions | undefined;
136
- protected logger: TConsoleBase;
137
- protected wf: WooksWorkflow<T>;
138
- constructor(opts?: TWooksWfOptions | undefined, wooks?: Wooks | WooksAdapterBase);
139
- attachSpy<I>(fn: TWorkflowSpy<T, I>): () => void;
140
- detachSpy<I>(fn: TWorkflowSpy<T, I>): void;
141
- step<I = any, D = any>(id: string, opts: {
142
- input?: D;
143
- handler: string | TStepHandler<T, I, D>;
144
- }): TProstoRouterPathHandle<Record<string, string | string[]>>;
145
- flow(id: string, schema: TWorkflowSchema<T>, init?: () => void | Promise<void>): TProstoRouterPathHandle<Record<string, string | string[]>>;
146
- start<I>(schemaId: string, inputContext: T, input?: I, spy?: TWorkflowSpy<T, I>, cleanup?: () => void): Promise<TFlowOutput<T, I>>;
147
- resume<I>(schemaId: string, state: {
148
- indexes: number[];
149
- context: T;
150
- }, input?: I, spy?: TWorkflowSpy<T, I>, cleanup?: () => void): Promise<TFlowOutput<T, I>>;
151
- protected _start<I>(schemaId: string, inputContext: T, indexes?: number[], input?: I, spy?: TWorkflowSpy<T, I>, cleanup?: () => void): Promise<TFlowOutput<T, I>>;
152
- protected onError(e: Error): void;
153
- protected error(e: string | Error): void;
154
- }
155
-
156
- declare class WooksWorkflow<T> extends Workflow<T> {
157
- protected wooks: Wooks;
158
- constructor(wooks: Wooks);
159
- protected resolveStep<I, D>(stepId: string): Step<T, I, D>;
160
- }
161
-
162
- export { }
1
+ import * as _wooksjs_event_core from '@wooksjs/event-core';
2
+ import { TEventOptions, TEmpty } from '@wooksjs/event-core';
3
+ import * as _prostojs_router from '@prostojs/router';
4
+ import { Wooks, TWooksHandler, TWooksOptions, WooksAdapterBase } from 'wooks';
5
+ import { TConsoleBase } from '@prostojs/logger';
6
+ import { Workflow, Step, TWorkflowSpy, TStepHandler, TWorkflowSchema, TFlowOutput } from '@prostojs/wf';
7
+ export { TStepHandler, TWorkflowSchema } from '@prostojs/wf';
8
+
9
+ interface TWFEventData {
10
+ schemaId: string;
11
+ inputContext: unknown;
12
+ indexes?: number[];
13
+ input?: unknown;
14
+ type: 'WF';
15
+ }
16
+ interface TWFContextStore {
17
+ resume: boolean;
18
+ }
19
+
20
+ declare function createWfContext(data: Omit<TWFEventData, 'type'>, options: TEventOptions): {
21
+ getCtx: () => TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>;
22
+ restoreCtx: () => _wooksjs_event_core.TGenericContextStore<TEmpty>;
23
+ clearCtx: () => null;
24
+ store: <K extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData>>(key: K) => {
25
+ value: (TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K];
26
+ hook: <K2 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2) => {
27
+ value: Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K][K2];
28
+ isDefined: boolean;
29
+ };
30
+ init: <K2_1 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_1, getter: () => Required<Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>[K2_1]) => Required<Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>[K2_1];
31
+ set: <K2_2 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_2, v: Required<(TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K]>[K2_2]) => Required<(TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K]>[K2_2];
32
+ get: <K2_3 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_3) => Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K][K2_3];
33
+ has: <K2_4 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_4) => boolean;
34
+ del: <K2_5 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_5) => void;
35
+ entries: () => [string, unknown][];
36
+ clear: () => void;
37
+ };
38
+ getStore: <K_1 extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData>>(key: K_1) => (TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K_1];
39
+ setStore: <K_2 extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData>>(key: K_2, v: (TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K_2]) => void;
40
+ };
41
+ declare function resumeWfContext(data: Omit<TWFEventData, 'type'>, options: TEventOptions): {
42
+ getCtx: () => TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>;
43
+ restoreCtx: () => _wooksjs_event_core.TGenericContextStore<TEmpty>;
44
+ clearCtx: () => null;
45
+ store: <K extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData>>(key: K) => {
46
+ value: (TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K];
47
+ hook: <K2 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2) => {
48
+ value: Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K][K2];
49
+ isDefined: boolean;
50
+ };
51
+ init: <K2_1 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_1, getter: () => Required<Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>[K2_1]) => Required<Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>[K2_1];
52
+ set: <K2_2 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_2, v: Required<(TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K]>[K2_2]) => Required<(TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K]>[K2_2];
53
+ get: <K2_3 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_3) => Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K][K2_3];
54
+ has: <K2_4 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_4) => boolean;
55
+ del: <K2_5 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_5) => void;
56
+ entries: () => [string, unknown][];
57
+ clear: () => void;
58
+ };
59
+ getStore: <K_1 extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData>>(key: K_1) => (TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K_1];
60
+ setStore: <K_2 extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData>>(key: K_2, v: (TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K_2]) => void;
61
+ };
62
+ /**
63
+ * Wrapper on top of useEventContext that provides
64
+ * proper context types for WF event
65
+ * @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
66
+ */
67
+ declare function useWFContext<T extends TEmpty>(): {
68
+ getCtx: () => TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>;
69
+ restoreCtx: () => _wooksjs_event_core.TGenericContextStore<TEmpty>;
70
+ clearCtx: () => null;
71
+ store: <K extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData> | keyof T>(key: K) => {
72
+ value: (TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K];
73
+ hook: <K2 extends keyof Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2) => {
74
+ value: Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K][K2];
75
+ isDefined: boolean;
76
+ };
77
+ init: <K2_1 extends keyof Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_1, getter: () => Required<Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>[K2_1]) => Required<Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>[K2_1];
78
+ set: <K2_2 extends keyof Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_2, v: Required<(TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K]>[K2_2]) => Required<(TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K]>[K2_2];
79
+ get: <K2_3 extends keyof Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_3) => Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K][K2_3];
80
+ has: <K2_4 extends keyof Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_4) => boolean;
81
+ del: <K2_5 extends keyof Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2_5) => void;
82
+ entries: () => [string, unknown][];
83
+ clear: () => void;
84
+ };
85
+ getStore: <K_1 extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData> | keyof T>(key: K_1) => (TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K_1];
86
+ setStore: <K_2 extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData> | keyof T>(key: K_2, v: (TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K_2]) => void;
87
+ };
88
+
89
+ declare class WooksWorkflow<T> extends Workflow<T> {
90
+ protected wooks: Wooks;
91
+ constructor(wooks: Wooks);
92
+ protected resolveStep<I, D>(stepId: string): Step<T, I, D>;
93
+ }
94
+
95
+ declare const wfShortcuts: {
96
+ flow: string;
97
+ step: string;
98
+ };
99
+ interface TWooksWfOptions {
100
+ onError?(e: Error): void;
101
+ onNotFound?: TWooksHandler<unknown>;
102
+ onUnknownFlow?: (schemaId: string, raiseError: () => void) => unknown;
103
+ logger?: TConsoleBase;
104
+ eventOptions?: TEventOptions;
105
+ router?: TWooksOptions['router'];
106
+ }
107
+ declare class WooksWf<T> extends WooksAdapterBase {
108
+ protected opts?: TWooksWfOptions | undefined;
109
+ protected logger: TConsoleBase;
110
+ protected wf: WooksWorkflow<T>;
111
+ constructor(opts?: TWooksWfOptions | undefined, wooks?: Wooks | WooksAdapterBase);
112
+ attachSpy<I>(fn: TWorkflowSpy<T, I>): () => void;
113
+ detachSpy<I>(fn: TWorkflowSpy<T, I>): void;
114
+ step<I = any, D = any>(id: string, opts: {
115
+ input?: D;
116
+ handler: string | TStepHandler<T, I, D>;
117
+ }): _prostojs_router.TProstoRouterPathHandle<Record<string, string | string[]>>;
118
+ flow(id: string, schema: TWorkflowSchema<T>, init?: () => void | Promise<void>): _prostojs_router.TProstoRouterPathHandle<Record<string, string | string[]>>;
119
+ start<I>(schemaId: string, inputContext: T, input?: I, spy?: TWorkflowSpy<T, I>, cleanup?: () => void): Promise<TFlowOutput<T, I>>;
120
+ resume<I>(schemaId: string, state: {
121
+ indexes: number[];
122
+ context: T;
123
+ }, input?: I, spy?: TWorkflowSpy<T, I>, cleanup?: () => void): Promise<TFlowOutput<T, I>>;
124
+ protected _start<I>(schemaId: string, inputContext: T, indexes?: number[], input?: I, spy?: TWorkflowSpy<T, I>, cleanup?: () => void): Promise<TFlowOutput<T, I>>;
125
+ protected onError(e: Error): void;
126
+ protected error(e: string | Error): void;
127
+ }
128
+ /**
129
+ * Factory for WooksWf App
130
+ * @param opts TWooksWfOptions
131
+ * @param wooks Wooks | WooksAdapterBase
132
+ * @returns WooksWf
133
+ */
134
+ declare function createWfApp<T>(opts?: TWooksWfOptions, wooks?: Wooks | WooksAdapterBase): WooksWf<T>;
135
+
136
+ declare function useWfState(): {
137
+ ctx: <T>() => T;
138
+ input: <I>() => I | undefined;
139
+ schemaId: string;
140
+ indexes: () => number[] | undefined;
141
+ resume: boolean;
142
+ };
143
+
144
+ export { type TWFContextStore, type TWFEventData, type TWooksWfOptions, WooksWf, createWfApp, createWfContext, resumeWfContext, useWFContext, useWfState, wfShortcuts };
package/dist/index.mjs CHANGED
@@ -22,11 +22,6 @@ function resumeWfContext(data, options) {
22
22
  options,
23
23
  });
24
24
  }
25
- /**
26
- * Wrapper on top of useEventContext that provides
27
- * proper context types for WF event
28
- * @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
29
- */
30
25
  function useWFContext() {
31
26
  return useEventContext('WF');
32
27
  }
@@ -106,7 +101,6 @@ class WooksWf extends WooksAdapterBase {
106
101
  spy(...args);
107
102
  }
108
103
  if (firstStep && args[0] === 'step') {
109
- // cleanup input after the first step
110
104
  firstStep = false;
111
105
  restoreCtx();
112
106
  const { store } = useWFContext();
@@ -168,12 +162,6 @@ class WooksWf extends WooksAdapterBase {
168
162
  }
169
163
  }
170
164
  }
171
- /**
172
- * Factory for WooksWf App
173
- * @param opts TWooksWfOptions
174
- * @param wooks Wooks | WooksAdapterBase
175
- * @returns WooksWf
176
- */
177
165
  function createWfApp(opts, wooks) {
178
166
  return new WooksWf(opts, wooks);
179
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooksjs/event-wf",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "description": "@wooksjs/event-wf",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -8,6 +8,14 @@
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
+ "exports": {
12
+ "./package.json": "./package.json",
13
+ ".": {
14
+ "require": "./dist/index.cjs",
15
+ "import": "./dist/index.mjs",
16
+ "types": "./dist/index.d.ts"
17
+ }
18
+ },
11
19
  "repository": {
12
20
  "type": "git",
13
21
  "url": "git+https://github.com/wooksjs/wooksjs.git",
@@ -25,11 +33,11 @@
25
33
  "author": "Artem Maltsev",
26
34
  "license": "MIT",
27
35
  "peerDependencies": {
28
- "wooks": "0.4.11",
29
- "@wooksjs/event-core": "0.4.11"
36
+ "wooks": "0.4.12",
37
+ "@wooksjs/event-core": "0.4.12"
30
38
  },
31
39
  "dependencies": {
32
- "@prostojs/logger": "^0.3.7",
40
+ "@prostojs/logger": "^0.4.0",
33
41
  "@prostojs/wf": "^0.0.10"
34
42
  },
35
43
  "bugs": {