@prisma/orm-target-postgres 8.0.0-rc.13-dev.11 → 8.0.0-rc.13-dev.12

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 (104) hide show
  1. package/dist/{adapter-C5hgqLKn-BtBmUU0b.mjs → adapter-Bz6wSV__-Dp93eiiH.mjs} +5 -5
  2. package/dist/{adapter-C5hgqLKn-BtBmUU0b.mjs.map → adapter-Bz6wSV__-Dp93eiiH.mjs.map} +1 -1
  3. package/dist/adapter.mjs +4 -4
  4. package/dist/adapter__adapter.mjs +1 -1
  5. package/dist/adapter__control.mjs +5 -5
  6. package/dist/adapter__control.mjs.map +1 -1
  7. package/dist/adapter__runtime.mjs +5 -5
  8. package/dist/adapter__runtime.mjs.map +1 -1
  9. package/dist/adapter__sql-renderer.mjs +1 -1
  10. package/dist/{authoring-DR-vV7Oe-Dia02ZUn.mjs → authoring-BmQxOggr-CK871YR4.mjs} +5 -5
  11. package/dist/{authoring-DR-vV7Oe-Dia02ZUn.mjs.map → authoring-BmQxOggr-CK871YR4.mjs.map} +1 -1
  12. package/dist/{codecs-Bbq1Qd0E.mjs → codecs-C4DVdgQG.mjs} +2 -2
  13. package/dist/{codecs-Bbq1Qd0E.mjs.map → codecs-C4DVdgQG.mjs.map} +1 -1
  14. package/dist/{codecs-Cjg0_n_k-DYOs5mGX.mjs → codecs-DQGmsnk3-H6nVRPCC.mjs} +18 -322
  15. package/dist/codecs-DQGmsnk3-H6nVRPCC.mjs.map +1 -0
  16. package/dist/{contract-free-ChOK2nXj.mjs → contract-free-B2-ZWT2L.mjs} +3 -3
  17. package/dist/{contract-free-ChOK2nXj.mjs.map → contract-free-B2-ZWT2L.mjs.map} +1 -1
  18. package/dist/{control-eWYKnooD.mjs → control-CRBnDCvo.mjs} +13 -12
  19. package/dist/control-CRBnDCvo.mjs.map +1 -0
  20. package/dist/{control-adapter-R1knQpcm-BWchDHdA.mjs → control-adapter-Buuq3v1c-DtBZerak.mjs} +10 -7
  21. package/dist/control-adapter-Buuq3v1c-DtBZerak.mjs.map +1 -0
  22. package/dist/{control-policy-DTvHBZHr-DFVImL4U.mjs → control-policy-DhL42DkN-DQos5sxF.mjs} +32 -13
  23. package/dist/control-policy-DhL42DkN-DQos5sxF.mjs.map +1 -0
  24. package/dist/{data-type-entries-Fxm2HDZk-D4AAd63w.mjs → data-type-entries-C8mv_52T-C20A-LBv.mjs} +3 -3
  25. package/dist/{data-type-entries-Fxm2HDZk-D4AAd63w.mjs.map → data-type-entries-C8mv_52T-C20A-LBv.mjs.map} +1 -1
  26. package/dist/data-types-Cl18KnNY-5I34Vd6Z.mjs +527 -0
  27. package/dist/data-types-Cl18KnNY-5I34Vd6Z.mjs.map +1 -0
  28. package/dist/{data-types-DgHu2vHj.d.mts → data-types-DJQDcSAC.d.mts} +12 -3
  29. package/dist/data-types-DJQDcSAC.d.mts.map +1 -0
  30. package/dist/{ddl-CdYNv79D-BkbF3B6U.mjs → ddl-BEslwyjE-CzNPjhh1.mjs} +3 -3
  31. package/dist/{ddl-CdYNv79D-BkbF3B6U.mjs.map → ddl-BEslwyjE-CzNPjhh1.mjs.map} +1 -1
  32. package/dist/{descriptor-meta-D36nLZuR-QY3F6uZM.mjs → descriptor-meta-BOx9pvBv-C4TEXck8.mjs} +5 -5
  33. package/dist/{descriptor-meta-D36nLZuR-QY3F6uZM.mjs.map → descriptor-meta-BOx9pvBv-C4TEXck8.mjs.map} +1 -1
  34. package/dist/{descriptor-meta-F1wsOtt2-CYf99ii0.mjs → descriptor-meta-F1wsOtt2-D014LIGM.mjs} +4 -4
  35. package/dist/{descriptor-meta-F1wsOtt2-CYf99ii0.mjs.map → descriptor-meta-F1wsOtt2-D014LIGM.mjs.map} +1 -1
  36. package/dist/{diff-database-schema-DRnjx_iX-Dgq9Fy7W.mjs → diff-database-schema-CqSZ2bgz-z_s_wavu.mjs} +10 -8
  37. package/dist/diff-database-schema-CqSZ2bgz-z_s_wavu.mjs.map +1 -0
  38. package/dist/{full-text-index-expression-CNNmwcrv-DRxxHYER.mjs → full-text-index-expression-PZszha7L-CW7i1TUY.mjs} +3 -3
  39. package/dist/{full-text-index-expression-CNNmwcrv-DRxxHYER.mjs.map → full-text-index-expression-PZszha7L-CW7i1TUY.mjs.map} +1 -1
  40. package/dist/{infer-psl-contract-DdelifiM-DJrxQnO8.mjs → infer-psl-contract-BDvQidvc-B1573q4j.mjs} +12 -8
  41. package/dist/infer-psl-contract-BDvQidvc-B1573q4j.mjs.map +1 -0
  42. package/dist/migration-PTHAY9Cv.mjs.map +1 -1
  43. package/dist/{op-factory-call-Dk0FETtB-LFFyR0Ms.mjs → op-factory-call-BBkvFvKK-7MkUHWJq.mjs} +5 -5
  44. package/dist/{op-factory-call-Dk0FETtB-LFFyR0Ms.mjs.map → op-factory-call-BBkvFvKK-7MkUHWJq.mjs.map} +1 -1
  45. package/dist/{planner-QwQ_jaFa-D-Br4xMh.mjs → planner-CvwnV6pj-DJhKg-qi.mjs} +8 -8
  46. package/dist/{planner-QwQ_jaFa-D-Br4xMh.mjs.map → planner-CvwnV6pj-DJhKg-qi.mjs.map} +1 -1
  47. package/dist/planner-ddl-builders-BQ_1YXut.d.mts +38 -0
  48. package/dist/planner-ddl-builders-BQ_1YXut.d.mts.map +1 -0
  49. package/dist/{planner-ddl-builders-Clym-Rcr-CyoEX9P0.mjs → planner-ddl-builders-GTcVPpwb-ClvrXb26.mjs} +52 -15
  50. package/dist/planner-ddl-builders-GTcVPpwb-ClvrXb26.mjs.map +1 -0
  51. package/dist/{planner-produced-postgres-migration-CWKVp9z4-mAn9meQ4.mjs → planner-produced-postgres-migration-DEJQPRjI-C9GuvVOY.mjs} +3 -3
  52. package/dist/{planner-produced-postgres-migration-CWKVp9z4-mAn9meQ4.mjs.map → planner-produced-postgres-migration-DEJQPRjI-C9GuvVOY.mjs.map} +1 -1
  53. package/dist/{planner-sql-checks-D53iVGBI-B8TBz3ne.mjs → planner-sql-checks-Bd8nN9P8-Cd98iEee.mjs} +3 -3
  54. package/dist/{planner-sql-checks-D53iVGBI-B8TBz3ne.mjs.map → planner-sql-checks-Bd8nN9P8-Cd98iEee.mjs.map} +1 -1
  55. package/dist/{postgres-contract-view-IMfyoKFv-BV0ZQO14.mjs → postgres-contract-view-DxcRT-qe-LQBHHgaS.mjs} +4 -4
  56. package/dist/{postgres-contract-view-IMfyoKFv-BV0ZQO14.mjs.map → postgres-contract-view-DxcRT-qe-LQBHHgaS.mjs.map} +1 -1
  57. package/dist/{postgres-migration-KjQ2KhZN-BEOLMLaS.mjs → postgres-migration-qwigEUIO-BWxjALsx.mjs} +5 -5
  58. package/dist/{postgres-migration-KjQ2KhZN-BEOLMLaS.mjs.map → postgres-migration-qwigEUIO-BWxjALsx.mjs.map} +1 -1
  59. package/dist/{postgres-schema-MIh_qSUu-gKCH4OhS.mjs → postgres-schema-yugFGBdS-5cY1PCmb.mjs} +3 -3
  60. package/dist/{postgres-schema-MIh_qSUu-gKCH4OhS.mjs.map → postgres-schema-yugFGBdS-5cY1PCmb.mjs.map} +1 -1
  61. package/dist/{prisma7-binding-Dborg-gx.mjs → prisma7-binding-BXzUH7xo.mjs} +5 -5
  62. package/dist/{prisma7-binding-Dborg-gx.mjs.map → prisma7-binding-BXzUH7xo.mjs.map} +1 -1
  63. package/dist/{registry-DWBKnvQq-CzxksOLO.mjs → registry-ld2ZUt1j-CH85fY3r.mjs} +3 -3
  64. package/dist/{registry-DWBKnvQq-CzxksOLO.mjs.map → registry-ld2ZUt1j-CH85fY3r.mjs.map} +1 -1
  65. package/dist/{resolve-ddl-schema-DDbcqhDH-QrDca-Np.mjs → resolve-ddl-schema-euaYYSHi-DM7kyWEw.mjs} +3 -3
  66. package/dist/{resolve-ddl-schema-DDbcqhDH-QrDca-Np.mjs.map → resolve-ddl-schema-euaYYSHi-DM7kyWEw.mjs.map} +1 -1
  67. package/dist/{sql-renderer-CgUgFbU4-NHcmNWwR.mjs → sql-renderer-CgUgFbU4-CRUChEAY.mjs} +2 -2
  68. package/dist/{sql-renderer-CgUgFbU4-NHcmNWwR.mjs.map → sql-renderer-CgUgFbU4-CRUChEAY.mjs.map} +1 -1
  69. package/dist/target.d.mts +3 -3
  70. package/dist/target.mjs +23 -23
  71. package/dist/target__codecs.mjs +3 -3
  72. package/dist/target__contract-free.mjs +3 -3
  73. package/dist/target__control.mjs +2 -2
  74. package/dist/target__data-types.d.mts +2 -2
  75. package/dist/target__data-types.mjs +3 -3
  76. package/dist/target__diff-database-schema.mjs +1 -1
  77. package/dist/target__issue-planner.mjs +1 -1
  78. package/dist/target__migration.mjs +2 -2
  79. package/dist/target__op-factory-call.mjs +1 -1
  80. package/dist/target__pack.mjs +1 -1
  81. package/dist/target__planner-ddl-builders.d.mts +2 -2
  82. package/dist/target__planner-ddl-builders.mjs +2 -2
  83. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  84. package/dist/target__planner-sql-checks.mjs +1 -1
  85. package/dist/target__planner.mjs +2 -2
  86. package/dist/target__prisma7-binding.mjs +1 -1
  87. package/dist/target__runtime.mjs +2 -2
  88. package/dist/target__runtime.mjs.map +1 -1
  89. package/dist/target__schema-ir-annotations.mjs +1 -1
  90. package/dist/target__sql-utils.mjs +1 -1
  91. package/dist/target__types.mjs +1 -1
  92. package/package.json +9 -9
  93. package/dist/codecs-Cjg0_n_k-DYOs5mGX.mjs.map +0 -1
  94. package/dist/control-adapter-R1knQpcm-BWchDHdA.mjs.map +0 -1
  95. package/dist/control-eWYKnooD.mjs.map +0 -1
  96. package/dist/control-policy-DTvHBZHr-DFVImL4U.mjs.map +0 -1
  97. package/dist/data-types-BOMKl3ue-BZ8EARvV.mjs +0 -113
  98. package/dist/data-types-BOMKl3ue-BZ8EARvV.mjs.map +0 -1
  99. package/dist/data-types-DgHu2vHj.d.mts.map +0 -1
  100. package/dist/diff-database-schema-DRnjx_iX-Dgq9Fy7W.mjs.map +0 -1
  101. package/dist/infer-psl-contract-DdelifiM-DJrxQnO8.mjs.map +0 -1
  102. package/dist/planner-ddl-builders-Clym-Rcr-CyoEX9P0.mjs.map +0 -1
  103. package/dist/planner-ddl-builders-bBCUsq_0.d.mts +0 -19
  104. package/dist/planner-ddl-builders-bBCUsq_0.d.mts.map +0 -1
