@fluojs/prisma 1.1.0 → 2.0.0

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/module.d.ts CHANGED
@@ -1,7 +1,14 @@
1
1
  import type { AsyncModuleOptions } from '@fluojs/core';
2
- import { type ModuleType } from '@fluojs/runtime';
2
+ import { type PrismaModuleType } from './integration.js';
3
3
  import type { InferPrismaTransactionClient, InferPrismaTransactionOptions, PrismaClientLike, PrismaModuleOptions } from './types.js';
4
- type PrismaAsyncModuleOptions<TClient extends PrismaClientLike<TTransactionClient, TTransactionOptions>, TTransactionClient, TTransactionOptions> = AsyncModuleOptions<Omit<PrismaModuleOptions<TClient, TTransactionClient, TTransactionOptions>, 'global' | 'name'>> & {
4
+ /**
5
+ * Configures an async Prisma module registration through an injected factory.
6
+ *
7
+ * @typeParam TClient Root Prisma client shape registered in the module.
8
+ * @typeParam TTransactionClient Transaction-scoped client resolved inside transaction callbacks.
9
+ * @typeParam TTransactionOptions Options forwarded to Prisma interactive transactions.
10
+ */
11
+ export type PrismaAsyncModuleOptions<TClient extends PrismaClientLike<TTransactionClient, TTransactionOptions>, TTransactionClient, TTransactionOptions> = AsyncModuleOptions<Omit<PrismaModuleOptions<TClient, TTransactionClient, TTransactionOptions>, 'global' | 'name'>> & {
5
12
  global?: boolean;
6
13
  name?: string;
7
14
  };
@@ -13,16 +20,15 @@ export declare class PrismaModule {
13
20
  * Registers Prisma providers from static options.
14
21
  *
15
22
  * @param options Prisma module options with client handle and strict transaction mode.
16
- * @returns A module definition that exports `PrismaService` and related Prisma tokens.
23
+ * @returns A module definition that exports `PrismaService`, compatibility interceptor, and related Prisma tokens.
17
24
  */
18
- static forRoot<TClient extends PrismaClientLike<TTransactionClient, TTransactionOptions>, TTransactionClient = InferPrismaTransactionClient<TClient>, TTransactionOptions = InferPrismaTransactionOptions<TClient>>(options: PrismaModuleOptions<TClient, TTransactionClient, TTransactionOptions>): ModuleType;
25
+ static forRoot<TClient extends PrismaClientLike<TTransactionClient, TTransactionOptions>, TTransactionClient = InferPrismaTransactionClient<TClient>, TTransactionOptions = InferPrismaTransactionOptions<TClient>>(options: PrismaModuleOptions<TClient, TTransactionClient, TTransactionOptions>): PrismaModuleType;
19
26
  /**
20
27
  * Registers Prisma providers from an async DI factory.
21
28
  *
22
29
  * @param options Async module options that resolve Prisma client/module configuration.
23
30
  * @returns A module definition that resolves async options once per application container.
24
31
  */
25
- static forRootAsync<TClient extends PrismaClientLike<TTransactionClient, TTransactionOptions>, TTransactionClient = InferPrismaTransactionClient<TClient>, TTransactionOptions = InferPrismaTransactionOptions<TClient>>(options: PrismaAsyncModuleOptions<TClient, TTransactionClient, TTransactionOptions>): ModuleType;
32
+ static forRootAsync<TClient extends PrismaClientLike<TTransactionClient, TTransactionOptions>, TTransactionClient = InferPrismaTransactionClient<TClient>, TTransactionOptions = InferPrismaTransactionOptions<TClient>>(options: PrismaAsyncModuleOptions<TClient, TTransactionClient, TTransactionOptions>): PrismaModuleType;
26
33
  }
27
- export {};
28
34
  //# sourceMappingURL=module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAS,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQhE,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAapB,KAAK,wBAAwB,CAC3B,OAAO,SAAS,gBAAgB,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,EACzE,kBAAkB,EAClB,mBAAmB,IACjB,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC,GAAG;IACvH,MAAM,C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H,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AA2MF;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,OAAO,SAAS,gBAAgB,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,EACzE,kBAAkB,GAAG,4BAA4B,CAAC,OAAO,CAAC,EAC1D,mBAAmB,GAAG,6BAA6B,CAAC,OAAO,CAAC,EAE5D,OAAO,EAAE,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,GAC7E,gBAAgB;IAInB;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CACjB,OAAO,SAAS,gBAAgB,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,EACzE,kBAAkB,GAAG,4BAA4B,CAAC,OAAO,CAAC,EAC1D,mBAAmB,GAAG,6BAA6B,CAAC,OAAO,CAAC,EAE5D,OAAO,EAAE,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,GAClF,gBAAgB;CAGpB"}
package/dist/module.js CHANGED
@@ -1,6 +1,16 @@
1
- import { defineModule } from '@fluojs/runtime';
1
+ import { definePrismaModule } from './integration.js';
2
2
  import { PrismaService } from './service.js';
3
3
  import { getPrismaClientToken, getPrismaOptionsToken, getPrismaServiceToken } from './tokens.js';
4
+ import { PrismaTransactionInterceptor } from './transaction.js';
5
+
6
+ /**
7
+ * Configures an async Prisma module registration through an injected factory.
8
+ *
9
+ * @typeParam TClient Root Prisma client shape registered in the module.
10
+ * @typeParam TTransactionClient Transaction-scoped client resolved inside transaction callbacks.
11
+ * @typeParam TTransactionOptions Options forwarded to Prisma interactive transactions.
12
+ */
13
+
4
14
  const PRISMA_NORMALIZED_OPTIONS = Symbol('fluo.prisma.normalized-options');
5
15
  function isObjectLike(value) {
6
16
  return typeof value === 'object' && value !== null || typeof value === 'function';
@@ -57,25 +67,23 @@ function createPrismaRuntimeProviders(normalizedOptionsProvider, name) {
57
67
  }, ...(name === undefined ? [createPrismaServiceProvider(PrismaService, clientToken, optionsToken), {
58
68
  provide: getPrismaServiceToken(),
59
69
  useExisting: PrismaService
60
- }] : [createPrismaServiceProvider(getPrismaServiceToken(name), clientToken, optionsToken)])];
70
+ }, PrismaTransactionInterceptor] : [createPrismaServiceProvider(getPrismaServiceToken(name), clientToken, optionsToken)])];
61
71
  }
