@moostjs/event-wf 0.2.35 → 0.2.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
@@ -41,6 +41,7 @@ const CONTEXT_TYPE = 'WF';
41
41
  class MoostWf {
42
42
  constructor(opts) {
43
43
  this.opts = opts;
44
+ this.toInit = [];
44
45
  const wfAppOpts = opts === null || opts === void 0 ? void 0 : opts.wooksWf;
45
46
  if (wfAppOpts && wfAppOpts instanceof eventWf.WooksWf) {
46
47
  this.wfApp = wfAppOpts;
@@ -70,6 +71,7 @@ class MoostWf {
70
71
  }
71
72
  onInit(moost) {
72
73
  this.moost = moost;
74
+ this.toInit.forEach(fn => fn());
73
75
  }
74
76
  start(schemaId, inputContext, input) {
75
77
  return this.wfApp.start(schemaId, inputContext, input, () => {
@@ -107,11 +109,11 @@ class MoostWf {
107
109
  manualUnscope: true,
108
110
  });
109
111
  }
110
- let routerBinding;
111
112
  if (handler.type === 'WF_STEP') {
112
- routerBinding = this.wfApp.step(targetPath, {
113
+ this.wfApp.step(targetPath, {
113
114
  handler: fn,
114
115
  });
116
+ opts.logHandler(`${''}(${handler.type})${''}${targetPath}`);
115
117
  }
116
118
  else {
117
119
  const mate = getWfMate();
@@ -119,13 +121,12 @@ class MoostWf {
119
121
  if (!wfSchema) {
120
122
  wfSchema = (_b = mate.read(opts.fakeInstance)) === null || _b === void 0 ? void 0 : _b.wfSchema;
121
123
  }
122
- routerBinding = this.wfApp.flow(targetPath, wfSchema || []);
124
+ const _fn = fn;
125
+ this.toInit.push(() => {
126
+ this.wfApp.flow(targetPath, wfSchema || [], _fn);
127
+ opts.logHandler(`${''}(${handler.type})${''}${targetPath}`);
128
+ });
123
129
  }
124
- opts.logHandler(`${''}(${handler.type})${''}${targetPath}`);
125
- const args = routerBinding.getArgs();
126
- const params = {};
127
- args.forEach(a => params[a] = `{${a}}`);
128
- opts.register(handler, routerBinding.getPath(params), args);
129
130
  }
130
131
  }
131
132
  }
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare class MoostWf<T> implements TMoostAdapter<TWfHandlerMeta> {
13
13
  constructor(opts?: TMoostWfOpts<T> | undefined);
14
14
  onNotFound(): Promise<unknown>;
15
15
  protected moost?: Moost;
16
+ protected toInit: (() => void)[];
16
17
  onInit(moost: Moost): void;
17
18
  start<I>(schemaId: string, inputContext: T, input?: I): Promise<TFlowOutput<T, I>>;
18
19
  resume<I>(schemaId: string, inputContext: T, indexes: number[], input?: I): Promise<TFlowOutput<T, I>>;
@@ -36,11 +37,11 @@ export declare interface TWfHandlerMeta {
36
37
 
37
38
  export { useCliContext }
38
39
 
39
- export declare const WfCtx: (name: string) => ParameterDecorator & PropertyDecorator;
40
+ export declare const WfCtx: (name?: string) => ParameterDecorator & PropertyDecorator;
40
41
 
41
42
  export declare const WfIndexes: () => ParameterDecorator & PropertyDecorator;
42
43
 
43
- export declare const WfInput: (name: string) => ParameterDecorator & PropertyDecorator;
44
+ export declare const WfInput: (name?: string) => ParameterDecorator & PropertyDecorator;
44
45
 
45
46
  export declare function WFlow(path?: string): MethodDecorator;
46
47
 
package/dist/index.mjs CHANGED
@@ -39,6 +39,7 @@ const CONTEXT_TYPE = 'WF';
39
39
  class MoostWf {
40
40
  constructor(opts) {
41
41
  this.opts = opts;
42
+ this.toInit = [];
42
43
  const wfAppOpts = opts === null || opts === void 0 ? void 0 : opts.wooksWf;
43
44
  if (wfAppOpts && wfAppOpts instanceof WooksWf) {
44
45
  this.wfApp = wfAppOpts;
@@ -68,6 +69,7 @@ class MoostWf {
68
69
  }
69
70
  onInit(moost) {
70
71
  this.moost = moost;
72
+ this.toInit.forEach(fn => fn());
71
73
  }
72
74
  start(schemaId, inputContext, input) {
73
75
  return this.wfApp.start(schemaId, inputContext, input, () => {
@@ -105,11 +107,11 @@ class MoostWf {
105
107
  manualUnscope: true,
106
108
  });
107
109
  }
108
- let routerBinding;
109
110
  if (handler.type === 'WF_STEP') {
110
- routerBinding = this.wfApp.step(targetPath, {
111
+ this.wfApp.step(targetPath, {
111
112
  handler: fn,
112
113
  });
114
+ opts.logHandler(`${''}(${handler.type})${''}${targetPath}`);
113
115
  }
114
116
  else {
115
117
  const mate = getWfMate();
@@ -117,13 +119,12 @@ class MoostWf {
117
119
  if (!wfSchema) {
118
120
  wfSchema = (_b = mate.read(opts.fakeInstance)) === null || _b === void 0 ? void 0 : _b.wfSchema;
119
121
  }
120
- routerBinding = this.wfApp.flow(targetPath, wfSchema || []);
122
+ const _fn = fn;
123
+ this.toInit.push(() => {
124
+ this.wfApp.flow(targetPath, wfSchema || [], _fn);
125
+ opts.logHandler(`${''}(${handler.type})${''}${targetPath}`);
126
+ });
121
127
  }
122
- opts.logHandler(`${''}(${handler.type})${''}${targetPath}`);
123
- const args = routerBinding.getArgs();
124
- const params = {};
125
- args.forEach(a => params[a] = `{${a}}`);
126
- opts.register(handler, routerBinding.getPath(params), args);
127
128
  }
128
129
  }
129
130
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/event-wf",
3
- "version": "0.2.35",
3
+ "version": "0.2.36",
4
4
  "description": "@moostjs/event-wf",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -36,10 +36,10 @@
36
36
  },
37
37
  "peerDependencies": {},
38
38
  "dependencies": {
39
- "moost": "0.2.35",
40
- "wooks": "^0.3.11",
41
- "@wooksjs/event-core": "^0.3.11",
42
- "@wooksjs/event-wf": "^0.3.11"
39
+ "moost": "0.2.36",
40
+ "wooks": "^0.3.12",
41
+ "@wooksjs/event-core": "^0.3.12",
42
+ "@wooksjs/event-wf": "^0.3.12"
43
43
  },
44
44
  "homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-wf#readme"
45
45
  }