@prisma-next/adapter-postgres 0.8.0 → 0.9.0-dev.2

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.
@@ -0,0 +1,314 @@
1
+ import { postgresCodecRegistry } from "@prisma-next/target-postgres/codecs";
2
+ import { PG_BIT_CODEC_ID, PG_BOOL_CODEC_ID, PG_BYTEA_CODEC_ID, PG_CHAR_CODEC_ID, PG_FLOAT4_CODEC_ID, PG_FLOAT8_CODEC_ID, PG_FLOAT_CODEC_ID, PG_INT2_CODEC_ID, PG_INT4_CODEC_ID, PG_INT8_CODEC_ID, PG_INTERVAL_CODEC_ID, PG_INT_CODEC_ID, PG_JSONB_CODEC_ID, PG_JSON_CODEC_ID, PG_NUMERIC_CODEC_ID, PG_TEXT_CODEC_ID, PG_TIMESTAMPTZ_CODEC_ID, PG_TIMESTAMP_CODEC_ID, PG_TIMETZ_CODEC_ID, PG_TIME_CODEC_ID, PG_VARBIT_CODEC_ID, PG_VARCHAR_CODEC_ID, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID } from "@prisma-next/target-postgres/codec-ids";
3
+ import { buildOperation, toExpr } from "@prisma-next/sql-relational-core/expression";
4
+ //#region src/core/descriptor-meta.ts
5
+ /** Creates a type import spec for codec types */
6
+ const codecTypeImport = (named) => ({
7
+ package: "@prisma-next/target-postgres/codec-types",
8
+ named,
9
+ alias: named
10
+ });
11
+ function isPositiveInteger(value) {
12
+ return typeof value === "number" && Number.isFinite(value) && Number.isInteger(value) && value > 0;
13
+ }
14
+ function isNonNegativeInteger(value) {
15
+ return typeof value === "number" && Number.isFinite(value) && Number.isInteger(value) && value >= 0;
16
+ }
17
+ function expandLength({ nativeType, typeParams }) {
18
+ if (!typeParams || !("length" in typeParams)) return nativeType;
19
+ const length = typeParams["length"];
20
+ if (!isPositiveInteger(length)) throw new Error(`Invalid "length" type parameter for "${nativeType}": expected a positive integer, got ${JSON.stringify(length)}`);
21
+ return `${nativeType}(${length})`;
22
+ }
23
+ function expandPrecision({ nativeType, typeParams }) {
24
+ if (!typeParams || !("precision" in typeParams)) return nativeType;
25
+ const precision = typeParams["precision"];
26
+ if (!isPositiveInteger(precision)) throw new Error(`Invalid "precision" type parameter for "${nativeType}": expected a positive integer, got ${JSON.stringify(precision)}`);
27
+ return `${nativeType}(${precision})`;
28
+ }
29
+ function expandNumeric({ nativeType, typeParams }) {
30
+ const hasPrecision = typeParams && "precision" in typeParams;
31
+ const hasScale = typeParams && "scale" in typeParams;
32
+ if (!hasPrecision && !hasScale) return nativeType;
33
+ if (!hasPrecision && hasScale) throw new Error(`Invalid type parameters for "${nativeType}": "scale" requires "precision" to be specified`);
34
+ if (hasPrecision) {
35
+ const precision = typeParams["precision"];
36
+ if (!isPositiveInteger(precision)) throw new Error(`Invalid "precision" type parameter for "${nativeType}": expected a positive integer, got ${JSON.stringify(precision)}`);
37
+ if (hasScale) {
38
+ const scale = typeParams["scale"];
39
+ if (!isNonNegativeInteger(scale)) throw new Error(`Invalid "scale" type parameter for "${nativeType}": expected a non-negative integer, got ${JSON.stringify(scale)}`);
40
+ return `${nativeType}(${precision},${scale})`;
41
+ }
42
+ return `${nativeType}(${precision})`;
43
+ }
44
+ return nativeType;
45
+ }
46
+ const lengthHooks = { expandNativeType: expandLength };
47
+ const precisionHooks = { expandNativeType: expandPrecision };
48
+ const numericHooks = { expandNativeType: expandNumeric };
49
+ const identityHooks = { expandNativeType: ({ nativeType }) => nativeType };
50
+ function postgresQueryOperations() {
51
+ return { ilike: {
52
+ self: { traits: ["textual"] },
53
+ impl: (self, pattern) => {
54
+ return buildOperation({
55
+ method: "ilike",
56
+ args: [toExpr(self), toExpr(pattern, { codecId: PG_TEXT_CODEC_ID })],
57
+ returns: {
58
+ codecId: PG_BOOL_CODEC_ID,
59
+ nullable: false
60
+ },
61
+ lowering: {
62
+ targetFamily: "sql",
63
+ strategy: "infix",
64
+ template: "{{self}} ILIKE {{arg0}}"
65
+ }
66
+ });
67
+ }
68
+ } };
69
+ }
70
+ const postgresAdapterDescriptorMeta = {
71
+ kind: "adapter",
72
+ familyId: "sql",
73
+ targetId: "postgres",
74
+ id: "postgres",
75
+ version: "0.0.1",
76
+ capabilities: {
77
+ postgres: {
78
+ orderBy: true,
79
+ limit: true,
80
+ lateral: true,
81
+ jsonAgg: true,
82
+ returning: true
83
+ },
84
+ sql: {
85
+ enums: true,
86
+ returning: true,
87
+ defaultInInsert: true
88
+ }
89
+ },
90
+ types: {
91
+ codecTypes: {
92
+ codecDescriptors: Array.from(postgresCodecRegistry.values()),
93
+ import: {
94
+ package: "@prisma-next/target-postgres/codec-types",
95
+ named: "CodecTypes",
96
+ alias: "PgTypes"
97
+ },
98
+ typeImports: [
99
+ {
100
+ package: "@prisma-next/target-postgres/codec-types",
101
+ named: "JsonValue",
102
+ alias: "JsonValue"
103
+ },
104
+ codecTypeImport("Char"),
105
+ codecTypeImport("Varchar"),
106
+ codecTypeImport("Numeric"),
107
+ codecTypeImport("Bit"),
108
+ codecTypeImport("VarBit"),
109
+ codecTypeImport("Timestamp"),
110
+ codecTypeImport("Timestamptz"),
111
+ codecTypeImport("Time"),
112
+ codecTypeImport("Timetz"),
113
+ codecTypeImport("Interval")
114
+ ],
115
+ controlPlaneHooks: {
116
+ [SQL_CHAR_CODEC_ID]: lengthHooks,
117
+ [SQL_VARCHAR_CODEC_ID]: lengthHooks,
118
+ [SQL_TIMESTAMP_CODEC_ID]: precisionHooks,
119
+ [PG_CHAR_CODEC_ID]: lengthHooks,
120
+ [PG_VARCHAR_CODEC_ID]: lengthHooks,
121
+ [PG_NUMERIC_CODEC_ID]: numericHooks,
122
+ [PG_BIT_CODEC_ID]: lengthHooks,
123
+ [PG_VARBIT_CODEC_ID]: lengthHooks,
124
+ [PG_TIMESTAMP_CODEC_ID]: precisionHooks,
125
+ [PG_TIMESTAMPTZ_CODEC_ID]: precisionHooks,
126
+ [PG_TIME_CODEC_ID]: precisionHooks,
127
+ [PG_TIMETZ_CODEC_ID]: precisionHooks,
128
+ [PG_INTERVAL_CODEC_ID]: precisionHooks,
129
+ [PG_JSON_CODEC_ID]: identityHooks,
130
+ [PG_JSONB_CODEC_ID]: identityHooks,
131
+ [PG_BYTEA_CODEC_ID]: identityHooks
132
+ }
133
+ },
134
+ storage: [
135
+ {
136
+ typeId: PG_TEXT_CODEC_ID,
137
+ familyId: "sql",
138
+ targetId: "postgres",
139
+ nativeType: "text"
140
+ },
141
+ {
142
+ typeId: SQL_TEXT_CODEC_ID,
143
+ familyId: "sql",
144
+ targetId: "postgres",
145
+ nativeType: "text"
146
+ },
147
+ {
148
+ typeId: SQL_CHAR_CODEC_ID,
149
+ familyId: "sql",
150
+ targetId: "postgres",
151
+ nativeType: "character"
152
+ },
153
+ {
154
+ typeId: SQL_VARCHAR_CODEC_ID,
155
+ familyId: "sql",
156
+ targetId: "postgres",
157
+ nativeType: "character varying"
158
+ },
159
+ {
160
+ typeId: SQL_INT_CODEC_ID,
161
+ familyId: "sql",
162
+ targetId: "postgres",
163
+ nativeType: "int4"
164
+ },
165
+ {
166
+ typeId: SQL_FLOAT_CODEC_ID,
167
+ familyId: "sql",
168
+ targetId: "postgres",
169
+ nativeType: "float8"
170
+ },
171
+ {
172
+ typeId: SQL_TIMESTAMP_CODEC_ID,
173
+ familyId: "sql",
174
+ targetId: "postgres",
175
+ nativeType: "timestamp"
176
+ },
177
+ {
178
+ typeId: PG_CHAR_CODEC_ID,
179
+ familyId: "sql",
180
+ targetId: "postgres",
181
+ nativeType: "character"
182
+ },
183
+ {
184
+ typeId: PG_VARCHAR_CODEC_ID,
185
+ familyId: "sql",
186
+ targetId: "postgres",
187
+ nativeType: "character varying"
188
+ },
189
+ {
190
+ typeId: PG_INT_CODEC_ID,
191
+ familyId: "sql",
192
+ targetId: "postgres",
193
+ nativeType: "int4"
194
+ },
195
+ {
196
+ typeId: PG_FLOAT_CODEC_ID,
197
+ familyId: "sql",
198
+ targetId: "postgres",
199
+ nativeType: "float8"
200
+ },
201
+ {
202
+ typeId: PG_INT4_CODEC_ID,
203
+ familyId: "sql",
204
+ targetId: "postgres",
205
+ nativeType: "int4"
206
+ },
207
+ {
208
+ typeId: PG_INT2_CODEC_ID,
209
+ familyId: "sql",
210
+ targetId: "postgres",
211
+ nativeType: "int2"
212
+ },
213
+ {
214
+ typeId: PG_INT8_CODEC_ID,
215
+ familyId: "sql",
216
+ targetId: "postgres",
217
+ nativeType: "int8"
218
+ },
219
+ {
220
+ typeId: PG_FLOAT4_CODEC_ID,
221
+ familyId: "sql",
222
+ targetId: "postgres",
223
+ nativeType: "float4"
224
+ },
225
+ {
226
+ typeId: PG_FLOAT8_CODEC_ID,
227
+ familyId: "sql",
228
+ targetId: "postgres",
229
+ nativeType: "float8"
230
+ },
231
+ {
232
+ typeId: PG_NUMERIC_CODEC_ID,
233
+ familyId: "sql",
234
+ targetId: "postgres",
235
+ nativeType: "numeric"
236
+ },
237
+ {
238
+ typeId: PG_TIMESTAMP_CODEC_ID,
239
+ familyId: "sql",
240
+ targetId: "postgres",
241
+ nativeType: "timestamp"
242
+ },
243
+ {
244
+ typeId: PG_TIMESTAMPTZ_CODEC_ID,
245
+ familyId: "sql",
246
+ targetId: "postgres",
247
+ nativeType: "timestamptz"
248
+ },
249
+ {
250
+ typeId: PG_TIME_CODEC_ID,
251
+ familyId: "sql",
252
+ targetId: "postgres",
253
+ nativeType: "time"
254
+ },
255
+ {
256
+ typeId: PG_TIMETZ_CODEC_ID,
257
+ familyId: "sql",
258
+ targetId: "postgres",
259
+ nativeType: "timetz"
260
+ },
261
+ {
262
+ typeId: PG_BOOL_CODEC_ID,
263
+ familyId: "sql",
264
+ targetId: "postgres",
265
+ nativeType: "bool"
266
+ },
267
+ {
268
+ typeId: PG_BIT_CODEC_ID,
269
+ familyId: "sql",
270
+ targetId: "postgres",
271
+ nativeType: "bit"
272
+ },
273
+ {
274
+ typeId: PG_VARBIT_CODEC_ID,
275
+ familyId: "sql",
276
+ targetId: "postgres",
277
+ nativeType: "bit varying"
278
+ },
279
+ {
280
+ typeId: PG_INTERVAL_CODEC_ID,
281
+ familyId: "sql",
282
+ targetId: "postgres",
283
+ nativeType: "interval"
284
+ },
285
+ {
286
+ typeId: PG_JSON_CODEC_ID,
287
+ familyId: "sql",
288
+ targetId: "postgres",
289
+ nativeType: "json"
290
+ },
291
+ {
292
+ typeId: PG_JSONB_CODEC_ID,
293
+ familyId: "sql",
294
+ targetId: "postgres",
295
+ nativeType: "jsonb"
296
+ },
297
+ {
298
+ typeId: PG_BYTEA_CODEC_ID,
299
+ familyId: "sql",
300
+ targetId: "postgres",
301
+ nativeType: "bytea"
302
+ }
303
+ ],
304
+ queryOperationTypes: { import: {
305
+ package: "@prisma-next/adapter-postgres/operation-types",
306
+ named: "QueryOperationTypes",
307
+ alias: "PgAdapterQueryOps"
308
+ } }
309
+ }
310
+ };
311
+ //#endregion
312
+ export { postgresQueryOperations as n, postgresAdapterDescriptorMeta as t };
313
+
314
+ //# sourceMappingURL=descriptor-meta-ZIv9PU-5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor-meta-ZIv9PU-5.mjs","names":[],"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["import type { CodecControlHooks, ExpandNativeTypeInput } from '@prisma-next/family-sql/control';\nimport {\n buildOperation,\n type CodecExpression,\n type Expression,\n type TraitExpression,\n toExpr,\n} from '@prisma-next/sql-relational-core/expression';\nimport {\n PG_BIT_CODEC_ID,\n PG_BOOL_CODEC_ID,\n PG_BYTEA_CODEC_ID,\n PG_CHAR_CODEC_ID,\n PG_FLOAT_CODEC_ID,\n PG_FLOAT4_CODEC_ID,\n PG_FLOAT8_CODEC_ID,\n PG_INT_CODEC_ID,\n PG_INT2_CODEC_ID,\n PG_INT4_CODEC_ID,\n PG_INT8_CODEC_ID,\n PG_INTERVAL_CODEC_ID,\n PG_JSON_CODEC_ID,\n PG_JSONB_CODEC_ID,\n PG_NUMERIC_CODEC_ID,\n PG_TEXT_CODEC_ID,\n PG_TIME_CODEC_ID,\n PG_TIMESTAMP_CODEC_ID,\n PG_TIMESTAMPTZ_CODEC_ID,\n PG_TIMETZ_CODEC_ID,\n PG_VARBIT_CODEC_ID,\n PG_VARCHAR_CODEC_ID,\n SQL_CHAR_CODEC_ID,\n SQL_FLOAT_CODEC_ID,\n SQL_INT_CODEC_ID,\n SQL_TEXT_CODEC_ID,\n SQL_TIMESTAMP_CODEC_ID,\n SQL_VARCHAR_CODEC_ID,\n} from '@prisma-next/target-postgres/codec-ids';\nimport { postgresCodecRegistry } from '@prisma-next/target-postgres/codecs';\nimport type { QueryOperationTypes } from '../types/operation-types';\n\n// ============================================================================ Helper functions for reducing boilerplate ============================================================================\n\n/** Creates a type import spec for codec types */\nconst codecTypeImport = (named: string) =>\n ({\n package: '@prisma-next/target-postgres/codec-types',\n named,\n alias: named,\n }) as const;\n\nfunction isPositiveInteger(value: unknown): value is number {\n return (\n typeof value === 'number' && Number.isFinite(value) && Number.isInteger(value) && value > 0\n );\n}\n\nfunction isNonNegativeInteger(value: unknown): value is number {\n return (\n typeof value === 'number' && Number.isFinite(value) && Number.isInteger(value) && value >= 0\n );\n}\n\nfunction expandLength({ nativeType, typeParams }: ExpandNativeTypeInput): string {\n if (!typeParams || !('length' in typeParams)) {\n return nativeType;\n }\n const length = typeParams['length'];\n if (!isPositiveInteger(length)) {\n throw new Error(\n `Invalid \"length\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(length)}`,\n );\n }\n return `${nativeType}(${length})`;\n}\n\nfunction expandPrecision({ nativeType, typeParams }: ExpandNativeTypeInput): string {\n if (!typeParams || !('precision' in typeParams)) {\n return nativeType;\n }\n const precision = typeParams['precision'];\n if (!isPositiveInteger(precision)) {\n throw new Error(\n `Invalid \"precision\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(precision)}`,\n );\n }\n return `${nativeType}(${precision})`;\n}\n\nfunction expandNumeric({ nativeType, typeParams }: ExpandNativeTypeInput): string {\n const hasPrecision = typeParams && 'precision' in typeParams;\n const hasScale = typeParams && 'scale' in typeParams;\n\n if (!hasPrecision && !hasScale) {\n return nativeType;\n }\n\n if (!hasPrecision && hasScale) {\n throw new Error(\n `Invalid type parameters for \"${nativeType}\": \"scale\" requires \"precision\" to be specified`,\n );\n }\n\n if (hasPrecision) {\n const precision = typeParams['precision'];\n if (!isPositiveInteger(precision)) {\n throw new Error(\n `Invalid \"precision\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(precision)}`,\n );\n }\n if (hasScale) {\n const scale = typeParams['scale'];\n if (!isNonNegativeInteger(scale)) {\n throw new Error(\n `Invalid \"scale\" type parameter for \"${nativeType}\": expected a non-negative integer, got ${JSON.stringify(scale)}`,\n );\n }\n return `${nativeType}(${precision},${scale})`;\n }\n return `${nativeType}(${precision})`;\n }\n\n return nativeType;\n}\n\nconst lengthHooks: CodecControlHooks = { expandNativeType: expandLength };\nconst precisionHooks: CodecControlHooks = { expandNativeType: expandPrecision };\nconst numericHooks: CodecControlHooks = { expandNativeType: expandNumeric };\nconst identityHooks: CodecControlHooks = { expandNativeType: ({ nativeType }) => nativeType };\n\n// ============================================================================ Descriptor metadata ============================================================================\n\ntype CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;\n\nexport function postgresQueryOperations<CT extends CodecTypesBase>(): QueryOperationTypes<CT> {\n return {\n ilike: {\n self: { traits: ['textual'] },\n impl: (\n self: TraitExpression<readonly ['textual'], false, CT>,\n pattern: CodecExpression<'pg/text@1', false, CT>,\n ): Expression<{ codecId: 'pg/bool@1'; nullable: false }> => {\n return buildOperation({\n method: 'ilike',\n args: [toExpr(self), toExpr(pattern, { codecId: PG_TEXT_CODEC_ID })],\n returns: { codecId: PG_BOOL_CODEC_ID, nullable: false },\n lowering: { targetFamily: 'sql', strategy: 'infix', template: '{{self}} ILIKE {{arg0}}' },\n });\n },\n },\n };\n}\n\nexport const postgresAdapterDescriptorMeta = {\n kind: 'adapter',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n orderBy: true,\n limit: true,\n lateral: true,\n jsonAgg: true,\n returning: true,\n },\n sql: {\n enums: true,\n returning: true,\n defaultInInsert: true,\n },\n },\n types: {\n codecTypes: {\n codecDescriptors: Array.from(postgresCodecRegistry.values()),\n import: {\n package: '@prisma-next/target-postgres/codec-types',\n named: 'CodecTypes',\n alias: 'PgTypes',\n },\n typeImports: [\n {\n package: '@prisma-next/target-postgres/codec-types',\n named: 'JsonValue',\n alias: 'JsonValue',\n },\n codecTypeImport('Char'),\n codecTypeImport('Varchar'),\n codecTypeImport('Numeric'),\n codecTypeImport('Bit'),\n codecTypeImport('VarBit'),\n codecTypeImport('Timestamp'),\n codecTypeImport('Timestamptz'),\n codecTypeImport('Time'),\n codecTypeImport('Timetz'),\n codecTypeImport('Interval'),\n ],\n controlPlaneHooks: {\n [SQL_CHAR_CODEC_ID]: lengthHooks,\n [SQL_VARCHAR_CODEC_ID]: lengthHooks,\n [SQL_TIMESTAMP_CODEC_ID]: precisionHooks,\n [PG_CHAR_CODEC_ID]: lengthHooks,\n [PG_VARCHAR_CODEC_ID]: lengthHooks,\n [PG_NUMERIC_CODEC_ID]: numericHooks,\n [PG_BIT_CODEC_ID]: lengthHooks,\n [PG_VARBIT_CODEC_ID]: lengthHooks,\n [PG_TIMESTAMP_CODEC_ID]: precisionHooks,\n [PG_TIMESTAMPTZ_CODEC_ID]: precisionHooks,\n [PG_TIME_CODEC_ID]: precisionHooks,\n [PG_TIMETZ_CODEC_ID]: precisionHooks,\n [PG_INTERVAL_CODEC_ID]: precisionHooks,\n [PG_JSON_CODEC_ID]: identityHooks,\n [PG_JSONB_CODEC_ID]: identityHooks,\n [PG_BYTEA_CODEC_ID]: identityHooks,\n },\n },\n storage: [\n { typeId: PG_TEXT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'text' },\n { typeId: SQL_TEXT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'text' },\n { typeId: SQL_CHAR_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'character' },\n {\n typeId: SQL_VARCHAR_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'character varying',\n },\n { typeId: SQL_INT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: SQL_FLOAT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n {\n typeId: SQL_TIMESTAMP_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamp',\n },\n { typeId: PG_CHAR_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'character' },\n {\n typeId: PG_VARCHAR_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'character varying',\n },\n { typeId: PG_INT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: PG_FLOAT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n { typeId: PG_INT4_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: PG_INT2_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int2' },\n { typeId: PG_INT8_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int8' },\n { typeId: PG_FLOAT4_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float4' },\n { typeId: PG_FLOAT8_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n { typeId: PG_NUMERIC_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'numeric' },\n {\n typeId: PG_TIMESTAMP_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamp',\n },\n {\n typeId: PG_TIMESTAMPTZ_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamptz',\n },\n { typeId: PG_TIME_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'time' },\n { typeId: PG_TIMETZ_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'timetz' },\n { typeId: PG_BOOL_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'bool' },\n { typeId: PG_BIT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'bit' },\n {\n typeId: PG_VARBIT_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'bit varying',\n },\n {\n typeId: PG_INTERVAL_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'interval',\n },\n { typeId: PG_JSON_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'json' },\n { typeId: PG_JSONB_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'jsonb' },\n { typeId: PG_BYTEA_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'bytea' },\n ],\n queryOperationTypes: {\n import: {\n package: '@prisma-next/adapter-postgres/operation-types',\n named: 'QueryOperationTypes',\n alias: 'PgAdapterQueryOps',\n },\n },\n },\n} as const;\n"],"mappings":";;;;;AA4CA,MAAM,mBAAmB,WACtB;CACC,SAAS;CACT;CACA,OAAO;CACR;AAEH,SAAS,kBAAkB,OAAiC;CAC1D,OACE,OAAO,UAAU,YAAY,OAAO,SAAS,MAAM,IAAI,OAAO,UAAU,MAAM,IAAI,QAAQ;;AAI9F,SAAS,qBAAqB,OAAiC;CAC7D,OACE,OAAO,UAAU,YAAY,OAAO,SAAS,MAAM,IAAI,OAAO,UAAU,MAAM,IAAI,SAAS;;AAI/F,SAAS,aAAa,EAAE,YAAY,cAA6C;CAC/E,IAAI,CAAC,cAAc,EAAE,YAAY,aAC/B,OAAO;CAET,MAAM,SAAS,WAAW;CAC1B,IAAI,CAAC,kBAAkB,OAAO,EAC5B,MAAM,I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U;IAAY,YAAY;IAAQ;GACvF;IAAE,QAAQ;IAAiB,UAAU;IAAO,UAAU;IAAY,YAAY;IAAO;GACrF;IACE,QAAQ;IACR,UAAU;IACV,UAAU;IACV,YAAY;IACb;GACD;IACE,QAAQ;IACR,UAAU;IACV,UAAU;IACV,YAAY;IACb;GACD;IAAE,QAAQ;IAAkB,UAAU;IAAO,UAAU;IAAY,YAAY;IAAQ;GACvF;IAAE,QAAQ;IAAmB,UAAU;IAAO,UAAU;IAAY,YAAY;IAAS;GACzF;IAAE,QAAQ;IAAmB,UAAU;IAAO,UAAU;IAAY,YAAY;IAAS;GAC1F;EACD,qBAAqB,EACnB,QAAQ;GACN,SAAS;GACT,OAAO;GACP,OAAO;GACR,EACF;EACF;CACF"}
package/dist/runtime.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as createPostgresAdapter } from "./adapter-BFQQweRI.mjs";
2
- import { n as postgresQueryOperations, t as postgresAdapterDescriptorMeta } from "./descriptor-meta-DvzAuIyE.mjs";
2
+ import { n as postgresQueryOperations, t as postgresAdapterDescriptorMeta } from "./descriptor-meta-ZIv9PU-5.mjs";
3
3
  import { extractCodecLookup } from "@prisma-next/framework-components/control";
