@versori/run 0.4.25 → 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
|
@@ -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>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=WorkflowClient.d.ts.map
|
|
@@ -0,0 +1 @@
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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,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
4
|
+
*
|
|
5
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
6
|
+
* included in the LICENSE file at the root of this repository.
|
|
7
|
+
*
|
|
8
|
+
* Change Date: 2029-01-01
|
|
9
|
+
* Change License: Apache License, Version 2.0
|
|
10
|
+
*
|
|
11
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
12
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.WorkflowImpl = void 0;
|
|
16
|
+
const node_buffer_1 = require("node:buffer");
|
|
17
|
+
class WorkflowImpl {
|
|
18
|
+
constructor(queue, executionId, activation) {
|
|
19
|
+
Object.defineProperty(this, "queue", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "executionId", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: void 0
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(this, "activation", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
this.queue = queue;
|
|
38
|
+
this.executionId = executionId;
|
|
39
|
+
this.activation = activation;
|
|
40
|
+
// I have no idea if I need this but I have suffered from it in the past
|
|
41
|
+
this.startWorkflow = this.startWorkflow.bind(this);
|
|
42
|
+
this.getWorkflow = this.getWorkflow.bind(this);
|
|
43
|
+
this.waitForCompletion = this.waitForCompletion.bind(this);
|
|
44
|
+
this.rescheduleWorkflow = this.rescheduleWorkflow.bind(this);
|
|
45
|
+
this.completeWorkflow = this.completeWorkflow.bind(this);
|
|
46
|
+
this.getWorkflowById = this.getWorkflowById.bind(this);
|
|
47
|
+
}
|
|
48
|
+
async startWorkflow(group, opts) {
|
|
49
|
+
const workflows = await this.queue.submit({
|
|
50
|
+
workflows: [
|
|
51
|
+
{
|
|
52
|
+
group,
|
|
53
|
+
metadata: {
|
|
54
|
+
executionId: this.executionId,
|
|
55
|
+
activationId: this.activation?.id,
|
|
56
|
+
userId: this.activation?.user?.externalId,
|
|
57
|
+
},
|
|
58
|
+
payload: opts.data ? node_buffer_1.Buffer.from(JSON.stringify(opts.data)).toString('base64') : node_buffer_1.Buffer.from("{}").toString('base64'),
|
|
59
|
+
maxAttempts: opts.maxAttempts,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
return workflows.workflows[0];
|
|
64
|
+
}
|
|
65
|
+
async getWorkflow(wf) {
|
|
66
|
+
return await this.queue.getWorkflow(wf.id);
|
|
67
|
+
}
|
|
68
|
+
async getWorkflowById(id) {
|
|
69
|
+
return await this.queue.getWorkflow(id);
|
|
70
|
+
}
|
|
71
|
+
async waitForCompletion(wf) {
|
|
72
|
+
while (wf.status !== 'completed' && wf.status !== 'failed') {
|
|
73
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
74
|
+
wf = await this.queue.getWorkflow(wf.id);
|
|
75
|
+
}
|
|
76
|
+
return wf;
|
|
77
|
+
}
|
|
78
|
+
async rescheduleWorkflow(wf, after) {
|
|
79
|
+
await this.queue.reschedule({
|
|
80
|
+
id: wf.id,
|
|
81
|
+
after,
|
|
82
|
+
});
|
|
83
|
+
// TODO: Is this a hack?
|
|
84
|
+
// In the durableworkflow taks I have this piece of code
|
|
85
|
+
//
|
|
86
|
+
// onSuccess: (completedContext: ContextImpl<unknown>) => {
|
|
87
|
+
// // locked status means we own the workflow and it's not completed yet
|
|
88
|
+
// if (wf.status === 'locked') {
|
|
89
|
+
// return;
|
|
90
|
+
// }
|
|
91
|
+
// ctx.queueProvider.complete({
|
|
92
|
+
// id: wf.id,
|
|
93
|
+
// output: btoa(JSON.stringify(completedContext.data)),
|
|
94
|
+
// status: 'completed',
|
|
95
|
+
// });
|
|
96
|
+
// },
|
|
97
|
+
//
|
|
98
|
+
// it basically ignores completing the workflow if it's not locked.
|
|
99
|
+
// the line bellow triggers this
|
|
100
|
+
wf.status = 'available';
|
|
101
|
+
}
|
|
102
|
+
async completeWorkflow(wf, status, output) {
|
|
103
|
+
const outputRaw = output ? node_buffer_1.Buffer.from(JSON.stringify(output)).toString('base64') : undefined;
|
|
104
|
+
await this.queue.complete({
|
|
105
|
+
id: wf.id,
|
|
106
|
+
output: outputRaw,
|
|
107
|
+
status: status,
|
|
108
|
+
});
|
|
109
|
+
wf.status = status;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.WorkflowImpl = WorkflowImpl;
|
|
@@ -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,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AI,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,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"}
|
|
@@ -159,6 +159,9 @@ class HttpContextImpl {
|
|
|
159
159
|
request() {
|
|
160
160
|
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").request();
|
|
161
161
|
}
|
|
162
|
+
workflowClient() {
|
|
163
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").workflowClient();
|
|
164
|
+
}
|
|
162
165
|
}
|
|
163
166
|
exports.HttpContextImpl = HttpContextImpl;
|
|
164
167
|
_HttpContextImpl_inner = new WeakMap();
|
|
@@ -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"}
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.InternalAuth = void 0;
|
|
16
|
-
const cli_js_1 = require("./cli.js");
|
|
17
16
|
const constants_js_1 = require("./constants.js");
|
|
18
17
|
class InternalAuth {
|
|
19
18
|
constructor() {
|
|
@@ -35,12 +34,6 @@ class InternalAuth {
|
|
|
35
34
|
writable: true,
|
|
36
35
|
value: void 0
|
|
37
36
|
});
|
|
38
|
-
Object.defineProperty(this, "runLocal", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: void 0
|
|
43
|
-
});
|
|
44
37
|
Object.defineProperty(this, "accessToken", {
|
|
45
38
|
enumerable: true,
|
|
46
39
|
configurable: true,
|
|
@@ -65,7 +58,6 @@ class InternalAuth {
|
|
|
65
58
|
this.jwt = '';
|
|
66
59
|
this.accessToken = '';
|
|
67
60
|
this.expiresAt = 0;
|
|
68
|
-
this.runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
|
|
69
61
|
if (Deno.env.get(constants_js_1.envVarInternalToken)) {
|
|
70
62
|
this.accessToken = Deno.env.get(constants_js_1.envVarInternalToken) || '';
|
|
71
63
|
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
@@ -78,11 +70,6 @@ class InternalAuth {
|
|
|
78
70
|
console.log(`Using static JWT provided by ${constants_js_1.envVarJwt}`);
|
|
79
71
|
return;
|
|
80
72
|
}
|
|
81
|
-
if (this.runLocal) {
|
|
82
|
-
console.info('Running in local mode using cookie for authentication');
|
|
83
|
-
this.accessToken = (0, cli_js_1.getVersoriCookie)();
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
73
|
if (!this.clientId || !this.clientSecret || !this.tokenEndpoint) {
|
|
87
74
|
const missingVars = [];
|
|
88
75
|
if (!this.clientId)
|
|
@@ -95,9 +82,6 @@ class InternalAuth {
|
|
|
95
82
|
}
|
|
96
83
|
}
|
|
97
84
|
async getAuthHeader() {
|
|
98
|
-
if (this.runLocal) {
|
|
99
|
-
return { 'Cookie': this.accessToken };
|
|
100
|
-
}
|
|
101
85
|
if (this.accessToken && this.expiresAt > Date.now()) {
|
|
102
86
|
return { 'X-Versori-Internal-Token': this.accessToken };
|
|
103
87
|
}
|
|
@@ -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,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CA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|
const compiler = options.compiler || new ObservableCompiler_js_1.ObservableCompiler();
|
|
194
194
|
const serviceName = Deno.env.get(constants_js_1.envVarProjectId) || 'example-service';
|
|
195
195
|
const environmentID = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
196
|
-
const _serviceId = Deno.env.get(constants_js_1.envVarProjectId) || 'development';
|
|
197
196
|
const version = Deno.env.get(constants_js_1.envVarVersion) || '1.0.0';
|
|
198
197
|
const environment = Deno.env.get(constants_js_1.envVarEnvironmentName) || 'development';
|
|
199
|
-
const _sdkAPIBaseURL = Deno.env.get(constants_js_1.envVarSDKApiBaseURL) || 'http://localhost:8902';
|
|
200
198
|
const orgId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
|
|
201
199
|
const orgSlug = Deno.env.get(constants_js_1.envVarOrgSlug) || 'development';
|
|
202
200
|
const otelTracesURL = Deno.env.get(constants_js_1.envVarOtelTracesURL);
|
|
@@ -237,7 +235,7 @@ class DurableInterpreter {
|
|
|
237
235
|
const platformApi = PlatformApi_js_1.PlatformApiImpl.fromEnv();
|
|
238
236
|
const organisationId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
|
|
239
237
|
const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
240
|
-
const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp, new CredentialsProvider_js_1.CredentialsProviderImpl(connectionFactory.credentials, connectionFactory.tokens, connectionFactory.oauth1, configReader, platformApi), platformApi, organisationId, environmentId, issuesProvider);
|
|
238
|
+
const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp, new CredentialsProvider_js_1.CredentialsProviderImpl(connectionFactory.credentials, connectionFactory.tokens, connectionFactory.oauth1, configReader, platformApi), platformApi, organisationId, environmentId, issuesProvider, queueProvider);
|
|
241
239
|
return new DurableInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), PlatformApi_js_1.PlatformApiImpl.fromEnv(), connectionFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
|
|
242
240
|
}
|
|
243
241
|
register(workflow, options) {
|
|
@@ -299,7 +297,7 @@ class DurableInterpreter {
|
|
|
299
297
|
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
300
298
|
registration.subscription = registration.trigger$
|
|
301
299
|
.pipe((0, rxjs_1.tap)((ctx) => {
|
|
302
|
-
ctx.log.info('DurableInterpreter.executionStarted', {
|
|
300
|
+
ctx.log.info('DurableInterpreter.executionStarted', {});
|
|
303
301
|
}), (0, rxjs_1.mergeMap)((ctx) => (0, rxjs_1.of)(ctx).pipe(registration.task$, (0, rxjs_1.catchError)((err) => {
|
|
304
302
|
ctx.log.error('DurableInterpreter.executionError', {
|
|
305
303
|
error: err instanceof Error ? err.toString() : err,
|
|
@@ -317,7 +315,7 @@ class DurableInterpreter {
|
|
|
317
315
|
return rxjs_1.EMPTY;
|
|
318
316
|
}))))
|
|
319
317
|
.subscribe({
|
|
320
|
-
next:
|
|
318
|
+
next: (ctx) => {
|
|
321
319
|
const durationMs = Date.now() - ctx.startTime.getTime();
|
|
322
320
|
ctx.log.info('DurableInterpreter.executionCompleted', {
|
|
323
321
|
durationMs,
|
|
@@ -332,17 +330,6 @@ class DurableInterpreter {
|
|
|
332
330
|
error: err instanceof Error ? err.toString() : err,
|
|
333
331
|
}));
|
|
334
332
|
}
|
|
335
|
-
if (ctx.workflowId) {
|
|
336
|
-
this.log.info('Async workflow completed', {
|
|
337
|
-
workflowId: ctx.workflowId,
|
|
338
|
-
});
|
|
339
|
-
const output = ctx.data ? btoa(JSON.stringify(ctx.data)) : undefined;
|
|
340
|
-
await ctx.queue?.complete({
|
|
341
|
-
id: ctx.workflowId,
|
|
342
|
-
output,
|
|
343
|
-
status: 'completed',
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
333
|
this.contextProvider.destroy(ctx);
|
|
347
334
|
},
|
|
348
335
|
error: (err) => {
|
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
import { Logger } from '
|
|
1
|
+
import { Logger } from '@versori/run/observability';
|
|
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":"
|
|
1
|
+
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/Queue.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AASpD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,gB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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"}
|
|
@@ -47,7 +47,6 @@ class QueueImpl {
|
|
|
47
47
|
this.environmentId = environmentId;
|
|
48
48
|
}
|
|
49
49
|
static fromEnv(log) {
|
|
50
|
-
// TODO make these environment variables configurable in constants/ts
|
|
51
50
|
const baseUrl = Deno.env.get(constants_js_1.envVarSDKApiBaseURL);
|
|
52
51
|
const _log = log || new mod_js_1.ConsoleLogger('debug');
|
|
53
52
|
const projectId = Deno.env.get(constants_js_1.envVarProjectId) || 'default-project';
|
|
@@ -72,7 +71,7 @@ class QueueImpl {
|
|
|
72
71
|
output: request.output,
|
|
73
72
|
status: request.status,
|
|
74
73
|
});
|
|
75
|
-
throw new Error(
|
|
74
|
+
throw new Error(await resp.text());
|
|
76
75
|
}
|
|
77
76
|
return;
|
|
78
77
|
}
|
|
@@ -110,16 +109,27 @@ class QueueImpl {
|
|
|
110
109
|
}),
|
|
111
110
|
});
|
|
112
111
|
if (!resp.ok) {
|
|
113
|
-
|
|
112
|
+
let errorText = "";
|
|
113
|
+
try {
|
|
114
|
+
const vErr = (await resp.json());
|
|
115
|
+
errorText = vErr.message;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
errorText = await resp.text();
|
|
119
|
+
}
|
|
114
120
|
this.log.error('Failed to fetch workflows', {
|
|
115
|
-
error: errorText
|
|
121
|
+
error: errorText,
|
|
116
122
|
ttl: request.ttl,
|
|
117
123
|
limit: request.limit,
|
|
118
124
|
group: request.group,
|
|
119
125
|
projectId: this.projectId || request.projectId,
|
|
126
|
+
response: {
|
|
127
|
+
status: resp.status,
|
|
128
|
+
statusText: resp.statusText,
|
|
129
|
+
},
|
|
120
130
|
});
|
|
121
131
|
throw new Error('failed to fetch workflows', {
|
|
122
|
-
cause: new Error(errorText
|
|
132
|
+
cause: new Error(errorText),
|
|
123
133
|
});
|
|
124
134
|
}
|
|
125
135
|
if (resp.status === 204) {
|
|
@@ -145,8 +155,7 @@ class QueueImpl {
|
|
|
145
155
|
}
|
|
146
156
|
return;
|
|
147
157
|
}
|
|
148
|
-
async
|
|
149
|
-
// this endpoint returns a 404 if the workflow is not completed
|
|
158
|
+
async getWorkflow(workflowId) {
|
|
150
159
|
const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch/${workflowId}`, {
|
|
151
160
|
method: 'GET',
|
|
152
161
|
});
|
|
@@ -174,7 +183,7 @@ class MockQueue {
|
|
|
174
183
|
reschedule(_request) {
|
|
175
184
|
throw new Error('Method not implemented.');
|
|
176
185
|
}
|
|
177
|
-
|
|
186
|
+
getWorkflow(_workflowId) {
|
|
178
187
|
throw new Error('Method not implemented.');
|
|
179
188
|
}
|
|
180
189
|
}
|
|
@@ -38,7 +38,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
38
38
|
annotations: {
|
|
39
39
|
'error': error.message,
|
|
40
40
|
'stack': error.stack || '',
|
|
41
|
-
'workflowId': ctx.options.
|
|
41
|
+
'workflowId': ctx.options.workflow?.id || ctx.workflow?.id || '',
|
|
42
42
|
'executionId': ctx.executionId,
|
|
43
43
|
'activationId': ctx.activation.id,
|
|
44
44
|
'activationExternalId': ctx.activation?.user.externalId,
|
|
@@ -55,7 +55,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
55
55
|
annotations: {
|
|
56
56
|
'error': error.message,
|
|
57
57
|
'stack': error.stack || '',
|
|
58
|
-
'workflowId': ctx.options.
|
|
58
|
+
'workflowId': ctx.options.workflow?.id || ctx.workflow?.id || '',
|
|
59
59
|
'executionId': ctx.executionId,
|
|
60
60
|
'activationId': ctx.activation.id,
|
|
61
61
|
'activationExternalId': ctx.activation?.user.externalId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAW,WAAW,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAyF9C;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAIhG,CAAC"}
|