@prisma-next/adapter-postgres 0.16.0-dev.3 → 0.16.0-dev.31
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/{adapter-BaZsfXGA.mjs → adapter-DlDJIHgB.mjs} +4 -4
- package/dist/adapter-DlDJIHgB.mjs.map +1 -0
- package/dist/adapter.d.mts.map +1 -1
- package/dist/adapter.mjs +1 -1
- package/dist/{control-adapter-B6IM_oTR.mjs → control-adapter-DKbwTazN.mjs} +164 -58
- package/dist/control-adapter-DKbwTazN.mjs.map +1 -0
- package/dist/control.d.mts +2 -2
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +269 -34
- package/dist/control.mjs.map +1 -1
- package/dist/{descriptor-meta-jMtx881n.mjs → descriptor-meta-pc7bA0_C.mjs} +26 -6
- package/dist/descriptor-meta-pc7bA0_C.mjs.map +1 -0
- package/dist/runtime.mjs +3 -3
- package/dist/runtime.mjs.map +1 -1
- package/package.json +23 -23
- package/src/core/adapter-errors.ts +25 -0
- package/src/core/adapter.ts +7 -2
- package/src/core/control-adapter.ts +140 -62
- package/src/core/control-codecs.ts +4 -1
- package/src/core/control-mutation-defaults.ts +134 -34
- package/src/core/descriptor-meta.ts +16 -5
- package/src/core/sql-renderer.ts +136 -34
- package/src/exports/control.ts +3 -4
- package/src/exports/runtime.ts +1 -1
- package/dist/adapter-BaZsfXGA.mjs.map +0 -1
- package/dist/control-adapter-B6IM_oTR.mjs.map +0 -1
- package/dist/descriptor-meta-jMtx881n.mjs.map +0 -1
package/dist/control.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { r as createPostgresBuiltinCodecLookup, t as PostgresControlAdapter } from "./control-adapter-
|
|
2
|
-
import { t as postgresAdapterDescriptorMeta } from "./descriptor-meta-
|
|
1
|
+
import { r as createPostgresBuiltinCodecLookup, t as PostgresControlAdapter } from "./control-adapter-DKbwTazN.mjs";
|
|
2
|
+
import { t as postgresAdapterDescriptorMeta } from "./descriptor-meta-pc7bA0_C.mjs";
|
|
3
3
|
import { parsePostgresDefault } from "@prisma-next/target-postgres/default-normalizer";
|
|
4
4
|
import { normalizeSchemaNativeType } from "@prisma-next/target-postgres/native-type-normalizer";
|
|
5
|
-
import {
|
|
5
|
+
import { escapeLiteral, qualifyName, quoteIdentifier } from "@prisma-next/target-postgres/sql-utils";
|
|
6
6
|
import { timestampNowControlDescriptor } from "@prisma-next/family-sql/control";
|
|
7
|
-
import { builtinGeneratorRegistryMetadata
|
|
7
|
+
import { builtinGeneratorRegistryMetadata } from "@prisma-next/ids";
|
|
8
8
|
import { int, num, oneOf, optional, str } from "@prisma-next/psl-parser";
|
|
9
9
|
//#region src/core/control-mutation-defaults.ts
|
|
10
10
|
function invalidArgumentDiagnostic(input) {
|
|
@@ -149,47 +149,282 @@ const postgresDefaultFunctionRegistryEntries = [
|
|
|
149
149
|
usageSignatures: ["dbgenerated(\"...\")"]
|
|
150
150
|
}]
|
|
151
151
|
];
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
152
|
+
/**
|
|
153
|
+
* The base PSL scalars as zero-arg type constructors in the unified authoring
|
|
154
|
+
* channel, with explicit `nativeType` values pinned to the codec manifests
|
|
155
|
+
* (`codecLookup.targetTypesFor(codecId)[0]`).
|
|
156
|
+
*
|
|
157
|
+
* The type position is the only storage decider: a mutation-default generator
|
|
158
|
+
* (`@default(uuid())`) never re-picks a column's storage.
|
|
159
|
+
*/
|
|
160
|
+
const postgresScalarAuthoringTypes = {
|
|
161
|
+
String: {
|
|
162
|
+
kind: "typeConstructor",
|
|
163
|
+
output: {
|
|
164
|
+
codecId: "pg/text@1",
|
|
165
|
+
nativeType: "text"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
Boolean: {
|
|
169
|
+
kind: "typeConstructor",
|
|
170
|
+
output: {
|
|
171
|
+
codecId: "pg/bool@1",
|
|
172
|
+
nativeType: "bool"
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
Int: {
|
|
176
|
+
kind: "typeConstructor",
|
|
177
|
+
output: {
|
|
178
|
+
codecId: "pg/int4@1",
|
|
179
|
+
nativeType: "int4"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
BigInt: {
|
|
183
|
+
kind: "typeConstructor",
|
|
184
|
+
output: {
|
|
185
|
+
codecId: "pg/int8@1",
|
|
186
|
+
nativeType: "int8"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
Float: {
|
|
190
|
+
kind: "typeConstructor",
|
|
191
|
+
output: {
|
|
192
|
+
codecId: "pg/float8@1",
|
|
193
|
+
nativeType: "float8"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
Decimal: {
|
|
197
|
+
kind: "typeConstructor",
|
|
198
|
+
output: {
|
|
199
|
+
codecId: "pg/numeric@1",
|
|
200
|
+
nativeType: "numeric"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
DateTime: {
|
|
204
|
+
kind: "typeConstructor",
|
|
205
|
+
output: {
|
|
206
|
+
codecId: "pg/timestamptz@1",
|
|
207
|
+
nativeType: "timestamptz"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
Json: {
|
|
211
|
+
kind: "typeConstructor",
|
|
212
|
+
output: {
|
|
213
|
+
codecId: "pg/json@1",
|
|
214
|
+
nativeType: "json"
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
Jsonb: {
|
|
218
|
+
kind: "typeConstructor",
|
|
219
|
+
output: {
|
|
220
|
+
codecId: "pg/jsonb@1",
|
|
221
|
+
nativeType: "jsonb"
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
Bytes: {
|
|
225
|
+
kind: "typeConstructor",
|
|
226
|
+
output: {
|
|
227
|
+
codecId: "pg/bytea@1",
|
|
228
|
+
nativeType: "bytea"
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const postgresNativeAuthoringTypes = {
|
|
233
|
+
VarChar: {
|
|
234
|
+
kind: "typeConstructor",
|
|
235
|
+
args: [{
|
|
236
|
+
kind: "number",
|
|
237
|
+
name: "length",
|
|
238
|
+
integer: true,
|
|
239
|
+
minimum: 1,
|
|
240
|
+
optional: true
|
|
241
|
+
}],
|
|
242
|
+
output: {
|
|
243
|
+
codecId: "sql/varchar@1",
|
|
244
|
+
nativeType: "character varying",
|
|
245
|
+
typeParams: { length: {
|
|
246
|
+
kind: "arg",
|
|
247
|
+
index: 0
|
|
248
|
+
} }
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
Char: {
|
|
252
|
+
kind: "typeConstructor",
|
|
253
|
+
args: [{
|
|
254
|
+
kind: "number",
|
|
255
|
+
name: "length",
|
|
256
|
+
integer: true,
|
|
257
|
+
minimum: 1,
|
|
258
|
+
optional: true
|
|
259
|
+
}],
|
|
260
|
+
output: {
|
|
261
|
+
codecId: "sql/char@1",
|
|
262
|
+
nativeType: "character",
|
|
263
|
+
typeParams: { length: {
|
|
264
|
+
kind: "arg",
|
|
265
|
+
index: 0
|
|
266
|
+
} }
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
Numeric: {
|
|
270
|
+
kind: "typeConstructor",
|
|
271
|
+
args: [{
|
|
272
|
+
kind: "number",
|
|
273
|
+
name: "precision",
|
|
274
|
+
integer: true,
|
|
275
|
+
minimum: 1,
|
|
276
|
+
optional: true
|
|
277
|
+
}, {
|
|
278
|
+
kind: "number",
|
|
279
|
+
name: "scale",
|
|
280
|
+
integer: true,
|
|
281
|
+
minimum: 0,
|
|
282
|
+
optional: true
|
|
283
|
+
}],
|
|
284
|
+
output: {
|
|
285
|
+
codecId: "pg/numeric@1",
|
|
286
|
+
nativeType: "numeric",
|
|
287
|
+
typeParams: {
|
|
288
|
+
precision: {
|
|
289
|
+
kind: "arg",
|
|
290
|
+
index: 0
|
|
291
|
+
},
|
|
292
|
+
scale: {
|
|
293
|
+
kind: "arg",
|
|
294
|
+
index: 1
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
Timestamp: {
|
|
300
|
+
kind: "typeConstructor",
|
|
301
|
+
args: [{
|
|
302
|
+
kind: "number",
|
|
303
|
+
name: "precision",
|
|
304
|
+
integer: true,
|
|
305
|
+
minimum: 0,
|
|
306
|
+
optional: true
|
|
307
|
+
}],
|
|
308
|
+
output: {
|
|
309
|
+
codecId: "pg/timestamp@1",
|
|
310
|
+
nativeType: "timestamp",
|
|
311
|
+
typeParams: { precision: {
|
|
312
|
+
kind: "arg",
|
|
313
|
+
index: 0
|
|
314
|
+
} }
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
Timestamptz: {
|
|
318
|
+
kind: "typeConstructor",
|
|
319
|
+
args: [{
|
|
320
|
+
kind: "number",
|
|
321
|
+
name: "precision",
|
|
322
|
+
integer: true,
|
|
323
|
+
minimum: 0,
|
|
324
|
+
optional: true
|
|
325
|
+
}],
|
|
326
|
+
output: {
|
|
327
|
+
codecId: "pg/timestamptz@1",
|
|
328
|
+
nativeType: "timestamptz",
|
|
329
|
+
typeParams: { precision: {
|
|
330
|
+
kind: "arg",
|
|
331
|
+
index: 0
|
|
332
|
+
} }
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
Time: {
|
|
336
|
+
kind: "typeConstructor",
|
|
337
|
+
args: [{
|
|
338
|
+
kind: "number",
|
|
339
|
+
name: "precision",
|
|
340
|
+
integer: true,
|
|
341
|
+
minimum: 0,
|
|
342
|
+
optional: true
|
|
343
|
+
}],
|
|
344
|
+
output: {
|
|
345
|
+
codecId: "pg/time@1",
|
|
346
|
+
nativeType: "time",
|
|
347
|
+
typeParams: { precision: {
|
|
348
|
+
kind: "arg",
|
|
349
|
+
index: 0
|
|
350
|
+
} }
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
Timetz: {
|
|
354
|
+
kind: "typeConstructor",
|
|
355
|
+
args: [{
|
|
356
|
+
kind: "number",
|
|
357
|
+
name: "precision",
|
|
358
|
+
integer: true,
|
|
359
|
+
minimum: 0,
|
|
360
|
+
optional: true
|
|
361
|
+
}],
|
|
362
|
+
output: {
|
|
363
|
+
codecId: "pg/timetz@1",
|
|
364
|
+
nativeType: "timetz",
|
|
365
|
+
typeParams: { precision: {
|
|
366
|
+
kind: "arg",
|
|
367
|
+
index: 0
|
|
368
|
+
} }
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
Uuid: {
|
|
372
|
+
kind: "typeConstructor",
|
|
373
|
+
output: {
|
|
374
|
+
codecId: "pg/uuid@1",
|
|
375
|
+
nativeType: "uuid"
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
Inet: {
|
|
379
|
+
kind: "typeConstructor",
|
|
380
|
+
output: {
|
|
381
|
+
codecId: "pg/inet@1",
|
|
382
|
+
nativeType: "inet"
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
SmallInt: {
|
|
386
|
+
kind: "typeConstructor",
|
|
387
|
+
output: {
|
|
388
|
+
codecId: "pg/int2@1",
|
|
389
|
+
nativeType: "int2"
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
Real: {
|
|
393
|
+
kind: "typeConstructor",
|
|
394
|
+
output: {
|
|
395
|
+
codecId: "pg/float4@1",
|
|
396
|
+
nativeType: "float4"
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
Date: {
|
|
400
|
+
kind: "typeConstructor",
|
|
401
|
+
output: {
|
|
402
|
+
codecId: "pg/date@1",
|
|
403
|
+
nativeType: "date"
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
const postgresAuthoringTypes = {
|
|
408
|
+
...postgresScalarAuthoringTypes,
|
|
409
|
+
...postgresNativeAuthoringTypes
|
|
410
|
+
};
|
|
163
411
|
function createPostgresDefaultFunctionRegistry() {
|
|
164
412
|
return new Map(postgresDefaultFunctionRegistryEntries);
|
|
165
413
|
}
|
|
166
414
|
function createPostgresMutationDefaultGeneratorDescriptors() {
|
|
167
415
|
return [...builtinGeneratorRegistryMetadata.map(({ id, applicableCodecIds }) => ({
|
|
168
416
|
id,
|
|
169
|
-
applicableCodecIds
|
|
170
|
-
resolveGeneratedColumnDescriptor: ({ generated }) => {
|
|
171
|
-
if (generated.kind !== "generator" || generated.id !== id) return;
|
|
172
|
-
const descriptor = resolveBuiltinGeneratedColumnDescriptor({
|
|
173
|
-
id,
|
|
174
|
-
...generated.params ? { params: generated.params } : {}
|
|
175
|
-
});
|
|
176
|
-
return {
|
|
177
|
-
codecId: descriptor.type.codecId,
|
|
178
|
-
nativeType: descriptor.type.nativeType,
|
|
179
|
-
...descriptor.type.typeRef ? { typeRef: descriptor.type.typeRef } : {},
|
|
180
|
-
...descriptor.typeParams ? { typeParams: descriptor.typeParams } : {}
|
|
181
|
-
};
|
|
182
|
-
}
|
|
417
|
+
applicableCodecIds
|
|
183
418
|
})), timestampNowControlDescriptor()];
|
|
184
419
|
}
|
|
185
|
-
function createPostgresScalarTypeDescriptors() {
|
|
186
|
-
return new Map(postgresScalarTypeDescriptors);
|
|
187
|
-
}
|
|
188
420
|
//#endregion
|
|
189
421
|
//#region src/exports/control.ts
|
|
190
422
|
const postgresAdapterDescriptor = {
|
|
191
423
|
...postgresAdapterDescriptorMeta,
|
|
192
|
-
|
|
424
|
+
authoring: {
|
|
425
|
+
type: postgresAuthoringTypes,
|
|
426
|
+
valueObjectStorageType: "Jsonb"
|
|
427
|
+
},
|
|
193
428
|
controlMutationDefaults: {
|
|
194
429
|
defaultFunctionRegistry: createPostgresDefaultFunctionRegistry(),
|
|
195
430
|
generatorDescriptors: createPostgresMutationDefaultGeneratorDescriptors()
|
|
@@ -199,6 +434,6 @@ const postgresAdapterDescriptor = {
|
|
|
199
434
|
}
|
|
200
435
|
};
|
|
201
436
|
//#endregion
|
|
202
|
-
export { PostgresControlAdapter,
|
|
437
|
+
export { PostgresControlAdapter, createPostgresBuiltinCodecLookup, postgresAdapterDescriptor as default, escapeLiteral, normalizeSchemaNativeType, parsePostgresDefault, qualifyName, quoteIdentifier };
|
|
203
438
|
|
|
204
439
|
//# sourceMappingURL=control.mjs.map
|
package/dist/control.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.mjs","names":[],"sources":["../src/core/control-mutation-defaults.ts","../src/exports/control.ts"],"sourcesContent":["import type { ExecutionMutationDefaultValue } from '@prisma-next/contract/types';\nimport { timestampNowControlDescriptor } from '@prisma-next/family-sql/control';\nimport type {\n ControlMutationDefaultEntry,\n DefaultFunctionLoweringContext,\n LoweredDefaultResult,\n MutationDefaultGeneratorDescriptor,\n TypedDefaultFunctionCall,\n} from '@prisma-next/framework-components/control';\nimport {\n builtinGeneratorRegistryMetadata,\n resolveBuiltinGeneratedColumnDescriptor,\n} from '@prisma-next/ids';\nimport type { FuncCallSig } from '@prisma-next/psl-parser';\nimport { int, num, oneOf, optional, str } from '@prisma-next/psl-parser';\n\nfunction invalidArgumentDiagnostic(input: {\n readonly context: DefaultFunctionLoweringContext;\n readonly span: TypedDefaultFunctionCall['span'];\n readonly message: string;\n}): LoweredDefaultResult {\n return {\n ok: false,\n diagnostic: {\n code: 'PSL_INVALID_DEFAULT_FUNCTION_ARGUMENT',\n message: input.message,\n sourceId: input.context.sourceId,\n span: input.span,\n },\n };\n}\n\nfunction executionGenerator(\n id: ExecutionMutationDefaultValue['id'],\n params?: Record<string, unknown>,\n): LoweredDefaultResult {\n return {\n ok: true,\n value: {\n kind: 'execution',\n generated: {\n kind: 'generator',\n id,\n ...(params ? { params } : {}),\n },\n },\n };\n}\n\nfunction lowerAutoincrement(): LoweredDefaultResult {\n return {\n ok: true,\n value: {\n kind: 'storage',\n defaultValue: { kind: 'function', expression: 'autoincrement()' },\n },\n };\n}\n\nfunction lowerNow(): LoweredDefaultResult {\n return {\n ok: true,\n value: {\n kind: 'storage',\n defaultValue: { kind: 'function', expression: 'now()' },\n },\n };\n}\n\nfunction lowerUlid(): LoweredDefaultResult {\n return executionGenerator('ulid');\n}\n\nfunction lowerUuid(input: {\n readonly call: TypedDefaultFunctionCall;\n readonly context: DefaultFunctionLoweringContext;\n}): LoweredDefaultResult {\n return input.call.args['version'] === 7\n ? executionGenerator('uuidv7')\n : executionGenerator('uuidv4');\n}\n\nfunction lowerCuid(): LoweredDefaultResult {\n return executionGenerator('cuid2');\n}\n\nfunction lowerNanoid(input: {\n readonly call: TypedDefaultFunctionCall;\n readonly context: DefaultFunctionLoweringContext;\n}): LoweredDefaultResult {\n const size = input.call.args['size'];\n return typeof size === 'number'\n ? executionGenerator('nanoid', { size })\n : executionGenerator('nanoid');\n}\n\nfunction lowerDbgenerated(input: {\n readonly call: TypedDefaultFunctionCall;\n readonly context: DefaultFunctionLoweringContext;\n}): LoweredDefaultResult {\n const expression = input.call.args['expression'];\n if (typeof expression !== 'string' || expression.trim().length === 0) {\n return invalidArgumentDiagnostic({\n context: input.context,\n span: input.call.span,\n message: 'Default function \"dbgenerated\" argument cannot be empty.',\n });\n }\n return {\n ok: true,\n value: {\n kind: 'storage',\n defaultValue: { kind: 'function', expression },\n },\n };\n}\n\nconst nowSig: FuncCallSig = {};\nconst autoincrementSig: FuncCallSig = {};\nconst ulidSig: FuncCallSig = {};\nconst uuidSig: FuncCallSig = {\n positional: [{ key: 'version', type: optional(oneOf(num(4), num(7))) }],\n};\nconst cuidSig: FuncCallSig = { positional: [{ key: 'version', type: num(2) }] };\nconst nanoidSig: FuncCallSig = {\n positional: [{ key: 'size', type: optional(int({ min: 2, max: 255 })) }],\n};\nconst dbgeneratedSig: FuncCallSig = { positional: [{ key: 'expression', type: str() }] };\n\nconst postgresDefaultFunctionRegistryEntries = [\n [\n 'autoincrement',\n {\n signature: autoincrementSig,\n lower: lowerAutoincrement,\n usageSignatures: ['autoincrement()'],\n },\n ],\n ['now', { signature: nowSig, lower: lowerNow, usageSignatures: ['now()'] }],\n [\n 'uuid',\n { signature: uuidSig, lower: lowerUuid, usageSignatures: ['uuid()', 'uuid(4)', 'uuid(7)'] },\n ],\n ['cuid', { signature: cuidSig, lower: lowerCuid, usageSignatures: ['cuid(2)'] }],\n ['ulid', { signature: ulidSig, lower: lowerUlid, usageSignatures: ['ulid()'] }],\n [\n 'nanoid',\n { signature: nanoidSig, lower: lowerNanoid, usageSignatures: ['nanoid()', 'nanoid(<2-255>)'] },\n ],\n [\n 'dbgenerated',\n { signature: dbgeneratedSig, lower: lowerDbgenerated, usageSignatures: ['dbgenerated(\"...\")'] },\n ],\n] satisfies ReadonlyArray<readonly [string, ControlMutationDefaultEntry]>;\n\nconst postgresScalarTypeDescriptors = new Map<string, string>([\n ['String', 'pg/text@1'],\n ['Boolean', 'pg/bool@1'],\n ['Int', 'pg/int4@1'],\n ['BigInt', 'pg/int8@1'],\n ['Float', 'pg/float8@1'],\n ['Decimal', 'pg/numeric@1'],\n ['DateTime', 'pg/timestamptz@1'],\n ['Json', 'pg/jsonb@1'],\n ['Bytes', 'pg/bytea@1'],\n]);\n\nexport function createPostgresDefaultFunctionRegistry(): ReadonlyMap<\n string,\n ControlMutationDefaultEntry\n> {\n return new Map(postgresDefaultFunctionRegistryEntries);\n}\n\nexport function createPostgresMutationDefaultGeneratorDescriptors(): readonly MutationDefaultGeneratorDescriptor[] {\n return [\n ...builtinGeneratorRegistryMetadata.map(\n ({ id, applicableCodecIds }): MutationDefaultGeneratorDescriptor => ({\n id,\n applicableCodecIds,\n resolveGeneratedColumnDescriptor: ({ generated }) => {\n if (generated.kind !== 'generator' || generated.id !== id) {\n return undefined;\n }\n const descriptor = resolveBuiltinGeneratedColumnDescriptor({\n id,\n ...(generated.params ? { params: generated.params } : {}),\n });\n return {\n codecId: descriptor.type.codecId,\n nativeType: descriptor.type.nativeType,\n ...(descriptor.type.typeRef ? { typeRef: descriptor.type.typeRef } : {}),\n ...(descriptor.typeParams ? { typeParams: descriptor.typeParams } : {}),\n };\n },\n }),\n ),\n timestampNowControlDescriptor(),\n ];\n}\n\nexport function createPostgresScalarTypeDescriptors(): ReadonlyMap<string, string> {\n return new Map(postgresScalarTypeDescriptors);\n}\n","import type { SqlControlAdapterDescriptor } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport {\n escapeLiteral,\n qualifyName,\n quoteIdentifier,\n SqlEscapeError,\n} from '@prisma-next/target-postgres/sql-utils';\nimport { PostgresControlAdapter } from '../core/control-adapter';\nimport {\n createPostgresDefaultFunctionRegistry,\n createPostgresMutationDefaultGeneratorDescriptors,\n createPostgresScalarTypeDescriptors,\n} from '../core/control-mutation-defaults';\nimport { postgresAdapterDescriptorMeta } from '../core/descriptor-meta';\n\nconst postgresAdapterDescriptor: SqlControlAdapterDescriptor<'postgres'> = {\n ...postgresAdapterDescriptorMeta,\n scalarTypeDescriptors: createPostgresScalarTypeDescriptors(),\n controlMutationDefaults: {\n defaultFunctionRegistry: createPostgresDefaultFunctionRegistry(),\n generatorDescriptors: createPostgresMutationDefaultGeneratorDescriptors(),\n },\n create(stack): SqlControlAdapter<'postgres'> {\n return new PostgresControlAdapter(stack.codecLookup);\n },\n};\n\nexport default postgresAdapterDescriptor;\n\nexport { parsePostgresDefault } from '@prisma-next/target-postgres/default-normalizer';\nexport { normalizeSchemaNativeType } from '@prisma-next/target-postgres/native-type-normalizer';\nexport { createPostgresBuiltinCodecLookup } from '../core/codec-lookup';\nexport { PostgresControlAdapter } from '../core/control-adapter';\nexport { escapeLiteral, qualifyName, quoteIdentifier, SqlEscapeError };\n"],"mappings":";;;;;;;;;AAgBA,SAAS,0BAA0B,OAIV;CACvB,OAAO;EACL,IAAI;EACJ,YAAY;GACV,MAAM;GACN,SAAS,MAAM;GACf,UAAU,MAAM,QAAQ;GACxB,MAAM,MAAM;EACd;CACF;AACF;AAEA,SAAS,mBACP,IACA,QACsB;CACtB,OAAO;EACL,IAAI;E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AAO,IAAI,IAAI,sCAAsC;AACvD;AAEA,SAAgB,oDAAmG;CACjH,OAAO,CACL,GAAG,iCAAiC,KACjC,EAAE,IAAI,0BAA8D;EACnE;EACA;EACA,mCAAmC,EAAE,gBAAgB;GACnD,IAAI,UAAU,SAAS,eAAe,UAAU,OAAO,IACrD;GAEF,MAAM,aAAa,wCAAwC;IACzD;IACA,GAAI,UAAU,SAAS,EAAE,QAAQ,UAAU,OAAO,IAAI,CAAC;GACzD,CAAC;GACD,OAAO;IACL,SAAS,WAAW,KAAK;IACzB,YAAY,WAAW,KAAK;IAC5B,GAAI,WAAW,KAAK,UAAU,EAAE,SAAS,WAAW,KAAK,QAAQ,IAAI,CAAC;IACtE,GAAI,WAAW,aAAa,EAAE,YAAY,WAAW,WAAW,IAAI,CAAC;GACvE;EACF;CACF,EACF,GACA,8BAA8B,CAChC;AACF;AAEA,SAAgB,sCAAmE;CACjF,OAAO,IAAI,IAAI,6BAA6B;AAC9C;;;AC3LA,MAAM,4BAAqE;CACzE,GAAG;CACH,uBAAuB,oCAAoC;CAC3D,yBAAyB;EACvB,yBAAyB,sCAAsC;EAC/D,sBAAsB,kDAAkD;CAC1E;CACA,OAAO,OAAsC;EAC3C,OAAO,IAAI,uBAAuB,MAAM,WAAW;CACrD;AACF"}
|
|
1
|
+
{"version":3,"file":"control.mjs","names":[],"sources":["../src/core/control-mutation-defaults.ts","../src/exports/control.ts"],"sourcesContent":["import type { ExecutionMutationDefaultValue } from '@prisma-next/contract/types';\nimport { timestampNowControlDescriptor } from '@prisma-next/family-sql/control';\nimport type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\nimport type {\n ControlMutationDefaultEntry,\n DefaultFunctionLoweringContext,\n LoweredDefaultResult,\n MutationDefaultGeneratorDescriptor,\n TypedDefaultFunctionCall,\n} from '@prisma-next/framework-components/control';\nimport { builtinGeneratorRegistryMetadata } from '@prisma-next/ids';\nimport type { FuncCallSig } from '@prisma-next/psl-parser';\nimport { int, num, oneOf, optional, str } from '@prisma-next/psl-parser';\n\nfunction invalidArgumentDiagnostic(input: {\n readonly context: DefaultFunctionLoweringContext;\n readonly span: TypedDefaultFunctionCall['span'];\n readonly message: string;\n}): LoweredDefaultResult {\n return {\n ok: false,\n diagnostic: {\n code: 'PSL_INVALID_DEFAULT_FUNCTION_ARGUMENT',\n message: input.message,\n sourceId: input.context.sourceId,\n span: input.span,\n },\n };\n}\n\nfunction executionGenerator(\n id: ExecutionMutationDefaultValue['id'],\n params?: Record<string, unknown>,\n): LoweredDefaultResult {\n return {\n ok: true,\n value: {\n kind: 'execution',\n generated: {\n kind: 'generator',\n id,\n ...(params ? { params } : {}),\n },\n },\n };\n}\n\nfunction lowerAutoincrement(): LoweredDefaultResult {\n return {\n ok: true,\n value: {\n kind: 'storage',\n defaultValue: { kind: 'function', expression: 'autoincrement()' },\n },\n };\n}\n\nfunction lowerNow(): LoweredDefaultResult {\n return {\n ok: true,\n value: {\n kind: 'storage',\n defaultValue: { kind: 'function', expression: 'now()' },\n },\n };\n}\n\nfunction lowerUlid(): LoweredDefaultResult {\n return executionGenerator('ulid');\n}\n\nfunction lowerUuid(input: {\n readonly call: TypedDefaultFunctionCall;\n readonly context: DefaultFunctionLoweringContext;\n}): LoweredDefaultResult {\n return input.call.args['version'] === 7\n ? executionGenerator('uuidv7')\n : executionGenerator('uuidv4');\n}\n\nfunction lowerCuid(): LoweredDefaultResult {\n return executionGenerator('cuid2');\n}\n\nfunction lowerNanoid(input: {\n readonly call: TypedDefaultFunctionCall;\n readonly context: DefaultFunctionLoweringContext;\n}): LoweredDefaultResult {\n const size = input.call.args['size'];\n return typeof size === 'number'\n ? executionGenerator('nanoid', { size })\n : executionGenerator('nanoid');\n}\n\nfunction lowerDbgenerated(input: {\n readonly call: TypedDefaultFunctionCall;\n readonly context: DefaultFunctionLoweringContext;\n}): LoweredDefaultResult {\n const expression = input.call.args['expression'];\n if (typeof expression !== 'string' || expression.trim().length === 0) {\n return invalidArgumentDiagnostic({\n context: input.context,\n span: input.call.span,\n message: 'Default function \"dbgenerated\" argument cannot be empty.',\n });\n }\n return {\n ok: true,\n value: {\n kind: 'storage',\n defaultValue: { kind: 'function', expression },\n },\n };\n}\n\nconst nowSig: FuncCallSig = {};\nconst autoincrementSig: FuncCallSig = {};\nconst ulidSig: FuncCallSig = {};\nconst uuidSig: FuncCallSig = {\n positional: [{ key: 'version', type: optional(oneOf(num(4), num(7))) }],\n};\nconst cuidSig: FuncCallSig = { positional: [{ key: 'version', type: num(2) }] };\nconst nanoidSig: FuncCallSig = {\n positional: [{ key: 'size', type: optional(int({ min: 2, max: 255 })) }],\n};\nconst dbgeneratedSig: FuncCallSig = { positional: [{ key: 'expression', type: str() }] };\n\nconst postgresDefaultFunctionRegistryEntries = [\n [\n 'autoincrement',\n {\n signature: autoincrementSig,\n lower: lowerAutoincrement,\n usageSignatures: ['autoincrement()'],\n },\n ],\n ['now', { signature: nowSig, lower: lowerNow, usageSignatures: ['now()'] }],\n [\n 'uuid',\n { signature: uuidSig, lower: lowerUuid, usageSignatures: ['uuid()', 'uuid(4)', 'uuid(7)'] },\n ],\n ['cuid', { signature: cuidSig, lower: lowerCuid, usageSignatures: ['cuid(2)'] }],\n ['ulid', { signature: ulidSig, lower: lowerUlid, usageSignatures: ['ulid()'] }],\n [\n 'nanoid',\n { signature: nanoidSig, lower: lowerNanoid, usageSignatures: ['nanoid()', 'nanoid(<2-255>)'] },\n ],\n [\n 'dbgenerated',\n { signature: dbgeneratedSig, lower: lowerDbgenerated, usageSignatures: ['dbgenerated(\"...\")'] },\n ],\n] satisfies ReadonlyArray<readonly [string, ControlMutationDefaultEntry]>;\n\n/**\n * The base PSL scalars as zero-arg type constructors in the unified authoring\n * channel, with explicit `nativeType` values pinned to the codec manifests\n * (`codecLookup.targetTypesFor(codecId)[0]`).\n *\n * The type position is the only storage decider: a mutation-default generator\n * (`@default(uuid())`) never re-picks a column's storage.\n */\nexport const postgresScalarAuthoringTypes = {\n String: {\n kind: 'typeConstructor',\n output: { codecId: 'pg/text@1', nativeType: 'text' },\n },\n Boolean: {\n kind: 'typeConstructor',\n output: { codecId: 'pg/bool@1', nativeType: 'bool' },\n },\n Int: {\n kind: 'typeConstructor',\n output: { codecId: 'pg/int4@1', nativeType: 'int4' },\n },\n BigInt: {\n kind: 'typeConstructor',\n output: { codecId: 'pg/int8@1', nativeType: 'int8' },\n },\n Float: {\n kind: 'typeConstructor',\n output: { codecId: 'pg/float8@1', nativeType: 'float8' },\n },\n Decimal: {\n kind: 'typeConstructor',\n output: { codecId: 'pg/numeric@1', nativeType: 'numeric' },\n },\n DateTime: {\n kind: 'typeConstructor',\n output: { codecId: 'pg/timestamptz@1', nativeType: 'timestamptz' },\n },\n Json: {\n kind: 'typeConstructor',\n output: { codecId: 'pg/json@1', nativeType: 'json' },\n },\n Jsonb: {\n kind: 'typeConstructor',\n output: { codecId: 'pg/jsonb@1', nativeType: 'jsonb' },\n },\n Bytes: {\n kind: 'typeConstructor',\n output: { codecId: 'pg/bytea@1', nativeType: 'bytea' },\n },\n} as const satisfies AuthoringTypeNamespace;\n\nexport const postgresNativeAuthoringTypes = {\n VarChar: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'length', integer: true, minimum: 1, optional: true }],\n output: {\n codecId: 'sql/varchar@1',\n nativeType: 'character varying',\n typeParams: { length: { kind: 'arg', index: 0 } },\n },\n },\n Char: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'length', integer: true, minimum: 1, optional: true }],\n output: {\n codecId: 'sql/char@1',\n nativeType: 'character',\n typeParams: { length: { kind: 'arg', index: 0 } },\n },\n },\n Numeric: {\n kind: 'typeConstructor',\n args: [\n { kind: 'number', name: 'precision', integer: true, minimum: 1, optional: true },\n { kind: 'number', name: 'scale', integer: true, minimum: 0, optional: true },\n ],\n output: {\n codecId: 'pg/numeric@1',\n nativeType: 'numeric',\n typeParams: {\n precision: { kind: 'arg', index: 0 },\n scale: { kind: 'arg', index: 1 },\n },\n },\n },\n Timestamp: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'precision', integer: true, minimum: 0, optional: true }],\n output: {\n codecId: 'pg/timestamp@1',\n nativeType: 'timestamp',\n typeParams: { precision: { kind: 'arg', index: 0 } },\n },\n },\n Timestamptz: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'precision', integer: true, minimum: 0, optional: true }],\n output: {\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n typeParams: { precision: { kind: 'arg', index: 0 } },\n },\n },\n Time: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'precision', integer: true, minimum: 0, optional: true }],\n output: {\n codecId: 'pg/time@1',\n nativeType: 'time',\n typeParams: { precision: { kind: 'arg', index: 0 } },\n },\n },\n Timetz: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'precision', integer: true, minimum: 0, optional: true }],\n output: {\n codecId: 'pg/timetz@1',\n nativeType: 'timetz',\n typeParams: { precision: { kind: 'arg', index: 0 } },\n },\n },\n Uuid: { kind: 'typeConstructor', output: { codecId: 'pg/uuid@1', nativeType: 'uuid' } },\n Inet: { kind: 'typeConstructor', output: { codecId: 'pg/inet@1', nativeType: 'inet' } },\n SmallInt: { kind: 'typeConstructor', output: { codecId: 'pg/int2@1', nativeType: 'int2' } },\n Real: { kind: 'typeConstructor', output: { codecId: 'pg/float4@1', nativeType: 'float4' } },\n Date: { kind: 'typeConstructor', output: { codecId: 'pg/date@1', nativeType: 'date' } },\n} as const satisfies AuthoringTypeNamespace;\n\nexport const postgresAuthoringTypes = {\n ...postgresScalarAuthoringTypes,\n ...postgresNativeAuthoringTypes,\n} as const satisfies AuthoringTypeNamespace;\n\nexport function createPostgresDefaultFunctionRegistry(): ReadonlyMap<\n string,\n ControlMutationDefaultEntry\n> {\n return new Map(postgresDefaultFunctionRegistryEntries);\n}\n\nexport function createPostgresMutationDefaultGeneratorDescriptors(): readonly MutationDefaultGeneratorDescriptor[] {\n return [\n ...builtinGeneratorRegistryMetadata.map(\n ({ id, applicableCodecIds }): MutationDefaultGeneratorDescriptor => ({\n id,\n applicableCodecIds,\n }),\n ),\n timestampNowControlDescriptor(),\n ];\n}\n","import type { SqlControlAdapterDescriptor } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport {\n escapeLiteral,\n qualifyName,\n quoteIdentifier,\n} from '@prisma-next/target-postgres/sql-utils';\nimport { PostgresControlAdapter } from '../core/control-adapter';\nimport {\n createPostgresDefaultFunctionRegistry,\n createPostgresMutationDefaultGeneratorDescriptors,\n postgresAuthoringTypes,\n} from '../core/control-mutation-defaults';\nimport { postgresAdapterDescriptorMeta } from '../core/descriptor-meta';\n\nconst postgresAdapterDescriptor: SqlControlAdapterDescriptor<'postgres'> = {\n ...postgresAdapterDescriptorMeta,\n authoring: { type: postgresAuthoringTypes, valueObjectStorageType: 'Jsonb' },\n controlMutationDefaults: {\n defaultFunctionRegistry: createPostgresDefaultFunctionRegistry(),\n generatorDescriptors: createPostgresMutationDefaultGeneratorDescriptors(),\n },\n create(stack): SqlControlAdapter<'postgres'> {\n return new PostgresControlAdapter(stack.codecLookup);\n },\n};\n\nexport default postgresAdapterDescriptor;\n\nexport { parsePostgresDefault } from '@prisma-next/target-postgres/default-normalizer';\nexport { normalizeSchemaNativeType } from '@prisma-next/target-postgres/native-type-normalizer';\nexport { createPostgresBuiltinCodecLookup } from '../core/codec-lookup';\nexport { PostgresControlAdapter } from '../core/control-adapter';\nexport { escapeLiteral, qualifyName, quoteIdentifier };\n"],"mappings":";;;;;;;;;AAcA,SAAS,0BAA0B,OAIV;CACvB,OAAO;EACL,IAAI;EACJ,YAAY;GACV,MAAM;GACN,SAAS,MAAM;GACf,UAAU,MAAM,QAAQ;GACxB,MAAM,MAAM;EACd;CACF;AACF;AAEA,SAAS,mBACP,IACA,QACsB;CACtB,OAAO;EACL,IAAI;EACJ,OAAO;GACL,MAAM;GACN,WAAW;IACT,MAAM;IACN;IACA,GAAI,SAAS,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G;AACL;AAEA,SAAgB,wCAGd;CACA,OAAO,IAAI,IAAI,sCAAsC;AACvD;AAEA,SAAgB,oDAAmG;CACjH,OAAO,CACL,GAAG,iCAAiC,KACjC,EAAE,IAAI,0BAA8D;EACnE;EACA;CACF,EACF,GACA,8BAA8B,CAChC;AACF;;;AChSA,MAAM,4BAAqE;CACzE,GAAG;CACH,WAAW;EAAE,MAAM;EAAwB,wBAAwB;CAAQ;CAC3E,yBAAyB;EACvB,yBAAyB,sCAAsC;EAC/D,sBAAsB,kDAAkD;CAC1E;CACA,OAAO,OAAsC;EAC3C,OAAO,IAAI,uBAAuB,MAAM,WAAW;CACrD;AACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i as adapterError } from "./control-adapter-DKbwTazN.mjs";
|
|
1
2
|
import { postgresCodecRegistry } from "@prisma-next/target-postgres/codecs";
|
|
2
3
|
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_INET_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_UUID_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
4
|
import { buildOperation, toExpr } from "@prisma-next/sql-relational-core/expression";
|
|
@@ -17,26 +18,45 @@ function isNonNegativeInteger(value) {
|
|
|
17
18
|
function expandLength({ nativeType, typeParams }) {
|
|
18
19
|
if (!typeParams || !("length" in typeParams)) return nativeType;
|
|
19
20
|
const length = typeParams["length"];
|
|
20
|
-
if (!isPositiveInteger(length)) throw
|
|
21
|
+
if (!isPositiveInteger(length)) throw adapterError("RUNTIME.TYPE_PARAMS_INVALID", `Invalid "length" type parameter for "${nativeType}": expected a positive integer, got ${JSON.stringify(length)}`, { meta: {
|
|
22
|
+
nativeType,
|
|
23
|
+
param: "length",
|
|
24
|
+
received: length
|
|
25
|
+
} });
|
|
21
26
|
return `${nativeType}(${length})`;
|
|
22
27
|
}
|
|
23
28
|
function expandPrecision({ nativeType, typeParams }) {
|
|
24
29
|
if (!typeParams || !("precision" in typeParams)) return nativeType;
|
|
25
30
|
const precision = typeParams["precision"];
|
|
26
|
-
if (!isPositiveInteger(precision)) throw
|
|
31
|
+
if (!isPositiveInteger(precision)) throw adapterError("RUNTIME.TYPE_PARAMS_INVALID", `Invalid "precision" type parameter for "${nativeType}": expected a positive integer, got ${JSON.stringify(precision)}`, { meta: {
|
|
32
|
+
nativeType,
|
|
33
|
+
param: "precision",
|
|
34
|
+
received: precision
|
|
35
|
+
} });
|
|
27
36
|
return `${nativeType}(${precision})`;
|
|
28
37
|
}
|
|
29
38
|
function expandNumeric({ nativeType, typeParams }) {
|
|
30
39
|
const hasPrecision = typeParams && "precision" in typeParams;
|
|
31
40
|
const hasScale = typeParams && "scale" in typeParams;
|
|
32
41
|
if (!hasPrecision && !hasScale) return nativeType;
|
|
33
|
-
if (!hasPrecision && hasScale) throw
|
|
42
|
+
if (!hasPrecision && hasScale) throw adapterError("RUNTIME.TYPE_PARAMS_INVALID", `Invalid type parameters for "${nativeType}": "scale" requires "precision" to be specified`, { meta: {
|
|
43
|
+
nativeType,
|
|
44
|
+
param: "scale"
|
|
45
|
+
} });
|
|
34
46
|
if (hasPrecision) {
|
|
35
47
|
const precision = typeParams["precision"];
|
|
36
|
-
if (!isPositiveInteger(precision)) throw
|
|
48
|
+
if (!isPositiveInteger(precision)) throw adapterError("RUNTIME.TYPE_PARAMS_INVALID", `Invalid "precision" type parameter for "${nativeType}": expected a positive integer, got ${JSON.stringify(precision)}`, { meta: {
|
|
49
|
+
nativeType,
|
|
50
|
+
param: "precision",
|
|
51
|
+
received: precision
|
|
52
|
+
} });
|
|
37
53
|
if (hasScale) {
|
|
38
54
|
const scale = typeParams["scale"];
|
|
39
|
-
if (!isNonNegativeInteger(scale)) throw
|
|
55
|
+
if (!isNonNegativeInteger(scale)) throw adapterError("RUNTIME.TYPE_PARAMS_INVALID", `Invalid "scale" type parameter for "${nativeType}": expected a non-negative integer, got ${JSON.stringify(scale)}`, { meta: {
|
|
56
|
+
nativeType,
|
|
57
|
+
param: "scale",
|
|
58
|
+
received: scale
|
|
59
|
+
} });
|
|
40
60
|
return `${nativeType}(${precision},${scale})`;
|
|
41
61
|
}
|
|
42
62
|
return `${nativeType}(${precision})`;
|
|
@@ -328,4 +348,4 @@ const postgresAdapterDescriptorMeta = {
|
|
|
328
348
|
//#endregion
|
|
329
349
|
export { postgresQueryOperations as n, postgresAdapterDescriptorMeta as t };
|
|
330
350
|
|
|
331
|
-
//# sourceMappingURL=descriptor-meta-
|
|
351
|
+
//# sourceMappingURL=descriptor-meta-pc7bA0_C.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta-pc7bA0_C.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_INET_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_UUID_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';\nimport { adapterError } from './adapter-errors';\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 adapterError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `Invalid \"length\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(length)}`,\n { meta: { nativeType, param: 'length', received: 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 adapterError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `Invalid \"precision\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(precision)}`,\n { meta: { nativeType, param: 'precision', received: 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 adapterError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `Invalid type parameters for \"${nativeType}\": \"scale\" requires \"precision\" to be specified`,\n { meta: { nativeType, param: 'scale' } },\n );\n }\n\n if (hasPrecision) {\n const precision = typeParams['precision'];\n if (!isPositiveInteger(precision)) {\n throw adapterError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `Invalid \"precision\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(precision)}`,\n { meta: { nativeType, param: 'precision', received: precision } },\n );\n }\n if (hasScale) {\n const scale = typeParams['scale'];\n if (!isNonNegativeInteger(scale)) {\n throw adapterError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `Invalid \"scale\" type parameter for \"${nativeType}\": expected a non-negative integer, got ${JSON.stringify(scale)}`,\n { meta: { nativeType, param: 'scale', received: 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 distinctOn: true,\n },\n sql: {\n enums: true,\n returning: true,\n defaultInInsert: true,\n lateral: true,\n scalarList: 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 [PG_UUID_CODEC_ID]: identityHooks,\n [PG_INET_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 { typeId: PG_UUID_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'uuid' },\n { typeId: PG_INET_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'inet' },\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":";;;;;;AA+CA,MAAM,mBAAmB,WACtB;CACC,SAAS;CACT;CACA,OAAO;AACT;AAEF,SAAS,kBAAkB,OAAiC;CAC1D,OACE,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,OAAO,UAAU,KAAK,KAAK,QAAQ;AAE9F;AAEA,SAAS,qBAAqB,OAAiC;CAC7D,OACE,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,OAAO,UAAU,KAAK,KAAK,SAAS;AAE/F;AAEA,SAAS,aAAa,EAAE,YAAY,cAA6C;CAC/E,IAAI,CAAC,cAAc,EAAE,YAAY,aAC/B,OAAO;CAET,MAAM,SAAS,WAAW;CAC1B,IAAI,CAAC,kBAAkB,MAAM,GAC3B,MAAM,aACJ,+BACA,wCAAwC,WAAW,sCAAsC,KAAK,UAAU,MAAM,KAC9G,EAAE,MAAM;EAAE;EAAY,OAAO;EAAU,UAAU;CAAO,EAAE,CAC5D;CAEF,OAAO,GAAG,WAAW,GAAG,OAAO;AACjC;AAEA,SAAS,gBAAgB,EAAE,YAAY,cAA6C;CAClF,IAAI,CAAC,cAAc,EAAE,eAAe,aAClC,OAAO;CAET,MAAM,YAAY,WAAW;CAC7B,IAAI,CAAC,kBAAkB,SAAS,GAC9B,MAAM,aACJ,+BACA,2CAA2C,WAAW,sCAAsC,KAAK,UAAU,SAAS,KACpH,EAAE,MAAM;EAAE;EAAY,OAAO;EAAa,UAAU;CAAU,EAAE,CAClE;CAEF,OAAO,GAAG,WAAW,GAAG,UAAU;AACpC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AU;IACV,UAAU;IACV,YAAY;GACd;GACA;IACE,QAAQ;IACR,UAAU;IACV,UAAU;IACV,YAAY;GACd;GACA;IAAE,QAAQ;IAAkB,UAAU;IAAO,UAAU;IAAY,YAAY;GAAO;GACtF;IAAE,QAAQ;IAAmB,UAAU;IAAO,UAAU;IAAY,YAAY;GAAQ;GACxF;IAAE,QAAQ;IAAmB,UAAU;IAAO,UAAU;IAAY,YAAY;GAAQ;GACxF;IAAE,QAAQ;IAAkB,UAAU;IAAO,UAAU;IAAY,YAAY;GAAO;GACtF;IAAE,QAAQ;IAAkB,UAAU;IAAO,UAAU;IAAY,YAAY;GAAO;EACxF;EACA,qBAAqB,EACnB,QAAQ;GACN,SAAS;GACT,OAAO;GACP,OAAO;EACT,EACF;CACF;AACF"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as postgresRawCodecInferer, t as createPostgresAdapter } from "./adapter-
|
|
2
|
-
import { n as postgresQueryOperations, t as postgresAdapterDescriptorMeta } from "./descriptor-meta-
|
|
1
|
+
import { n as postgresRawCodecInferer, t as createPostgresAdapter } from "./adapter-DlDJIHgB.mjs";
|
|
2
|
+
import { n as postgresQueryOperations, t as postgresAdapterDescriptorMeta } from "./descriptor-meta-pc7bA0_C.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";
|
|
@@ -28,7 +28,7 @@ const postgresRuntimeAdapterDescriptor = {
|
|
|
28
28
|
return createPostgresAdapter({ codecLookup: extractCodecLookup([
|
|
29
29
|
stack.target,
|
|
30
30
|
stack.adapter,
|
|
31
|
-
...stack.
|
|
31
|
+
...stack.extensions
|
|
32
32
|
]) });
|
|
33
33
|
}
|
|
34
34
|
};
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { GeneratedValueSpec } from '@prisma-next/contract/types';\nimport { timestampNowRuntimeGenerator } from '@prisma-next/family-sql/runtime';\nimport { extractCodecLookup } from '@prisma-next/framework-components/control';\nimport type { RuntimeAdapterInstance } from '@prisma-next/framework-components/execution';\nimport { builtinGeneratorIds } from '@prisma-next/ids';\nimport { generateId } from '@prisma-next/ids/runtime';\nimport type { Adapter, AnyQueryAst } from '@prisma-next/sql-relational-core/ast';\nimport type { SqlRuntimeAdapterDescriptor } from '@prisma-next/sql-runtime';\nimport { postgresCodecRegistry } from '@prisma-next/target-postgres/codecs';\nimport { createPostgresAdapter, postgresRawCodecInferer } from '../core/adapter';\nimport { postgresAdapterDescriptorMeta, postgresQueryOperations } from '../core/descriptor-meta';\nimport type { PostgresContract, PostgresLoweredStatement } from '../core/types';\n\nexport interface SqlRuntimeAdapter\n extends RuntimeAdapterInstance<'sql', 'postgres'>,\n Adapter<AnyQueryAst, PostgresContract, PostgresLoweredStatement> {}\n\nfunction createPostgresMutationDefaultGenerators() {\n return [\n ...builtinGeneratorIds.map((id) => ({\n id,\n generate: (params?: Record<string, unknown>) => {\n const spec: GeneratedValueSpec = params ? { id, params } : { id };\n return generateId(spec);\n },\n stability: 'field' as const,\n })),\n timestampNowRuntimeGenerator(),\n ];\n}\n\nconst postgresRuntimeAdapterDescriptor: SqlRuntimeAdapterDescriptor<'postgres', SqlRuntimeAdapter> =\n {\n ...postgresAdapterDescriptorMeta,\n codecs: () => Array.from(postgresCodecRegistry.values()),\n queryOperations: () => postgresQueryOperations(),\n mutationDefaultGenerators: createPostgresMutationDefaultGenerators,\n rawCodecInferer: postgresRawCodecInferer,\n create(stack): SqlRuntimeAdapter {\n // The runtime `ExecutionStack` does not (yet) carry a pre-assembled `codecLookup` field the way the control `ControlStack` does, so we derive an equivalent lookup here from the stack's component metadata (target + adapter + extension packs) using the same assembly helper that `createControlStack` uses. This keeps the renderer fed with the same codec set on both planes — including extension-contributed codecs like\n // `pg/vector@1` from `@prisma-next/extension-pgvector`.\n const components = [stack.target, stack.adapter, ...stack.
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { GeneratedValueSpec } from '@prisma-next/contract/types';\nimport { timestampNowRuntimeGenerator } from '@prisma-next/family-sql/runtime';\nimport { extractCodecLookup } from '@prisma-next/framework-components/control';\nimport type { RuntimeAdapterInstance } from '@prisma-next/framework-components/execution';\nimport { builtinGeneratorIds } from '@prisma-next/ids';\nimport { generateId } from '@prisma-next/ids/runtime';\nimport type { Adapter, AnyQueryAst } from '@prisma-next/sql-relational-core/ast';\nimport type { SqlRuntimeAdapterDescriptor } from '@prisma-next/sql-runtime';\nimport { postgresCodecRegistry } from '@prisma-next/target-postgres/codecs';\nimport { createPostgresAdapter, postgresRawCodecInferer } from '../core/adapter';\nimport { postgresAdapterDescriptorMeta, postgresQueryOperations } from '../core/descriptor-meta';\nimport type { PostgresContract, PostgresLoweredStatement } from '../core/types';\n\nexport interface SqlRuntimeAdapter\n extends RuntimeAdapterInstance<'sql', 'postgres'>,\n Adapter<AnyQueryAst, PostgresContract, PostgresLoweredStatement> {}\n\nfunction createPostgresMutationDefaultGenerators() {\n return [\n ...builtinGeneratorIds.map((id) => ({\n id,\n generate: (params?: Record<string, unknown>) => {\n const spec: GeneratedValueSpec = params ? { id, params } : { id };\n return generateId(spec);\n },\n stability: 'field' as const,\n })),\n timestampNowRuntimeGenerator(),\n ];\n}\n\nconst postgresRuntimeAdapterDescriptor: SqlRuntimeAdapterDescriptor<'postgres', SqlRuntimeAdapter> =\n {\n ...postgresAdapterDescriptorMeta,\n codecs: () => Array.from(postgresCodecRegistry.values()),\n queryOperations: () => postgresQueryOperations(),\n mutationDefaultGenerators: createPostgresMutationDefaultGenerators,\n rawCodecInferer: postgresRawCodecInferer,\n create(stack): SqlRuntimeAdapter {\n // The runtime `ExecutionStack` does not (yet) carry a pre-assembled `codecLookup` field the way the control `ControlStack` does, so we derive an equivalent lookup here from the stack's component metadata (target + adapter + extension packs) using the same assembly helper that `createControlStack` uses. This keeps the renderer fed with the same codec set on both planes — including extension-contributed codecs like\n // `pg/vector@1` from `@prisma-next/extension-pgvector`.\n const components = [stack.target, stack.adapter, ...stack.extensions];\n const codecLookup = extractCodecLookup(components);\n return createPostgresAdapter({ codecLookup });\n },\n };\n\nexport default postgresRuntimeAdapterDescriptor;\n"],"mappings":";;;;;;;;AAiBA,SAAS,0CAA0C;CACjD,OAAO,CACL,GAAG,oBAAoB,KAAK,QAAQ;EAClC;EACA,WAAW,WAAqC;GAE9C,OAAO,WAD0B,SAAS;IAAE;IAAI;GAAO,IAAI,EAAE,GAAG,CAC1C;EACxB;EACA,WAAW;CACb,EAAE,GACF,6BAA6B,CAC/B;AACF;AAEA,MAAM,mCACJ;CACE,GAAG;CACH,cAAc,MAAM,KAAK,sBAAsB,OAAO,CAAC;CACvD,uBAAuB,wBAAwB;CAC/C,2BAA2B;CAC3B,iBAAiB;CACjB,OAAO,OAA0B;EAK/B,OAAO,sBAAsB,EAAE,aADX,mBAAmB;GADnB,MAAM;GAAQ,MAAM;GAAS,GAAG,MAAM;EACV,CACP,EAAE,CAAC;CAC9C;AACF"}
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/adapter-postgres",
|
|
3
|
-
"version": "0.16.0-dev.
|
|
3
|
+
"version": "0.16.0-dev.31",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/contract": "0.16.0-dev.
|
|
9
|
-
"@prisma-next/contract-authoring": "0.16.0-dev.
|
|
10
|
-
"@prisma-next/errors": "0.16.0-dev.
|
|
11
|
-
"@prisma-next/family-sql": "0.16.0-dev.
|
|
12
|
-
"@prisma-next/framework-components": "0.16.0-dev.
|
|
13
|
-
"@prisma-next/ids": "0.16.0-dev.
|
|
14
|
-
"@prisma-next/psl-parser": "0.16.0-dev.
|
|
15
|
-
"@prisma-next/sql-contract": "0.16.0-dev.
|
|
16
|
-
"@prisma-next/sql-contract-psl": "0.16.0-dev.
|
|
17
|
-
"@prisma-next/sql-contract-ts": "0.16.0-dev.
|
|
18
|
-
"@prisma-next/sql-operations": "0.16.0-dev.
|
|
19
|
-
"@prisma-next/sql-relational-core": "0.16.0-dev.
|
|
20
|
-
"@prisma-next/sql-runtime": "0.16.0-dev.
|
|
21
|
-
"@prisma-next/sql-schema-ir": "0.16.0-dev.
|
|
22
|
-
"@prisma-next/target-postgres": "0.16.0-dev.
|
|
23
|
-
"@prisma-next/utils": "0.16.0-dev.
|
|
8
|
+
"@prisma-next/contract": "0.16.0-dev.31",
|
|
9
|
+
"@prisma-next/contract-authoring": "0.16.0-dev.31",
|
|
10
|
+
"@prisma-next/errors": "0.16.0-dev.31",
|
|
11
|
+
"@prisma-next/family-sql": "0.16.0-dev.31",
|
|
12
|
+
"@prisma-next/framework-components": "0.16.0-dev.31",
|
|
13
|
+
"@prisma-next/ids": "0.16.0-dev.31",
|
|
14
|
+
"@prisma-next/psl-parser": "0.16.0-dev.31",
|
|
15
|
+
"@prisma-next/sql-contract": "0.16.0-dev.31",
|
|
16
|
+
"@prisma-next/sql-contract-psl": "0.16.0-dev.31",
|
|
17
|
+
"@prisma-next/sql-contract-ts": "0.16.0-dev.31",
|
|
18
|
+
"@prisma-next/sql-operations": "0.16.0-dev.31",
|
|
19
|
+
"@prisma-next/sql-relational-core": "0.16.0-dev.31",
|
|
20
|
+
"@prisma-next/sql-runtime": "0.16.0-dev.31",
|
|
21
|
+
"@prisma-next/sql-schema-ir": "0.16.0-dev.31",
|
|
22
|
+
"@prisma-next/target-postgres": "0.16.0-dev.31",
|
|
23
|
+
"@prisma-next/utils": "0.16.0-dev.31",
|
|
24
24
|
"arktype": "^2.2.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@prisma-next/cli": "0.16.0-dev.
|
|
28
|
-
"@prisma-next/driver-postgres": "0.16.0-dev.
|
|
29
|
-
"@prisma-next/migration-tools": "0.16.0-dev.
|
|
30
|
-
"@prisma-next/test-utils": "0.16.0-dev.
|
|
31
|
-
"@prisma-next/tsconfig": "0.16.0-dev.
|
|
32
|
-
"@prisma-next/tsdown": "0.16.0-dev.
|
|
27
|
+
"@prisma-next/cli": "0.16.0-dev.31",
|
|
28
|
+
"@prisma-next/driver-postgres": "0.16.0-dev.31",
|
|
29
|
+
"@prisma-next/migration-tools": "0.16.0-dev.31",
|
|
30
|
+
"@prisma-next/test-utils": "0.16.0-dev.31",
|
|
31
|
+
"@prisma-next/tsconfig": "0.16.0-dev.31",
|
|
32
|
+
"@prisma-next/tsdown": "0.16.0-dev.31",
|
|
33
33
|
"pathe": "^2.0.3",
|
|
34
34
|
"tsdown": "0.22.8",
|
|
35
35
|
"typescript": "5.9.3",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { StructuredError, StructuredErrorOptions } from '@prisma-next/utils/structured-error';
|
|
2
|
+
import { structuredError } from '@prisma-next/utils/structured-error';
|
|
3
|
+
|
|
4
|
+
type RuntimeSubcode =
|
|
5
|
+
| 'DDL_UNSUPPORTED'
|
|
6
|
+
| 'RAW_SQL_UNSUPPORTED_INTERPOLATION'
|
|
7
|
+
| 'TYPE_PARAMS_INVALID'
|
|
8
|
+
| 'PARAM_REF_MISSING_CODEC'
|
|
9
|
+
| 'NAMESPACE_UNKNOWN'
|
|
10
|
+
| 'AST_INVALID';
|
|
11
|
+
|
|
12
|
+
type ContractSubcode =
|
|
13
|
+
| 'INTROSPECTION_UNSUPPORTED'
|
|
14
|
+
| 'DEFAULT_INVALID'
|
|
15
|
+
| 'PACK_CONTRIBUTION_INVALID';
|
|
16
|
+
|
|
17
|
+
export type PostgresAdapterErrorCode = `RUNTIME.${RuntimeSubcode}` | `CONTRACT.${ContractSubcode}`;
|
|
18
|
+
|
|
19
|
+
export function adapterError(
|
|
20
|
+
code: PostgresAdapterErrorCode,
|
|
21
|
+
message: string,
|
|
22
|
+
options?: StructuredErrorOptions,
|
|
23
|
+
): StructuredError {
|
|
24
|
+
return structuredError(code, message, options);
|
|
25
|
+
}
|