@@ -1,318 +1,14 @@
1
1
  import { A as PG_TIME_TEMPORAL_CODEC_ID, C as PG_TIMESTAMPTZ_DATE_CODEC_ID, D as PG_TIMESTAMP_TEMPORAL_CODEC_ID, E as PG_TIMESTAMP_STRING_CODEC_ID, F as PG_VARCHAR_CODEC_ID, M as PG_UNBOUNDED_INT_CODEC_ID, N as PG_UUID_CODEC_ID, O as PG_TIMETZ_CODEC_ID, P as PG_VARBIT_CODEC_ID, S as PG_TEXT_CODEC_ID, T as PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID, _ as PG_INT_CODEC_ID, a as PG_DATE_STRING_CODEC_ID, b as PG_NUMERIC_CODEC_ID, c as PG_FLOAT4_CODEC_ID, d as PG_INET_CODEC_ID, f as PG_INT2_CODEC_ID, g as PG_INTERVAL_CODEC_ID, h as PG_INT8_NUMBER_CODEC_ID, i as PG_CHAR_CODEC_ID, j as PG_TSQUERY_CODEC_ID, k as PG_TIME_STRING_CODEC_ID, l as PG_FLOAT8_CODEC_ID, m as PG_INT8_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_DATE_TEMPORAL_CODEC_ID, p as PG_INT4_CODEC_ID, r as PG_BYTEA_CODEC_ID, s as PG_ENUM_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_FLOAT_CODEC_ID, v as PG_JSONB_CODEC_ID, w as PG_TIMESTAMPTZ_STRING_CODEC_ID, x as PG_TEXT_ARRAY_CODEC_ID, y as PG_JSON_CODEC_ID } from "./codec-ids-Cb0yO-IS--e0P2rfI.mjs";