4
4
  import { postgresCodecRegistry } from "@prisma-next/target-postgres/codecs";
5
5
  import { builtinGeneratorIds } from "@prisma-next/ids";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma-next/adapter-postgres",
3
- "version": "0.8.0",
3
+ "version": "0.9.0-dev.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -9,30 +9,30 @@
9
9
  "src"
10
10
  ],
11
11
  "dependencies": {
12
- "@prisma-next/contract": "0.8.0",
13
- "@prisma-next/contract-authoring": "0.8.0",
14
- "@prisma-next/family-sql": "0.8.0",
15
- "@prisma-next/framework-components": "0.8.0",
16
- "@prisma-next/ids": "0.8.0",
17
- "@prisma-next/sql-contract": "0.8.0",
18
- "@prisma-next/sql-contract-psl": "0.8.0",
19
- "@prisma-next/sql-contract-ts": "0.8.0",
20
- "@prisma-next/sql-operations": "0.8.0",
21
- "@prisma-next/sql-relational-core": "0.8.0",
22
- "@prisma-next/sql-runtime": "0.8.0",
23
- "@prisma-next/sql-schema-ir": "0.8.0",
24
- "@prisma-next/target-postgres": "0.8.0",
25
- "@prisma-next/utils": "0.8.0",
12
+ "@prisma-next/contract": "0.9.0-dev.2",
13
+ "@prisma-next/contract-authoring": "0.9.0-dev.2",
14
+ "@prisma-next/family-sql": "0.9.0-dev.2",
15
+ "@prisma-next/framework-components": "0.9.0-dev.2",
16
+ "@prisma-next/ids": "0.9.0-dev.2",
17
+ "@prisma-next/sql-contract": "0.9.0-dev.2",
18
+ "@prisma-next/sql-contract-psl": "0.9.0-dev.2",
19
+ "@prisma-next/sql-contract-ts": "0.9.0-dev.2",
20
+ "@prisma-next/sql-operations": "0.9.0-dev.2",
21
+ "@prisma-next/sql-relational-core": "0.9.0-dev.2",
22
+ "@prisma-next/sql-runtime": "0.9.0-dev.2",
23
+ "@prisma-next/sql-schema-ir": "0.9.0-dev.2",
24
+ "@prisma-next/target-postgres": "0.9.0-dev.2",
25
+ "@prisma-next/utils": "0.9.0-dev.2",
26
26
  "arktype": "^2.1.29"
27
27
  },
