@relkit/drizzle 0.5.4 → 0.5.6
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/activation.d.ts +9 -1
- package/dist/activation.d.ts.map +1 -1
- package/dist/activation.js +32 -8
- package/dist/activation.js.map +1 -1
- package/dist/activation.types.d.ts +6 -0
- package/dist/activation.types.d.ts.map +1 -0
- package/dist/activation.types.js +2 -0
- package/dist/activation.types.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/activation.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { DatabaseContext, DrizzleServiceDescriptor } from "./types.js";
|
|
2
|
+
import type { DrizzleActivationOptions } from "./activation.types.js";
|
|
3
|
+
export type { DrizzleActivationOptions } from "./activation.types.js";
|
|
2
4
|
export interface DrizzleActivation<Service extends DrizzleServiceDescriptor<any, any, any, any>> {
|
|
3
5
|
readonly client: Service extends DrizzleServiceDescriptor<any, infer Client, any, any> ? Client : never;
|
|
4
6
|
readonly context: DatabaseContext<Service>;
|
|
@@ -7,6 +9,12 @@ export interface DrizzleActivation<Service extends DrizzleServiceDescriptor<any,
|
|
|
7
9
|
/**
|
|
8
10
|
* Activates a service once per descriptor object and returns its client, context, and close hook.
|
|
9
11
|
* Repeated calls share the first activation; close does not evict the cached activation.
|
|
12
|
+
* Isolated acquisition bypasses that cache and transfers close ownership to the caller.
|
|
13
|
+
* @typeParam Service - Descriptor retaining client and model inference.
|
|
14
|
+
* @param service - Lazy database declaration.
|
|
15
|
+
* @param env - Environment passed to its client factory.
|
|
16
|
+
* @param options - Isolation policy for independently scoped application owners.
|
|
17
|
+
* @returns The acquired client/context and its idempotent close hook.
|
|
10
18
|
*
|
|
11
19
|
* @example
|
|
12
20
|
* ```ts
|
|
@@ -30,5 +38,5 @@ export interface DrizzleActivation<Service extends DrizzleServiceDescriptor<any,
|
|
|
30
38
|
* @category Database
|
|
31
39
|
* @since 0.1.0
|
|
32
40
|
*/
|
|
33
|
-
export declare function activateDrizzleService<Service extends DrizzleServiceDescriptor<any, any, any, any>>(service: Service, env: Readonly<Record<string, unknown
|
|
41
|
+
export declare function activateDrizzleService<Service extends DrizzleServiceDescriptor<any, any, any, any>>(service: Service, env: Readonly<Record<string, unknown>>, options?: DrizzleActivationOptions): Promise<DrizzleActivation<Service>>;
|
|
34
42
|
//# sourceMappingURL=activation.d.ts.map
|
package/dist/activation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../src/activation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../src/activation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,wBAAwB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAC7F,QAAQ,CAAC,MAAM,EAAE,OAAO,SAAS,wBAAwB,CAAC,GAAG,EAAE,MAAM,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GAClF,MAAM,GACN,KAAK,CAAC;IACV,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,SAAS,wBAAwB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAE5D,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACtC,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAQrC"}
|
package/dist/activation.js
CHANGED
|
@@ -4,6 +4,12 @@ const activations = new WeakMap();
|
|
|
4
4
|
/**
|
|
5
5
|
* Activates a service once per descriptor object and returns its client, context, and close hook.
|
|
6
6
|
* Repeated calls share the first activation; close does not evict the cached activation.
|
|
7
|
+
* Isolated acquisition bypasses that cache and transfers close ownership to the caller.
|
|
8
|
+
* @typeParam Service - Descriptor retaining client and model inference.
|
|
9
|
+
* @param service - Lazy database declaration.
|
|
10
|
+
* @param env - Environment passed to its client factory.
|
|
11
|
+
* @param options - Isolation policy for independently scoped application owners.
|
|
12
|
+
* @returns The acquired client/context and its idempotent close hook.
|
|
7
13
|
*
|
|
8
14
|
* @example
|
|
9
15
|
* ```ts
|
|
@@ -27,7 +33,9 @@ const activations = new WeakMap();
|
|
|
27
33
|
* @category Database
|
|
28
34
|
* @since 0.1.0
|
|
29
35
|
*/
|
|
30
|
-
export function activateDrizzleService(service, env) {
|
|
36
|
+
export function activateDrizzleService(service, env, options = {}) {
|
|
37
|
+
if (options.isolated === true)
|
|
38
|
+
return activate(service, env);
|
|
31
39
|
const existing = activations.get(service);
|
|
32
40
|
if (existing !== undefined)
|
|
33
41
|
return existing;
|
|
@@ -36,20 +44,36 @@ export function activateDrizzleService(service, env) {
|
|
|
36
44
|
activation.catch(() => activations.delete(service));
|
|
37
45
|
return activation;
|
|
38
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Binds one native client and releases it if context construction fails.
|
|
49
|
+
* @typeParam Service - Descriptor retaining client and model inference.
|
|
50
|
+
* @param service - Lazy declaration to activate.
|
|
51
|
+
* @param env - Resolved application environment.
|
|
52
|
+
* @returns One native activation with shared close completion.
|
|
53
|
+
*/
|
|
39
54
|
async function activate(service, env) {
|
|
40
55
|
const runtime = drizzleRuntimeOf(service);
|
|
41
56
|
const client = await runtime.client({ env });
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
let context;
|
|
58
|
+
try {
|
|
59
|
+
context = createDatabaseContext(service, runtime, client);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
try {
|
|
63
|
+
await runtime.dispose?.(client);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
/* Preserve the acquisition failure. */
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
let closing;
|
|
44
71
|
const result = {
|
|
45
72
|
client,
|
|
46
73
|
context,
|
|
47
|
-
close: async () => {
|
|
48
|
-
if (closed)
|
|
49
|
-
return;
|
|
50
|
-
closed = true;
|
|
74
|
+
close: () => (closing ??= Promise.resolve().then(async () => {
|
|
51
75
|
await runtime.dispose?.(client);
|
|
52
|
-
},
|
|
76
|
+
})),
|
|
53
77
|
};
|
|
54
78
|
Object.defineProperty(result, Symbol.for("relkit.drizzle.service"), { value: service });
|
|
55
79
|
return Object.freeze(result);
|
package/dist/activation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activation.js","sourceRoot":"","sources":["../src/activation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"activation.js","sourceRoot":"","sources":["../src/activation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAahD,MAAM,WAAW,GAAG,IAAI,OAAO,EAA2C,CAAC;AAE3E;;;;;;;;;;;;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,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YAC7C,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;KACN,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAA+B,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Acquisition policy for an application that owns its database lifetime. */
|
|
2
|
+
export interface DrizzleActivationOptions {
|
|
3
|
+
/** Bypasses descriptor sharing; the caller must close this activation. */
|
|
4
|
+
readonly isolated?: boolean;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=activation.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation.types.d.ts","sourceRoot":"","sources":["../src/activation.types.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,WAAW,wBAAwB;IACvC,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation.types.js","sourceRoot":"","sources":["../src/activation.types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { activateDrizzleService } from "./activation.js";
|
|
2
|
+
export type { DrizzleActivationOptions } from "./activation.types.js";
|
|
2
3
|
export { defineModel } from "./model.js";
|
|
3
4
|
export { defineDrizzleService } from "./service.js";
|
|
4
5
|
export type { ApplicationEnv, BaseOperations, DatabaseContext, DeleteArgs, DialectDatabase, DrizzleCapability, DrizzleOverrides, DrizzleServiceDescriptor, FindManyArgs, FindOneArgs, InsertArgs, ModelDescriptor, ModelExtensionContext, Row, TableOverrides, TableZodSchemas, Update, UpdateArgs, UpsertArgs, Where, } from "./types.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,GAAG,EACH,cAAc,EACd,eAAe,EACf,MAAM,EACN,UAAU,EACV,UAAU,EACV,KAAK,GACN,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,GAAG,EACH,cAAc,EACd,eAAe,EACf,MAAM,EACN,UAAU,EACV,UAAU,EACV,KAAK,GACN,MAAM,YAAY,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relkit/drizzle",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Drizzle ORM integration for RELKIT functions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@relkit/contracts": "0.5.
|
|
37
|
-
"@relkit/invocation": "0.5.
|
|
36
|
+
"@relkit/contracts": "0.5.6",
|
|
37
|
+
"@relkit/invocation": "0.5.6",
|
|
38
38
|
"drizzle-orm": "1.0.0-rc.5-169397b",
|
|
39
39
|
"zod": "4.4.3"
|
|
40
40
|
},
|