2
2
  import { a as postgresCodec, r as definePostgresCodecs, t as PostgresCodecDescriptor } from "./codec-descriptor-BfoHQP3R-CMRVT-F6.mjs";
3
- import { C as pgTsquery, E as pgVarchar, S as pgTimetz, T as pgVarbit, _ as pgText, a as pgDate, b as pgTimestamp, c as pgFloat8, d as pgInt4, f as pgInt8, g as pgNumeric, h as pgJsonb, i as pgChar, l as pgInet, m as pgJson, n as pgBool, o as pgEnum, p as pgInterval, r as pgBytea, s as pgFloat4, t as pgBit, u as pgInt2, v as pgTextArray, w as pgUuid, x as pgTimestamptz, y as pgTime } from "./data-types-BOMKl3ue-BZ8EARvV.mjs";
4
3
  import { a as errorTemporalUnrepresentable, i as errorTemporalUnavailableForDefault, n as errorTemporalNonIsoCalendar, o as errorTemporalWrongType, r as errorTemporalUnavailable, s as postgresError } from "./errors-DYyzTYzE-39CV_aMo.mjs";
4
+ import { $ as pgTsquery, A as pgIntervalDecode, B as pgNumeric, C as pgInt8, D as pgInt8NumberEncode, E as pgInt8NumberDecodeJson, F as pgJsonDecode, G as pgTime, H as pgNumericRenderOutputType, I as pgJsonEncode, J as pgTimestampCanonical, K as pgTimeCanonical, L as pgJsonb, M as pgIntervalEncodeJson, N as pgIntervalToIso, O as pgInt8NumberEncodeJson, P as pgJson, Q as pgTimetzCanonical, R as pgJsonbDecode, S as pgInt4, T as pgInt8NumberDecode, U as pgText, V as pgNumericDecode, W as pgTextArray, X as pgTimestamptzCanonical, Y as pgTimestamptz, Z as pgTimetz, _ as pgFloatDecodeJson, a as pgBit, at as precisionParamsSchema, b as pgInet, c as pgByteaDecodeJson, d as pgChar, et as pgUnboundedIntDecode, f as pgDate, g as pgFloat8, h as pgFloat4, i as pgBigintEncodeJson, j as pgIntervalDecodeJson, k as pgInterval, l as pgByteaDecodeWire, m as pgEnum, n as decimalTextNumberLiteral, nt as pgVarbit, o as pgBool, ot as renderLength, p as pgDateCanonical, q as pgTimestamp, r as pgBigintEncode, rt as pgVarchar, s as pgBytea, st as renderPrecision, t as decimalTextBigintLiteral, tt as pgUuid, u as pgByteaEncodeJson, v as pgFloatEncode, w as pgInt8Decode, x as pgInt2, y as pgFloatEncodeJson, z as pgJsonbEncode } from "./data-types-Cl18KnNY-5I34Vd6Z.mjs";
5
5
  import { t as PostgresNativeEnum } from "./postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs";
