@fluojs/drizzle 1.0.0 → 1.0.2
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/README.ko.md +7 -3
- package/README.md +7 -3
- package/dist/database.d.ts +3 -0
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +28 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +10 -14
- package/package.json +5 -5
package/README.ko.md
CHANGED
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
## 설치
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
npm install @fluojs/drizzle
|
|
25
|
+
npm install @fluojs/drizzle drizzle-orm
|
|
26
|
+
# 사용하는 Drizzle adapter에 맞는 driver도 함께 설치하세요. 예:
|
|
27
|
+
npm install pg
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
## 사용 시점
|
|
@@ -106,9 +108,9 @@ class UsersController {}
|
|
|
106
108
|
|
|
107
109
|
### 종료와 상태 계약
|
|
108
110
|
|
|
109
|
-
`DrizzleTransactionInterceptor`는 각 HTTP 요청을 `DrizzleDatabase.requestTransaction(...)`으로 실행합니다. 애플리케이션 종료 중에는 `DrizzleDatabase`가 아직 활성 상태인 요청 트랜잭션을 abort하고,
|
|
111
|
+
`DrizzleTransactionInterceptor`는 각 HTTP 요청을 `DrizzleDatabase.requestTransaction(...)`으로 실행합니다. 애플리케이션 종료 중에는 `DrizzleDatabase`가 아직 활성 상태인 요청 트랜잭션을 abort하고, 열린 요청 및 수동 transaction callback이 settle되거나 rollback될 때까지 기다린 뒤 선택적 `dispose(database)` hook을 실행합니다. 이 순서는 pool이나 외부 관리 리소스를 닫기 전에 driver가 commit/rollback/cleanup 작업을 끝낼 수 있게 보장합니다.
|
|
110
112
|
기존 요청 boundary 안에서 열린 중첩 `requestTransaction(...)` 호출은 활성 Drizzle transaction을 재사용하면서도 ambient request abort signal을 관찰합니다. 기존 수동 transaction boundary 안에서 열린 중첩 `requestTransaction(...)` 호출도 두 번째 Drizzle transaction을 열지 않고 shutdown settlement tracking에 참여하며, 해당 settlement handle은 바깥 수동 transaction이 settle될 때까지 tracking에 남아 shutdown이 `dispose(database)`를 실행하기 전에 그 바깥 경계까지 drain하게 합니다. 단, platform status activity count는 더 짧게 유지됩니다. 중첩 request callback이 settle되는 즉시, 바깥 수동 transaction이 계속 실행 중이어도 `details.activeRequestTransactions`는 감소합니다.
|
|
111
|
-
종료가 시작된 뒤 새 `requestTransaction(...)` 호출은 거부되므로, 종료 boundary를 지난 뒤 시작되는 늦은
|
|
113
|
+
종료가 시작된 뒤 새 `transaction(...)` 및 `requestTransaction(...)` 호출은 거부되므로, 종료 boundary를 지난 뒤 시작되는 늦은 트랜잭션보다 dispose가 먼저 실행되는 상황을 방지합니다.
|
|
112
114
|
요청 callback이 완료된 뒤 underlying Drizzle transaction runner가 commit 또는 rollback을 끝내기 전에 request signal이 abort되면, `requestTransaction(...)`은 먼저 해당 runner가 settle될 때까지 기다린 다음 abort reason으로 reject합니다. 이 동작은 Drizzle cleanup을 request cancellation과 직렬화하면서, 완료된 callback 결과를 반환하는 대신 늦은 request abort를 caller에게 드러냅니다.
|
|
113
115
|
|
|
114
116
|
`createDrizzlePlatformStatusSnapshot(...)`과 `DrizzleDatabase.createPlatformStatusSnapshot()`은 같은 계약을 진단 surface에 노출합니다.
|
|
@@ -156,7 +158,9 @@ defineModule(ManualDrizzleModule, {
|
|
|
156
158
|
|
|
157
159
|
- `DrizzleModule.forRoot(options)` / `DrizzleModule.forRootAsync(options)`
|
|
158
160
|
- `forRootAsync(...)`는 database/dispose/transaction 설정을 factory에서 반환하는 DI-aware Drizzle 옵션을 받습니다. provider를 전역으로 노출해야 할 때는 최상위 async 등록 옵션에 `global`을 전달하세요.
|
|
161
|
+
- `forRootAsync(...)`는 애플리케이션 container마다 옵션을 한 번 resolve합니다. 테스트나 multi-app process에서 같은 module definition을 재사용해도 memoized factory result를 공유하지 않고 각 container가 독립적인 database/dispose 결과를 받습니다.
|
|
159
162
|
- `strictTransactions: true`를 설정하면 transaction 지원이 없는 database handle에서 예외를 던집니다.
|
|
163
|
+
- sync 및 async 등록 모두에서 `database`는 실제 object/function handle이어야 하며, 누락된 handle은 모듈 등록 또는 async bootstrap 중 거부됩니다.
|
|
160
164
|
|
|
161
165
|
## 관련 패키지
|
|
162
166
|
|
package/README.md
CHANGED
|
@@ -22,7 +22,9 @@ Drizzle ORM integration for fluo with a transaction-aware database wrapper and a
|
|
|
22
22
|
## Installation
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
npm install @fluojs/drizzle
|
|
25
|
+
npm install @fluojs/drizzle drizzle-orm
|
|
26
|
+
# Install the driver for your Drizzle adapter as well, for example:
|
|
27
|
+
npm install pg
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
## When to Use
|
|
@@ -106,9 +108,9 @@ class UsersController {}
|
|
|
106
108
|
|
|
107
109
|
### Shutdown and status contracts
|
|
108
110
|
|
|
109
|
-
`DrizzleTransactionInterceptor` runs each HTTP request through `DrizzleDatabase.requestTransaction(...)`. During application shutdown, `DrizzleDatabase` aborts any still-active request transaction, waits for
|
|
111
|
+
`DrizzleTransactionInterceptor` runs each HTTP request through `DrizzleDatabase.requestTransaction(...)`. During application shutdown, `DrizzleDatabase` aborts any still-active request transaction, waits for open request and manual transaction callbacks to settle or roll back, and only then runs the optional `dispose(database)` hook. This ordering lets drivers finish commit/rollback/cleanup work before pools or externally managed resources are closed.
|
|
110
112
|
Nested `requestTransaction(...)` calls opened inside an existing request boundary observe the ambient request abort signal while still reusing the active Drizzle transaction. Nested `requestTransaction(...)` calls opened inside an existing manual transaction boundary also join shutdown settlement tracking without opening a second Drizzle transaction, and their settlement handle remains tracked until the outer manual transaction settles so shutdown drains that outer boundary before `dispose(database)` runs. The platform status activity count is intentionally shorter lived: once the nested request callback settles, `details.activeRequestTransactions` is decremented even if the outer manual transaction continues running.
|
|
111
|
-
New `requestTransaction(...)` calls are rejected once shutdown begins, so disposal cannot overtake a late
|
|
113
|
+
New `transaction(...)` and `requestTransaction(...)` calls are rejected once shutdown begins, so disposal cannot overtake a late transaction that starts after the shutdown boundary is crossed.
|
|
112
114
|
If the request signal aborts after the request callback has completed but before the underlying Drizzle transaction runner finishes committing or rolling back, `requestTransaction(...)` waits for that runner to settle first and then rejects with the abort reason. This keeps Drizzle cleanup serialized with request cancellation while making the late request abort visible to the caller instead of returning the completed callback result.
|
|
113
115
|
|
|
114
116
|
`createDrizzlePlatformStatusSnapshot(...)` and `DrizzleDatabase.createPlatformStatusSnapshot()` expose the same contract to diagnostics surfaces:
|
|
@@ -156,7 +158,9 @@ defineModule(ManualDrizzleModule, {
|
|
|
156
158
|
|
|
157
159
|
- `DrizzleModule.forRoot(options)` / `DrizzleModule.forRootAsync(options)`
|
|
158
160
|
- `forRootAsync(...)` accepts DI-aware Drizzle options whose factory returns the database/dispose/transaction settings; pass `global` on the top-level async registration when the providers should be visible globally.
|
|
161
|
+
- `forRootAsync(...)` resolves options once per application container. Reusing the same module definition across tests or multi-app processes creates isolated database/dispose results for each container instead of sharing a memoized factory result.
|
|
159
162
|
- Supports `strictTransactions: true` to throw if transaction support is missing.
|
|
163
|
+
- `database` must be a concrete object/function handle for both sync and async registration; missing handles are rejected during module registration or async bootstrap.
|
|
160
164
|
|
|
161
165
|
## Related Packages
|
|
162
166
|
|
package/dist/database.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare class DrizzleDatabase<TDatabase extends DrizzleDatabaseLike<TTran
|
|
|
16
16
|
private readonly databaseOptions;
|
|
17
17
|
private readonly transactions;
|
|
18
18
|
private readonly activeRequestTransactions;
|
|
19
|
+
private readonly activeTransactionScopes;
|
|
19
20
|
private activeRequestTransactionStatusCount;
|
|
20
21
|
private lifecycleState;
|
|
21
22
|
constructor(database: TDatabase, dispose?: ((database: TDatabase) => Promise<void> | void) | undefined, databaseOptions?: DrizzleRuntimeOptions);
|
|
@@ -68,10 +69,12 @@ export declare class DrizzleDatabase<TDatabase extends DrizzleDatabaseLike<TTran
|
|
|
68
69
|
private executeNestedRequestTransaction;
|
|
69
70
|
private executeRequestFallback;
|
|
70
71
|
private assertRequestTransactionsAvailable;
|
|
72
|
+
private assertTransactionsAvailable;
|
|
71
73
|
private throwIfRequestAborted;
|
|
72
74
|
private trackActiveRequestTransaction;
|
|
73
75
|
private untrackActiveRequestTransaction;
|
|
74
76
|
private markRequestTransactionInactiveForStatus;
|
|
77
|
+
private trackActiveTransactionScope;
|
|
75
78
|
private resolveTransactionRunner;
|
|
76
79
|
}
|
|
77
80
|
export {};
|
package/dist/database.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAK7D,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAK7D,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAgCpB,KAAK,qBAAqB,GAAG;IAC3B,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AA8CF;;;;;;GAMG;AACH,qBACa,eAAe,CAC1B,SAAS,SAAS,mBAAmB,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,EAChF,oBAAoB,GAAG,SAAS,EAChC,mBAAmB,GAAG,OAAO,CAC7B,YAAW,qBAAqB,CAAC,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,CAAC,EAAE,qBAAqB;IAS3G,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe;IATlC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqE;IAClG,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAuC;IACjF,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAqC;IAC7E,OAAO,CAAC,mCAAmC,CAAK;IAChD,OAAO,CAAC,cAAc,CAAkD;gBAGrD,QAAQ,EAAE,SAAS,EACnB,OAAO,CAAC,GAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,aAAA,EACvD,eAAe,GAAE,qBAAqD;IAGzF;;;;;;;;;OASG;IACH,OAAO,IAAI,SAAS,GAAG,oBAAoB;IAI3C,qGAAqG;IAC/F,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5C,yFAAyF;IACzF,4BAA4B;IAS5B;;;;;;;;;;;;;OAaG;IACG,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,CAAC,CAAC;IAIrF;;;;;;;;;;;;OAYG;IACG,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,CAAC,CAAC;YAIpG,kBAAkB;YA0DlB,yBAAyB;YA8BzB,+BAA+B;YA6C/B,sBAAsB;IAkBpC,OAAO,CAAC,kCAAkC;IAM1C,OAAO,CAAC,2BAA2B;IAMnC,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,6BAA6B;IAOrC,OAAO,CAAC,+BAA+B;IAKvC,OAAO,CAAC,uCAAuC;IAO/C,OAAO,CAAC,2BAA2B;IAkBnC,OAAO,CAAC,wBAAwB;CAWjC"}
|
package/dist/database.js
CHANGED
|
@@ -11,6 +11,7 @@ import { DRIZZLE_DATABASE, DRIZZLE_DISPOSE, DRIZZLE_OPTIONS } from './tokens.js'
|
|
|
11
11
|
import { createDrizzlePlatformStatusSnapshot } from './status.js';
|
|
12
12
|
const TRANSACTION_NOT_SUPPORTED_ERROR = 'Transaction not supported: Drizzle database does not implement transaction.';
|
|
13
13
|
const NESTED_TRANSACTION_OPTIONS_NOT_SUPPORTED_ERROR = 'Nested Drizzle transaction options are not supported because the active transaction context is reused.';
|
|
14
|
+
const TRANSACTION_UNAVAILABLE_ERROR = 'Drizzle transactions are not available during application shutdown.';
|
|
14
15
|
const REQUEST_TRANSACTION_UNAVAILABLE_ERROR = 'Drizzle request transactions are not available during shutdown.';
|
|
15
16
|
function createRequestAbortSignalView(parentSignal, signal) {
|
|
16
17
|
if (!signal) {
|
|
@@ -59,6 +60,7 @@ class DrizzleDatabase {
|
|
|
59
60
|
}
|
|
60
61
|
transactions = new AsyncLocalStorage();
|
|
61
62
|
activeRequestTransactions = new Set();
|
|
63
|
+
activeTransactionScopes = new Set();
|
|
62
64
|
activeRequestTransactionStatusCount = 0;
|
|
63
65
|
lifecycleState = 'ready';
|
|
64
66
|
constructor(database, dispose, databaseOptions = {
|
|
@@ -90,7 +92,7 @@ class DrizzleDatabase {
|
|
|
90
92
|
for (const transaction of activeRequestTransactions) {
|
|
91
93
|
transaction.abort(new Error('Application shutdown interrupted an open request transaction.'));
|
|
92
94
|
}
|
|
93
|
-
await Promise.allSettled(activeRequestTransactions.map(transaction => transaction.settled));
|
|
95
|
+
await Promise.allSettled([...activeRequestTransactions.map(transaction => transaction.settled), ...Array.from(this.activeTransactionScopes, transaction => transaction.settled)]);
|
|
94
96
|
if (this.dispose) {
|
|
95
97
|
await this.dispose(this.database);
|
|
96
98
|
}
|
|
@@ -152,6 +154,9 @@ class DrizzleDatabase {
|
|
|
152
154
|
}
|
|
153
155
|
return fn();
|
|
154
156
|
}
|
|
157
|
+
if (!requestScoped) {
|
|
158
|
+
this.assertTransactionsAvailable();
|
|
159
|
+
}
|
|
155
160
|
const transactionRunner = this.resolveTransactionRunner();
|
|
156
161
|
if (!transactionRunner) {
|
|
157
162
|
if (requestScoped) {
|
|
@@ -161,6 +166,7 @@ class DrizzleDatabase {
|
|
|
161
166
|
}
|
|
162
167
|
if (!requestScoped) {
|
|
163
168
|
const deferredRequestTransactionSettlements = new Set();
|
|
169
|
+
const activeTransactionScope = this.trackActiveTransactionScope();
|
|
164
170
|
try {
|
|
165
171
|
return await transactionRunner(transactionDatabase => this.transactions.run({
|
|
166
172
|
database: transactionDatabase,
|
|
@@ -170,6 +176,7 @@ class DrizzleDatabase {
|
|
|
170
176
|
for (const handle of deferredRequestTransactionSettlements) {
|
|
171
177
|
this.untrackActiveRequestTransaction(handle);
|
|
172
178
|
}
|
|
179
|
+
activeTransactionScope.settle();
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
182
|
return this.executeRequestTransaction(transactionRunner, fn, options, signal);
|
|
@@ -239,6 +246,11 @@ class DrizzleDatabase {
|
|
|
239
246
|
throw new Error(REQUEST_TRANSACTION_UNAVAILABLE_ERROR);
|
|
240
247
|
}
|
|
241
248
|
}
|
|
249
|
+
assertTransactionsAvailable() {
|
|
250
|
+
if (this.lifecycleState !== 'ready') {
|
|
251
|
+
throw new Error(TRANSACTION_UNAVAILABLE_ERROR);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
242
254
|
throwIfRequestAborted(signal) {
|
|
243
255
|
if (signal.aborted) {
|
|
244
256
|
throw createAbortError(signal.reason);
|
|
@@ -262,6 +274,21 @@ class DrizzleDatabase {
|
|
|
262
274
|
handle.statusActive = false;
|
|
263
275
|
}
|
|
264
276
|
}
|
|
277
|
+
trackActiveTransactionScope() {
|
|
278
|
+
let settle;
|
|
279
|
+
const active = {
|
|
280
|
+
settled: new Promise(resolve => {
|
|
281
|
+
settle = resolve;
|
|
282
|
+
})
|
|
283
|
+
};
|
|
284
|
+
this.activeTransactionScopes.add(active);
|
|
285
|
+
return {
|
|
286
|
+
settle: () => {
|
|
287
|
+
this.activeTransactionScopes.delete(active);
|
|
288
|
+
settle();
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
265
292
|
resolveTransactionRunner() {
|
|
266
293
|
if (typeof this.database.transaction !== 'function') {
|
|
267
294
|
if (this.databaseOptions.strictTransactions) {
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAc5E,KAAK,yBAAyB,CAC5B,SAAS,SAAS,mBAAmB,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,EAChF,oBAAoB,EACpB,mBAAmB,IACjB,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,CAAC,EAAE,QAAQ,CAAC,CAAC,GAChH,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,CAAC,EAAE,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAc5E,KAAK,yBAAyB,CAC5B,SAAS,SAAS,mBAAmB,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,EAChF,oBAAoB,EACpB,mBAAmB,IACjB,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,CAAC,EAAE,QAAQ,CAAC,CAAC,GAChH,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,CAAC,EAAE,QAAQ,CAAC,CAAC;AAwH7F;;GAEG;AACH,qBAAa,aAAa;IACxB,+DAA+D;IAC/D,MAAM,CAAC,OAAO,CACZ,SAAS,SAAS,mBAAmB,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,EAChF,oBAAoB,GAAG,SAAS,EAChC,mBAAmB,GAAG,OAAO,EAC7B,OAAO,EAAE,oBAAoB,CAAC,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,CAAC,GAAG,UAAU;IAIlG,uEAAuE;IACvE,MAAM,CAAC,YAAY,CACjB,SAAS,SAAS,mBAAmB,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,EAChF,oBAAoB,GAAG,SAAS,EAChC,mBAAmB,GAAG,OAAO,EAC7B,OAAO,EAAE,yBAAyB,CAAC,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,CAAC,GAAG,UAAU;CAGxG"}
|
package/dist/module.js
CHANGED
|
@@ -4,7 +4,13 @@ import { DRIZZLE_DATABASE, DRIZZLE_DISPOSE, DRIZZLE_HANDLE_PROVIDER, DRIZZLE_OPT
|
|
|
4
4
|
import { DrizzleTransactionInterceptor } from './transaction.js';
|
|
5
5
|
const DRIZZLE_NORMALIZED_OPTIONS = Symbol('fluo.drizzle.normalized-options');
|
|
6
6
|
const DRIZZLE_MODULE_EXPORTS = [DrizzleDatabase, DrizzleTransactionInterceptor, DRIZZLE_HANDLE_PROVIDER];
|
|
7
|
+
function isObjectLike(value) {
|
|
8
|
+
return typeof value === 'object' && value !== null || typeof value === 'function';
|
|
9
|
+
}
|
|
7
10
|
function normalizeDrizzleModuleOptions(options) {
|
|
11
|
+
if (!isObjectLike(options.database)) {
|
|
12
|
+
throw new Error('DrizzleModule requires a database option.');
|
|
13
|
+
}
|
|
8
14
|
return {
|
|
9
15
|
...options,
|
|
10
16
|
strictTransactions: options.strictTransactions ?? false
|
|
@@ -33,25 +39,15 @@ function createDrizzleRuntimeProviders(normalizedOptionsProvider) {
|
|
|
33
39
|
useExisting: DrizzleDatabase
|
|
34
40
|
}, DrizzleTransactionInterceptor];
|
|
35
41
|
}
|
|
36
|
-
function createMemoizedDrizzleOptionsResolver(options) {
|
|
37
|
-
let cachedResult;
|
|
38
|
-
return (...deps) => {
|
|
39
|
-
if (!cachedResult) {
|
|
40
|
-
cachedResult = Promise.resolve(options.useFactory(...deps)).then(resolved => normalizeDrizzleModuleOptions(resolved));
|
|
41
|
-
}
|
|
42
|
-
if (!cachedResult) {
|
|
43
|
-
throw new Error('Drizzle module options resolver initialization failed.');
|
|
44
|
-
}
|
|
45
|
-
return cachedResult;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
42
|
function createDrizzleProvidersAsync(options) {
|
|
49
|
-
const resolveOptions = createMemoizedDrizzleOptionsResolver(options);
|
|
50
43
|
const normalizedOptionsProvider = {
|
|
51
44
|
inject: options.inject,
|
|
52
45
|
provide: DRIZZLE_NORMALIZED_OPTIONS,
|
|
53
46
|
scope: 'singleton',
|
|
54
|
-
useFactory: async (...deps) =>
|
|
47
|
+
useFactory: async (...deps) => normalizeDrizzleModuleOptions({
|
|
48
|
+
...(await options.useFactory(...deps)),
|
|
49
|
+
global: options.global
|
|
50
|
+
})
|
|
55
51
|
};
|
|
56
52
|
return createDrizzleRuntimeProviders(normalizedOptionsProvider);
|
|
57
53
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"transaction",
|
|
10
10
|
"als"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.
|
|
12
|
+
"version": "1.0.2",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@fluojs/core": "^1.0.
|
|
40
|
-
"@fluojs/http": "^1.
|
|
41
|
-
"@fluojs/di": "^1.0.
|
|
42
|
-
"@fluojs/runtime": "^1.
|
|
39
|
+
"@fluojs/core": "^1.0.3",
|
|
40
|
+
"@fluojs/http": "^1.1.0",
|
|
41
|
+
"@fluojs/di": "^1.0.3",
|
|
42
|
+
"@fluojs/runtime": "^1.1.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"drizzle-orm": ">=0.30.0"
|