@wooksjs/event-wf 0.4.15 → 0.4.17

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
@@ -34,16 +34,17 @@ class WooksWorkflow extends wf.Workflow {
34
34
  this.wooks = wooks;
35
35
  }
36
36
  resolveStep(stepId) {
37
+ const stepIdNorm = stepId[0] === '/' ? stepId : '/' + stepId;
37
38
  try {
38
39
  useWFContext();
39
- const found = this.wooks.lookup('WF_STEP', '/' + stepId);
40
+ const found = this.wooks.lookup('WF_STEP', stepIdNorm);
40
41
  if (found?.handlers?.length) {
41
42
  return found.handlers[0]();
42
43
  }
43
44
  }
44
45
  catch (e) {
45
46
  const router = this.wooks.getRouter();
46
- const found = router.lookup('WF_STEP', '/' + stepId);
47
+ const found = router.lookup('WF_STEP', stepIdNorm);
47
48
  if (found?.route?.handlers?.length) {
48
49
  return found.route.handlers[0]();
49
50
  }
@@ -80,8 +81,8 @@ class WooksWf extends wooks.WooksAdapterBase {
80
81
  start(schemaId, inputContext, input, spy, cleanup) {
81
82
  return this._start(schemaId, inputContext, undefined, input, spy, cleanup);
82
83
  }
83
- resume(schemaId, state, input, spy, cleanup) {
84
- return this._start(schemaId, state.context, state.indexes, input, spy, cleanup);
84
+ resume(state, input, spy, cleanup) {
85
+ return this._start(state.schemaId, state.context, state.indexes, input, spy, cleanup);
85
86
  }
86
87
  async _start(schemaId, inputContext, indexes, input, spy, cleanup) {
87
88
  const resume = !!indexes?.length;
@@ -119,7 +120,7 @@ class WooksWf extends wooks.WooksAdapterBase {
119
120
  }
120
121
  restoreCtx();
121
122
  if (resume) {
122
- result = await this.wf.resume(id, { context: inputContext, indexes }, input, _spy);
123
+ result = await this.wf.resume({ schemaId: id, context: inputContext, indexes }, input, _spy);
123
124
  break;
124
125
  }
125
126
  else {
package/dist/index.d.ts CHANGED
@@ -117,7 +117,8 @@ declare class WooksWf<T> extends WooksAdapterBase {
117
117
  }): _prostojs_router.TProstoRouterPathHandle<Record<string, string | string[]>>;
118
118
  flow(id: string, schema: TWorkflowSchema<T>, prefix?: string, init?: () => void | Promise<void>): _prostojs_router.TProstoRouterPathHandle<Record<string, string | string[]>>;
119
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: {
120
+ resume<I>(state: {
121
+ schemaId: string;
121
122
  indexes: number[];
122
123
  context: T;
123
124
  }, input?: I, spy?: TWorkflowSpy<T, I>, cleanup?: () => void): Promise<TFlowOutput<T, I>>;
package/dist/index.mjs CHANGED
@@ -32,16 +32,17 @@ class WooksWorkflow extends Workflow {
32
32
  this.wooks = wooks;
33
33
  }
34
34
  resolveStep(stepId) {
35
+ const stepIdNorm = stepId[0] === '/' ? stepId : '/' + stepId;
35
36
  try {
36
37
  useWFContext();
37
- const found = this.wooks.lookup('WF_STEP', '/' + stepId);
38
+ const found = this.wooks.lookup('WF_STEP', stepIdNorm);
38
39
  if (found?.handlers?.length) {
39
40
  return found.handlers[0]();
40
41
  }
41
42
  }
42
43
  catch (e) {
43
44
  const router = this.wooks.getRouter();
44
- const found = router.lookup('WF_STEP', '/' + stepId);
45
+ const found = router.lookup('WF_STEP', stepIdNorm);
45
46
  if (found?.route?.handlers?.length) {
46
47
  return found.route.handlers[0]();
47
48
  }
@@ -78,8 +79,8 @@ class WooksWf extends WooksAdapterBase {
78
79
  start(schemaId, inputContext, input, spy, cleanup) {
79
80
  return this._start(schemaId, inputContext, undefined, input, spy, cleanup);
80
81
  }
81
- resume(schemaId, state, input, spy, cleanup) {
82
- return this._start(schemaId, state.context, state.indexes, input, spy, cleanup);
82
+ resume(state, input, spy, cleanup) {
83
+ return this._start(state.schemaId, state.context, state.indexes, input, spy, cleanup);
83
84
  }
84
85
  async _start(schemaId, inputContext, indexes, input, spy, cleanup) {
85
86
  const resume = !!indexes?.length;
@@ -117,7 +118,7 @@ class WooksWf extends WooksAdapterBase {
117
118
  }
118
119
  restoreCtx();
119
120
  if (resume) {
120
- result = await this.wf.resume(id, { context: inputContext, indexes }, input, _spy);
121
+ result = await this.wf.resume({ schemaId: id, context: inputContext, indexes }, input, _spy);
121
122
  break;
122
123
  }
123
124
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooksjs/event-wf",
3
- "version": "0.4.15",
3
+ "version": "0.4.17",
4
4
  "description": "@wooksjs/event-wf",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -33,12 +33,12 @@
33
33
  "author": "Artem Maltsev",
34
34
  "license": "MIT",
35
35
  "peerDependencies": {
36
- "wooks": "0.4.15",
37
- "@wooksjs/event-core": "0.4.15"
36
+ "wooks": "0.4.17",
37
+ "@wooksjs/event-core": "0.4.17"
38
38
  },
39
39
  "dependencies": {
40
40
  "@prostojs/logger": "^0.4.0",
41
- "@prostojs/wf": "^0.0.12"
41
+ "@prostojs/wf": "^0.0.14"
42
42
  },
43
43
  "bugs": {
44
44
  "url": "https://github.com/wooksjs/wooksjs/issues"