@moostjs/event-wf 0.3.12 → 0.3.13

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
@@ -12,20 +12,20 @@ function getWfMate() {
12
12
  const LOGGER_TITLE = 'moost-wf';
13
13
  const CONTEXT_TYPE = 'WF';
14
14
  class MoostWf {
15
- constructor(opts) {
15
+ constructor(opts, debug) {
16
16
  this.opts = opts;
17
+ this.debug = debug;
17
18
  this.toInit = [];
18
- const wfAppOpts = opts?.wooksWf;
19
- if (wfAppOpts && wfAppOpts instanceof eventWf.WooksWf) {
20
- this.wfApp = wfAppOpts;
19
+ if (opts && opts instanceof eventWf.WooksWf) {
20
+ this.wfApp = opts;
21
21
  }
22
- else if (wfAppOpts) {
23
- this.wfApp = eventWf.createWfApp(wfAppOpts);
22
+ else if (opts) {
23
+ this.wfApp = eventWf.createWfApp(opts);
24
24
  }
25
25
  else {
26
26
  this.wfApp = eventWf.createWfApp();
27
27
  }
28
- if (!opts?.debug) {
28
+ if (!debug) {
29
29
  moost.getMoostInfact().silent(true);
30
30
  }
31
31
  }
@@ -35,13 +35,13 @@ class MoostWf {
35
35
  getIterceptorHandler: () => this.moost?.getGlobalInterceptorHandler(),
36
36
  getControllerInstance: () => this.moost,
37
37
  callControllerMethod: () => undefined,
38
- logErrors: this.opts?.debug,
38
+ logErrors: this.debug,
39
39
  })();
40
40
  return response;
41
41
  }
42
42
  onInit(moost) {
43
43
  this.moost = moost;
44
- this.toInit.forEach(fn => fn());
44
+ this.toInit.forEach((fn) => fn());
45
45
  }
46
46
  getWfApp() {
47
47
  return this.wfApp;
@@ -67,7 +67,7 @@ class MoostWf {
67
67
  bindHandler(opts) {
68
68
  let fn;
69
69
  for (const handler of opts.handlers) {
70
- if (!(['WF_STEP', 'WF_FLOW'].includes(handler.type)))
70
+ if (!['WF_STEP', 'WF_FLOW'].includes(handler.type))
71
71
  continue;
72
72
  const schemaId = handler.path;
73
73
  const path = typeof schemaId === 'string'
@@ -75,7 +75,8 @@ class MoostWf {
75
75
  : typeof opts.method === 'string'
76
76
  ? opts.method
77
77
  : '';
78
- const targetPath = `${opts.prefix || ''}/${path}`.replace(/\/\/+/g, '/') + `${path.endsWith('//') ? '/' : ''}`;
78
+ const targetPath = `${opts.prefix || ''}/${path}`.replace(/\/\/+/g, '/') +
79
+ `${path.endsWith('//') ? '/' : ''}`;
79
80
  if (!fn) {
80
81
  fn = moost.defineMoostEventHandler({
81
82
  contextType: CONTEXT_TYPE,
@@ -101,7 +102,7 @@ class MoostWf {
101
102
  }
102
103
  const _fn = fn;
103
104
  this.toInit.push(() => {
104
- this.wfApp.flow(targetPath, wfSchema || [], _fn);
105
+ this.wfApp.flow(targetPath, wfSchema || [], opts.prefix, _fn);
105
106
  opts.logHandler(`${''}(${handler.type})${''}${targetPath}`);
106
107
  });
107
108
  }
package/dist/index.d.ts CHANGED
@@ -7,20 +7,11 @@ export { StepRetriableError, TFlowOutput, TWorkflowSchema } from '@prostojs/wf';
7
7
  interface TWfHandlerMeta {
8
8
  path: string;
9
9
  }
10
- interface TMoostWfOpts<T> {
11
- /**
12
- * wooksWf options or instance
13
- */
14
- wooksWf?: WooksWf<T> | TWooksWfOptions;
15
- /**
16
- * more internal logs are printed when true
17
- */
18
- debug?: boolean;
19
- }
20
10
  declare class MoostWf<T> implements TMoostAdapter<TWfHandlerMeta> {
21
- protected opts?: TMoostWfOpts<T> | undefined;
11
+ protected opts?: WooksWf<T> | TWooksWfOptions | undefined;
12
+ private readonly debug?;
22
13
  protected wfApp: WooksWf<T>;
23
- constructor(opts?: TMoostWfOpts<T> | undefined);
14
+ constructor(opts?: WooksWf<T> | TWooksWfOptions | undefined, debug?: boolean | undefined);
24
15
  onNotFound(): Promise<unknown>;
25
16
  protected moost?: Moost;
26
17
  protected toInit: (() => void)[];
@@ -45,4 +36,4 @@ declare const WfIndexes: () => ParameterDecorator & PropertyDecorator;
45
36
  declare const WfSchemaId: () => ParameterDecorator & PropertyDecorator;
46
37
  declare const WfInput: (name?: string) => ParameterDecorator & PropertyDecorator;
47
38
 
48
- export { MoostWf, type TMoostWfOpts, type TWfHandlerMeta, WFlow, WSchema, WStep, WfCtx, WfIndexes, WfInput, WfResume, WfSchemaId };
39
+ export { MoostWf, type TWfHandlerMeta, WFlow, WSchema, WStep, WfCtx, WfIndexes, WfInput, WfResume, WfSchemaId };
package/dist/index.mjs CHANGED
@@ -11,20 +11,20 @@ function getWfMate() {
11
11
  const LOGGER_TITLE = 'moost-wf';
12
12
  const CONTEXT_TYPE = 'WF';
13
13
  class MoostWf {
14
- constructor(opts) {
14
+ constructor(opts, debug) {
15
15
  this.opts = opts;
16
+ this.debug = debug;
16
17
  this.toInit = [];
17
- const wfAppOpts = opts?.wooksWf;
18
- if (wfAppOpts && wfAppOpts instanceof WooksWf) {
19
- this.wfApp = wfAppOpts;
18
+ if (opts && opts instanceof WooksWf) {
19
+ this.wfApp = opts;
20
20
  }
21
- else if (wfAppOpts) {
22
- this.wfApp = createWfApp(wfAppOpts);
21
+ else if (opts) {
22
+ this.wfApp = createWfApp(opts);
23
23
  }
24
24
  else {
25
25
  this.wfApp = createWfApp();
26
26
  }
27
- if (!opts?.debug) {
27
+ if (!debug) {
28
28
  getMoostInfact().silent(true);
29
29
  }
30
30
  }
@@ -34,13 +34,13 @@ class MoostWf {
34
34
  getIterceptorHandler: () => this.moost?.getGlobalInterceptorHandler(),
35
35
  getControllerInstance: () => this.moost,
36
36
  callControllerMethod: () => undefined,
37
- logErrors: this.opts?.debug,
37
+ logErrors: this.debug,
38
38
  })();
39
39
  return response;
40
40
  }
41
41
  onInit(moost) {
42
42
  this.moost = moost;
43
- this.toInit.forEach(fn => fn());
43
+ this.toInit.forEach((fn) => fn());
44
44
  }
45
45
  getWfApp() {
46
46
  return this.wfApp;
@@ -66,7 +66,7 @@ class MoostWf {
66
66
  bindHandler(opts) {
67
67
  let fn;
68
68
  for (const handler of opts.handlers) {
69
- if (!(['WF_STEP', 'WF_FLOW'].includes(handler.type)))
69
+ if (!['WF_STEP', 'WF_FLOW'].includes(handler.type))
70
70
  continue;
71
71
  const schemaId = handler.path;
72
72
  const path = typeof schemaId === 'string'
@@ -74,7 +74,8 @@ class MoostWf {
74
74
  : typeof opts.method === 'string'
75
75
  ? opts.method
76
76
  : '';
77
- const targetPath = `${opts.prefix || ''}/${path}`.replace(/\/\/+/g, '/') + `${path.endsWith('//') ? '/' : ''}`;
77
+ const targetPath = `${opts.prefix || ''}/${path}`.replace(/\/\/+/g, '/') +
78
+ `${path.endsWith('//') ? '/' : ''}`;
78
79
  if (!fn) {
79
80
  fn = defineMoostEventHandler({
80
81
  contextType: CONTEXT_TYPE,
@@ -100,7 +101,7 @@ class MoostWf {
100
101
  }
101
102
  const _fn = fn;
102
103
  this.toInit.push(() => {
103
- this.wfApp.flow(targetPath, wfSchema || [], _fn);
104
+ this.wfApp.flow(targetPath, wfSchema || [], opts.prefix, _fn);
104
105
  opts.logHandler(`${''}(${handler.type})${''}${targetPath}`);
105
106
  });
106
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/event-wf",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "@moostjs/event-wf",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -37,13 +37,13 @@
37
37
  },
38
38
  "peerDependencies": {},
39
39
  "dependencies": {
40
- "moost": "0.3.12",
41
- "wooks": "^0.4.13",
42
- "@wooksjs/event-core": "^0.4.13",
43
- "@wooksjs/event-wf": "^0.4.13",
40
+ "moost": "0.3.13",
41
+ "wooks": "^0.4.15",
42
+ "@wooksjs/event-core": "^0.4.15",
43
+ "@wooksjs/event-wf": "^0.4.15",
44
44
  "@prostojs/infact": "^0.1.13",
45
45
  "@prostojs/mate": "^0.2.1",
46
- "@prostojs/wf": "^0.0.10"
46
+ "@prostojs/wf": "^0.0.12"
47
47
  },
48
48
  "homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-wf#readme"
49
49
  }