@dbos-inc/dbos-sdk 1.12.13-preview.g7a8a447e44 → 1.13.5-preview
Sign up to get free protection for your applications and to get access to all the features.
- package/dbos-config.schema.json +2 -1
- package/dist/schemas/system_db_schema.d.ts +2 -0
- package/dist/schemas/system_db_schema.d.ts.map +1 -1
- package/dist/src/communicator.d.ts +1 -1
- package/dist/src/communicator.d.ts.map +1 -1
- package/dist/src/communicator.js.map +1 -1
- package/dist/src/context.d.ts +2 -0
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js +3 -2
- package/dist/src/context.js.map +1 -1
- package/dist/src/dbos-executor.d.ts +27 -11
- package/dist/src/dbos-executor.d.ts.map +1 -1
- package/dist/src/dbos-executor.js +149 -58
- package/dist/src/dbos-executor.js.map +1 -1
- package/dist/src/dbos-runtime/config.d.ts +0 -1
- package/dist/src/dbos-runtime/config.d.ts.map +1 -1
- package/dist/src/dbos-runtime/config.js +2 -4
- package/dist/src/dbos-runtime/config.js.map +1 -1
- package/dist/src/debugger/debug_workflow.d.ts +14 -5
- package/dist/src/debugger/debug_workflow.d.ts.map +1 -1
- package/dist/src/debugger/debug_workflow.js +80 -23
- package/dist/src/debugger/debug_workflow.js.map +1 -1
- package/dist/src/decorators.d.ts +19 -2
- package/dist/src/decorators.d.ts.map +1 -1
- package/dist/src/decorators.js +104 -27
- package/dist/src/decorators.js.map +1 -1
- package/dist/src/httpServer/handler.d.ts +22 -15
- package/dist/src/httpServer/handler.d.ts.map +1 -1
- package/dist/src/httpServer/handler.js +44 -35
- package/dist/src/httpServer/handler.js.map +1 -1
- package/dist/src/httpServer/handlerTypes.d.ts +4 -1
- package/dist/src/httpServer/handlerTypes.d.ts.map +1 -1
- package/dist/src/httpServer/handlerTypes.js +3 -0
- package/dist/src/httpServer/handlerTypes.js.map +1 -1
- package/dist/src/httpServer/server.d.ts.map +1 -1
- package/dist/src/httpServer/server.js +36 -12
- package/dist/src/httpServer/server.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/kafka/kafka.d.ts +2 -3
- package/dist/src/kafka/kafka.d.ts.map +1 -1
- package/dist/src/kafka/kafka.js +2 -13
- package/dist/src/kafka/kafka.js.map +1 -1
- package/dist/src/scheduler/scheduler.d.ts +4 -8
- package/dist/src/scheduler/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler/scheduler.js +2 -9
- package/dist/src/scheduler/scheduler.js.map +1 -1
- package/dist/src/system_database.d.ts +4 -0
- package/dist/src/system_database.d.ts.map +1 -1
- package/dist/src/system_database.js +102 -34
- package/dist/src/system_database.js.map +1 -1
- package/dist/src/telemetry/logs.d.ts.map +1 -1
- package/dist/src/telemetry/logs.js +13 -10
- package/dist/src/telemetry/logs.js.map +1 -1
- package/dist/src/telemetry/traces.d.ts +1 -0
- package/dist/src/telemetry/traces.d.ts.map +1 -1
- package/dist/src/telemetry/traces.js +5 -2
- package/dist/src/telemetry/traces.js.map +1 -1
- package/dist/src/testing/testing_runtime.d.ts +9 -5
- package/dist/src/testing/testing_runtime.d.ts.map +1 -1
- package/dist/src/testing/testing_runtime.js +24 -12
- package/dist/src/testing/testing_runtime.js.map +1 -1
- package/dist/src/transaction.d.ts +1 -1
- package/dist/src/transaction.d.ts.map +1 -1
- package/dist/src/utils.d.ts +6 -12
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +30 -13
- package/dist/src/utils.js.map +1 -1
- package/dist/src/workflow.d.ts +46 -10
- package/dist/src/workflow.d.ts.map +1 -1
- package/dist/src/workflow.js +78 -26
- package/dist/src/workflow.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/migrations/20240517000000_status_class_config.js +18 -0
- package/package.json +2 -2
- package/dist/src/dbos-runtime/applicationVersion.d.ts +0 -3
- package/dist/src/dbos-runtime/applicationVersion.d.ts.map +0 -1
- package/dist/src/dbos-runtime/applicationVersion.js +0 -13
- package/dist/src/dbos-runtime/applicationVersion.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"testing_runtime.d.ts","sourceRoot":"","sources":["../../../src/testing/testing_runtime.ts"],"names":[],"mappings":";;;AACA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAmB,MAAM,YAAY,CAAC;
|
1
|
+
{"version":3,"file":"testing_runtime.d.ts","sourceRoot":"","sources":["../../../src/testing/testing_runtime.ts"],"names":[],"mappings":";;;AACA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAmB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAA2B,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE9J,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAY,cAAc,EAAkB,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAMpD;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,cAAc,GAAE,MAA2B,EAAE,SAAS,GAAE,OAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAmBjK;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;I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C,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpG,QAAQ,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,cAAc,GAAE,MAAmD,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAI5I,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC;IAItD,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAK3D,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B;;OAEG;IACH,WAAW,IAAI,YAAY;CAM5B"}
|
@@ -93,9 +93,9 @@ class TestingRuntimeImpl {
|
|
93
93
|
* Generate a proxy object for the provided class that wraps direct calls (i.e. OpClass.someMethod(param))
|
94
94
|
* to invoke workflows, transactions, and communicators;
|
95
95
|
*/
|
96
|
-
mainInvoke(object, workflowUUID, params, asyncWf) {
|
96
|
+
mainInvoke(object, workflowUUID, params, asyncWf, clsinst) {
|
97
97
|
const dbosExec = this.getDBOSExec();
|
98
|
-
const ops = (0, decorators_1.getRegisteredOperations)(object);
|
98
|
+
const ops = (0, decorators_1.getRegisteredOperations)(clsinst ? clsinst : object);
|
99
99
|
const proxy = {};
|
100
100
|
// Creates a context to pass in necessary info.
|
101
101
|
const span = dbosExec.tracer.startSpan("test");
|
@@ -103,25 +103,19 @@ class TestingRuntimeImpl {
|
|
103
103
|
oc.authenticatedUser = params?.authenticatedUser ?? "";
|
104
104
|
oc.request = params?.request ?? {};
|
105
105
|
oc.authenticatedRoles = params?.authenticatedRoles ?? [];
|
106
|
-
const wfParams = { workflowUUID: workflowUUID, parentCtx: oc };
|
106
|
+
const wfParams = { workflowUUID: workflowUUID, parentCtx: oc, configuredInstance: clsinst };
|
107
107
|
for (const op of ops) {
|
108
108
|
if (asyncWf) {
|
109
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
110
109
|
proxy[op.name] = op.txnConfig
|
111
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
112
110
|
? (...args) => dbosExec.transaction(op.registeredFunction, wfParams, ...args)
|
113
111
|
: op.workflowConfig
|
114
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
115
112
|
? (...args) => dbosExec.workflow(op.registeredFunction, wfParams, ...args)
|
116
113
|
: op.commConfig
|
117
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
118
114
|
? (...args) => dbosExec.external(op.registeredFunction, wfParams, ...args)
|
119
115
|
: undefined;
|
120
116
|
}
|
121
117
|
else {
|
122
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
123
118
|
proxy[op.name] = op.workflowConfig
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
125
119
|
? (...args) => dbosExec.workflow(op.registeredFunction, wfParams, ...args).then((handle) => handle.getResult())
|
126
120
|
: undefined;
|
127
121
|
}
|
@@ -129,13 +123,31 @@ class TestingRuntimeImpl {
|
|
129
123
|
return proxy;
|
130
124
|
}
|
131
125
|
invoke(object, workflowUUID, params) {
|
132
|
-
|
126
|
+
if (typeof object === 'function') {
|
127
|
+
return this.mainInvoke(object, workflowUUID, params, true, null);
|
128
|
+
}
|
129
|
+
else {
|
130
|
+
const targetInst = object;
|
131
|
+
return this.mainInvoke(targetInst.constructor, workflowUUID, params, true, targetInst);
|
132
|
+
}
|
133
133
|
}
|
134
134
|
startWorkflow(object, workflowUUID, params) {
|
135
|
-
|
135
|
+
if (typeof object === 'function') {
|
136
|
+
return this.mainInvoke(object, workflowUUID, params, true, null);
|
137
|
+
}
|
138
|
+
else {
|
139
|
+
const targetInst = object;
|
140
|
+
return this.mainInvoke(targetInst.constructor, workflowUUID, params, true, targetInst);
|
141
|
+
}
|
136
142
|
}
|
137
143
|
invokeWorkflow(object, workflowUUID, params) {
|
138
|
-
|
144
|
+
if (typeof object === 'function') {
|
145
|
+
return this.mainInvoke(object, workflowUUID, params, false, null);
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
const targetInst = object;
|
149
|
+
return this.mainInvoke(targetInst.constructor, workflowUUID, params, false, targetInst);
|
150
|
+
}
|
139
151
|
}
|
140
152
|
/**
|
141
153
|
* Return a request handler callback for node's native http/http2 server, which includes all registered HTTP endpoints.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"testing_runtime.js","sourceRoot":"","sources":["../../../src/testing/testing_runtime.ts"],"names":[],"mappings":";;;AAGA,wCAA0D;AAC1D,
|
1
|
+
{"version":3,"file":"testing_runtime.js","sourceRoot":"","sources":["../../../src/testing/testing_runtime.ts"],"names":[],"mappings":";;;AAGA,wCAA0D;AAC1D,8CAA4E;AAC5E,oCAA6D;AAE7D,iDAAsD;AACtD,oDAA4D;AAC5D,mDAA6E;AAM7E,mCAAkC;AAClC,2BAA4B;AAC5B,0CAA2C;AAC3C,sDAAuD;AAEvD;;GAEG;AACI,KAAK,UAAU,oBAAoB,CAAC,WAAqB,EAAE,iBAAyB,2BAAkB,EAAE,YAAqB,IAAI;IACtI,MAAM,CAAC,UAAU,CAAC,GAAG,IAAA,wBAAe,EAAC,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC;IAErE,IAAI,SAAS,EAAE,CAAC;QACd,gFAAgF;QAChF,MAAM,cAAc,GAAG,IAAI,WAAM,CAAC;YAChC,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,IAAI;YAChC,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,IAAI;YAChC,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,IAAI;YAChC,QAAQ,EAAE,UAAU,C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CAAC;IAED,KAAK,CAAC,QAAQ,CAAI,YAAoB,EAAE,GAAW,EAAE,iBAAyB,4BAAY,CAAC,6BAA6B;QACtH,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;IACxE,CAAC;IAED,gBAAgB,CAAI,YAAoB;QACtC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,WAAW,CAAI,GAAW,EAAE,GAAG,MAAa;QAChD,iEAAiE;QACjE,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;IACxD,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,WAAW;QACT,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,iBAAS,CAAC,qEAAqE,CAAC,CAAC;QAC7F,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,CAAC;CACF;AAlLD,gDAkLC"}
|
@@ -5,7 +5,7 @@ import { DBOSContext, DBOSContextImpl } from "./context";
|
|
5
5
|
import { ValuesOf } from "./utils";
|
6
6
|
import { GlobalLogger as Logger } from "./telemetry/logs";
|
7
7
|
import { WorkflowContextDebug } from "./debugger/debug_workflow";
|
8
|
-
export type Transaction<T extends
|
8
|
+
export type Transaction<T extends unknown[], R> = (ctxt: TransactionContext<any>, ...args: T) => Promise<R>;
|
9
9
|
export interface TransactionConfig {
|
10
10
|
isolationLevel?: IsolationLevel;
|
11
11
|
readOnly?: boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE5G,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,cAAc,CAAC,CAAC;AAE7D,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,kBAAkB,CAAE,SAAQ,WAAW;IACnF,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;CACpB;AAED,qBAAa,sBAAsB,CAAC,CAAC,SAAS,kBAAkB,CAAE,SAAQ,eAAgB,YAAW,kBAAkB,CAAC,CAAC,CAAC;IAEtH,QAAQ,CAAC,UAAU,EAAE,gBAAgB;IACrC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAIlB,QAAQ,CAAC,UAAU,EAAE,MAAM;gBALlB,UAAU,EAAE,gBAAgB,EAC5B,MAAM,EAAE,CAAC,EAClB,eAAe,EAAE,mBAAmB,GAAG,oBAAoB,EAC3D,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACL,UAAU,EAAE,MAAM,EAC3B,aAAa,EAAE,MAAM;CAKxB"}
|
package/dist/src/utils.d.ts
CHANGED
@@ -3,17 +3,11 @@ export declare function readFileSync(path: string, encoding?: BufferEncoding): s
|
|
3
3
|
export declare const sleepms: (ms: number) => Promise<unknown>;
|
4
4
|
export type ValuesOf<T> = T[keyof T];
|
5
5
|
export declare function findPackageRoot(start: string | string[]): string;
|
6
|
-
|
7
|
-
* Reviver and Replacer
|
8
|
-
* --------------------
|
9
|
-
* These can be passed to JSON.stringify and JSON.parse, respectively, to support more types.
|
10
|
-
*
|
11
|
-
* Additional types supported:
|
12
|
-
* - Buffer
|
13
|
-
*
|
14
|
-
* Currently, these are only used for operation inputs.
|
15
|
-
* TODO: Use in other contexts where we perform serialization and deserialization.
|
16
|
-
*/
|
17
|
-
export declare function DBOSReplacer(_key: string, value: unknown): unknown;
|
6
|
+
export declare function DBOSReplacer(this: any, key: string, value: unknown): unknown;
|
18
7
|
export declare function DBOSReviver(_key: string, value: unknown): unknown;
|
8
|
+
export declare const DBOSJSON: {
|
9
|
+
parse: (text: string) => any;
|
10
|
+
stringify: (value: unknown) => string;
|
11
|
+
};
|
12
|
+
export declare function exhaustiveCheckGuard(_: never): never;
|
19
13
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/src/utils.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AASA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,cAAuB,GAAG,MAAM,CAYpF;AAED,eAAO,MAAM,OAAO,OAAQ,MAAM,qBAA0C,CAAC;AAE7E,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAGrC,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAoBhE;
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AASA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,cAAuB,GAAG,MAAM,CAYpF;AAED,eAAO,MAAM,OAAO,OAAQ,MAAM,qBAA0C,CAAC;AAE7E,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAGrC,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAoBhE;AAgCD,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,WAWlE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAUjE;AAED,eAAO,MAAM,QAAQ;kBACL,MAAM;uBAID,OAAO;CAG3B,CAAA;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAEpD"}
|
package/dist/src/utils.js
CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.DBOSReviver = exports.DBOSReplacer = exports.findPackageRoot = exports.sleepms = exports.readFileSync = void 0;
|
6
|
+
exports.exhaustiveCheckGuard = exports.DBOSJSON = exports.DBOSReviver = exports.DBOSReplacer = exports.findPackageRoot = exports.sleepms = exports.readFileSync = void 0;
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
8
8
|
const path_1 = __importDefault(require("path"));
|
9
9
|
/*
|
@@ -47,18 +47,18 @@ function findPackageRoot(start) {
|
|
47
47
|
return findPackageRoot(start);
|
48
48
|
}
|
49
49
|
exports.findPackageRoot = findPackageRoot;
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
//https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
52
|
+
function DBOSReplacer(key, value) {
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
54
|
+
const actualValue = this[key];
|
55
|
+
if (actualValue instanceof Date) {
|
56
|
+
const res = {
|
57
|
+
dbos_type: 'dbos_Date',
|
58
|
+
dbos_data: actualValue.toISOString()
|
59
|
+
};
|
60
|
+
return res;
|
61
|
+
}
|
62
62
|
return value;
|
63
63
|
}
|
64
64
|
exports.DBOSReplacer = DBOSReplacer;
|
@@ -67,7 +67,24 @@ function DBOSReviver(_key, value) {
|
|
67
67
|
if (candidate && candidate.type === 'Buffer' && Array.isArray(candidate.data)) {
|
68
68
|
return Buffer.from(candidate.data);
|
69
69
|
}
|
70
|
+
const dateCandidate = value;
|
71
|
+
if (dateCandidate && dateCandidate.dbos_type === 'dbos_Date') {
|
72
|
+
return new Date(Date.parse(dateCandidate.dbos_data));
|
73
|
+
}
|
70
74
|
return value;
|
71
75
|
}
|
72
76
|
exports.DBOSReviver = DBOSReviver;
|
77
|
+
exports.DBOSJSON = {
|
78
|
+
parse: (text) => {
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
80
|
+
return JSON.parse(text, DBOSReviver);
|
81
|
+
},
|
82
|
+
stringify: (value) => {
|
83
|
+
return JSON.stringify(value, DBOSReplacer);
|
84
|
+
}
|
85
|
+
};
|
86
|
+
function exhaustiveCheckGuard(_) {
|
87
|
+
throw new Error('Exaustive matching is not applied');
|
88
|
+
}
|
89
|
+
exports.exhaustiveCheckGuard = exhaustiveCheckGuard;
|
73
90
|
//# sourceMappingURL=utils.js.map
|
package/dist/src/utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB;;;;;IAKI;AACJ,SAAgB,YAAY,CAAC,IAAY,EAAE,WAA2B,MAAM;IAC1E,wBAAwB;IACxB,YAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAmC,EAAE,KAAe,EAAE,EAAE;QACrE,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACxE,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,gBAA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ACtB,+DAA+D;QAC/D,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IACtC,CAAC;IACD,SAAS,EAAE,CAAC,KAAc,EAAE,EAAE;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;IAC5C,CAAC;CACF,CAAA;AAED,SAAgB,oBAAoB,CAAC,CAAQ;IAC3C,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;AACvD,CAAC;AAFD,oDAEC"}
|
package/dist/src/workflow.d.ts
CHANGED
@@ -4,22 +4,30 @@ import { Communicator, CommunicatorContext } from "./communicator";
|
|
4
4
|
import { SystemDatabase } from "./system_database";
|
5
5
|
import { UserDatabaseClient } from "./user_database";
|
6
6
|
import { HTTPRequest, DBOSContext, DBOSContextImpl } from './context';
|
7
|
-
|
7
|
+
import { ConfiguredInstance } from "./decorators";
|
8
|
+
import { InvokeFuncsInst } from "./httpServer/handler";
|
9
|
+
export type Workflow<T extends unknown[], R> = (ctxt: WorkflowContext, ...args: T) => Promise<R>;
|
8
10
|
export type TailParameters<T extends (arg: any, args: any[]) => any> = T extends (arg: any, ...args: infer P) => any ? P : never;
|
9
11
|
type TxFunc = (ctxt: TransactionContext<any>, ...args: any[]) => Promise<any>;
|
10
12
|
type CommFunc = (ctxt: CommunicatorContext, ...args: any[]) => Promise<any>;
|
11
|
-
export type WFInvokeFuncs<T> = {
|
13
|
+
export type WFInvokeFuncs<T> = T extends ConfiguredInstance ? never : {
|
12
14
|
[P in keyof T as T[P] extends TxFunc | CommFunc ? P : never]: T[P] extends TxFunc | CommFunc ? (...args: TailParameters<T[P]>) => ReturnType<T[P]> : never;
|
13
15
|
};
|
16
|
+
export type WFInvokeFuncsInst<T> = T extends ConfiguredInstance ? {
|
17
|
+
[P in keyof T as T[P] extends TxFunc | CommFunc ? P : never]: T[P] extends TxFunc | CommFunc ? (...args: TailParameters<T[P]>) => ReturnType<T[P]> : never;
|
18
|
+
} : never;
|
14
19
|
export interface WorkflowParams {
|
15
20
|
workflowUUID?: string;
|
16
21
|
parentCtx?: DBOSContextImpl;
|
22
|
+
configuredInstance?: ConfiguredInstance | null;
|
17
23
|
}
|
18
24
|
export interface WorkflowConfig {
|
19
25
|
}
|
20
26
|
export interface WorkflowStatus {
|
21
27
|
readonly status: string;
|
22
28
|
readonly workflowName: string;
|
29
|
+
readonly workflowClassName: string;
|
30
|
+
readonly workflowConfigName: string;
|
23
31
|
readonly authenticatedUser: string;
|
24
32
|
readonly assumedRole: string;
|
25
33
|
readonly authenticatedRoles: string[];
|
@@ -38,11 +46,32 @@ export declare const StatusString: {
|
|
38
46
|
readonly SUCCESS: "SUCCESS";
|
39
47
|
readonly ERROR: "ERROR";
|
40
48
|
};
|
49
|
+
type WFFunc = (ctxt: WorkflowContext, ...args: any[]) => Promise<unknown>;
|
50
|
+
export type WfInvokeWfs<T> = {
|
51
|
+
[P in keyof T]: T[P] extends WFFunc ? (...args: TailParameters<T[P]>) => ReturnType<T[P]> : never;
|
52
|
+
};
|
53
|
+
export type WfInvokeWfsAsync<T> = {
|
54
|
+
[P in keyof T]: T[P] extends WFFunc ? (...args: TailParameters<T[P]>) => Promise<WorkflowHandle<Awaited<ReturnType<T[P]>>>> : never;
|
55
|
+
};
|
56
|
+
export type WfInvokeWfsInst<T> = T extends ConfiguredInstance ? {
|
57
|
+
[P in keyof T]: T[P] extends WFFunc ? (...args: TailParameters<T[P]>) => ReturnType<T[P]> : never;
|
58
|
+
} : never;
|
59
|
+
export type WfInvokeWfsInstAsync<T> = T extends ConfiguredInstance ? {
|
60
|
+
[P in keyof T]: T[P] extends WFFunc ? (...args: TailParameters<T[P]>) => Promise<WorkflowHandle<Awaited<ReturnType<T[P]>>>> : never;
|
61
|
+
} : never;
|
41
62
|
export interface WorkflowContext extends DBOSContext {
|
63
|
+
invoke<T extends ConfiguredInstance>(targetCfg: T): InvokeFuncsInst<T>;
|
42
64
|
invoke<T extends object>(targetClass: T): WFInvokeFuncs<T>;
|
65
|
+
/** @deprecated See startWorkflow */
|
43
66
|
startChildWorkflow<T extends any[], R>(wf: Workflow<T, R>, ...args: T): Promise<WorkflowHandle<R>>;
|
44
|
-
|
45
|
-
|
67
|
+
/** @deprecated See invokeWorkflow */
|
68
|
+
invokeChildWorkflow<T extends unknown[], R>(wf: Workflow<T, R>, ...args: T): Promise<R>;
|
69
|
+
/** @deprecated calls startWorkflow */
|
70
|
+
childWorkflow<T extends unknown[], R>(wf: Workflow<T, R>, ...args: T): Promise<WorkflowHandle<R>>;
|
71
|
+
invokeWorkflow<T extends ConfiguredInstance>(targetClass: T): WfInvokeWfsInst<T>;
|
72
|
+
invokeWorkflow<T extends object>(targetClass: T): WfInvokeWfs<T>;
|
73
|
+
startWorkflow<T extends ConfiguredInstance>(targetClass: T): WfInvokeWfsInstAsync<T>;
|
74
|
+
startWorkflow<T extends object>(targetClass: T): WfInvokeWfsAsync<T>;
|
46
75
|
send<T>(destinationUUID: string, message: T, topic?: string): Promise<void>;
|
47
76
|
recv<T>(topic?: string, timeoutSeconds?: number): Promise<T | null>;
|
48
77
|
setEvent<T>(key: string, value: T): Promise<void>;
|
@@ -94,22 +123,29 @@ export declare class WorkflowContextImpl extends DBOSContextImpl implements Work
|
|
94
123
|
* We pass in itself as a parent context and assign the child workflow with a deterministic UUID "this.workflowUUID-functionID".
|
95
124
|
* We also pass in its own workflowUUID and function ID so the invoked handle is deterministic.
|
96
125
|
*/
|
97
|
-
startChildWorkflow<T extends
|
98
|
-
invokeChildWorkflow<T extends
|
99
|
-
|
126
|
+
startChildWorkflow<T extends unknown[], R>(wf: Workflow<T, R>, ...args: T): Promise<WorkflowHandle<R>>;
|
127
|
+
invokeChildWorkflow<T extends unknown[], R>(wf: Workflow<T, R>, ...args: T): Promise<R>;
|
128
|
+
/**
|
129
|
+
* Generate a proxy object for the provided class that wraps direct calls (i.e. OpClass.someMethod(param))
|
130
|
+
* to use WorkflowContext.Transaction(OpClass.someMethod, param);
|
131
|
+
*/
|
132
|
+
proxyInvokeWF<T extends object>(object: T, workflowUUID: string | undefined, asyncWf: boolean, configuredInstance: ConfiguredInstance | null): WfInvokeWfsAsync<T>;
|
133
|
+
startWorkflow<T extends object>(target: T, workflowUUID?: string): WfInvokeWfsAsync<T>;
|
134
|
+
invokeWorkflow<T extends object>(target: T, workflowUUID?: string): WfInvokeWfs<T>;
|
135
|
+
childWorkflow<T extends unknown[], R>(wf: Workflow<T, R>, ...args: T): Promise<WorkflowHandle<R>>;
|
100
136
|
/**
|
101
137
|
* Execute a transactional function.
|
102
138
|
* The transaction is guaranteed to execute exactly once, even if the workflow is retried with the same UUID.
|
103
139
|
* If the transaction encounters a Postgres serialization error, retry it.
|
104
140
|
* If it encounters any other error, throw it.
|
105
141
|
*/
|
106
|
-
transaction<T extends
|
142
|
+
transaction<T extends unknown[], R>(txn: Transaction<T, R>, clsinst: ConfiguredInstance | null, ...args: T): Promise<R>;
|
107
143
|
/**
|
108
144
|
* Execute a communicator function.
|
109
145
|
* If it encounters any error, retry according to its configured retry policy until the maximum number of attempts is reached, then throw an DBOSError.
|
110
146
|
* The communicator may execute many times, but once it is complete, it will not re-execute.
|
111
147
|
*/
|
112
|
-
external<T extends
|
148
|
+
external<T extends unknown[], R>(commFn: Communicator<T, R>, clsInst: ConfiguredInstance | null, ...args: T): Promise<R>;
|
113
149
|
/**
|
114
150
|
* Send a message to a workflow identified by a UUID.
|
115
151
|
* The message can optionally be tagged with a topic.
|
@@ -130,7 +166,7 @@ export declare class WorkflowContextImpl extends DBOSContextImpl implements Work
|
|
130
166
|
* Generate a proxy object for the provided class that wraps direct calls (i.e. OpClass.someMethod(param))
|
131
167
|
* to use WorkflowContext.Transaction(OpClass.someMethod, param);
|
132
168
|
*/
|
133
|
-
invoke<T extends object>(object: T): WFInvokeFuncs<T>;
|
169
|
+
invoke<T extends object>(object: T | ConfiguredInstance): WFInvokeFuncs<T> | InvokeFuncsInst<T>;
|
134
170
|
/**
|
135
171
|
* Wait for a workflow to emit an event, then return its value.
|
136
172
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAqC,MAAM,iBAAiB,CAAC;AAElF,OAAO,EAAkB,WAAW,EAAE,kBAAkB,EAA0B,MAAM,eAAe,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA2B,MAAM,gBAAgB,CAAC;AAI5F,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAqC,MAAM,iBAAiB,CAAC;AAElF,OAAO,EAAkB,WAAW,EAAE,kBAAkB,EAA0B,MAAM,eAAe,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA2B,MAAM,gBAAgB,CAAC;AAI5F,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAA2B,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAGjG,MAAM,MAAM,cAAc,CAAC,C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AO,CAAC,CAAC,CAAC;CAG9B;AAED;;GAEG;AACH,qBAAa,eAAe,CAAC,CAAC,CAAE,YAAW,cAAc,CAAC,CAAC,CAAC;IAC9C,QAAQ,CAAC,cAAc,EAAE,cAAc;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM;IAAE,QAAQ,CAAC,UAAU,CAAC;IAAU,QAAQ,CAAC,gBAAgB,CAAC;gBAAvH,cAAc,EAAE,cAAc,EAAW,YAAY,EAAE,MAAM,EAAW,UAAU,CAAC,oBAAQ,EAAW,gBAAgB,CAAC,oBAAQ;IAEpJ,eAAe,IAAI,MAAM;IAInB,SAAS,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAI3C,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC;CAG9B"}
|
package/dist/src/workflow.js
CHANGED
@@ -78,11 +78,11 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
78
78
|
// recorded=false row will be first because we used ORDER BY.
|
79
79
|
res.txn_snapshot = rows[0].txn_snapshot;
|
80
80
|
if (rows.length === 2) {
|
81
|
-
if (
|
82
|
-
throw (0, serialize_error_1.deserializeError)(
|
81
|
+
if (utils_1.DBOSJSON.parse(rows[1].error) !== null) {
|
82
|
+
throw (0, serialize_error_1.deserializeError)(utils_1.DBOSJSON.parse(rows[1].error));
|
83
83
|
}
|
84
84
|
else {
|
85
|
-
res.output =
|
85
|
+
res.output = utils_1.DBOSJSON.parse(rows[1].output);
|
86
86
|
}
|
87
87
|
}
|
88
88
|
return res;
|
@@ -112,7 +112,7 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
112
112
|
sqlStmt += ", ";
|
113
113
|
}
|
114
114
|
sqlStmt += `($${paramCnt++}, $${paramCnt++}, $${paramCnt++}, $${paramCnt++}, null, $${paramCnt++}, $${paramCnt++})`;
|
115
|
-
values.push(this.workflowUUID, funcID,
|
115
|
+
values.push(this.workflowUUID, funcID, utils_1.DBOSJSON.stringify(output), utils_1.DBOSJSON.stringify(null), txnSnapshot, createdAt);
|
116
116
|
}
|
117
117
|
this.logger.debug(sqlStmt);
|
118
118
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
@@ -133,7 +133,7 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
133
133
|
*/
|
134
134
|
async recordOutput(client, funcID, txnSnapshot, output) {
|
135
135
|
try {
|
136
|
-
const serialOutput =
|
136
|
+
const serialOutput = utils_1.DBOSJSON.stringify(output);
|
137
137
|
const rows = await this.#dbosExec.userDatabase.queryWithClient(client, "INSERT INTO dbos.transaction_outputs (workflow_uuid, function_id, output, txn_id, txn_snapshot, created_at) VALUES ($1, $2, $3, (select pg_current_xact_id_if_assigned()::text), $4, $5) RETURNING txn_id;", this.workflowUUID, funcID, serialOutput, txnSnapshot, Date.now());
|
138
138
|
return rows[0].txn_id;
|
139
139
|
}
|
@@ -152,7 +152,7 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
152
152
|
*/
|
153
153
|
async recordError(client, funcID, txnSnapshot, err) {
|
154
154
|
try {
|
155
|
-
const serialErr =
|
155
|
+
const serialErr = utils_1.DBOSJSON.stringify((0, serialize_error_1.serializeError)(err));
|
156
156
|
await this.#dbosExec.userDatabase.queryWithClient(client, "INSERT INTO dbos.transaction_outputs (workflow_uuid, function_id, error, txn_id, txn_snapshot, created_at) VALUES ($1, $2, $3, null, $4, $5) RETURNING txn_id;", this.workflowUUID, funcID, serialErr, txnSnapshot, Date.now());
|
157
157
|
}
|
158
158
|
catch (error) {
|
@@ -180,7 +180,47 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
180
180
|
async invokeChildWorkflow(wf, ...args) {
|
181
181
|
return this.startChildWorkflow(wf, ...args).then((handle) => handle.getResult());
|
182
182
|
}
|
183
|
-
|
183
|
+
/**
|
184
|
+
* Generate a proxy object for the provided class that wraps direct calls (i.e. OpClass.someMethod(param))
|
185
|
+
* to use WorkflowContext.Transaction(OpClass.someMethod, param);
|
186
|
+
*/
|
187
|
+
proxyInvokeWF(object, workflowUUID, asyncWf, configuredInstance) {
|
188
|
+
const ops = (0, decorators_1.getRegisteredOperations)(object);
|
189
|
+
const proxy = {};
|
190
|
+
const funcId = this.functionIDGetIncrement();
|
191
|
+
const childUUID = workflowUUID || (this.workflowUUID + "-" + funcId);
|
192
|
+
const params = { workflowUUID: childUUID, parentCtx: this, configuredInstance };
|
193
|
+
for (const op of ops) {
|
194
|
+
if (asyncWf) {
|
195
|
+
proxy[op.name] = op.workflowConfig
|
196
|
+
? (...args) => this.#dbosExec.internalWorkflow(op.registeredFunction, params, this.workflowUUID, funcId, ...args)
|
197
|
+
: undefined;
|
198
|
+
}
|
199
|
+
else {
|
200
|
+
proxy[op.name] = op.workflowConfig
|
201
|
+
? (...args) => this.#dbosExec.internalWorkflow(op.registeredFunction, params, this.workflowUUID, funcId, ...args)
|
202
|
+
.then((handle) => handle.getResult())
|
203
|
+
: undefined;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
return proxy;
|
207
|
+
}
|
208
|
+
startWorkflow(target, workflowUUID) {
|
209
|
+
if (typeof target === 'function') {
|
210
|
+
return this.proxyInvokeWF(target, workflowUUID, true, null);
|
211
|
+
}
|
212
|
+
else {
|
213
|
+
return this.proxyInvokeWF(target, workflowUUID, true, target);
|
214
|
+
}
|
215
|
+
}
|
216
|
+
invokeWorkflow(target, workflowUUID) {
|
217
|
+
if (typeof target === 'function') {
|
218
|
+
return this.proxyInvokeWF(target, workflowUUID, false, null);
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
return this.proxyInvokeWF(target, workflowUUID, false, target);
|
222
|
+
}
|
223
|
+
}
|
184
224
|
async childWorkflow(wf, ...args) {
|
185
225
|
return this.startChildWorkflow(wf, ...args);
|
186
226
|
}
|
@@ -190,8 +230,8 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
190
230
|
* If the transaction encounters a Postgres serialization error, retry it.
|
191
231
|
* If it encounters any other error, throw it.
|
192
232
|
*/
|
193
|
-
async transaction(txn, ...args) {
|
194
|
-
const txnInfo = this.#dbosExec.
|
233
|
+
async transaction(txn, clsinst, ...args) {
|
234
|
+
const txnInfo = this.#dbosExec.getTransactionInfo(txn);
|
195
235
|
if (txnInfo === undefined) {
|
196
236
|
throw new error_1.DBOSNotRegisteredError(txn.name);
|
197
237
|
}
|
@@ -236,7 +276,7 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
236
276
|
await this.flushResultBuffer(client);
|
237
277
|
}
|
238
278
|
// Execute the user's transaction.
|
239
|
-
const result = await txn(tCtxt, ...args);
|
279
|
+
const result = await txn.call(clsinst, tCtxt, ...args);
|
240
280
|
// Record the execution, commit, and return.
|
241
281
|
if (readOnly) {
|
242
282
|
// Buffer the output of read-only transactions instead of synchronously writing it.
|
@@ -289,8 +329,8 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
289
329
|
* If it encounters any error, retry according to its configured retry policy until the maximum number of attempts is reached, then throw an DBOSError.
|
290
330
|
* The communicator may execute many times, but once it is complete, it will not re-execute.
|
291
331
|
*/
|
292
|
-
async external(commFn, ...args) {
|
293
|
-
const commInfo = this.#dbosExec.
|
332
|
+
async external(commFn, clsInst, ...args) {
|
333
|
+
const commInfo = this.#dbosExec.getCommunicatorInfo(commFn);
|
294
334
|
if (commInfo === undefined) {
|
295
335
|
throw new error_1.DBOSNotRegisteredError(commFn.name);
|
296
336
|
}
|
@@ -333,7 +373,7 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
333
373
|
}
|
334
374
|
while (result === dbos_executor_1.dbosNull && numAttempts++ < ctxt.maxAttempts) {
|
335
375
|
try {
|
336
|
-
result = await commFn(ctxt, ...args);
|
376
|
+
result = await commFn.call(clsInst, ctxt, ...args);
|
337
377
|
}
|
338
378
|
catch (error) {
|
339
379
|
this.logger.error(error);
|
@@ -350,7 +390,7 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
350
390
|
}
|
351
391
|
else {
|
352
392
|
try {
|
353
|
-
result = await commFn(ctxt, ...args);
|
393
|
+
result = await commFn.call(clsInst, ctxt, ...args);
|
354
394
|
}
|
355
395
|
catch (error) {
|
356
396
|
err = error;
|
@@ -415,19 +455,31 @@ class WorkflowContextImpl extends context_1.DBOSContextImpl {
|
|
415
455
|
* to use WorkflowContext.Transaction(OpClass.someMethod, param);
|
416
456
|
*/
|
417
457
|
invoke(object) {
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
458
|
+
if (typeof object === 'function') {
|
459
|
+
const ops = (0, decorators_1.getRegisteredOperations)(object);
|
460
|
+
const proxy = {};
|
461
|
+
for (const op of ops) {
|
462
|
+
proxy[op.name] = op.txnConfig
|
463
|
+
? (...args) => this.transaction(op.registeredFunction, null, ...args)
|
464
|
+
: op.commConfig
|
465
|
+
? (...args) => this.external(op.registeredFunction, null, ...args)
|
466
|
+
: undefined;
|
467
|
+
}
|
468
|
+
return proxy;
|
469
|
+
}
|
470
|
+
else {
|
471
|
+
const targetInst = object;
|
472
|
+
const ops = (0, decorators_1.getRegisteredOperations)(targetInst);
|
473
|
+
const proxy = {};
|
474
|
+
for (const op of ops) {
|
475
|
+
proxy[op.name] = op.txnConfig
|
476
|
+
? (...args) => this.transaction(op.registeredFunction, targetInst, ...args)
|
477
|
+
: op.commConfig
|
478
|
+
? (...args) => this.external(op.registeredFunction, targetInst, ...args)
|
479
|
+
: undefined;
|
480
|
+
}
|
481
|
+
return proxy;
|
429
482
|
}
|
430
|
-
return proxy;
|
431
483
|
}
|
432
484
|
/**
|
433
485
|
* Wait for a workflow to emit an event, then return its value.
|