@dbos-inc/typeorm-datasource 3.0.7-preview.gfe77addda7 → 3.0.8-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.
@@ -1,15 +1,12 @@
1
1
  import { PoolConfig } from 'pg';
2
- import { PGIsolationLevel as IsolationLevel, PGTransactionConfig as TypeOrmTransactionConfig, DBOSDataSource } from '@dbos-inc/dbos-sdk/datasource';
2
+ import { DBOSDataSource, PGTransactionConfig } from '@dbos-inc/dbos-sdk/datasource';
3
3
  import { EntityManager } from 'typeorm';
4
- export { IsolationLevel, TypeOrmTransactionConfig };
5
- export declare class TypeOrmDataSource implements DBOSDataSource<TypeOrmTransactionConfig> {
4
+ export declare class TypeOrmDataSource implements DBOSDataSource<PGTransactionConfig> {
6
5
  #private;
7
6
  readonly name: string;
8
- readonly config: PoolConfig;
9
- readonly entities: Function[];
10
- constructor(name: string, config: PoolConfig, entities: Function[]);
11
7
  static get entityManager(): EntityManager;
12
- initializeInternalSchema(): Promise<void>;
8
+ static initializeInternalSchema(config: PoolConfig): Promise<void>;
9
+ constructor(name: string, config: PoolConfig, entities: Function[]);
13
10
  /**
14
11
  * Run `callback` as a transaction against this DataSource
15
12
  * @param callback Function to run within a transactional context
@@ -17,7 +14,7 @@ export declare class TypeOrmDataSource implements DBOSDataSource<TypeOrmTransact
17
14
  * @param config Transaction configuration (isolation, etc)
18
15
  * @returns Return value from `callback`
19
16
  */
20
- runTransaction<T>(callback: () => Promise<T>, funcName: string, config?: TypeOrmTransactionConfig): Promise<T>;
17
+ runTransaction<T>(callback: () => Promise<T>, funcName: string, config?: PGTransactionConfig): Promise<T>;
21
18
  /**
22
19
  * Register function as DBOS transaction, to be called within the context
23
20
  * of a transaction on this data source.
@@ -27,14 +24,10 @@ export declare class TypeOrmDataSource implements DBOSDataSource<TypeOrmTransact
27
24
  * @param config Transaction settings
28
25
  * @returns Wrapped function, to be called instead of `func`
29
26
  */
30
- registerTransaction<This, Args extends unknown[], Return>(func: (this: This, ...args: Args) => Promise<Return>, name: string, config?: TypeOrmTransactionConfig): (this: This, ...args: Args) => Promise<Return>;
27
+ registerTransaction<This, Args extends unknown[], Return>(func: (this: This, ...args: Args) => Promise<Return>, config?: PGTransactionConfig, name?: string): (this: This, ...args: Args) => Promise<Return>;
31
28
  /**
32
29
  * Decorator establishing function as a transaction
33
30
  */
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>;
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>>;
39
32
  }
40
- //# sourceMappingURL=typeorm_datasource.d.ts.map
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,OAAO,EAQL,cAAc,EAEd,mBAAmB,EACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAc,aAAa,EAAE,MAAM,SAAS,CAAC;AA+MpD,qBAAa,iBAAkB,YAAW,cAAc,CAAC,mBAAmB,CAAC;;IA2BzE,QAAQ,CAAC,IAAI,EAAE,MAAM;IAzBvB,MAAM,KAAK,aAAa,IAAI,aAAa,CAUxC;WAEY,wBAAwB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;gBAa7D,IAAI,EAAE,MAAM,EACrB,MAAM,EAAE,UAAU,EAElB,QAAQ,EAAE,QAAQ,EAAE;IAMtB;;;;;;OAMG;IACG,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB;IAIlG;;;;;;;;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,MAAM,CAAC,EAAE,mBAAmB,EAC5B,IAAI,CAAC,EAAE,MAAM,GACZ,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC;IAIjD;;OAEG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,mBAAmB,mDAI3B,MAAM,eACF,WAAW,cACZ,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,QAAQ,MAAM,CAAC,CAAC,oCAAxC,IAAI,WAAW,IAAI,KAAK,QAAQ,MAAM,CAAC;CAWvF"}
package/dist/index.js ADDED
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeOrmDataSource = void 0;
4
+ const dbos_sdk_1 = require("@dbos-inc/dbos-sdk");
5
+ const datasource_1 = require("@dbos-inc/dbos-sdk/datasource");
6
+ const typeorm_1 = require("typeorm");
7
+ const async_hooks_1 = require("async_hooks");
8
+ const superjson_1 = require("superjson");
9
+ const asyncLocalCtx = new async_hooks_1.AsyncLocalStorage();
10
+ class TypeOrmTransactionHandler {
11
+ name;
12
+ config;
13
+ entities;
14
+ dsType = 'TypeOrm';
15
+ #dataSourceField;
16
+ constructor(name, config,
17
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
18
+ entities) {
19
+ this.name = name;
20
+ this.config = config;
21
+ this.entities = entities;
22
+ }
23
+ static async createInstance(config,
24
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
25
+ entities) {
26
+ const ds = new typeorm_1.DataSource({
27
+ type: 'postgres',
28
+ entities: entities,
29
+ url: config.connectionString,
30
+ host: config.host,
31
+ port: config.port,
32
+ username: config.user,
33
+ // password: config.password,
34
+ database: config.database,
35
+ // ssl: config.ssl,
36
+ connectTimeoutMS: config.connectionTimeoutMillis,
37
+ poolSize: config.max,
38
+ });
39
+ await ds.initialize();
40
+ return ds;
41
+ }
42
+ async initialize() {
43
+ const ds = this.#dataSourceField;
44
+ this.#dataSourceField = await TypeOrmTransactionHandler.createInstance(this.config, this.entities);
45
+ await ds?.destroy();
46
+ }
47
+ async destroy() {
48
+ const ds = this.#dataSourceField;
49
+ this.#dataSourceField = undefined;
50
+ await ds?.destroy();
51
+ }
52
+ get #dataSource() {
53
+ if (!this.#dataSourceField) {
54
+ throw new Error(`DataSource ${this.name} is not initialized.`);
55
+ }
56
+ return this.#dataSourceField;
57
+ }
58
+ async #checkExecution(workflowID, stepID) {
59
+ const rows = await this.#dataSource.query(`SELECT output, error FROM dbos.transaction_completion
60
+ WHERE workflow_id=$1 AND function_num=$2;`, [workflowID, stepID]);
61
+ if (rows.length !== 1) {
62
+ return undefined;
63
+ }
64
+ if (rows[0].output === null) {
65
+ return undefined;
66
+ }
67
+ const { output, error } = rows[0];
68
+ return error !== null ? { error } : { output };
69
+ }
70
+ static async #recordOutput(entityManager, workflowID, stepID, output) {
71
+ try {
72
+ await entityManager.query(`INSERT INTO dbos.transaction_completion (workflow_id, function_num, output)
73
+ VALUES ($1, $2, $3)`, [workflowID, stepID, output]);
74
+ }
75
+ catch (error) {
76
+ if ((0, datasource_1.isPGKeyConflictError)(error)) {
77
+ throw new dbos_sdk_1.DBOSWorkflowConflictError(workflowID);
78
+ }
79
+ else {
80
+ throw error;
81
+ }
82
+ }
83
+ }
84
+ async #recordError(workflowID, stepID, error) {
85
+ try {
86
+ await this.#dataSource.query(`INSERT INTO dbos.transaction_completion (workflow_id, function_num, error)
87
+ VALUES ($1, $2, $3)`, [workflowID, stepID, error]);
88
+ }
89
+ catch (error) {
90
+ if ((0, datasource_1.isPGKeyConflictError)(error)) {
91
+ throw new dbos_sdk_1.DBOSWorkflowConflictError(workflowID);
92
+ }
93
+ else {
94
+ throw error;
95
+ }
96
+ }
97
+ }
98
+ /* Required by base class */
99
+ async invokeTransactionFunction(config, target, func, ...args) {
100
+ const workflowID = dbos_sdk_1.DBOS.workflowID;
101
+ const stepID = dbos_sdk_1.DBOS.stepID;
102
+ if (workflowID !== undefined && stepID === undefined) {
103
+ throw new Error('DBOS.stepID is undefined inside a workflow.');
104
+ }
105
+ const isolationLevel = config?.isolationLevel ?? 'READ COMMITTED';
106
+ const readOnly = config?.readOnly ? true : false;
107
+ const saveResults = !readOnly && workflowID !== undefined;
108
+ // Retry loop if appropriate
109
+ let retryWaitMS = 1;
110
+ const backoffFactor = 1.5;
111
+ const maxRetryWaitMS = 2000; // Maximum wait 2 seconds.
112
+ while (true) {
113
+ // Check to see if this tx has already been executed
114
+ const previousResult = saveResults ? await this.#checkExecution(workflowID, stepID) : undefined;
115
+ if (previousResult) {
116
+ dbos_sdk_1.DBOS.span?.setAttribute('cached', true);
117
+ if ('error' in previousResult) {
118
+ throw superjson_1.SuperJSON.parse(previousResult.error);
119
+ }
120
+ return (previousResult.output ? superjson_1.SuperJSON.parse(previousResult.output) : null);
121
+ }
122
+ try {
123
+ const result = await this.#dataSource.transaction(isolationLevel, async (entityManager) => {
124
+ if (readOnly) {
125
+ await entityManager.query('SET TRANSACTION READ ONLY');
126
+ }
127
+ const result = await asyncLocalCtx.run({ entityManager: entityManager }, async () => {
128
+ return await func.call(target, ...args);
129
+ });
130
+ // save the output of read/write transactions
131
+ if (saveResults) {
132
+ await TypeOrmTransactionHandler.#recordOutput(entityManager, workflowID, stepID, superjson_1.SuperJSON.stringify(result));
133
+ }
134
+ return result;
135
+ });
136
+ return result;
137
+ }
138
+ catch (error) {
139
+ if ((0, datasource_1.isPGRetriableTransactionError)(error)) {
140
+ dbos_sdk_1.DBOS.span?.addEvent('TXN SERIALIZATION FAILURE', { retryWaitMillis: retryWaitMS }, performance.now());
141
+ // Retry serialization failures.
142
+ await new Promise((resolve) => setTimeout(resolve, retryWaitMS));
143
+ retryWaitMS = Math.min(retryWaitMS * backoffFactor, maxRetryWaitMS);
144
+ continue;
145
+ }
146
+ else {
147
+ if (saveResults) {
148
+ const message = superjson_1.SuperJSON.stringify(error);
149
+ await this.#recordError(workflowID, stepID, message);
150
+ }
151
+ throw error;
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ class TypeOrmDataSource {
158
+ name;
159
+ // User calls this... DBOS not directly involved...
160
+ static get entityManager() {
161
+ if (!dbos_sdk_1.DBOS.isInTransaction()) {
162
+ throw new Error('Invalid use of TypeOrmDataSource.entityManager outside of a DBOS transaction');
163
+ }
164
+ const ctx = asyncLocalCtx.getStore();
165
+ if (!ctx) {
166
+ throw new Error('Invalid use of TypeOrmDataSource.entityManager outside of a DBOS transaction');
167
+ }
168
+ return ctx.entityManager;
169
+ }
170
+ static async initializeInternalSchema(config) {
171
+ const ds = await TypeOrmTransactionHandler.createInstance(config, []);
172
+ try {
173
+ await ds.query(datasource_1.createTransactionCompletionSchemaPG);
174
+ await ds.query(datasource_1.createTransactionCompletionTablePG);
175
+ }
176
+ finally {
177
+ await ds.destroy();
178
+ }
179
+ }
180
+ #provider;
181
+ constructor(name, config,
182
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
183
+ entities) {
184
+ this.name = name;
185
+ this.#provider = new TypeOrmTransactionHandler(name, config, entities);
186
+ (0, datasource_1.registerDataSource)(this.#provider);
187
+ }
188
+ /**
189
+ * Run `callback` as a transaction against this DataSource
190
+ * @param callback Function to run within a transactional context
191
+ * @param funcName Name to record for the transaction
192
+ * @param config Transaction configuration (isolation, etc)
193
+ * @returns Return value from `callback`
194
+ */
195
+ async runTransaction(callback, funcName, config) {
196
+ return await (0, datasource_1.runTransaction)(callback, funcName, { dsName: this.name, config });
197
+ }
198
+ /**
199
+ * Register function as DBOS transaction, to be called within the context
200
+ * of a transaction on this data source.
201
+ *
202
+ * @param func Function to wrap
203
+ * @param target Name of function
204
+ * @param config Transaction settings
205
+ * @returns Wrapped function, to be called instead of `func`
206
+ */
207
+ registerTransaction(func, config, name) {
208
+ return (0, datasource_1.registerTransaction)(this.name, func, { name: name ?? func.name }, config);
209
+ }
210
+ /**
211
+ * Decorator establishing function as a transaction
212
+ */
213
+ transaction(config) {
214
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
215
+ const ds = this;
216
+ return function decorator(_target, propertyKey, descriptor) {
217
+ if (!descriptor.value) {
218
+ throw new Error('Use of decorator when original method is undefined');
219
+ }
220
+ descriptor.value = ds.registerTransaction(descriptor.value, config, String(propertyKey));
221
+ return descriptor;
222
+ };
223
+ }
224
+ }
225
+ exports.TypeOrmDataSource = TypeOrmDataSource;
226
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AACA,iDAAqE;AACrE,8DAWuC;AACvC,qCAAoD;AACpD,6CAAgD;AAChD,yCAAsC;AAMtC,MAAM,aAAa,GAAG,IAAI,+BAAiB,EAAuB,CAAC;AASnE,MAAM,yBAAyB;IAKlB;IACQ;IAEA;IAPV,MAAM,GAAG,SAAS,CAAC;IAC5B,gBAAgB,CAAyB;IAEzC,YACW,IAAY,EACJ,MAAkB;IACnC,sEAAsE;IACrD,QAAoB;QAH5B,SAAI,GAAJ,IAAI,CAAQ;QACJ,WAAM,GAAN,MAAM,CAAY;QAElB,aAAQ,GAAR,QAAQ,CAAY;IACpC,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,cAAc,CACzB,MAAkB;IAClB,sEAAsE;IACtE,QAAoB;QAEpB,MAAM,EAAE,GAAG,IAAI,oBAAU,CAAC;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