28
28
  "devDependencies": {
29
- "@prisma-next/cli": "0.8.0",
30
- "@prisma-next/driver-postgres": "0.8.0",
31
- "@prisma-next/errors": "0.8.0",
32
- "@prisma-next/migration-tools": "0.8.0",
33
- "@prisma-next/test-utils": "0.8.0",
34
- "@prisma-next/tsconfig": "0.8.0",
35
- "@prisma-next/tsdown": "0.8.0",
29
+ "@prisma-next/cli": "0.9.0-dev.2",
30
+ "@prisma-next/driver-postgres": "0.9.0-dev.2",
31
+ "@prisma-next/errors": "0.9.0-dev.2",
32
+ "@prisma-next/migration-tools": "0.9.0-dev.2",
33
+ "@prisma-next/test-utils": "0.9.0-dev.2",
34
+ "@prisma-next/tsconfig": "0.9.0-dev.2",
35
+ "@prisma-next/tsdown": "0.9.0-dev.2",
36
36
  "pathe": "^2.0.3",
37
37
  "tsdown": "0.22.0",
38
38
  "typescript": "5.9.3",
@@ -3,6 +3,7 @@ import type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter'
3
3
  import { parseContractMarkerRow } from '@prisma-next/family-sql/verify';
4
4
  import type { CodecLookup } from '@prisma-next/framework-components/codec';
5
5
  import type { ControlDriverInstance } from '@prisma-next/framework-components/control';
6
+ import type { PostgresEnumStorageEntry } from '@prisma-next/sql-contract/types';
6
7
  import type {
7
8
  AnyQueryAst,
8
9
  LoweredStatement,
@@ -19,10 +20,11 @@ import type {
19
20
  SqlUniqueIR,
20
21
  } from '@prisma-next/sql-schema-ir/types';
21
22
  import { parsePostgresDefault } from '@prisma-next/target-postgres/default-normalizer';
23
+ import { readExistingEnumValues } from '@prisma-next/target-postgres/enum-planning';
22
24
  import { normalizeSchemaNativeType } from '@prisma-next/target-postgres/native-type-normalizer';
23
25
  import { ifDefined } from '@prisma-next/utils/defined';
24
26
  import { createPostgresBuiltinCodecLookup } from './codec-lookup';
25
- import { pgEnumControlHooks } from './enum-control-hooks';
27
+ import { introspectPostgresEnumTypes } from './enum-control-hooks';
26
28
  import { renderLoweredSql } from './sql-renderer';
27
29
  import type { PostgresContract } from './types';
28
30
 
@@ -60,6 +62,17 @@ export class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
60
62
  */
61
63
  readonly normalizeNativeType = normalizeSchemaNativeType;
62
64
 
65
+ /**
66
+ * Bridges native `PostgresEnumStorageEntry` IR walks against the Postgres
67
+ * introspection shape (`schema.annotations.pg.storageTypes`). Lets
68
+ * the family-level schema verifier walk enum types without reaching
69
+ * into target-specific annotation layouts itself.
70
+ */
71
+ readonly resolveExistingEnumValues = (
72
+ schema: SqlSchemaIR,
73
+ enumType: PostgresEnumStorageEntry,
74
+ ): readonly string[] | null => readExistingEnumValues(schema, enumType.nativeType);
75
+
63
76
  /**
64
77
  * Lower a SQL query AST into a Postgres-flavored `{ sql, params }` payload.
65
78
  *
@@ -573,8 +586,7 @@ export class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
573
586
  };
574
587
  }
575
588
 
576
- const storageTypes =
577
- (await pgEnumControlHooks.introspectTypes?.({ driver, schemaName: schema })) ?? {};
589
+ const storageTypes = await introspectPostgresEnumTypes({ driver, schemaName: schema });
578
590
 
579
591
  const annotations = {
580
592
  pg: {
@@ -11,7 +11,6 @@ import {
11
11
  PG_BOOL_CODEC_ID,
12
12
  PG_BYTEA_CODEC_ID,
13
13
  PG_CHAR_CODEC_ID,
14
- PG_ENUM_CODEC_ID,
15
14
  PG_FLOAT_CODEC_ID,
16
15
  PG_FLOAT4_CODEC_ID,
17
16
  PG_FLOAT8_CODEC_ID,
@@ -39,7 +38,6 @@ import {
39
38
  } from '@prisma-next/target-postgres/codec-ids';
40
39
  import { postgresCodecRegistry } from '@prisma-next/target-postgres/codecs';
41
40
  import type { QueryOperationTypes } from '../types/operation-types';
42
- import { pgEnumControlHooks } from './enum-control-hooks';
43
41
 
44
42
  // ============================================================================ Helper functions for reducing boilerplate ============================================================================
45
43
 
@@ -212,7 +210,6 @@ export const postgresAdapterDescriptorMeta = {
212
210
  [PG_TIME_CODEC_ID]: precisionHooks,
213
211
  [PG_TIMETZ_CODEC_ID]: precisionHooks,
214
212
  [PG_INTERVAL_CODEC_ID]: precisionHooks,
215
- [PG_ENUM_CODEC_ID]: pgEnumControlHooks,
216
213
  [PG_JSON_CODEC_ID]: identityHooks,
217
214
  [PG_JSONB_CODEC_ID]: identityHooks,
218
215
  [PG_BYTEA_CODEC_ID]: identityHooks,