62
72
  function buildPrismaModule(options) {
63
- class PrismaRootModuleDefinition {}
64
73
  const normalizedOptions = normalizePrismaModuleOptions(options);
65
74
  if (normalizedOptions.name !== undefined && normalizedOptions.global) {
66
75
  throw new Error('Named Prisma registrations are scoped and cannot be registered globally.');
67
76
  }
68
- return defineModule(PrismaRootModuleDefinition, {
69
- exports: normalizedOptions.name === undefined ? [PrismaService, getPrismaServiceToken(), getPrismaClientToken(), getPrismaOptionsToken()] : [getPrismaServiceToken(normalizedOptions.name), getPrismaClientToken(normalizedOptions.name), getPrismaOptionsToken(normalizedOptions.name)],
77
+ return definePrismaModule({
78
+ exports: normalizedOptions.name === undefined ? [PrismaService, PrismaTransactionInterceptor, getPrismaServiceToken(), getPrismaClientToken(), getPrismaOptionsToken()] : [getPrismaServiceToken(normalizedOptions.name), getPrismaClientToken(normalizedOptions.name), getPrismaOptionsToken(normalizedOptions.name)],
70
79
  global: normalizedOptions.name === undefined ? normalizedOptions.global : false,
71
80
  providers: createPrismaRuntimeProviders({
72
81
  provide: getPrismaNormalizedOptionsToken(normalizedOptions.name),
73
82
  useValue: normalizedOptions
74
83
  }, normalizedOptions.name)
75
- });
84
+ }, 'PrismaRootModuleDefinition');
76
85
  }
77
86
  function buildPrismaModuleAsync(options) {
78
- class PrismaAsyncModuleDefinition {}
79
87
  const factory = options.useFactory;
80
88
  const normalizedName = normalizePrismaRegistrationName(options.name);
81
89
  if (normalizedName !== undefined && options.global) {
@@ -94,11 +102,11 @@ function buildPrismaModuleAsync(options) {
94
102
  });
95
103
  }