6
- import { BinaryExpr, CaseExpr, CastExpr, FunctionCallExpr, LiteralExpr, NullCheckExpr, OrExpr, SqlCharCodec, SqlFloatCodec, SqlIntCodec, SqlVarcharCodec, isNonFiniteText, numeralText, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlTextDescriptor, sqlVarcharDescriptor } from "@prisma/orm-family-sql/relational-core/ast";
6
+ import { BinaryExpr, CaseExpr, CastExpr, FunctionCallExpr, LiteralExpr, NullCheckExpr, OrExpr, SqlCharCodec, SqlFloatCodec, SqlIntCodec, SqlVarcharCodec, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlTextDescriptor, sqlVarcharDescriptor } from "@prisma/orm-family-sql/relational-core/ast";
7
7
  import { CodecImpl, column, renderTsLiteral } from "@prisma/orm-framework/components/codec";
8
8
  import { blindCast } from "@prisma/orm-framework/utils/casts";
9
- import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
10
9
  import { type } from "arktype";
11
- //#region ../../../3-targets/3-targets/postgres/dist/codecs-Cjg0_n_k.mjs
12
- const precisionParamsSchema = type({ "precision?": "number.integer >= 0 & number.integer <= 6" });
13
- function renderLength(typeName, typeParams) {
14
- const length = typeParams.length;
15
- if (length === void 0) return;
16
- if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length)) throw postgresError("RUNTIME.TYPE_PARAMS_INVALID", `renderOutputType: expected integer "length" in typeParams for ${typeName}, got ${String(length)}`, { meta: {
17
- nativeType: typeName,
18
- param: "length",
19
- received: String(length)
20
- } });
21
- return `${typeName}<${length}>`;
22
- }
23
- function renderPrecision(typeName, typeParams) {
24
- const precision = typeParams.precision;
25
- if (precision === void 0) return typeName;
26
- if (typeof precision !== "number" || !Number.isFinite(precision) || !Number.isInteger(precision)) throw postgresError("RUNTIME.TYPE_PARAMS_INVALID", `renderOutputType: expected integer "precision" in typeParams for ${typeName}, got ${String(precision)}`, { meta: {
27
- nativeType: typeName,
28
- param: "precision",
29
- received: String(precision)
30
- } });
31
- return `${typeName}<${precision}>`;
32
- }
33
- /**
34
- * A `numeric` value as its canonical decimal text. A number is written out without an exponent,
35
- * because `numeric` text has no exponent syntax and `encodeJson` refuses one.
36
- */
37
- const pgNumericDecode = (wire) => {
38
- if (typeof wire === "number") return numeralText(wire);
39
- return wire;
40
- };
41
- const DECIMAL_INTEGER = /^-?\d+$/;
42
- /**
43
- * Requires an application value to be of the JS type the codec reads.
44
- *
45
- * A range check reads a value of the wrong type as a value out of range, and
46
- * reports a number plainly inside the range as outside it — so the type is
47
- * established first and answered for on its own terms, naming what a caller
48
- * has to change.
49
- */
50
- const requireJsType = (codecId, expected, value) => {
51
- if (typeof value === expected) return;
52
- throw postgresError("RUNTIME.ENCODE_FAILED", `${codecId} value must be a ${expected}, got ${typeof value} ${String(value)}`, { meta: {
53
- codecId,
54
- received: typeof value
55
- } });
56
- };
57
- /** Writes a `bigint` application value as the decimal text the wire form of the exact integer codecs carries. */
58
- const pgBigintEncode = (codecId, value) => {
59
- requireJsType(codecId, "bigint", value);
60
- return value.toString();
61
- };
62
- /**
63
- * Writes an application value as the decimal text these codecs carry as their
64
- * canonical JSON.
65
- *
66
- * A schema-written literal default (`BigInt @default(0)`) arrives here as a
67
- * `number`, since a number literal is the only integer a schema language
68
- * writes, and one that is a safe integer names its value exactly. Past that
69
- * range the literal was rounded before any of this ran, so the value written is
70
- * not the value meant — which this refuses rather than minting an exact-looking
71
- * total from it. A non-integral number is refused on the same terms.
72
- */
73
- const pgBigintEncodeJson = (codecId, value) => {
74
- if (typeof value !== "number") return pgBigintEncode(codecId, value);
75
- if (!Number.isSafeInteger(value)) throw postgresError("RUNTIME.ENCODE_FAILED", `${codecId} number literal must be an integer within the safe integer range, got ${String(value)}`, { meta: {
76
- codecId,
77
- received: String(value)
78
- } });
79
- return BigInt(value).toString();
80
- };
81
- /**
82
- * Reads a wire or JSON value as a `bigint`, rejecting anything `BigInt()` would
83
- * misread. A number-typed wire value must also be a safe integer: past
84
- * ±(2^53 − 1) the driver's `number` has already rounded, so stringifying it
85
- * would mint a spuriously-exact `bigint` that need not equal the stored value.
86
- */
87
- const decimalIntegerDecode = (codecId, wire) => {
88
- if (typeof wire === "bigint") return wire;
89
- const text = String(wire);
90
- if (!DECIMAL_INTEGER.test(text)) throw postgresError("RUNTIME.DECODE_FAILED", `${codecId} value must be a decimal integer`, { meta: {
91
- codecId,
92
- received: text
93
- } });
94
- if (typeof wire === "number" && !Number.isSafeInteger(wire)) throw postgresError("RUNTIME.DECODE_FAILED", `${codecId} wire number must be an integer within the safe integer range, got ${text}`, { meta: {
95
- codecId,
96
- received: text
97
- } });
98
- return BigInt(text);
99
- };
100
- /** Reads an `int8` wire or JSON value as a `bigint`, rejecting anything `BigInt()` would misread. */
101
- const pgInt8Decode = (wire) => decimalIntegerDecode("pg/int8@1", wire);
102
- /**
103
- * Reads an unconstrained-`numeric` wire or JSON value as a `bigint`, rejecting
104
- * non-integral values — including `NaN` and the infinities, which are `numeric`
105
- * values but not integers.
106
- */
107
- const pgUnboundedIntDecode = (wire) => decimalIntegerDecode("pg/unboundedint@1", wire);
108
- /**
109
- * Neither JSON nor a SQL number literal has a form for `NaN` or the infinities; PostgreSQL reads
110
- * and writes them as the text `NaN`, `Infinity`, `-Infinity`, so the float codecs carry them as
111
- * that text on the wire and in JSON.
112
- */
113
- const pgFloatEncode = (value) => Number.isFinite(value) ? value : String(value);
114
- const pgFloatEncodeJson = (value) => pgFloatEncode(value);
115
- const pgFloatDecodeJson = (codecId, json) => {
116
- if (typeof json === "number") return json;
117
- if (typeof json === "string" && isNonFiniteText(json)) return Number(json);
118
- throw postgresError("RUNTIME.DECODE_FAILED", `${codecId} database JSON value must be a number or the text NaN, Infinity or -Infinity`, { meta: {
119
- codecId,
120
- received: typeof json
121
- } });
122
- };
123
- const MIN_SAFE_INTEGER_BIGINT = BigInt(Number.MIN_SAFE_INTEGER);
124
- const MAX_SAFE_INTEGER_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);
125
- /**
126
- * Requires an integer within ±(2^53 − 1), the range a JS `number` holds
127
- * exactly. The guard throws rather than rounding: past the boundary a `number`
128
- * silently loses digits, which is the failure mode this codec exists to refuse.
129
- */
130
- const pgInt8NumberGuard = (code, value) => {
131
- if (!Number.isSafeInteger(value)) throw postgresError(code, `pg/int8number@1 value must be an integer within the safe integer range, got ${String(value)}`, { meta: {
132
- codecId: "pg/int8number@1",
133
- received: String(value)
134
- } });
135
- return value;
136
- };
137
- const pgInt8NumberEncode = (value) => {
138
- requireJsType("pg/int8number@1", "number", value);
139
- return String(pgInt8NumberGuard("RUNTIME.ENCODE_FAILED", value));
140
- };
141
- const pgInt8NumberEncodeJson = (value) => pgInt8NumberEncode(value);
142
- /**
143
- * Reads an `int8` wire value as a `number`, throwing outside ±(2^53 − 1) and on
144
- * non-integral input. Decimal text goes through `BigInt` before the range check
145
- * so an out-of-range value is compared exactly rather than after rounding.
146
- */
147
- const pgInt8NumberDecode = (wire) => {
148
- if (typeof wire === "number") return pgInt8NumberGuard("RUNTIME.DECODE_FAILED", wire);
149
- const value = decimalIntegerDecode("pg/int8number@1", wire);
150
- if (value < MIN_SAFE_INTEGER_BIGINT || value > MAX_SAFE_INTEGER_BIGINT) throw postgresError("RUNTIME.DECODE_FAILED", `pg/int8number@1 value must be an integer within the safe integer range, got ${value}`, { meta: {
151
- codecId: "pg/int8number@1",
152
- received: value.toString()
153
- } });
154
- return Number(value);
155
- };
156
- const pgInt8NumberDecodeJson = (json) => {
157
- if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", "pg/int8number@1 database JSON value must be decimal text", { meta: {
158
- codecId: "pg/int8number@1",
159
- received: typeof json
160
- } });
161
- return pgInt8NumberDecode(json);
162
- };
163
- /**
164
- * Renders a decimal-text default as a `bigint` literal, for the codecs whose
165
- * canonical JSON is decimal text while the application type is `bigint`
166
- * (`pg/int8@1`, `pg/unboundedint@1`) — a plain string literal would not
167
- * typecheck against the emitted column type.
168
- */
169
- const decimalTextBigintLiteral = (value) => typeof value === "string" && DECIMAL_INTEGER.test(value) ? `${value}n` : void 0;
170
- /** Renders the decimal text of `pg/int8number@1`, whose application type is `number`, as a number literal. */
171
- const decimalTextNumberLiteral = (value) => typeof value === "string" && DECIMAL_INTEGER.test(value) ? value : void 0;
172
- const pgNumericRenderOutputType = (typeParams) => {
173
- const precision = typeParams.precision;
174
- if (precision === void 0) return void 0;
175
- if (typeof precision !== "number" || !Number.isFinite(precision) || !Number.isInteger(precision)) throw postgresError("RUNTIME.TYPE_PARAMS_INVALID", `renderOutputType: expected integer "precision" in typeParams for Numeric, got ${String(precision)}`, { meta: {
176
- nativeType: "Numeric",
177
- param: "precision",
178
- received: String(precision)
179
- } });
180
- const scale = typeParams.scale;
181
- if (scale === void 0) return `Numeric<${precision}>`;
182
- if (typeof scale !== "number" || !Number.isFinite(scale) || !Number.isInteger(scale)) throw postgresError("RUNTIME.TYPE_PARAMS_INVALID", `renderOutputType: expected integer "scale" in typeParams for Numeric, got ${String(scale)}`, { meta: {
183
- nativeType: "Numeric",
184
- param: "scale",
185
- received: String(scale)
186
- } });
187
- return `Numeric<${precision}, ${scale}>`;
188
- };
189
- const ISO_DURATION = /^P(?!$)(-?\d+Y)?(-?\d+M)?(-?\d+D)?(?:T(?!$)(-?\d+H)?(-?\d+M)?(-?\d+(?:\.\d+)?S)?)?$/;
190
- const MICROS_PER_SECOND = 1000000n;
191
- /**
192
- * Converts a fractional-seconds digit string to microseconds, rounding rather
193
- * than truncating past the sixth digit.
194
- *
195
- * PostgreSQL rounds: `INTERVAL '1.1234567 seconds'` is `1.123457`, and
196
- * `'1.9999999 seconds'` carries into `2`. Truncating here made the parsed value
197
- * disagree with the database for any input past microsecond resolution.
198
- *
199
- * Ties round toward positive infinity, matching `Math.round` on the sibling path
200
- * that reads the driver's component object — so the two agree. PostgreSQL's own
201
- * tie behaviour is unobservable, because it parses the literal into a double
202
- * first and an exact half never survives that.
203
- */
204
- const microsFromFraction = (fraction, negative) => {
205
- if (fraction === "") return 0n;
206
- const kept = BigInt(fraction.slice(0, 6).padEnd(6, "0"));
207
- const rest = fraction.slice(6).replace(/0+$/, "");
208
- if (rest === "") return kept;
209
- const half = rest[0] === "5" && rest.length === 1;
210
- return rest > "5" || half && !negative ? kept + 1n : kept;
211
- };
212
- const intervalFieldsOf = (text) => {
213
- const match = ISO_DURATION.exec(text);
214
- if (match === null) throw postgresError("RUNTIME.DECODE_FAILED", `pg/interval@1 value must be an ISO-8601 duration, got ${text}`, { meta: {
215
- codecId: "pg/interval@1",
216
- received: text
217
- } });
218
- const [, years, months, days, hours, minutes, seconds] = match;
219
- const wholeNumber = (part) => part === void 0 ? 0 : Number(part.slice(0, -1));
220
- const secondsLiteral = seconds === void 0 ? "0" : seconds.slice(0, -1);
221
- const negative = secondsLiteral.startsWith("-");
222
- const [whole = "0", fraction = ""] = secondsLiteral.replace("-", "").split(".");
223
- const magnitude = BigInt(whole) * MICROS_PER_SECOND + microsFromFraction(fraction, negative);
224
- return {
225
- months: wholeNumber(years) * 12 + wholeNumber(months),
226
- days: wholeNumber(days),
227
- micros: BigInt(wholeNumber(hours)) * 3600n * MICROS_PER_SECOND + BigInt(wholeNumber(minutes)) * 60n * MICROS_PER_SECOND + (negative ? -magnitude : magnitude)
228
- };
229
- };
230
- const secondsText = (micros) => {
231
- const sign = micros < 0n ? "-" : "";
232
- const magnitude = micros < 0n ? -micros : micros;
233
- const whole = magnitude / MICROS_PER_SECOND % 60n;
234
- const fraction = magnitude % MICROS_PER_SECOND;
235
- return `${sign}${whole}${fraction === 0n ? "" : `.${fraction.toString().padStart(6, "0").replace(/0+$/, "")}`}`;
236
- };
237
- /**
238
- * Renders {@link PgInterval} the way PostgreSQL spells an interval under
239
- * `IntervalStyle = 'iso_8601'`: zero components omitted, `T` present only when a
240
- * time component is, each component carrying its own sign, and an all-zero
241
- * interval written `PT0S`.
242
- */
243
- const formatIsoDuration = ({ months, days, micros }) => {
244
- const years = Math.trunc(months / 12);
245
- const restMonths = months % 12;
246
- const sign = micros < 0n ? "-" : "";
247
- const magnitude = micros < 0n ? -micros : micros;
248
- const hours = magnitude / (3600n * MICROS_PER_SECOND);
249
- const minutes = magnitude / (60n * MICROS_PER_SECOND) % 60n;
250
- const hasSeconds = magnitude % (60n * MICROS_PER_SECOND) !== 0n;
251
- const parts = [
252
- years === 0 ? "" : `${years}Y`,
253
- restMonths === 0 ? "" : `${restMonths}M`,
254
- days === 0 ? "" : `${days}D`
255
- ];
256
- const time = [
257
- hours === 0n ? "" : `${sign}${hours}H`,
258
- minutes === 0n ? "" : `${sign}${minutes}M`,
259
- hasSeconds ? `${secondsText(micros)}S` : ""
260
- ].join("");
261
- const rendered = `P${parts.join("")}${time === "" ? "" : `T${time}`}`;
262
- return rendered === "P" ? "PT0S" : rendered;
263
- };
264
- /** Renders the application value as its canonical ISO-8601 duration. */
265
- const pgIntervalToIso = (value) => formatIsoDuration(value);
266
- const pgIntervalEncodeJson = (value) => formatIsoDuration(value);
267
- const pgIntervalDecodeJson = (json) => {
268
- if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", "pg/interval@1 database JSON value must be an ISO-8601 duration string", { meta: {
269
- codecId: "pg/interval@1",
270
- received: typeof json
271
- } });
272
- return intervalFieldsOf(json);
273
- };
274
- /**
275
- * Reads the driver's wire value into the application value. `pg` parses an
276
- * interval into a component object, which is the same three fields under other
277
- * names; a text wire value is an ISO-8601 duration, because that is what the
278
- * codec writes.
279
- */
280
- const pgIntervalDecode = (wire) => {
281
- if (typeof wire === "string") return intervalFieldsOf(wire);
282
- const part = (name) => {
283
- const raw = wire[name];
284
- return typeof raw === "number" ? raw : 0;
285
- };
286
- const seconds = part("seconds") + part("milliseconds") / 1e3;
287
- return {
288
- months: part("years") * 12 + part("months"),
289
- days: part("days"),
290
- micros: BigInt(part("hours")) * 3600n * MICROS_PER_SECOND + BigInt(part("minutes")) * 60n * MICROS_PER_SECOND + BigInt(Math.round(seconds * 1e6))
291
- };
292
- };
293
- const BASE64_TEXT = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
294
- const pgByteaEncodeJson = (value) => Buffer.from(value).toString("base64");
295
- const pgByteaDecodeJson = (value) => {
296
- if (typeof value !== "string" || !BASE64_TEXT.test(value)) throw postgresError("RUNTIME.DECODE_FAILED", "pg/bytea@1 database JSON value must be a base64 string", { meta: { codecId: "pg/bytea@1" } });
297
- return new Uint8Array(Buffer.from(value, "base64"));
298
- };
299
- const BYTEA_TEXT = /^\\x(?:[0-9A-Fa-f]{2})*$/;
300
- /**
301
- * Scalar pg bytea values arrive as Uint8Array/Buffer; target-parsed bytea list elements arrive as PostgreSQL hex text.
302
- */
303
- const pgByteaDecodeWire = (wire) => {
304
- if (wire instanceof Uint8Array) return wire.constructor === Uint8Array ? wire : new Uint8Array(wire.buffer, wire.byteOffset, wire.byteLength);
305
- if (!BYTEA_TEXT.test(wire)) throw postgresError("RUNTIME.DECODE_FAILED", "pg/bytea@1 wire value must be a bytea hex string or Uint8Array", { meta: {
306
- codecId: "pg/bytea@1",
307
- received: wire
308
- } });
309
- return new Uint8Array(Buffer.from(wire.slice(2), "hex"));
310
- };
311
- const parseJsonWire = JSON.parse;
312
- const pgJsonEncode = (value) => JSON.stringify(value);
313
- const pgJsonDecode = (wire) => typeof wire === "string" ? parseJsonWire(wire) : wire;
314
- const pgJsonbEncode = (value) => JSON.stringify(value);
315
- const pgJsonbDecode = (wire) => typeof wire === "string" ? parseJsonWire(wire) : wire;
10
+ import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
11
+ //#region ../../../3-targets/3-targets/postgres/dist/codecs-DQGmsnk3.mjs
316
12
  let fallback;
