@prisma-next/target-postgres 0.14.0-dev.51 → 0.14.0-dev.53

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.
Files changed (63) hide show
  1. package/dist/{authoring-DzHOdWTl.mjs → authoring-ohGMgi8g.mjs} +2 -2
  2. package/dist/{authoring-DzHOdWTl.mjs.map → authoring-ohGMgi8g.mjs.map} +1 -1
  3. package/dist/{codec-types-BDVmvKAW.d.mts → codec-types-BiIWziRO.d.mts} +2 -2
  4. package/dist/{codec-types-BDVmvKAW.d.mts.map → codec-types-BiIWziRO.d.mts.map} +1 -1
  5. package/dist/codec-types.d.mts +1 -1
  6. package/dist/codecs-CkVQrZ4G.mjs +913 -0
  7. package/dist/codecs-CkVQrZ4G.mjs.map +1 -0
  8. package/dist/{codecs-Dk2sxGLv.d.mts → codecs-Cm-nS4mQ.d.mts} +46 -12
  9. package/dist/codecs-Cm-nS4mQ.d.mts.map +1 -0
  10. package/dist/codecs.d.mts +2 -2
  11. package/dist/codecs.mjs +3 -872
  12. package/dist/codecs.mjs.map +1 -1
  13. package/dist/contract-free.mjs +2 -2
  14. package/dist/{control-policy-DUFgy9jO.mjs → control-policy-CafkzSUC.mjs} +4 -4
  15. package/dist/{control-policy-DUFgy9jO.mjs.map → control-policy-CafkzSUC.mjs.map} +1 -1
  16. package/dist/control.mjs +4 -4
  17. package/dist/{ddl-ujxH2A7r.mjs → ddl-CZNFMoCp.mjs} +2 -2
  18. package/dist/{ddl-ujxH2A7r.mjs.map → ddl-CZNFMoCp.mjs.map} +1 -1
  19. package/dist/{descriptor-meta-CuGDsrG4.mjs → descriptor-meta-Cok-1QEK.mjs} +6 -4
  20. package/dist/descriptor-meta-Cok-1QEK.mjs.map +1 -0
  21. package/dist/{diff-database-schema-BmSmWcaY.mjs → diff-database-schema-BivMht-X.mjs} +4 -4
  22. package/dist/{diff-database-schema-BmSmWcaY.mjs.map → diff-database-schema-BivMht-X.mjs.map} +1 -1
  23. package/dist/diff-database-schema.mjs +1 -1
  24. package/dist/issue-planner.mjs +1 -1
  25. package/dist/migration.mjs +2 -2
  26. package/dist/{op-factory-call-BKRnMgrB.mjs → op-factory-call-zo3HqJiO.mjs} +3 -3
  27. package/dist/{op-factory-call-BKRnMgrB.mjs.map → op-factory-call-zo3HqJiO.mjs.map} +1 -1
  28. package/dist/op-factory-call.mjs +1 -1
  29. package/dist/pack.d.mts +4 -2
  30. package/dist/pack.d.mts.map +1 -1
  31. package/dist/pack.mjs +1 -1
  32. package/dist/{planner-produced-postgres-migration-Dp6IO_gj.mjs → planner-produced-postgres-migration-kVlK1Dts.mjs} +2 -2
  33. package/dist/{planner-produced-postgres-migration-Dp6IO_gj.mjs.map → planner-produced-postgres-migration-kVlK1Dts.mjs.map} +1 -1
  34. package/dist/planner-produced-postgres-migration.mjs +1 -1
  35. package/dist/{planner-BMBRPzsv.mjs → planner-r4iLpxD7.mjs} +7 -7
  36. package/dist/{planner-BMBRPzsv.mjs.map → planner-r4iLpxD7.mjs.map} +1 -1
  37. package/dist/{planner-sql-checks-Cze3vMfe.mjs → planner-sql-checks-q58sWl7M.mjs} +2 -2
  38. package/dist/{planner-sql-checks-Cze3vMfe.mjs.map → planner-sql-checks-q58sWl7M.mjs.map} +1 -1
  39. package/dist/planner-sql-checks.mjs +1 -1
  40. package/dist/planner.d.mts +1 -1
  41. package/dist/planner.mjs +2 -2
  42. package/dist/{postgres-contract-view-3xfUgjnC.mjs → postgres-contract-view-C5RSIHFm.mjs} +3 -3
  43. package/dist/{postgres-contract-view-3xfUgjnC.mjs.map → postgres-contract-view-C5RSIHFm.mjs.map} +1 -1
  44. package/dist/{postgres-migration-D0jwzYDT.mjs → postgres-migration-CiA7wpQD.mjs} +3 -3
  45. package/dist/{postgres-migration-D0jwzYDT.mjs.map → postgres-migration-CiA7wpQD.mjs.map} +1 -1
  46. package/dist/{postgres-schema-DqnhQRvR.d.mts → postgres-schema-9vFZLwGo.d.mts} +6 -3
  47. package/dist/{postgres-schema-DqnhQRvR.d.mts.map → postgres-schema-9vFZLwGo.d.mts.map} +1 -1
  48. package/dist/{postgres-schema-CajYAwny.mjs → postgres-schema-CsOBpCwV.mjs} +5 -2
  49. package/dist/{postgres-schema-CajYAwny.mjs.map → postgres-schema-CsOBpCwV.mjs.map} +1 -1
  50. package/dist/{resolve-ddl-schema-Bv1ZvjX8.mjs → resolve-ddl-schema-gmgUaHK3.mjs} +2 -2
  51. package/dist/{resolve-ddl-schema-Bv1ZvjX8.mjs.map → resolve-ddl-schema-gmgUaHK3.mjs.map} +1 -1
  52. package/dist/runtime.mjs +1 -1
  53. package/dist/schema-ir-annotations.mjs +1 -1
  54. package/dist/types.d.mts +2 -2
  55. package/dist/types.mjs +3 -2
  56. package/package.json +20 -20
  57. package/src/core/codecs.ts +55 -16
  58. package/src/core/descriptor-meta.ts +2 -0
  59. package/src/core/postgres-schema.ts +4 -1
  60. package/src/exports/codecs.ts +3 -0
  61. package/src/exports/types.ts +1 -0
  62. package/dist/codecs-Dk2sxGLv.d.mts.map +0 -1
  63. package/dist/descriptor-meta-CuGDsrG4.mjs.map +0 -1
