@versori/run 0.4.24 → 0.4.26
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/esm/src/context/AsyncWorkflow.js +1 -1
- package/esm/src/context/Context.d.ts +8 -24
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +18 -5
- package/esm/src/context/ContextProvider.d.ts +2 -0
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +5 -2
- package/esm/src/context/WorkflowClient.d.ts +28 -0
- package/esm/src/context/WorkflowClient.d.ts.map +1 -0
- package/esm/src/context/WorkflowClient.js +108 -0
- package/esm/src/context/mod.d.ts +2 -1
- package/esm/src/context/mod.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.d.ts +5 -3
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +3 -0
- package/esm/src/internal/InternalAuth.d.ts +0 -1
- package/esm/src/internal/InternalAuth.d.ts.map +1 -1
- package/esm/src/internal/InternalAuth.js +1 -17
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +4 -17
- package/esm/src/interpreter/durable/Queue.d.ts +25 -17
- package/esm/src/interpreter/durable/Queue.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.js +17 -8
- package/esm/src/interpreter/durable/compilers/catch.js +2 -2
- package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.js +31 -35
- package/esm/src/interpreter/memory/MemoryInterpreter.js +2 -2
- package/esm/src/interpreter/memory/compilers/catch.js +2 -2
- package/esm/src/kv/sdk/SDKKeyValue.d.ts +2 -2
- package/esm/src/kv/sdk/SDKKeyValue.d.ts.map +1 -1
- package/esm/src/kv/sdk/SDKKeyValue.js +9 -3
- package/package.json +1 -1
- package/script/src/context/AsyncWorkflow.js +1 -1
- package/script/src/context/Context.d.ts +8 -24
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +18 -5
- package/script/src/context/ContextProvider.d.ts +2 -0
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +5 -2
- package/script/src/context/WorkflowClient.d.ts +28 -0
- package/script/src/context/WorkflowClient.d.ts.map +1 -0
- package/script/src/context/WorkflowClient.js +112 -0
- package/script/src/context/mod.d.ts +2 -1
- package/script/src/context/mod.d.ts.map +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.d.ts +5 -3
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +3 -0
- package/script/src/internal/InternalAuth.d.ts +0 -1
- package/script/src/internal/InternalAuth.d.ts.map +1 -1
- package/script/src/internal/InternalAuth.js +0 -16
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +3 -16
- package/script/src/interpreter/durable/Queue.d.ts +25 -17
- package/script/src/interpreter/durable/Queue.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.js +17 -8
- package/script/src/interpreter/durable/compilers/catch.js +2 -2
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.js +31 -35
- package/script/src/interpreter/memory/MemoryInterpreter.js +1 -1
- package/script/src/interpreter/memory/compilers/catch.js +2 -2
- package/script/src/kv/sdk/SDKKeyValue.d.ts +2 -2
- package/script/src/kv/sdk/SDKKeyValue.d.ts.map +1 -1
- package/script/src/kv/sdk/SDKKeyValue.js +9 -3
- package/esm/src/internal/cli.d.ts +0 -2
- package/esm/src/internal/cli.d.ts.map +0 -1
- package/esm/src/internal/cli.js +0 -32
- package/script/src/internal/cli.d.ts +0 -2
- package/script/src/internal/cli.d.ts.map +0 -1
- package/script/src/internal/cli.js +0 -35
|
@@ -84,7 +84,7 @@ export class AsyncWorkflow {
|
|
|
84
84
|
this.isWaiting = false;
|
|
85
85
|
throw new Error('wait timed out');
|
|
86
86
|
}
|
|
87
|
-
const workflow = await this.queue.
|
|
87
|
+
const workflow = await this.queue.getWorkflow(this.workflowId);
|
|
88
88
|
if (workflow.status === 'completed') {
|
|
89
89
|
// workflow is completed, parse the output and set the data and completed to true
|
|
90
90
|
const stringData = workflow.output;
|
|
@@ -1,40 +1,20 @@
|
|
|
1
1
|
import type * as express from 'express';
|
|
2
2
|
import { CredentialsProvider } from '../dsl/http/versori/contextcredentials.js';
|
|
3
|
-
import { QueueAPI } from '../interpreter/durable/Queue.js';
|
|
3
|
+
import { QueueAPI, Workflow } from '../interpreter/durable/Queue.js';
|
|
4
4
|
import { Issue, IssueAPI } from '../issues/Issues.js';
|
|
5
5
|
import { KeyValue, KeyValueProvider, KeyValueScope } from '../kv/KeyValue.js';
|
|
6
6
|
import { Logger } from '../observability/logging/Logger.js';
|
|
7
7
|
import { ActivationImpl } from './ActivationImpl.js';
|
|
8
8
|
import { AsyncWorkflow } from './AsyncWorkflow.js';
|
|
9
|
+
import { WorkflowInterface, WorkflowOpts } from './WorkflowClient.js';
|
|
9
10
|
export type OnSuccessFn = (ctx: Context<any>) => void;
|
|
10
11
|
export type OnErrorFn = (ctx: Context<any>) => void;
|
|
11
12
|
export type ContextOptions = {
|
|
12
|
-
|
|
13
|
+
workflow?: Workflow;
|
|
13
14
|
request?: express.Request;
|
|
14
15
|
onSuccess?: OnSuccessFn;
|
|
15
16
|
onError?: OnErrorFn;
|
|
16
17
|
};
|
|
17
|
-
/**
|
|
18
|
-
* WorkflowOpts is used to pass data to the workflow when starting it. Use either `data` or `dataRaw`, but not both.
|
|
19
|
-
*
|
|
20
|
-
* MaxAttempts is used to limit the number of attempts for the workflow execution.
|
|
21
|
-
*/
|
|
22
|
-
export type WorkflowOpts = {
|
|
23
|
-
/**
|
|
24
|
-
* MaxAttempts is used to limit the number of attempts for the workflow execution.
|
|
25
|
-
*
|
|
26
|
-
* @default 5
|
|
27
|
-
*/
|
|
28
|
-
maxAttempts?: number;
|
|
29
|
-
/**
|
|
30
|
-
* The data passed to the workflow instance when it was created.
|
|
31
|
-
*/
|
|
32
|
-
data?: unknown;
|
|
33
|
-
/**
|
|
34
|
-
* The data passed to the workflow instance when it was created, base64 encoded.
|
|
35
|
-
*/
|
|
36
|
-
dataRaw?: string;
|
|
37
|
-
};
|
|
38
18
|
/**
|
|
39
19
|
* CreateIssue is the payload for creating a new issue.
|
|
40
20
|
*/
|
|
@@ -66,6 +46,7 @@ export interface Context<D> {
|
|
|
66
46
|
readonly startTime: Date;
|
|
67
47
|
readonly data: D;
|
|
68
48
|
activation: ActivationImpl;
|
|
49
|
+
workflow?: Workflow;
|
|
69
50
|
/**
|
|
70
51
|
* Opens a key value store for the given scope, defaulting to ':project:' if not provided.
|
|
71
52
|
* @param scope The scope of the key value store to open, defaulting to ':project:' if not provided.
|
|
@@ -106,6 +87,7 @@ export interface Context<D> {
|
|
|
106
87
|
* Returns the underlying express {@link express.Request} object for the current execution.
|
|
107
88
|
*/
|
|
108
89
|
request(): express.Request | undefined;
|
|
90
|
+
workflowClient(): WorkflowInterface;
|
|
109
91
|
}
|
|
110
92
|
export declare class ContextImpl<D, Index = void> implements Context<D> {
|
|
111
93
|
#private;
|
|
@@ -119,14 +101,16 @@ export declare class ContextImpl<D, Index = void> implements Context<D> {
|
|
|
119
101
|
readonly options: ContextOptions;
|
|
120
102
|
constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, executionId: string, startTime: Date, data: D, activation: ActivationImpl, issues: IssueAPI, queue?: QueueAPI, options?: ContextOptions);
|
|
121
103
|
get activation(): ActivationImpl;
|
|
122
|
-
get
|
|
104
|
+
get workflow(): Workflow | undefined;
|
|
123
105
|
setIndex(idx: number): ContextImpl<D, number>;
|
|
124
106
|
withData<D2>(data: D2): ContextImpl<D2, Index>;
|
|
125
107
|
openKv(scope?: KeyValueScope): KeyValue;
|
|
126
108
|
request(): express.Request | undefined;
|
|
109
|
+
workflowClient(): WorkflowInterface;
|
|
127
110
|
start(group: string, opts: WorkflowOpts): Promise<AsyncWorkflow>;
|
|
128
111
|
createIssue(issue: CreateIssue, options?: {
|
|
129
112
|
deduplicate?: boolean;
|
|
113
|
+
duplicationKey?: string;
|
|
130
114
|
}): Promise<Issue | null>;
|
|
131
115
|
credentials(): CredentialsProvider;
|
|
132
116
|
destroy(scope: KeyValueScope): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAgB,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEpF,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E,EAAE,GAAG,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC;IAe9C,MAAM,CAAC,KAAK,GAAE,aAA2B,GAAG,QAAQ;IAepD,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS;IAItC,cAAc,IAAI,iBAAiB;IAQ7B,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAgCtE,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAYpH,WAAW,IAAI,mBAAmB;IAUlC,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5C,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQlD"}
|
|
@@ -22,7 +22,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
22
22
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
23
23
|
};
|
|
24
24
|
var _ContextImpl_activation, _ContextImpl_issues, _ContextImpl_creds;
|
|
25
|
+
import { Buffer } from 'node:buffer';
|
|
25
26
|
import { AsyncWorkflow } from './AsyncWorkflow.js';
|
|
27
|
+
import { WorkflowImpl } from './WorkflowClient.js';
|
|
26
28
|
export class ContextImpl {
|
|
27
29
|
constructor(log, kvp, creds, executionId, startTime, data, activation, issues, queue, options = {}) {
|
|
28
30
|
Object.defineProperty(this, "log", {
|
|
@@ -96,12 +98,13 @@ export class ContextImpl {
|
|
|
96
98
|
this.request = this.request.bind(this);
|
|
97
99
|
this.createIssue = this.createIssue.bind(this);
|
|
98
100
|
this.destroy = this.destroy.bind(this);
|
|
101
|
+
this.workflowClient = this.workflowClient.bind(this);
|
|
99
102
|
}
|
|
100
103
|
get activation() {
|
|
101
104
|
return __classPrivateFieldGet(this, _ContextImpl_activation, "f");
|
|
102
105
|
}
|
|
103
|
-
get
|
|
104
|
-
return this.options.
|
|
106
|
+
get workflow() {
|
|
107
|
+
return this.options.workflow;
|
|
105
108
|
}
|
|
106
109
|
setIndex(idx) {
|
|
107
110
|
const next = new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, __classPrivateFieldGet(this, _ContextImpl_activation, "f"), __classPrivateFieldGet(this, _ContextImpl_issues, "f"), this.queue, this.options);
|
|
@@ -127,6 +130,12 @@ export class ContextImpl {
|
|
|
127
130
|
request() {
|
|
128
131
|
return this.options.request;
|
|
129
132
|
}
|
|
133
|
+
workflowClient() {
|
|
134
|
+
if (!this.queue) {
|
|
135
|
+
throw new Error('Queue is not available for this context, cannot start workflow');
|
|
136
|
+
}
|
|
137
|
+
return new WorkflowImpl(this.queue, this.executionId, this.activation);
|
|
138
|
+
}
|
|
130
139
|
async start(group, opts) {
|
|
131
140
|
// this makes a post request to the endpoint sending a message and schedule the workflow to run
|
|
132
141
|
if (!this.queue) {
|
|
@@ -134,7 +143,7 @@ export class ContextImpl {
|
|
|
134
143
|
}
|
|
135
144
|
let payload;
|
|
136
145
|
if (opts.data) {
|
|
137
|
-
payload = opts.data ?
|
|
146
|
+
payload = opts.data ? Buffer.from(JSON.stringify(opts.data)).toString('base64') : undefined;
|
|
138
147
|
}
|
|
139
148
|
else if (opts.dataRaw) {
|
|
140
149
|
payload = opts.dataRaw; // Assume this is already base64 encoded
|
|
@@ -148,7 +157,7 @@ export class ContextImpl {
|
|
|
148
157
|
activationId: this.activation?.id,
|
|
149
158
|
userId: this.activation?.user?.externalId,
|
|
150
159
|
},
|
|
151
|
-
payload,
|
|
160
|
+
payload: payload ?? btoa("{}"),
|
|
152
161
|
maxAttempts: opts.maxAttempts,
|
|
153
162
|
},
|
|
154
163
|
],
|
|
@@ -156,10 +165,14 @@ export class ContextImpl {
|
|
|
156
165
|
return new AsyncWorkflow(this.queue, resp.workflows[0].id ?? 'unknown');
|
|
157
166
|
}
|
|
158
167
|
createIssue(issue, options) {
|
|
168
|
+
// Default to deduplicate: true only if neither deduplicate nor duplicationKey are provided
|
|
169
|
+
const resolvedOptions = options?.deduplicate !== undefined || options?.duplicationKey !== undefined
|
|
170
|
+
? options
|
|
171
|
+
: { deduplicate: true, ...options };
|
|
159
172
|
return __classPrivateFieldGet(this, _ContextImpl_issues, "f").createIssue({
|
|
160
173
|
reason: 'manual',
|
|
161
174
|
...issue,
|
|
162
|
-
},
|
|
175
|
+
}, resolvedOptions);
|
|
163
176
|
}
|
|
164
177
|
credentials() {
|
|
165
178
|
return {
|
|
@@ -7,6 +7,7 @@ import { Context, ContextImpl, ContextOptions } from './Context.js';
|
|
|
7
7
|
import { Activation, PlatformApi } from '../services/platform/mod.js';
|
|
8
8
|
export interface ContextProvider {
|
|
9
9
|
create<D>(activation: Activation, data: D, options?: ContextOptions): ContextImpl<D, void>;
|
|
10
|
+
createWithExecutionId<D>(activation: Activation, data: D, executionId: string, options?: ContextOptions): ContextImpl<D, void>;
|
|
10
11
|
destroy(ctx: Context<any>): Promise<void>;
|
|
11
12
|
}
|
|
12
13
|
export declare class ContextProviderImpl implements ContextProvider {
|
|
@@ -19,6 +20,7 @@ export declare class ContextProviderImpl implements ContextProvider {
|
|
|
19
20
|
issues: IssueAPI;
|
|
20
21
|
queue?: QueueAPI;
|
|
21
22
|
constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, platformApi: PlatformApi, organisationId: string, environmentId: string, issues: IssueAPI, queue?: QueueAPI | undefined);
|
|
23
|
+
createWithExecutionId<D>(activation: Activation, data: D, executionId: string, options?: ContextOptions): ContextImpl<D, void>;
|
|
22
24
|
create<D>(activation: Activation, data: D, options?: ContextOptions): ContextImpl<D>;
|
|
23
25
|
destroy(_: Context<any>): Promise<void>;
|
|
24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;IAC5B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAZlC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,gBAAgB,CAAC;IACtB,KAAK,EAAE,mBAAmB,CAAC;IAC3B,MAAM,EAAE,QAAQ,CAAC;IACjB,KAAK,CAAC,EAAE,QAAQ,CAAC;gBAGb,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,mBAAmB,EACT,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACtC,MAAM,EAAE,QAAQ,EAChB,KAAK,GAAE,QAAQ,GAAG,SAAqB;IAS3C,qBAAqB,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC;IA6BlI,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,cAAmB,GAAG,WAAW,CAAC,CAAC,CAAC;IAMxF,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1C"}
|
|
@@ -69,8 +69,7 @@ export class ContextProviderImpl {
|
|
|
69
69
|
this.issues = issues;
|
|
70
70
|
this.queue = queue;
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
const executionId = ulid();
|
|
72
|
+
createWithExecutionId(activation, data, executionId, options = {}) {
|
|
74
73
|
const logger = this.log.child({
|
|
75
74
|
executionId,
|
|
76
75
|
activationId: activation.id,
|
|
@@ -79,6 +78,10 @@ export class ContextProviderImpl {
|
|
|
79
78
|
const activationImpl = new ActivationImpl(activation, this.platformApi, this.organisationId, this.environmentId, logger);
|
|
80
79
|
return new ContextImpl(logger, this.kvp, this.creds, executionId, new Date(), data, activationImpl, this.issues, this.queue, options);
|
|
81
80
|
}
|
|
81
|
+
create(activation, data, options = {}) {
|
|
82
|
+
const executionId = ulid();
|
|
83
|
+
return this.createWithExecutionId(activation, data, executionId, options);
|
|
84
|
+
}
|
|
82
85
|
destroy(_) {
|
|
83
86
|
return Promise.resolve();
|
|
84
87
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { QueueAPI, Workflow } from '../interpreter/durable/Queue.js';
|
|
2
|
+
import { ActivationImpl } from './ActivationImpl.js';
|
|
3
|
+
export type WorkflowOpts = {
|
|
4
|
+
maxAttempts?: number;
|
|
5
|
+
data?: unknown;
|
|
6
|
+
dataRaw?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface WorkflowInterface {
|
|
9
|
+
startWorkflow(group: string, opts: WorkflowOpts): Promise<Workflow>;
|
|
10
|
+
getWorkflow(wfs: Workflow): Promise<Workflow>;
|
|
11
|
+
getWorkflowById(id: string): Promise<Workflow>;
|
|
12
|
+
waitForCompletion(wf: Workflow): Promise<Workflow>;
|
|
13
|
+
rescheduleWorkflow(wf: Workflow, after: string): Promise<void>;
|
|
14
|
+
completeWorkflow(wf: Workflow, status: 'completed' | 'failed', output?: any): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare class WorkflowImpl implements WorkflowInterface {
|
|
17
|
+
private queue;
|
|
18
|
+
private executionId;
|
|
19
|
+
private activation;
|
|
20
|
+
constructor(queue: QueueAPI, executionId: string, activation: ActivationImpl);
|
|
21
|
+
startWorkflow(group: string, opts: WorkflowOpts): Promise<Workflow>;
|
|
22
|
+
getWorkflow(wf: Workflow): Promise<Workflow>;
|
|
23
|
+
getWorkflowById(id: string): Promise<Workflow>;
|
|
24
|
+
waitForCompletion(wf: Workflow): Promise<Workflow>;
|
|
25
|
+
rescheduleWorkflow(wf: Workflow, after: string): Promise<void>;
|
|
26
|
+
completeWorkflow(wf: Workflow, status: 'completed' | 'failed', output?: any): Promise<void>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AAU,EAAE,cAAc;IActE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;IAmBnE,WAAW,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI5C,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI9C,iBAAiB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IASlD,kBAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B9D,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,QAAQ,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAYpG"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
+
*
|
|
4
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
+
* included in the LICENSE file at the root of this repository.
|
|
6
|
+
*
|
|
7
|
+
* Change Date: 2029-01-01
|
|
8
|
+
* Change License: Apache License, Version 2.0
|
|
9
|
+
*
|
|
10
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
+
*/
|
|
13
|
+
import { Buffer } from 'node:buffer';
|
|
14
|
+
export class WorkflowImpl {
|
|
15
|
+
constructor(queue, executionId, activation) {
|
|
16
|
+
Object.defineProperty(this, "queue", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "executionId", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(this, "activation", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: void 0
|
|
33
|
+
});
|
|
34
|
+
this.queue = queue;
|
|
35
|
+
this.executionId = executionId;
|
|
36
|
+
this.activation = activation;
|
|
37
|
+
// I have no idea if I need this but I have suffered from it in the past
|
|
38
|
+
this.startWorkflow = this.startWorkflow.bind(this);
|
|
39
|
+
this.getWorkflow = this.getWorkflow.bind(this);
|
|
40
|
+
this.waitForCompletion = this.waitForCompletion.bind(this);
|
|
41
|
+
this.rescheduleWorkflow = this.rescheduleWorkflow.bind(this);
|
|
42
|
+
this.completeWorkflow = this.completeWorkflow.bind(this);
|
|
43
|
+
this.getWorkflowById = this.getWorkflowById.bind(this);
|
|
44
|
+
}
|
|
45
|
+
async startWorkflow(group, opts) {
|
|
46
|
+
const workflows = await this.queue.submit({
|
|
47
|
+
workflows: [
|
|
48
|
+
{
|
|
49
|
+
group,
|
|
50
|
+
metadata: {
|
|
51
|
+
executionId: this.executionId,
|
|
52
|
+
activationId: this.activation?.id,
|
|
53
|
+
userId: this.activation?.user?.externalId,
|
|
54
|
+
},
|
|
55
|
+
payload: opts.data ? Buffer.from(JSON.stringify(opts.data)).toString('base64') : Buffer.from("{}").toString('base64'),
|
|
56
|
+
maxAttempts: opts.maxAttempts,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
return workflows.workflows[0];
|
|
61
|
+
}
|
|
62
|
+
async getWorkflow(wf) {
|
|
63
|
+
return await this.queue.getWorkflow(wf.id);
|
|
64
|
+
}
|
|
65
|
+
async getWorkflowById(id) {
|
|
66
|
+
return await this.queue.getWorkflow(id);
|
|
67
|
+
}
|
|
68
|
+
async waitForCompletion(wf) {
|
|
69
|
+
while (wf.status !== 'completed' && wf.status !== 'failed') {
|
|
70
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
71
|
+
wf = await this.queue.getWorkflow(wf.id);
|
|
72
|
+
}
|
|
73
|
+
return wf;
|
|
74
|
+
}
|
|
75
|
+
async rescheduleWorkflow(wf, after) {
|
|
76
|
+
await this.queue.reschedule({
|
|
77
|
+
id: wf.id,
|
|
78
|
+
after,
|
|
79
|
+
});
|
|
80
|
+
// TODO: Is this a hack?
|
|
81
|
+
// In the durableworkflow taks I have this piece of code
|
|
82
|
+
//
|
|
83
|
+
// onSuccess: (completedContext: ContextImpl<unknown>) => {
|
|
84
|
+
// // locked status means we own the workflow and it's not completed yet
|
|
85
|
+
// if (wf.status === 'locked') {
|
|
86
|
+
// return;
|
|
87
|
+
// }
|
|
88
|
+
// ctx.queueProvider.complete({
|
|
89
|
+
// id: wf.id,
|
|
90
|
+
// output: btoa(JSON.stringify(completedContext.data)),
|
|
91
|
+
// status: 'completed',
|
|
92
|
+
// });
|
|
93
|
+
// },
|
|
94
|
+
//
|
|
95
|
+
// it basically ignores completing the workflow if it's not locked.
|
|
96
|
+
// the line bellow triggers this
|
|
97
|
+
wf.status = 'available';
|
|
98
|
+
}
|
|
99
|
+
async completeWorkflow(wf, status, output) {
|
|
100
|
+
const outputRaw = output ? Buffer.from(JSON.stringify(output)).toString('base64') : undefined;
|
|
101
|
+
await this.queue.complete({
|
|
102
|
+
id: wf.id,
|
|
103
|
+
output: outputRaw,
|
|
104
|
+
status: status,
|
|
105
|
+
});
|
|
106
|
+
wf.status = status;
|
|
107
|
+
}
|
|
108
|
+
}
|
package/esm/src/context/mod.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
-
export type { Context, CreateIssue, WorkflowOpts } from './Context.js';
|
|
8
7
|
export type { AsyncWorkflow } from './AsyncWorkflow.js';
|
|
8
|
+
export type { Context, CreateIssue } from './Context.js';
|
|
9
9
|
export * from './ContextFunc.js';
|
|
10
|
+
export type { WorkflowOpts } from './WorkflowClient.js';
|
|
10
11
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/context/mod.ts"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/context/mod.ts"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACzD,cAAc,kBAAkB,CAAC;AACjC,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlatformApi } from '
|
|
1
|
+
import { PlatformApi } from '@versori/run/services/platform';
|
|
2
2
|
import { NextFunction, Request, Response } from 'express';
|
|
3
3
|
import { ConnectionFactory } from '../../../connection/types.js';
|
|
4
4
|
import { Logger } from '../../../observability/logging/Logger.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhookmiddleware.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/webhookmiddleware.ts"],"names":[],"mappings":"AAaA,OAAO,EAAc,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"webhookmiddleware.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/webhookmiddleware.ts"],"names":[],"mappings":"AAaA,OAAO,EAAc,WAAW,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,2BAA2B,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,SAAS,EAAE,YAAY,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,6BAA6B,CACzC,IAAI,EAAE,2BAA2B,GAClC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CA4GpE;AAED,wBAAgB,mCAAmC,CAC/C,IAAI,EAAE,2BAA2B,GAClC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAkGpE;AAED,wBAAgB,oCAAoC,CAChD,IAAI,EAAE,2BAA2B,GAClC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAqFpE"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type * as express from 'express';
|
|
2
|
+
import { FetchLike } from '../../connection/types.js';
|
|
3
|
+
import { ActivationImpl } from '../../context/ActivationImpl.js';
|
|
2
4
|
import { AsyncWorkflow } from '../../context/AsyncWorkflow.js';
|
|
3
|
-
import { Context, ContextImpl, CreateIssue
|
|
5
|
+
import { Context, ContextImpl, CreateIssue } from '../../context/Context.js';
|
|
6
|
+
import { WorkflowInterface, WorkflowOpts } from '../../context/WorkflowClient.js';
|
|
4
7
|
import { Issue } from '../../issues/Issues.js';
|
|
5
8
|
import { KeyValue, KeyValueScope } from '../../kv/KeyValue.js';
|
|
6
9
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
7
10
|
import { CredentialsProvider } from '../http/versori/contextcredentials.js';
|
|
8
11
|
import { ArrayTask, Task, Taskable, TaskType } from '../Task.js';
|
|
9
|
-
import { ActivationImpl } from '../../context/ActivationImpl.js';
|
|
10
|
-
import { FetchLike } from '../../connection/types.js';
|
|
11
12
|
/**
|
|
12
13
|
* HttpContext extends the standard {@link Context} with HTTP-specific functionality including an authenticated
|
|
13
14
|
* `fetch` function and connection variables.
|
|
@@ -109,6 +110,7 @@ export declare class HttpContextImpl<D, PageParams> implements HttpContext<D, Pa
|
|
|
109
110
|
}): Promise<Issue | null>;
|
|
110
111
|
nextPage(_nextParams: PageParams): Promise<void>;
|
|
111
112
|
request(): express.Request | undefined;
|
|
113
|
+
workflowClient(): WorkflowInterface;
|
|
112
114
|
}
|
|
113
115
|
/**
|
|
114
116
|
* Create a task that makes HTTP requests using an authenticated connection.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpTask.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/tasks/HttpTask.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"HttpTask.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/tasks/HttpTask.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,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EAAE,UAAU,GAAG,OAAO,EAC1D,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,CAAC,UAAU,CAAC,EAC7B,EAAE,EAAE,eAAe,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,GACzC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAEf"}
|
|
@@ -154,6 +154,9 @@ export class HttpContextImpl {
|
|
|
154
154
|
request() {
|
|
155
155
|
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").request();
|
|
156
156
|
}
|
|
157
|
+
workflowClient() {
|
|
158
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").workflowClient();
|
|
159
|
+
}
|
|
157
160
|
}
|
|
158
161
|
_HttpContextImpl_inner = new WeakMap();
|
|
159
162
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalAuth.d.ts","sourceRoot":"","sources":["../../../src/src/internal/InternalAuth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InternalAuth.d.ts","sourceRoot":"","sources":["../../../src/src/internal/InternalAuth.ts"],"names":[],"mappings":"AAqBA,KAAK,kBAAkB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpD,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,SAAS,CAAS;;IAqCpB,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;CA0BrD"}
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
* As of the Change Date, in accordance with the Business Source License,
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
14
|
-
import { envVarClientId, envVarClientSecret, envVarInternalToken, envVarJwt, envVarLocalRun, envVarTokenEndpoint, } from './constants.js';
|
|
13
|
+
import { envVarClientId, envVarClientSecret, envVarInternalToken, envVarJwt, envVarTokenEndpoint, } from './constants.js';
|
|
15
14
|
export class InternalAuth {
|
|
16
15
|
constructor() {
|
|
17
16
|
Object.defineProperty(this, "clientId", {
|
|
@@ -32,12 +31,6 @@ export class InternalAuth {
|
|
|
32
31
|
writable: true,
|
|
33
32
|
value: void 0
|
|
34
33
|
});
|
|
35
|
-
Object.defineProperty(this, "runLocal", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: void 0
|
|
40
|
-
});
|
|
41
34
|
Object.defineProperty(this, "accessToken", {
|
|
42
35
|
enumerable: true,
|
|
43
36
|
configurable: true,
|
|
@@ -62,7 +55,6 @@ export class InternalAuth {
|
|
|
62
55
|
this.jwt = '';
|
|
63
56
|
this.accessToken = '';
|
|
64
57
|
this.expiresAt = 0;
|
|
65
|
-
this.runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
66
58
|
if (Deno.env.get(envVarInternalToken)) {
|
|
67
59
|
this.accessToken = Deno.env.get(envVarInternalToken) || '';
|
|
68
60
|
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
@@ -75,11 +67,6 @@ export class InternalAuth {
|
|
|
75
67
|
console.log(`Using static JWT provided by ${envVarJwt}`);
|
|
76
68
|
return;
|
|
77
69
|
}
|
|
78
|
-
if (this.runLocal) {
|
|
79
|
-
console.info('Running in local mode using cookie for authentication');
|
|
80
|
-
this.accessToken = getVersoriCookie();
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
70
|
if (!this.clientId || !this.clientSecret || !this.tokenEndpoint) {
|
|
84
71
|
const missingVars = [];
|
|
85
72
|
if (!this.clientId)
|
|
@@ -92,9 +79,6 @@ export class InternalAuth {
|
|
|
92
79
|
}
|
|
93
80
|
}
|
|
94
81
|
async getAuthHeader() {
|
|
95
|
-
if (this.runLocal) {
|
|
96
|
-
return { 'Cookie': this.accessToken };
|
|
97
|
-
}
|
|
98
82
|
if (this.accessToken && this.expiresAt > Date.now()) {
|
|
99
83
|
return { 'X-Versori-Internal-Token': this.accessToken };
|
|
100
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DurableInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/DurableInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AAEtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"DurableInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/DurableInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AAEtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAA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@ -20,7 +20,7 @@ import { CredentialsProviderImpl } from '../../connection/CredentialsProvider.js
|
|
|
20
20
|
import { DirectConnectionFactory } from '../../connection/DirectConnectionFactory.js';
|
|
21
21
|
import { ContextProviderImpl } from '../../context/ContextProvider.js';
|
|
22
22
|
import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
|
|
23
|
-
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId,
|
|
23
|
+
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../dsl/http/versori/constants.js';
|
|
24
24
|
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
25
25
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
26
26
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
@@ -187,10 +187,8 @@ export class DurableInterpreter {
|
|
|
187
187
|
const compiler = options.compiler || new ObservableCompiler();
|
|
188
188
|
const serviceName = Deno.env.get(envVarProjectId) || 'example-service';
|
|
189
189
|
const environmentID = Deno.env.get(envVarEnvId) || 'development';
|
|
190
|
-
const _serviceId = Deno.env.get(envVarProjectId) || 'development';
|
|
191
190
|
const version = Deno.env.get(envVarVersion) || '1.0.0';
|
|
192
191
|
const environment = Deno.env.get(envVarEnvironmentName) || 'development';
|
|
193
|
-
const _sdkAPIBaseURL = Deno.env.get(envVarSDKApiBaseURL) || 'http://localhost:8902';
|
|
194
192
|
const orgId = Deno.env.get(envVarOrgId) || 'development';
|
|
195
193
|
const orgSlug = Deno.env.get(envVarOrgSlug) || 'development';
|
|
196
194
|
const otelTracesURL = Deno.env.get(envVarOtelTracesURL);
|
|
@@ -231,7 +229,7 @@ export class DurableInterpreter {
|
|
|
231
229
|
const platformApi = PlatformApiImpl.fromEnv();
|
|
232
230
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
233
231
|
const environmentId = Deno.env.get(envVarEnvId) || 'development';
|
|
234
|
-
const ctxProvider = new ContextProviderImpl(log, kvp, new CredentialsProviderImpl(connectionFactory.credentials, connectionFactory.tokens, connectionFactory.oauth1, configReader, platformApi), platformApi, organisationId, environmentId, issuesProvider);
|
|
232
|
+
const ctxProvider = new ContextProviderImpl(log, kvp, new CredentialsProviderImpl(connectionFactory.credentials, connectionFactory.tokens, connectionFactory.oauth1, configReader, platformApi), platformApi, organisationId, environmentId, issuesProvider, queueProvider);
|
|
235
233
|
return new DurableInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), PlatformApiImpl.fromEnv(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
|
|
236
234
|
}
|
|
237
235
|
register(workflow, options) {
|
|
@@ -293,7 +291,7 @@ export class DurableInterpreter {
|
|
|
293
291
|
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
294
292
|
registration.subscription = registration.trigger$
|
|
295
293
|
.pipe(tap((ctx) => {
|
|
296
|
-
ctx.log.info('DurableInterpreter.executionStarted', {
|
|
294
|
+
ctx.log.info('DurableInterpreter.executionStarted', {});
|
|
297
295
|
}), mergeMap((ctx) => of(ctx).pipe(registration.task$, catchError((err) => {
|
|
298
296
|
ctx.log.error('DurableInterpreter.executionError', {
|
|
299
297
|
error: err instanceof Error ? err.toString() : err,
|
|
@@ -311,7 +309,7 @@ export class DurableInterpreter {
|
|
|
311
309
|
return EMPTY;
|
|
312
310
|
}))))
|
|
313
311
|
.subscribe({
|
|
314
|
-
next:
|
|
312
|
+
next: (ctx) => {
|
|
315
313
|
const durationMs = Date.now() - ctx.startTime.getTime();
|
|
316
314
|
ctx.log.info('DurableInterpreter.executionCompleted', {
|
|
317
315
|
durationMs,
|
|
@@ -326,17 +324,6 @@ export class DurableInterpreter {
|
|
|
326
324
|
error: err instanceof Error ? err.toString() : err,
|
|
327
325
|
}));
|
|
328
326
|
}
|
|
329
|
-
if (ctx.workflowId) {
|
|
330
|
-
this.log.info('Async workflow completed', {
|
|
331
|
-
workflowId: ctx.workflowId,
|
|
332
|
-
});
|
|
333
|
-
const output = ctx.data ? btoa(JSON.stringify(ctx.data)) : undefined;
|
|
334
|
-
await ctx.queue?.complete({
|
|
335
|
-
id: ctx.workflowId,
|
|
336
|
-
output,
|
|
337
|
-
status: 'completed',
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
327
|
this.contextProvider.destroy(ctx);
|
|
341
328
|
},
|
|
342
329
|
error: (err) => {
|