@versori/run 0.2.14 → 0.2.15

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.
Files changed (151) hide show
  1. package/esm/src/context/AsyncWorkflow.d.ts +14 -0
  2. package/esm/src/context/AsyncWorkflow.d.ts.map +1 -0
  3. package/esm/src/context/AsyncWorkflow.js +89 -0
  4. package/esm/src/context/Context.d.ts +12 -1
  5. package/esm/src/context/Context.d.ts.map +1 -1
  6. package/esm/src/context/Context.js +43 -4
  7. package/esm/src/context/ContextProvider.d.ts +3 -1
  8. package/esm/src/context/ContextProvider.d.ts.map +1 -1
  9. package/esm/src/context/ContextProvider.js +9 -2
  10. package/esm/src/dsl/http/versori/constants.d.ts +1 -0
  11. package/esm/src/dsl/http/versori/constants.d.ts.map +1 -1
  12. package/esm/src/dsl/http/versori/constants.js +1 -0
  13. package/esm/src/dsl/triggers/DurableTrigger.d.ts +17 -0
  14. package/esm/src/dsl/triggers/DurableTrigger.d.ts.map +1 -0
  15. package/esm/src/dsl/triggers/DurableTrigger.js +36 -0
  16. package/esm/src/dsl/triggers/mod.d.ts +1 -0
  17. package/esm/src/dsl/triggers/mod.d.ts.map +1 -1
  18. package/esm/src/dsl/triggers/mod.js +1 -0
  19. package/esm/src/interpreter/durable/DurableInterpreter.d.ts +52 -0
  20. package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -0
  21. package/esm/src/interpreter/durable/DurableInterpreter.js +433 -0
  22. package/esm/src/interpreter/durable/ExecutionError.d.ts +6 -0
  23. package/esm/src/interpreter/durable/ExecutionError.d.ts.map +1 -0
  24. package/esm/src/interpreter/durable/ExecutionError.js +13 -0
  25. package/esm/src/interpreter/durable/ObservableCompiler.d.ts +35 -0
  26. package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -0
  27. package/esm/src/interpreter/durable/ObservableCompiler.js +69 -0
  28. package/esm/src/interpreter/durable/Queue.d.ts +60 -0
  29. package/esm/src/interpreter/durable/Queue.d.ts.map +1 -0
  30. package/esm/src/interpreter/durable/Queue.js +131 -0
  31. package/esm/src/interpreter/durable/compilers/background.d.ts +4 -0
  32. package/esm/src/interpreter/durable/compilers/background.d.ts.map +1 -0
  33. package/esm/src/interpreter/durable/compilers/background.js +22 -0
  34. package/esm/src/interpreter/durable/compilers/catch.d.ts +4 -0
  35. package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -0
  36. package/esm/src/interpreter/durable/compilers/catch.js +36 -0
  37. package/esm/src/interpreter/durable/compilers/chain.d.ts +3 -0
  38. package/esm/src/interpreter/durable/compilers/chain.d.ts.map +1 -0
  39. package/esm/src/interpreter/durable/compilers/chain.js +9 -0
  40. package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts +8 -0
  41. package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -0
  42. package/esm/src/interpreter/durable/compilers/durableworkflow.js +54 -0
  43. package/esm/src/interpreter/durable/compilers/fn.d.ts +4 -0
  44. package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -0
  45. package/esm/src/interpreter/durable/compilers/fn.js +22 -0
  46. package/esm/src/interpreter/durable/compilers/http.d.ts +4 -0
  47. package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -0
  48. package/esm/src/interpreter/durable/compilers/http.js +44 -0
  49. package/esm/src/interpreter/durable/compilers/mod.d.ts +2 -0
  50. package/esm/src/interpreter/durable/compilers/mod.d.ts.map +1 -0
  51. package/esm/src/interpreter/durable/compilers/mod.js +1 -0
  52. package/esm/src/interpreter/durable/compilers/parallel.d.ts +4 -0
  53. package/esm/src/interpreter/durable/compilers/parallel.d.ts.map +1 -0
  54. package/esm/src/interpreter/durable/compilers/parallel.js +19 -0
  55. package/esm/src/interpreter/durable/compilers/schedule.d.ts +4 -0
  56. package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -0
  57. package/esm/src/interpreter/durable/compilers/schedule.js +94 -0
  58. package/esm/src/interpreter/durable/compilers/serial.d.ts +4 -0
  59. package/esm/src/interpreter/durable/compilers/serial.d.ts.map +1 -0
  60. package/esm/src/interpreter/durable/compilers/serial.js +16 -0
  61. package/esm/src/interpreter/durable/compilers/types.d.ts +15 -0
  62. package/esm/src/interpreter/durable/compilers/types.d.ts.map +1 -0
  63. package/esm/src/interpreter/durable/compilers/types.js +1 -0
  64. package/esm/src/interpreter/durable/compilers/unpack.d.ts +4 -0
  65. package/esm/src/interpreter/durable/compilers/unpack.d.ts.map +1 -0
  66. package/esm/src/interpreter/durable/compilers/unpack.js +22 -0
  67. package/esm/src/interpreter/durable/compilers/webhook.d.ts +4 -0
  68. package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -0
  69. package/esm/src/interpreter/durable/compilers/webhook.js +248 -0
  70. package/esm/src/interpreter/durable/mod.d.ts +5 -0
  71. package/esm/src/interpreter/durable/mod.d.ts.map +1 -0
  72. package/esm/src/interpreter/durable/mod.js +4 -0
  73. package/esm/src/interpreter/mod.d.ts +1 -0
  74. package/esm/src/interpreter/mod.d.ts.map +1 -1
  75. package/esm/src/interpreter/mod.js +1 -0
  76. package/package.json +1 -1
  77. package/script/src/context/AsyncWorkflow.d.ts +14 -0
  78. package/script/src/context/AsyncWorkflow.d.ts.map +1 -0
  79. package/script/src/context/AsyncWorkflow.js +93 -0
  80. package/script/src/context/Context.d.ts +12 -1
  81. package/script/src/context/Context.d.ts.map +1 -1
  82. package/script/src/context/Context.js +43 -4
  83. package/script/src/context/ContextProvider.d.ts +3 -1
  84. package/script/src/context/ContextProvider.d.ts.map +1 -1
  85. package/script/src/context/ContextProvider.js +9 -2
  86. package/script/src/dsl/http/versori/constants.d.ts +1 -0
  87. package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
  88. package/script/src/dsl/http/versori/constants.js +2 -1
  89. package/script/src/dsl/triggers/DurableTrigger.d.ts +17 -0
  90. package/script/src/dsl/triggers/DurableTrigger.d.ts.map +1 -0
  91. package/script/src/dsl/triggers/DurableTrigger.js +41 -0
  92. package/script/src/dsl/triggers/mod.d.ts +1 -0
  93. package/script/src/dsl/triggers/mod.d.ts.map +1 -1
  94. package/script/src/dsl/triggers/mod.js +3 -1
  95. package/script/src/interpreter/durable/DurableInterpreter.d.ts +52 -0
  96. package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -0
  97. package/script/src/interpreter/durable/DurableInterpreter.js +440 -0
  98. package/script/src/interpreter/durable/ExecutionError.d.ts +6 -0
  99. package/script/src/interpreter/durable/ExecutionError.d.ts.map +1 -0
  100. package/script/src/interpreter/durable/ExecutionError.js +17 -0
  101. package/script/src/interpreter/durable/ObservableCompiler.d.ts +35 -0
  102. package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -0
  103. package/script/src/interpreter/durable/ObservableCompiler.js +73 -0
  104. package/script/src/interpreter/durable/Queue.d.ts +60 -0
  105. package/script/src/interpreter/durable/Queue.d.ts.map +1 -0
  106. package/script/src/interpreter/durable/Queue.js +135 -0
  107. package/script/src/interpreter/durable/compilers/background.d.ts +4 -0
  108. package/script/src/interpreter/durable/compilers/background.d.ts.map +1 -0
  109. package/script/src/interpreter/durable/compilers/background.js +25 -0
  110. package/script/src/interpreter/durable/compilers/catch.d.ts +4 -0
  111. package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -0
  112. package/script/src/interpreter/durable/compilers/catch.js +39 -0
  113. package/script/src/interpreter/durable/compilers/chain.d.ts +3 -0
  114. package/script/src/interpreter/durable/compilers/chain.d.ts.map +1 -0
  115. package/script/src/interpreter/durable/compilers/chain.js +12 -0
  116. package/script/src/interpreter/durable/compilers/durableworkflow.d.ts +8 -0
  117. package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -0
  118. package/script/src/interpreter/durable/compilers/durableworkflow.js +58 -0
  119. package/script/src/interpreter/durable/compilers/fn.d.ts +4 -0
  120. package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -0
  121. package/script/src/interpreter/durable/compilers/fn.js +25 -0
  122. package/script/src/interpreter/durable/compilers/http.d.ts +4 -0
  123. package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -0
  124. package/script/src/interpreter/durable/compilers/http.js +47 -0
  125. package/script/src/interpreter/durable/compilers/mod.d.ts +2 -0
  126. package/script/src/interpreter/durable/compilers/mod.d.ts.map +1 -0
  127. package/script/src/interpreter/durable/compilers/mod.js +2 -0
  128. package/script/src/interpreter/durable/compilers/parallel.d.ts +4 -0
  129. package/script/src/interpreter/durable/compilers/parallel.d.ts.map +1 -0
  130. package/script/src/interpreter/durable/compilers/parallel.js +22 -0
  131. package/script/src/interpreter/durable/compilers/schedule.d.ts +4 -0
  132. package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -0
  133. package/script/src/interpreter/durable/compilers/schedule.js +97 -0
  134. package/script/src/interpreter/durable/compilers/serial.d.ts +4 -0
  135. package/script/src/interpreter/durable/compilers/serial.d.ts.map +1 -0
  136. package/script/src/interpreter/durable/compilers/serial.js +19 -0
  137. package/script/src/interpreter/durable/compilers/types.d.ts +15 -0
  138. package/script/src/interpreter/durable/compilers/types.d.ts.map +1 -0
  139. package/script/src/interpreter/durable/compilers/types.js +2 -0
  140. package/script/src/interpreter/durable/compilers/unpack.d.ts +4 -0
  141. package/script/src/interpreter/durable/compilers/unpack.d.ts.map +1 -0
  142. package/script/src/interpreter/durable/compilers/unpack.js +25 -0
  143. package/script/src/interpreter/durable/compilers/webhook.d.ts +4 -0
  144. package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -0
  145. package/script/src/interpreter/durable/compilers/webhook.js +254 -0
  146. package/script/src/interpreter/durable/mod.d.ts +5 -0
  147. package/script/src/interpreter/durable/mod.d.ts.map +1 -0
  148. package/script/src/interpreter/durable/mod.js +20 -0
  149. package/script/src/interpreter/mod.d.ts +1 -0
  150. package/script/src/interpreter/mod.d.ts.map +1 -1
  151. package/script/src/interpreter/mod.js +14 -0