package/dist/codecs.mjs CHANGED
@@ -1,882 +1,13 @@
1
- import { C as PG_UUID_CODEC_ID, S as PG_TIME_CODEC_ID, T as PG_VARCHAR_CODEC_ID, _ as PG_TEXT_ARRAY_CODEC_ID, a as PG_ENUM_CODEC_ID, b as PG_TIMESTAMP_CODEC_ID, c as PG_FLOAT_CODEC_ID, d as PG_INT8_CODEC_ID, f as PG_INTERVAL_CODEC_ID, g as PG_NUMERIC_CODEC_ID, h as PG_JSON_CODEC_ID, i as PG_CHAR_CODEC_ID, l as PG_INT2_CODEC_ID, m as PG_JSONB_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT4_CODEC_ID, p as PG_INT_CODEC_ID, r as PG_BYTEA_CODEC_ID, s as PG_FLOAT8_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT4_CODEC_ID, v as PG_TEXT_CODEC_ID, w as PG_VARBIT_CODEC_ID, x as PG_TIMETZ_CODEC_ID, y as PG_TIMESTAMPTZ_CODEC_ID } from "./codec-ids-C_-Hj6bL.mjs";
2
- import "./namespace-ids-xtp_ZY86.mjs";
3
- import { t as PostgresNativeEnum } from "./postgres-native-enum-xdiqmBf_.mjs";
4
- import { SqlCharCodec, SqlFloatCodec, SqlIntCodec, SqlVarcharCodec, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlTextDescriptor, sqlTimestampDescriptor, sqlVarcharDescriptor } from "@prisma-next/sql-relational-core/ast";
5
- import { CodecDescriptorImpl, CodecImpl, column, renderTsLiteral, voidParamsSchema } from "@prisma-next/framework-components/codec";
6
- import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
7
- import { blindCast } from "@prisma-next/utils/casts";
8
- import { type } from "arktype";
1
+ import { C as pgVarbitColumn, S as pgUuidColumn, _ as pgTextColumn, a as pgEnumDescriptor, b as pgTimestamptzColumn, c as pgFloatColumn, d as pgInt8Column, f as pgIntColumn, g as pgNumericColumn, h as pgJsonbColumn, i as pgCharColumn, l as pgInt2Column, m as pgJsonColumn, n as pgBitColumn, o as pgFloat4Column, p as pgIntervalColumn, r as pgBoolColumn, s as pgFloat8Column, t as codecDescriptors, u as pgInt4Column, v as pgTimeColumn, w as pgVarcharColumn, x as pgTimetzColumn, y as pgTimestampColumn } from "./codecs-CkVQrZ4G.mjs";
9
2
  import { buildCodecDescriptorRegistry } from "@prisma-next/sql-relational-core/codec-descriptor-registry";
