@dbos-inc/dbos-sdk 4.26.6-preview → 4.26.7-preview
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/dist/src/datasource.d.ts +20 -1
- package/dist/src/datasource.d.ts.map +1 -1
- package/dist/src/datasource.js +40 -2
- package/dist/src/datasource.js.map +1 -1
- package/dist/src/system_database.js +5 -5
- package/dist/src/system_database.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/datasource.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FunctionName } from './decorators';
|
|
2
|
+
import { DBOSError } from './error';
|
|
2
3
|
/**
|
|
3
4
|
* This interface is to be used for implementers of transactional data sources
|
|
4
5
|
* This is what gets registered for the transaction control framework
|
|
@@ -95,6 +96,25 @@ export interface PGTransactionConfig {
|
|
|
95
96
|
/** If set, request read-only transaction from underlying app database */
|
|
96
97
|
readOnly?: boolean;
|
|
97
98
|
}
|
|
99
|
+
/** Base error type, re-exported so data sources can raise DBOS-typed failures. */
|
|
100
|
+
export { DBOSError };
|
|
101
|
+
/**
|
|
102
|
+
* Internal signal that a concurrent duplicate execution recorded this step's outcome first.
|
|
103
|
+
* Data sources throw this from their completion insert so the user transaction rolls back
|
|
104
|
+
* and the recorded outcome is replayed instead; it is never surfaced to user code.
|
|
105
|
+
*/
|
|
106
|
+
export declare class DBOSStepAlreadyRecordedError extends Error {
|
|
107
|
+
constructor(workflowID: string, stepID: number);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Deliver a transaction outcome recorded by an earlier or concurrent execution.
|
|
111
|
+
* Data sources share this between their pre-execution check and their conflict handler
|
|
112
|
+
* so the two paths cannot drift apart.
|
|
113
|
+
*/
|
|
114
|
+
export declare function replayRecordedStep<Return>(recorded: {
|
|
115
|
+
output?: string | null;
|
|
116
|
+
error?: string | null;
|
|
117
|
+
}): Return;
|
|
98
118
|
export interface CheckSchemaInstallationReturn {
|
|
99
119
|
schema_exists: number;
|
|
100
120
|
table_exists: number;
|
|
@@ -105,5 +125,4 @@ export declare function createTransactionCompletionTablePG(schemaName?: string):
|
|
|
105
125
|
export declare function isPGRetriableTransactionError(error: unknown): boolean;
|
|
106
126
|
export declare function isPGKeyConflictError(error: unknown): boolean;
|
|
107
127
|
export declare function isPGFailedSqlTransactionError(error: unknown): boolean;
|
|
108
|
-
export {};
|
|
109
128
|
//# sourceMappingURL=datasource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/datasource.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,YAAY,EAKb,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/datasource.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,YAAY,EAKb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAsC,MAAM,SAAS,CAAC;AAIxE;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;OAEG;IACH,yBAAyB,CAAC,IAAI,EAAE,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EAC5D,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,IAAI,EACZ,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,EACpD,GAAG,IAAI,EAAE,IAAI,GACZ,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc,CA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,yBAAyB,CAAC,UAAU,GAAE,MAAe,GAAG,MAAM,CAe7E;AAED,wBAAgB,mCAAmC,CAAC,UAAU,GAAE,MAAe,GAAG,MAAM,CAEvF;AAED,wBAAgB,kCAAkC,CAAC,UAAU,GAAE,MAAe,GAAG,MAAM,CAWtF;AAiBD,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAErE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE5D;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAErE"}
|
package/dist/src/datasource.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPGFailedSqlTransactionError = exports.isPGKeyConflictError = exports.isPGRetriableTransactionError = exports.createTransactionCompletionTablePG = exports.createTransactionCompletionSchemaPG = exports.checkSchemaInstallationPG = exports.PGIsolationLevel = exports.registerDataSource = exports.registerTransaction = exports.runTransaction = void 0;
|
|
3
|
+
exports.isPGFailedSqlTransactionError = exports.isPGKeyConflictError = exports.isPGRetriableTransactionError = exports.createTransactionCompletionTablePG = exports.createTransactionCompletionSchemaPG = exports.checkSchemaInstallationPG = exports.replayRecordedStep = exports.DBOSStepAlreadyRecordedError = exports.DBOSError = exports.PGIsolationLevel = exports.registerDataSource = exports.registerTransaction = exports.runTransaction = void 0;
|
|
4
4
|
const context_1 = require("./context");
|
|
5
5
|
const dbos_1 = require("./dbos");
|
|
6
6
|
const dbos_executor_1 = require("./dbos-executor");
|
|
7
7
|
const decorators_1 = require("./decorators");
|
|
8
8
|
const error_1 = require("./error");
|
|
9
|
+
Object.defineProperty(exports, "DBOSError", { enumerable: true, get: function () { return error_1.DBOSError; } });
|
|
9
10
|
const traces_1 = require("./telemetry/traces");
|
|
11
|
+
const superjson_1 = require("superjson");
|
|
10
12
|
/// Calling into DBOS
|
|
11
13
|
/**
|
|
12
14
|
* This function is to be called by `DataSourceTransactionHandler` instances,
|
|
@@ -142,6 +144,32 @@ exports.PGIsolationLevel = Object.freeze({
|
|
|
142
144
|
RepeatableRead: 'REPEATABLE READ',
|
|
143
145
|
Serializable: 'SERIALIZABLE',
|
|
144
146
|
});
|
|
147
|
+
/**
|
|
148
|
+
* Internal signal that a concurrent duplicate execution recorded this step's outcome first.
|
|
149
|
+
* Data sources throw this from their completion insert so the user transaction rolls back
|
|
150
|
+
* and the recorded outcome is replayed instead; it is never surfaced to user code.
|
|
151
|
+
*/
|
|
152
|
+
class DBOSStepAlreadyRecordedError extends Error {
|
|
153
|
+
constructor(workflowID, stepID) {
|
|
154
|
+
super(`Step ${stepID} of workflow ${workflowID} was already recorded by a concurrent execution`);
|
|
155
|
+
this.name = 'DBOSStepAlreadyRecordedError';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.DBOSStepAlreadyRecordedError = DBOSStepAlreadyRecordedError;
|
|
159
|
+
/**
|
|
160
|
+
* Deliver a transaction outcome recorded by an earlier or concurrent execution.
|
|
161
|
+
* Data sources share this between their pre-execution check and their conflict handler
|
|
162
|
+
* so the two paths cannot drift apart.
|
|
163
|
+
*/
|
|
164
|
+
function replayRecordedStep(recorded) {
|
|
165
|
+
dbos_1.DBOS.span?.setAttribute('cached', true);
|
|
166
|
+
// Discriminate on the value: a raw row carries both keys, with the unused one null.
|
|
167
|
+
if (typeof recorded.error === 'string') {
|
|
168
|
+
throw superjson_1.SuperJSON.parse(recorded.error);
|
|
169
|
+
}
|
|
170
|
+
return (recorded.output ? superjson_1.SuperJSON.parse(recorded.output) : null);
|
|
171
|
+
}
|
|
172
|
+
exports.replayRecordedStep = replayRecordedStep;
|
|
145
173
|
function checkSchemaInstallationPG(schemaName = 'dbos') {
|
|
146
174
|
return `
|
|
147
175
|
SELECT
|
|
@@ -176,8 +204,18 @@ function createTransactionCompletionTablePG(schemaName = 'dbos') {
|
|
|
176
204
|
`;
|
|
177
205
|
}
|
|
178
206
|
exports.createTransactionCompletionTablePG = createTransactionCompletionTablePG;
|
|
207
|
+
const SQLSTATE_PATTERN = /^[0-9A-Z]{5}$/;
|
|
179
208
|
function getPGErrorCode(error) {
|
|
180
|
-
|
|
209
|
+
// Some clients wrap the driver's error, so follow the cause chain to find the code.
|
|
210
|
+
for (let depth = 0, e = error; e && typeof e === 'object' && depth < 10; depth++) {
|
|
211
|
+
// Only a SQLSTATE ends the search, so a wrapper's own code cannot shadow the driver's.
|
|
212
|
+
const code = e.code;
|
|
213
|
+
if (typeof code === 'string' && SQLSTATE_PATTERN.test(code)) {
|
|
214
|
+
return code;
|
|
215
|
+
}
|
|
216
|
+
e = e.cause;
|
|
217
|
+
}
|
|
218
|
+
return undefined;
|
|
181
219
|
}
|
|
182
220
|
function isPGRetriableTransactionError(error) {
|
|
183
221
|
return getPGErrorCode(error) === '40001';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../src/datasource.ts"],"names":[],"mappings":";;;AAAA,uCAA0F;AAC1F,iCAA8B;AAC9B,mDAA8D;AAC9D,6CAOsB;AACtB,
|
|
1
|
+
{"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../src/datasource.ts"],"names":[],"mappings":";;;AAAA,uCAA0F;AAC1F,iCAA8B;AAC9B,mDAA8D;AAC9D,6CAOsB;AACtB,mCAAwE;AAiS/D,0FAjSA,iBAAS,OAiSA;AAhSlB,+CAAkE;AAClE,yCAAsC;AAyFtC,qBAAqB;AAErB;;;;;;;;;;GAUG;AACI,KAAK,UAAU,cAAc,CAClC,QAA0B,EAC1B,QAAgB,EAChB,UAAiD,EAAE;IAEnD,IAAA,iCAAoB,EAAC,cAAc,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC;IAC1C,MAAM,EAAE,GAAG,IAAA,uCAA0B,EAAC,GAAG,CAAC,CAAC;IAE3C,IAA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WC;AAED,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEzC,SAAS,cAAc,CAAC,KAAc;IACpC,oFAAoF;IACpF,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;QACjF,uFAAuF;QACvF,MAAM,IAAI,GAAI,CAAwB,CAAC,IAAI,CAAC;QAC5C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,CAAC,GAAI,CAAyB,CAAC,KAAK,CAAC;IACvC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,6BAA6B,CAAC,KAAc;IAC1D,OAAO,cAAc,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC;AAC3C,CAAC;AAFD,sEAEC;AAED,SAAgB,oBAAoB,CAAC,KAAc;IACjD,OAAO,cAAc,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC;AAC3C,CAAC;AAFD,oDAEC;AAED,SAAgB,6BAA6B,CAAC,KAAc;IAC1D,OAAO,cAAc,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC;AAC3C,CAAC;AAFD,sEAEC"}
|
|
@@ -1211,15 +1211,15 @@ class SystemDatabase {
|
|
|
1211
1211
|
}
|
|
1212
1212
|
const result = await this.pool.query(query, params);
|
|
1213
1213
|
const startStepByID = new Map(result.rows.map((r) => [r.workflow_uuid, Number(r.start_step)]));
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
if (
|
|
1214
|
+
if (options.fromStepName !== undefined) {
|
|
1215
|
+
for (const wid of workflowIDs) {
|
|
1216
|
+
if (!startStepByID.has(wid)) {
|
|
1217
1217
|
throw new Error(`Workflow ${wid} has no step named '${options.fromStepName}'`);
|
|
1218
1218
|
}
|
|
1219
|
-
throw new Error(`Workflow ${wid} has no steps`);
|
|
1220
1219
|
}
|
|
1221
1220
|
}
|
|
1222
|
-
|
|
1221
|
+
// A workflow with no recorded steps has nothing to resume from, so restart it from the beginning.
|
|
1222
|
+
startSteps = workflowIDs.map((wid) => startStepByID.get(wid) ?? 0);
|
|
1223
1223
|
}
|
|
1224
1224
|
const forkedIDs = workflowIDs.map(() => (0, crypto_1.randomUUID)());
|
|
1225
1225
|
return this.bulkForkWorkflows(workflowIDs, forkedIDs, startSteps, options);
|