@webda/workflow 0.0.0-stage → 4.0.0-beta.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/LICENSE +166 -0
- package/README.md +54 -2
- package/lib/authoring.d.ts +112 -0
- package/lib/authoring.d.ts.map +1 -0
- package/lib/authoring.js +107 -0
- package/lib/authoring.js.map +1 -0
- package/lib/expression.d.ts +21 -0
- package/lib/expression.d.ts.map +1 -0
- package/lib/expression.js +196 -0
- package/lib/expression.js.map +1 -0
- package/lib/graph.d.ts +291 -0
- package/lib/graph.d.ts.map +1 -0
- package/lib/graph.js +72 -0
- package/lib/graph.js.map +1 -0
- package/lib/hooks.d.ts +38 -0
- package/lib/hooks.d.ts.map +1 -0
- package/lib/hooks.js +23 -0
- package/lib/hooks.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -0
- package/lib/interpreter.d.ts +63 -0
- package/lib/interpreter.d.ts.map +1 -0
- package/lib/interpreter.js +330 -0
- package/lib/interpreter.js.map +1 -0
- package/lib/models/workflow.model.d.ts +71 -0
- package/lib/models/workflow.model.d.ts.map +1 -0
- package/lib/models/workflow.model.js +70 -0
- package/lib/models/workflow.model.js.map +1 -0
- package/lib/models/workflowinstance.model.d.ts +132 -0
- package/lib/models/workflowinstance.model.d.ts.map +1 -0
- package/lib/models/workflowinstance.model.js +168 -0
- package/lib/models/workflowinstance.model.js.map +1 -0
- package/lib/models/workflowsignal.model.d.ts +51 -0
- package/lib/models/workflowsignal.model.d.ts.map +1 -0
- package/lib/models/workflowsignal.model.js +53 -0
- package/lib/models/workflowsignal.model.js.map +1 -0
- package/lib/models/workflowtask.model.d.ts +103 -0
- package/lib/models/workflowtask.model.d.ts.map +1 -0
- package/lib/models/workflowtask.model.js +104 -0
- package/lib/models/workflowtask.model.js.map +1 -0
- package/lib/workflow.service.d.ts +670 -0
- package/lib/workflow.service.d.ts.map +1 -0
- package/lib/workflow.service.js +1950 -0
- package/lib/workflow.service.js.map +1 -0
- package/package.json +68 -3
- package/webda.module.json +2670 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { Action, CoreModel } from "@webda/core";
|
|
36
|
+
import { useWorkflowControls } from "../hooks.js";
|
|
37
|
+
/**
|
|
38
|
+
* Actions allowed to the launcher of a workflow: reads, signals and the controls
|
|
39
|
+
*/
|
|
40
|
+
const LAUNCHER_ACTIONS = ["get", "query", "signal", "cancel", "retry", "migrate"];
|
|
41
|
+
/**
|
|
42
|
+
* Whether a caller may read or control an object launched by `launcherId`
|
|
43
|
+
* @param context - the caller
|
|
44
|
+
* @param action - the action
|
|
45
|
+
* @param launcherId - user id of the launcher
|
|
46
|
+
* @returns true when allowed, the reason otherwise
|
|
47
|
+
*/
|
|
48
|
+
export function canReadWorkflow(context, action, launcherId) {
|
|
49
|
+
if (context.isGlobalContext()) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (!LAUNCHER_ACTIONS.includes(action)) {
|
|
53
|
+
return "Workflows are written through the WorkflowService only";
|
|
54
|
+
}
|
|
55
|
+
const userId = context.getCurrentUserId();
|
|
56
|
+
if (!userId || userId !== launcherId) {
|
|
57
|
+
return "Only the launcher can read a workflow";
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
let WorkflowInstance = (() => {
|
|
62
|
+
let _classSuper = CoreModel;
|
|
63
|
+
let _instanceExtraInitializers = [];
|
|
64
|
+
let _cancel_decorators;
|
|
65
|
+
let _retry_decorators;
|
|
66
|
+
let _migrate_decorators;
|
|
67
|
+
return class WorkflowInstance extends _classSuper {
|
|
68
|
+
static {
|
|
69
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
70
|
+
_cancel_decorators = [Action({ rest: { method: "POST" } })];
|
|
71
|
+
_retry_decorators = [Action({ rest: { method: "POST" } })];
|
|
72
|
+
_migrate_decorators = [Action({ rest: { method: "POST" } })];
|
|
73
|
+
__esDecorate(this, null, _cancel_decorators, { kind: "method", name: "cancel", static: false, private: false, access: { has: obj => "cancel" in obj, get: obj => obj.cancel }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
74
|
+
__esDecorate(this, null, _retry_decorators, { kind: "method", name: "retry", static: false, private: false, access: { has: obj => "retry" in obj, get: obj => obj.retry }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
75
|
+
__esDecorate(this, null, _migrate_decorators, { kind: "method", name: "migrate", static: false, private: false, access: { has: obj => "migrate" in obj, get: obj => obj.migrate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
76
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Flow id: the operation id launching the flow
|
|
80
|
+
*/
|
|
81
|
+
flowId = __runInitializers(this, _instanceExtraInitializers);
|
|
82
|
+
/**
|
|
83
|
+
* Version of the pinned definition
|
|
84
|
+
*/
|
|
85
|
+
version;
|
|
86
|
+
/**
|
|
87
|
+
* The definition the instance runs, pinned at launch
|
|
88
|
+
*/
|
|
89
|
+
definition;
|
|
90
|
+
/**
|
|
91
|
+
* Flow input, by parameter name
|
|
92
|
+
*/
|
|
93
|
+
input;
|
|
94
|
+
/**
|
|
95
|
+
* Outcomes of the finished tasks, by task key
|
|
96
|
+
*/
|
|
97
|
+
journal;
|
|
98
|
+
/**
|
|
99
|
+
* Current status
|
|
100
|
+
*/
|
|
101
|
+
status;
|
|
102
|
+
/**
|
|
103
|
+
* Identity the steps run as
|
|
104
|
+
*/
|
|
105
|
+
launcher;
|
|
106
|
+
/**
|
|
107
|
+
* Flow output, once SUCCESS
|
|
108
|
+
*/
|
|
109
|
+
output;
|
|
110
|
+
/**
|
|
111
|
+
* Uncaught error, once ERROR
|
|
112
|
+
*/
|
|
113
|
+
error;
|
|
114
|
+
/**
|
|
115
|
+
* Revision of the instance, incremented by every write (compare-and-set)
|
|
116
|
+
*/
|
|
117
|
+
revision;
|
|
118
|
+
/**
|
|
119
|
+
* Parent instance and task key of a child flow
|
|
120
|
+
*/
|
|
121
|
+
parent;
|
|
122
|
+
/**
|
|
123
|
+
* Creation time (ms)
|
|
124
|
+
*/
|
|
125
|
+
createdAt;
|
|
126
|
+
/**
|
|
127
|
+
* Last update time (ms)
|
|
128
|
+
*/
|
|
129
|
+
updatedAt;
|
|
130
|
+
/**
|
|
131
|
+
* Launcher and system may read, writes go through the service only
|
|
132
|
+
* @param context - the caller
|
|
133
|
+
* @param action - the action
|
|
134
|
+
* @returns true when allowed, the reason otherwise
|
|
135
|
+
*/
|
|
136
|
+
canAct(context, action) {
|
|
137
|
+
return canReadWorkflow(context, action, this.launcher?.userId);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Cancel the instance, its live tasks and the children it waits on
|
|
141
|
+
*/
|
|
142
|
+
async cancel() {
|
|
143
|
+
await useWorkflowControls().cancelInstance(this.uuid);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Restart a failed instance from its failed task, keeping the outcomes before it
|
|
147
|
+
*/
|
|
148
|
+
async retry() {
|
|
149
|
+
await useWorkflowControls().retryInstance(this.uuid);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Move a running instance to another version of its flow
|
|
153
|
+
* @param version - the target version, the latest registered when omitted
|
|
154
|
+
*/
|
|
155
|
+
async migrate(version) {
|
|
156
|
+
await useWorkflowControls().migrateInstance(this.uuid, version);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
})();
|
|
160
|
+
/**
|
|
161
|
+
* A running (or finished) flow: its pinned definition, input and journal of task outcomes
|
|
162
|
+
*
|
|
163
|
+
* @WebdaModel
|
|
164
|
+
* @WebdaPlural WorkflowInstances
|
|
165
|
+
*/
|
|
166
|
+
export default WorkflowInstance;
|
|
167
|
+
export { WorkflowInstance };
|
|
168
|
+
//# sourceMappingURL=workflowinstance.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowinstance.model.js","sources":["../../src/models/workflowinstance.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAyC,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AA0ClD;;GAEG;AACH,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAElF;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,OAA0B,EAAE,MAAc,EAAE,UAAmB;IAC7F,IAAI,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,OAAO,wDAAwD,CAAC;IAClE,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAC1C,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QACrC,OAAO,uCAAuC,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;;sBAQ6C,SAAS;;;;;iBAAlC,gBAAiB,SAAQ,WAAS;;;kCAmEpD,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;iCAQpC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;mCASpC,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
1
|
+
import { CoreModel, type IOperationContext } from "@webda/core";
|
|
2
|
+
/**
|
|
3
|
+
* A signal sent before any instance waited for it, kept until `expiresAt`
|
|
4
|
+
*
|
|
5
|
+
* The first wait on the same `(event, key)` whose instance accepts the sender consumes it.
|
|
6
|
+
*
|
|
7
|
+
* @WebdaModel
|
|
8
|
+
* @WebdaPlural WorkflowSignals
|
|
9
|
+
*/
|
|
10
|
+
export default class WorkflowSignal extends CoreModel {
|
|
11
|
+
/**
|
|
12
|
+
* Event name
|
|
13
|
+
*/
|
|
14
|
+
event: string;
|
|
15
|
+
/**
|
|
16
|
+
* Business key
|
|
17
|
+
*/
|
|
18
|
+
key: string;
|
|
19
|
+
/**
|
|
20
|
+
* Payload, the result of the wait
|
|
21
|
+
*/
|
|
22
|
+
payload?: any;
|
|
23
|
+
/**
|
|
24
|
+
* User id of the sender
|
|
25
|
+
*/
|
|
26
|
+
senderId?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Ident used by the sender
|
|
29
|
+
*/
|
|
30
|
+
senderIdent?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Sent by the system
|
|
33
|
+
*/
|
|
34
|
+
system?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* When it was sent (ms)
|
|
37
|
+
*/
|
|
38
|
+
createdAt: number;
|
|
39
|
+
/**
|
|
40
|
+
* When it can no longer be consumed (ms)
|
|
41
|
+
*/
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
/**
|
|
44
|
+
* Only the system: signals are written and consumed by the WorkflowService
|
|
45
|
+
* @param context - the caller
|
|
46
|
+
* @returns true for the system
|
|
47
|
+
*/
|
|
48
|
+
canAct(context: IOperationContext): string | boolean;
|
|
49
|
+
}
|
|
50
|
+
export { WorkflowSignal };
|
|
51
|
+
//# sourceMappingURL=workflowsignal.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowsignal.model.d.ts","sources":["../../src/models/workflowsignal.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,SAAS;IACnD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAEnD;CACF;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CoreModel } from "@webda/core";
|
|
2
|
+
/**
|
|
3
|
+
* A signal sent before any instance waited for it, kept until `expiresAt`
|
|
4
|
+
*
|
|
5
|
+
* The first wait on the same `(event, key)` whose instance accepts the sender consumes it.
|
|
6
|
+
*
|
|
7
|
+
* @WebdaModel
|
|
8
|
+
* @WebdaPlural WorkflowSignals
|
|
9
|
+
*/
|
|
10
|
+
export default class WorkflowSignal extends CoreModel {
|
|
11
|
+
/**
|
|
12
|
+
* Event name
|
|
13
|
+
*/
|
|
14
|
+
event;
|
|
15
|
+
/**
|
|
16
|
+
* Business key
|
|
17
|
+
*/
|
|
18
|
+
key;
|
|
19
|
+
/**
|
|
20
|
+
* Payload, the result of the wait
|
|
21
|
+
*/
|
|
22
|
+
payload;
|
|
23
|
+
/**
|
|
24
|
+
* User id of the sender
|
|
25
|
+
*/
|
|
26
|
+
senderId;
|
|
27
|
+
/**
|
|
28
|
+
* Ident used by the sender
|
|
29
|
+
*/
|
|
30
|
+
senderIdent;
|
|
31
|
+
/**
|
|
32
|
+
* Sent by the system
|
|
33
|
+
*/
|
|
34
|
+
system;
|
|
35
|
+
/**
|
|
36
|
+
* When it was sent (ms)
|
|
37
|
+
*/
|
|
38
|
+
createdAt;
|
|
39
|
+
/**
|
|
40
|
+
* When it can no longer be consumed (ms)
|
|
41
|
+
*/
|
|
42
|
+
expiresAt;
|
|
43
|
+
/**
|
|
44
|
+
* Only the system: signals are written and consumed by the WorkflowService
|
|
45
|
+
* @param context - the caller
|
|
46
|
+
* @returns true for the system
|
|
47
|
+
*/
|
|
48
|
+
canAct(context) {
|
|
49
|
+
return context.isGlobalContext() || "Signals are handled by the WorkflowService only";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export { WorkflowSignal };
|
|
53
|
+
//# sourceMappingURL=workflowsignal.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowsignal.model.js","sources":["../../src/models/workflowsignal.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,SAAS;IACnD;;OAEG;IACH,KAAK,CAAS;IACd;;OAEG;IACH,GAAG,CAAS;IACZ;;OAEG;IACH,OAAO,CAAO;IACd;;OAEG;IACH,QAAQ,CAAU;IAClB;;OAEG;IACH,WAAW,CAAU;IACrB;;OAEG;IACH,MAAM,CAAW;IACjB;;OAEG;IACH,SAAS,CAAS;IAClB;;OAEG;IACH,SAAS,CAAS;IAElB;;;;OAIG;IACH,MAAM,CAAC,OAA0B;QAC/B,OAAO,OAAO,CAAC,eAAe,EAAE,IAAI,iDAAiD,CAAC;IACxF,CAAC;CACF;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CoreModel, type IOperationContext } from "@webda/core";
|
|
2
|
+
import type { FlowError, TaskOptions } from "../graph.js";
|
|
3
|
+
/**
|
|
4
|
+
* Status of a task attempt
|
|
5
|
+
*/
|
|
6
|
+
export type WorkflowTaskStatus = "PENDING" | "RUNNING" | "WAITING_EVENT" | "WAITING_CHILD" | "SUCCESS" | "ERROR" | "CANCELLED";
|
|
7
|
+
/**
|
|
8
|
+
* One attempt of a task of a workflow instance
|
|
9
|
+
*
|
|
10
|
+
* @WebdaModel
|
|
11
|
+
* @WebdaPlural WorkflowTasks
|
|
12
|
+
*/
|
|
13
|
+
export default class WorkflowTask extends CoreModel {
|
|
14
|
+
/**
|
|
15
|
+
* Uuid of the workflow instance
|
|
16
|
+
*/
|
|
17
|
+
instance: string;
|
|
18
|
+
/**
|
|
19
|
+
* Task key in the instance journal
|
|
20
|
+
*/
|
|
21
|
+
key: string;
|
|
22
|
+
/**
|
|
23
|
+
* Operation id or built-in
|
|
24
|
+
*/
|
|
25
|
+
operation: string;
|
|
26
|
+
/**
|
|
27
|
+
* Operation input
|
|
28
|
+
*/
|
|
29
|
+
input: any;
|
|
30
|
+
/**
|
|
31
|
+
* Task options, flow defaults included
|
|
32
|
+
*/
|
|
33
|
+
options: TaskOptions;
|
|
34
|
+
/**
|
|
35
|
+
* Attempt number, starting at 1
|
|
36
|
+
*/
|
|
37
|
+
attempt: number;
|
|
38
|
+
/**
|
|
39
|
+
* Current status
|
|
40
|
+
*/
|
|
41
|
+
status: WorkflowTaskStatus;
|
|
42
|
+
/**
|
|
43
|
+
* When the task becomes runnable (ms)
|
|
44
|
+
*/
|
|
45
|
+
runAt: number;
|
|
46
|
+
/**
|
|
47
|
+
* Worker holding the lease
|
|
48
|
+
*/
|
|
49
|
+
owner?: string;
|
|
50
|
+
/**
|
|
51
|
+
* End of the lease (ms), 0 when free
|
|
52
|
+
*/
|
|
53
|
+
leaseUntil: number;
|
|
54
|
+
/**
|
|
55
|
+
* Result of the attempt
|
|
56
|
+
*/
|
|
57
|
+
output?: any;
|
|
58
|
+
/**
|
|
59
|
+
* Error of the attempt
|
|
60
|
+
*/
|
|
61
|
+
error?: FlowError;
|
|
62
|
+
/**
|
|
63
|
+
* Start of the attempt (ms)
|
|
64
|
+
*/
|
|
65
|
+
startedAt?: number;
|
|
66
|
+
/**
|
|
67
|
+
* End of the attempt (ms)
|
|
68
|
+
*/
|
|
69
|
+
endedAt?: number;
|
|
70
|
+
/**
|
|
71
|
+
* User id of the instance launcher, for canAct
|
|
72
|
+
*/
|
|
73
|
+
launcherId?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Event a `Wait.ForEvent` waits for
|
|
76
|
+
*/
|
|
77
|
+
event?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Business key a `Wait.ForEvent` waits for
|
|
80
|
+
*/
|
|
81
|
+
eventKey?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Users allowed to signal the wait, besides the launcher and the system
|
|
84
|
+
*/
|
|
85
|
+
allow?: string[];
|
|
86
|
+
/**
|
|
87
|
+
* The wait was resolved by a signal: `output` holds its payload
|
|
88
|
+
*/
|
|
89
|
+
signaled?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Child instance of a `WAITING_CHILD` task
|
|
92
|
+
*/
|
|
93
|
+
child?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Launcher and system may read, writes go through the service only
|
|
96
|
+
* @param context - the caller
|
|
97
|
+
* @param action - the action
|
|
98
|
+
* @returns true when allowed, the reason otherwise
|
|
99
|
+
*/
|
|
100
|
+
canAct(context: IOperationContext, action: string): string | boolean;
|
|
101
|
+
}
|
|
102
|
+
export { WorkflowTask };
|
|
103
|
+
//# sourceMappingURL=workflowtask.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowtask.model.d.ts","sources":["../../src/models/workflowtask.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EA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AAM,GAAG,MAAM,GAAG,OAAO,CAKnE;CACF;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { CoreModel } from "@webda/core";
|
|
2
|
+
import { canReadWorkflow } from "./workflowinstance.model.js";
|
|
3
|
+
/**
|
|
4
|
+
* One attempt of a task of a workflow instance
|
|
5
|
+
*
|
|
6
|
+
* @WebdaModel
|
|
7
|
+
* @WebdaPlural WorkflowTasks
|
|
8
|
+
*/
|
|
9
|
+
export default class WorkflowTask extends CoreModel {
|
|
10
|
+
/**
|
|
11
|
+
* Uuid of the workflow instance
|
|
12
|
+
*/
|
|
13
|
+
instance;
|
|
14
|
+
/**
|
|
15
|
+
* Task key in the instance journal
|
|
16
|
+
*/
|
|
17
|
+
key;
|
|
18
|
+
/**
|
|
19
|
+
* Operation id or built-in
|
|
20
|
+
*/
|
|
21
|
+
operation;
|
|
22
|
+
/**
|
|
23
|
+
* Operation input
|
|
24
|
+
*/
|
|
25
|
+
input;
|
|
26
|
+
/**
|
|
27
|
+
* Task options, flow defaults included
|
|
28
|
+
*/
|
|
29
|
+
options;
|
|
30
|
+
/**
|
|
31
|
+
* Attempt number, starting at 1
|
|
32
|
+
*/
|
|
33
|
+
attempt;
|
|
34
|
+
/**
|
|
35
|
+
* Current status
|
|
36
|
+
*/
|
|
37
|
+
status;
|
|
38
|
+
/**
|
|
39
|
+
* When the task becomes runnable (ms)
|
|
40
|
+
*/
|
|
41
|
+
runAt;
|
|
42
|
+
/**
|
|
43
|
+
* Worker holding the lease
|
|
44
|
+
*/
|
|
45
|
+
owner;
|
|
46
|
+
/**
|
|
47
|
+
* End of the lease (ms), 0 when free
|
|
48
|
+
*/
|
|
49
|
+
leaseUntil;
|
|
50
|
+
/**
|
|
51
|
+
* Result of the attempt
|
|
52
|
+
*/
|
|
53
|
+
output;
|
|
54
|
+
/**
|
|
55
|
+
* Error of the attempt
|
|
56
|
+
*/
|
|
57
|
+
error;
|
|
58
|
+
/**
|
|
59
|
+
* Start of the attempt (ms)
|
|
60
|
+
*/
|
|
61
|
+
startedAt;
|
|
62
|
+
/**
|
|
63
|
+
* End of the attempt (ms)
|
|
64
|
+
*/
|
|
65
|
+
endedAt;
|
|
66
|
+
/**
|
|
67
|
+
* User id of the instance launcher, for canAct
|
|
68
|
+
*/
|
|
69
|
+
launcherId;
|
|
70
|
+
/**
|
|
71
|
+
* Event a `Wait.ForEvent` waits for
|
|
72
|
+
*/
|
|
73
|
+
event;
|
|
74
|
+
/**
|
|
75
|
+
* Business key a `Wait.ForEvent` waits for
|
|
76
|
+
*/
|
|
77
|
+
eventKey;
|
|
78
|
+
/**
|
|
79
|
+
* Users allowed to signal the wait, besides the launcher and the system
|
|
80
|
+
*/
|
|
81
|
+
allow;
|
|
82
|
+
/**
|
|
83
|
+
* The wait was resolved by a signal: `output` holds its payload
|
|
84
|
+
*/
|
|
85
|
+
signaled;
|
|
86
|
+
/**
|
|
87
|
+
* Child instance of a `WAITING_CHILD` task
|
|
88
|
+
*/
|
|
89
|
+
child;
|
|
90
|
+
/**
|
|
91
|
+
* Launcher and system may read, writes go through the service only
|
|
92
|
+
* @param context - the caller
|
|
93
|
+
* @param action - the action
|
|
94
|
+
* @returns true when allowed, the reason otherwise
|
|
95
|
+
*/
|
|
96
|
+
canAct(context, action) {
|
|
97
|
+
if (!context.isGlobalContext() && action !== "get" && action !== "query") {
|
|
98
|
+
return "Workflow tasks are written through the WorkflowService only";
|
|
99
|
+
}
|
|
100
|
+
return canReadWorkflow(context, action, this.launcherId);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export { WorkflowTask };
|
|
104
|
+
//# sourceMappingURL=workflowtask.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowtask.model.js","sources":["../../src/models/workflowtask.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAQ9D;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,SAAS;IACjD;;OAEG;IACH,QAAQ,CAAS;IACjB;;OAEG;IACH,GAAG,CAAS;IACZ;;OAEG;IACH,SAAS,CAAS;IAClB;;OAEG;IACH,KAAK,CAAM;IACX;;OAEG;IACH,OAAO,CAAc;IACrB;;OAEG;IACH,OAAO,CAAS;IAChB;;OAEG;IACH,MAAM,CAAqB;IAC3B;;OAEG;IACH,KAAK,CAAS;IACd;;OAEG;IACH,KAAK,CAAU;IACf;;OAEG;IACH,UAAU,CAAS;IACnB;;OAEG;IACH,MAAM,CAAO;IACb;;OAEG;IACH,KAAK,CAAa;IAClB;;OAEG;IACH,SAAS,CAAU;IACnB;;OAEG;IACH,OAAO,CAAU;IACjB;;OAEG;IACH,UAAU,CAAU;IACpB;;OAEG;IACH,KAAK,CAAU;IACf;;OAEG;IACH,QAAQ,CAAU;IAClB;;OAEG;IACH,KAAK,CAAY;IACjB;;OAEG;IACH,QAAQ,CAAW;IACnB;;OAEG;IACH,KAAK,CAAU;IAEf;;;;;OAKG;IACH,MAAM,CAAC,OAA0B,EAAE,MAAc;QAC/C,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YACzE,OAAO,6DAA6D,CAAC;QACvE,CAAC;QACD,OAAO,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3D,CAAC;CACF;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|