@wooksjs/event-wf 0.4.34 → 0.4.36

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
@@ -103,7 +103,7 @@ class WooksWf extends wooks.WooksAdapterBase {
103
103
  }
104
104
  async _start(schemaId, inputContext, indexes, input, spy, cleanup) {
105
105
  const resume = !!indexes?.length;
106
- const { restoreCtx, clearCtx } = (resume ? resumeWfContext : createWfContext)({
106
+ const { restoreCtx, endEvent } = (resume ? resumeWfContext : createWfContext)({
107
107
  inputContext,
108
108
  schemaId,
109
109
  stepId: null,
@@ -150,18 +150,18 @@ class WooksWf extends wooks.WooksAdapterBase {
150
150
  throw error;
151
151
  }
152
152
  clean();
153
- clearCtx();
153
+ endEvent();
154
154
  return result;
155
155
  }
156
156
  clean();
157
+ endEvent(`Unknown schemaId: ${schemaId}`);
158
+ throw new Error(`Unknown schemaId: ${schemaId}`);
157
159
  function clean() {
158
160
  if (cleanup) {
159
161
  restoreCtx();
160
162
  cleanup();
161
163
  }
162
164
  }
163
- clearCtx();
164
- throw new Error(`Unknown schemaId: ${schemaId}`);
165
165
  }
166
166
  onError(e) {
167
167
  if (this.opts?.onError) {
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ declare function createWfContext(data: Omit<TWFEventData, 'type'>, options: TEve
31
31
  getCtx: () => TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>;
32
32
  restoreCtx: () => _wooksjs_event_core.TGenericContextStore<TEmpty>;
33
33
  clearCtx: () => null;
34
+ endEvent: (abortReason?: string | undefined) => void;
34
35
  store: <K extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData>>(key: K) => {
35
36
  value: (TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K];
36
37
  hook: <K2 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2) => {
@@ -54,6 +55,7 @@ declare function resumeWfContext(data: Omit<TWFEventData, 'type'>, options: TEve
54
55
  getCtx: () => TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>;
55
56
  restoreCtx: () => _wooksjs_event_core.TGenericContextStore<TEmpty>;
56
57
  clearCtx: () => null;
58
+ endEvent: (abortReason?: string | undefined) => void;
57
59
  store: <K extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData>>(key: K) => {
58
60
  value: (TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K];
59
61
  hook: <K2 extends keyof Required<TWFContextStore & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2) => {
@@ -82,6 +84,7 @@ declare function useWFContext<T extends TEmpty>(): {
82
84
  getCtx: () => TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>;
83
85
  restoreCtx: () => _wooksjs_event_core.TGenericContextStore<TEmpty>;
84
86
  clearCtx: () => null;
87
+ endEvent: (abortReason?: string | undefined) => void;
85
88
  store: <K extends "resume" | keyof _wooksjs_event_core.TGenericContextStore<TWFEventData> | keyof T>(key: K) => {
86
89
  value: (TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>)[K];
87
90
  hook: <K2 extends keyof Required<TWFContextStore & T & _wooksjs_event_core.TGenericContextStore<TWFEventData>>[K]>(key2: K2) => {
package/dist/index.mjs CHANGED
@@ -101,7 +101,7 @@ class WooksWf extends WooksAdapterBase {
101
101
  }
102
102
  async _start(schemaId, inputContext, indexes, input, spy, cleanup) {
103
103
  const resume = !!indexes?.length;
104
- const { restoreCtx, clearCtx } = (resume ? resumeWfContext : createWfContext)({
104
+ const { restoreCtx, endEvent } = (resume ? resumeWfContext : createWfContext)({
105
105
  inputContext,
106
106
  schemaId,
107
107
  stepId: null,
@@ -148,18 +148,18 @@ class WooksWf extends WooksAdapterBase {
148
148
  throw error;
149
149
  }
150
150
  clean();
151
- clearCtx();
151
+ endEvent();
152
152
  return result;
153
153
  }
154
154
  clean();
155
+ endEvent(`Unknown schemaId: ${schemaId}`);
156
+ throw new Error(`Unknown schemaId: ${schemaId}`);
155
157
  function clean() {
156
158
  if (cleanup) {
157
159
  restoreCtx();
158
160
  cleanup();
159
161
  }
160
162
  }
161
- clearCtx();
162
- throw new Error(`Unknown schemaId: ${schemaId}`);
163
163
  }
164
164
  onError(e) {
165
165
  if (this.opts?.onError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooksjs/event-wf",
3
- "version": "0.4.34",
3
+ "version": "0.4.36",
4
4
  "description": "@wooksjs/event-wf",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -33,8 +33,8 @@
33
33
  "author": "Artem Maltsev",
34
34
  "license": "MIT",
35
35
  "peerDependencies": {
36
- "wooks": "0.4.34",
37
- "@wooksjs/event-core": "0.4.34"
36
+ "wooks": "0.4.36",
37
+ "@wooksjs/event-core": "0.4.36"
38
38
  },
39
39
  "dependencies": {
40
40
  "@prostojs/logger": "^0.4.0",