@prisma-next/adapter-postgres 0.16.0-dev.2 → 0.16.0-dev.21
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-DcBWxseT.mjs} +2 -2
- package/dist/{adapter-BaZsfXGA.mjs.map → adapter-DcBWxseT.mjs.map} +1 -1
- package/dist/adapter.mjs +1 -1
- package/dist/{control-adapter-B6IM_oTR.mjs → control-adapter-hSsjUXtc.mjs} +48 -18
- package/dist/control-adapter-hSsjUXtc.mjs.map +1 -0
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +266 -31
- package/dist/control.mjs.map +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/runtime.mjs.map +1 -1
- package/package.json +23 -23
- package/src/core/control-adapter.ts +8 -2
- package/src/core/control-mutation-defaults.ts +140 -34
- package/src/core/sql-renderer.ts +95 -23
- package/src/exports/control.ts +2 -2
- package/src/exports/runtime.ts +1 -1
- package/dist/control-adapter-B6IM_oTR.mjs.map +0 -1
package/dist/control.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { r as createPostgresBuiltinCodecLookup, t as PostgresControlAdapter } from "./control-adapter-
|
|
1
|
+
import { r as createPostgresBuiltinCodecLookup, t as PostgresControlAdapter } from "./control-adapter-hSsjUXtc.mjs";
|
|
2
2
|
import { t as postgresAdapterDescriptorMeta } from "./descriptor-meta-jMtx881n.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
5
|
import { SqlEscapeError, 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
|
+
/**
|
|
233
|
+
* The former `@db.*` native types as first-class top-level type constructors
|
|
234
|
+
* (TML-2986). Codec ids, native types, and typeParams key shapes mirror the
|
|
235
|
+
* legacy `@db.*` attribute path (`NATIVE_TYPE_SPECS` in sql-contract-psl)
|
|
236
|
+
* exactly; every argument is optional, so each name is also authorable bare
|
|
237
|
+
* (`VarChar` ≡ `VarChar()`), and omitted arguments omit their typeParams keys.
|
|
238
|
+
*/
|
|
239
|
+
const postgresNativeAuthoringTypes = {
|
|
240
|
+
VarChar: {
|
|
241
|
+
kind: "typeConstructor",
|
|
242
|
+
args: [{
|
|
243
|
+
kind: "number",
|
|
244
|
+
name: "length",
|
|
245
|
+
integer: true,
|
|
246
|
+
minimum: 1,
|
|
247
|
+
optional: true
|
|
248
|
+
}],
|
|
249
|
+
output: {
|
|
250
|
+
codecId: "sql/varchar@1",
|
|
251
|
+
nativeType: "character varying",
|
|
252
|
+
typeParams: { length: {
|
|
253
|
+
kind: "arg",
|
|
254
|
+
index: 0
|
|
255
|
+
} }
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
Char: {
|
|
259
|
+
kind: "typeConstructor",
|
|
260
|
+
args: [{
|
|
261
|
+
kind: "number",
|
|
262
|
+
name: "length",
|
|
263
|
+
integer: true,
|
|
264
|
+
minimum: 1,
|
|
265
|
+
optional: true
|
|
266
|
+
}],
|
|
267
|
+
output: {
|
|
268
|
+
codecId: "sql/char@1",
|
|
269
|
+
nativeType: "character",
|
|
270
|
+
typeParams: { length: {
|
|
271
|
+
kind: "arg",
|
|
272
|
+
index: 0
|
|
273
|
+
} }
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
Numeric: {
|
|
277
|
+
kind: "typeConstructor",
|
|
278
|
+
args: [{
|
|
279
|
+
kind: "number",
|
|
280
|
+
name: "precision",
|
|
281
|
+
integer: true,
|
|
282
|
+
minimum: 1,
|
|
283
|
+
optional: true
|
|
284
|
+
}, {
|
|
285
|
+
kind: "number",
|
|
286
|
+
name: "scale",
|
|
287
|
+
integer: true,
|
|
288
|
+
minimum: 0,
|
|
289
|
+
optional: true
|
|
290
|
+
}],
|
|
291
|
+
output: {
|
|
292
|
+
codecId: "pg/numeric@1",
|
|
293
|
+
nativeType: "numeric",
|
|
294
|
+
typeParams: {
|
|
295
|
+
precision: {
|
|
296
|
+
kind: "arg",
|
|
297
|
+
index: 0
|
|
298
|
+
},
|
|
299
|
+
scale: {
|
|
300
|
+
kind: "arg",
|
|
301
|
+
index: 1
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
Timestamp: {
|
|
307
|
+
kind: "typeConstructor",
|
|
308
|
+
args: [{
|
|
309
|
+
kind: "number",
|
|
310
|
+
name: "precision",
|
|
311
|
+
integer: true,
|
|
312
|
+
minimum: 0,
|
|
313
|
+
optional: true
|
|
314
|
+
}],
|
|
315
|
+
output: {
|
|
316
|
+
codecId: "pg/timestamp@1",
|
|
317
|
+
nativeType: "timestamp",
|
|
318
|
+
typeParams: { precision: {
|
|
319
|
+
kind: "arg",
|
|
320
|
+
index: 0
|
|
321
|
+
} }
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
Timestamptz: {
|
|
325
|
+
kind: "typeConstructor",
|
|
326
|
+
args: [{
|
|
327
|
+
kind: "number",
|
|
328
|
+
name: "precision",
|
|
329
|
+
integer: true,
|
|
330
|
+
minimum: 0,
|
|
331
|
+
optional: true
|
|
332
|
+
}],
|
|
333
|
+
output: {
|
|
334
|
+
codecId: "pg/timestamptz@1",
|
|
335
|
+
nativeType: "timestamptz",
|
|
336
|
+
typeParams: { precision: {
|
|
337
|
+
kind: "arg",
|
|
338
|
+
index: 0
|
|
339
|
+
} }
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
Time: {
|
|
343
|
+
kind: "typeConstructor",
|
|
344
|
+
args: [{
|
|
345
|
+
kind: "number",
|
|
346
|
+
name: "precision",
|
|
347
|
+
integer: true,
|
|
348
|
+
minimum: 0,
|
|
349
|
+
optional: true
|
|
350
|
+
}],
|
|
351
|
+
output: {
|
|
352
|
+
codecId: "pg/time@1",
|
|
353
|
+
nativeType: "time",
|
|
354
|
+
typeParams: { precision: {
|
|
355
|
+
kind: "arg",
|
|
356
|
+
index: 0
|
|
357
|
+
} }
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
Timetz: {
|
|
361
|
+
kind: "typeConstructor",
|
|
362
|
+
args: [{
|
|
363
|
+
kind: "number",
|
|
364
|
+
name: "precision",
|
|
365
|
+
integer: true,
|
|
366
|
+
minimum: 0,
|
|
367
|
+
optional: true
|
|
368
|
+
}],
|
|
369
|
+
output: {
|
|
370
|
+
codecId: "pg/timetz@1",
|
|
371
|
+
nativeType: "timetz",
|
|
372
|
+
typeParams: { precision: {
|
|
373
|
+
kind: "arg",
|
|
374
|
+
index: 0
|
|
375
|
+
} }
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
Uuid: {
|
|
379
|
+
kind: "typeConstructor",
|
|
380
|
+
output: {
|
|
381
|
+
codecId: "pg/uuid@1",
|
|
382
|
+
nativeType: "uuid"
|
|
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()
|
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;EACJ,OAAO;GACL,MAAM;GACN,WAAW;IACT,MAAM;IACN;IACA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;GAC7B;EACF;CACF;AACF;AAEA,SAAS,qBAA2C;CAClD,OAAO;EACL,IAAI;EACJ,OAAO;GACL,MAAM;GACN,cAAc;IAAE,MAAM;IAAY,YAAY;GAAkB;EAClE;CACF;AACF;AAEA,SAAS,WAAiC;CACxC,OAAO;EACL,IAAI;EACJ,OAAO;GACL,MAAM;GACN,cAAc;IAAE,MAAM;IAAY,YAAY;GAAQ;EACxD;CACF;AACF;AAEA,SAAS,YAAkC;CACzC,OAAO,mBAAmB,MAAM;AAClC;AAEA,SAAS,UAAU,OAGM;CACvB,OAAO,MAAM,KAAK,KAAK,eAAe,IAClC,mBAAmB,QAAQ,IAC3B,mBAAmB,QAAQ;AAC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ACA,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\n/**\n * The former `@db.*` native types as first-class top-level type constructors\n * (TML-2986). Codec ids, native types, and typeParams key shapes mirror the\n * legacy `@db.*` attribute path (`NATIVE_TYPE_SPECS` in sql-contract-psl)\n * exactly; every argument is optional, so each name is also authorable bare\n * (`VarChar` ≡ `VarChar()`), and omitted arguments omit their typeParams keys.\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 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 SqlEscapeError,\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, SqlEscapeError };\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,EAAE,OAAO,IAAI,CAAC;GAC7B;EACF;CACF;AACF;AAEA,SAAS,qBAA2C;CAClD,OAAO;EACL,IAAI;EACJ,OAAO;GACL,MAAM;GACN,cAAc;IAAE,MAAM;IAAY,YAAY;GAAkB;EAClE;CACF;AACF;AAEA,SAAS,WAAiC;CACxC,OAAO;EACL,IAAI;EACJ,OAAO;GACL,MAAM;GACN,cAAc;IAAE,MAAM;IAAY,YAAY;GAAQ;EACxD;CACF;AACF;AAEA,SAAS,YAAkC;CACzC,OAAO,mBAAmB,MAAM;AAClC;A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
package/dist/runtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as postgresRawCodecInferer, t as createPostgresAdapter } from "./adapter-
|
|
1
|
+
import { n as postgresRawCodecInferer, t as createPostgresAdapter } from "./adapter-DcBWxseT.mjs";
|
|
2
2
|
import { n as postgresQueryOperations, t as postgresAdapterDescriptorMeta } from "./descriptor-meta-jMtx881n.mjs";
|
|
3
3
|
import { extractCodecLookup } from "@prisma-next/framework-components/control";
|
|
4
4
|
import { postgresCodecRegistry } from "@prisma-next/target-postgres/codecs";
|
|
@@ -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.21",
|
|
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.21",
|
|
9
|
+
"@prisma-next/contract-authoring": "0.16.0-dev.21",
|
|
10
|
+
"@prisma-next/errors": "0.16.0-dev.21",
|
|
11
|
+
"@prisma-next/family-sql": "0.16.0-dev.21",
|
|
12
|
+
"@prisma-next/framework-components": "0.16.0-dev.21",
|
|
13
|
+
"@prisma-next/ids": "0.16.0-dev.21",
|
|
14
|
+
"@prisma-next/psl-parser": "0.16.0-dev.21",
|
|
15
|
+
"@prisma-next/sql-contract": "0.16.0-dev.21",
|
|
16
|
+
"@prisma-next/sql-contract-psl": "0.16.0-dev.21",
|
|
17
|
+
"@prisma-next/sql-contract-ts": "0.16.0-dev.21",
|
|
18
|
+
"@prisma-next/sql-operations": "0.16.0-dev.21",
|
|
19
|
+
"@prisma-next/sql-relational-core": "0.16.0-dev.21",
|
|
20
|
+
"@prisma-next/sql-runtime": "0.16.0-dev.21",
|
|
21
|
+
"@prisma-next/sql-schema-ir": "0.16.0-dev.21",
|
|
22
|
+
"@prisma-next/target-postgres": "0.16.0-dev.21",
|
|
23
|
+
"@prisma-next/utils": "0.16.0-dev.21",
|
|
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.21",
|
|
28
|
+
"@prisma-next/driver-postgres": "0.16.0-dev.21",
|
|
29
|
+
"@prisma-next/migration-tools": "0.16.0-dev.21",
|
|
30
|
+
"@prisma-next/test-utils": "0.16.0-dev.21",
|
|
31
|
+
"@prisma-next/tsconfig": "0.16.0-dev.21",
|
|
32
|
+
"@prisma-next/tsdown": "0.16.0-dev.21",
|
|
33
33
|
"pathe": "^2.0.3",
|
|
34
34
|
"tsdown": "0.22.8",
|
|
35
35
|
"typescript": "5.9.3",
|
|
@@ -867,6 +867,7 @@ export class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
|
|
|
867
867
|
tablename: string;
|
|
868
868
|
indexname: string;
|
|
869
869
|
indisunique: boolean;
|
|
870
|
+
indpartial: boolean;
|
|
870
871
|
attname: string | null;
|
|
871
872
|
index_position: number;
|
|
872
873
|
amname: string | null;
|
|
@@ -885,6 +886,7 @@ export class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
|
|
|
885
886
|
i.tablename,
|
|
886
887
|
i.indexname,
|
|
887
888
|
ix.indisunique,
|
|
889
|
+
ix.indpred IS NOT NULL AS indpartial,
|
|
888
890
|
a.attname,
|
|
889
891
|
k.ord AS index_position,
|
|
890
892
|
am.amname,
|
|
@@ -1130,6 +1132,7 @@ export class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
|
|
|
1130
1132
|
columns: string[];
|
|
1131
1133
|
name: string;
|
|
1132
1134
|
unique: boolean;
|
|
1135
|
+
partial: boolean;
|
|
1133
1136
|
type: string | undefined;
|
|
1134
1137
|
options: Record<string, string> | undefined;
|
|
1135
1138
|
}
|
|
@@ -1165,6 +1168,7 @@ export class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
|
|
|
1165
1168
|
columns: [idxRow.attname],
|
|
1166
1169
|
name: idxRow.indexname,
|
|
1167
1170
|
unique: idxRow.indisunique,
|
|
1171
|
+
partial: idxRow.indpartial,
|
|
1168
1172
|
type: indexType,
|
|
1169
1173
|
options: indexOptions,
|
|
1170
1174
|
});
|
|
@@ -1200,8 +1204,10 @@ export class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
|
|
|
1200
1204
|
columns: Object.freeze([...idx.columns]),
|
|
1201
1205
|
name: idx.name,
|
|
1202
1206
|
unique: idx.unique,
|
|
1203
|
-
|
|
1204
|
-
|
|
1207
|
+
partial: idx.partial,
|
|
1208
|
+
type: idx.type,
|
|
1209
|
+
options: idx.options,
|
|
1210
|
+
annotations: undefined,
|
|
1205
1211
|
dependsOn: postgresColumnDependsOn(schema, tableName, idx.columns),
|
|
1206
1212
|
}),
|
|
1207
1213
|
);
|