@@ -0,0 +1,14 @@
1
+ import { QueueAPI } from '../interpreter/durable/Queue.js';
2
+ export declare class AsyncWorkflow {
3
+ private workflowId;
4
+ private queue;
5
+ private data;
6
+ private dataRaw;
7
+ private isWaiting;
8
+ private isCompleted;
9
+ constructor(queue: QueueAPI, workflowId: string);
10
+ wait(maxWait?: number): Promise<void>;
11
+ getData(): Promise<unknown | undefined>;
12
+ getDataRaw(): Promise<string | undefined>;
13
+ }
14
+ //# sourceMappingURL=AsyncWorkflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsyncWorkflow.d.ts","sourceRoot":"","sources":["../../../src/src/context/AsyncWorkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,qBAAa,aAAa;IACtB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,IAAI,CAAsB;IAClC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,WAAW,CAAkB;gBAEzB,KAAK,EAAE,QAAQ,EAAC,UAAU,EAAE,MAAM;IASxC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsCrC,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAQvC,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAMlD"}
@@ -0,0 +1,89 @@
1
+ export class AsyncWorkflow {
2
+ constructor(queue, workflowId) {
3
+ Object.defineProperty(this, "workflowId", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: void 0
8
+ });
9
+ Object.defineProperty(this, "queue", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: void 0
14
+ });
15
+ Object.defineProperty(this, "data", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: void 0
20
+ });
21
+ Object.defineProperty(this, "dataRaw", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+ Object.defineProperty(this, "isWaiting", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: false
32
+ });
33
+ Object.defineProperty(this, "isCompleted", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: false
38
+ });
39
+ this.queue = queue;
40
+ this.workflowId = workflowId;
41
+ }
42
+ // wait will wait for the workflow to complete by polling the queue
43
+ // If maxWait is provided (in milliseconds), it will wait for that long before giving up
44
+ // If the workflow is already completed, it will return immediately.
45
+ // Throws an error if already waiting or if the wait times out.
46
+ async wait(maxWait) {
47
+ if (this.isWaiting) {
48
+ return Promise.reject(new Error('already waiting for workflow to complete'));
49
+ }
50
+ if (this.isCompleted) {
51
+ return;
52
+ }
53
+ this.isWaiting = true;
54
+ const start = Date.now();
55
+ while (true && !this.isCompleted) {
56
+ if (maxWait !== undefined && Date.now() - start >= maxWait) {
57
+ this.isWaiting = false;
58
+ throw new Error('wait timed out');
59
+ }
60
+ const workflow = await this.queue.poll(this.workflowId);
61
+ if (workflow.status === 'completed') {
62
+ // workflow is completed, parse the output and set the data and completed to true
63
+ const stringData = workflow.output;
64
+ if (stringData) {
65
+ this.data = JSON.parse(atob(stringData));
66
+ this.dataRaw = workflow.output;
67
+ }
68
+ this.isWaiting = false;
69
+ this.isCompleted = true;
70
+ return;
71
+ }
72
+ await new Promise(resolve => setTimeout(resolve, 1000));
73
+ }
74
+ }
75
+ // getData returns the data as D type, which is JSON parsed
76
+ async getData() {
77
+ if (!this.isWaiting) {
78
+ await this.wait();
79
+ }
80
+ return this.data;
81
+ }
82
+ // getDataRaw returns the raw data as base64 encoded string
83
+ async getDataRaw() {
84
+ if (!this.isWaiting) {
85
+ await this.wait();
86
+ }
87
+ return this.dataRaw;
88
+ }
89
+ }
@@ -1,14 +1,21 @@
1
1
  import { Activation } from '../dsl/http/types.js';
