@versori/run 0.3.0-beta.6 → 0.3.0-beta.9
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/{script/deps/jsr.io/@std/fs/1.0.19 → esm/deps/jsr.io/@std/fs/1.0.20}/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
- package/esm/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/DirectConnectionFactory.js +7 -4
- package/esm/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/esm/src/connection/internal/CredentialHolder.js +2 -11
- package/esm/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/internal/OutboundConnectionFactory.js +1 -0
- package/esm/src/context/AsyncWorkflow.js +1 -1
- package/esm/src/context/Context.d.ts +6 -7
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +13 -3
- 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 +29 -0
- package/esm/src/context/WorkflowClient.d.ts.map +1 -0
- package/esm/src/context/WorkflowClient.js +95 -0
- 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/http/versori/webhookmiddleware.js +18 -10
- package/esm/src/dsl/tasks/HttpTask.d.ts +2 -1
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +3 -0
- package/esm/src/dsl/triggers/DurableTrigger.d.ts +0 -1
- package/esm/src/dsl/triggers/DurableTrigger.d.ts.map +1 -1
- 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 -14
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +2 -20
- package/esm/src/interpreter/durable/Queue.d.ts +24 -16
- package/esm/src/interpreter/durable/Queue.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.js +3 -4
- 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 +19 -19
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +0 -1
- package/esm/src/interpreter/memory/compilers/catch.js +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/{esm/deps/jsr.io/@std/fs/1.0.19 → script/deps/jsr.io/@std/fs/1.0.20}/exists.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
- package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/DirectConnectionFactory.js +7 -4
- package/script/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/script/src/connection/internal/CredentialHolder.js +2 -11
- package/script/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/internal/OutboundConnectionFactory.js +1 -0
- package/script/src/context/AsyncWorkflow.js +1 -1
- package/script/src/context/Context.d.ts +6 -7
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +13 -3
- 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 +29 -0
- package/script/src/context/WorkflowClient.d.ts.map +1 -0
- package/script/src/context/WorkflowClient.js +99 -0
- 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/http/versori/webhookmiddleware.js +18 -10
- package/script/src/dsl/tasks/HttpTask.d.ts +2 -1
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +3 -0
- package/script/src/dsl/triggers/DurableTrigger.d.ts +0 -1
- package/script/src/dsl/triggers/DurableTrigger.d.ts.map +1 -1
- 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 -13
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +1 -19
- package/script/src/interpreter/durable/Queue.d.ts +24 -16
- package/script/src/interpreter/durable/Queue.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.js +3 -4
- 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 +19 -19
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +0 -1
- package/script/src/interpreter/memory/compilers/catch.js +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 -20
- package/esm/src/services/createConnectRpcClient.d.ts +0 -16
- package/esm/src/services/createConnectRpcClient.d.ts.map +0 -1
- package/esm/src/services/createConnectRpcClient.js +0 -63
- 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 -23
- package/script/src/services/createConnectRpcClient.d.ts +0 -16
- package/script/src/services/createConnectRpcClient.d.ts.map +0 -1
- package/script/src/services/createConnectRpcClient.js +0 -66
- /package/esm/deps/jsr.io/@std/fs/{1.0.19 → 1.0.20}/exists.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fs/{1.0.19 → 1.0.20}/exists.js +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.19 → 1.0.20}/exists.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.19 → 1.0.20}/exists.js +0 -0
|
@@ -60,8 +60,7 @@ class ContextProviderImpl {
|
|
|
60
60
|
this.issues = issues;
|
|
61
61
|
this.queue = queue;
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
const executionId = (0, mod_js_1.ulid)();
|
|
63
|
+
createWithExecutionId(activation, data, executionId, options = {}) {
|
|
65
64
|
const logger = this.log.child({
|
|
66
65
|
executionId,
|
|
67
66
|
activationId: activation.id,
|
|
@@ -70,6 +69,10 @@ class ContextProviderImpl {
|
|
|
70
69
|
const activationImpl = new ActivationImpl_js_1.ActivationImpl(activation, this.platformApi, this.organisationId, this.environmentId, logger);
|
|
71
70
|
return new Context_js_1.ContextImpl(logger, this.kvp, this.creds, executionId, new Date(), data, activationImpl, this.issues, this.queue, options);
|
|
72
71
|
}
|
|
72
|
+
create(activation, data, options = {}) {
|
|
73
|
+
const executionId = (0, mod_js_1.ulid)();
|
|
74
|
+
return this.createWithExecutionId(activation, data, executionId, options);
|
|
75
|
+
}
|
|
73
76
|
destroy(_) {
|
|
74
77
|
return Promise.resolve();
|
|
75
78
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { QueueAPI } from '../interpreter/durable/Queue.js';
|
|
2
|
+
import { Workflow } from '../interpreter/durable/Queue.js';
|
|
3
|
+
import { ActivationImpl } from './ActivationImpl.js';
|
|
4
|
+
export type WorkflowOpts = {
|
|
5
|
+
maxAttempts?: number;
|
|
6
|
+
data?: unknown;
|
|
7
|
+
dataRaw?: string;
|
|
8
|
+
};
|
|
9
|
+
export interface WorkflowInterface {
|
|
10
|
+
startWorkflow(group: string, opts: WorkflowOpts): Promise<Workflow>;
|
|
11
|
+
getWorkflow(wfs: Workflow): Promise<Workflow>;
|
|
12
|
+
getWorkflowById(id: string): Promise<Workflow>;
|
|
13
|
+
waitForCompletion(wf: Workflow): Promise<Workflow>;
|
|
14
|
+
rescheduleWorkflow(wf: Workflow, after: string): Promise<void>;
|
|
15
|
+
completeWorkflow(wf: Workflow, status: 'completed' | 'failed', output?: any): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare class WorkflowImpl implements WorkflowInterface {
|
|
18
|
+
private queue;
|
|
19
|
+
private executionId;
|
|
20
|
+
private activation;
|
|
21
|
+
constructor(queue: QueueAPI, executionId: string, activation: ActivationImpl);
|
|
22
|
+
startWorkflow(group: string, opts: WorkflowOpts): Promise<Workflow>;
|
|
23
|
+
getWorkflow(wf: Workflow): Promise<Workflow>;
|
|
24
|
+
getWorkflowById(id: string): Promise<Workflow>;
|
|
25
|
+
waitForCompletion(wf: Workflow): Promise<Workflow>;
|
|
26
|
+
rescheduleWorkflow(wf: Workflow, after: string): Promise<void>;
|
|
27
|
+
completeWorkflow(wf: Workflow, status: 'completed' | 'failed', output?: any): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=WorkflowClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkflowClient.d.ts","sourceRoot":"","sources":["../../../src/src/context/WorkflowClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,MAAM,MAAM,YAAY,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAC9B,a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GAAG,QAAQ,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAYpG"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowImpl = void 0;
|
|
4
|
+
class WorkflowImpl {
|
|
5
|
+
constructor(queue, executionId, activation) {
|
|
6
|
+
Object.defineProperty(this, "queue", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: void 0
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "executionId", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "activation", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
this.queue = queue;
|
|
25
|
+
this.executionId = executionId;
|
|
26
|
+
this.activation = activation;
|
|
27
|
+
// I have no idea if I need this but I have suffered from it in the past
|
|
28
|
+
this.startWorkflow = this.startWorkflow.bind(this);
|
|
29
|
+
this.getWorkflow = this.getWorkflow.bind(this);
|
|
30
|
+
this.waitForCompletion = this.waitForCompletion.bind(this);
|
|
31
|
+
this.rescheduleWorkflow = this.rescheduleWorkflow.bind(this);
|
|
32
|
+
this.completeWorkflow = this.completeWorkflow.bind(this);
|
|
33
|
+
this.getWorkflowById = this.getWorkflowById.bind(this);
|
|
34
|
+
}
|
|
35
|
+
async startWorkflow(group, opts) {
|
|
36
|
+
const workflows = await this.queue.submit({
|
|
37
|
+
workflows: [
|
|
38
|
+
{
|
|
39
|
+
group,
|
|
40
|
+
metadata: {
|
|
41
|
+
executionId: this.executionId,
|
|
42
|
+
activationId: this.activation?.id,
|
|
43
|
+
userId: this.activation?.user?.externalId,
|
|
44
|
+
},
|
|
45
|
+
payload: opts.data ? btoa(JSON.stringify(opts.data)) : btoa("{}"),
|
|
46
|
+
maxAttempts: opts.maxAttempts,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
return workflows.workflows[0];
|
|
51
|
+
}
|
|
52
|
+
async getWorkflow(wf) {
|
|
53
|
+
return await this.queue.getWorkflow(wf.id);
|
|
54
|
+
}
|
|
55
|
+
async getWorkflowById(id) {
|
|
56
|
+
return await this.queue.getWorkflow(id);
|
|
57
|
+
}
|
|
58
|
+
async waitForCompletion(wf) {
|
|
59
|
+
while (wf.status !== 'completed' && wf.status !== 'failed') {
|
|
60
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
61
|
+
wf = await this.queue.getWorkflow(wf.id);
|
|
62
|
+
}
|
|
63
|
+
return wf;
|
|
64
|
+
}
|
|
65
|
+
async rescheduleWorkflow(wf, after) {
|
|
66
|
+
await this.queue.reschedule({
|
|
67
|
+
id: wf.id,
|
|
68
|
+
after,
|
|
69
|
+
});
|
|
70
|
+
// TODO: Is this a hack?
|
|
71
|
+
// In the durableworkflow taks I have this piece of code
|
|
72
|
+
//
|
|
73
|
+
// onSuccess: (completedContext: ContextImpl<unknown>) => {
|
|
74
|
+
// // locked status means we own the workflow and it's not completed yet
|
|
75
|
+
// if (wf.status === 'locked') {
|
|
76
|
+
// return;
|
|
77
|
+
// }
|
|
78
|
+
// ctx.queueProvider.complete({
|
|
79
|
+
// id: wf.id,
|
|
80
|
+
// output: btoa(JSON.stringify(completedContext.data)),
|
|
81
|
+
// status: 'completed',
|
|
82
|
+
// });
|
|
83
|
+
// },
|
|
84
|
+
//
|
|
85
|
+
// it basically ignores completing the workflow if it's not locked.
|
|
86
|
+
// the line bellow triggers this
|
|
87
|
+
wf.status = 'available';
|
|
88
|
+
}
|
|
89
|
+
async completeWorkflow(wf, status, output) {
|
|
90
|
+
const outputRaw = output ? btoa(JSON.stringify(output)) : undefined;
|
|
91
|
+
await this.queue.complete({
|
|
92
|
+
id: wf.id,
|
|
93
|
+
output: outputRaw,
|
|
94
|
+
status: status,
|
|
95
|
+
});
|
|
96
|
+
wf.status = status;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.WorkflowImpl = WorkflowImpl;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from 'express';
|
|
2
2
|
import { ConnectionFactory } from '../../../connection/types.js';
|
|
3
3
|
import { Logger } from '../../../observability/mod.js';
|
|
4
|
-
import { PlatformApi } from '../../../services/platform/mod.js';
|
|
5
4
|
import { ConfigReader } from '../types.js';
|
|
5
|
+
import { PlatformApi } from '../../../services/platform/mod.js';
|
|
6
6
|
export type CreateWebhookMiddleWareOpts = {
|
|
7
7
|
id: string;
|
|
8
8
|
organisationId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhookmiddleware.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/webhookmiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"webhookmiddleware.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/webhookmiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAc,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAU5E,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;AAyCF,wBAAgB,6BAA6B,CACzC,IAAI,EAAE,2BAA2B,GAClC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAqEpE;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,CA6DpE;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"}
|
|
@@ -5,16 +5,24 @@ exports.createActIdDynamicWebhookMiddleware = createActIdDynamicWebhookMiddlewar
|
|
|
5
5
|
exports.createUserIdDynamicWebhookMiddleware = createUserIdDynamicWebhookMiddleware;
|
|
6
6
|
// TODO: this gets called for every request for all endpoints, can we cache this?
|
|
7
7
|
async function getStaticActivation(opts) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
let activations;
|
|
9
|
+
try {
|
|
10
|
+
const { data } = await opts.platformApi.listActivations({
|
|
11
|
+
path: {
|
|
12
|
+
organisation_id: opts.organisationId,
|
|
13
|
+
environment_id: opts.environmentId,
|
|
14
|
+
},
|
|
15
|
+
query: {
|
|
16
|
+
static: true,
|
|
17
|
+
},
|
|
18
|
+
throwOnError: true,
|
|
19
|
+
});
|
|
20
|
+
activations = data;
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
opts.log.error('Failed to list activations', { error: err });
|
|
24
|
+
throw new Error('Failed to list activations');
|
|
25
|
+
}
|
|
18
26
|
let activation;
|
|
19
27
|
if (activations && activations.length > 0) {
|
|
20
28
|
if (activations.length > 1) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as express from 'express';
|
|
2
2
|
import { AsyncWorkflow } from '../../context/AsyncWorkflow.js';
|
|
3
3
|
import { Context, ContextImpl, CreateIssue } from '../../context/Context.js';
|
|
4
|
+
import { WorkflowInterface, WorkflowOpts } from '../../context/WorkflowClient.js';
|
|
4
5
|
import { Issue } from '../../issues/Issues.js';
|
|
5
6
|
import { KeyValue, KeyValueScope } from '../../kv/KeyValue.js';
|
|
6
|
-
import { WorkflowOpts } from '../../mod.js';
|
|
7
7
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
8
8
|
import { CredentialsProvider } from '../http/versori/contextcredentials.js';
|
|
9
9
|
import { ArrayTask, Task, Taskable, TaskType } from '../Task.js';
|
|
@@ -59,6 +59,7 @@ export declare class HttpContextImpl<D, PageParams> implements HttpContext<D, Pa
|
|
|
59
59
|
}): Promise<Issue | null>;
|
|
60
60
|
nextPage(_nextParams: PageParams): Promise<void>;
|
|
61
61
|
request(): express.Request | undefined;
|
|
62
|
+
workflowClient(): WorkflowInterface;
|
|
62
63
|
}
|
|
63
64
|
export declare function http<In = any, Out = any, PageParams = unknown>(taskId: string, opts: HttpOptions<In, Out, PageParams>, fn: HttpContextFunc<In, Out, PageParams>): Task<In, Out>;
|
|
64
65
|
//# sourceMappingURL=HttpTask.d.ts.map
|
|
@@ -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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AAC;IAI7E,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QACtC,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAIzB,QAAQ,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS;IAItC,cAAc,IAAI,iBAAiB;CAGtC;AAED,wBAAgB,IAAI,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,UAAU,GAAG,OAAO,EAC1D,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,EACtC,EAAE,EAAE,eAAe,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,GACzC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAEf"}
|
|
@@ -147,6 +147,9 @@ class HttpContextImpl {
|
|
|
147
147
|
request() {
|
|
148
148
|
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").request();
|
|
149
149
|
}
|
|
150
|
+
workflowClient() {
|
|
151
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").workflowClient();
|
|
152
|
+
}
|
|
150
153
|
}
|
|
151
154
|
exports.HttpContextImpl = HttpContextImpl;
|
|
152
155
|
_HttpContextImpl_inner = new WeakMap();
|
|
@@ -4,7 +4,6 @@ import { Workflow } from '../Workflow.js';
|
|
|
4
4
|
export type DurableWorkflowOptions = {
|
|
5
5
|
ttl?: number;
|
|
6
6
|
limit?: number;
|
|
7
|
-
maxAttempts?: number;
|
|
8
7
|
};
|
|
9
8
|
export type DurableWorkflowData = Record<string, unknown>;
|
|
10
9
|
export declare class DurableWorkflowTrigger implements Trigger<DurableWorkflowData> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DurableTrigger.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/triggers/DurableTrigger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAExD,MAAM,MAAM,sBAAsB,GAAG;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"DurableTrigger.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/triggers/DurableTrigger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAExD,MAAM,MAAM,sBAAsB,GAAG;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1D,qBAAa,sBAAuB,YAAW,OAAO,CAAC,mBAAmB,CAAC;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,sBAAsB,CAAC;IAEhC,CAAC,WAAW,CAAC,EAAE,MAAM,CAAqB;gBAE9B,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B;IAK5D,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,mBAAmB,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;CAIlE;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAEnG"}
|
|
@@ -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":"AAOA,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,SAAS,CAAS;;IA2BpB,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;CAsBrD"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InternalAuth = void 0;
|
|
4
|
-
const cli_js_1 = require("./cli.js");
|
|
5
4
|
const constants_js_1 = require("./constants.js");
|
|
6
5
|
class InternalAuth {
|
|
7
6
|
constructor() {
|
|
@@ -23,12 +22,6 @@ class InternalAuth {
|
|
|
23
22
|
writable: true,
|
|
24
23
|
value: void 0
|
|
25
24
|
});
|
|
26
|
-
Object.defineProperty(this, "runLocal", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true,
|
|
30
|
-
value: void 0
|
|
31
|
-
});
|
|
32
25
|
Object.defineProperty(this, "accessToken", {
|
|
33
26
|
enumerable: true,
|
|
34
27
|
configurable: true,
|
|
@@ -46,18 +39,12 @@ class InternalAuth {
|
|
|
46
39
|
this.tokenEndpoint = Deno.env.get(constants_js_1.envVarTokenEndpoint) || '';
|
|
47
40
|
this.accessToken = '';
|
|
48
41
|
this.expiresAt = 0;
|
|
49
|
-
this.runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
|
|
50
42
|
if (Deno.env.get(constants_js_1.envVarInternalToken)) {
|
|
51
43
|
this.accessToken = Deno.env.get(constants_js_1.envVarInternalToken) || '';
|
|
52
44
|
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
53
45
|
console.log(`Using static token provided by ${constants_js_1.envVarInternalToken}`);
|
|
54
46
|
return;
|
|
55
47
|
}
|
|
56
|
-
if (this.runLocal) {
|
|
57
|
-
console.info('Running in local mode using cookie for authentication');
|
|
58
|
-
this.accessToken = (0, cli_js_1.getVersoriCookie)();
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
48
|
if (!this.clientId || !this.clientSecret || !this.tokenEndpoint) {
|
|
62
49
|
const missingVars = [];
|
|
63
50
|
if (!this.clientId)
|
|
@@ -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;
|
|
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;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAuB,M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tB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAO9B"}
|
|
@@ -19,16 +19,12 @@ const cronapi_js_1 = require("../../dsl/http/versori/cronapi.js");
|
|
|
19
19
|
const proxyroundtripper_js_1 = require("../../dsl/http/versori/proxyroundtripper.js");
|
|
20
20
|
const Workflow_js_1 = require("../../dsl/Workflow.js");
|
|
21
21
|
const Issues_js_1 = require("../../issues/Issues.js");
|
|
22
|
-
const MemoryKeyValueProvider_js_1 = require("../../kv/memory/MemoryKeyValueProvider.js");
|
|
23
22
|
const SDKKeyValueProvider_js_1 = require("../../kv/sdk/SDKKeyValueProvider.js");
|
|
24
23
|
const ConsoleLogger_js_1 = require("../../observability/logging/ConsoleLogger.js");
|
|
25
24
|
const PlatformApi_js_1 = require("../../services/platform/PlatformApi.js");
|
|
26
25
|
const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
|
|
27
26
|
const Queue_js_1 = require("./Queue.js");
|
|
28
27
|
function getKVProvider(runLocal) {
|
|
29
|
-
if (runLocal) {
|
|
30
|
-
return Promise.resolve(new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider());
|
|
31
|
-
}
|
|
32
28
|
return SDKKeyValueProvider_js_1.SDKKeyValueProvider.fromEnv();
|
|
33
29
|
}
|
|
34
30
|
function getRoundTripperFactory(log, tracer, opts) {
|
|
@@ -166,10 +162,8 @@ class DurableInterpreter {
|
|
|
166
162
|
const compiler = options.compiler || new ObservableCompiler_js_1.ObservableCompiler();
|
|
167
163
|
const serviceName = Deno.env.get(constants_js_1.envVarProjectId) || 'example-service';
|
|
168
164
|
const environmentID = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
169
|
-
const serviceId = Deno.env.get(constants_js_1.envVarProjectId) || 'development';
|
|
170
165
|
const version = Deno.env.get(constants_js_1.envVarVersion) || '1.0.0';
|
|
171
166
|
const environment = Deno.env.get(constants_js_1.envVarEnvironmentName) || 'development';
|
|
172
|
-
const sdkAPIBaseURL = Deno.env.get(constants_js_1.envVarSDKApiBaseURL) || 'http://localhost:8902';
|
|
173
167
|
const orgId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
|
|
174
168
|
const orgSlug = Deno.env.get(constants_js_1.envVarOrgSlug) || 'development';
|
|
175
169
|
const otelTracesURL = Deno.env.get(constants_js_1.envVarOtelTracesURL);
|
|
@@ -213,7 +207,7 @@ class DurableInterpreter {
|
|
|
213
207
|
const platformApi = PlatformApi_js_1.PlatformApiImpl.fromEnv();
|
|
214
208
|
const organisationId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
|
|
215
209
|
const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
216
|
-
const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp, roundTripperFactory.credentials(), platformApi, organisationId, environmentId, issuesProvider);
|
|
210
|
+
const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp, roundTripperFactory.credentials(), platformApi, organisationId, environmentId, issuesProvider, queueProvider);
|
|
217
211
|
return new DurableInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), PlatformApi_js_1.PlatformApiImpl.fromEnv(), DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log), cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
|
|
218
212
|
}
|
|
219
213
|
register(workflow, options) {
|
|
@@ -297,7 +291,6 @@ class DurableInterpreter {
|
|
|
297
291
|
const durationMs = Date.now() - ctx.startTime.getTime();
|
|
298
292
|
ctx.log.info('DurableInterpreter.executionCompleted', {
|
|
299
293
|
durationMs,
|
|
300
|
-
data: ctx.data,
|
|
301
294
|
});
|
|
302
295
|
try {
|
|
303
296
|
ctx.options.onSuccess?.(ctx);
|
|
@@ -309,17 +302,6 @@ class DurableInterpreter {
|
|
|
309
302
|
error: err instanceof Error ? err.toString() : err,
|
|
310
303
|
}));
|
|
311
304
|
}
|
|
312
|
-
if (ctx.workflowId) {
|
|
313
|
-
this.log.info('Async workflow completed', {
|
|
314
|
-
workflowId: ctx.workflowId,
|
|
315
|
-
});
|
|
316
|
-
const output = ctx.data ? btoa(JSON.stringify(ctx.data)) : undefined;
|
|
317
|
-
await ctx.queue?.complete({
|
|
318
|
-
id: ctx.workflowId,
|
|
319
|
-
output,
|
|
320
|
-
status: 'completed',
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
305
|
this.contextProvider.destroy(ctx);
|
|
324
306
|
},
|
|
325
307
|
error: (err) => {
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import { Logger } from '../../observability/mod.js';
|
|
2
2
|
export type WorkflowMsgMetadata = {
|
|
3
3
|
parentWorkflowId?: string;
|
|
4
|
-
executionId
|
|
5
|
-
activationId
|
|
4
|
+
executionId: string;
|
|
5
|
+
activationId: string;
|
|
6
6
|
userId?: string;
|
|
7
7
|
};
|
|
8
8
|
export type Workflows = {
|
|
9
|
-
workflows:
|
|
9
|
+
workflows: Workflow[];
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
12
|
-
id
|
|
13
|
-
projectId
|
|
14
|
-
environmentId
|
|
11
|
+
export type Workflow = {
|
|
12
|
+
id: string;
|
|
13
|
+
projectId: string;
|
|
14
|
+
environmentId: string;
|
|
15
15
|
group: string;
|
|
16
|
-
payload
|
|
16
|
+
payload: string;
|
|
17
17
|
output?: string;
|
|
18
18
|
status?: 'available' | 'locked' | 'completed' | 'failed';
|
|
19
|
-
attempt
|
|
19
|
+
attempt: number;
|
|
20
|
+
maxAttempts?: number;
|
|
21
|
+
timeout: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
metadata: WorkflowMsgMetadata;
|
|
24
|
+
};
|
|
25
|
+
export type SubmitWorkflow = {
|
|
26
|
+
group: string;
|
|
27
|
+
payload: string;
|
|
20
28
|
maxAttempts?: number;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
metadata: WorkflowMsgMetadata;
|
|
30
|
+
projectId?: string;
|
|
31
|
+
environmentId?: string;
|
|
24
32
|
};
|
|
25
33
|
export type CompleteWorkflowRequest = {
|
|
26
34
|
id: string;
|
|
@@ -39,14 +47,14 @@ export type RescheduleWorkflowRequest = {
|
|
|
39
47
|
after: string;
|
|
40
48
|
};
|
|
41
49
|
export type SubmitWorkflowsRequest = {
|
|
42
|
-
workflows:
|
|
50
|
+
workflows: SubmitWorkflow[];
|
|
43
51
|
};
|
|
44
52
|
export interface QueueAPI {
|
|
45
53
|
complete(request: CompleteWorkflowRequest): Promise<void>;
|
|
46
54
|
submit(request: SubmitWorkflowsRequest): Promise<Workflows>;
|
|
47
55
|
fetchWorkflows(request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
|
|
48
56
|
reschedule(request: RescheduleWorkflowRequest): Promise<void>;
|
|
49
|
-
|
|
57
|
+
getWorkflow(workflowId: string): Promise<Workflow>;
|
|
50
58
|
}
|
|
51
59
|
export declare class QueueImpl implements QueueAPI {
|
|
52
60
|
private baseUrl;
|
|
@@ -59,7 +67,7 @@ export declare class QueueImpl implements QueueAPI {
|
|
|
59
67
|
submit(request: SubmitWorkflowsRequest): Promise<Workflows>;
|
|
60
68
|
fetchWorkflows(request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
|
|
61
69
|
reschedule(request: RescheduleWorkflowRequest): Promise<void>;
|
|
62
|
-
|
|
70
|
+
getWorkflow(workflowId: string): Promise<Workflow>;
|
|
63
71
|
}
|
|
64
72
|
export declare class MockQueue implements QueueAPI {
|
|
65
73
|
constructor();
|
|
@@ -67,6 +75,6 @@ export declare class MockQueue implements QueueAPI {
|
|
|
67
75
|
submit(_request: SubmitWorkflowsRequest): Promise<Workflows>;
|
|
68
76
|
fetchWorkflows(_request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
|
|
69
77
|
reschedule(_request: RescheduleWorkflowRequest): Promise<void>;
|
|
70
|
-
|
|
78
|
+
getWorkflow(_workflowId: string): Promise<Workflow>;
|
|
71
79
|
}
|
|
72
80
|
//# sourceMappingURL=Queue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/Queue.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,
|
|
1
|
+
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/Queue.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACpB,SAAS,EAAE,QAAQ,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,mBAAmB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,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AS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAOlF,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;IAehC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBzD,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC;IA2B3D,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAoC9E,UAAU,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB7D,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CAc3D;AAGD,qBAAa,SAAU,YAAW,QAAQ;;IAGtC,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAG1D,MAAM,CAAC,QAAQ,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC;IAG5D,cAAc,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAG/E,UAAU,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAG9D,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CAGtD"}
|
|
@@ -60,7 +60,7 @@ class QueueImpl {
|
|
|
60
60
|
output: request.output,
|
|
61
61
|
status: request.status,
|
|
62
62
|
});
|
|
63
|
-
throw new Error(
|
|
63
|
+
throw new Error(await resp.text());
|
|
64
64
|
}
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
@@ -133,8 +133,7 @@ class QueueImpl {
|
|
|
133
133
|
}
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
async
|
|
137
|
-
// this endpoint returns a 404 if the workflow is not completed
|
|
136
|
+
async getWorkflow(workflowId) {
|
|
138
137
|
const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch/${workflowId}`, {
|
|
139
138
|
method: 'GET',
|
|
140
139
|
});
|
|
@@ -162,7 +161,7 @@ class MockQueue {
|
|
|
162
161
|
reschedule(_request) {
|
|
163
162
|
throw new Error('Method not implemented.');
|
|
164
163
|
}
|
|
165
|
-
|
|
164
|
+
getWorkflow(_workflowId) {
|
|
166
165
|
throw new Error('Method not implemented.');
|
|
167
166
|
}
|
|
168
167
|
}
|
|
@@ -26,7 +26,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
26
26
|
annotations: {
|
|
27
27
|
'error': error.message,
|
|
28
28
|
'stack': error.stack || '',
|
|
29
|
-
'workflowId': ctx.options.
|
|
29
|
+
'workflowId': ctx.options.workflow?.id || ctx.workflow?.id ||
|
|
30
30
|
'',
|
|
31
31
|
'executionId': ctx.executionId,
|
|
32
32
|
},
|
|
@@ -42,7 +42,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
42
42
|
annotations: {
|
|
43
43
|
'error': error.message || '',
|
|
44
44
|
'stack': error.stack || '',
|
|
45
|
-
'workflowId': ctx.options.
|
|
45
|
+
'workflowId': ctx.options.workflow?.id || ctx.workflow?.id ||
|
|
46
46
|
'',
|
|
47
47
|
'executionId': ctx.executionId,
|
|
48
48
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAW,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAK3C,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CA8F9C;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAIhG,CAAC"}
|
|
@@ -5,6 +5,7 @@ exports.compileDurableWorkflow = compileDurableWorkflow;
|
|
|
5
5
|
const rxjs_1 = require("rxjs");
|
|
6
6
|
const DurableTrigger_js_1 = require("../../../dsl/triggers/DurableTrigger.js");
|
|
7
7
|
const constants_js_1 = require("../../../internal/constants.js");
|
|
8
|
+
const mod_js_1 = require("../../../../deps/jsr.io/@std/ulid/1.0.0/mod.js");
|
|
8
9
|
function compileDurableWorkflow(ctx, trigger, signal) {
|
|
9
10
|
return new rxjs_1.Observable((subscriber) => {
|
|
10
11
|
function cleanup() {
|
|
@@ -39,24 +40,9 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
39
40
|
continue;
|
|
40
41
|
}
|
|
41
42
|
for (const wf of wfs.workflows) {
|
|
42
|
-
if (wf.id &&
|
|
43
|
-
wf.attempt !== undefined &&
|
|
44
|
-
trigger.options.maxAttempts &&
|
|
45
|
-
wf.attempt > trigger.options.maxAttempts) {
|
|
46
|
-
ctx.log.error('Workflow exceeded max attempts failing', {
|
|
47
|
-
workflowId: wf.id,
|
|
48
|
-
attempts: wf.attempt,
|
|
49
|
-
});
|
|
50
|
-
await ctx.queueProvider.complete({
|
|
51
|
-
id: wf.id,
|
|
52
|
-
output: wf.output,
|
|
53
|
-
status: 'failed',
|
|
54
|
-
});
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
43
|
const data = JSON.parse(atob(wf.payload ?? '{}'));
|
|
58
44
|
let activation;
|
|
59
|
-
|
|
45
|
+
try {
|
|
60
46
|
const { data } = await ctx.platformApi.getActivation({
|
|
61
47
|
path: {
|
|
62
48
|
activation_id: wf.metadata.activationId,
|
|
@@ -67,9 +53,23 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
67
53
|
});
|
|
68
54
|
activation = data;
|
|
69
55
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
56
|
+
catch (error) {
|
|
57
|
+
ctx.log.error('Failed to get activation', { error });
|
|
58
|
+
throw new Error('Failed to get activation');
|
|
59
|
+
}
|
|
60
|
+
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata.executionId ?? (0, mod_js_1.ulid)().toString(), {
|
|
61
|
+
workflow: wf,
|
|
62
|
+
onSuccess: (completedContext) => {
|
|
63
|
+
// locked status means we own the workflow and it's not completed yet
|
|
64
|
+
if (wf.status !== 'locked') {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
ctx.queueProvider.complete({
|
|
68
|
+
id: wf.id,
|
|
69
|
+
output: btoa(JSON.stringify(completedContext.data)),
|
|
70
|
+
status: 'completed',
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
73
|
});
|
|
74
74
|
consecutiveErrors = 0;
|
|
75
75
|
subscriber.next(newContext);
|