@dbos-inc/typeorm-datasource 3.0.10-preview → 3.0.11-preview.gc9233b8190

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.
@@ -0,0 +1,2 @@
1
+ export { IsolationLevel, TypeOrmDataSource, TypeOrmTransactionConfig } from './typeorm_datasource';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeOrmDataSource = exports.IsolationLevel = void 0;
4
+ var typeorm_datasource_1 = require("./typeorm_datasource");
5
+ Object.defineProperty(exports, "IsolationLevel", { enumerable: true, get: function () { return typeorm_datasource_1.IsolationLevel; } });
6
+ Object.defineProperty(exports, "TypeOrmDataSource", { enumerable: true, get: function () { return typeorm_datasource_1.TypeOrmDataSource; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAmG;AAA1F,oHAAA,cAAc,OAAA;AAAE,uHAAA,iBAAiB,OAAA"}
@@ -1,12 +1,15 @@
1
1
  import { PoolConfig } from 'pg';
2
- import { DBOSDataSource, PGTransactionConfig } from '@dbos-inc/dbos-sdk/datasource';
2
+ import { PGIsolationLevel as IsolationLevel, PGTransactionConfig as TypeOrmTransactionConfig, DBOSDataSource } from '@dbos-inc/dbos-sdk/datasource';
3
3
  import { EntityManager } from 'typeorm';
4
- export declare class TypeOrmDataSource implements DBOSDataSource<PGTransactionConfig> {
4
+ export { IsolationLevel, TypeOrmTransactionConfig };
5
+ export declare class TypeOrmDataSource implements DBOSDataSource<TypeOrmTransactionConfig> {
5
6
  #private;
6
7
  readonly name: string;
7
- static get entityManager(): EntityManager;
8
- static initializeInternalSchema(config: PoolConfig): Promise<void>;
8
+ readonly config: PoolConfig;
9
+ readonly entities: Function[];
9
10
  constructor(name: string, config: PoolConfig, entities: Function[]);
11
+ static get entityManager(): EntityManager;
12
+ initializeInternalSchema(): Promise<void>;
10
13
  /**
11
14
  * Run `callback` as a transaction against this DataSource
12
15
  * @param callback Function to run within a transactional context
@@ -14,7 +17,7 @@ export declare class TypeOrmDataSource implements DBOSDataSource<PGTransactionCo
14
17
  * @param config Transaction configuration (isolation, etc)
15
18
  * @returns Return value from `callback`
16
19
  */
17
- runTransaction<T>(callback: () => Promise<T>, funcName: string, config?: PGTransactionConfig): Promise<T>;
20
+ runTransaction<T>(callback: () => Promise<T>, funcName: string, config?: TypeOrmTransactionConfig): Promise<T>;
18
21
  /**
19
22
  * Register function as DBOS transaction, to be called within the context
20
23
  * of a transaction on this data source.
@@ -24,10 +27,14 @@ export declare class TypeOrmDataSource implements DBOSDataSource<PGTransactionCo
24
27
  * @param config Transaction settings
25
28
  * @returns Wrapped function, to be called instead of `func`
26
29
  */
27
- registerTransaction<This, Args extends unknown[], Return>(func: (this: This, ...args: Args) => Promise<Return>, config?: PGTransactionConfig, name?: string): (this: This, ...args: Args) => Promise<Return>;
30
+ registerTransaction<This, Args extends unknown[], Return>(func: (this: This, ...args: Args) => Promise<Return>, name: string, config?: TypeOrmTransactionConfig): (this: This, ...args: Args) => Promise<Return>;
28
31
  /**
29
32
  * Decorator establishing function as a transaction
30
33
  */
31
- transaction(config?: PGTransactionConfig): <This, Args extends unknown[], Return>(_target: object, propertyKey: PropertyKey, descriptor: TypedPropertyDescriptor<(this: This, ...args: Args) => Promise<Return>>) => TypedPropertyDescriptor<(this: This, ...args: Args) => Promise<Return>>;
34
+ transaction(config?: TypeOrmTransactionConfig): <This, Args extends unknown[], Return>(_target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<(this: This, ...args: Args) => Promise<Return>>) => TypedPropertyDescriptor<(this: This, ...args: Args) => Promise<Return>>;
35
+ /**
36
+ * For testing: Use DataSource.syncronize to install the user schema
37
+ */
38
+ createSchema(): Promise<void>;
32
39
  }
33
- //# sourceMappingURL=index.d.ts.map
40
+ //# sourceMappingURL=typeorm_datasource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeorm_datasource.d.ts","sourceRoot":"","sources":["../../src/typeorm_datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,OAAO,EASL,gBAAgB,IAAI,cAAc,EAClC,mBAAmB,IAAI,wBAAwB,EAC/C,cAAc,EAEf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAc,aAAa,EAAE,MAAM,SAAS,CAAC;AA0BpD,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,CAAC;AA+LpD,qBAAa,iBAAkB,YAAW,cAAc,CAAC,wBAAwB,CAAC;;IAG9E,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,UAAU;IAE3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE;gBAHpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,UAAU,EAElB,QAAQ,EAAE,QAAQ,EAAE;IAO/B,MAAM,KAAK,aAAa,IAAI,aAAa,CAOxC;IAEK,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB/C;;;;;;OAMG;IACG,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,wBAAwB;IAIvG;;;;;;;;OAQG;IACH,mBAAmB,CAAC,IAAI,EAAE,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EACtD,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,EACpD,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,wBAAwB,GAChC,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC;IAIjD;;OAEG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,wBAAwB,mDAIhC,MAAM,eACF,MAAM,cACP,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,QAAQ,MAAM,CAAC,CAAC,oCAAxC,IAAI,WAAW,IAAI,KAAK,QAAQ,MAAM,CAAC;IAYtF;;OAEG;IACG,YAAY;CAQnB"}
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeOrmDataSource = exports.IsolationLevel = void 0;
4
+ const dbos_sdk_1 = require("@dbos-inc/dbos-sdk");
5
+ const datasource_1 = require("@dbos-inc/dbos-sdk/datasource");
6
+ Object.defineProperty(exports, "IsolationLevel", { enumerable: true, get: function () { return datasource_1.PGIsolationLevel; } });
7
+ const typeorm_1 = require("typeorm");
8
+ const async_hooks_1 = require("async_hooks");
9
+ const superjson_1 = require("superjson");
10
+ const asyncLocalCtx = new async_hooks_1.AsyncLocalStorage();
11
+ function getCurrentDSContextStore() {
12
+ return asyncLocalCtx.getStore();
13
+ }
14
+ function assertCurrentDSContextStore() {
15
+ const ctx = getCurrentDSContextStore();
16
+ if (!ctx)
17
+ throw new dbos_sdk_1.Error.DBOSInvalidWorkflowTransitionError('Invalid use of TypeOrmDs outside of a `transaction`');
18
+ return ctx;
19
+ }
20
+ class TypeOrmDSTH {
21
+ name;
22
+ config;
23
+ entities;
24
+ dsType = 'TypeOrm';
25
+ dataSource;
26
+ constructor(name, config,
27
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
28
+ entities) {
29
+ this.name = name;
30
+ this.config = config;
31
+ this.entities = entities;
32
+ }
33
+ async createInstance() {
34
+ const ds = new typeorm_1.DataSource({
35
+ type: 'postgres',
36
+ url: this.config.connectionString,
37
+ connectTimeoutMS: this.config.connectionTimeoutMillis,
38
+ entities: this.entities,
39
+ poolSize: this.config.max,
40
+ });
41
+ await ds.initialize();
42
+ return ds;
43
+ }
44
+ async initialize() {
45
+ this.dataSource = await this.createInstance();
46
+ return Promise.resolve();
47
+ }
48
+ async destroy() {
49
+ await this.dataSource?.destroy();
50
+ }
51
+ async #checkExecution(client, workflowID, funcNum) {
52
+ const { rows } = await client.query(`SELECT output
53
+ FROM dbos.transaction_completion
54
+ WHERE workflow_id=$1 AND function_num=$2;`, [workflowID, funcNum]);
55
+ if (rows.length !== 1) {
56
+ return undefined;
57
+ }
58
+ if (rows[0].output === null) {
59
+ return undefined;
60
+ }
61
+ return { res: superjson_1.SuperJSON.parse(rows[0].output) };
62
+ }
63
+ async #recordOutput(client, workflowID, funcNum, output) {
64
+ const serialOutput = superjson_1.SuperJSON.stringify(output);
65
+ await client.query(`INSERT INTO dbos.transaction_completion (
66
+ workflow_id,
67
+ function_num,
68
+ output,
69
+ created_at
70
+ ) VALUES ($1, $2, $3, $4)`, [workflowID, funcNum, serialOutput, Date.now()]);
71
+ }
72
+ async #recordError(client, workflowID, funcNum, error) {
73
+ const serialError = superjson_1.SuperJSON.stringify(error);
74
+ await client.query(`INSERT INTO dbos.transaction_completion (
75
+ workflow_id,
76
+ function_num,
77
+ error,
78
+ created_at
79
+ ) VALUES ($1, $2, $3, $4)`, [workflowID, funcNum, serialError, Date.now()]);
80
+ }
81
+ /* Required by base class */
82
+ async invokeTransactionFunction(config, target, func, ...args) {
83
+ const isolationLevel = config?.isolationLevel ?? 'SERIALIZABLE';
84
+ const readOnly = config?.readOnly ? true : false;
85
+ const wfid = dbos_sdk_1.DBOS.workflowID;
86
+ const funcnum = dbos_sdk_1.DBOS.stepID;
87
+ const funcname = func.name;
88
+ // Retry loop if appropriate
89
+ let retryWaitMillis = 1;
90
+ const backoffFactor = 1.5;
91
+ const maxRetryWaitMs = 2000; // Maximum wait 2 seconds.
92
+ const shouldCheckOutput = false;
93
+ if (this.dataSource === undefined) {
94
+ throw new dbos_sdk_1.Error.DBOSInvalidWorkflowTransitionError('Invalid use of Datasource');
95
+ }
96
+ while (true) {
97
+ let failedForRetriableReasons = false;
98
+ try {
99
+ const result = this.dataSource.transaction(isolationLevel, async (transactionEntityManager) => {
100
+ if (this.dataSource === undefined) {
101
+ throw new dbos_sdk_1.Error.DBOSInvalidWorkflowTransitionError('Invalid use of Datasource');
102
+ }
103
+ if (shouldCheckOutput && !readOnly && wfid) {
104
+ const executionResult = await this.#checkExecution(this.dataSource, wfid, funcnum);
105
+ if (executionResult) {
106
+ dbos_sdk_1.DBOS.span?.setAttribute('cached', true);
107
+ return executionResult.res;
108
+ }
109
+ }
110
+ const result = await asyncLocalCtx.run({ typeOrmEntityManager: transactionEntityManager }, async () => {
111
+ return await func.call(target, ...args);
112
+ });
113
+ // Save result
114
+ try {
115
+ if (!readOnly && wfid) {
116
+ await this.#recordOutput(this.dataSource, wfid, funcnum, result);
117
+ }
118
+ }
119
+ catch (e) {
120
+ const error = e;
121
+ await this.#recordError(this.dataSource, wfid, funcnum, error);
122
+ // Aside from a connectivity error, two kinds of error are anticipated here:
123
+ // 1. The transaction is marked failed, but the user code did not throw.
124
+ // Bad on them. We will throw an error (this will get recorded) and not retry.
125
+ // 2. There was a key conflict in the statement, and we need to use the fetched output
126
+ if ((0, datasource_1.isPGFailedSqlTransactionError)(error)) {
127
+ dbos_sdk_1.DBOS.logger.error(`In workflow ${wfid}, Postgres aborted a transaction but the function '${funcname}' did not raise an exception. Please ensure that the transaction method raises an exception if the database transaction is aborted.`);
128
+ failedForRetriableReasons = false;
129
+ throw new dbos_sdk_1.Error.DBOSFailedSqlTransactionError(wfid, funcname);
130
+ }
131
+ else if ((0, datasource_1.isPGKeyConflictError)(error)) {
132
+ throw new dbos_sdk_1.Error.DBOSWorkflowConflictError(`In workflow ${wfid}, Postgres raised a key conflict error in transaction '${funcname}'. This is not retriable, but the output will be fetched from the database.`);
133
+ }
134
+ else {
135
+ dbos_sdk_1.DBOS.logger.error(`Unexpected error raised in transaction '${funcname}: ${error}`);
136
+ failedForRetriableReasons = false;
137
+ throw error;
138
+ }
139
+ }
140
+ return result;
141
+ });
142
+ return result;
143
+ }
144
+ catch (e) {
145
+ const err = e;
146
+ if (failedForRetriableReasons || (0, datasource_1.isPGRetriableTransactionError)(err)) {
147
+ dbos_sdk_1.DBOS.span?.addEvent('TXN SERIALIZATION FAILURE', { retryWaitMillis: retryWaitMillis }, performance.now());
148
+ // Retry serialization failures.
149
+ await dbos_sdk_1.DBOS.sleepms(retryWaitMillis);
150
+ retryWaitMillis *= backoffFactor;
151
+ retryWaitMillis = retryWaitMillis < maxRetryWaitMs ? retryWaitMillis : maxRetryWaitMs;
152
+ continue;
153
+ }
154
+ else {
155
+ throw err;
156
+ }
157
+ }
158
+ }
159
+ }
160
+ }
161
+ class TypeOrmDataSource {
162
+ name;
163
+ config;
164
+ entities;
165
+ #provider;
166
+ constructor(name, config,
167
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
168
+ entities) {
169
+ this.name = name;
170
+ this.config = config;
171
+ this.entities = entities;
172
+ this.#provider = new TypeOrmDSTH(name, config, entities);
173
+ (0, datasource_1.registerDataSource)(this.#provider);
174
+ }
175
+ // User calls this... DBOS not directly involved...
176
+ static get entityManager() {
177
+ const ctx = assertCurrentDSContextStore();
178
+ if (!dbos_sdk_1.DBOS.isInTransaction())
179
+ throw new dbos_sdk_1.Error.DBOSInvalidWorkflowTransitionError('Invalid use of `TypeOrmDataSource.entityManager` outside of a `transaction`');
180
+ return ctx.typeOrmEntityManager;
181
+ }
182
+ async initializeInternalSchema() {
183
+ const ds = await this.#provider.createInstance();
184
+ try {
185
+ await ds.query(datasource_1.createTransactionCompletionSchemaPG);
186
+ await ds.query(datasource_1.createTransactionCompletionTablePG);
187
+ }
188
+ catch (e) {
189
+ const error = e;
190
+ throw new dbos_sdk_1.Error.DBOSError(`Unexpected error initializing schema: ${error.message}`);
191
+ }
192
+ finally {
193
+ try {
194
+ await ds.destroy();
195
+ }
196
+ catch (e) { }
197
+ }
198
+ }
199
+ /**
200
+ * Run `callback` as a transaction against this DataSource
201
+ * @param callback Function to run within a transactional context
202
+ * @param funcName Name to record for the transaction
203
+ * @param config Transaction configuration (isolation, etc)
204
+ * @returns Return value from `callback`
205
+ */
206
+ async runTransaction(callback, funcName, config) {
207
+ return await (0, datasource_1.runTransaction)(callback, funcName, { dsName: this.name, config });
208
+ }
209
+ /**
210
+ * Register function as DBOS transaction, to be called within the context
211
+ * of a transaction on this data source.
212
+ *
213
+ * @param func Function to wrap
214
+ * @param target Name of function
215
+ * @param config Transaction settings
216
+ * @returns Wrapped function, to be called instead of `func`
217
+ */
218
+ registerTransaction(func, name, config) {
219
+ return (0, datasource_1.registerTransaction)(this.name, func, { name }, config);
220
+ }
221
+ /**
222
+ * Decorator establishing function as a transaction
223
+ */
224
+ transaction(config) {
225
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
226
+ const ds = this;
227
+ return function decorator(_target, propertyKey, descriptor) {
228
+ if (!descriptor.value) {
229
+ throw new dbos_sdk_1.Error.DBOSError('Use of decorator when original method is undefined');
230
+ }
231
+ descriptor.value = ds.registerTransaction(descriptor.value, propertyKey.toString(), config);
232
+ return descriptor;
233
+ };
234
+ }
235
+ /**
236
+ * For testing: Use DataSource.syncronize to install the user schema
237
+ */
238
+ async createSchema() {
239
+ const ds = await this.#provider.createInstance();
240
+ try {
241
+ await ds.synchronize();
242
+ }
243
+ finally {
244
+ await ds.destroy();
245
+ }
246
+ }
247
+ }
248
+ exports.TypeOrmDataSource = TypeOrmDataSource;
249
+ //# sourceMappingURL=typeorm_datasource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeorm_datasource.js","sourceRoot":"","sources":["../../src/typeorm_datasource.ts"],"names":[],"mappings":";;;AACA,iDAAiD;AACjD,8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