@relkit/drizzle 0.5.6 → 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 +3 -7
- package/dist/activation.d.ts.map +1 -1
- package/dist/activation.js +51 -20
- package/dist/activation.js.map +1 -1
- package/dist/activation.types.d.ts +18 -0
- package/dist/activation.types.d.ts.map +1 -1
- 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 +4 -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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type Column, type SQL } from "drizzle-orm";
|
|
2
|
+
import type { ModelBinding } from "./runtime-types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Requires a complete non-null unique selector.
|
|
5
|
+
* @param binding - Table metadata.
|
|
6
|
+
* @param value - Unknown selector.
|
|
7
|
+
* @returns Validated selector record.
|
|
8
|
+
* @throws TypeError for invalid keys or incomplete uniqueness.
|
|
9
|
+
*/
|
|
10
|
+
export declare function selector(binding: ModelBinding, value: unknown): Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Finds a complete key for MySQL row recovery after writes.
|
|
13
|
+
* @param binding - Table constraints.
|
|
14
|
+
* @param value - Known row/write fields.
|
|
15
|
+
* @returns One complete selector or undefined.
|
|
16
|
+
*/
|
|
17
|
+
export declare function recoverable(binding: ModelBinding, value: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Builds equality predicates, treating null as SQL IS NULL.
|
|
20
|
+
* @param binding - Declared columns.
|
|
21
|
+
* @param where - Filter record.
|
|
22
|
+
* @returns Conjoined predicate, or undefined for an empty filter.
|
|
23
|
+
* @throws TypeError for undefined values or unknown columns.
|
|
24
|
+
*/
|
|
25
|
+
export declare function clause(binding: ModelBinding, where: Record<string, unknown>): SQL | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves one declared column.
|
|
28
|
+
* @param binding - Declared columns.
|
|
29
|
+
* @param key - TypeScript column name.
|
|
30
|
+
* @returns Drizzle column.
|
|
31
|
+
* @throws TypeError for unknown fields.
|
|
32
|
+
*/
|
|
33
|
+
export declare function columnFor(binding: ModelBinding, key: string): Column;
|
|
34
|
+
/**
|
|
35
|
+
* Calls a checked native method with its original receiver.
|
|
36
|
+
* @param target - Database or query builder.
|
|
37
|
+
* @param name - Native method name.
|
|
38
|
+
* @param args - Native arguments.
|
|
39
|
+
* @returns Native method result, preserving thenables.
|
|
40
|
+
* @throws TypeError when the method is unavailable.
|
|
41
|
+
*/
|
|
42
|
+
export declare function call(target: unknown, name: string, ...args: unknown[]): unknown;
|
|
43
|
+
/**
|
|
44
|
+
* Inspects a native capability without invoking it.
|
|
45
|
+
* @param target - Native builder.
|
|
46
|
+
* @param name - Method name.
|
|
47
|
+
* @returns Whether a callable method exists.
|
|
48
|
+
*/
|
|
49
|
+
export declare function hasMethod(target: unknown, name: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Requires a plain argument record.
|
|
52
|
+
* @param value - Unknown arguments.
|
|
53
|
+
* @returns Record retaining original keys.
|
|
54
|
+
* @throws TypeError for null, arrays and scalar arguments.
|
|
55
|
+
*/
|
|
56
|
+
export declare function record(value: unknown): Record<string, unknown>;
|
|
57
|
+
/**
|
|
58
|
+
* Checks bounded pagination without coercing strings.
|
|
59
|
+
* @param value - Unknown limit/offset.
|
|
60
|
+
* @param name - Diagnostic field.
|
|
61
|
+
* @param fallback - Default when absent.
|
|
62
|
+
* @param maximum - Inclusive maximum.
|
|
63
|
+
* @returns Safe non-negative integer.
|
|
64
|
+
* @throws TypeError for invalid pagination.
|
|
65
|
+
*/
|
|
66
|
+
export declare function integer(value: unknown, name: string, fallback: number, maximum?: number): number;
|
|
67
|
+
/**
|
|
68
|
+
* Requires a successful mutation row.
|
|
69
|
+
* @param value - Native row or missing result.
|
|
70
|
+
* @returns Existing row.
|
|
71
|
+
* @throws TypeError when no row was returned.
|
|
72
|
+
*/
|
|
73
|
+
export declare function requiredRow(value: unknown): unknown;
|
|
74
|
+
/**
|
|
75
|
+
* Checks argument records without invoking getters.
|
|
76
|
+
* @param value - Unknown value.
|
|
77
|
+
* @returns Whether it is a non-array object.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
80
|
+
//# sourceMappingURL=operations.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.utils.d.ts","sourceRoot":"","sources":["../src/operations.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,MAAM,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWvF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAKrC;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,GAAG,SAAS,CAO7F;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIpE;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAM/E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKhE;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAG9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,SAA0B,GAChC,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAGnD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { and, eq, isNull } from "drizzle-orm";
|
|
2
|
+
/**
|
|
3
|
+
* Requires a complete non-null unique selector.
|
|
4
|
+
* @param binding - Table metadata.
|
|
5
|
+
* @param value - Unknown selector.
|
|
6
|
+
* @returns Validated selector record.
|
|
7
|
+
* @throws TypeError for invalid keys or incomplete uniqueness.
|
|
8
|
+
*/
|
|
9
|
+
export function selector(binding, value) {
|
|
10
|
+
const where = record(value);
|
|
11
|
+
for (const [key, entry] of Object.entries(where)) {
|
|
12
|
+
columnFor(binding, key);
|
|
13
|
+
if (entry === null || entry === undefined)
|
|
14
|
+
throw new TypeError("Selector values cannot be null or undefined");
|
|
15
|
+
}
|
|
16
|
+
if (!binding.metadata.selectors.some((keys) => keys.every((key) => Object.hasOwn(where, key)))) {
|
|
17
|
+
throw new TypeError("Selector must contain a complete primary or unique constraint");
|
|
18
|
+
}
|
|
19
|
+
return where;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Finds a complete key for MySQL row recovery after writes.
|
|
23
|
+
* @param binding - Table constraints.
|
|
24
|
+
* @param value - Known row/write fields.
|
|
25
|
+
* @returns One complete selector or undefined.
|
|
26
|
+
*/
|
|
27
|
+
export function recoverable(binding, value) {
|
|
28
|
+
const keys = binding.metadata.selectors.find((candidate) => candidate.every((key) => value[key] !== null && value[key] !== undefined));
|
|
29
|
+
return keys === undefined ? undefined : Object.fromEntries(keys.map((key) => [key, value[key]]));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Builds equality predicates, treating null as SQL IS NULL.
|
|
33
|
+
* @param binding - Declared columns.
|
|
34
|
+
* @param where - Filter record.
|
|
35
|
+
* @returns Conjoined predicate, or undefined for an empty filter.
|
|
36
|
+
* @throws TypeError for undefined values or unknown columns.
|
|
37
|
+
*/
|
|
38
|
+
export function clause(binding, where) {
|
|
39
|
+
const filters = Object.entries(where).map(([key, value]) => {
|
|
40
|
+
const column = columnFor(binding, key);
|
|
41
|
+
if (value === undefined)
|
|
42
|
+
throw new TypeError("Filter values cannot be undefined");
|
|
43
|
+
return value === null ? isNull(column) : eq(column, value);
|
|
44
|
+
});
|
|
45
|
+
return filters.length === 0 ? undefined : and(...filters);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resolves one declared column.
|
|
49
|
+
* @param binding - Declared columns.
|
|
50
|
+
* @param key - TypeScript column name.
|
|
51
|
+
* @returns Drizzle column.
|
|
52
|
+
* @throws TypeError for unknown fields.
|
|
53
|
+
*/
|
|
54
|
+
export function columnFor(binding, key) {
|
|
55
|
+
const column = binding.metadata.columns[key];
|
|
56
|
+
if (column === undefined)
|
|
57
|
+
throw new TypeError(`Unknown table column "${key}"`);
|
|
58
|
+
return column;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Calls a checked native method with its original receiver.
|
|
62
|
+
* @param target - Database or query builder.
|
|
63
|
+
* @param name - Native method name.
|
|
64
|
+
* @param args - Native arguments.
|
|
65
|
+
* @returns Native method result, preserving thenables.
|
|
66
|
+
* @throws TypeError when the method is unavailable.
|
|
67
|
+
*/
|
|
68
|
+
export function call(target, name, ...args) {
|
|
69
|
+
if (!isRecord(target) && typeof target !== "function")
|
|
70
|
+
throw new TypeError(`Drizzle ${name} is unavailable`);
|
|
71
|
+
const method = target[name];
|
|
72
|
+
if (typeof method !== "function")
|
|
73
|
+
throw new TypeError(`Drizzle ${name} is unavailable`);
|
|
74
|
+
return method.apply(target, args);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Inspects a native capability without invoking it.
|
|
78
|
+
* @param target - Native builder.
|
|
79
|
+
* @param name - Method name.
|
|
80
|
+
* @returns Whether a callable method exists.
|
|
81
|
+
*/
|
|
82
|
+
export function hasMethod(target, name) {
|
|
83
|
+
return ((isRecord(target) || typeof target === "function") &&
|
|
84
|
+
typeof target[name] === "function");
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Requires a plain argument record.
|
|
88
|
+
* @param value - Unknown arguments.
|
|
89
|
+
* @returns Record retaining original keys.
|
|
90
|
+
* @throws TypeError for null, arrays and scalar arguments.
|
|
91
|
+
*/
|
|
92
|
+
export function record(value) {
|
|
93
|
+
if (!isRecord(value))
|
|
94
|
+
throw new TypeError("Data-model arguments must be objects");
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Checks bounded pagination without coercing strings.
|
|
99
|
+
* @param value - Unknown limit/offset.
|
|
100
|
+
* @param name - Diagnostic field.
|
|
101
|
+
* @param fallback - Default when absent.
|
|
102
|
+
* @param maximum - Inclusive maximum.
|
|
103
|
+
* @returns Safe non-negative integer.
|
|
104
|
+
* @throws TypeError for invalid pagination.
|
|
105
|
+
*/
|
|
106
|
+
export function integer(value, name, fallback, maximum = Number.MAX_SAFE_INTEGER) {
|
|
107
|
+
if (value === undefined)
|
|
108
|
+
return fallback;
|
|
109
|
+
if (!Number.isSafeInteger(value) || Number(value) < 0 || Number(value) > maximum)
|
|
110
|
+
throw new TypeError(`${name} is invalid`);
|
|
111
|
+
return Number(value);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Requires a successful mutation row.
|
|
115
|
+
* @param value - Native row or missing result.
|
|
116
|
+
* @returns Existing row.
|
|
117
|
+
* @throws TypeError when no row was returned.
|
|
118
|
+
*/
|
|
119
|
+
export function requiredRow(value) {
|
|
120
|
+
if (value === null || value === undefined)
|
|
121
|
+
throw new TypeError("Mutation did not return a row");
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Checks argument records without invoking getters.
|
|
126
|
+
* @param value - Unknown value.
|
|
127
|
+
* @returns Whether it is a non-array object.
|
|
128
|
+
*/
|
|
129
|
+
export function isRecord(value) {
|
|
130
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=operations.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.utils.js","sourceRoot":"","sources":["../src/operations.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAyB,MAAM,aAAa,CAAC;AAGrE;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAqB,EAAE,KAAc;IAC5D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACxB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YACvC,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/F,MAAM,IAAI,SAAS,CAAC,+DAA+D,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,OAAqB,EACrB,KAA8B;IAE9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AC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO;QAC9E,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,aAAa,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,SAAS,CAAC,+BAA+B,CAAC,CAAC;IAChG,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/owner.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
import { DrizzleFailure } from "./failure.js";
|
|
3
|
+
import type { DrizzleServiceRuntime } from "./runtime-types.js";
|
|
4
|
+
import type { DrizzleOwnerInterface, OwnerBinding } from "./owner.types.js";
|
|
5
|
+
declare const DrizzleOwner_base: Context.ServiceClass<DrizzleOwner, "@relkit/drizzle/Owner", DrizzleOwnerInterface>;
|
|
6
|
+
/**
|
|
7
|
+
* Client lifetime/admission contract, substitutable through live/test Layers.
|
|
8
|
+
* @see {@link drizzleOwnerLayer} for checked acquisition/provisioning/cleanup composition.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DrizzleOwner extends DrizzleOwner_base {
|
|
11
|
+
}
|
|
12
|
+
/** Weak association preserving the exact frozen public activation shape. */
|
|
13
|
+
export declare const owners: WeakMap<object, OwnerBinding>;
|
|
14
|
+
/**
|
|
15
|
+
* Acquires one client into a Layer scope.
|
|
16
|
+
* @param declaration - Native acquisition/disposal dependencies.
|
|
17
|
+
* @param env - First activation environment.
|
|
18
|
+
* @returns A live owner Layer; its scope releases the client exactly once.
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { ManagedRuntime } from "effect";
|
|
22
|
+
* import { sqliteTable, integer } from "drizzle-orm/sqlite-core";
|
|
23
|
+
* import { defineDrizzleService } from "@relkit/drizzle";
|
|
24
|
+
* import { DrizzleOwner, drizzleOwnerLayer, drizzleRuntimeOf } from "@relkit/drizzle/internal";
|
|
25
|
+
* const records = sqliteTable("records", { id: integer().primaryKey() });
|
|
26
|
+
* const declaration = drizzleRuntimeOf(defineDrizzleService({ schema: { records }, client: () => ({}) }));
|
|
27
|
+
* const owner = ManagedRuntime.make(drizzleOwnerLayer(declaration, {}));
|
|
28
|
+
* try { await owner.runPromise(DrizzleOwner); }
|
|
29
|
+
* finally { await owner.dispose(); }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function drizzleOwnerLayer(declaration: DrizzleServiceRuntime, env: Readonly<Record<string, unknown>>): Layer.Layer<DrizzleOwner, DrizzleFailure, never>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates the service contract for live acquisition or deterministic fake clients.
|
|
35
|
+
* @param client - Client owned by the enclosing Layer scope.
|
|
36
|
+
* @returns Lazy owner state and named admission/shutdown workflows.
|
|
37
|
+
* @see {@link drizzleOwnerLayer} for the owning Layer and execution boundary.
|
|
38
|
+
*/
|
|
39
|
+
export declare const makeDrizzleOwner: (client: unknown) => Effect.Effect<DrizzleOwnerInterface, never, never>;
|
|
40
|
+
/**
|
|
41
|
+
* Admits lazy work and releases its lease after safe native settlement.
|
|
42
|
+
* @typeParam A - Success value.
|
|
43
|
+
* @typeParam E - Caller failure.
|
|
44
|
+
* @typeParam R - Caller services, retained without hidden provisioning.
|
|
45
|
+
* @param activation - Frozen activation associated with its owner.
|
|
46
|
+
* @param effect - Lazy work; SDK adapters must wait for native completion.
|
|
47
|
+
* @returns The original effect with a typed closed-owner failure.
|
|
48
|
+
* @example Compose work with an existing activation
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { Effect } from "effect";
|
|
51
|
+
* import { activateDrizzleService } from "@relkit/drizzle";
|
|
52
|
+
* import { withDrizzleWork } from "@relkit/drizzle/internal";
|
|
53
|
+
* function borrowedWork(active: Awaited<ReturnType<typeof activateDrizzleService>>) {
|
|
54
|
+
* return withDrizzleWork(active, Effect.succeed(1));
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function withDrizzleWork<A, E, R>(activation: object, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | DrizzleFailure, R>;
|
|
59
|
+
/**
|
|
60
|
+
* Reads the observation context captured at activation.
|
|
61
|
+
* @param activation - Database owner borrowed by another specialized service.
|
|
62
|
+
* @returns Logger/tracer/metric context without additional client authority.
|
|
63
|
+
*/
|
|
64
|
+
export declare function drizzleInstrumentationOf(activation: object): Context.Context<never>;
|
|
65
|
+
/**
|
|
66
|
+
* Executes one admitted Promise compatibility edge.
|
|
67
|
+
* @typeParam A - Success value.
|
|
68
|
+
* @typeParam E - Operation failure.
|
|
69
|
+
* @param activation - Database owner.
|
|
70
|
+
* @param effect - Already instrumented lazy operation.
|
|
71
|
+
* @returns Its public result, preserving native error identity.
|
|
72
|
+
* @see {@link withDrizzleWork} for the equivalent Effect-native borrowed lease.
|
|
73
|
+
*/
|
|
74
|
+
export declare function runDrizzleWorkPromise<A, E>(activation: object, effect: Effect.Effect<A, E>): Promise<A>;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=owner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner.d.ts","sourceRoot":"","sources":["../src/owner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAS,KAAK,EAAO,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAc,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;;AAY5E;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAEjC;CAAG;AAEJ,4EAA4E;AAC5E,eAAO,MAAM,MAAM,+BAAsC,CAAC;AAE1D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,qBAAqB,EAClC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,oDAkCvC;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,yEA6B5B,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACrC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC,CAYzC;AAmDD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAEnF;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,CAAC,EACxC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC,CAIZ"}
|
package/dist/owner.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { Context, Effect, Latch, Layer, Ref } from "effect";
|
|
2
|
+
import { DrizzleFailure, nativeCall } from "./failure.js";
|
|
3
|
+
import { observeSpecializedOperation } from "./operation-tracing.js";
|
|
4
|
+
import { redactSpecializedTrace } from "./trace-redaction.js";
|
|
5
|
+
import { closeNativeLease, inheritNativeLeases, makeNativeLease, NativeLeases, releaseNativeLease, retainNativeLease, } from "./native-leases.js";
|
|
6
|
+
/**
|
|
7
|
+
* Client lifetime/admission contract, substitutable through live/test Layers.
|
|
8
|
+
* @see {@link drizzleOwnerLayer} for checked acquisition/provisioning/cleanup composition.
|
|
9
|
+
*/
|
|
10
|
+
export class DrizzleOwner extends Context.Service()("@relkit/drizzle/Owner") {
|
|
11
|
+
}
|
|
12
|
+
/** Weak association preserving the exact frozen public activation shape. */
|
|
13
|
+
export const owners = new WeakMap();
|
|
14
|
+
/**
|
|
15
|
+
* Acquires one client into a Layer scope.
|
|
16
|
+
* @param declaration - Native acquisition/disposal dependencies.
|
|
17
|
+
* @param env - First activation environment.
|
|
18
|
+
* @returns A live owner Layer; its scope releases the client exactly once.
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { ManagedRuntime } from "effect";
|
|
22
|
+
* import { sqliteTable, integer } from "drizzle-orm/sqlite-core";
|
|
23
|
+
* import { defineDrizzleService } from "@relkit/drizzle";
|
|
24
|
+
* import { DrizzleOwner, drizzleOwnerLayer, drizzleRuntimeOf } from "@relkit/drizzle/internal";
|
|
25
|
+
* const records = sqliteTable("records", { id: integer().primaryKey() });
|
|
26
|
+
* const declaration = drizzleRuntimeOf(defineDrizzleService({ schema: { records }, client: () => ({}) }));
|
|
27
|
+
* const owner = ManagedRuntime.make(drizzleOwnerLayer(declaration, {}));
|
|
28
|
+
* try { await owner.runPromise(DrizzleOwner); }
|
|
29
|
+
* finally { await owner.dispose(); }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function drizzleOwnerLayer(declaration, env) {
|
|
33
|
+
return Layer.effect(DrizzleOwner, redactSpecializedTrace(Effect.gen(function* () {
|
|
34
|
+
// The release closure must also drain callers executing through a native
|
|
35
|
+
// Effect context outside ManagedRuntime's own fiber scope.
|
|
36
|
+
let service;
|
|
37
|
+
const client = yield* Effect.acquireRelease(observeSpecializedOperation("database.acquire", nativeCall("acquire", () => declaration.client({ env }))), (client) => Effect.gen(function* () {
|
|
38
|
+
if (service !== undefined) {
|
|
39
|
+
yield* service.beginClose();
|
|
40
|
+
yield* service.awaitDrained();
|
|
41
|
+
}
|
|
42
|
+
yield* observeSpecializedOperation("database.close", nativeCall("close", () => declaration.dispose?.(client))).pipe(Effect.mapError((failure) => failure.cause), Effect.orDie);
|
|
43
|
+
}));
|
|
44
|
+
service = yield* makeDrizzleOwner(client);
|
|
45
|
+
return service;
|
|
46
|
+
})));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates the service contract for live acquisition or deterministic fake clients.
|
|
50
|
+
* @param client - Client owned by the enclosing Layer scope.
|
|
51
|
+
* @returns Lazy owner state and named admission/shutdown workflows.
|
|
52
|
+
* @see {@link drizzleOwnerLayer} for the owning Layer and execution boundary.
|
|
53
|
+
*/
|
|
54
|
+
export const makeDrizzleOwner = Effect.fn("Drizzle.owner")((client) => Effect.gen(function* () {
|
|
55
|
+
const admission = yield* Ref.make({ closing: false, active: 0 });
|
|
56
|
+
const drained = yield* Latch.make(true);
|
|
57
|
+
return DrizzleOwner.of({
|
|
58
|
+
client,
|
|
59
|
+
admission,
|
|
60
|
+
drained,
|
|
61
|
+
work: (effect) => redactSpecializedTrace(Effect.fn("Drizzle.admit")((work) => admitOwnerWork(admission, drained, work))(effect)),
|
|
62
|
+
beginClose: Effect.fn("Drizzle.beginClose")(() => Ref.update(admission, (state) => ({ ...state, closing: true }))),
|
|
63
|
+
awaitDrained: Effect.fn("Drizzle.awaitDrained")(() => Effect.gen(function* () {
|
|
64
|
+
// Atomic admission is authoritative; scheduler yielding can expose the
|
|
65
|
+
// short interval between a count transition and its latch transition.
|
|
66
|
+
while ((yield* Ref.get(admission)).active !== 0) {
|
|
67
|
+
yield* drained.await;
|
|
68
|
+
yield* Effect.yieldNow;
|
|
69
|
+
}
|
|
70
|
+
})),
|
|
71
|
+
});
|
|
72
|
+
}));
|
|
73
|
+
/**
|
|
74
|
+
* Admits lazy work and releases its lease after safe native settlement.
|
|
75
|
+
* @typeParam A - Success value.
|
|
76
|
+
* @typeParam E - Caller failure.
|
|
77
|
+
* @typeParam R - Caller services, retained without hidden provisioning.
|
|
78
|
+
* @param activation - Frozen activation associated with its owner.
|
|
79
|
+
* @param effect - Lazy work; SDK adapters must wait for native completion.
|
|
80
|
+
* @returns The original effect with a typed closed-owner failure.
|
|
81
|
+
* @example Compose work with an existing activation
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { Effect } from "effect";
|
|
84
|
+
* import { activateDrizzleService } from "@relkit/drizzle";
|
|
85
|
+
* import { withDrizzleWork } from "@relkit/drizzle/internal";
|
|
86
|
+
* function borrowedWork(active: Awaited<ReturnType<typeof activateDrizzleService>>) {
|
|
87
|
+
* return withDrizzleWork(active, Effect.succeed(1));
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export function withDrizzleWork(activation, effect) {
|
|
92
|
+
return Effect.suspend(() => {
|
|
93
|
+
const owner = owners.get(activation)?.service;
|
|
94
|
+
if (owner === undefined)
|
|
95
|
+
return Effect.fail(new DrizzleFailure({
|
|
96
|
+
operation: "admission",
|
|
97
|
+
cause: new TypeError("Invalid Drizzle activation"),
|
|
98
|
+
}));
|
|
99
|
+
return owner.work(effect);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Owns the atomic admission/release transition for one caller.
|
|
104
|
+
* @typeParam A - Success value.
|
|
105
|
+
* @typeParam E - Caller failure.
|
|
106
|
+
* @typeParam R - Caller services.
|
|
107
|
+
* @param admission - Shared atomic owner state.
|
|
108
|
+
* @param drained - Gate opened when all leases settle.
|
|
109
|
+
* @param effect - Lazy caller work.
|
|
110
|
+
* @returns Admitted effect or a typed closed-owner failure.
|
|
111
|
+
*/
|
|
112
|
+
function admitOwnerWork(admission, drained, effect) {
|
|
113
|
+
return Effect.uninterruptibleMask((restore) => Effect.gen(function* () {
|
|
114
|
+
const leases = yield* NativeLeases;
|
|
115
|
+
if (leases.owner?.key === admission && (yield* retainNativeLease(leases.owner)))
|
|
116
|
+
return yield* restore(effect).pipe(Effect.ensuring(releaseNativeLease(leases.owner)));
|
|
117
|
+
const admitted = yield* Ref.modify(admission, (state) => state.closing ? [false, state] : [true, { ...state, active: state.active + 1 }]);
|
|
118
|
+
if (!admitted)
|
|
119
|
+
return yield* Effect.fail(new DrizzleFailure({
|
|
120
|
+
operation: "admission",
|
|
121
|
+
cause: new TypeError("Drizzle activation is closed"),
|
|
122
|
+
}));
|
|
123
|
+
yield* drained.close;
|
|
124
|
+
const lease = yield* makeNativeLease(admission);
|
|
125
|
+
return yield* restore(effect).pipe(Effect.provideService(NativeLeases, { ...leases, owner: lease }), Effect.ensuring(Effect.gen(function* () {
|
|
126
|
+
yield* closeNativeLease(lease);
|
|
127
|
+
const remaining = yield* Ref.modify(admission, (state) => [
|
|
128
|
+
state.active - 1,
|
|
129
|
+
{ ...state, active: state.active - 1 },
|
|
130
|
+
]);
|
|
131
|
+
if (remaining === 0)
|
|
132
|
+
yield* drained.open;
|
|
133
|
+
})));
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Reads the observation context captured at activation.
|
|
138
|
+
* @param activation - Database owner borrowed by another specialized service.
|
|
139
|
+
* @returns Logger/tracer/metric context without additional client authority.
|
|
140
|
+
*/
|
|
141
|
+
export function drizzleInstrumentationOf(activation) {
|
|
142
|
+
return owners.get(activation)?.instrumentation ?? Context.empty();
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Executes one admitted Promise compatibility edge.
|
|
146
|
+
* @typeParam A - Success value.
|
|
147
|
+
* @typeParam E - Operation failure.
|
|
148
|
+
* @param activation - Database owner.
|
|
149
|
+
* @param effect - Already instrumented lazy operation.
|
|
150
|
+
* @returns Its public result, preserving native error identity.
|
|
151
|
+
* @see {@link withDrizzleWork} for the equivalent Effect-native borrowed lease.
|
|
152
|
+
*/
|
|
153
|
+
export function runDrizzleWorkPromise(activation, effect) {
|
|
154
|
+
const owner = owners.get(activation);
|
|
155
|
+
if (owner === undefined)
|
|
156
|
+
return Promise.reject(new TypeError("Invalid Drizzle activation"));
|
|
157
|
+
return owner.run(inheritNativeLeases(withDrizzleWork(activation, effect)));
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=owner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner.js","sourceRoot":"","sources":["../src/owner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,OAAO,EAAuC,CACtF,uBAAuB,CACxB;CAAG;AAEJ,4EAA4E;AAC5E,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAwB,CAAC;AAE1D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,WAAkC,EAClC,GAAsC;IAEtC,OAAO,KAAK,CAAC,MAAM,CACjB,YAAY,EACZ,sBAAsB,CACpB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,yEAAyE;QACzE,2DAA2D;QAC3D,IAAI,OAA0C,CAAC;QAC/C,MAAM,MAAM,GAAG,KAAK,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CAAC,mBAAmB,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Context, Effect, Latch, ManagedRuntime, Ref } from "effect";
|
|
2
|
+
import type { DrizzleFailure } from "./failure.js";
|
|
3
|
+
import type { DrizzleOwner } from "./owner.js";
|
|
4
|
+
/** Atomic owner admission state; close is monotonic. */
|
|
5
|
+
export interface AdmissionState {
|
|
6
|
+
readonly closing: boolean;
|
|
7
|
+
readonly active: number;
|
|
8
|
+
}
|
|
9
|
+
/** Shared live/test contract for one client lifetime. */
|
|
10
|
+
export interface DrizzleOwnerInterface {
|
|
11
|
+
readonly client: unknown;
|
|
12
|
+
readonly admission: Ref.Ref<AdmissionState>;
|
|
13
|
+
readonly drained: Latch.Latch;
|
|
14
|
+
/**
|
|
15
|
+
* Admits lazy work while preserving its caller requirements and causes.
|
|
16
|
+
* @typeParam A - Successful caller result.
|
|
17
|
+
* @typeParam E - Caller typed failure.
|
|
18
|
+
* @typeParam R - Required caller services.
|
|
19
|
+
* @param effect - SDK adapter work retaining its lease until native settlement.
|
|
20
|
+
* @returns Lazy caller work or a typed closed-owner admission failure.
|
|
21
|
+
*/
|
|
22
|
+
readonly work: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | DrizzleFailure, R>;
|
|
23
|
+
/**
|
|
24
|
+
* Marks admission closed monotonically.
|
|
25
|
+
* @returns Lazy state transition; already admitted work retains its lease.
|
|
26
|
+
*/
|
|
27
|
+
readonly beginClose: () => Effect.Effect<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Awaits all previously admitted native work.
|
|
30
|
+
* @returns Lazy drain barrier; resource disposal must follow this completion.
|
|
31
|
+
*/
|
|
32
|
+
readonly awaitDrained: () => Effect.Effect<void>;
|
|
33
|
+
}
|
|
34
|
+
/** Private association; the public activation remains frozen. */
|
|
35
|
+
export interface OwnerBinding {
|
|
36
|
+
readonly dialect: "sqlite" | "pg" | "mysql";
|
|
37
|
+
readonly service: DrizzleOwnerInterface;
|
|
38
|
+
readonly runtime: ManagedRuntime.ManagedRuntime<DrizzleOwner, DrizzleFailure>;
|
|
39
|
+
readonly instrumentation: Context.Context<never>;
|
|
40
|
+
readonly run: <A, E>(effect: Effect.Effect<A, E>) => Promise<A>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=owner.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner.types.d.ts","sourceRoot":"","sources":["../src/owner.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,yDAAyD;AACzD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC;IAE9B;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC;IAE7C;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE/C;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CAClD;AAED,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,cAAc,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IAC9E,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACjD,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CACjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner.types.js","sourceRoot":"","sources":["../src/owner.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { ModelBinding } from "./runtime-types.js";
|
|
3
|
+
import { DrizzleFailure } from "./failure.js";
|
|
4
|
+
/**
|
|
5
|
+
* Selects one unique row and validates persisted data.
|
|
6
|
+
* @param binding - Table/client metadata.
|
|
7
|
+
* @param where - Complete unique selector.
|
|
8
|
+
* @returns Lazy row or null when absent.
|
|
9
|
+
*/
|
|
10
|
+
export declare const findOne: (binding: ModelBinding, where: Record<string, unknown>) => Effect.Effect<{} | null, DrizzleFailure, never>;
|
|
11
|
+
/**
|
|
12
|
+
* Selects a bounded ordered page.
|
|
13
|
+
* @param binding - Table/client metadata.
|
|
14
|
+
* @param args - Filter/order/pagination arguments.
|
|
15
|
+
* @returns Lazy validated rows in native ordering.
|
|
16
|
+
*/
|
|
17
|
+
export declare const findMany: (binding: ModelBinding, args: Record<string, unknown>) => Effect.Effect<unknown[], DrizzleFailure, never>;
|
|
18
|
+
/**
|
|
19
|
+
* Awaits native rows then validates sequentially without starting new SDK work.
|
|
20
|
+
* @param binding - Select schema.
|
|
21
|
+
* @param query - Uncancellable native thenable.
|
|
22
|
+
* @returns Lazy validated row array, preserving order and first failure.
|
|
23
|
+
*/
|
|
24
|
+
export declare function rows(binding: ModelBinding, query: unknown): Effect.Effect<unknown[], DrizzleFailure, never>;
|
|
25
|
+
/**
|
|
26
|
+
* Converts expected synchronous argument/native-builder exceptions.
|
|
27
|
+
* @typeParam A - Result of pure/native-builder validation.
|
|
28
|
+
* @param run - Suspended synchronous boundary.
|
|
29
|
+
* @returns Lazy value or typed failure with original cause.
|
|
30
|
+
*/
|
|
31
|
+
export declare function checked<A>(run: () => A): Effect.Effect<A, DrizzleFailure>;
|
|
32
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAc,MAAM,cAAc,CAAC;AAI1D;;;;;GAKG;AACH,eAAO,MAAM,OAAO,4GAiBnB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,2GAsBpB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,mDASzD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,CAAC,CAKzE"}
|
package/dist/queries.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { asc, desc } from "drizzle-orm";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { DrizzleFailure, nativeCall } from "./failure.js";
|
|
4
|
+
import { decodeTableValue } from "./table.schemas.js";
|
|
5
|
+
import { call, clause, columnFor, integer, record } from "./operations.utils.js";
|
|
6
|
+
/**
|
|
7
|
+
* Selects one unique row and validates persisted data.
|
|
8
|
+
* @param binding - Table/client metadata.
|
|
9
|
+
* @param where - Complete unique selector.
|
|
10
|
+
* @returns Lazy row or null when absent.
|
|
11
|
+
*/
|
|
12
|
+
export const findOne = Effect.fn("Drizzle.findOne")((binding, where) => Effect.gen(function* () {
|
|
13
|
+
const query = yield* checked(() => call(call(call(call(binding.drizzle, "select"), "from", binding.table), "where", clause(binding, where)), "limit", 1));
|
|
14
|
+
const selected = yield* rows(binding, query);
|
|
15
|
+
return selected[0] ?? null;
|
|
16
|
+
}));
|
|
17
|
+
/**
|
|
18
|
+
* Selects a bounded ordered page.
|
|
19
|
+
* @param binding - Table/client metadata.
|
|
20
|
+
* @param args - Filter/order/pagination arguments.
|
|
21
|
+
* @returns Lazy validated rows in native ordering.
|
|
22
|
+
*/
|
|
23
|
+
export const findMany = Effect.fn("Drizzle.findMany")((binding, args) => Effect.gen(function* () {
|
|
24
|
+
const query = yield* checked(() => {
|
|
25
|
+
const limit = integer(args.limit, "limit", 100, 1_000);
|
|
26
|
+
const offset = integer(args.offset, "offset", 0);
|
|
27
|
+
let query = call(call(binding.drizzle, "select"), "from", binding.table);
|
|
28
|
+
if (args.where !== undefined)
|
|
29
|
+
query = call(query, "where", clause(binding, record(args.where)));
|
|
30
|
+
if (args.orderBy !== undefined) {
|
|
31
|
+
const order = record(args.orderBy);
|
|
32
|
+
if (typeof order.field !== "string" || order.field === "")
|
|
33
|
+
throw new TypeError("orderBy.field is invalid");
|
|
34
|
+
const column = columnFor(binding, order.field);
|
|
35
|
+
if (order.direction !== "asc" && order.direction !== "desc")
|
|
36
|
+
throw new TypeError("orderBy.direction must be asc or desc");
|
|
37
|
+
query = call(query, "orderBy", order.direction === "asc" ? asc(column) : desc(column));
|
|
38
|
+
}
|
|
39
|
+
return call(call(query, "limit", limit), "offset", offset);
|
|
40
|
+
});
|
|
41
|
+
return yield* rows(binding, query);
|
|
42
|
+
}));
|
|
43
|
+
/**
|
|
44
|
+
* Awaits native rows then validates sequentially without starting new SDK work.
|
|
45
|
+
* @param binding - Select schema.
|
|
46
|
+
* @param query - Uncancellable native thenable.
|
|
47
|
+
* @returns Lazy validated row array, preserving order and first failure.
|
|
48
|
+
*/
|
|
49
|
+
export function rows(binding, query) {
|
|
50
|
+
return Effect.gen(function* () {
|
|
51
|
+
const value = yield* nativeCall("query", () => query);
|
|
52
|
+
if (!Array.isArray(value))
|
|
53
|
+
return yield* checked(() => {
|
|
54
|
+
throw new TypeError("Drizzle query did not return rows");
|
|
55
|
+
});
|
|
56
|
+
return yield* Effect.forEach(value, (row) => decodeTableValue(binding.schemas.select, row));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Converts expected synchronous argument/native-builder exceptions.
|
|
61
|
+
* @typeParam A - Result of pure/native-builder validation.
|
|
62
|
+
* @param run - Suspended synchronous boundary.
|
|
63
|
+
* @returns Lazy value or typed failure with original cause.
|
|
64
|
+
*/
|
|
65
|
+
export function checked(run) {
|
|
66
|
+
return Effect.try({
|
|
67
|
+
try: run,
|
|
68
|
+
catch: (cause) => new DrizzleFailure({ operation: "validation", cause }),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEh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