10
- //#region src/core/codec-helpers.ts
11
- function renderLength(typeName, typeParams) {
12
- const length = typeParams["length"];
13
- if (length === void 0) return;
14
- if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length)) throw new Error(`renderOutputType: expected integer "length" in typeParams for ${typeName}, got ${String(length)}`);
15
- return `${typeName}<${length}>`;
16
- }
17
- function renderPrecision(typeName, typeParams) {
18
- const precision = typeParams["precision"];
19
- if (precision === void 0) return typeName;
20
- if (typeof precision !== "number" || !Number.isFinite(precision) || !Number.isInteger(precision)) throw new Error(`renderOutputType: expected integer "precision" in typeParams for ${typeName}, got ${String(precision)}`);
21
- return `${typeName}<${precision}>`;
22
- }
23
- const pgNumericDecode = (wire) => {
24
- if (typeof wire === "number") return String(wire);
25
- return wire;
26
- };
27
- const pgNumericRenderOutputType = (typeParams) => {
28
- const precision = typeParams.precision;
29
- if (precision === void 0) return void 0;
30
- if (typeof precision !== "number" || !Number.isFinite(precision) || !Number.isInteger(precision)) throw new Error(`renderOutputType: expected integer "precision" in typeParams for Numeric, got ${String(precision)}`);
31
- const scale = typeParams.scale;
32
- if (scale === void 0) return `Numeric<${precision}>`;
33
- if (typeof scale !== "number" || !Number.isFinite(scale) || !Number.isInteger(scale)) throw new Error(`renderOutputType: expected integer "scale" in typeParams for Numeric, got ${String(scale)}`);
34
- return `Numeric<${precision}, ${scale}>`;
35
- };
36
- const ISO_8601_UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/;
37
- const pgTimestampEncodeJson = (value) => value.toISOString();
38
- const pgTimestampDecodeJson = (json) => {
39
- if (typeof json !== "string") throw new Error(`Expected ISO date string for pg/timestamp@1, got ${typeof json}`);
40
- if (!ISO_8601_UTC.test(json)) throw new Error(`Invalid ISO date string for pg/timestamp@1: ${json}`);
41
- const date = new Date(json);
42
- if (Number.isNaN(date.getTime())) throw new Error(`Invalid ISO date string for pg/timestamp@1: ${json}`);
43
- return date;
44
- };
45
- const pgTimestamptzEncodeJson = (value) => value.toISOString();
46
- const pgTimestamptzDecodeJson = (json) => {
47
- if (typeof json !== "string") throw new Error(`Expected ISO date string for pg/timestamptz@1, got ${typeof json}`);
48
- if (!ISO_8601_UTC.test(json)) throw new Error(`Invalid ISO date string for pg/timestamptz@1: ${json}`);
49
- const date = new Date(json);
50
- if (Number.isNaN(date.getTime())) throw new Error(`Invalid ISO date string for pg/timestamptz@1: ${json}`);
51
- return date;
52
- };
53
- const pgIntervalDecode = (wire) => {
54
- if (typeof wire === "string") return wire;
55
- return JSON.stringify(wire);
56
- };
57
- const pgJsonEncode = (value) => JSON.stringify(value);
58
- const pgJsonDecode = (wire) => typeof wire === "string" ? JSON.parse(wire) : wire;
59
- const pgJsonbEncode = (value) => JSON.stringify(value);
60
- const pgJsonbDecode = (wire) => typeof wire === "string" ? JSON.parse(wire) : wire;
61
- //#endregion
62
- //#region src/core/codecs.ts
63
- const lengthParamsSchema = type({ "length?": "number.integer > 0" });
64
- const numericParamsSchema = type({
65
- precision: "number.integer > 0 & number.integer <= 1000",
66
- "scale?": "number.integer >= 0"
67
- });
68
- const precisionParamsSchema = type({ "precision?": "number.integer >= 0 & number.integer <= 6" });
69
- const PG_TEXT_META = { db: { sql: { postgres: { nativeType: "text" } } } };
70
- const PG_TEXT_ARRAY_META = { db: { sql: { postgres: { nativeType: "text[]" } } } };
71
- const PG_INT4_META = { db: { sql: { postgres: { nativeType: "integer" } } } };
72
- const PG_INT2_META = { db: { sql: { postgres: { nativeType: "smallint" } } } };
73
- const PG_INT8_META = { db: { sql: { postgres: { nativeType: "bigint" } } } };
74
- const PG_FLOAT4_META = { db: { sql: { postgres: { nativeType: "real" } } } };
75
- const PG_FLOAT8_META = { db: { sql: { postgres: { nativeType: "double precision" } } } };
76
- const PG_NUMERIC_META = { db: { sql: { postgres: { nativeType: "numeric" } } } };
77
- const PG_TIMESTAMP_META = { db: { sql: { postgres: { nativeType: "timestamp without time zone" } } } };
78
- const PG_TIMESTAMPTZ_META = { db: { sql: { postgres: { nativeType: "timestamp with time zone" } } } };
79
- const PG_TIME_META = { db: { sql: { postgres: { nativeType: "time" } } } };
80
- const PG_TIMETZ_META = { db: { sql: { postgres: { nativeType: "timetz" } } } };
81
- const PG_BOOL_META = { db: { sql: { postgres: { nativeType: "boolean" } } } };
82
- const PG_BIT_META = { db: { sql: { postgres: { nativeType: "bit" } } } };
83
- const PG_VARBIT_META = { db: { sql: { postgres: { nativeType: "bit varying" } } } };
84
- const PG_BYTEA_META = { db: { sql: { postgres: { nativeType: "bytea" } } } };
85
- const PG_INTERVAL_META = { db: { sql: { postgres: { nativeType: "interval" } } } };
86
- const PG_JSON_META = { db: { sql: { postgres: { nativeType: "json" } } } };
87
- const PG_JSONB_META = { db: { sql: { postgres: { nativeType: "jsonb" } } } };
88
- var PgTextCodec = class extends CodecImpl {
89
- async encode(value, _ctx) {
90
- return value;
91
- }
92
- async decode(wire, _ctx) {
93
- return wire;
94
- }
95
- encodeJson(value) {
96
- return value;
97
- }
98
- decodeJson(json) {
99
- return json;
100
- }
101
- };
102
- var PgTextDescriptor = class extends CodecDescriptorImpl {
103
- codecId = PG_TEXT_CODEC_ID;
104
- traits = [
105
- "equality",
106
- "order",
107
- "textual"
108
- ];
109
- targetTypes = ["text"];
110
- meta = PG_TEXT_META;
111
- paramsSchema = voidParamsSchema;
112
- renderValueLiteral(value) {
113
- return renderTsLiteral(value);
114
- }
115
- factory() {
116
- return () => new PgTextCodec(this);
117
- }
118
- };
119
- const pgTextDescriptor = new PgTextDescriptor();
120
- const pgTextColumn = () => column(pgTextDescriptor.factory(), pgTextDescriptor.codecId, void 0, "text");
121
- /**
122
- * Codec for a `pg.enum(Ref)` column bound to a native Postgres enum type.
123
- * Text passthrough, identical to `pg/text@1` — encode/decode do not carry the
124
- * enum's member values; membership is enforced by the native type itself, not
125
- * by this codec. `renderValueLiteral` renders a member value as its TS
126
- * literal, which is what drives the column's typed value-union (via
127
- * `renderValueSetType` reading the column's `valueSet` ref) — the codec
128
- * itself carries no params of its own; typing comes entirely from the
129
- * column's value-set, not from `pg/enum@1`.
130
- *
131
- * A distinct codec id (rather than reusing `pg/text@1` on a plain text
132
- * column) keeps native-enum columns independently identifiable — from a
133
- * column's `codecId` alone, without also inspecting `nativeType` — which
134
- * the managed (DDL) phase needs to target `CREATE TYPE`/`ALTER TYPE`
135
- * operations at exactly the columns that use one.
136
- */
137
- var PgEnumCodec = class extends CodecImpl {
138
- async encode(value, _ctx) {
139
- return value;
140
- }
141
- async decode(wire, _ctx) {
142
- return wire;
143
- }
144
- encodeJson(value) {
145
- return value;
146
- }
147
- decodeJson(json) {
148
- return blindCast(json);
149
- }
150
- };
151
- const pgEnumParamsSchema = type({ typeName: "string" });
152
- function isJsonObject(value) {
153
- return typeof value === "object" && value !== null && !Array.isArray(value);
154
- }
155
- var PgEnumDescriptor = class extends CodecDescriptorImpl {
156
- codecId = PG_ENUM_CODEC_ID;
157
- traits = [
158
- "equality",
159
- "order",
160
- "textual"
161
- ];
162
- targetTypes = ["text"];
163
- meta = PG_TEXT_META;
164
- paramsSchema = pgEnumParamsSchema;
165
- renderValueLiteral(value) {
166
- return renderTsLiteral(value);
167
- }
168
- metaFor(typeParams) {
169
- if (!isJsonObject(typeParams)) return this.meta;
170
- const typeName = typeParams["typeName"];
171
- return typeof typeName === "string" ? { db: { sql: { postgres: { nativeType: typeName } } } } : this.meta;
172
- }
173
- factory(_params) {
174
- return () => new PgEnumCodec(this);
175
- }
176
- /**
177
- * Authoring-time hook a `pg.enum(<ref>)` type constructor calls once it has
178
- * resolved its ref argument to the referenced `native_enum` entity: given
179
- * that entity and the field's namespace id, produces this codec's
180
- * per-column `typeParams` and native type. The type name is schema-qualified
181
- * for a named non-default schema (matching `format_type()`); `public` and
182
- * the unbound namespace stay bare (`search_path`). `nativeType` mirrors
183
- * `typeParams.typeName` — the same value {@link metaFor} derives at
184
- * render time — so the column's declared native type and the render-time
185
- * cast agree. Returns `undefined` if `entity` is not a `PostgresNativeEnum`
186
- * (a contributor bug, not a user-schema error — the caller decides how to
187
- * report it).
188
- */
189
- columnFromEntity(entity, namespaceId) {
190
- if (!PostgresNativeEnum.is(entity)) return void 0;
191
- const typeName = namespaceId !== void 0 && namespaceId !== "public" && namespaceId !== UNBOUND_NAMESPACE_ID ? `${namespaceId}.${entity.typeName}` : entity.typeName;
192
- return {
193
- typeParams: { typeName },
194
- nativeType: typeName
195
- };
196
- }
197
- };
198
- const pgEnumDescriptor = new PgEnumDescriptor();
199
- /**
200
- * Postgres `text[]` codec. Encode is an identity pass-through: the pg wire
201
- * driver serialises a JS `string[]` to a Postgres array literal under the
202
- * `$N::text[]` cast the renderer emits from this codec's `text[]` native type,
203
- * and decode reads it back as a JS array. Used by the control plane to write
204
- * the marker's `invariants` column. Not a user-facing scalar — it is not part
205
- * of the authorable `CodecTypes` surface, only the runtime codec registry.
206
- */
207
- var PgTextArrayCodec = class extends CodecImpl {
208
- async encode(value, _ctx) {
209
- return value;
210
- }
211
- async decode(wire, _ctx) {
212
- return wire;
213
- }
214
- encodeJson(value) {
215
- return [...value];
216
- }
217
- decodeJson(json) {
218
- return Array.isArray(json) ? json.map((entry) => String(entry)) : [];
219
- }
220
- };
221
- var PgTextArrayDescriptor = class extends CodecDescriptorImpl {
222
- codecId = PG_TEXT_ARRAY_CODEC_ID;
223
- traits = ["equality"];
224
- targetTypes = ["text[]"];
225
- meta = PG_TEXT_ARRAY_META;
226
- paramsSchema = voidParamsSchema;
227
- factory() {
228
- return () => new PgTextArrayCodec(this);
229
- }
230
- };
231
- const pgTextArrayDescriptor = new PgTextArrayDescriptor();
232
- var PgInt4Codec = class extends CodecImpl {
233
- async encode(value, _ctx) {
234
- return value;
235
- }
236
- async decode(wire, _ctx) {
237
- return wire;
238
- }
239
- encodeJson(value) {
240
- return value;
241
- }
242
- decodeJson(json) {
243
- return json;
244
- }
245
- };
246
- var PgInt4Descriptor = class extends CodecDescriptorImpl {
247
- codecId = PG_INT4_CODEC_ID;
248
- traits = [
249
- "equality",
250
- "order",
251
- "numeric"
252
- ];
253
- targetTypes = ["int4"];
254
- meta = PG_INT4_META;
255
- paramsSchema = voidParamsSchema;
256
- renderValueLiteral(value) {
257
- return renderTsLiteral(value);
258
- }
259
- factory() {
260
- return () => new PgInt4Codec(this);
261
- }
262
- };
263
- const pgInt4Descriptor = new PgInt4Descriptor();
264
- const pgInt4Column = () => column(pgInt4Descriptor.factory(), pgInt4Descriptor.codecId, void 0, "int4");
265
- var PgInt2Codec = class extends CodecImpl {
266
- async encode(value, _ctx) {
267
- return value;
268
- }
269
- async decode(wire, _ctx) {
270
- return wire;
271
- }
272
- encodeJson(value) {
273
- return value;
274
- }
275
- decodeJson(json) {
276
- return json;
277
- }
278
- };
279
- var PgInt2Descriptor = class extends CodecDescriptorImpl {
280
- codecId = PG_INT2_CODEC_ID;
281
- traits = [
282
- "equality",
283
- "order",
284
- "numeric"
285
- ];
286
- targetTypes = ["int2"];
287
- meta = PG_INT2_META;
288
- paramsSchema = voidParamsSchema;
289
- renderValueLiteral(value) {
290
- return renderTsLiteral(value);
291
- }
292
- factory() {
293
- return () => new PgInt2Codec(this);
294
- }
295
- };
296
- const pgInt2Descriptor = new PgInt2Descriptor();
297
- const pgInt2Column = () => column(pgInt2Descriptor.factory(), pgInt2Descriptor.codecId, void 0, "int2");
298
- var PgInt8Codec = class extends CodecImpl {
299
- async encode(value, _ctx) {
300
- return value;
301
- }
302
- async decode(wire, _ctx) {
303
- return wire;
304
- }
305
- encodeJson(value) {
306
- return value;
307
- }
308
- decodeJson(json) {
309
- return json;
310
- }
311
- };
312
- var PgInt8Descriptor = class extends CodecDescriptorImpl {
313
- codecId = PG_INT8_CODEC_ID;
314
- traits = [
315
- "equality",
316
- "order",
317
- "numeric"
318
- ];
319
- targetTypes = ["int8"];
320
- meta = PG_INT8_META;
321
- paramsSchema = voidParamsSchema;
322
- renderValueLiteral(value) {
323
- return renderTsLiteral(value);
324
- }
325
- factory() {
326
- return () => new PgInt8Codec(this);
327
- }
328
- };
329
- const pgInt8Descriptor = new PgInt8Descriptor();
330
- const pgInt8Column = () => column(pgInt8Descriptor.factory(), pgInt8Descriptor.codecId, void 0, "int8");
331
- var PgFloat4Codec = class extends CodecImpl {
332
- async encode(value, _ctx) {
333
- return value;
334
- }
335
- async decode(wire, _ctx) {
336
- return wire;
337
- }
338
- encodeJson(value) {
339
- return value;
340
- }
341
- decodeJson(json) {
342
- return json;
343
- }
344
- };
345
- var PgFloat4Descriptor = class extends CodecDescriptorImpl {
346
- codecId = PG_FLOAT4_CODEC_ID;
347
- traits = [
348
- "equality",
349
- "order",
350
- "numeric"
351
- ];
352
- targetTypes = ["float4"];
353
- meta = PG_FLOAT4_META;
354
- paramsSchema = voidParamsSchema;
355
- renderValueLiteral(value) {
356
- return renderTsLiteral(value);
357
- }
358
- factory() {
359
- return () => new PgFloat4Codec(this);
360
- }
361
- };
362
- const pgFloat4Descriptor = new PgFloat4Descriptor();
363
- const pgFloat4Column = () => column(pgFloat4Descriptor.factory(), pgFloat4Descriptor.codecId, void 0, "float4");
364
- var PgFloat8Codec = class extends CodecImpl {
365
- async encode(value, _ctx) {
366
- return value;
367
- }
368
- async decode(wire, _ctx) {
369
- return wire;
370
- }
371
- encodeJson(value) {
372
- return value;
373
- }
374
- decodeJson(json) {
375
- return json;
376
- }
377
- };
378
- var PgFloat8Descriptor = class extends CodecDescriptorImpl {
379
- codecId = PG_FLOAT8_CODEC_ID;
380
- traits = [
381
- "equality",
382
- "order",
383
- "numeric"
384
- ];
385
- targetTypes = ["float8"];
386
- meta = PG_FLOAT8_META;
387
- paramsSchema = voidParamsSchema;
388
- renderValueLiteral(value) {
389
- return renderTsLiteral(value);
390
- }
391
- factory() {
392
- return () => new PgFloat8Codec(this);
393
- }
394
- };
395
- const pgFloat8Descriptor = new PgFloat8Descriptor();
396
- const pgFloat8Column = () => column(pgFloat8Descriptor.factory(), pgFloat8Descriptor.codecId, void 0, "float8");
397
- var PgBoolCodec = class extends CodecImpl {
398
- async encode(value, _ctx) {
399
- return value;
400
- }
401
- async decode(wire, _ctx) {
402
- return wire;
403
- }
404
- encodeJson(value) {
405
- return value;
406
- }
407
- decodeJson(json) {
408
- return json;
409
- }
410
- };
411
- var PgBoolDescriptor = class extends CodecDescriptorImpl {
412
- codecId = PG_BOOL_CODEC_ID;
413
- traits = ["equality", "boolean"];
414
- targetTypes = ["bool"];
415
- meta = PG_BOOL_META;
416
- paramsSchema = voidParamsSchema;
417
- renderValueLiteral(value) {
418
- return renderTsLiteral(value);
419
- }
420
- factory() {
421
- return () => new PgBoolCodec(this);
422
- }
423
- };
424
- const pgBoolDescriptor = new PgBoolDescriptor();
425
- const pgBoolColumn = () => column(pgBoolDescriptor.factory(), pgBoolDescriptor.codecId, void 0, "bool");
426
- var PgNumericCodec = class extends CodecImpl {
427
- async encode(value, _ctx) {
428
- return value;
429
- }
430
- async decode(wire, _ctx) {
431
- return pgNumericDecode(wire);
432
- }
433
- encodeJson(value) {
434
- return value;
435
- }
436
- decodeJson(json) {
437
- return json;
438
- }
439
- };
440
- var PgNumericDescriptor = class extends CodecDescriptorImpl {
441
- codecId = PG_NUMERIC_CODEC_ID;
442
- traits = [
443
- "equality",
444
- "order",
445
- "numeric"
446
- ];
447
- targetTypes = ["numeric", "decimal"];
448
- meta = PG_NUMERIC_META;
449
- paramsSchema = numericParamsSchema;
450
- renderOutputType(params) {
451
- return pgNumericRenderOutputType(params);
452
- }
453
- factory(_params) {
454
- return () => new PgNumericCodec(this);
455
- }
456
- };
457
- const pgNumericDescriptor = new PgNumericDescriptor();
458
- const pgNumericColumn = (params) => column(pgNumericDescriptor.factory(params), pgNumericDescriptor.codecId, params, "numeric");
459
- var PgTimestampCodec = class extends CodecImpl {
460
- async encode(value, _ctx) {
461
- return value;
462
- }
463
- async decode(wire, _ctx) {
464
- return wire;
465
- }
466
- encodeJson(value) {
467
- return pgTimestampEncodeJson(value);
468
- }
469
- decodeJson(json) {
470
- return pgTimestampDecodeJson(json);
471
- }
472
- };
473
- var PgTimestampDescriptor = class extends CodecDescriptorImpl {
474
- codecId = PG_TIMESTAMP_CODEC_ID;
475
- traits = ["equality", "order"];
476
- targetTypes = ["timestamp"];
477
- meta = PG_TIMESTAMP_META;
478
- paramsSchema = precisionParamsSchema;
479
- renderOutputType(params) {
480
- return renderPrecision("Timestamp", params);
481
- }
482
- factory(_params) {
483
- return () => new PgTimestampCodec(this);
484
- }
485
- };
486
- const pgTimestampDescriptor = new PgTimestampDescriptor();
487
- const pgTimestampColumn = (params = {}) => column(pgTimestampDescriptor.factory(params), pgTimestampDescriptor.codecId, params, "timestamp");
488
- var PgTimestamptzCodec = class extends CodecImpl {
489
- async encode(value, _ctx) {
490
- return value;
491
- }
492
- async decode(wire, _ctx) {
493
- return wire;
494
- }
495
- encodeJson(value) {
496
- return pgTimestamptzEncodeJson(value);
497
- }
498
- decodeJson(json) {
499
- return pgTimestamptzDecodeJson(json);
500
- }
501
- };
502
- var PgTimestamptzDescriptor = class extends CodecDescriptorImpl {
503
- codecId = PG_TIMESTAMPTZ_CODEC_ID;
504
- traits = ["equality", "order"];
505
- targetTypes = ["timestamptz"];
506
- meta = PG_TIMESTAMPTZ_META;
507
- paramsSchema = precisionParamsSchema;
508
- renderOutputType(params) {
509
- return renderPrecision("Timestamptz", params);
510
- }
511
- factory(_params) {
512
- return () => new PgTimestamptzCodec(this);
513
- }
514
- };
515
- const pgTimestamptzDescriptor = new PgTimestamptzDescriptor();
516
- const pgTimestamptzColumn = (params = {}) => column(pgTimestamptzDescriptor.factory(params), pgTimestamptzDescriptor.codecId, params, "timestamptz");
517
- var PgTimeCodec = class extends CodecImpl {
518
- async encode(value, _ctx) {
519
- return value;
520
- }
521
- async decode(wire, _ctx) {
522
- return wire;
523
- }
524
- encodeJson(value) {
525
- return value;
526
- }
527
- decodeJson(json) {
528
- return json;
529
- }
530
- };
531
- var PgTimeDescriptor = class extends CodecDescriptorImpl {
532
- codecId = PG_TIME_CODEC_ID;
533
- traits = ["equality", "order"];
534
- targetTypes = ["time"];
535
- meta = PG_TIME_META;
536
- paramsSchema = precisionParamsSchema;
537
- renderOutputType(params) {
538
- return renderPrecision("Time", params);
539
- }
540
- factory(_params) {
541
- return () => new PgTimeCodec(this);
542
- }
543
- };
544
- const pgTimeDescriptor = new PgTimeDescriptor();
545
- const pgTimeColumn = (params = {}) => column(pgTimeDescriptor.factory(params), pgTimeDescriptor.codecId, params, "time");
546
- var PgTimetzCodec = class extends CodecImpl {
547
- async encode(value, _ctx) {
548
- return value;
549
- }
550
- async decode(wire, _ctx) {
551
- return wire;
552
- }
553
- encodeJson(value) {
554
- return value;
555
- }
556
- decodeJson(json) {
557
- return json;
558
- }
559
- };
560
- var PgTimetzDescriptor = class extends CodecDescriptorImpl {
561
- codecId = PG_TIMETZ_CODEC_ID;
562
- traits = ["equality", "order"];
563
- targetTypes = ["timetz"];
564
- meta = PG_TIMETZ_META;
565
- paramsSchema = precisionParamsSchema;
566
- renderOutputType(params) {
567
- return renderPrecision("Timetz", params);
568
- }
569
- factory(_params) {
570
- return () => new PgTimetzCodec(this);
571
- }
572
- };
573
- const pgTimetzDescriptor = new PgTimetzDescriptor();
574
- const pgTimetzColumn = (params = {}) => column(pgTimetzDescriptor.factory(params), pgTimetzDescriptor.codecId, params, "timetz");
575
- var PgBitCodec = class extends CodecImpl {
576
- async encode(value, _ctx) {
577
- return value;
578
- }
579
- async decode(wire, _ctx) {
580
- return wire;
581
- }
582
- encodeJson(value) {
583
- return value;
584
- }
585
- decodeJson(json) {
586
- return json;
587
- }
588
- };
589
- var PgBitDescriptor = class extends CodecDescriptorImpl {
590
- codecId = PG_BIT_CODEC_ID;
591
- traits = ["equality", "order"];
592
- targetTypes = ["bit"];
593
- meta = PG_BIT_META;
594
- paramsSchema = lengthParamsSchema;
595
- renderOutputType(params) {
596
- return renderLength("Bit", params);
597
- }
598
- factory(_params) {
599
- return () => new PgBitCodec(this);
600
- }
601
- };
602
- const pgBitDescriptor = new PgBitDescriptor();
603
- const pgBitColumn = (params = {}) => column(pgBitDescriptor.factory(params), pgBitDescriptor.codecId, params, "bit");
604
- var PgVarbitCodec = class extends CodecImpl {
605
- async encode(value, _ctx) {
606
- return value;
607
- }
608
- async decode(wire, _ctx) {
609
- return wire;
610
- }
611
- encodeJson(value) {
612
- return value;
613
- }
614
- decodeJson(json) {
615
- return json;
616
- }
617
- };
618
- var PgVarbitDescriptor = class extends CodecDescriptorImpl {
619
- codecId = PG_VARBIT_CODEC_ID;
620
- traits = ["equality", "order"];
621
- targetTypes = ["bit varying"];
622
- meta = PG_VARBIT_META;
623
- paramsSchema = lengthParamsSchema;
624
- renderOutputType(params) {
625
- return renderLength("VarBit", params);
626
- }
627
- factory(_params) {
628
- return () => new PgVarbitCodec(this);
629
- }
630
- };
631
- const pgVarbitDescriptor = new PgVarbitDescriptor();
632
- const pgVarbitColumn = (params = {}) => column(pgVarbitDescriptor.factory(params), pgVarbitDescriptor.codecId, params, "bit varying");
633
- var PgByteaCodec = class extends CodecImpl {
634
- async encode(value, _ctx) {
635
- return value;
636
- }
637
- async decode(wire, _ctx) {
638
- return wire instanceof Uint8Array && wire.constructor === Uint8Array ? wire : new Uint8Array(wire.buffer, wire.byteOffset, wire.byteLength);
639
- }
640
- encodeJson(value) {
641
- return Buffer.from(value).toString("base64");
642
- }
643
- decodeJson(json) {
644
- if (typeof json !== "string") throw new Error(`Expected base64 string for pg/bytea@1, got ${typeof json}`);
645
- const decoded = Buffer.from(json, "base64");
646
- if (decoded.toString("base64") !== json) throw new Error(`Invalid base64 string for pg/bytea@1 (length: ${json.length})`);
647
- return new Uint8Array(decoded);
648
- }
649
- };
650
- var PgByteaDescriptor = class extends CodecDescriptorImpl {
651
- codecId = PG_BYTEA_CODEC_ID;
652
- traits = ["equality"];
653
- targetTypes = ["bytea"];
654
- meta = PG_BYTEA_META;
655
- paramsSchema = voidParamsSchema;
656
- factory() {
657
- return () => new PgByteaCodec(this);
658
- }
659
- };
660
- const pgByteaDescriptor = new PgByteaDescriptor();
661
- const PG_UUID_META = { db: { sql: { postgres: { nativeType: "uuid" } } } };
662
- var PgUuidCodec = class extends CodecImpl {
663
- async encode(value, _ctx) {
664
- return value;
665
- }
666
- async decode(wire, _ctx) {
667
- return wire;
668
- }
669
- encodeJson(value) {
670
- return value;
671
- }
672
- decodeJson(json) {
673
- return blindCast(json);
674
- }
675
- };
676
- var PgUuidDescriptor = class extends CodecDescriptorImpl {
677
- codecId = PG_UUID_CODEC_ID;
678
- traits = ["equality", "order"];
679
- targetTypes = ["uuid"];
680
- meta = PG_UUID_META;
681
- paramsSchema = voidParamsSchema;
682
- factory() {
683
- return () => new PgUuidCodec(this);
684
- }
685
- };
686
- const pgUuidDescriptor = new PgUuidDescriptor();
687
- const pgUuidColumn = () => column(pgUuidDescriptor.factory(), pgUuidDescriptor.codecId, void 0, "uuid");
688
- var PgIntervalCodec = class extends CodecImpl {
689
- async encode(value, _ctx) {
690
- return value;
691
- }
692
- async decode(wire, _ctx) {
693
- return pgIntervalDecode(wire);
694
- }
695
- encodeJson(value) {
696
- return value;
697
- }
698
- decodeJson(json) {
699
- return json;
700
- }
701
- };
702
- var PgIntervalDescriptor = class extends CodecDescriptorImpl {
703
- codecId = PG_INTERVAL_CODEC_ID;
704
- traits = ["equality", "order"];
705
- targetTypes = ["interval"];
706
- meta = PG_INTERVAL_META;
707
- paramsSchema = precisionParamsSchema;
708
- renderOutputType(params) {
709
- return renderPrecision("Interval", params);
710
- }
711
- factory(_params) {
712
- return () => new PgIntervalCodec(this);
713
- }
714
- };
715
- const pgIntervalDescriptor = new PgIntervalDescriptor();
716
- const pgIntervalColumn = (params = {}) => column(pgIntervalDescriptor.factory(params), pgIntervalDescriptor.codecId, params, "interval");
717
- var PgJsonCodec = class extends CodecImpl {
718
- async encode(value, _ctx) {
719
- return pgJsonEncode(value);
720
- }
721
- async decode(wire, _ctx) {
722
- return pgJsonDecode(wire);
723
- }
724
- encodeJson(value) {
725
- return value;
726
- }
727
- decodeJson(json) {
728
- return json;
729
- }
730
- };
731
- var PgJsonDescriptor = class extends CodecDescriptorImpl {
732
- codecId = PG_JSON_CODEC_ID;
733
- traits = [];
734
- targetTypes = ["json"];
735
- meta = PG_JSON_META;
736
- paramsSchema = voidParamsSchema;
737
- factory() {
738
- return () => new PgJsonCodec(this);
739
- }
740
- };
741
- const pgJsonDescriptor = new PgJsonDescriptor();
742
- const pgJsonColumn = () => column(pgJsonDescriptor.factory(), pgJsonDescriptor.codecId, void 0, "json");
743
- var PgJsonbCodec = class extends CodecImpl {
744
- async encode(value, _ctx) {
745
- return pgJsonbEncode(value);
746
- }
747
- async decode(wire, _ctx) {
748
- return pgJsonbDecode(wire);
749
- }
750
- encodeJson(value) {
751
- return value;
752
- }
753
- decodeJson(json) {
754
- return json;
755
- }
756
- };
757
- var PgJsonbDescriptor = class extends CodecDescriptorImpl {
758
- codecId = PG_JSONB_CODEC_ID;
759
- traits = ["equality"];
760
- targetTypes = ["jsonb"];
761
- meta = PG_JSONB_META;
762
- paramsSchema = voidParamsSchema;
763
- factory() {
764
- return () => new PgJsonbCodec(this);
765
- }
766
- };
767
- const pgJsonbDescriptor = new PgJsonbDescriptor();
768
- const pgJsonbColumn = () => column(pgJsonbDescriptor.factory(), pgJsonbDescriptor.codecId, void 0, "jsonb");
769
- const PG_CHAR_META = { db: { sql: { postgres: { nativeType: "character" } } } };
770
- const PG_VARCHAR_META = { db: { sql: { postgres: { nativeType: "character varying" } } } };
771
- const PG_INT_META = { db: { sql: { postgres: { nativeType: "integer" } } } };
772
- const PG_FLOAT_META = { db: { sql: { postgres: { nativeType: "double precision" } } } };
773
- var PgCharDescriptor = class extends CodecDescriptorImpl {
774
- codecId = PG_CHAR_CODEC_ID;
775
- targetTypes = ["character"];
776
- meta = PG_CHAR_META;
777
- traits = sqlCharDescriptor.traits;
778
- paramsSchema = sqlCharDescriptor.paramsSchema;
779
- renderOutputType(params) {
780
- return sqlCharDescriptor.renderOutputType(params);
781
- }
782
- renderValueLiteral(value) {
783
- return renderTsLiteral(value);
784
- }
785
- factory(_params) {
786
- return () => new SqlCharCodec(this);
787
- }
788
- };
789
- const pgCharDescriptor = new PgCharDescriptor();
790
- const pgCharColumn = (params = {}) => column(pgCharDescriptor.factory(params), pgCharDescriptor.codecId, params, "character");
791
- var PgVarcharDescriptor = class extends CodecDescriptorImpl {
792
- codecId = PG_VARCHAR_CODEC_ID;
793
- targetTypes = ["character varying"];
794
- meta = PG_VARCHAR_META;
795
- traits = sqlVarcharDescriptor.traits;
796
- paramsSchema = sqlVarcharDescriptor.paramsSchema;
797
- renderOutputType(params) {
798
- return sqlVarcharDescriptor.renderOutputType(params);
799
- }
800
- renderValueLiteral(value) {
801
- return renderTsLiteral(value);
802
- }
803
- factory(_params) {
804
- return () => new SqlVarcharCodec(this);
805
- }
806
- };
807
- const pgVarcharDescriptor = new PgVarcharDescriptor();
808
- const pgVarcharColumn = (params = {}) => column(pgVarcharDescriptor.factory(params), pgVarcharDescriptor.codecId, params, "character varying");
809
- var PgIntDescriptor = class extends CodecDescriptorImpl {
810
- codecId = PG_INT_CODEC_ID;
811
- targetTypes = ["int4"];
812
- meta = PG_INT_META;
813
- traits = sqlIntDescriptor.traits;
814
- paramsSchema = sqlIntDescriptor.paramsSchema;
815
- renderValueLiteral(value) {
816
- return renderTsLiteral(value);
817
- }
818
- factory() {
819
- return () => new SqlIntCodec(this);
820
- }
821
- };
822
- const pgIntDescriptor = new PgIntDescriptor();
823
- const pgIntColumn = () => column(pgIntDescriptor.factory(), pgIntDescriptor.codecId, void 0, "int4");
824
- var PgFloatDescriptor = class extends CodecDescriptorImpl {
825
- codecId = PG_FLOAT_CODEC_ID;
826
- targetTypes = ["float8"];
827
- meta = PG_FLOAT_META;
828
- traits = sqlFloatDescriptor.traits;
829
- paramsSchema = sqlFloatDescriptor.paramsSchema;
830
- renderValueLiteral(value) {
831
- return renderTsLiteral(value);
832
- }
833
- factory() {
834
- return () => new SqlFloatCodec(this);
835
- }
836
- };
837
- const pgFloatDescriptor = new PgFloatDescriptor();
838
- const pgFloatColumn = () => column(pgFloatDescriptor.factory(), pgFloatDescriptor.codecId, void 0, "float8");
839
- //#endregion
840
3
  //#region src/core/registry.ts
