@relkit/drizzle 0.5.5 → 0.6.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/activation.d.ts +11 -7
- package/dist/activation.d.ts.map +1 -1
- package/dist/activation.js +74 -19
- package/dist/activation.js.map +1 -1
- package/dist/activation.types.d.ts +24 -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/context.d.ts +12 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +35 -56
- package/dist/context.js.map +1 -1
- package/dist/context.types.d.ts +11 -0
- package/dist/context.types.d.ts.map +1 -0
- package/dist/context.types.js +2 -0
- package/dist/context.types.js.map +1 -0
- package/dist/coordination.d.ts +15 -0
- package/dist/coordination.d.ts.map +1 -0
- package/dist/coordination.js +27 -0
- package/dist/coordination.js.map +1 -0
- package/dist/failure.d.ts +48 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +66 -0
- package/dist/failure.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +12 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +11 -0
- package/dist/internal.js.map +1 -1
- package/dist/metadata.d.ts +18 -0
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +44 -0
- package/dist/metadata.js.map +1 -1
- package/dist/model.d.ts +18 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +40 -8
- package/dist/model.js.map +1 -1
- package/dist/mutations.d.ts +25 -0
- package/dist/mutations.d.ts.map +1 -0
- package/dist/mutations.js +67 -0
- package/dist/mutations.js.map +1 -0
- package/dist/native-leases.d.ts +54 -0
- package/dist/native-leases.d.ts.map +1 -0
- package/dist/native-leases.js +92 -0
- package/dist/native-leases.js.map +1 -0
- package/dist/native-leases.types.d.ts +17 -0
- package/dist/native-leases.types.d.ts.map +1 -0
- package/dist/native-leases.types.js +2 -0
- package/dist/native-leases.types.js.map +1 -0
- package/dist/operation-tracing.d.ts +25 -2
- package/dist/operation-tracing.d.ts.map +1 -1
- package/dist/operation-tracing.js +72 -2
- package/dist/operation-tracing.js.map +1 -1
- package/dist/operations.d.ts +30 -1
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +103 -166
- package/dist/operations.js.map +1 -1
- package/dist/operations.types.d.ts +115 -0
- package/dist/operations.types.d.ts.map +1 -0
- package/dist/operations.types.js +2 -0
- package/dist/operations.types.js.map +1 -0
- package/dist/operations.utils.d.ts +80 -0
- package/dist/operations.utils.d.ts.map +1 -0
- package/dist/operations.utils.js +132 -0
- package/dist/operations.utils.js.map +1 -0
- package/dist/owner.d.ts +76 -0
- package/dist/owner.d.ts.map +1 -0
- package/dist/owner.js +159 -0
- package/dist/owner.js.map +1 -0
- package/dist/owner.types.d.ts +42 -0
- package/dist/owner.types.d.ts.map +1 -0
- package/dist/owner.types.js +2 -0
- package/dist/owner.types.js.map +1 -0
- package/dist/queries.d.ts +32 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +71 -0
- package/dist/queries.js.map +1 -0
- package/dist/runtime-types.d.ts +19 -0
- package/dist/runtime-types.d.ts.map +1 -1
- package/dist/runtime-types.js +2 -0
- package/dist/runtime-types.js.map +1 -1
- package/dist/service.d.ts +15 -11
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +40 -0
- package/dist/service.js.map +1 -1
- package/dist/service.types.d.ts +28 -0
- package/dist/service.types.d.ts.map +1 -0
- package/dist/service.types.js +2 -0
- package/dist/service.types.js.map +1 -0
- package/dist/table.schemas.d.ts +27 -0
- package/dist/table.schemas.d.ts.map +1 -0
- package/dist/table.schemas.js +54 -0
- package/dist/table.schemas.js.map +1 -0
- package/dist/trace-redaction.d.ts +17 -0
- package/dist/trace-redaction.d.ts.map +1 -0
- package/dist/trace-redaction.js +50 -0
- package/dist/trace-redaction.js.map +1 -0
- package/dist/transaction.d.ts +35 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transaction.js +130 -0
- package/dist/transaction.js.map +1 -0
- package/dist/types.d.ts +86 -47
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -3
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Observes specialized work once through the configured caller sinks.
|
|
4
|
+
* @typeParam A - Successful value.
|
|
5
|
+
* @typeParam E - Typed failure retained together with defects/interruption.
|
|
6
|
+
* @typeParam R - Required caller services.
|
|
7
|
+
* @param operation - Bounded label; custom method names are normalized.
|
|
8
|
+
* @param effect - Lazy authoritative work; payloads are never recorded.
|
|
9
|
+
* @returns An observed Effect retaining values, causes and requirements.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from "effect";
|
|
13
|
+
* import { observeSpecializedOperation } from "@relkit/drizzle/internal";
|
|
14
|
+
* await Effect.runPromise(observeSpecializedOperation("auth.session", Effect.succeed(null)));
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function observeSpecializedOperation<A, E, R>(operation: `database.${string}` | `auth.${string}`, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
|
|
18
|
+
/**
|
|
19
|
+
* Bridges invocation parenting without capturing native rows or auth sessions.
|
|
20
|
+
* @typeParam A - Private operation result.
|
|
21
|
+
* @param operation - Bounded operation label.
|
|
22
|
+
* @param run - Existing runtime boundary.
|
|
23
|
+
* @returns Original result; the invocation span sees only void.
|
|
24
|
+
*/
|
|
25
|
+
export declare function runSpecializedTrace<A>(operation: string, run: () => Promise<A>): Promise<A>;
|
|
3
26
|
//# sourceMappingURL=operation-tracing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-tracing.d.ts","sourceRoot":"","sources":["../src/operation-tracing.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"operation-tracing.d.ts","sourceRoot":"","sources":["../src/operation-tracing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAsBhC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACjD,SAAS,EAAE,YAAY,MAAM,EAAE,GAAG,QAAQ,MAAM,EAAE,EAClD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAWxB;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAmBjG"}
|
|
@@ -1,5 +1,75 @@
|
|
|
1
|
+
import { observeExecution } from "@relkit/contracts/operation";
|
|
2
|
+
import { Effect } from "effect";
|
|
1
3
|
import { frameworkTrace } from "@relkit/invocation";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
+
import { redactSpecializedTrace } from "./trace-redaction.js";
|
|
5
|
+
const operations = new Set([
|
|
6
|
+
"database.acquire",
|
|
7
|
+
"database.close",
|
|
8
|
+
"database.findOne",
|
|
9
|
+
"database.findMany",
|
|
10
|
+
"database.insert",
|
|
11
|
+
"database.update",
|
|
12
|
+
"database.upsert",
|
|
13
|
+
"database.delete",
|
|
14
|
+
"database.transaction",
|
|
15
|
+
"database.extension",
|
|
16
|
+
"auth.acquire",
|
|
17
|
+
"auth.handler",
|
|
18
|
+
"auth.session",
|
|
19
|
+
"auth.api",
|
|
20
|
+
"auth.factory",
|
|
21
|
+
]);
|
|
22
|
+
/**
|
|
23
|
+
* Observes specialized work once through the configured caller sinks.
|
|
24
|
+
* @typeParam A - Successful value.
|
|
25
|
+
* @typeParam E - Typed failure retained together with defects/interruption.
|
|
26
|
+
* @typeParam R - Required caller services.
|
|
27
|
+
* @param operation - Bounded label; custom method names are normalized.
|
|
28
|
+
* @param effect - Lazy authoritative work; payloads are never recorded.
|
|
29
|
+
* @returns An observed Effect retaining values, causes and requirements.
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { Effect } from "effect";
|
|
33
|
+
* import { observeSpecializedOperation } from "@relkit/drizzle/internal";
|
|
34
|
+
* await Effect.runPromise(observeSpecializedOperation("auth.session", Effect.succeed(null)));
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function observeSpecializedOperation(operation, effect) {
|
|
38
|
+
const label = operations.has(operation)
|
|
39
|
+
? operation
|
|
40
|
+
: operation.startsWith("database.")
|
|
41
|
+
? "database.extension"
|
|
42
|
+
: "auth.api";
|
|
43
|
+
return redactSpecializedTrace(observeExecution("runtime", label, effect, () => ({ operations: 1 })).pipe(Effect.withSpan(`relkit.${label}`)));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Bridges invocation parenting without capturing native rows or auth sessions.
|
|
47
|
+
* @typeParam A - Private operation result.
|
|
48
|
+
* @param operation - Bounded operation label.
|
|
49
|
+
* @param run - Existing runtime boundary.
|
|
50
|
+
* @returns Original result; the invocation span sees only void.
|
|
51
|
+
*/
|
|
52
|
+
export async function runSpecializedTrace(operation, run) {
|
|
53
|
+
let result;
|
|
54
|
+
let failure;
|
|
55
|
+
try {
|
|
56
|
+
await frameworkTrace.span(`relkit.${operation}`, {}, async () => {
|
|
57
|
+
try {
|
|
58
|
+
result = { value: await run() };
|
|
59
|
+
}
|
|
60
|
+
catch (cause) {
|
|
61
|
+
failure = { cause };
|
|
62
|
+
// Native SDK messages may include SQL, tokens or row values. Preserve
|
|
63
|
+
// the native rejection privately while tracing only bounded failure text.
|
|
64
|
+
throw new Error("Specialized operation failed");
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (cause) {
|
|
69
|
+
throw failure === undefined ? cause : failure.cause;
|
|
70
|
+
}
|
|
71
|
+
if (result === undefined)
|
|
72
|
+
throw new TypeError("Specialized operation did not complete");
|
|
73
|
+
return result.value;
|
|
4
74
|
}
|
|
5
75
|
//# sourceMappingURL=operation-tracing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-tracing.js","sourceRoot":"","sources":["../src/operation-tracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"operation-tracing.js","sourceRoot":"","sources":["../src/operation-tracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,kBAAkB;IAClB,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,sBAAsB;IACtB,oBAAoB;IACpB,cAAc;IACd,cAAc;IACd,cAAc;IACd,UAAU;IACV,cAAc;CACf,CAAC,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,2BAA2B,CACzC,SAAkD,EAClD,MAA8B;IAE9B,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC;QACrC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC;YACjC,CAAC,CAAC,oBAAoB;YACtB,CAAC,CAAC,UAAU,CAAC;IACjB,OAAO,sBAAsB,CAC3B,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CACxE,MAAM,CAAC,QAAQ,CAAC,UAAU,KAAK,EAAE,CAAC,CACnC,CACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAI,SAAiB,EAAE,GAAqB;IACnF,IAAI,MAAyC,CAAC;IAC9C,IAAI,OAAgD,CAAC;IACrD,IAAI,CAAC;QACH,MAAM,cAAc,CAAC,IAAI,CAAC,UAAU,SAAS,EAAE,EAAE,EAAE,EAAE,KAAK,IAAI,EAAE;YAC9D,IAAI,CAAC;gBACH,MAAM,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,EAAE,EAAE,CAAC;YAClC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC;gBACpB,sEAAsE;gBACtE,0EAA0E;gBAC1E,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAClD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACtD,CAAC;IACD,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC"}
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
1
2
|
import type { ModelBinding } from "./runtime-types.js";
|
|
2
|
-
|
|
3
|
+
import { type DrizzleFailure } from "./failure.js";
|
|
4
|
+
/**
|
|
5
|
+
* Runs one lazy CRUD workflow at its compatibility edge.
|
|
6
|
+
* @param binding - Owned client/model/transaction binding.
|
|
7
|
+
* @param name - Reserved CRUD operation.
|
|
8
|
+
* @param args - Public arguments validated inside the workflow.
|
|
9
|
+
* @returns Native Promise result retaining expected native rejection identity.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runOperation(binding: ModelBinding, name: string, args: unknown): Promise<unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Composes overrides and MySQL write/recovery transaction ownership.
|
|
14
|
+
* @param binding - Model binding.
|
|
15
|
+
* @param name - Reserved operation.
|
|
16
|
+
* @param args - Original override arguments.
|
|
17
|
+
* @returns Lazy CRUD work with typed failures and no automatic write retries.
|
|
18
|
+
* @example Compose a page with an existing owner and table binding
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { Effect } from "effect";
|
|
21
|
+
* import type { ManagedRuntime } from "effect";
|
|
22
|
+
* import { DrizzleFailure, DrizzleOwner, operationEffect, runDrizzlePromise } from "@relkit/drizzle/internal";
|
|
23
|
+
* function page(owner: ManagedRuntime.ManagedRuntime<DrizzleOwner, DrizzleFailure>, binding: Parameters<typeof operationEffect>[0]) {
|
|
24
|
+
* return runDrizzlePromise(owner, Effect.gen(function* () {
|
|
25
|
+
* const service = yield* DrizzleOwner;
|
|
26
|
+
* return yield* service.work(operationEffect(binding, "findMany", { limit: 10 }));
|
|
27
|
+
* }));
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function operationEffect(binding: ModelBinding, name: string, args: unknown): Effect.Effect<unknown, DrizzleFailure>;
|
|
3
32
|
//# sourceMappingURL=operations.d.ts.map
|
package/dist/operations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAQ/D;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEjG;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAIxC"}
|
package/dist/operations.js
CHANGED
|
@@ -1,175 +1,112 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { nativeCall } from "./failure.js";
|
|
3
|
+
import { observeSpecializedOperation } from "./operation-tracing.js";
|
|
4
|
+
import { transactionEffect, withSqlitePermit, withTransactionWork } from "./transaction.js";
|
|
5
|
+
import { redactSpecializedTrace } from "./trace-redaction.js";
|
|
6
|
+
import { checked, findOne, findMany } from "./queries.js";
|
|
7
|
+
import { insert, update, remove } from "./mutations.js";
|
|
8
|
+
import { isRecord, requiredRow, selector } from "./operations.utils.js";
|
|
9
|
+
/**
|
|
10
|
+
* Runs one lazy CRUD workflow at its compatibility edge.
|
|
11
|
+
* @param binding - Owned client/model/transaction binding.
|
|
12
|
+
* @param name - Reserved CRUD operation.
|
|
13
|
+
* @param args - Public arguments validated inside the workflow.
|
|
14
|
+
* @returns Native Promise result retaining expected native rejection identity.
|
|
15
|
+
*/
|
|
16
|
+
export function runOperation(binding, name, args) {
|
|
17
|
+
return binding.run(operationEffect(binding, name, args), name);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Composes overrides and MySQL write/recovery transaction ownership.
|
|
21
|
+
* @param binding - Model binding.
|
|
22
|
+
* @param name - Reserved operation.
|
|
23
|
+
* @param args - Original override arguments.
|
|
24
|
+
* @returns Lazy CRUD work with typed failures and no automatic write retries.
|
|
25
|
+
* @example Compose a page with an existing owner and table binding
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { Effect } from "effect";
|
|
28
|
+
* import type { ManagedRuntime } from "effect";
|
|
29
|
+
* import { DrizzleFailure, DrizzleOwner, operationEffect, runDrizzlePromise } from "@relkit/drizzle/internal";
|
|
30
|
+
* function page(owner: ManagedRuntime.ManagedRuntime<DrizzleOwner, DrizzleFailure>, binding: Parameters<typeof operationEffect>[0]) {
|
|
31
|
+
* return runDrizzlePromise(owner, Effect.gen(function* () {
|
|
32
|
+
* const service = yield* DrizzleOwner;
|
|
33
|
+
* return yield* service.work(operationEffect(binding, "findMany", { limit: 10 }));
|
|
34
|
+
* }));
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function operationEffect(binding, name, args) {
|
|
39
|
+
return redactSpecializedTrace(observeSpecializedOperation(`database.${name}`, operationWorkflow(binding, name, args)));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Composes the unobserved core for nested dialect recovery and override bases.
|
|
43
|
+
* @param binding - Transaction-aware native dependencies.
|
|
44
|
+
* @param name - Reserved CRUD operation.
|
|
45
|
+
* @param args - Original public arguments.
|
|
46
|
+
* @returns Lazy work counted by the independently callable outer operation.
|
|
47
|
+
*/
|
|
48
|
+
const operationWorkflow = Effect.fn("Drizzle.operation")((binding, name, args) => {
|
|
5
49
|
if (binding.dialect === "mysql" &&
|
|
6
50
|
!binding.inTransaction &&
|
|
7
51
|
["insert", "update", "upsert", "delete"].includes(name)) {
|
|
8
|
-
return
|
|
52
|
+
return transactionEffect(binding.drizzle, "mysql", (drizzle, lease) => {
|
|
53
|
+
const transactionBinding = {
|
|
54
|
+
...binding,
|
|
55
|
+
drizzle,
|
|
56
|
+
inTransaction: true,
|
|
57
|
+
run: (effect, operation) => binding.run(withTransactionWork(lease, effect), operation),
|
|
58
|
+
};
|
|
59
|
+
return transactionBinding.run(operationWorkflow(transactionBinding, name, args), name);
|
|
60
|
+
});
|
|
9
61
|
}
|
|
10
|
-
const base = (next) => baseOperation(binding, name, next);
|
|
11
62
|
const override = binding.override[name];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
63
|
+
const base = (next) => {
|
|
64
|
+
const core = baseOperation(binding, name, next);
|
|
65
|
+
return binding.run(binding.dialect === "sqlite" && !binding.inTransaction
|
|
66
|
+
? withSqlitePermit(binding.drizzle, core)
|
|
67
|
+
: core, name);
|
|
68
|
+
};
|
|
69
|
+
const effect = typeof override === "function"
|
|
70
|
+
? nativeCall(name, () => override({ args, base }))
|
|
71
|
+
: baseOperation(binding, name, args);
|
|
72
|
+
return binding.dialect === "sqlite" && !binding.inTransaction
|
|
73
|
+
? withSqlitePermit(binding.drizzle, effect)
|
|
74
|
+
: effect;
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Dispatches validated arguments to named domain workflows.
|
|
78
|
+
* @param binding - Table/client metadata.
|
|
79
|
+
* @param name - Reserved operation.
|
|
80
|
+
* @param args - Unknown public arguments.
|
|
81
|
+
* @returns Lazy operation result or typed validation failure.
|
|
82
|
+
*/
|
|
83
|
+
function baseOperation(binding, name, args) {
|
|
84
|
+
return Effect.gen(function* () {
|
|
85
|
+
const value = isRecord(args) ? args : {};
|
|
86
|
+
const where = () => selector(binding, value.where);
|
|
87
|
+
switch (name) {
|
|
88
|
+
case "findOne":
|
|
89
|
+
return yield* findOne(binding, yield* checked(where));
|
|
90
|
+
case "findMany":
|
|
91
|
+
return yield* findMany(binding, value);
|
|
92
|
+
case "insert":
|
|
93
|
+
return yield* insert(binding, value.data);
|
|
94
|
+
case "update":
|
|
95
|
+
return yield* update(binding, yield* checked(where), value.data);
|
|
96
|
+
case "delete":
|
|
97
|
+
return yield* remove(binding, yield* checked(where));
|
|
98
|
+
case "upsert": {
|
|
99
|
+
const selected = yield* checked(where);
|
|
100
|
+
const existing = yield* findOne(binding, selected);
|
|
101
|
+
return existing === null
|
|
102
|
+
? yield* insert(binding, value.create)
|
|
103
|
+
: yield* update(binding, selected, value.update).pipe(Effect.flatMap((row) => checked(() => requiredRow(row))));
|
|
104
|
+
}
|
|
105
|
+
default:
|
|
106
|
+
return yield* checked(() => {
|
|
107
|
+
throw new TypeError(`Unknown model operation "${name}"`);
|
|
108
|
+
});
|
|
50
109
|
}
|
|
51
|
-
query = call(query, "orderBy", order.direction === "asc" ? asc(column) : desc(column));
|
|
52
|
-
}
|
|
53
|
-
query = call(call(query, "limit", limit), "offset", offset);
|
|
54
|
-
return rows(query);
|
|
55
|
-
}
|
|
56
|
-
async function insert(binding, data) {
|
|
57
|
-
const values = record(data);
|
|
58
|
-
const query = call(call(binding.drizzle, "insert", binding.table), "values", values);
|
|
59
|
-
if (hasMethod(query, "returning"))
|
|
60
|
-
return requiredRow((await rows(call(query, "returning")))[0]);
|
|
61
|
-
const where = recoverable(binding, values);
|
|
62
|
-
if (where === undefined)
|
|
63
|
-
throw new TypeError("MySQL insert requires a recoverable unique key override");
|
|
64
|
-
await query;
|
|
65
|
-
return requiredRow(await findOne(binding, where));
|
|
66
|
-
}
|
|
67
|
-
async function update(binding, where, data) {
|
|
68
|
-
const before = binding.dialect === "mysql" ? await findOne(binding, where) : undefined;
|
|
69
|
-
if (binding.dialect === "mysql" && before === null)
|
|
70
|
-
return null;
|
|
71
|
-
let query = call(call(binding.drizzle, "update", binding.table), "set", record(data));
|
|
72
|
-
query = call(query, "where", clause(binding, where));
|
|
73
|
-
if (hasMethod(query, "returning"))
|
|
74
|
-
return (await rows(call(query, "returning")))[0] ?? null;
|
|
75
|
-
await query;
|
|
76
|
-
const recover = recoverable(binding, { ...record(before), ...record(data) });
|
|
77
|
-
if (recover === undefined)
|
|
78
|
-
throw new TypeError("MySQL update requires a recoverable unique key override");
|
|
79
|
-
return findOne(binding, recover);
|
|
80
|
-
}
|
|
81
|
-
async function remove(binding, where) {
|
|
82
|
-
const before = await findOne(binding, where);
|
|
83
|
-
if (before === null)
|
|
84
|
-
return null;
|
|
85
|
-
let query = call(binding.drizzle, "delete", binding.table);
|
|
86
|
-
query = call(query, "where", clause(binding, where));
|
|
87
|
-
if (hasMethod(query, "returning"))
|
|
88
|
-
return (await rows(call(query, "returning")))[0] ?? null;
|
|
89
|
-
await query;
|
|
90
|
-
return before;
|
|
91
|
-
}
|
|
92
|
-
async function upsert(binding, where, create, updateValue) {
|
|
93
|
-
const existing = await findOne(binding, where);
|
|
94
|
-
return existing === null
|
|
95
|
-
? insert(binding, create)
|
|
96
|
-
: requiredRow(await update(binding, where, updateValue));
|
|
97
|
-
}
|
|
98
|
-
function selector(binding, value) {
|
|
99
|
-
const where = record(value);
|
|
100
|
-
for (const [key, entry] of Object.entries(where)) {
|
|
101
|
-
columnFor(binding, key);
|
|
102
|
-
if (entry === null || entry === undefined)
|
|
103
|
-
throw new TypeError("Selector values cannot be null or undefined");
|
|
104
|
-
}
|
|
105
|
-
if (!binding.metadata.selectors.some((keys) => keys.every((key) => Object.hasOwn(where, key)))) {
|
|
106
|
-
throw new TypeError("Selector must contain a complete primary or unique constraint");
|
|
107
|
-
}
|
|
108
|
-
return where;
|
|
109
|
-
}
|
|
110
|
-
function recoverable(binding, value) {
|
|
111
|
-
const keys = binding.metadata.selectors.find((candidate) => candidate.every((key) => value[key] !== null && value[key] !== undefined));
|
|
112
|
-
return keys === undefined ? undefined : Object.fromEntries(keys.map((key) => [key, value[key]]));
|
|
113
|
-
}
|
|
114
|
-
function clause(binding, where) {
|
|
115
|
-
const filters = Object.entries(where).map(([key, value]) => {
|
|
116
|
-
const column = columnFor(binding, key);
|
|
117
|
-
if (value === undefined)
|
|
118
|
-
throw new TypeError("Filter values cannot be undefined");
|
|
119
|
-
return value === null ? isNull(column) : eq(column, value);
|
|
120
110
|
});
|
|
121
|
-
return filters.length === 0 ? undefined : and(...filters);
|
|
122
|
-
}
|
|
123
|
-
function columnFor(binding, key) {
|
|
124
|
-
const column = binding.metadata.columns[key];
|
|
125
|
-
if (column === undefined)
|
|
126
|
-
throw new TypeError(`Unknown table column "${key}"`);
|
|
127
|
-
return column;
|
|
128
|
-
}
|
|
129
|
-
async function rows(query) {
|
|
130
|
-
const value = await query;
|
|
131
|
-
if (!Array.isArray(value))
|
|
132
|
-
throw new TypeError("Drizzle query did not return rows");
|
|
133
|
-
return value;
|
|
134
|
-
}
|
|
135
|
-
function call(target, name, ...args) {
|
|
136
|
-
if (!isRecord(target) && typeof target !== "function")
|
|
137
|
-
throw new TypeError(`Drizzle ${name} is unavailable`);
|
|
138
|
-
const method = target[name];
|
|
139
|
-
if (typeof method !== "function")
|
|
140
|
-
throw new TypeError(`Drizzle ${name} is unavailable`);
|
|
141
|
-
return method.apply(target, args);
|
|
142
|
-
}
|
|
143
|
-
function hasMethod(target, name) {
|
|
144
|
-
return ((isRecord(target) || typeof target === "function") &&
|
|
145
|
-
typeof target[name] === "function");
|
|
146
|
-
}
|
|
147
|
-
function transaction(drizzle, run) {
|
|
148
|
-
return call(drizzle, "transaction", run);
|
|
149
|
-
}
|
|
150
|
-
function record(value) {
|
|
151
|
-
if (!isRecord(value))
|
|
152
|
-
throw new TypeError("Data-model arguments must be objects");
|
|
153
|
-
return value;
|
|
154
|
-
}
|
|
155
|
-
function text(value, name) {
|
|
156
|
-
if (typeof value !== "string" || value === "")
|
|
157
|
-
throw new TypeError(`${name} is invalid`);
|
|
158
|
-
return value;
|
|
159
|
-
}
|
|
160
|
-
function integer(value, name, fallback, maximum = Number.MAX_SAFE_INTEGER) {
|
|
161
|
-
if (value === undefined)
|
|
162
|
-
return fallback;
|
|
163
|
-
if (!Number.isSafeInteger(value) || Number(value) < 0 || Number(value) > maximum)
|
|
164
|
-
throw new TypeError(`${name} is invalid`);
|
|
165
|
-
return Number(value);
|
|
166
|
-
}
|
|
167
|
-
function requiredRow(value) {
|
|
168
|
-
if (value === null || value === undefined)
|
|
169
|
-
throw new TypeError("Mutation did not return a row");
|
|
170
|
-
return value;
|
|
171
|
-
}
|
|
172
|
-
function isRecord(value) {
|
|
173
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
174
111
|
}
|
|
175
112
|
//# sourceMappingURL=operations.js.map
|
package/dist/operations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAuB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE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EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CACzD,CAAC;YACR,CAAC;YACD;gBACE,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;oBACzB,MAAM,IAAI,SAAS,CAAC,4BAA4B,IAAI,GAAG,CAAC,CAAC;gBAC3D,CAAC,CAAC,CAAC;QACP,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { InferInsertModel, InferSelectModel, Table } from "drizzle-orm";
|
|
2
|
+
/**
|
|
3
|
+
* Persisted row inferred from a table.
|
|
4
|
+
* @typeParam T - Authored table.
|
|
5
|
+
*/
|
|
6
|
+
export type Row<T extends Table> = InferSelectModel<T>;
|
|
7
|
+
/**
|
|
8
|
+
* Insert values retaining nullable, default and generated-column inference.
|
|
9
|
+
* @typeParam T - Authored table.
|
|
10
|
+
*/
|
|
11
|
+
export type Insert<T extends Table> = InferInsertModel<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Partial insert-compatible update values.
|
|
14
|
+
* @typeParam T - Authored table.
|
|
15
|
+
*/
|
|
16
|
+
export type Update<T extends Table> = Partial<Insert<T>>;
|
|
17
|
+
/**
|
|
18
|
+
* Column equality filter; unique operations require a complete selector.
|
|
19
|
+
* @typeParam T - Authored table.
|
|
20
|
+
*/
|
|
21
|
+
export type Where<T extends Table> = Partial<Row<T>>;
|
|
22
|
+
/**
|
|
23
|
+
* Complete unique selector for one row.
|
|
24
|
+
* @typeParam T - Authored table.
|
|
25
|
+
*/
|
|
26
|
+
export interface FindOneArgs<T extends Table> {
|
|
27
|
+
readonly where: Where<T>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Bounded ordered page filters; default limit is 100.
|
|
31
|
+
* @typeParam T - Authored table.
|
|
32
|
+
*/
|
|
33
|
+
export interface FindManyArgs<T extends Table> {
|
|
34
|
+
readonly where?: Where<T>;
|
|
35
|
+
readonly orderBy?: {
|
|
36
|
+
readonly field: Extract<keyof Row<T>, string>;
|
|
37
|
+
readonly direction: "asc" | "desc";
|
|
38
|
+
};
|
|
39
|
+
readonly limit?: number;
|
|
40
|
+
readonly offset?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Single-row insertion values.
|
|
44
|
+
* @typeParam T - Authored table.
|
|
45
|
+
*/
|
|
46
|
+
export interface InsertArgs<T extends Table> {
|
|
47
|
+
readonly data: Insert<T>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Complete selector and partial update values.
|
|
51
|
+
* @typeParam T - Authored table.
|
|
52
|
+
*/
|
|
53
|
+
export interface UpdateArgs<T extends Table> {
|
|
54
|
+
readonly where: Where<T>;
|
|
55
|
+
readonly data: Update<T>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Selector and separate create/update branches.
|
|
59
|
+
* @typeParam T - Authored table.
|
|
60
|
+
*/
|
|
61
|
+
export interface UpsertArgs<T extends Table> {
|
|
62
|
+
readonly where: Where<T>;
|
|
63
|
+
readonly create: Insert<T>;
|
|
64
|
+
readonly update: Update<T>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Complete unique selector for deletion.
|
|
68
|
+
* @typeParam T - Authored table.
|
|
69
|
+
*/
|
|
70
|
+
export interface DeleteArgs<T extends Table> {
|
|
71
|
+
readonly where: Where<T>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Stable public Promise CRUD contract over one table.
|
|
75
|
+
* @typeParam T - Authored table.
|
|
76
|
+
*/
|
|
77
|
+
export interface BaseOperations<T extends Table> {
|
|
78
|
+
/**
|
|
79
|
+
* Selects one row by a complete unique key.
|
|
80
|
+
* @param args - Unique selector.
|
|
81
|
+
* @returns Matching row or null, rejecting invalid selectors/native failures.
|
|
82
|
+
*/
|
|
83
|
+
findOne(args: FindOneArgs<T>): Promise<Row<T> | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Selects a bounded ordered page.
|
|
86
|
+
* @param args - Optional filters, ordering and pagination.
|
|
87
|
+
* @returns Validated rows in driver order.
|
|
88
|
+
*/
|
|
89
|
+
findMany(args?: FindManyArgs<T>): Promise<Row<T>[]>;
|
|
90
|
+
/**
|
|
91
|
+
* Inserts one row without automatic retries.
|
|
92
|
+
* @param args - Insert values.
|
|
93
|
+
* @returns Validated inserted row.
|
|
94
|
+
*/
|
|
95
|
+
insert(args: InsertArgs<T>): Promise<Row<T>>;
|
|
96
|
+
/**
|
|
97
|
+
* Updates one selected row without automatic retries.
|
|
98
|
+
* @param args - Unique selector and partial update values.
|
|
99
|
+
* @returns Updated row or null when absent.
|
|
100
|
+
*/
|
|
101
|
+
update(args: UpdateArgs<T>): Promise<Row<T> | null>;
|
|
102
|
+
/**
|
|
103
|
+
* Selects then inserts or updates using portable dialect semantics.
|
|
104
|
+
* @param args - Unique selector and create/update branches.
|
|
105
|
+
* @returns Resulting row; this portable read/write sequence is not an atomic SQL upsert.
|
|
106
|
+
*/
|
|
107
|
+
upsert(args: UpsertArgs<T>): Promise<Row<T>>;
|
|
108
|
+
/**
|
|
109
|
+
* Removes one selected row without automatic retries.
|
|
110
|
+
* @param args - Complete unique selector.
|
|
111
|
+
* @returns Deleted row or null when absent.
|
|
112
|
+
*/
|
|
113
|
+
delete(args: DeleteArgs<T>): Promise<Row<T> | null>;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=operations.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.types.d.ts","sourceRoot":"","sources":["../src/operations.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,KAAK,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC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