2
2
  import { CredentialsProvider } from '../dsl/http/versori/contextcredentials.js';
3
+ import { QueueAPI } from '../interpreter/durable/Queue.js';
3
4
  import { KeyValue, KeyValueProvider, KeyValueScope } from '../kv/KeyValue.js';
4
5
  import { Logger } from '../observability/logging/Logger.js';
6
+ import { AsyncWorkflow } from './AsyncWorkflow.js';
5
7
  export type OnSuccessFn = (ctx: Context<any>) => void;
6
8
  export type OnErrorFn = (ctx: Context<any>) => void;
7
9
  export type ContextOptions = {
8
10
  activation?: Activation;
11
+ workflowId?: string;
9
12
  onSuccess?: OnSuccessFn;
10
13
  onError?: OnErrorFn;
11
14
  };
15
+ export type WorkflowOpts = {
16
+ data?: unknown;
17
+ dataRaw?: string;
18
+ };
12
19
  export interface Context<D> {
13
20
  readonly log: Logger;
14
21
  readonly executionId: string;
@@ -20,6 +27,7 @@ export interface Context<D> {
20
27
  * @param scope
21
28
  */
22
29
  openKv(scope?: KeyValueScope): KeyValue;
30
+ start(workflowId: string, workflowOpts: WorkflowOpts): Promise<AsyncWorkflow>;
23
31
  credentials(): CredentialsProvider;
24
32
  }
25
33
  export declare class ContextImpl<D, Index = void> implements Context<D> {
@@ -30,13 +38,16 @@ export declare class ContextImpl<D, Index = void> implements Context<D> {
30
38
  readonly data: D;
31
39
  idx: Index;
32
40
  readonly kvp: KeyValueProvider;
41
+ readonly queue?: QueueAPI;
33
42
  readonly options: ContextOptions;
34
- constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, executionId: string, startTime: Date, data: D, options?: ContextOptions);
43
+ constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, executionId: string, startTime: Date, data: D, queue?: QueueAPI, options?: ContextOptions);
35
44
  get activation(): Activation | undefined;
45
+ get workflowId(): string | undefined;
36
46
  setIndex(idx: number): ContextImpl<D, number>;
37
47
  withActivation(activation: Activation): ContextImpl<D, Index>;
38
48
  withData<D2>(data: D2): ContextImpl<D2, Index>;
39
49
  openKv(scope?: KeyValueScope): KeyValue;
50
+ start(group: string, opts: WorkflowOpts): Promise<AsyncWorkflow>;
40
51
  credentials(): CredentialsProvider;
41
52
  destroy(scope: KeyValueScope): Promise<void>;
42
53
  [Symbol.toPrimitive](): Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;AACtD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;AAEpD,MAAM,MAAM,cAAc,GAAG;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,OAAO,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,OAAO,CAAC,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAEjB,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,QAAQ,CAAC;IAExC,WAAW,IAAI,mBAAmB,CAAC;CACtC;AAED,qBAAa,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;;IAC3D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,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function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _ContextImpl_creds;
13
+ import { AsyncWorkflow } from './AsyncWorkflow.js';
13
14
  export class ContextImpl {
14
- constructor(log, kvp, creds, executionId, startTime, data, options = {}) {
15
+ constructor(log, kvp, creds, executionId, startTime, data, queue, options = {}) {
15
16
  Object.defineProperty(this, "log", {
16
17
  enumerable: true,
17
18
  configurable: true,
@@ -48,6 +49,12 @@ export class ContextImpl {
48
49
  writable: true,
49
50
  value: void 0
50
51
  });
52
+ Object.defineProperty(this, "queue", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: void 0
57
+ }); // Optional, can be used for durable workflows
51
58
  Object.defineProperty(this, "options", {
52
59
  enumerable: true,
53
60
  configurable: true,
@@ -63,17 +70,22 @@ export class ContextImpl {
63
70
  this.idx = void 0;
64
71
  this.kvp = kvp;
65
72
  this.options = options;
73
+ this.queue = queue;
66
74
  // all methods on ContextImpl which are exposed via the Context interface need to be bound
67
75
  // so that destructuring the context object doesn't break the binding of the methods to the
68
76
  // correct instance.
69
77
  this.openKv = this.openKv.bind(this);
70
78
  this.credentials = this.credentials.bind(this);
79
+ this.start = this.start.bind(this);
71
80
  }
72
81
  get activation() {
73
82
  return this.options.activation;
74
83
  }
84
+ get workflowId() {
85
+ return this.options.workflowId;
86
+ }
75
87
  setIndex(idx) {
76
- const next = new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, this.options);
88
+ const next = new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, this.queue, this.options);
77
89
  next.idx = idx;
78
90
  return next;
79
91
  }
@@ -82,13 +94,13 @@ export class ContextImpl {
82
94
  if (this.activation) {
83
95
  throw new Error('Activation is already set');
84
96
  }
85
- return new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, {
97
+ return new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, this.queue, {
86
98
  ...this.options,
87
99
  activation,
88
100
  });
89
101
  }
90
102
  withData(data) {
91
- return new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, data, this.options);
103
+ return new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, data, this.queue, this.options);
92
104
  }
93
105
  openKv(scope = ':project:') {
94
106
  if (scope === ':execution:') {
@@ -103,6 +115,33 @@ export class ContextImpl {
103
115
  activationId: this.activation?.id,
104
116
  });
105
117
  }
118
+ async start(group, opts) {
119
+ // this makes a post request to the endpoint sending a message and schedule the workflow to run
120
+ if (!this.queue) {
121
+ throw new Error('Queue is not available for this context, cannot start workflow');
122
+ }
123
+ let payload;
124
+ if (opts.data) {
125
+ payload = opts.data ? btoa(JSON.stringify(opts.data)) : undefined;
126
+ }
127
+ else if (opts.dataRaw) {
128
+ payload = opts.dataRaw; // Assume this is already base64 encoded
129
+ }
130
+ const resp = await this.queue.submit({
131
+ workflows: [
132
+ {
133
+ group,
134
+ metadata: {
135
+ executionId: this.executionId,
136
+ activationId: this.activation?.id,
137
+ userId: this.activation?.user.externalId,
138
+ },
139
+ payload,
140
+ }
141
+ ]
142
+ });
143
+ return new AsyncWorkflow(this.queue, resp.workflows[0].id ?? 'unknown');
144
+ }
106
145
  credentials() {
107
146
  return {
108
147
  getRaw: (name) => __classPrivateFieldGet(this, _ContextImpl_creds, "f").getRaw(name, this.activation?.id || undefined),
@@ -2,6 +2,7 @@ import { KeyValueProvider } from '../kv/KeyValue.js';
2
2
  import { Logger } from '../observability/logging/Logger.js';
3
3
  import { Context, ContextImpl, ContextOptions } from './Context.js';
4
4
  import { CredentialsProvider } from '../dsl/http/versori/contextcredentials.js';
5
+ import { QueueAPI } from '../interpreter/durable/Queue.js';
5
6
  export interface ContextProvider {
6
7
  create<D>(data: D, options?: ContextOptions): ContextImpl<D, void>;
7
8
  destroy(ctx: Context<any>): Promise<void>;
@@ -10,7 +11,8 @@ export declare class ContextProviderImpl implements ContextProvider {
10
11
  log: Logger;
11
12
  kvp: KeyValueProvider;
12
13
  creds: CredentialsProvider;
13
- constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider);
14
+ queue?: QueueAPI;
15
+ constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, queue: QueueAPI | undefined);
14
16
  create<D>(data: D, options?: ContextOptions): ContextImpl<D>;
15
17
  destroy(ctx: Context<any>): Promise<void>;
16
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ContextProvider.d.ts","sourceRoot":"","sources":["../../../src/src/context/ContextProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAEhF,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACnE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,qBAAa,mBAAoB,YAAW,eAAe;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,gBAAgB,CAAC;IACtB,KAAK,EAAE,mBAAmB,CAAC;gBAEf,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,mBAAmB;IAM1E,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C,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAM5C"}
@@ -1,7 +1,7 @@
1
1
  import { ulid } from '../../deps/jsr.io/@std/ulid/1.0.0/mod.js';
2
2
  import { ContextImpl } from './Context.js';
3
3
  export class ContextProviderImpl {
4
- constructor(log, kvp, creds) {
4
+ constructor(log, kvp, creds, queue) {
5
5
  Object.defineProperty(this, "log", {
6
6
  enumerable: true,
7
7
  configurable: true,
@@ -20,9 +20,16 @@ export class ContextProviderImpl {
20
20
  writable: true,
21
21
  value: void 0
22
22
  });
23
+ Object.defineProperty(this, "queue", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
23
29
  this.log = log;
24
30
  this.kvp = kvp;
25
31
  this.creds = creds;
32
+ this.queue = queue;
26
33
  }
27
34
  create(data, options = {}) {
28
35
  const executionId = ulid();
@@ -33,7 +40,7 @@ export class ContextProviderImpl {
33
40
  externalUserId: options.activation.user.externalId,
34
41
  });
35
42
  }
36
- return new ContextImpl(logger, this.kvp, this.creds, executionId, new Date(), data, options);
43
+ return new ContextImpl(logger, this.kvp, this.creds, executionId, new Date(), data, this.queue, options);
37
44
  }
38
45
  destroy(ctx) {
39
46
  return this.kvp.destroy({
@@ -5,6 +5,7 @@ export declare const envVarProjectId = "RUN_SERVICE_ID";
5
5
  export declare const envVarOrgSlug = "RUN_ORGANISATION_SLUG";
6
6
  export declare const envVarPlatformApiBaseURL = "RUN_PLATFORM_API_INTERNAL_URL";
7
7
  export declare const envVarCronApiBaseURL = "RUN_CRON_API_INTERNAL_URL";
8
+ export declare const envVarWorkflowApiBaseURL = "RUN_SDK_API_URL";
8
9
  export declare const envVarSelfRefURL = "RUN_SELF_REF_URL";
9
10
  export declare const envVarCredsBaseURL = "RUN_CREDENTIALS_SERVICE_INTERNAL_URL";
10
11
  export declare const envVarOtelTracesURL = "RUN_OTEL_TRACES_URL";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAGxD,eAAO,MAAM,cAAc,cAAc,CAAC;AAI1C,eAAO,MAAM,QAAQ,OAAO,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAC1D,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAGxD,eAAO,MAAM,cAAc,cAAc,CAAC;AAI1C,eAAO,MAAM,QAAQ,OAAO,CAAC"}
@@ -6,6 +6,7 @@ export const envVarProjectId = 'RUN_SERVICE_ID';
6
6
  export const envVarOrgSlug = 'RUN_ORGANISATION_SLUG';
7
7
  export const envVarPlatformApiBaseURL = 'RUN_PLATFORM_API_INTERNAL_URL';
8
8
  export const envVarCronApiBaseURL = 'RUN_CRON_API_INTERNAL_URL';
9
+ export const envVarWorkflowApiBaseURL = 'RUN_SDK_API_URL';
9
10
  export const envVarSelfRefURL = 'RUN_SELF_REF_URL';
10
11
  export const envVarCredsBaseURL = 'RUN_CREDENTIALS_SERVICE_INTERNAL_URL';
11
12
  export const envVarOtelTracesURL = 'RUN_OTEL_TRACES_URL';
@@ -0,0 +1,17 @@
1
+ import { Taskable } from '../mod.js';
2
+ import { Trigger, TriggerType } from '../Trigger.js';
3
+ import { Workflow } from '../Workflow.js';
4
+ export type DurableWorkflowOptions = {
5
+ ttl?: number;
6
+ limit?: number;
7
+ };
8
+ export type DurableWorkflowData = Record<string, unknown>;
9
+ export declare class DurableWorkflowTrigger implements Trigger<DurableWorkflowData> {
10
+ id: string;
11
+ options: DurableWorkflowOptions;
12
+ [TriggerType]: string;
13
+ constructor(id: string, options?: DurableWorkflowOptions);
14
+ then<OO>(task: Taskable<DurableWorkflowData, OO>): Workflow<OO>;
15
+ }
16
+ export declare function workflow(id: string, options?: DurableWorkflowOptions): Trigger<DurableWorkflowData>;
17
+ //# sourceMappingURL=DurableTrigger.d.ts.map
@@ -0,0 +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;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"}
@@ -0,0 +1,36 @@
1
+ var _a;
2
+ import { ensureTask } from '../ensureTask.js';
3
+ import { TriggerType } from '../Trigger.js';
4
+ import { WorkflowImpl } from '../Workflow.js';
5
+ export class DurableWorkflowTrigger {
6
+ constructor(id, options = {}) {
7
+ Object.defineProperty(this, "id", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: void 0
12
+ });
13
+ Object.defineProperty(this, "options", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: void 0
18
+ });
19
+ Object.defineProperty(this, _a, {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: 'durableWorkflow'
24
+ });
25
+ this.id = id;
26
+ this.options = options;
27
+ }
28
+ then(task) {
29
+ return new WorkflowImpl(this, ensureTask(task));
30
+ }
31
+ }
32
+ _a = TriggerType;
33
+ ;
34
+ export function workflow(id, options) {
35
+ return new DurableWorkflowTrigger(id, options);
36
+ }
@@ -2,4 +2,5 @@ export type * from './ScheduleTrigger.js';
2
2
  export type * from './WebhookTrigger.js';
3
3
  export { schedule } from './ScheduleTrigger.js';
4
4
  export { webhook } from './WebhookTrigger.js';
5
+ export { workflow } from './DurableTrigger.js';
5
6
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/triggers/mod.ts"],"names":[],"mappings":"AAAA,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,qBAAqB,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/triggers/mod.ts"],"names":[],"mappings":"AAAA,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,qBAAqB,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export { schedule } from './ScheduleTrigger.js';
2
2
  export { webhook } from './WebhookTrigger.js';
3
+ export { workflow } from './DurableTrigger.js';
@@ -0,0 +1,52 @@
1
+ import { Tracer } from '@opentelemetry/api';
2
+ import { NodeSDK } from '@opentelemetry/sdk-node';
3
+ import { Router } from 'express';
4
+ import { Observable, Subscription } from 'rxjs';
5
+ import { ContextProvider } from '../../context/ContextProvider.js';
6
+ import { ConfigReader, ConnectionProvider, CronProvider, RoundTripperFactory } from '../../dsl/http/types.js';
7
+ import { Workflow } from '../../dsl/Workflow.js';
8
+ import { ContextImpl, ContextOperatorFunction } from '../../mod.js';
9
+ import { Logger } from '../../observability/logging/Logger.js';
10
+ import { ObservableCompiler } from './ObservableCompiler.js';
11
+ import { QueueAPI } from './Queue.js';
12
+ export type DurableInterpreterOptions = {
13
+ logger?: Logger;
14
+ compiler?: ObservableCompiler;
15
+ contextProvider?: ContextProvider;
16
+ signal?: AbortSignal;
17
+ skipVersoriCredentials?: boolean;
18
+ };
19
+ type Registration = {
20
+ trigger$: Observable<ContextImpl<any, void>>;
21
+ task$: ContextOperatorFunction<any, any, any>;
22
+ localAbortController: AbortController;
23
+ sigintListener: () => void;
24
+ subscription?: Subscription;
25
+ };
26
+ export declare class DurableInterpreter {
27
+ private readonly log;
28
+ private readonly compiler;
29
+ private readonly contextProvider;
30
+ private readonly roundTripperFactory;
31
+ private readonly webhookRouter;
32
+ private readonly cronRouter;
33
+ private cronRegistry;
34
+ private readonly connectionProvider;
35
+ private readonly cronProvider;
36
+ private readonly tracer;
37
+ private readonly cfgReader;
38
+ private readonly queueProvider;
39
+ private readonly otelSDK?;
40
+ private registeredWorkflows;
41
+ private webhookServer?;
42
+ private cronServer?;
43
+ private shutdownServer?;
44
+ private isShuttingDown;
45
+ constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, roundTripperFactory: RoundTripperFactory, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, connectionProvider: ConnectionProvider, cronProvider: CronProvider, tracer: Tracer, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
46
+ static newInstance(options?: DurableInterpreterOptions): Promise<DurableInterpreter>;
47
+ register<O>(workflow: Workflow<O>, options?: DurableInterpreterOptions): Registration;
48
+ start(): Promise<void>;
49
+ stop(): Promise<void>;
50
+ }
51
+ export {};
52
+ //# sourceMappingURL=DurableInterpreter.d.ts.map
@@ -0,0 +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;AAG7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AAExF,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACtB,MAAM,yBAAyB,CAAC;AAcjC,OAAO,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAoB,MAAM,cAAc,CAAC;AAEtF,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAA0B,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGrF,OAAO,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AAEjD,MAAM,MAAM,yBAAyB,GAAG;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,KAAK,YAAY,GAAG;IAChB,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7C,KAAK,EAAE,uBAAuB,CAAC,G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