841
4
  /**
842
5
  * Registry of every codec descriptor shipped by `@prisma-next/target-postgres`.
843
6
  *
844
7
  * Public consumer surface for the postgres codec set: the postgres adapter and any other consumer that needs to enumerate or look up a postgres codec by id consumes this rather than the raw descriptor array. See ADR 208.
845
8
  */
846
- const postgresCodecRegistry = buildCodecDescriptorRegistry([
847
- sqlCharDescriptor,
848
- sqlVarcharDescriptor,
849
- sqlIntDescriptor,
850
- sqlFloatDescriptor,
851
- sqlTextDescriptor,
852
- sqlTimestampDescriptor,
853
- pgTextDescriptor,
854
- pgEnumDescriptor,
855
- pgCharDescriptor,
856
- pgVarcharDescriptor,
857
- pgIntDescriptor,
858
- pgFloatDescriptor,
859
- pgInt4Descriptor,
860
- pgInt2Descriptor,
861
- pgInt8Descriptor,
862
- pgFloat4Descriptor,
863
- pgFloat8Descriptor,
864
- pgNumericDescriptor,
865
- pgTimestampDescriptor,
866
- pgTimestamptzDescriptor,
867
- pgTimeDescriptor,
868
- pgTimetzDescriptor,
869
- pgBoolDescriptor,
870
- pgBitDescriptor,
871
- pgVarbitDescriptor,
872
- pgByteaDescriptor,
873
- pgUuidDescriptor,
874
- pgIntervalDescriptor,
875
- pgJsonDescriptor,
876
- pgJsonbDescriptor,
877
- pgTextArrayDescriptor
878
- ]);
9
+ const postgresCodecRegistry = buildCodecDescriptorRegistry(codecDescriptors);
879
10
  //#endregion
880
- export { pgBitColumn, pgBoolColumn, pgCharColumn, pgFloat4Column, pgFloat8Column, pgFloatColumn, pgInt2Column, pgInt4Column, pgInt8Column, pgIntColumn, pgIntervalColumn, pgJsonColumn, pgJsonbColumn, pgNumericColumn, pgTextColumn, pgTimeColumn, pgTimestampColumn, pgTimestamptzColumn, pgTimetzColumn, pgUuidColumn, pgVarbitColumn, pgVarcharColumn, postgresCodecRegistry };
11
+ export { pgBitColumn, pgBoolColumn, pgCharColumn, pgEnumDescriptor, pgFloat4Column, pgFloat8Column, pgFloatColumn, pgInt2Column, pgInt4Column, pgInt8Column, pgIntColumn, pgIntervalColumn, pgJsonColumn, pgJsonbColumn, pgNumericColumn, pgTextColumn, pgTimeColumn, pgTimestampColumn, pgTimestamptzColumn, pgTimetzColumn, pgUuidColumn, pgVarbitColumn, pgVarcharColumn, postgresCodecRegistry };
881
12
 
882
13
  //# sourceMappingURL=codecs.mjs.map