317
13
  /**
318
14
  * Sets the implementation `requireTemporal` returns when the runtime has no global `Temporal`.
@@ -414,7 +110,7 @@ const pgTimestamptzTemporalDecode = (wire) => decodeTemporalText(TIMESTAMPTZ_TEM
414
110
  const pgTimestamptzTemporalEncode = (value) => encodeTemporalValue(TIMESTAMPTZ_TEMPORAL, value);
415
111
  const pgTimeTemporalDecode = (wire) => decodeTemporalText(TIME_TEMPORAL, wire, (temporal, text) => temporal.PlainTime.from(text), unadapted);
416
112
  const pgTimeTemporalEncode = (value) => encodeTemporalValue(TIME_TEMPORAL, value);
417
- const TIMESTAMPTZ_TEXT = /^(\d{4,6})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,6}))?(?:Z|([+-])(\d{2})(?::?(\d{2}))?(?::?(\d{2}))?)( BC)?$/;
113
+ const TIMESTAMPTZ_TEXT = /^([+-]\d{6}|\d{4,6})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,6}))?(?:Z|([+-])(\d{2})(?::?(\d{2}))?(?::?(\d{2}))?)( BC)?$/;
418
114
  const MIN_TIMESTAMPTZ_MILLISECONDS = (/* @__PURE__ */ new Date("-004713-11-24T00:00:00.000Z")).getTime();