96
104
  };
97
- return defineModule(PrismaAsyncModuleDefinition, {
98
- exports: normalizedName === undefined ? [PrismaService, getPrismaServiceToken(), getPrismaClientToken(), getPrismaOptionsToken()] : [getPrismaServiceToken(normalizedName), getPrismaClientToken(normalizedName), getPrismaOptionsToken(normalizedName)],
105
+ return definePrismaModule({
106
+ exports: normalizedName === undefined ? [PrismaService, PrismaTransactionInterceptor, getPrismaServiceToken(), getPrismaClientToken(), getPrismaOptionsToken()] : [getPrismaServiceToken(normalizedName), getPrismaClientToken(normalizedName), getPrismaOptionsToken(normalizedName)],
99
107
  global: normalizedName === undefined ? options.global ?? false : false,
100
108
  providers: createPrismaRuntimeProviders(normalizedOptionsProvider, normalizedName)
101
- });
109
+ }, 'PrismaAsyncModuleDefinition');
102
110
  }
103
111
 
104
112
  /**
@@ -109,7 +117,7 @@ export class PrismaModule {
109
117
  * Registers Prisma providers from static options.
110
118
  *
111
119
  * @param options Prisma module options with client handle and strict transaction mode.
112
- * @returns A module definition that exports `PrismaService` and related Prisma tokens.
120
+ * @returns A module definition that exports `PrismaService`, compatibility interceptor, and related Prisma tokens.
113
121
  */
