@prisma-next/operations 0.5.0-dev.4 → 0.5.0-dev.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.mts +10 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +12 -10
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ This package provides a generic, target-neutral operation registry. It's part of
|
|
|
22
22
|
- **Depended on by**:
|
|
23
23
|
- `@prisma-next/sql-operations` (extends with SQL-specific lowering specs)
|
|
24
24
|
- `@prisma-next/sql-relational-core` (imports `ParamSpec` for AST and type definitions)
|
|
25
|
-
- `@prisma-next/runtime-
|
|
25
|
+
- `@prisma-next/sql-runtime`, `@prisma-next/framework-components`, and other packages that build on the operation registry
|
|
26
26
|
|
|
27
27
|
## Architecture
|
|
28
28
|
|
package/dist/index.d.mts
CHANGED
|
@@ -8,9 +8,16 @@ interface ReturnSpec {
|
|
|
8
8
|
readonly codecId: string;
|
|
9
9
|
readonly nullable: boolean;
|
|
10
10
|
}
|
|
11
|
+
type SelfSpec = {
|
|
12
|
+
readonly codecId: string;
|
|
13
|
+
readonly traits?: never;
|
|
14
|
+
} | {
|
|
15
|
+
readonly traits: readonly string[];
|
|
16
|
+
readonly codecId?: never;
|
|
17
|
+
};
|
|
11
18
|
interface OperationEntry {
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
19
|
+
readonly self?: SelfSpec;
|
|
20
|
+
readonly impl: (...args: never[]) => unknown;
|
|
14
21
|
}
|
|
15
22
|
type OperationDescriptor<T extends OperationEntry = OperationEntry> = T & {
|
|
16
23
|
readonly method: string;
|
|
@@ -21,5 +28,5 @@ interface OperationRegistry<T extends OperationEntry = OperationEntry> {
|
|
|
21
28
|
}
|
|
22
29
|
declare function createOperationRegistry<T extends OperationEntry = OperationEntry>(): OperationRegistry<T>;
|
|
23
30
|
//#endregion
|
|
24
|
-
export { OperationDescriptor, OperationEntry, OperationRegistry, ParamSpec, ReturnSpec, createOperationRegistry };
|
|
31
|
+
export { OperationDescriptor, OperationEntry, OperationRegistry, ParamSpec, ReturnSpec, SelfSpec, createOperationRegistry };
|
|
25
32
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";UAAiB,SAAA;EAAA,SAAA,OAAS,CAAA,EAAA,MAAA;EAMT,SAAA,MAAU,CAAA,EAAA,SAAA,MAAA,EAAA;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";UAAiB,SAAA;EAAA,SAAA,OAAS,CAAA,EAAA,MAAA;EAMT,SAAA,MAAU,CAAA,EAAA,SAAA,MAAA,EAAA;EAKf,SAAA,QAAQ,EAAA,OAAA;AAIpB;AAKY,UAdK,UAAA,CAcc;EAAW,SAAA,OAAA,EAAA,MAAA;EAAiB,SAAA,QAAA,EAAA,OAAA;;AAAmB,KATlE,QAAA,GASkE;EAI7D,SAAA,OAAA,EAAA,MAAiB;EAAW,SAAA,MAAA,CAAA,EAAA,KAAA;CAAiB,GAAA;EACnB,SAAA,MAAA,EAAA,SAAA,MAAA,EAAA;EAApB,SAAA,OAAA,CAAA,EAAA,KAAA;CACc;AAAf,UAXL,cAAA,CAWK;EAAT,SAAA,IAAA,CAAA,EAVK,QAUL;EAAQ,SAAA,IAAA,EAAA,CAAA,GAAA,IAAA,EAAA,KAAA,EAAA,EAAA,GAAA,OAAA;AAGrB;AACY,KAVA,mBAUA,CAAA,UAV8B,cAU9B,GAV+C,cAU/C,CAAA,GAViE,CAUjE,GAAA;EAAiB,SAAA,MAAA,EAAA,MAAA;CACN;AAAlB,UAPY,iBAOZ,CAAA,UAPwC,cAOxC,GAPyD,cAOzD,CAAA,CAAA;EAAiB,QAAA,CAAA,UAAA,EANC,mBAMD,CANqB,CAMrB,CAAA,CAAA,EAAA,IAAA;aALT,SAAS,eAAe;;iBAGrB,kCACJ,iBAAiB,mBACxB,kBAAkB"}
|
package/dist/index.mjs
CHANGED
|
@@ -4,12 +4,12 @@ function createOperationRegistry() {
|
|
|
4
4
|
return {
|
|
5
5
|
register(descriptor) {
|
|
6
6
|
if (descriptor.method in operations) throw new Error(`Operation "${descriptor.method}" is already registered`);
|
|
7
|
-
descriptor.
|
|
8
|
-
const hasCodecId =
|
|
9
|
-
const hasTraits =
|
|
10
|
-
if (!hasCodecId && !hasTraits) throw new Error(`Operation "${descriptor.method}"
|
|
11
|
-
if (hasCodecId && hasTraits) throw new Error(`Operation "${descriptor.method}"
|
|
12
|
-
}
|
|
7
|
+
if (descriptor.self) {
|
|
8
|
+
const hasCodecId = descriptor.self.codecId !== void 0;
|
|
9
|
+
const hasTraits = descriptor.self.traits !== void 0 && descriptor.self.traits.length > 0;
|
|
10
|
+
if (!hasCodecId && !hasTraits) throw new Error(`Operation "${descriptor.method}" self has neither codecId nor traits`);
|
|
11
|
+
if (hasCodecId && hasTraits) throw new Error(`Operation "${descriptor.method}" self has both codecId and traits`);
|
|
12
|
+
}
|
|
13
13
|
const { method: _method, ...entry } = descriptor;
|
|
14
14
|
operations[descriptor.method] = entry;
|
|
15
15
|
},
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["operations: Record<string, T>"],"sources":["../src/index.ts"],"sourcesContent":["export interface ParamSpec {\n readonly codecId?: string;\n readonly traits?: readonly string[];\n readonly nullable: boolean;\n}\n\nexport interface ReturnSpec {\n readonly codecId: string;\n readonly nullable: boolean;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["operations: Record<string, T>"],"sources":["../src/index.ts"],"sourcesContent":["export interface ParamSpec {\n readonly codecId?: string;\n readonly traits?: readonly string[];\n readonly nullable: boolean;\n}\n\nexport interface ReturnSpec {\n readonly codecId: string;\n readonly nullable: boolean;\n}\n\nexport type SelfSpec =\n | { readonly codecId: string; readonly traits?: never }\n | { readonly traits: readonly string[]; readonly codecId?: never };\n\nexport interface OperationEntry {\n readonly self?: SelfSpec;\n readonly impl: (...args: never[]) => unknown;\n}\n\nexport type OperationDescriptor<T extends OperationEntry = OperationEntry> = T & {\n readonly method: string;\n};\n\nexport interface OperationRegistry<T extends OperationEntry = OperationEntry> {\n register(descriptor: OperationDescriptor<T>): void;\n entries(): Readonly<Record<string, T>>;\n}\n\nexport function createOperationRegistry<\n T extends OperationEntry = OperationEntry,\n>(): OperationRegistry<T> {\n const operations: Record<string, T> = Object.create(null);\n\n return {\n register(descriptor: OperationDescriptor<T>) {\n if (descriptor.method in operations) {\n throw new Error(`Operation \"${descriptor.method}\" is already registered`);\n }\n if (descriptor.self) {\n const hasCodecId = descriptor.self.codecId !== undefined;\n const hasTraits = descriptor.self.traits !== undefined && descriptor.self.traits.length > 0;\n if (!hasCodecId && !hasTraits) {\n throw new Error(`Operation \"${descriptor.method}\" self has neither codecId nor traits`);\n }\n if (hasCodecId && hasTraits) {\n throw new Error(`Operation \"${descriptor.method}\" self has both codecId and traits`);\n }\n }\n const { method: _method, ...entry } = descriptor;\n // OperationDescriptor<T> = T & { method }, so stripping method yields T.\n // TypeScript can't prove Omit<T & { method }, 'method'> = T for generic T.\n operations[descriptor.method] = entry as unknown as T;\n },\n entries() {\n return Object.freeze({ ...operations });\n },\n };\n}\n"],"mappings":";AA6BA,SAAgB,0BAEU;CACxB,MAAMA,aAAgC,OAAO,OAAO,KAAK;AAEzD,QAAO;EACL,SAAS,YAAoC;AAC3C,OAAI,WAAW,UAAU,WACvB,OAAM,IAAI,MAAM,cAAc,WAAW,OAAO,yBAAyB;AAE3E,OAAI,WAAW,MAAM;IACnB,MAAM,aAAa,WAAW,KAAK,YAAY;IAC/C,MAAM,YAAY,WAAW,KAAK,WAAW,UAAa,WAAW,KAAK,OAAO,SAAS;AAC1F,QAAI,CAAC,cAAc,CAAC,UAClB,OAAM,IAAI,MAAM,cAAc,WAAW,OAAO,uCAAuC;AAEzF,QAAI,cAAc,UAChB,OAAM,IAAI,MAAM,cAAc,WAAW,OAAO,oCAAoC;;GAGxF,MAAM,EAAE,QAAQ,SAAS,GAAG,UAAU;AAGtC,cAAW,WAAW,UAAU;;EAElC,UAAU;AACR,UAAO,OAAO,OAAO,EAAE,GAAG,YAAY,CAAC;;EAE1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/operations",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Target-neutral operation registry and capability helpers for Prisma Next",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"tsdown": "0.18.4",
|
|
10
10
|
"typescript": "5.9.3",
|
|
11
11
|
"vitest": "4.0.17",
|
|
12
|
+
"@prisma-next/test-utils": "0.0.1",
|
|
12
13
|
"@prisma-next/tsconfig": "0.0.0",
|
|
13
|
-
"@prisma-next/tsdown": "0.0.0"
|
|
14
|
-
"@prisma-next/test-utils": "0.0.1"
|
|
14
|
+
"@prisma-next/tsdown": "0.0.0"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"dist",
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,13 @@ export interface ReturnSpec {
|
|
|
9
9
|
readonly nullable: boolean;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export type SelfSpec =
|
|
13
|
+
| { readonly codecId: string; readonly traits?: never }
|
|
14
|
+
| { readonly traits: readonly string[]; readonly codecId?: never };
|
|
15
|
+
|
|
12
16
|
export interface OperationEntry {
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
17
|
+
readonly self?: SelfSpec;
|
|
18
|
+
readonly impl: (...args: never[]) => unknown;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export type OperationDescriptor<T extends OperationEntry = OperationEntry> = T & {
|
|
@@ -33,18 +37,16 @@ export function createOperationRegistry<
|
|
|
33
37
|
if (descriptor.method in operations) {
|
|
34
38
|
throw new Error(`Operation "${descriptor.method}" is already registered`);
|
|
35
39
|
}
|
|
36
|
-
descriptor.
|
|
37
|
-
const hasCodecId =
|
|
38
|
-
const hasTraits =
|
|
40
|
+
if (descriptor.self) {
|
|
41
|
+
const hasCodecId = descriptor.self.codecId !== undefined;
|
|
42
|
+
const hasTraits = descriptor.self.traits !== undefined && descriptor.self.traits.length > 0;
|
|
39
43
|
if (!hasCodecId && !hasTraits) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
`Operation "${descriptor.method}" arg[${i}] has neither codecId nor traits`,
|
|
42
|
-
);
|
|
44
|
+
throw new Error(`Operation "${descriptor.method}" self has neither codecId nor traits`);
|
|
43
45
|
}
|
|
44
46
|
if (hasCodecId && hasTraits) {
|
|
45
|
-
throw new Error(`Operation "${descriptor.method}"
|
|
47
|
+
throw new Error(`Operation "${descriptor.method}" self has both codecId and traits`);
|
|
46
48
|
}
|
|
47
|
-
}
|
|
49
|
+
}
|
|
48
50
|
const { method: _method, ...entry } = descriptor;
|
|
49
51
|
// OperationDescriptor<T> = T & { method }, so stripping method yields T.
|
|
50
52
|
// TypeScript can't prove Omit<T & { method }, 'method'> = T for generic T.
|