419
115
  function invalidDate() {
420
116
  return /* @__PURE__ */ new RangeError(`${PG_TIMESTAMPTZ_DATE_CODEC_ID} requires a valid Date or a representable ISO PostgreSQL timestamp with time zone; use TimestamptzString for unsupported values`);
@@ -426,7 +122,7 @@ function validateDate(value) {
426
122
  function decodeDate(wire) {
427
123
  const match = typeof wire === "string" ? TIMESTAMPTZ_TEXT.exec(wire) : null;
428
124
  if (!match) throw invalidDate();
429
- const [, yearText, monthText, dayText, hourText, minuteText, secondText, fraction = "", sign, offsetHour = "0", offsetMinute = "0", offsetSecond = "0", era] = match;
125
+ const [, yearText = "", monthText, dayText, hourText, minuteText, secondText, fraction = "", sign, offsetHour = "0", offsetMinute = "0", offsetSecond = "0", era] = match;
430
126
  const year = era ? 1 - Number(yearText) : Number(yearText);
431
127
  const month = Number(monthText) - 1;
432
128
  const day = Number(dayText);
@@ -439,7 +135,7 @@ function decodeDate(wire) {
439
135
  const local = /* @__PURE__ */ new Date(0);
440
136
  local.setUTCFullYear(safeYear, month, day);
441
137
  local.setUTCHours(hour, minute, second, milliseconds);
442
- if (Number(yearText) === 0 || local.getUTCFullYear() !== safeYear || local.getUTCMonth() !== month || local.getUTCDate() !== day || local.getUTCHours() !== hour || local.getUTCMinutes() !== minute || local.getUTCSeconds() !== second || Number(offsetHour) > 15 || Number(offsetMinute) > 59 || Number(offsetSecond) > 59) throw invalidDate();
138
+ if (era !== void 0 && (Number(yearText) === 0 || /^[+-]/.test(yearText)) || local.getUTCFullYear() !== safeYear || local.getUTCMonth() !== month || local.getUTCDate() !== day || local.getUTCHours() !== hour || local.getUTCMinutes() !== minute || local.getUTCSeconds() !== second || Number(offsetHour) > 15 || Number(offsetMinute) > 59 || Number(offsetSecond) > 59) throw invalidDate();
443
139
  const offset = (Number(offsetHour) * 3600 + Number(offsetMinute) * 60 + Number(offsetSecond)) * (sign === "-" ? -1 : 1);
444
140
  return validateDate(/* @__PURE__ */ new Date(local.getTime() - offset * 1e3 + cycles * 146097 * 864e5));
445
141
  }
@@ -459,7 +155,7 @@ var PgTimestamptzDateCodec = class extends CodecImpl {
459
155
  return decodeDate(wire);
460
156
  }
461
157
  encodeJson(value) {
462
- return encodeDate(value);
158
+ return pgTimestamptzCanonical(validateDate(value).toISOString());
463
159
  }
464
160
  decodeJson(json) {
465
161
  return decodeDate(json);
@@ -494,7 +190,7 @@ var PgDateTemporalCodec = class extends CodecImpl {
494
190
  return pgDateTemporalDecode(wire);
495
191
  }
496
192
  encodeJson(value) {
497
- return pgDateTemporalEncode(value);
193
+ return pgDateCanonical(pgDateTemporalEncode(value));
498
194
  }
499
195
  decodeJson(json) {
500
196
  return pgDateTemporalDecode(blindCast(json));
@@ -525,7 +221,7 @@ var PgTimestampTemporalCodec = class extends CodecImpl {
525
221
  return pgTimestampTemporalDecode(wire);
526
222
  }
527
223
  encodeJson(value) {
528
- return pgTimestampTemporalEncode(value);
224
+ return pgTimestampCanonical(pgTimestampTemporalEncode(value));
529
225
  }
530
226
  decodeJson(json) {
531
227
  return pgTimestampTemporalDecode(blindCast(json));
@@ -556,7 +252,7 @@ var PgTimestamptzTemporalCodec = class extends CodecImpl {
556
252
  return pgTimestamptzTemporalDecode(wire);
557
253
  }
558
254
  encodeJson(value) {
559
- return pgTimestamptzTemporalEncode(value);
255
+ return pgTimestamptzCanonical(pgTimestamptzTemporalEncode(value));
560
256
  }
561
257
  decodeJson(json) {
562
258
  return pgTimestamptzTemporalDecode(blindCast(json));
@@ -587,7 +283,7 @@ var PgTimeTemporalCodec = class extends CodecImpl {
587
283
  return pgTimeTemporalDecode(wire);
588
284
  }
589
285
  encodeJson(value) {
590
- return pgTimeTemporalEncode(value);
286
+ return pgTimeCanonical(pgTimeTemporalEncode(value));
591
287
  }
592
288
  decodeJson(json) {
593
289
  return pgTimeTemporalDecode(blindCast(json));
@@ -618,7 +314,7 @@ var PgDateStringCodec = class extends CodecImpl {
618
314
  return wire;
619
315
  }
620
316
  encodeJson(value) {
621
- return value;
317
+ return pgDateCanonical(value);
622
318
  }
623
319
  decodeJson(json) {
624
320
  return blindCast(json);
@@ -649,7 +345,7 @@ var PgTimestampStringCodec = class extends CodecImpl {
649
345
  return wire;
650
346
  }
651
347
  encodeJson(value) {
652
- return value;
348
+ return pgTimestampCanonical(value);
653
349
  }
654
350
  decodeJson(json) {
655
351
  return blindCast(json);
@@ -683,7 +379,7 @@ var PgTimestamptzStringCodec = class extends CodecImpl {
683
379
  return wire;
684
380
  }
685
381
  encodeJson(value) {
686
- return value;
382
+ return pgTimestamptzCanonical(value);
687
383
  }
688
384
  decodeJson(json) {
689
385
  return blindCast(json);
@@ -717,7 +413,7 @@ var PgTimeStringCodec = class extends CodecImpl {
717
413
  return wire;
718
414
  }
719
415
  encodeJson(value) {
720
- return value;
416
+ return pgTimeCanonical(value);
721
417
  }
722
418
  decodeJson(json) {
723
419
  return blindCast(json);
@@ -1495,7 +1191,7 @@ var PgTimetzCodec = class extends CodecImpl {
1495
1191
  return wire;
1496
1192
  }
1497
1193
  encodeJson(value) {
1498
- return value;
1194
+ return pgTimetzCanonical(value);
1499
1195
  }
1500
1196
  decodeJson(json) {
1501
1197
  return blindCast(json);
@@ -1992,4 +1688,4 @@ const codecDescriptors = definePostgresCodecs([
1992
1688
  //#endregion
1993
1689
  export { postgresQualifyColumnType as A, pgTimestamptzDateColumn as C, pgUuidColumn as D, pgUnboundedIntColumn as E, setFallbackTemporal as M, pgVarbitColumn as O, pgTextColumn as S, pgTimetzColumn as T, pgIntColumn as _, pgBitColumn as a, pgJsonbColumn as b, pgEnumDescriptor as c, pgFloatColumn as d, pgInetColumn as f, pgInt8NumberColumn as g, pgInt8Column as h, isPgEnumParams as i, requireTemporal as j, pgVarcharColumn as k, pgFloat4Column as l, pgInt4Column as m, PgTimestamptzDateDescriptor as n, pgBoolColumn as o, pgInt2Column as p, codecDescriptors as r, pgCharColumn as s, PgTimestamptzDateCodec as t, pgFloat8Column as u, pgIntervalColumn as v, pgTimestamptzDateDescriptor as w, pgNumericColumn as x, pgJsonColumn as y };
1994
1690
 
1995
- //# sourceMappingURL=codecs-Cjg0_n_k-DYOs5mGX.mjs.map
1691
+ //# sourceMappingURL=codecs-DQGmsnk3-H6nVRPCC.mjs.map