@prisma-next/sql-contract 0.3.0-dev.15 → 0.3.0-dev.162
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/LICENSE +201 -0
- package/README.md +80 -11
- package/dist/factories.d.mts +29 -0
- package/dist/factories.d.mts.map +1 -0
- package/dist/factories.mjs +64 -0
- package/dist/factories.mjs.map +1 -0
- package/dist/pack-types.d.mts +13 -0
- package/dist/pack-types.d.mts.map +1 -0
- package/dist/pack-types.mjs +1 -0
- package/dist/types-BYQMEXGG.d.mts +176 -0
- package/dist/types-BYQMEXGG.d.mts.map +1 -0
- package/dist/types-DRR5stkj.mjs +13 -0
- package/dist/types-DRR5stkj.mjs.map +1 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +3 -0
- package/dist/validate.d.mts +9 -0
- package/dist/validate.d.mts.map +1 -0
- package/dist/validate.mjs +107 -0
- package/dist/validate.mjs.map +1 -0
- package/dist/validators-BjZ6lOS1.mjs +281 -0
- package/dist/validators-BjZ6lOS1.mjs.map +1 -0
- package/dist/validators.d.mts +61 -0
- package/dist/validators.d.mts.map +1 -0
- package/dist/validators.mjs +3 -0
- package/package.json +22 -25
- package/src/exports/factories.ts +1 -11
- package/src/exports/types.ts +24 -6
- package/src/exports/validate.ts +1 -0
- package/src/exports/validators.ts +1 -1
- package/src/factories.ts +29 -57
- package/src/index.ts +1 -0
- package/src/types.ts +164 -30
- package/src/validate.ts +227 -0
- package/src/validators.ts +300 -50
- package/dist/exports/factories.d.ts +0 -2
- package/dist/exports/factories.d.ts.map +0 -1
- package/dist/exports/factories.js +0 -83
- package/dist/exports/factories.js.map +0 -1
- package/dist/exports/pack-types.d.ts +0 -2
- package/dist/exports/pack-types.d.ts.map +0 -1
- package/dist/exports/pack-types.js +0 -1
- package/dist/exports/pack-types.js.map +0 -1
- package/dist/exports/types.d.ts +0 -2
- package/dist/exports/types.d.ts.map +0 -1
- package/dist/exports/types.js +0 -1
- package/dist/exports/types.js.map +0 -1
- package/dist/exports/validators.d.ts +0 -2
- package/dist/exports/validators.d.ts.map +0 -1
- package/dist/exports/validators.js +0 -96
- package/dist/exports/validators.js.map +0 -1
- package/dist/factories.d.ts +0 -38
- package/dist/factories.d.ts.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/pack-types.d.ts +0 -10
- package/dist/pack-types.d.ts.map +0 -1
- package/dist/types.d.ts +0 -68
- package/dist/types.d.ts.map +0 -1
- package/dist/validators.d.ts +0 -35
- package/dist/validators.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,50 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sql-contract",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.162",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "SQL contract types, validators, and IR factories for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"arktype": "^2.1.25",
|
|
9
|
-
"@prisma-next/contract": "0.3.0-dev.
|
|
9
|
+
"@prisma-next/contract": "0.3.0-dev.162",
|
|
10
|
+
"@prisma-next/framework-components": "0.3.0-dev.162"
|
|
10
11
|
},
|
|
11
12
|
"devDependencies": {
|
|
12
|
-
"
|
|
13
|
-
"tsup": "8.5.1",
|
|
13
|
+
"tsdown": "0.18.4",
|
|
14
14
|
"typescript": "5.9.3",
|
|
15
|
-
"vitest": "4.0.
|
|
16
|
-
"@prisma-next/test-utils": "0.0.1"
|
|
15
|
+
"vitest": "4.0.17",
|
|
16
|
+
"@prisma-next/test-utils": "0.0.1",
|
|
17
|
+
"@prisma-next/tsconfig": "0.0.0",
|
|
18
|
+
"@prisma-next/tsdown": "0.0.0"
|
|
17
19
|
},
|
|
18
20
|
"files": [
|
|
19
21
|
"dist",
|
|
20
22
|
"src"
|
|
21
23
|
],
|
|
22
24
|
"exports": {
|
|
23
|
-
"./
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"./validators":
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
"./pack-types": {
|
|
36
|
-
"types": "./dist/exports/pack-types.d.ts",
|
|
37
|
-
"import": "./dist/exports/pack-types.js"
|
|
38
|
-
}
|
|
25
|
+
"./factories": "./dist/factories.mjs",
|
|
26
|
+
"./pack-types": "./dist/pack-types.mjs",
|
|
27
|
+
"./types": "./dist/types.mjs",
|
|
28
|
+
"./validate": "./dist/validate.mjs",
|
|
29
|
+
"./validators": "./dist/validators.mjs",
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/prisma/prisma-next.git",
|
|
35
|
+
"directory": "packages/2-sql/1-core/contract"
|
|
39
36
|
},
|
|
40
37
|
"scripts": {
|
|
41
|
-
"build": "
|
|
38
|
+
"build": "tsdown",
|
|
42
39
|
"test": "vitest run",
|
|
43
40
|
"test:coverage": "vitest run --coverage",
|
|
44
|
-
"typecheck": "tsc --
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
45
42
|
"lint": "biome check . --error-on-warnings",
|
|
46
43
|
"lint:fix": "biome check --write .",
|
|
47
44
|
"lint:fix:unsafe": "biome check --write --unsafe .",
|
|
48
|
-
"clean": "
|
|
45
|
+
"clean": "rm -rf dist dist-tsc dist-tsc-prod coverage .tmp-output"
|
|
49
46
|
}
|
|
50
47
|
}
|
package/src/exports/factories.ts
CHANGED
package/src/exports/types.ts
CHANGED
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
export type {
|
|
2
|
+
CodecTypesOf,
|
|
3
|
+
ContractWithTypeMaps,
|
|
2
4
|
ExtractCodecTypes,
|
|
3
|
-
|
|
5
|
+
ExtractFieldInputTypes,
|
|
6
|
+
ExtractFieldOutputTypes,
|
|
7
|
+
ExtractQueryOperationTypes,
|
|
8
|
+
ExtractTypeMapsFromContract,
|
|
9
|
+
FieldInputTypesOf,
|
|
10
|
+
FieldOutputTypesOf,
|
|
4
11
|
ForeignKey,
|
|
12
|
+
ForeignKeyOptions,
|
|
5
13
|
ForeignKeyReferences,
|
|
6
14
|
Index,
|
|
7
|
-
|
|
8
|
-
ModelField,
|
|
9
|
-
ModelStorage,
|
|
15
|
+
OperationTypesOf,
|
|
10
16
|
PrimaryKey,
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
QueryOperationTypeEntry,
|
|
18
|
+
QueryOperationTypesBase,
|
|
19
|
+
QueryOperationTypesOf,
|
|
20
|
+
ReferentialAction,
|
|
21
|
+
ResolveCodecTypes,
|
|
22
|
+
ResolveOperationTypes,
|
|
23
|
+
SqlModelFieldStorage,
|
|
24
|
+
SqlModelStorage,
|
|
25
|
+
SqlQueryOperationTypes,
|
|
13
26
|
SqlStorage,
|
|
14
27
|
StorageColumn,
|
|
15
28
|
StorageTable,
|
|
29
|
+
StorageTypeInstance,
|
|
30
|
+
TypeMaps,
|
|
31
|
+
TypeMapsPhantomKey,
|
|
16
32
|
UniqueConstraint,
|
|
17
33
|
} from '../types';
|
|
34
|
+
|
|
35
|
+
export { applyFkDefaults, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX } from '../types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { validateContract } from '../validate';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from '../validators';
|
package/src/factories.ts
CHANGED
|
@@ -1,27 +1,18 @@
|
|
|
1
|
+
import type { ScalarFieldType } from '@prisma-next/contract/types';
|
|
1
2
|
import type {
|
|
2
3
|
ForeignKey,
|
|
4
|
+
ForeignKeyOptions,
|
|
3
5
|
ForeignKeyReferences,
|
|
4
6
|
Index,
|
|
5
|
-
ModelDefinition,
|
|
6
|
-
ModelField,
|
|
7
|
-
ModelStorage,
|
|
8
7
|
PrimaryKey,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
SqlStorage,
|
|
8
|
+
SqlModelFieldStorage,
|
|
9
|
+
SqlModelStorage,
|
|
12
10
|
StorageColumn,
|
|
13
11
|
StorageTable,
|
|
14
12
|
UniqueConstraint,
|
|
15
13
|
} from './types';
|
|
14
|
+
import { applyFkDefaults } from './types';
|
|
16
15
|
|
|
17
|
-
/**
|
|
18
|
-
* Creates a StorageColumn with nativeType and codecId.
|
|
19
|
-
*
|
|
20
|
-
* @param nativeType - Native database type identifier (e.g., 'int4', 'text', 'vector')
|
|
21
|
-
* @param codecId - Codec identifier (e.g., 'pg/int4@1', 'pg/text@1')
|
|
22
|
-
* @param nullable - Whether the column is nullable (default: false)
|
|
23
|
-
* @returns StorageColumn with nativeType and codecId
|
|
24
|
-
*/
|
|
25
16
|
export function col(nativeType: string, codecId: string, nullable = false): StorageColumn {
|
|
26
17
|
return {
|
|
27
18
|
nativeType,
|
|
@@ -52,16 +43,20 @@ export function fk(
|
|
|
52
43
|
columns: readonly string[],
|
|
53
44
|
refTable: string,
|
|
54
45
|
refColumns: readonly string[],
|
|
55
|
-
|
|
46
|
+
opts?: ForeignKeyOptions & { constraint?: boolean; index?: boolean },
|
|
56
47
|
): ForeignKey {
|
|
57
48
|
const references: ForeignKeyReferences = {
|
|
58
49
|
table: refTable,
|
|
59
50
|
columns: refColumns,
|
|
60
51
|
};
|
|
52
|
+
|
|
61
53
|
return {
|
|
62
54
|
columns,
|
|
63
55
|
references,
|
|
64
|
-
...(name !== undefined && { name }),
|
|
56
|
+
...(opts?.name !== undefined && { name: opts.name }),
|
|
57
|
+
...(opts?.onDelete !== undefined && { onDelete: opts.onDelete }),
|
|
58
|
+
...(opts?.onUpdate !== undefined && { onUpdate: opts.onUpdate }),
|
|
59
|
+
...applyFkDefaults({ constraint: opts?.constraint, index: opts?.index }),
|
|
65
60
|
};
|
|
66
61
|
}
|
|
67
62
|
|
|
@@ -84,50 +79,27 @@ export function table(
|
|
|
84
79
|
}
|
|
85
80
|
|
|
86
81
|
export function model(
|
|
87
|
-
|
|
88
|
-
fields: Record<string,
|
|
82
|
+
tableName: string,
|
|
83
|
+
fields: Record<string, SqlModelFieldStorage>,
|
|
89
84
|
relations: Record<string, unknown> = {},
|
|
90
|
-
):
|
|
91
|
-
|
|
85
|
+
): {
|
|
86
|
+
storage: SqlModelStorage;
|
|
87
|
+
fields: Record<string, { readonly nullable: boolean; readonly type: ScalarFieldType }>;
|
|
88
|
+
relations: Record<string, unknown>;
|
|
89
|
+
} {
|
|
90
|
+
const storage: SqlModelStorage = { table: tableName, fields };
|
|
91
|
+
const domainFields = Object.fromEntries(
|
|
92
|
+
Object.entries(fields).map(([name, field]) => [
|
|
93
|
+
name,
|
|
94
|
+
{
|
|
95
|
+
nullable: field.nullable ?? false,
|
|
96
|
+
type: { kind: 'scalar' as const, codecId: field.codecId ?? 'core/unknown@1' },
|
|
97
|
+
},
|
|
98
|
+
]),
|
|
99
|
+
) as Record<string, { nullable: boolean; type: ScalarFieldType }>;
|
|
92
100
|
return {
|
|
93
101
|
storage,
|
|
94
|
-
fields,
|
|
102
|
+
fields: domainFields,
|
|
95
103
|
relations,
|
|
96
104
|
};
|
|
97
105
|
}
|
|
98
|
-
|
|
99
|
-
export function storage(tables: Record<string, StorageTable>): SqlStorage {
|
|
100
|
-
return { tables };
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function contract(opts: {
|
|
104
|
-
target: string;
|
|
105
|
-
coreHash: string;
|
|
106
|
-
storage: SqlStorage;
|
|
107
|
-
models?: Record<string, ModelDefinition>;
|
|
108
|
-
relations?: Record<string, unknown>;
|
|
109
|
-
mappings?: Partial<SqlMappings>;
|
|
110
|
-
schemaVersion?: '1';
|
|
111
|
-
targetFamily?: 'sql';
|
|
112
|
-
profileHash?: string;
|
|
113
|
-
capabilities?: Record<string, Record<string, boolean>>;
|
|
114
|
-
extensionPacks?: Record<string, unknown>;
|
|
115
|
-
meta?: Record<string, unknown>;
|
|
116
|
-
sources?: Record<string, unknown>;
|
|
117
|
-
}): SqlContract {
|
|
118
|
-
return {
|
|
119
|
-
schemaVersion: opts.schemaVersion ?? '1',
|
|
120
|
-
target: opts.target,
|
|
121
|
-
targetFamily: opts.targetFamily ?? 'sql',
|
|
122
|
-
coreHash: opts.coreHash,
|
|
123
|
-
storage: opts.storage,
|
|
124
|
-
models: opts.models ?? {},
|
|
125
|
-
relations: opts.relations ?? {},
|
|
126
|
-
mappings: (opts.mappings ?? {}) as SqlMappings,
|
|
127
|
-
...(opts.profileHash !== undefined && { profileHash: opts.profileHash }),
|
|
128
|
-
...(opts.capabilities !== undefined && { capabilities: opts.capabilities }),
|
|
129
|
-
...(opts.extensionPacks !== undefined && { extensionPacks: opts.extensionPacks }),
|
|
130
|
-
...(opts.meta !== undefined && { meta: opts.meta }),
|
|
131
|
-
...(opts.sources !== undefined && { sources: opts.sources as Record<string, unknown> }),
|
|
132
|
-
} as SqlContract;
|
|
133
|
-
}
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ColumnDefault, StorageBase } from '@prisma-next/contract/types';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A column definition in storage.
|
|
5
|
+
*
|
|
6
|
+
* `typeParams` is optional because most columns use non-parameterized types.
|
|
7
|
+
* Columns with parameterized types can either inline `typeParams` or reference
|
|
8
|
+
* a named {@link StorageTypeInstance} via `typeRef`.
|
|
9
|
+
*/
|
|
3
10
|
export type StorageColumn = {
|
|
4
11
|
readonly nativeType: string;
|
|
5
12
|
readonly codecId: string;
|
|
6
13
|
readonly nullable: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Opaque, codec-owned JS/type parameters.
|
|
16
|
+
* The codec that owns `codecId` defines the shape and semantics.
|
|
17
|
+
* Mutually exclusive with `typeRef`.
|
|
18
|
+
*/
|
|
19
|
+
readonly typeParams?: Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Reference to a named type instance in `storage.types`.
|
|
22
|
+
* Mutually exclusive with `typeParams`.
|
|
23
|
+
*/
|
|
24
|
+
readonly typeRef?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Default value for the column.
|
|
27
|
+
* Can be a literal value or database function.
|
|
28
|
+
*/
|
|
29
|
+
readonly default?: ColumnDefault;
|
|
7
30
|
};
|
|
8
31
|
|
|
9
32
|
export type PrimaryKey = {
|
|
@@ -19,6 +42,16 @@ export type UniqueConstraint = {
|
|
|
19
42
|
export type Index = {
|
|
20
43
|
readonly columns: readonly string[];
|
|
21
44
|
readonly name?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Optional access method identifier.
|
|
47
|
+
* Extension-specific methods are represented as strings and interpreted
|
|
48
|
+
* by the owning extension package.
|
|
49
|
+
*/
|
|
50
|
+
readonly using?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Optional extension-owned index configuration payload.
|
|
53
|
+
*/
|
|
54
|
+
readonly config?: Record<string, unknown>;
|
|
22
55
|
};
|
|
23
56
|
|
|
24
57
|
export type ForeignKeyReferences = {
|
|
@@ -26,10 +59,24 @@ export type ForeignKeyReferences = {
|
|
|
26
59
|
readonly columns: readonly string[];
|
|
27
60
|
};
|
|
28
61
|
|
|
62
|
+
export type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
|
|
63
|
+
|
|
64
|
+
export type ForeignKeyOptions = {
|
|
65
|
+
readonly name?: string;
|
|
66
|
+
readonly onDelete?: ReferentialAction;
|
|
67
|
+
readonly onUpdate?: ReferentialAction;
|
|
68
|
+
};
|
|
69
|
+
|
|
29
70
|
export type ForeignKey = {
|
|
30
71
|
readonly columns: readonly string[];
|
|
31
72
|
readonly references: ForeignKeyReferences;
|
|
32
73
|
readonly name?: string;
|
|
74
|
+
readonly onDelete?: ReferentialAction;
|
|
75
|
+
readonly onUpdate?: ReferentialAction;
|
|
76
|
+
/** Whether to emit FK constraint DDL (ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY). */
|
|
77
|
+
readonly constraint: boolean;
|
|
78
|
+
/** Whether to emit a backing index for the FK columns. */
|
|
79
|
+
readonly index: boolean;
|
|
33
80
|
};
|
|
34
81
|
|
|
35
82
|
export type StorageTable = {
|
|
@@ -40,48 +87,135 @@ export type StorageTable = {
|
|
|
40
87
|
readonly foreignKeys: ReadonlyArray<ForeignKey>;
|
|
41
88
|
};
|
|
42
89
|
|
|
43
|
-
|
|
90
|
+
/**
|
|
91
|
+
* A named, parameterized type instance.
|
|
92
|
+
* These are registered in `storage.types` for reuse across columns
|
|
93
|
+
* and to enable ergonomic schema surfaces like `schema.types.MyType`.
|
|
94
|
+
*
|
|
95
|
+
* Unlike {@link StorageColumn}, `typeParams` is required here because
|
|
96
|
+
* `StorageTypeInstance` exists specifically to define reusable parameterized types.
|
|
97
|
+
* A type instance without parameters would be redundant—columns can reference
|
|
98
|
+
* the codec directly via `codecId`.
|
|
99
|
+
*/
|
|
100
|
+
export type StorageTypeInstance = {
|
|
101
|
+
readonly codecId: string;
|
|
102
|
+
readonly nativeType: string;
|
|
103
|
+
readonly typeParams: Record<string, unknown>;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type SqlStorage<THash extends string = string> = StorageBase<THash> & {
|
|
44
107
|
readonly tables: Record<string, StorageTable>;
|
|
108
|
+
/**
|
|
109
|
+
* Named type instances for parameterized/custom types.
|
|
110
|
+
* Columns can reference these via `typeRef`.
|
|
111
|
+
*/
|
|
112
|
+
readonly types?: Record<string, StorageTypeInstance>;
|
|
45
113
|
};
|
|
46
114
|
|
|
47
|
-
export type
|
|
115
|
+
export type SqlModelFieldStorage = {
|
|
48
116
|
readonly column: string;
|
|
117
|
+
readonly codecId?: string;
|
|
118
|
+
readonly nullable?: boolean;
|
|
49
119
|
};
|
|
50
120
|
|
|
51
|
-
export type
|
|
121
|
+
export type SqlModelStorage = {
|
|
52
122
|
readonly table: string;
|
|
123
|
+
readonly fields: Record<string, SqlModelFieldStorage>;
|
|
53
124
|
};
|
|
54
125
|
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
126
|
+
export const DEFAULT_FK_CONSTRAINT = true;
|
|
127
|
+
export const DEFAULT_FK_INDEX = true;
|
|
128
|
+
|
|
129
|
+
export function applyFkDefaults(
|
|
130
|
+
fk: { constraint?: boolean | undefined; index?: boolean | undefined },
|
|
131
|
+
overrideDefaults?: { constraint?: boolean | undefined; index?: boolean | undefined },
|
|
132
|
+
): { constraint: boolean; index: boolean } {
|
|
133
|
+
return {
|
|
134
|
+
constraint: fk.constraint ?? overrideDefaults?.constraint ?? DEFAULT_FK_CONSTRAINT,
|
|
135
|
+
index: fk.index ?? overrideDefaults?.index ?? DEFAULT_FK_INDEX,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type TypeMaps<
|
|
140
|
+
TCodecTypes extends Record<string, { output: unknown }> = Record<string, never>,
|
|
141
|
+
TOperationTypes extends Record<string, unknown> = Record<string, never>,
|
|
142
|
+
TQueryOperationTypes extends Record<string, unknown> = Record<string, never>,
|
|
143
|
+
TFieldOutputTypes extends Record<string, Record<string, unknown>> = Record<string, never>,
|
|
144
|
+
TFieldInputTypes extends Record<string, Record<string, unknown>> = Record<string, never>,
|
|
145
|
+
> = {
|
|
146
|
+
readonly codecTypes: TCodecTypes;
|
|
147
|
+
readonly operationTypes: TOperationTypes;
|
|
148
|
+
readonly queryOperationTypes: TQueryOperationTypes;
|
|
149
|
+
readonly fieldOutputTypes: TFieldOutputTypes;
|
|
150
|
+
readonly fieldInputTypes: TFieldInputTypes;
|
|
59
151
|
};
|
|
60
152
|
|
|
61
|
-
export type
|
|
62
|
-
|
|
63
|
-
readonly
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
153
|
+
export type CodecTypesOf<T> = [T] extends [never]
|
|
154
|
+
? Record<string, never>
|
|
155
|
+
: T extends { readonly codecTypes: infer C }
|
|
156
|
+
? C extends Record<string, { output: unknown }>
|
|
157
|
+
? C
|
|
158
|
+
: Record<string, never>
|
|
159
|
+
: Record<string, never>;
|
|
160
|
+
|
|
161
|
+
export type OperationTypesOf<T> = [T] extends [never]
|
|
162
|
+
? Record<string, never>
|
|
163
|
+
: T extends { readonly operationTypes: infer O }
|
|
164
|
+
? O extends Record<string, unknown>
|
|
165
|
+
? O
|
|
166
|
+
: Record<string, never>
|
|
167
|
+
: Record<string, never>;
|
|
168
|
+
|
|
169
|
+
export type QueryOperationTypeEntry = {
|
|
170
|
+
readonly args: readonly { readonly codecId: string; readonly nullable: boolean }[];
|
|
171
|
+
readonly returns: { readonly codecId: string; readonly nullable: boolean };
|
|
68
172
|
};
|
|
69
173
|
|
|
70
|
-
export type
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
readonly
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
174
|
+
export type SqlQueryOperationTypes<T extends Record<string, QueryOperationTypeEntry>> = T;
|
|
175
|
+
|
|
176
|
+
export type QueryOperationTypesBase = Record<string, QueryOperationTypeEntry>;
|
|
177
|
+
|
|
178
|
+
export type QueryOperationTypesOf<T> = [T] extends [never]
|
|
179
|
+
? Record<string, never>
|
|
180
|
+
: T extends { readonly queryOperationTypes: infer Q }
|
|
181
|
+
? Q extends Record<string, unknown>
|
|
182
|
+
? Q
|
|
183
|
+
: Record<string, never>
|
|
184
|
+
: Record<string, never>;
|
|
185
|
+
|
|
186
|
+
export type TypeMapsPhantomKey = '__@prisma-next/sql-contract/typeMaps@__';
|
|
187
|
+
|
|
188
|
+
export type ContractWithTypeMaps<TContract, TTypeMaps> = TContract & {
|
|
189
|
+
readonly [K in TypeMapsPhantomKey]?: TTypeMaps;
|
|
81
190
|
};
|
|
82
191
|
|
|
83
|
-
export type
|
|
84
|
-
|
|
192
|
+
export type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T
|
|
193
|
+
? NonNullable<T[TypeMapsPhantomKey & keyof T]>
|
|
194
|
+
: never;
|
|
195
|
+
|
|
196
|
+
export type FieldOutputTypesOf<T> = [T] extends [never]
|
|
197
|
+
? Record<string, never>
|
|
198
|
+
: T extends { readonly fieldOutputTypes: infer F }
|
|
199
|
+
? F extends Record<string, Record<string, unknown>>
|
|
200
|
+
? F
|
|
201
|
+
: Record<string, never>
|
|
202
|
+
: Record<string, never>;
|
|
203
|
+
|
|
204
|
+
export type FieldInputTypesOf<T> = [T] extends [never]
|
|
205
|
+
? Record<string, never>
|
|
206
|
+
: T extends { readonly fieldInputTypes: infer F }
|
|
207
|
+
? F extends Record<string, Record<string, unknown>>
|
|
208
|
+
? F
|
|
209
|
+
: Record<string, never>
|
|
210
|
+
: Record<string, never>;
|
|
211
|
+
|
|
212
|
+
export type ExtractCodecTypes<T> = CodecTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
213
|
+
export type ExtractQueryOperationTypes<T> = QueryOperationTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
214
|
+
export type ExtractFieldOutputTypes<T> = FieldOutputTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
215
|
+
export type ExtractFieldInputTypes<T> = FieldInputTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
216
|
+
|
|
217
|
+
export type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never]
|
|
218
|
+
? ExtractCodecTypes<TContract>
|
|
219
|
+
: CodecTypesOf<TTypeMaps>;
|
|
85
220
|
|
|
86
|
-
export type
|
|
87
|
-
TContract['mappings']['operationTypes'];
|
|
221
|
+
export type ResolveOperationTypes<_TContract, TTypeMaps> = OperationTypesOf<TTypeMaps>;
|