114
122
  static forRoot(options) {
115
123
  return buildPrismaModule(options);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Marks an internal Prisma service or facade handle for default `@Transaction()` resolution.
3
+ *
4
+ * @internal
5
+ */
6
+ export declare function markPrismaServiceHandle<THandle extends object>(handle: THandle): THandle;
7
+ /**
8
+ * Checks whether a value is an internally marked Prisma service or facade handle.
9
+ *
10
+ * @internal
11
+ */
12
+ export declare function isPrismaServiceHandle(value: unknown): value is object;
13
+ //# sourceMappingURL=prisma-service-brand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-service-brand.d.ts","sourceRoot":"","sources":["../src/prisma-service-brand.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAIxF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAMrE"}
@@ -0,0 +1,23 @@
1
+ const brandedPrismaServiceHandles = new WeakSet();
2
+
3
+ /**
4
+ * Marks an internal Prisma service or facade handle for default `@Transaction()` resolution.
5
+ *
6
+ * @internal
7
+ */
8
+ export function markPrismaServiceHandle(handle) {
9
+ brandedPrismaServiceHandles.add(handle);
10
+ return handle;
11
+ }
12
+
13
+ /**
14
+ * Checks whether a value is an internally marked Prisma service or facade handle.
15
+ *
16
+ * @internal
17
+ */
18
+ export function isPrismaServiceHandle(value) {
19
+ if (typeof value !== 'object' && typeof value !== 'function' || value === null) {
20
+ return false;
21
+ }
22
+ return brandedPrismaServiceHandles.has(value);
23
+ }
package/dist/service.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { OnApplicationShutdown, OnModuleInit } from '@fluojs/runtime';
1
+ import { type OnApplicationShutdown, type OnModuleInit } from './integration.js';
2
2
  import type { InferPrismaTransactionClient, InferPrismaTransactionOptions, PrismaClientLike, PrismaHandleProvider } from './types.js';
3
3
  interface PrismaServiceOptions {
4
4
  strictTransactions: boolean;
@@ -15,6 +15,9 @@ export declare class PrismaService<TClient extends PrismaClientLike<TTransaction
15
15
  private readonly serviceOptions;
16
16
  private readonly transactions;
17
17
  private readonly activeRequestTransactions;
18
+ private readonly activeTransactionBoundaries;
19
+ private connectTransition?;
20
+ private shutdownTransition?;
18
21
  private transactionAbortSignalSupport;
19
22
  private lifecycleState;
20
23
  constructor(client: TClient, serviceOptions?: PrismaServiceOptions);
@@ -46,12 +49,38 @@ export declare class PrismaService<TClient extends PrismaClientLike<TTransaction
46
49
  private runWithTransactionClient;
47
50
  onModuleInit(): Promise<void>;
48
51
  onApplicationShutdown(): Promise<void>;
52
+ private completeApplicationShutdown;
49
53
  /**
50
54
  * Creates a shared platform-status snapshot for runtime/CLI/Studio health surfaces.
51
55
  *
52
56
  * @returns Platform snapshot data reflecting lifecycle state and transaction capability diagnostics.
53
57
  */
54
- createPlatformStatusSnapshot(): import("@fluojs/runtime").PersistencePlatformStatusSnapshot;
58
+ createPlatformStatusSnapshot(): {
59
+ details: Record<string, unknown>;
60
+ health: {
61
+ checks?: Array<{
62
+ message?: string;
63
+ name: string;
64
+ status: "pass" | "fail" | "degraded";
65
+ }>;
66
+ reason?: string;
67
+ status: "healthy" | "unhealthy" | "degraded";
68
+ };
69
+ ownership: {
70
+ externallyManaged: boolean;
71
+ ownsResources: boolean;
72
+ };
73
+ readiness: {
74
+ checks?: Array<{
75
+ message?: string;
76
+ name: string;
77
+ status: "pass" | "fail" | "degraded";
78
+ }>;
79
+ critical: boolean;
80
+ reason?: string;
81
+ status: "ready" | "not-ready" | "degraded";
82
+ };
83
+ };
55
84
  /**
56
85
  * Opens a Prisma interactive transaction boundary and executes the callback in that context.
57
86
  *
@@ -94,6 +123,7 @@ export declare class PrismaService<TClient extends PrismaClientLike<TTransaction
94
123
  private runWithRequestTransactionClient;
95
124
  private runNestedRequestTransaction;
96
125
  private assertRequestTransactionsAvailable;
126
+ private assertTransactionBoundariesAvailable;
97
127
  private assertTransactionContextAvailable;
98
128
  private throwIfRequestAborted;
99
129
  private runRequestTransactionWithAbortSignal;
@@ -104,6 +134,8 @@ export declare class PrismaService<TClient extends PrismaClientLike<TTransaction
104
134
  private withTransactionAbortSignal;
105
135
  private trackActiveRequestTransaction;
106
136
  private untrackActiveRequestTransaction;
137
+ private trackActiveTransactionBoundary;
138
+ private untrackActiveTransactionBoundary;
107
139
  }
108
140
  /**
109
141
  * Injection-facing Prisma facade type that combines the Fluo wrapper methods with the registered Prisma client surface.
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAK3E,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,gBAAgB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,kBAAkB,EAAE,mBAAmB,CAAC,GACjE,IAAI,CAAC,OAAO,EAAE,MAAM,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC,CAAC"}
package/dist/service.js CHANGED
@@ -4,15 +4,18 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
4
4
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
5
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
6
6
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
7
- import { createAbortError, createRequestAbortContext, raceWithAbort, trackActiveRequestTransaction, untrackActiveRequestTransaction } from '@fluojs/runtime';
8
7
  import { Inject } from '@fluojs/core';
8
+ import { createAbortError, createRequestAbortContext, raceWithAbort, trackActiveRequestTransaction, untrackActiveRequestTransaction } from './integration.js';
9
+ import { markPrismaServiceHandle } from './prisma-service-brand.js';
9
10
  import { createPrismaPlatformStatusSnapshot } from './status.js';
10
11
  import { PRISMA_CLIENT, PRISMA_OPTIONS } from './tokens.js';
11
12
  const NESTED_TRANSACTION_OPTIONS_NOT_SUPPORTED_ERROR = 'Nested Prisma transaction options are not supported because the active transaction context is reused.';
12
13
  const REQUEST_TRANSACTION_UNAVAILABLE_ERROR = 'Prisma request transactions are not available during shutdown.';
14
+ const TRANSACTION_BOUNDARY_UNAVAILABLE_ERROR = 'Prisma transaction boundaries are not available during shutdown.';
13
15
  const TRANSACTION_CONTEXT_UNAVAILABLE_ERROR = 'Prisma transaction context requires AsyncLocalStorage support from the host runtime.';
14
16
  function createCurrentClientPrismaFacade(target) {
15
- return new Proxy(target, {
17
+ markPrismaServiceHandle(target);
18
+ return markPrismaServiceHandle(new Proxy(target, {
16
19
  get(service, prop, receiver) {
17
20
  if (prop in service) {
18
21
  return Reflect.get(service, prop, receiver);
@@ -21,7 +24,7 @@ function createCurrentClientPrismaFacade(target) {
21
24
  const value = Reflect.get(currentClient, prop, currentClient);
22
25
  return typeof value === 'function' ? value.bind(currentClient) : value;
23
26
  }
24
- });
27
+ }));
25
28
  }
26
29
  class AsyncLocalStorageTransactionContextStore {
27
30
  kind = 'als';
@@ -49,7 +52,11 @@ function resolveAsyncLocalStorageConstructor(host = globalThis) {
49
52
  if (typeof host.AsyncLocalStorage === 'function') {
50
53
  return host.AsyncLocalStorage;
51
54
  }
52
- return host.process?.getBuiltinModule?.('node:async_hooks').AsyncLocalStorage;
55
+ try {
56
+ return host.process?.getBuiltinModule?.('node:async_hooks')?.AsyncLocalStorage;
57
+ } catch {
58
+ return undefined;
59
+ }
53
60
  }
54
61
  function createTransactionContextStore() {
55
62
  const AsyncLocalStorage = resolveAsyncLocalStorageConstructor();
@@ -73,6 +80,9 @@ class PrismaService {
73
80
  }
74
81
  transactions = createTransactionContextStore();
75
82
  activeRequestTransactions = new Set();
83
+ activeTransactionBoundaries = new Set();
84
+ connectTransition;
85
+ shutdownTransition;
76
86
  transactionAbortSignalSupport = 'unknown';
77
87
  lifecycleState = 'created';
78
88
  constructor(client, serviceOptions = {
@@ -80,6 +90,7 @@ class PrismaService {
80
90
  }) {
81
91
  this.client = client;
82
92
  this.serviceOptions = serviceOptions;
93
+ markPrismaServiceHandle(this);
83
94
  this.installCurrentClientFacade();
84
95
  }
85
96
 
@@ -136,37 +147,66 @@ class PrismaService {
136
147
  }
137
148
  return fn();
138
149
  }
139
- if (typeof this.client.$transaction !== 'function') {
140
- if (this.serviceOptions.strictTransactions) {
141
- throw new Error('Transaction not supported: Prisma client does not implement $transaction.');
142
- }
143
- return fn();
144
- }
145
- this.assertTransactionContextAvailable();
146
- const deferredRequestTransactionHandles = new Set();
150
+ this.assertTransactionBoundariesAvailable();
151
+ const activeTransaction = this.trackActiveTransactionBoundary();
147
152
  try {
148
- return await run(transactionClient => this.transactions.run({
149
- client: transactionClient,
150
- deferredRequestTransactionHandles
151
- }, fn), options);
152
- } finally {
153
- for (const handle of deferredRequestTransactionHandles) {
154
- this.untrackActiveRequestTransaction(handle);
153
+ if (typeof this.client.$transaction !== 'function') {
154
+ if (this.serviceOptions.strictTransactions) {
155
+ throw new Error('Transaction not supported: Prisma client does not implement $transaction.');
156
+ }
157
+ return await fn();
155
158
  }
159
+ this.assertTransactionContextAvailable();
160
+ const deferredRequestTransactionHandles = new Set();
161
+ try {
162
+ return await run(transactionClient => this.transactions.run({
163
+ client: transactionClient,
164
+ deferredRequestTransactionHandles
165
+ }, fn), options);
166
+ } finally {
167
+ for (const handle of deferredRequestTransactionHandles) {
168
+ this.untrackActiveRequestTransaction(handle);
169
+ }
170
+ }
171
+ } finally {
172
+ this.untrackActiveTransactionBoundary(activeTransaction);
156
173
  }
157
174
  }
158
175
  async onModuleInit() {
159
176
  if (typeof this.client.$connect === 'function') {
160
- await this.client.$connect();
177
+ this.connectTransition = Promise.resolve(this.client.$connect());
178
+ await this.connectTransition;
179
+ }
180
+ if (this.lifecycleState === 'created') {
181
+ this.lifecycleState = 'ready';
161
182
  }
162
- this.lifecycleState = 'ready';
163
183
  }
164
- async onApplicationShutdown() {
184
+ onApplicationShutdown() {
185
+ if (this.lifecycleState === 'stopped') {
186
+ return Promise.resolve();
187
+ }
188
+ if (this.shutdownTransition) {
189
+ return this.shutdownTransition;
190
+ }
191
+ const shutdownTransition = this.completeApplicationShutdown();
192
+ this.shutdownTransition = shutdownTransition;
193
+ void shutdownTransition.then(undefined, () => {
194
+ if (this.shutdownTransition === shutdownTransition) {
195
+ this.shutdownTransition = undefined;
196
+ }
197
+ });
198
+ return shutdownTransition;
199
+ }
200
+ async completeApplicationShutdown() {
165
201
  this.lifecycleState = 'shutting-down';
166
202
  for (const transaction of this.activeRequestTransactions) {
167
203
  transaction.abort(new Error('Application shutdown interrupted an open request transaction.'));
168
204
  }
169
205
  await Promise.allSettled(Array.from(this.activeRequestTransactions, transaction => transaction.settled));
206
+ await Promise.allSettled(Array.from(this.activeTransactionBoundaries, transaction => transaction.settled));
207
+ if (this.connectTransition) {
208
+ await Promise.allSettled([this.connectTransition]);
209
+ }
170
210
  if (typeof this.client.$disconnect === 'function') {
171
211
  await this.client.$disconnect();
172
212
  }
@@ -180,6 +220,7 @@ class PrismaService {
180
220
  */
181
221
  createPlatformStatusSnapshot() {
182
222
  return createPrismaPlatformStatusSnapshot({
223
+ activeTransactionBoundaries: this.activeTransactionBoundaries.size,
183
224
  activeRequestTransactions: this.activeRequestTransactions.size,
184
225
  lifecycleState: this.lifecycleState,
185
226
  strictTransactions: this.serviceOptions.strictTransactions,
@@ -295,6 +336,11 @@ class PrismaService {
295
336
  throw new Error(REQUEST_TRANSACTION_UNAVAILABLE_ERROR);
296
337
  }
297
338
  }
339
+ assertTransactionBoundariesAvailable() {
340
+ if (this.lifecycleState === 'shutting-down' || this.lifecycleState === 'stopped') {
341
+ throw new Error(TRANSACTION_BOUNDARY_UNAVAILABLE_ERROR);
342
+ }
343
+ }
298
344
  assertTransactionContextAvailable() {
299
345
  if (this.transactions.kind === 'unavailable') {
300
346
  throw new Error(TRANSACTION_CONTEXT_UNAVAILABLE_ERROR);
@@ -368,6 +414,23 @@ class PrismaService {
368
414
  untrackActiveRequestTransaction(handle) {
369
415
  untrackActiveRequestTransaction(this.activeRequestTransactions, handle);
370
416
  }
417
+ trackActiveTransactionBoundary() {
418
+ let settle;
419
+ const active = {
420
+ settled: new Promise(resolve => {
421
+ settle = resolve;
422
+ })
423
+ };
424
+ this.activeTransactionBoundaries.add(active);
425
+ return {
426
+ active,
427
+ settle
428
+ };
429
+ }
430
+ untrackActiveTransactionBoundary(handle) {
431
+ this.activeTransactionBoundaries.delete(handle.active);
432
+ handle.settle();
433
+ }
371
434
  static {
372
435
  _initClass();
373
436
  }
package/dist/status.d.ts CHANGED
@@ -1,6 +1,41 @@
1
- import type { PersistencePlatformStatusSnapshot } from '@fluojs/runtime';
1
+ type PlatformReadinessReport = {
2
+ checks?: Array<{
3
+ message?: string;
4
+ name: string;
5
+ status: 'pass' | 'fail' | 'degraded';
6
+ }>;
7
+ critical: boolean;
8
+ reason?: string;
9
+ status: 'ready' | 'not-ready' | 'degraded';
10
+ };
11
+ type PlatformHealthReport = {
12
+ checks?: Array<{
13
+ message?: string;
14
+ name: string;
15
+ status: 'pass' | 'fail' | 'degraded';
16
+ }>;
17
+ reason?: string;
18
+ status: 'healthy' | 'unhealthy' | 'degraded';
19
+ };
20
+ type PersistencePlatformStatusSnapshot = {
21
+ details: Record<string, unknown>;
22
+ health: PlatformHealthReport;
23
+ ownership: {
24
+ externallyManaged: boolean;
25
+ ownsResources: boolean;
26
+ };
27
+ readiness: PlatformReadinessReport;
28
+ };
2
29
  type PrismaPlatformLifecycleState = 'created' | 'ready' | 'shutting-down' | 'stopped';
3
- type PrismaPlatformStatusSnapshotInput = {
30
+ /**
31
+ * Supplies lifecycle and transaction state for a Prisma platform status snapshot.
32
+ *
33
+ * @remarks
34
+ * Omit `activeTransactionBoundaries` when no outer service or manual transaction boundary is open;
35
+ * the snapshot reports it as `0`.
36
+ */
37
+ export type PrismaPlatformStatusSnapshotInput = {
38
+ activeTransactionBoundaries?: number;
4
39
  activeRequestTransactions: number;
5
40
  lifecycleState: PrismaPlatformLifecycleState;
6
41
  strictTransactions: boolean;
@@ -11,10 +46,15 @@ type PrismaPlatformStatusSnapshotInput = {
11
46
  transactionContext?: 'als' | 'unavailable';
12
47
  };
13
48
  /**
14
- * Create prisma platform status snapshot.
49
+ * Creates a Prisma platform status snapshot for diagnostics surfaces.
50
+ *
51
+ * @remarks
52
+ * `details.activeTransactionBoundaries` reports open outer service/manual transaction boundaries that
53
+ * shutdown drains before disconnecting. It is intentionally distinct from
54
+ * `details.activeRequestTransactions`, which reports abort-aware request transaction activity.
15
55
  *
16
- * @param input The input.
17
- * @returns The create prisma platform status snapshot result.
56
+ * @param input Lifecycle and transaction activity inputs for the registered Prisma client.
57
+ * @returns A snapshot containing lifecycle, health, readiness, ownership, and transaction diagnostics.
18
58
  */
19
59
  export declare function createPrismaPlatformStatusSnapshot(input: PrismaPlatformStatusSnapshotInput): PersistencePlatformStatusSnapshot;
20
60
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iCAAiC,EAGlC,MAAM,iBAAiB,CAAC;AAEzB,KAAK,4BAA4B,GAAG,SAAS,GAAG,OAAO,GAAG,eAAe,GAAG,SAAS,CAAC;AAEtF,KAAK,iCAAiC,GAAG;IACvC,yBAAyB,EAAE,MAAM,CAAC;IAClC,cAAc,EAAE,4BAA4B,CAAC;IAC7C,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,6BAA6B,EAAE,SAAS,GAAG,WAAW,GAAG,aAAa,CAAC;IACvE,kBAAkB,CAAC,EAAE,KAAK,GAAG,aAAa,CAAC;CAC5C,CAAC;AAqEF;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,iCAAiC,GACvC,iCAAiC,CAqBnC"}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,KAAK,uBAAuB,GAAG;IAC7B,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC,CAAC;IACzF,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,C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package/dist/status.js CHANGED
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Supplies lifecycle and transaction state for a Prisma platform status snapshot.
3
+ *
4
+ * @remarks
5
+ * Omit `activeTransactionBoundaries` when no outer service or manual transaction boundary is open;
6
+ * the snapshot reports it as `0`.
7
+ */
8
+
1
9
  function createReadiness(input) {
2
10
  if (input.lifecycleState === 'created') {
3
11
  return {
@@ -48,7 +56,7 @@ function createHealth(input) {
48
56
  }
49
57
  if (input.lifecycleState === 'shutting-down') {
50
58
  return {
51
- reason: 'Prisma integration is draining request transactions during shutdown.',
59
+ reason: 'Prisma integration is draining open transactions during shutdown.',
52
60
  status: 'degraded'
53
61
  };
54
62
  }
@@ -58,15 +66,21 @@ function createHealth(input) {
58
66
  }
59
67
 
60
68
  /**
61
- * Create prisma platform status snapshot.
69
+ * Creates a Prisma platform status snapshot for diagnostics surfaces.
70
+ *
71
+ * @remarks
72
+ * `details.activeTransactionBoundaries` reports open outer service/manual transaction boundaries that
73
+ * shutdown drains before disconnecting. It is intentionally distinct from
74
+ * `details.activeRequestTransactions`, which reports abort-aware request transaction activity.
62
75
  *
63
- * @param input The input.
64
- * @returns The create prisma platform status snapshot result.
76
+ * @param input Lifecycle and transaction activity inputs for the registered Prisma client.
77
+ * @returns A snapshot containing lifecycle, health, readiness, ownership, and transaction diagnostics.
65
78
  */
66
79
  export function createPrismaPlatformStatusSnapshot(input) {
67
80
  const transactionContext = input.transactionContext ?? 'als';
68
81
  return {
69
82
  details: {
83
+ activeTransactionBoundaries: input.activeTransactionBoundaries ?? 0,
70
84
  activeRequestTransactions: input.activeRequestTransactions,
71
85
  lifecycleState: input.lifecycleState,
72
86
  strictTransactions: input.strictTransactions,
@@ -1,4 +1,9 @@
1
+ import type { CallHandler, Interceptor, InterceptorContext } from '@fluojs/http';
2
+ import { PrismaService } from './service.js';
3
+ import type { PrismaClientLike } from './types.js';
1
4
  type TransactionalPrismaService<TOptions = unknown> = {
5
+ createPlatformStatusSnapshot(): unknown;
6
+ current(): unknown;
2
7
  transaction<T>(fn: () => Promise<T>, options?: TOptions): Promise<T>;
3
8
  };
4
9
  type TransactionAccessor<THost, TOptions> = (self: THost) => TransactionalPrismaService<TOptions>;
@@ -18,5 +23,27 @@ type TransactionMethod<THost, TArgs extends unknown[], TResult> = (this: THost,
18
23
  * @returns A standard method decorator that runs the original method inside a Prisma transaction boundary.
19
24
  */
20
25
  export declare function Transaction<THost, TOptions = unknown>(input?: TransactionAccessor<THost, TOptions> | TOptions): <TArgs extends unknown[], TResult>(value: TransactionMethod<THost, TArgs, TResult>, context: ClassMethodDecoratorContext<THost, TransactionMethod<THost, TArgs, TResult>>) => TransactionMethod<THost, TArgs, TResult>;
26
+ /**
27
+ * Compatibility HTTP interceptor that opens a Prisma request transaction around a routed handler.
28
+ *
29
+ * @remarks
30
+ * This deprecated 1.x bridge forwards the request `AbortSignal` to `PrismaService.requestTransaction(...)` and is
31
+ * registered only by the unnamed `PrismaModule` entrypoint. Prefer service-layer `@Transaction()` or an explicit
32
+ * request boundary for new code.
33
+ *
34
+ * @deprecated Prefer service-layer `@Transaction()` or explicit `PrismaService.requestTransaction(...)`.
35
+ */
36
+ export declare class PrismaTransactionInterceptor implements Interceptor {
37
+ private readonly prisma;
38
+ constructor(prisma: PrismaService<PrismaClientLike>);
39
+ /**
40
+ * Runs the downstream handler inside the compatibility request transaction.
41
+ *
42
+ * @param context Interceptor context containing the request cancellation signal.
43
+ * @param next Downstream handler chain.
44
+ * @returns The downstream result after the request transaction settles.
45
+ */
46
+ intercept(context: InterceptorContext, next: CallHandler): Promise<unknown>;
47
+ }
21
48
  export {};
22
49
  //# sourceMappingURL=transaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,KAAK,0BAA0B,CAAC,QAAQ,GAAG,OAAO,IAAI;IACpD,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAA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