@moostjs/event-wf 0.3.23 → 0.3.24
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/README.md +1 -1
- package/dist/index.cjs +45 -38
- package/dist/index.d.ts +9 -9
- package/dist/index.mjs +40 -33
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# @moostjs/event-wf
|
|
1
|
+
# @moostjs/event-wf
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var moost = require('moost');
|
|
4
3
|
var eventWf = require('@wooksjs/event-wf');
|
|
4
|
+
var moost = require('moost');
|
|
5
5
|
var eventCore = require('@wooksjs/event-core');
|
|
6
6
|
var wf = require('@prostojs/wf');
|
|
7
7
|
|
|
@@ -9,6 +9,35 @@ function getWfMate() {
|
|
|
9
9
|
return moost.getMoostMate();
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
function Step(path) {
|
|
13
|
+
return getWfMate().decorate('handlers', { path, type: 'WF_STEP' }, true);
|
|
14
|
+
}
|
|
15
|
+
function Workflow(path) {
|
|
16
|
+
return getWfMate().decorate('handlers', { path, type: 'WF_FLOW' }, true);
|
|
17
|
+
}
|
|
18
|
+
function WorkflowSchema(schema) {
|
|
19
|
+
return getWfMate().decorate('wfSchema', schema);
|
|
20
|
+
}
|
|
21
|
+
const WorkflowParam = (name) => {
|
|
22
|
+
switch (name) {
|
|
23
|
+
case 'resume': {
|
|
24
|
+
return moost.Resolve(() => eventWf.useWfState().resume, 'Workflow-Resume');
|
|
25
|
+
}
|
|
26
|
+
case 'indexes': {
|
|
27
|
+
return moost.Resolve(() => eventWf.useWfState().indexes, 'Workflow-Indexes');
|
|
28
|
+
}
|
|
29
|
+
case 'schemaId': {
|
|
30
|
+
return moost.Resolve(() => eventWf.useWfState().schemaId, 'Workflow-SchemaId');
|
|
31
|
+
}
|
|
32
|
+
case 'context': {
|
|
33
|
+
return moost.Resolve(() => eventWf.useWfState().ctx(), 'Workflow-Context');
|
|
34
|
+
}
|
|
35
|
+
case 'input': {
|
|
36
|
+
return moost.Resolve(() => eventWf.useWfState().input(), 'Workflow-Input');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
12
41
|
const LOGGER_TITLE = 'moost-wf';
|
|
13
42
|
const CONTEXT_TYPE = 'WF';
|
|
14
43
|
class MoostWf {
|
|
@@ -30,18 +59,19 @@ class MoostWf {
|
|
|
30
59
|
}
|
|
31
60
|
}
|
|
32
61
|
async onNotFound() {
|
|
33
|
-
|
|
62
|
+
return moost.defineMoostEventHandler({
|
|
34
63
|
loggerTitle: LOGGER_TITLE,
|
|
35
64
|
getIterceptorHandler: () => this.moost?.getGlobalInterceptorHandler(),
|
|
36
65
|
getControllerInstance: () => this.moost,
|
|
37
66
|
callControllerMethod: () => undefined,
|
|
38
67
|
logErrors: this.debug,
|
|
39
68
|
})();
|
|
40
|
-
return response;
|
|
41
69
|
}
|
|
42
70
|
onInit(moost) {
|
|
43
71
|
this.moost = moost;
|
|
44
|
-
this.toInit.forEach(
|
|
72
|
+
this.toInit.forEach(fn => {
|
|
73
|
+
fn();
|
|
74
|
+
});
|
|
45
75
|
}
|
|
46
76
|
getWfApp() {
|
|
47
77
|
return this.wfApp;
|
|
@@ -50,7 +80,7 @@ class MoostWf {
|
|
|
50
80
|
return this.wfApp.attachSpy(fn);
|
|
51
81
|
}
|
|
52
82
|
detachSpy(fn) {
|
|
53
|
-
|
|
83
|
+
this.wfApp.detachSpy(fn);
|
|
54
84
|
}
|
|
55
85
|
start(schemaId, initialContext, input) {
|
|
56
86
|
return this.wfApp.start(schemaId, initialContext, input, () => { }, () => {
|
|
@@ -67,16 +97,12 @@ class MoostWf {
|
|
|
67
97
|
bindHandler(opts) {
|
|
68
98
|
let fn;
|
|
69
99
|
for (const handler of opts.handlers) {
|
|
70
|
-
if (!['WF_STEP', 'WF_FLOW'].includes(handler.type))
|
|
100
|
+
if (!['WF_STEP', 'WF_FLOW'].includes(handler.type)) {
|
|
71
101
|
continue;
|
|
102
|
+
}
|
|
72
103
|
const schemaId = handler.path;
|
|
73
|
-
const path = typeof schemaId === 'string'
|
|
74
|
-
|
|
75
|
-
: typeof opts.method === 'string'
|
|
76
|
-
? opts.method
|
|
77
|
-
: '';
|
|
78
|
-
const targetPath = `${opts.prefix || ''}/${path}`.replace(/\/\/+/g, '/') +
|
|
79
|
-
`${path.endsWith('//') ? '/' : ''}`;
|
|
104
|
+
const path = typeof schemaId === 'string' ? schemaId : typeof opts.method === 'string' ? opts.method : '';
|
|
105
|
+
const targetPath = `${`${opts.prefix || ''}/${path}`.replace(/\/\/+/g, '/')}${path.endsWith('//') ? '/' : ''}`;
|
|
80
106
|
if (!fn) {
|
|
81
107
|
fn = moost.defineMoostEventHandler({
|
|
82
108
|
contextType: CONTEXT_TYPE,
|
|
@@ -110,36 +136,17 @@ class MoostWf {
|
|
|
110
136
|
}
|
|
111
137
|
}
|
|
112
138
|
|
|
113
|
-
function Step(path) {
|
|
114
|
-
return getWfMate().decorate('handlers', { path, type: 'WF_STEP' }, true);
|
|
115
|
-
}
|
|
116
|
-
function Workflow(path) {
|
|
117
|
-
return getWfMate().decorate('handlers', { path, type: 'WF_FLOW' }, true);
|
|
118
|
-
}
|
|
119
|
-
function WorkflowSchema(schema) {
|
|
120
|
-
return getWfMate().decorate('wfSchema', schema);
|
|
121
|
-
}
|
|
122
|
-
const WorkflowParam = (name) => {
|
|
123
|
-
switch (name) {
|
|
124
|
-
case 'resume': return moost.Resolve(() => eventWf.useWfState().resume, 'Workflow-Resume');
|
|
125
|
-
case 'indexes': return moost.Resolve(() => eventWf.useWfState().indexes, 'Workflow-Indexes');
|
|
126
|
-
case 'schemaId': return moost.Resolve(() => eventWf.useWfState().schemaId, 'Workflow-SchemaId');
|
|
127
|
-
case 'context': return moost.Resolve(() => eventWf.useWfState().ctx(), 'Workflow-Context');
|
|
128
|
-
case 'input': return moost.Resolve(() => eventWf.useWfState().input(), 'Workflow-Input');
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
139
|
Object.defineProperty(exports, "useWFContext", {
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function () { return eventWf.useWFContext; }
|
|
135
142
|
});
|
|
136
143
|
Object.defineProperty(exports, "useWfState", {
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function () { return eventWf.useWfState; }
|
|
139
146
|
});
|
|
140
147
|
Object.defineProperty(exports, "StepRetriableError", {
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
enumerable: true,
|
|
149
|
+
get: function () { return wf.StepRetriableError; }
|
|
143
150
|
});
|
|
144
151
|
exports.MoostWf = MoostWf;
|
|
145
152
|
exports.Step = Step;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TWorkflowSchema, TWorkflowSpy, TFlowOutput } from '@prostojs/wf';
|
|
2
|
+
export { StepRetriableError, TFlowOutput, TWorkflowSchema } from '@prostojs/wf';
|
|
2
3
|
import { WooksWf, TWooksWfOptions } from '@wooksjs/event-wf';
|
|
3
4
|
export { useWFContext, useWfState } from '@wooksjs/event-wf';
|
|
4
|
-
import {
|
|
5
|
-
|
|
5
|
+
import { TMoostAdapter, Moost, TMoostAdapterOptions } from 'moost';
|
|
6
|
+
|
|
7
|
+
declare function Step(path?: string): MethodDecorator;
|
|
8
|
+
declare function Workflow(path?: string): MethodDecorator;
|
|
9
|
+
declare function WorkflowSchema<T>(schema: TWorkflowSchema<T>): MethodDecorator;
|
|
10
|
+
declare const WorkflowParam: (name: 'resume' | 'indexes' | 'schemaId' | 'context' | 'input') => ParameterDecorator & PropertyDecorator;
|
|
6
11
|
|
|
7
12
|
interface TWfHandlerMeta {
|
|
8
13
|
path: string;
|
|
@@ -14,7 +19,7 @@ declare class MoostWf<T = any, IR = any> implements TMoostAdapter<TWfHandlerMeta
|
|
|
14
19
|
constructor(opts?: WooksWf<T, IR> | TWooksWfOptions | undefined, debug?: boolean | undefined);
|
|
15
20
|
onNotFound(): Promise<unknown>;
|
|
16
21
|
protected moost?: Moost;
|
|
17
|
-
protected toInit: (
|
|
22
|
+
protected toInit: Array<() => void>;
|
|
18
23
|
onInit(moost: Moost): void;
|
|
19
24
|
getWfApp(): WooksWf<T, IR>;
|
|
20
25
|
attachSpy<I>(fn: TWorkflowSpy<T, I, IR>): () => void;
|
|
@@ -28,9 +33,4 @@ declare class MoostWf<T = any, IR = any> implements TMoostAdapter<TWfHandlerMeta
|
|
|
28
33
|
bindHandler<T extends object = object>(opts: TMoostAdapterOptions<TWfHandlerMeta, T>): void;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
declare function Step(path?: string): MethodDecorator;
|
|
32
|
-
declare function Workflow(path?: string): MethodDecorator;
|
|
33
|
-
declare function WorkflowSchema<T>(schema: TWorkflowSchema<T>): MethodDecorator;
|
|
34
|
-
declare const WorkflowParam: (name: 'resume' | 'indexes' | 'schemaId' | 'context' | 'input') => ParameterDecorator & PropertyDecorator;
|
|
35
|
-
|
|
36
36
|
export { MoostWf, Step, type TWfHandlerMeta, Workflow, WorkflowParam, WorkflowSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WooksWf, createWfApp, useWfState } from '@wooksjs/event-wf';
|
|
1
|
+
import { useWfState, WooksWf, createWfApp } from '@wooksjs/event-wf';
|
|
3
2
|
export { useWFContext, useWfState } from '@wooksjs/event-wf';
|
|
3
|
+
import { getMoostMate, Resolve, getMoostInfact, defineMoostEventHandler } from 'moost';
|
|
4
4
|
import { useEventId } from '@wooksjs/event-core';
|
|
5
5
|
export { StepRetriableError } from '@prostojs/wf';
|
|
6
6
|
|
|
@@ -8,6 +8,35 @@ function getWfMate() {
|
|
|
8
8
|
return getMoostMate();
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
function Step(path) {
|
|
12
|
+
return getWfMate().decorate('handlers', { path, type: 'WF_STEP' }, true);
|
|
13
|
+
}
|
|
14
|
+
function Workflow(path) {
|
|
15
|
+
return getWfMate().decorate('handlers', { path, type: 'WF_FLOW' }, true);
|
|
16
|
+
}
|
|
17
|
+
function WorkflowSchema(schema) {
|
|
18
|
+
return getWfMate().decorate('wfSchema', schema);
|
|
19
|
+
}
|
|
20
|
+
const WorkflowParam = (name) => {
|
|
21
|
+
switch (name) {
|
|
22
|
+
case 'resume': {
|
|
23
|
+
return Resolve(() => useWfState().resume, 'Workflow-Resume');
|
|
24
|
+
}
|
|
25
|
+
case 'indexes': {
|
|
26
|
+
return Resolve(() => useWfState().indexes, 'Workflow-Indexes');
|
|
27
|
+
}
|
|
28
|
+
case 'schemaId': {
|
|
29
|
+
return Resolve(() => useWfState().schemaId, 'Workflow-SchemaId');
|
|
30
|
+
}
|
|
31
|
+
case 'context': {
|
|
32
|
+
return Resolve(() => useWfState().ctx(), 'Workflow-Context');
|
|
33
|
+
}
|
|
34
|
+
case 'input': {
|
|
35
|
+
return Resolve(() => useWfState().input(), 'Workflow-Input');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
11
40
|
const LOGGER_TITLE = 'moost-wf';
|
|
12
41
|
const CONTEXT_TYPE = 'WF';
|
|
13
42
|
class MoostWf {
|
|
@@ -29,18 +58,19 @@ class MoostWf {
|
|
|
29
58
|
}
|
|
30
59
|
}
|
|
31
60
|
async onNotFound() {
|
|
32
|
-
|
|
61
|
+
return defineMoostEventHandler({
|
|
33
62
|
loggerTitle: LOGGER_TITLE,
|
|
34
63
|
getIterceptorHandler: () => this.moost?.getGlobalInterceptorHandler(),
|
|
35
64
|
getControllerInstance: () => this.moost,
|
|
36
65
|
callControllerMethod: () => undefined,
|
|
37
66
|
logErrors: this.debug,
|
|
38
67
|
})();
|
|
39
|
-
return response;
|
|
40
68
|
}
|
|
41
69
|
onInit(moost) {
|
|
42
70
|
this.moost = moost;
|
|
43
|
-
this.toInit.forEach(
|
|
71
|
+
this.toInit.forEach(fn => {
|
|
72
|
+
fn();
|
|
73
|
+
});
|
|
44
74
|
}
|
|
45
75
|
getWfApp() {
|
|
46
76
|
return this.wfApp;
|
|
@@ -49,7 +79,7 @@ class MoostWf {
|
|
|
49
79
|
return this.wfApp.attachSpy(fn);
|
|
50
80
|
}
|
|
51
81
|
detachSpy(fn) {
|
|
52
|
-
|
|
82
|
+
this.wfApp.detachSpy(fn);
|
|
53
83
|
}
|
|
54
84
|
start(schemaId, initialContext, input) {
|
|
55
85
|
return this.wfApp.start(schemaId, initialContext, input, () => { }, () => {
|
|
@@ -66,16 +96,12 @@ class MoostWf {
|
|
|
66
96
|
bindHandler(opts) {
|
|
67
97
|
let fn;
|
|
68
98
|
for (const handler of opts.handlers) {
|
|
69
|
-
if (!['WF_STEP', 'WF_FLOW'].includes(handler.type))
|
|
99
|
+
if (!['WF_STEP', 'WF_FLOW'].includes(handler.type)) {
|
|
70
100
|
continue;
|
|
101
|
+
}
|
|
71
102
|
const schemaId = handler.path;
|
|
72
|
-
const path = typeof schemaId === 'string'
|
|
73
|
-
|
|
74
|
-
: typeof opts.method === 'string'
|
|
75
|
-
? opts.method
|
|
76
|
-
: '';
|
|
77
|
-
const targetPath = `${opts.prefix || ''}/${path}`.replace(/\/\/+/g, '/') +
|
|
78
|
-
`${path.endsWith('//') ? '/' : ''}`;
|
|
103
|
+
const path = typeof schemaId === 'string' ? schemaId : typeof opts.method === 'string' ? opts.method : '';
|
|
104
|
+
const targetPath = `${`${opts.prefix || ''}/${path}`.replace(/\/\/+/g, '/')}${path.endsWith('//') ? '/' : ''}`;
|
|
79
105
|
if (!fn) {
|
|
80
106
|
fn = defineMoostEventHandler({
|
|
81
107
|
contextType: CONTEXT_TYPE,
|
|
@@ -109,23 +135,4 @@ class MoostWf {
|
|
|
109
135
|
}
|
|
110
136
|
}
|
|
111
137
|
|
|
112
|
-
function Step(path) {
|
|
113
|
-
return getWfMate().decorate('handlers', { path, type: 'WF_STEP' }, true);
|
|
114
|
-
}
|
|
115
|
-
function Workflow(path) {
|
|
116
|
-
return getWfMate().decorate('handlers', { path, type: 'WF_FLOW' }, true);
|
|
117
|
-
}
|
|
118
|
-
function WorkflowSchema(schema) {
|
|
119
|
-
return getWfMate().decorate('wfSchema', schema);
|
|
120
|
-
}
|
|
121
|
-
const WorkflowParam = (name) => {
|
|
122
|
-
switch (name) {
|
|
123
|
-
case 'resume': return Resolve(() => useWfState().resume, 'Workflow-Resume');
|
|
124
|
-
case 'indexes': return Resolve(() => useWfState().indexes, 'Workflow-Indexes');
|
|
125
|
-
case 'schemaId': return Resolve(() => useWfState().schemaId, 'Workflow-SchemaId');
|
|
126
|
-
case 'context': return Resolve(() => useWfState().ctx(), 'Workflow-Context');
|
|
127
|
-
case 'input': return Resolve(() => useWfState().input(), 'Workflow-Input');
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
138
|
export { MoostWf, Step, Workflow, WorkflowParam, WorkflowSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-wf",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.24",
|
|
4
4
|
"description": "@moostjs/event-wf",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"moost": "0.3.
|
|
41
|
-
"wooks": "^0.4.
|
|
42
|
-
"@wooksjs/event-core": "^0.4.
|
|
43
|
-
"@wooksjs/event-wf": "^0.4.
|
|
40
|
+
"moost": "0.3.24",
|
|
41
|
+
"wooks": "^0.4.29",
|
|
42
|
+
"@wooksjs/event-core": "^0.4.29",
|
|
43
|
+
"@wooksjs/event-wf": "^0.4.29",
|
|
44
44
|
"@prostojs/infact": "^0.1.13",
|
|
45
45
|
"@prostojs/mate": "^0.3.0",
|
|
46
46
|
"@prostojs/wf": "^0.0.18"
|