@prisma-next/target-postgres 0.5.0-dev.9 → 0.5.0
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/{codec-ids-CojIXVf9.mjs → codec-ids-C5qzBqus.mjs} +4 -4
- package/dist/{codec-ids-CojIXVf9.mjs.map → codec-ids-C5qzBqus.mjs.map} +1 -1
- package/dist/codec-ids-CplrEfmx.d.mts +29 -0
- package/dist/codec-ids-CplrEfmx.d.mts.map +1 -0
- package/dist/codec-ids.d.mts +2 -28
- package/dist/codec-ids.mjs +2 -3
- package/dist/codec-types-lrsb3N07.d.mts +79 -0
- package/dist/codec-types-lrsb3N07.d.mts.map +1 -0
- package/dist/codec-types.d.mts +2 -42
- package/dist/codec-types.mjs +1 -3
- package/dist/codecs-Cue97Xqf.d.mts +558 -0
- package/dist/codecs-Cue97Xqf.d.mts.map +1 -0
- package/dist/codecs.d.mts +13 -2
- package/dist/codecs.d.mts.map +1 -0
- package/dist/codecs.mjs +738 -2
- package/dist/codecs.mjs.map +1 -0
- package/dist/control.d.mts +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +131 -94
- package/dist/control.mjs.map +1 -1
- package/dist/{data-transform-VfEGzXWt.mjs → data-transform-DKWXdHuZ.mjs} +25 -7
- package/dist/data-transform-DKWXdHuZ.mjs.map +1 -0
- package/dist/data-transform-bIeAcZIJ.d.mts +38 -0
- package/dist/data-transform-bIeAcZIJ.d.mts.map +1 -0
- package/dist/data-transform.d.mts +1 -1
- package/dist/data-transform.mjs +2 -3
- package/dist/{default-normalizer-DNOpRoOF.mjs → default-normalizer-C8XyZj85.mjs} +2 -2
- package/dist/{default-normalizer-DNOpRoOF.mjs.map → default-normalizer-C8XyZj85.mjs.map} +1 -1
- package/dist/default-normalizer.d.mts +0 -1
- package/dist/default-normalizer.d.mts.map +1 -1
- package/dist/default-normalizer.mjs +2 -3
- package/dist/descriptor-meta-Dde_BS3K.mjs +99 -0
- package/dist/descriptor-meta-Dde_BS3K.mjs.map +1 -0
- package/dist/{errors-AFvEPZ1R.mjs → errors-Chm2bKcS.mjs} +2 -3
- package/dist/{errors-AFvEPZ1R.mjs.map → errors-Chm2bKcS.mjs.map} +1 -1
- package/dist/errors.d.mts +0 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +2 -3
- package/dist/{issue-planner-CFjB0_oO.mjs → issue-planner-CiNmA4ls.mjs} +20 -16
- package/dist/issue-planner-CiNmA4ls.mjs.map +1 -0
- package/dist/issue-planner.d.mts +2 -4
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +2 -3
- package/dist/migration.d.mts +8 -4
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +4 -5
- package/dist/migration.mjs.map +1 -1
- package/dist/{native-type-normalizer-CInai_oY.mjs → native-type-normalizer-Cry4QoLf.mjs} +2 -2
- package/dist/native-type-normalizer-Cry4QoLf.mjs.map +1 -0
- package/dist/native-type-normalizer.d.mts.map +1 -1
- package/dist/native-type-normalizer.mjs +2 -3
- package/dist/{op-factory-call-C3bWXKSP.d.mts → op-factory-call-BUhxZuUA.d.mts} +9 -5
- package/dist/op-factory-call-BUhxZuUA.d.mts.map +1 -0
- package/dist/{op-factory-call-BKlruaiC.mjs → op-factory-call-Bs3HWhvG.mjs} +25 -7
- package/dist/op-factory-call-Bs3HWhvG.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +1 -2
- package/dist/op-factory-call.mjs +2 -3
- package/dist/pack.d.mts +28 -9
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +2 -3
- package/dist/{planner-CLUvVhUN.mjs → planner-Lhacw3uU.mjs} +22 -16
- package/dist/planner-Lhacw3uU.mjs.map +1 -0
- package/dist/{planner-ddl-builders-Dxvw1LHw.mjs → planner-ddl-builders-CLB7Umhh.mjs} +4 -5
- package/dist/planner-ddl-builders-CLB7Umhh.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +1 -1
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +2 -3
- package/dist/{planner-identity-values-Dju-o5GF.mjs → planner-identity-values-DTx0gePL.mjs} +2 -3
- package/dist/{planner-identity-values-Dju-o5GF.mjs.map → planner-identity-values-DTx0gePL.mjs.map} +1 -1
- package/dist/planner-identity-values.d.mts +0 -1
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/planner-identity-values.mjs +2 -3
- package/dist/{planner-produced-postgres-migration-CRRTno6Z.d.mts → planner-produced-postgres-migration-CjxWIVgh.d.mts} +11 -7
- package/dist/planner-produced-postgres-migration-CjxWIVgh.d.mts.map +1 -0
- package/dist/{planner-produced-postgres-migration-DSSPq8QS.mjs → planner-produced-postgres-migration-DphktB2N.mjs} +16 -8
- package/dist/planner-produced-postgres-migration-DphktB2N.mjs.map +1 -0
- package/dist/planner-produced-postgres-migration.d.mts +1 -4
- package/dist/planner-produced-postgres-migration.mjs +2 -3
- package/dist/{planner-schema-lookup-B7lkypwn.mjs → planner-schema-lookup-B1ags8ys.mjs} +2 -2
- package/dist/{planner-schema-lookup-B7lkypwn.mjs.map → planner-schema-lookup-B1ags8ys.mjs.map} +1 -1
- package/dist/planner-schema-lookup.d.mts +0 -1
- package/dist/planner-schema-lookup.d.mts.map +1 -1
- package/dist/planner-schema-lookup.mjs +2 -3
- package/dist/{planner-sql-checks-7jkgm9TX.mjs → planner-sql-checks-DwZvGlV4.mjs} +3 -5
- package/dist/planner-sql-checks-DwZvGlV4.mjs.map +1 -0
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +2 -3
- package/dist/{planner-target-details-DH-azLu-.d.mts → planner-target-details-bVVcanWh.d.mts} +1 -1
- package/dist/planner-target-details-bVVcanWh.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner-target-details.mjs +1 -1
- package/dist/planner.d.mts +21 -12
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -4
- package/dist/{postgres-migration-qtmtbONe.mjs → postgres-migration-Bkv140RW.mjs} +4 -5
- package/dist/postgres-migration-Bkv140RW.mjs.map +1 -0
- package/dist/{postgres-migration-BjA3Zmts.d.mts → postgres-migration-UkcHfZAA.d.mts} +6 -6
- package/dist/postgres-migration-UkcHfZAA.d.mts.map +1 -0
- package/dist/render-ops--1nnfNus.mjs +23 -0
- package/dist/render-ops--1nnfNus.mjs.map +1 -0
- package/dist/render-ops.d.mts +3 -4
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/render-ops.mjs +2 -3
- package/dist/{render-typescript-1rF_SB4g.mjs → render-typescript-D3doH-vX.mjs} +2 -14
- package/dist/render-typescript-D3doH-vX.mjs.map +1 -0
- package/dist/render-typescript.d.mts +3 -6
- package/dist/render-typescript.d.mts.map +1 -1
- package/dist/render-typescript.mjs +2 -3
- package/dist/runtime.d.mts +5 -9
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +7 -14
- package/dist/runtime.mjs.map +1 -1
- package/dist/{shared-Bxkt8pNO.d.mts → shared-MpwjwAjM.d.mts} +2 -2
- package/dist/shared-MpwjwAjM.d.mts.map +1 -0
- package/dist/{sql-utils-r-Lw535w.mjs → sql-utils-CggjWNij.mjs} +4 -2
- package/dist/sql-utils-CggjWNij.mjs.map +1 -0
- package/dist/sql-utils.d.mts.map +1 -1
- package/dist/sql-utils.mjs +2 -3
- package/dist/{statement-builders-BPnmt6wx.mjs → statement-builders-BT889jV0.mjs} +28 -13
- package/dist/statement-builders-BT889jV0.mjs.map +1 -0
- package/dist/statement-builders.d.mts +31 -3
- package/dist/statement-builders.d.mts.map +1 -1
- package/dist/statement-builders.mjs +2 -3
- package/dist/{tables-BmdW_FWO.mjs → tables-r9Zk1y-Y.mjs} +18 -13
- package/dist/tables-r9Zk1y-Y.mjs.map +1 -0
- package/dist/{types-ClK03Ojd.d.mts → types-CTqpysRY.d.mts} +1 -1
- package/dist/types-CTqpysRY.d.mts.map +1 -0
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +1 -1
- package/package.json +21 -19
- package/src/core/authoring.ts +5 -11
- package/src/core/codec-helpers.ts +135 -0
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codec-type-map.ts +81 -0
- package/src/core/codecs.ts +941 -547
- package/src/core/descriptor-meta.ts +1 -1
- package/src/core/migrations/issue-planner.ts +15 -3
- package/src/core/migrations/op-factory-call.ts +24 -2
- package/src/core/migrations/operations/data-transform.ts +86 -21
- package/src/core/migrations/operations/indexes.ts +27 -2
- package/src/core/migrations/planner-produced-postgres-migration.ts +17 -5
- package/src/core/migrations/planner.ts +62 -20
- package/src/core/migrations/postgres-migration.ts +3 -6
- package/src/core/migrations/render-ops.ts +26 -3
- package/src/core/migrations/render-typescript.ts +5 -9
- package/src/core/migrations/runner.ts +172 -151
- package/src/core/migrations/statement-builders.ts +49 -10
- package/src/core/registry.ts +11 -0
- package/src/exports/codec-types.ts +4 -13
- package/src/exports/codecs.ts +49 -2
- package/src/exports/runtime.ts +6 -11
- package/src/exports/statement-builders.ts +2 -1
- package/dist/codec-ids.d.mts.map +0 -1
- package/dist/codec-types.d.mts.map +0 -1
- package/dist/codecs-BQEm9_oo.d.mts +0 -319
- package/dist/codecs-BQEm9_oo.d.mts.map +0 -1
- package/dist/codecs-BoahtY_Q.mjs +0 -385
- package/dist/codecs-BoahtY_Q.mjs.map +0 -1
- package/dist/data-transform-CxFRBIUp.d.mts +0 -32
- package/dist/data-transform-CxFRBIUp.d.mts.map +0 -1
- package/dist/data-transform-VfEGzXWt.mjs.map +0 -1
- package/dist/descriptor-meta-BVoVtyp-.mjs +0 -120
- package/dist/descriptor-meta-BVoVtyp-.mjs.map +0 -1
- package/dist/issue-planner-CFjB0_oO.mjs.map +0 -1
- package/dist/native-type-normalizer-CInai_oY.mjs.map +0 -1
- package/dist/op-factory-call-BKlruaiC.mjs.map +0 -1
- package/dist/op-factory-call-C3bWXKSP.d.mts.map +0 -1
- package/dist/planner-CLUvVhUN.mjs.map +0 -1
- package/dist/planner-ddl-builders-Dxvw1LHw.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-CRRTno6Z.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-DSSPq8QS.mjs.map +0 -1
- package/dist/planner-sql-checks-7jkgm9TX.mjs.map +0 -1
- package/dist/planner-target-details-DH-azLu-.d.mts.map +0 -1
- package/dist/postgres-migration-BjA3Zmts.d.mts.map +0 -1
- package/dist/postgres-migration-qtmtbONe.mjs.map +0 -1
- package/dist/render-ops-D6_DHdOK.mjs +0 -8
- package/dist/render-ops-D6_DHdOK.mjs.map +0 -1
- package/dist/render-typescript-1rF_SB4g.mjs.map +0 -1
- package/dist/shared-Bxkt8pNO.d.mts.map +0 -1
- package/dist/sql-utils-r-Lw535w.mjs.map +0 -1
- package/dist/statement-builders-BPnmt6wx.mjs.map +0 -1
- package/dist/tables-BmdW_FWO.mjs.map +0 -1
- package/dist/types-ClK03Ojd.d.mts.map +0 -1
- package/src/core/json-schema-type-expression.ts +0 -131
package/dist/codecs-BoahtY_Q.mjs
DELETED
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import { S as PG_VARCHAR_CODEC_ID, _ as PG_TIMESTAMPTZ_CODEC_ID, a as PG_FLOAT4_CODEC_ID, b as PG_TIME_CODEC_ID, c as PG_INT2_CODEC_ID, d as PG_INTERVAL_CODEC_ID, f as PG_INT_CODEC_ID, g as PG_TEXT_CODEC_ID, h as PG_NUMERIC_CODEC_ID, i as PG_ENUM_CODEC_ID, l as PG_INT4_CODEC_ID, m as PG_JSON_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT8_CODEC_ID, p as PG_JSONB_CODEC_ID, r as PG_CHAR_CODEC_ID, s as PG_FLOAT_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT8_CODEC_ID, v as PG_TIMESTAMP_CODEC_ID, x as PG_VARBIT_CODEC_ID, y as PG_TIMETZ_CODEC_ID } from "./codec-ids-CojIXVf9.mjs";
|
|
2
|
-
import { codec, defineCodecs, sqlCodecDefinitions } from "@prisma-next/sql-relational-core/ast";
|
|
3
|
-
import { ifDefined } from "@prisma-next/utils/defined";
|
|
4
|
-
import { type } from "arktype";
|
|
5
|
-
|
|
6
|
-
//#region src/core/json-schema-type-expression.ts
|
|
7
|
-
const MAX_DEPTH = 32;
|
|
8
|
-
function isRecord(value) {
|
|
9
|
-
return typeof value === "object" && value !== null;
|
|
10
|
-
}
|
|
11
|
-
function escapeStringLiteral(str) {
|
|
12
|
-
return str.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
13
|
-
}
|
|
14
|
-
function quotePropertyKey(key) {
|
|
15
|
-
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : `'${escapeStringLiteral(key)}'`;
|
|
16
|
-
}
|
|
17
|
-
function renderLiteral(value) {
|
|
18
|
-
if (typeof value === "string") return `'${escapeStringLiteral(value)}'`;
|
|
19
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
20
|
-
if (value === null) return "null";
|
|
21
|
-
return "unknown";
|
|
22
|
-
}
|
|
23
|
-
function renderUnion(items, depth) {
|
|
24
|
-
return items.map((item) => render(item, depth)).join(" | ");
|
|
25
|
-
}
|
|
26
|
-
function renderObjectType(schema, depth) {
|
|
27
|
-
const properties = isRecord(schema["properties"]) ? schema["properties"] : {};
|
|
28
|
-
const required = Array.isArray(schema["required"]) ? new Set(schema["required"].filter((key) => typeof key === "string")) : /* @__PURE__ */ new Set();
|
|
29
|
-
const keys = Object.keys(properties).sort((left, right) => left.localeCompare(right));
|
|
30
|
-
if (keys.length === 0) {
|
|
31
|
-
const additionalProperties = schema["additionalProperties"];
|
|
32
|
-
if (additionalProperties === true || additionalProperties === void 0) return "Record<string, unknown>";
|
|
33
|
-
return `Record<string, ${render(additionalProperties, depth)}>`;
|
|
34
|
-
}
|
|
35
|
-
return `{ ${keys.map((key) => {
|
|
36
|
-
const valueSchema = properties[key];
|
|
37
|
-
const optionalMarker = required.has(key) ? "" : "?";
|
|
38
|
-
return `${quotePropertyKey(key)}${optionalMarker}: ${render(valueSchema, depth)}`;
|
|
39
|
-
}).join("; ")} }`;
|
|
40
|
-
}
|
|
41
|
-
function renderArrayType(schema, depth) {
|
|
42
|
-
if (Array.isArray(schema["items"])) return `readonly [${schema["items"].map((item) => render(item, depth)).join(", ")}]`;
|
|
43
|
-
if (schema["items"] !== void 0) {
|
|
44
|
-
const itemType = render(schema["items"], depth);
|
|
45
|
-
return itemType.includes(" | ") || itemType.includes(" & ") ? `(${itemType})[]` : `${itemType}[]`;
|
|
46
|
-
}
|
|
47
|
-
return "unknown[]";
|
|
48
|
-
}
|
|
49
|
-
function render(schema, depth) {
|
|
50
|
-
if (depth > MAX_DEPTH || !isRecord(schema)) return "JsonValue";
|
|
51
|
-
const nextDepth = depth + 1;
|
|
52
|
-
if ("const" in schema) return renderLiteral(schema["const"]);
|
|
53
|
-
if (Array.isArray(schema["enum"])) return schema["enum"].map((value) => renderLiteral(value)).join(" | ");
|
|
54
|
-
if (Array.isArray(schema["oneOf"])) return renderUnion(schema["oneOf"], nextDepth);
|
|
55
|
-
if (Array.isArray(schema["anyOf"])) return renderUnion(schema["anyOf"], nextDepth);
|
|
56
|
-
if (Array.isArray(schema["allOf"])) return schema["allOf"].map((item) => render(item, nextDepth)).join(" & ");
|
|
57
|
-
if (Array.isArray(schema["type"])) return schema["type"].map((item) => render({
|
|
58
|
-
...schema,
|
|
59
|
-
type: item
|
|
60
|
-
}, nextDepth)).join(" | ");
|
|
61
|
-
switch (schema["type"]) {
|
|
62
|
-
case "string": return "string";
|
|
63
|
-
case "number":
|
|
64
|
-
case "integer": return "number";
|
|
65
|
-
case "boolean": return "boolean";
|
|
66
|
-
case "null": return "null";
|
|
67
|
-
case "array": return renderArrayType(schema, nextDepth);
|
|
68
|
-
case "object": return renderObjectType(schema, nextDepth);
|
|
69
|
-
default: break;
|
|
70
|
-
}
|
|
71
|
-
return "JsonValue";
|
|
72
|
-
}
|
|
73
|
-
function renderTypeScriptTypeFromJsonSchema(schema) {
|
|
74
|
-
return render(schema, 0);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/core/codecs.ts
|
|
79
|
-
const lengthParamsSchema = type({ length: "number.integer > 0" });
|
|
80
|
-
const numericParamsSchema = type({
|
|
81
|
-
precision: "number.integer > 0 & number.integer <= 1000",
|
|
82
|
-
"scale?": "number.integer >= 0"
|
|
83
|
-
});
|
|
84
|
-
const precisionParamsSchema = type({ "precision?": "number.integer >= 0 & number.integer <= 6" });
|
|
85
|
-
function renderLength(typeName, typeParams) {
|
|
86
|
-
const length = typeParams["length"];
|
|
87
|
-
if (length === void 0) return;
|
|
88
|
-
if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length)) throw new Error(`renderOutputType: expected integer "length" in typeParams for ${typeName}, got ${String(length)}`);
|
|
89
|
-
return `${typeName}<${length}>`;
|
|
90
|
-
}
|
|
91
|
-
function renderPrecision(typeName, typeParams) {
|
|
92
|
-
const precision = typeParams["precision"];
|
|
93
|
-
if (precision === void 0) return typeName;
|
|
94
|
-
if (typeof precision !== "number" || !Number.isFinite(precision) || !Number.isInteger(precision)) throw new Error(`renderOutputType: expected integer "precision" in typeParams for ${typeName}, got ${String(precision)}`);
|
|
95
|
-
return `${typeName}<${precision}>`;
|
|
96
|
-
}
|
|
97
|
-
function renderJsonOutputType(typeParams) {
|
|
98
|
-
const typeName = typeParams["type"];
|
|
99
|
-
if (typeof typeName === "string" && typeName.trim().length > 0) return typeName.trim();
|
|
100
|
-
const schema = typeParams["schemaJson"];
|
|
101
|
-
if (schema && typeof schema === "object") return renderTypeScriptTypeFromJsonSchema(schema);
|
|
102
|
-
throw new Error(`renderOutputType: JSON codec typeParams must contain "type" (string) or "schemaJson" (object), got keys: ${Object.keys(typeParams).join(", ")}`);
|
|
103
|
-
}
|
|
104
|
-
function aliasCodec(base, options) {
|
|
105
|
-
return {
|
|
106
|
-
id: options.typeId,
|
|
107
|
-
targetTypes: options.targetTypes,
|
|
108
|
-
...ifDefined("meta", options.meta),
|
|
109
|
-
...ifDefined("paramsSchema", base.paramsSchema),
|
|
110
|
-
...ifDefined("init", base.init),
|
|
111
|
-
...ifDefined("encode", base.encode),
|
|
112
|
-
...ifDefined("traits", base.traits),
|
|
113
|
-
...ifDefined("renderOutputType", base.renderOutputType),
|
|
114
|
-
decode: base.decode,
|
|
115
|
-
encodeJson: base.encodeJson,
|
|
116
|
-
decodeJson: base.decodeJson
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
const sqlCharCodec = sqlCodecDefinitions.char.codec;
|
|
120
|
-
const sqlVarcharCodec = sqlCodecDefinitions.varchar.codec;
|
|
121
|
-
const sqlIntCodec = sqlCodecDefinitions.int.codec;
|
|
122
|
-
const sqlFloatCodec = sqlCodecDefinitions.float.codec;
|
|
123
|
-
const sqlTextCodec = sqlCodecDefinitions.text.codec;
|
|
124
|
-
const sqlTimestampCodec = sqlCodecDefinitions.timestamp.codec;
|
|
125
|
-
const pgTextCodec = codec({
|
|
126
|
-
typeId: PG_TEXT_CODEC_ID,
|
|
127
|
-
targetTypes: ["text"],
|
|
128
|
-
traits: [
|
|
129
|
-
"equality",
|
|
130
|
-
"order",
|
|
131
|
-
"textual"
|
|
132
|
-
],
|
|
133
|
-
encode: (value) => value,
|
|
134
|
-
decode: (wire) => wire,
|
|
135
|
-
meta: { db: { sql: { postgres: { nativeType: "text" } } } }
|
|
136
|
-
});
|
|
137
|
-
const pgCharCodec = aliasCodec(sqlCharCodec, {
|
|
138
|
-
typeId: PG_CHAR_CODEC_ID,
|
|
139
|
-
targetTypes: ["character"],
|
|
140
|
-
meta: { db: { sql: { postgres: { nativeType: "character" } } } }
|
|
141
|
-
});
|
|
142
|
-
const pgVarcharCodec = aliasCodec(sqlVarcharCodec, {
|
|
143
|
-
typeId: PG_VARCHAR_CODEC_ID,
|
|
144
|
-
targetTypes: ["character varying"],
|
|
145
|
-
meta: { db: { sql: { postgres: { nativeType: "character varying" } } } }
|
|
146
|
-
});
|
|
147
|
-
const pgIntCodec = aliasCodec(sqlIntCodec, {
|
|
148
|
-
typeId: PG_INT_CODEC_ID,
|
|
149
|
-
targetTypes: ["int4"],
|
|
150
|
-
meta: { db: { sql: { postgres: { nativeType: "integer" } } } }
|
|
151
|
-
});
|
|
152
|
-
const pgFloatCodec = aliasCodec(sqlFloatCodec, {
|
|
153
|
-
typeId: PG_FLOAT_CODEC_ID,
|
|
154
|
-
targetTypes: ["float8"],
|
|
155
|
-
meta: { db: { sql: { postgres: { nativeType: "double precision" } } } }
|
|
156
|
-
});
|
|
157
|
-
const pgInt4Codec = codec({
|
|
158
|
-
typeId: PG_INT4_CODEC_ID,
|
|
159
|
-
targetTypes: ["int4"],
|
|
160
|
-
traits: [
|
|
161
|
-
"equality",
|
|
162
|
-
"order",
|
|
163
|
-
"numeric"
|
|
164
|
-
],
|
|
165
|
-
encode: (value) => value,
|
|
166
|
-
decode: (wire) => wire,
|
|
167
|
-
meta: { db: { sql: { postgres: { nativeType: "integer" } } } }
|
|
168
|
-
});
|
|
169
|
-
const pgNumericCodec = codec({
|
|
170
|
-
typeId: PG_NUMERIC_CODEC_ID,
|
|
171
|
-
targetTypes: ["numeric", "decimal"],
|
|
172
|
-
traits: [
|
|
173
|
-
"equality",
|
|
174
|
-
"order",
|
|
175
|
-
"numeric"
|
|
176
|
-
],
|
|
177
|
-
encode: (value) => value,
|
|
178
|
-
decode: (wire) => {
|
|
179
|
-
if (typeof wire === "number") return String(wire);
|
|
180
|
-
return wire;
|
|
181
|
-
},
|
|
182
|
-
paramsSchema: numericParamsSchema,
|
|
183
|
-
renderOutputType: (typeParams) => {
|
|
184
|
-
const precision = typeParams["precision"];
|
|
185
|
-
if (precision === void 0) return void 0;
|
|
186
|
-
if (typeof precision !== "number" || !Number.isFinite(precision) || !Number.isInteger(precision)) throw new Error(`renderOutputType: expected integer "precision" in typeParams for Numeric, got ${String(precision)}`);
|
|
187
|
-
const scale = typeParams["scale"];
|
|
188
|
-
return typeof scale === "number" ? `Numeric<${precision}, ${scale}>` : `Numeric<${precision}>`;
|
|
189
|
-
},
|
|
190
|
-
meta: { db: { sql: { postgres: { nativeType: "numeric" } } } }
|
|
191
|
-
});
|
|
192
|
-
const pgInt2Codec = codec({
|
|
193
|
-
typeId: PG_INT2_CODEC_ID,
|
|
194
|
-
targetTypes: ["int2"],
|
|
195
|
-
traits: [
|
|
196
|
-
"equality",
|
|
197
|
-
"order",
|
|
198
|
-
"numeric"
|
|
199
|
-
],
|
|
200
|
-
encode: (value) => value,
|
|
201
|
-
decode: (wire) => wire,
|
|
202
|
-
meta: { db: { sql: { postgres: { nativeType: "smallint" } } } }
|
|
203
|
-
});
|
|
204
|
-
const pgInt8Codec = codec({
|
|
205
|
-
typeId: PG_INT8_CODEC_ID,
|
|
206
|
-
targetTypes: ["int8"],
|
|
207
|
-
traits: [
|
|
208
|
-
"equality",
|
|
209
|
-
"order",
|
|
210
|
-
"numeric"
|
|
211
|
-
],
|
|
212
|
-
encode: (value) => value,
|
|
213
|
-
decode: (wire) => wire,
|
|
214
|
-
meta: { db: { sql: { postgres: { nativeType: "bigint" } } } }
|
|
215
|
-
});
|
|
216
|
-
const pgFloat4Codec = codec({
|
|
217
|
-
typeId: PG_FLOAT4_CODEC_ID,
|
|
218
|
-
targetTypes: ["float4"],
|
|
219
|
-
traits: [
|
|
220
|
-
"equality",
|
|
221
|
-
"order",
|
|
222
|
-
"numeric"
|
|
223
|
-
],
|
|
224
|
-
encode: (value) => value,
|
|
225
|
-
decode: (wire) => wire,
|
|
226
|
-
meta: { db: { sql: { postgres: { nativeType: "real" } } } }
|
|
227
|
-
});
|
|
228
|
-
const pgFloat8Codec = codec({
|
|
229
|
-
typeId: PG_FLOAT8_CODEC_ID,
|
|
230
|
-
targetTypes: ["float8"],
|
|
231
|
-
traits: [
|
|
232
|
-
"equality",
|
|
233
|
-
"order",
|
|
234
|
-
"numeric"
|
|
235
|
-
],
|
|
236
|
-
encode: (value) => value,
|
|
237
|
-
decode: (wire) => wire,
|
|
238
|
-
meta: { db: { sql: { postgres: { nativeType: "double precision" } } } }
|
|
239
|
-
});
|
|
240
|
-
const pgTimestampCodec = codec({
|
|
241
|
-
typeId: PG_TIMESTAMP_CODEC_ID,
|
|
242
|
-
targetTypes: ["timestamp"],
|
|
243
|
-
traits: ["equality", "order"],
|
|
244
|
-
encode: (value) => {
|
|
245
|
-
if (value instanceof Date) return value.toISOString();
|
|
246
|
-
if (typeof value === "string") return value;
|
|
247
|
-
return String(value);
|
|
248
|
-
},
|
|
249
|
-
decode: (wire) => {
|
|
250
|
-
if (wire instanceof Date) return wire.toISOString();
|
|
251
|
-
return wire;
|
|
252
|
-
},
|
|
253
|
-
encodeJson: (value) => value instanceof Date ? value.toISOString() : value,
|
|
254
|
-
decodeJson: (json) => {
|
|
255
|
-
if (typeof json !== "string") throw new Error(`Expected ISO date string for pg/timestamp@1, got ${typeof json}`);
|
|
256
|
-
const date = new Date(json);
|
|
257
|
-
if (Number.isNaN(date.getTime())) throw new Error(`Invalid ISO date string for pg/timestamp@1: ${json}`);
|
|
258
|
-
return date;
|
|
259
|
-
},
|
|
260
|
-
paramsSchema: precisionParamsSchema,
|
|
261
|
-
renderOutputType: (typeParams) => renderPrecision("Timestamp", typeParams),
|
|
262
|
-
meta: { db: { sql: { postgres: { nativeType: "timestamp without time zone" } } } }
|
|
263
|
-
});
|
|
264
|
-
const pgTimestamptzCodec = codec({
|
|
265
|
-
typeId: PG_TIMESTAMPTZ_CODEC_ID,
|
|
266
|
-
targetTypes: ["timestamptz"],
|
|
267
|
-
traits: ["equality", "order"],
|
|
268
|
-
encode: (value) => {
|
|
269
|
-
if (value instanceof Date) return value.toISOString();
|
|
270
|
-
if (typeof value === "string") return value;
|
|
271
|
-
return String(value);
|
|
272
|
-
},
|
|
273
|
-
decode: (wire) => {
|
|
274
|
-
if (wire instanceof Date) return wire.toISOString();
|
|
275
|
-
return wire;
|
|
276
|
-
},
|
|
277
|
-
encodeJson: (value) => value instanceof Date ? value.toISOString() : value,
|
|
278
|
-
decodeJson: (json) => {
|
|
279
|
-
if (typeof json !== "string") throw new Error(`Expected ISO date string for pg/timestamptz@1, got ${typeof json}`);
|
|
280
|
-
const date = new Date(json);
|
|
281
|
-
if (Number.isNaN(date.getTime())) throw new Error(`Invalid ISO date string for pg/timestamptz@1: ${json}`);
|
|
282
|
-
return date;
|
|
283
|
-
},
|
|
284
|
-
paramsSchema: precisionParamsSchema,
|
|
285
|
-
renderOutputType: (typeParams) => renderPrecision("Timestamptz", typeParams),
|
|
286
|
-
meta: { db: { sql: { postgres: { nativeType: "timestamp with time zone" } } } }
|
|
287
|
-
});
|
|
288
|
-
const pgTimeCodec = codec({
|
|
289
|
-
typeId: PG_TIME_CODEC_ID,
|
|
290
|
-
targetTypes: ["time"],
|
|
291
|
-
traits: ["equality", "order"],
|
|
292
|
-
encode: (value) => value,
|
|
293
|
-
decode: (wire) => wire,
|
|
294
|
-
paramsSchema: precisionParamsSchema,
|
|
295
|
-
renderOutputType: (typeParams) => renderPrecision("Time", typeParams),
|
|
296
|
-
meta: { db: { sql: { postgres: { nativeType: "time" } } } }
|
|
297
|
-
});
|
|
298
|
-
const pgTimetzCodec = codec({
|
|
299
|
-
typeId: PG_TIMETZ_CODEC_ID,
|
|
300
|
-
targetTypes: ["timetz"],
|
|
301
|
-
traits: ["equality", "order"],
|
|
302
|
-
encode: (value) => value,
|
|
303
|
-
decode: (wire) => wire,
|
|
304
|
-
paramsSchema: precisionParamsSchema,
|
|
305
|
-
renderOutputType: (typeParams) => renderPrecision("Timetz", typeParams),
|
|
306
|
-
meta: { db: { sql: { postgres: { nativeType: "timetz" } } } }
|
|
307
|
-
});
|
|
308
|
-
const pgBoolCodec = codec({
|
|
309
|
-
typeId: PG_BOOL_CODEC_ID,
|
|
310
|
-
targetTypes: ["bool"],
|
|
311
|
-
traits: ["equality", "boolean"],
|
|
312
|
-
encode: (value) => value,
|
|
313
|
-
decode: (wire) => wire,
|
|
314
|
-
meta: { db: { sql: { postgres: { nativeType: "boolean" } } } }
|
|
315
|
-
});
|
|
316
|
-
const pgBitCodec = codec({
|
|
317
|
-
typeId: PG_BIT_CODEC_ID,
|
|
318
|
-
targetTypes: ["bit"],
|
|
319
|
-
traits: ["equality", "order"],
|
|
320
|
-
encode: (value) => value,
|
|
321
|
-
decode: (wire) => wire,
|
|
322
|
-
paramsSchema: lengthParamsSchema,
|
|
323
|
-
renderOutputType: (typeParams) => renderLength("Bit", typeParams),
|
|
324
|
-
meta: { db: { sql: { postgres: { nativeType: "bit" } } } }
|
|
325
|
-
});
|
|
326
|
-
const pgVarbitCodec = codec({
|
|
327
|
-
typeId: PG_VARBIT_CODEC_ID,
|
|
328
|
-
targetTypes: ["bit varying"],
|
|
329
|
-
traits: ["equality", "order"],
|
|
330
|
-
encode: (value) => value,
|
|
331
|
-
decode: (wire) => wire,
|
|
332
|
-
paramsSchema: lengthParamsSchema,
|
|
333
|
-
renderOutputType: (typeParams) => renderLength("VarBit", typeParams),
|
|
334
|
-
meta: { db: { sql: { postgres: { nativeType: "bit varying" } } } }
|
|
335
|
-
});
|
|
336
|
-
const pgEnumCodec = codec({
|
|
337
|
-
typeId: PG_ENUM_CODEC_ID,
|
|
338
|
-
targetTypes: ["enum"],
|
|
339
|
-
traits: ["equality", "order"],
|
|
340
|
-
encode: (value) => value,
|
|
341
|
-
decode: (wire) => wire,
|
|
342
|
-
renderOutputType: (typeParams) => {
|
|
343
|
-
const values = typeParams["values"];
|
|
344
|
-
if (!Array.isArray(values)) throw new Error(`renderOutputType: expected array "values" in typeParams for enum, got ${typeof values}`);
|
|
345
|
-
return values.map((value) => `'${String(value).replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`).join(" | ");
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
const pgIntervalCodec = codec({
|
|
349
|
-
typeId: PG_INTERVAL_CODEC_ID,
|
|
350
|
-
targetTypes: ["interval"],
|
|
351
|
-
traits: ["equality", "order"],
|
|
352
|
-
encode: (value) => value,
|
|
353
|
-
decode: (wire) => {
|
|
354
|
-
if (typeof wire === "string") return wire;
|
|
355
|
-
return JSON.stringify(wire);
|
|
356
|
-
},
|
|
357
|
-
paramsSchema: precisionParamsSchema,
|
|
358
|
-
renderOutputType: (typeParams) => renderPrecision("Interval", typeParams),
|
|
359
|
-
meta: { db: { sql: { postgres: { nativeType: "interval" } } } }
|
|
360
|
-
});
|
|
361
|
-
const pgJsonCodec = codec({
|
|
362
|
-
typeId: PG_JSON_CODEC_ID,
|
|
363
|
-
targetTypes: ["json"],
|
|
364
|
-
traits: [],
|
|
365
|
-
encode: (value) => JSON.stringify(value),
|
|
366
|
-
decode: (wire) => typeof wire === "string" ? JSON.parse(wire) : wire,
|
|
367
|
-
renderOutputType: renderJsonOutputType,
|
|
368
|
-
meta: { db: { sql: { postgres: { nativeType: "json" } } } }
|
|
369
|
-
});
|
|
370
|
-
const pgJsonbCodec = codec({
|
|
371
|
-
typeId: PG_JSONB_CODEC_ID,
|
|
372
|
-
targetTypes: ["jsonb"],
|
|
373
|
-
traits: ["equality"],
|
|
374
|
-
encode: (value) => JSON.stringify(value),
|
|
375
|
-
decode: (wire) => typeof wire === "string" ? JSON.parse(wire) : wire,
|
|
376
|
-
renderOutputType: renderJsonOutputType,
|
|
377
|
-
meta: { db: { sql: { postgres: { nativeType: "jsonb" } } } }
|
|
378
|
-
});
|
|
379
|
-
const codecs = defineCodecs().add("char", sqlCharCodec).add("varchar", sqlVarcharCodec).add("int", sqlIntCodec).add("float", sqlFloatCodec).add("sql-text", sqlTextCodec).add("sql-timestamp", sqlTimestampCodec).add("text", pgTextCodec).add("character", pgCharCodec).add("character varying", pgVarcharCodec).add("integer", pgIntCodec).add("double precision", pgFloatCodec).add("int4", pgInt4Codec).add("int2", pgInt2Codec).add("int8", pgInt8Codec).add("float4", pgFloat4Codec).add("float8", pgFloat8Codec).add("numeric", pgNumericCodec).add("timestamp", pgTimestampCodec).add("timestamptz", pgTimestamptzCodec).add("time", pgTimeCodec).add("timetz", pgTimetzCodec).add("bool", pgBoolCodec).add("bit", pgBitCodec).add("bit varying", pgVarbitCodec).add("interval", pgIntervalCodec).add("enum", pgEnumCodec).add("json", pgJsonCodec).add("jsonb", pgJsonbCodec);
|
|
380
|
-
const codecDefinitions = codecs.codecDefinitions;
|
|
381
|
-
const dataTypes = codecs.dataTypes;
|
|
382
|
-
|
|
383
|
-
//#endregion
|
|
384
|
-
export { dataTypes as n, codecDefinitions as t };
|
|
385
|
-
//# sourceMappingURL=codecs-BoahtY_Q.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codecs-BoahtY_Q.mjs","names":["arktype"],"sources":["../src/core/json-schema-type-expression.ts","../src/core/codecs.ts"],"sourcesContent":["type JsonSchemaRecord = Record<string, unknown>;\n\nconst MAX_DEPTH = 32;\n\nfunction isRecord(value: unknown): value is JsonSchemaRecord {\n return typeof value === 'object' && value !== null;\n}\n\nfunction escapeStringLiteral(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r');\n}\n\nfunction quotePropertyKey(key: string): string {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : `'${escapeStringLiteral(key)}'`;\n}\n\nfunction renderLiteral(value: unknown): string {\n if (typeof value === 'string') {\n return `'${escapeStringLiteral(value)}'`;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (value === null) {\n return 'null';\n }\n return 'unknown';\n}\n\nfunction renderUnion(items: readonly unknown[], depth: number): string {\n const rendered = items.map((item) => render(item, depth));\n return rendered.join(' | ');\n}\n\nfunction renderObjectType(schema: JsonSchemaRecord, depth: number): string {\n const properties = isRecord(schema['properties']) ? schema['properties'] : {};\n const required = Array.isArray(schema['required'])\n ? new Set(schema['required'].filter((key): key is string => typeof key === 'string'))\n : new Set<string>();\n const keys = Object.keys(properties).sort((left, right) => left.localeCompare(right));\n\n if (keys.length === 0) {\n const additionalProperties = schema['additionalProperties'];\n if (additionalProperties === true || additionalProperties === undefined) {\n return 'Record<string, unknown>';\n }\n return `Record<string, ${render(additionalProperties, depth)}>`;\n }\n\n const renderedProperties = keys.map((key) => {\n const valueSchema = (properties as JsonSchemaRecord)[key];\n const optionalMarker = required.has(key) ? '' : '?';\n return `${quotePropertyKey(key)}${optionalMarker}: ${render(valueSchema, depth)}`;\n });\n\n return `{ ${renderedProperties.join('; ')} }`;\n}\n\nfunction renderArrayType(schema: JsonSchemaRecord, depth: number): string {\n if (Array.isArray(schema['items'])) {\n return `readonly [${schema['items'].map((item) => render(item, depth)).join(', ')}]`;\n }\n\n if (schema['items'] !== undefined) {\n const itemType = render(schema['items'], depth);\n const needsParens = itemType.includes(' | ') || itemType.includes(' & ');\n return needsParens ? `(${itemType})[]` : `${itemType}[]`;\n }\n\n return 'unknown[]';\n}\n\nfunction render(schema: unknown, depth: number): string {\n if (depth > MAX_DEPTH || !isRecord(schema)) {\n return 'JsonValue';\n }\n\n const nextDepth = depth + 1;\n\n if ('const' in schema) {\n return renderLiteral(schema['const']);\n }\n\n if (Array.isArray(schema['enum'])) {\n return schema['enum'].map((value) => renderLiteral(value)).join(' | ');\n }\n\n if (Array.isArray(schema['oneOf'])) {\n return renderUnion(schema['oneOf'], nextDepth);\n }\n\n if (Array.isArray(schema['anyOf'])) {\n return renderUnion(schema['anyOf'], nextDepth);\n }\n\n if (Array.isArray(schema['allOf'])) {\n return schema['allOf'].map((item) => render(item, nextDepth)).join(' & ');\n }\n\n if (Array.isArray(schema['type'])) {\n return schema['type'].map((item) => render({ ...schema, type: item }, nextDepth)).join(' | ');\n }\n\n switch (schema['type']) {\n case 'string':\n return 'string';\n case 'number':\n case 'integer':\n return 'number';\n case 'boolean':\n return 'boolean';\n case 'null':\n return 'null';\n case 'array':\n return renderArrayType(schema, nextDepth);\n case 'object':\n return renderObjectType(schema, nextDepth);\n default:\n break;\n }\n\n return 'JsonValue';\n}\n\nexport function renderTypeScriptTypeFromJsonSchema(schema: unknown): string {\n return render(schema, 0);\n}\n","/**\n * Unified codec definitions for Postgres adapter.\n *\n * This file contains a single source of truth for all codec information:\n * - Scalar names\n * - Type IDs\n * - Codec implementations (runtime)\n * - Type information (compile-time)\n *\n * This structure is used both at runtime (to populate the registry) and\n * at compile time (to derive CodecTypes).\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport type { Codec, CodecMeta, CodecTrait } from '@prisma-next/sql-relational-core/ast';\nimport { codec, defineCodecs, sqlCodecDefinitions } from '@prisma-next/sql-relational-core/ast';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { type as arktype } from 'arktype';\nimport {\n PG_BIT_CODEC_ID,\n PG_BOOL_CODEC_ID,\n PG_CHAR_CODEC_ID,\n PG_ENUM_CODEC_ID,\n PG_FLOAT_CODEC_ID,\n PG_FLOAT4_CODEC_ID,\n PG_FLOAT8_CODEC_ID,\n PG_INT_CODEC_ID,\n PG_INT2_CODEC_ID,\n PG_INT4_CODEC_ID,\n PG_INT8_CODEC_ID,\n PG_INTERVAL_CODEC_ID,\n PG_JSON_CODEC_ID,\n PG_JSONB_CODEC_ID,\n PG_NUMERIC_CODEC_ID,\n PG_TEXT_CODEC_ID,\n PG_TIME_CODEC_ID,\n PG_TIMESTAMP_CODEC_ID,\n PG_TIMESTAMPTZ_CODEC_ID,\n PG_TIMETZ_CODEC_ID,\n PG_VARBIT_CODEC_ID,\n PG_VARCHAR_CODEC_ID,\n} from './codec-ids';\nimport { renderTypeScriptTypeFromJsonSchema } from './json-schema-type-expression';\n\nconst lengthParamsSchema = arktype({\n length: 'number.integer > 0',\n});\n\nconst numericParamsSchema = arktype({\n precision: 'number.integer > 0 & number.integer <= 1000',\n 'scale?': 'number.integer >= 0',\n});\n\nconst precisionParamsSchema = arktype({\n 'precision?': 'number.integer >= 0 & number.integer <= 6',\n});\n\nfunction renderLength(typeName: string, typeParams: Record<string, unknown>): string | undefined {\n const length = typeParams['length'];\n if (length === undefined) {\n return undefined;\n }\n if (typeof length !== 'number' || !Number.isFinite(length) || !Number.isInteger(length)) {\n throw new Error(\n `renderOutputType: expected integer \"length\" in typeParams for ${typeName}, got ${String(length)}`,\n );\n }\n return `${typeName}<${length}>`;\n}\n\nfunction renderPrecision(typeName: string, typeParams: Record<string, unknown>): string {\n const precision = typeParams['precision'];\n if (precision === undefined) {\n return typeName;\n }\n if (\n typeof precision !== 'number' ||\n !Number.isFinite(precision) ||\n !Number.isInteger(precision)\n ) {\n throw new Error(\n `renderOutputType: expected integer \"precision\" in typeParams for ${typeName}, got ${String(precision)}`,\n );\n }\n return `${typeName}<${precision}>`;\n}\n\nfunction renderJsonOutputType(typeParams: Record<string, unknown>): string {\n const typeName = typeParams['type'];\n if (typeof typeName === 'string' && typeName.trim().length > 0) {\n return typeName.trim();\n }\n const schema = typeParams['schemaJson'];\n if (schema && typeof schema === 'object') {\n return renderTypeScriptTypeFromJsonSchema(schema);\n }\n throw new Error(\n `renderOutputType: JSON codec typeParams must contain \"type\" (string) or \"schemaJson\" (object), got keys: ${Object.keys(typeParams).join(', ')}`,\n );\n}\n\nfunction aliasCodec<\n Id extends string,\n TTraits extends readonly CodecTrait[],\n TWire,\n TJs,\n TParams,\n THelper,\n>(\n base: Codec<string, TTraits, TWire, TJs, TParams, THelper>,\n options: {\n readonly typeId: Id;\n readonly targetTypes: readonly string[];\n readonly meta?: CodecMeta;\n },\n): Codec<Id, TTraits, TWire, TJs, TParams, THelper> {\n return {\n id: options.typeId,\n targetTypes: options.targetTypes,\n ...ifDefined('meta', options.meta),\n ...ifDefined('paramsSchema', base.paramsSchema),\n ...ifDefined('init', base.init),\n ...ifDefined('encode', base.encode),\n ...ifDefined('traits', base.traits),\n ...ifDefined('renderOutputType', base.renderOutputType),\n decode: base.decode,\n encodeJson: base.encodeJson,\n decodeJson: base.decodeJson,\n } as Codec<Id, TTraits, TWire, TJs, TParams, THelper>;\n}\n\nconst sqlCharCodec = sqlCodecDefinitions.char.codec;\nconst sqlVarcharCodec = sqlCodecDefinitions.varchar.codec;\nconst sqlIntCodec = sqlCodecDefinitions.int.codec;\nconst sqlFloatCodec = sqlCodecDefinitions.float.codec;\nconst sqlTextCodec = sqlCodecDefinitions.text.codec;\nconst sqlTimestampCodec = sqlCodecDefinitions.timestamp.codec;\n\n// Create individual codec instances\nconst pgTextCodec = codec({\n typeId: PG_TEXT_CODEC_ID,\n targetTypes: ['text'],\n traits: ['equality', 'order', 'textual'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'text',\n },\n },\n },\n },\n});\n\nconst pgCharCodec = aliasCodec(sqlCharCodec, {\n typeId: PG_CHAR_CODEC_ID,\n targetTypes: ['character'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'character',\n },\n },\n },\n },\n});\n\nconst pgVarcharCodec = aliasCodec(sqlVarcharCodec, {\n typeId: PG_VARCHAR_CODEC_ID,\n targetTypes: ['character varying'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'character varying',\n },\n },\n },\n },\n});\n\nconst pgIntCodec = aliasCodec(sqlIntCodec, {\n typeId: PG_INT_CODEC_ID,\n targetTypes: ['int4'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'integer',\n },\n },\n },\n },\n});\n\nconst pgFloatCodec = aliasCodec(sqlFloatCodec, {\n typeId: PG_FLOAT_CODEC_ID,\n targetTypes: ['float8'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'double precision',\n },\n },\n },\n },\n});\n\nconst pgInt4Codec = codec({\n typeId: PG_INT4_CODEC_ID,\n targetTypes: ['int4'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'integer',\n },\n },\n },\n },\n});\n\nconst pgNumericCodec = codec<\n typeof PG_NUMERIC_CODEC_ID,\n readonly ['equality', 'order', 'numeric'],\n string,\n string\n>({\n typeId: PG_NUMERIC_CODEC_ID,\n targetTypes: ['numeric', 'decimal'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: string): string => value,\n decode: (wire: string | number): string => {\n if (typeof wire === 'number') return String(wire);\n return wire;\n },\n paramsSchema: numericParamsSchema,\n renderOutputType: (typeParams) => {\n const precision = typeParams['precision'];\n if (precision === undefined) return undefined;\n if (\n typeof precision !== 'number' ||\n !Number.isFinite(precision) ||\n !Number.isInteger(precision)\n ) {\n throw new Error(\n `renderOutputType: expected integer \"precision\" in typeParams for Numeric, got ${String(precision)}`,\n );\n }\n const scale = typeParams['scale'];\n return typeof scale === 'number' ? `Numeric<${precision}, ${scale}>` : `Numeric<${precision}>`;\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'numeric',\n },\n },\n },\n },\n});\n\nconst pgInt2Codec = codec({\n typeId: PG_INT2_CODEC_ID,\n targetTypes: ['int2'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'smallint',\n },\n },\n },\n },\n});\n\nconst pgInt8Codec = codec({\n typeId: PG_INT8_CODEC_ID,\n targetTypes: ['int8'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bigint',\n },\n },\n },\n },\n});\n\nconst pgFloat4Codec = codec({\n typeId: PG_FLOAT4_CODEC_ID,\n targetTypes: ['float4'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'real',\n },\n },\n },\n },\n});\n\nconst pgFloat8Codec = codec({\n typeId: PG_FLOAT8_CODEC_ID,\n targetTypes: ['float8'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'double precision',\n },\n },\n },\n },\n});\n\nconst pgTimestampCodec = codec<\n typeof PG_TIMESTAMP_CODEC_ID,\n readonly ['equality', 'order'],\n string | Date,\n string | Date\n>({\n typeId: PG_TIMESTAMP_CODEC_ID,\n targetTypes: ['timestamp'],\n traits: ['equality', 'order'],\n encode: (value: string | Date): string => {\n if (value instanceof Date) return value.toISOString();\n if (typeof value === 'string') return value;\n return String(value);\n },\n decode: (wire: string | Date): string => {\n if (wire instanceof Date) return wire.toISOString();\n return wire;\n },\n encodeJson: (value: string | Date) => (value instanceof Date ? value.toISOString() : value),\n decodeJson: (json) => {\n if (typeof json !== 'string') {\n throw new Error(`Expected ISO date string for pg/timestamp@1, got ${typeof json}`);\n }\n const date = new Date(json);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid ISO date string for pg/timestamp@1: ${json}`);\n }\n return date;\n },\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Timestamp', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp without time zone',\n },\n },\n },\n },\n});\n\nconst pgTimestamptzCodec = codec<\n typeof PG_TIMESTAMPTZ_CODEC_ID,\n readonly ['equality', 'order'],\n string | Date,\n string | Date\n>({\n typeId: PG_TIMESTAMPTZ_CODEC_ID,\n targetTypes: ['timestamptz'],\n traits: ['equality', 'order'],\n encode: (value: string | Date): string => {\n if (value instanceof Date) return value.toISOString();\n if (typeof value === 'string') return value;\n return String(value);\n },\n decode: (wire: string | Date): string => {\n if (wire instanceof Date) return wire.toISOString();\n return wire;\n },\n encodeJson: (value: string | Date) => (value instanceof Date ? value.toISOString() : value),\n decodeJson: (json) => {\n if (typeof json !== 'string') {\n throw new Error(`Expected ISO date string for pg/timestamptz@1, got ${typeof json}`);\n }\n const date = new Date(json);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid ISO date string for pg/timestamptz@1: ${json}`);\n }\n return date;\n },\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Timestamptz', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp with time zone',\n },\n },\n },\n },\n});\n\nconst pgTimeCodec = codec<typeof PG_TIME_CODEC_ID, readonly ['equality', 'order'], string, string>({\n typeId: PG_TIME_CODEC_ID,\n targetTypes: ['time'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Time', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'time',\n },\n },\n },\n },\n});\n\nconst pgTimetzCodec = codec<\n typeof PG_TIMETZ_CODEC_ID,\n readonly ['equality', 'order'],\n string,\n string\n>({\n typeId: PG_TIMETZ_CODEC_ID,\n targetTypes: ['timetz'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Timetz', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timetz',\n },\n },\n },\n },\n});\n\nconst pgBoolCodec = codec({\n typeId: PG_BOOL_CODEC_ID,\n targetTypes: ['bool'],\n traits: ['equality', 'boolean'],\n encode: (value: boolean): boolean => value,\n decode: (wire: boolean): boolean => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'boolean',\n },\n },\n },\n },\n});\n\nconst pgBitCodec = codec<typeof PG_BIT_CODEC_ID, readonly ['equality', 'order'], string, string>({\n typeId: PG_BIT_CODEC_ID,\n targetTypes: ['bit'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: lengthParamsSchema,\n renderOutputType: (typeParams) => renderLength('Bit', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bit',\n },\n },\n },\n },\n});\n\nconst pgVarbitCodec = codec<\n typeof PG_VARBIT_CODEC_ID,\n readonly ['equality', 'order'],\n string,\n string\n>({\n typeId: PG_VARBIT_CODEC_ID,\n targetTypes: ['bit varying'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: lengthParamsSchema,\n renderOutputType: (typeParams) => renderLength('VarBit', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bit varying',\n },\n },\n },\n },\n});\n\nconst pgEnumCodec = codec({\n typeId: PG_ENUM_CODEC_ID,\n targetTypes: ['enum'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n renderOutputType: (typeParams) => {\n const values = typeParams['values'];\n if (!Array.isArray(values)) {\n throw new Error(\n `renderOutputType: expected array \"values\" in typeParams for enum, got ${typeof values}`,\n );\n }\n return values\n .map((value) => `'${String(value).replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`)\n .join(' | ');\n },\n});\n\nconst pgIntervalCodec = codec<\n typeof PG_INTERVAL_CODEC_ID,\n readonly ['equality', 'order'],\n string | Record<string, unknown>,\n string\n>({\n typeId: PG_INTERVAL_CODEC_ID,\n targetTypes: ['interval'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string | Record<string, unknown>): string => {\n if (typeof wire === 'string') return wire;\n return JSON.stringify(wire);\n },\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Interval', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'interval',\n },\n },\n },\n },\n});\n\nconst pgJsonCodec = codec({\n typeId: PG_JSON_CODEC_ID,\n targetTypes: ['json'],\n traits: [],\n encode: (value: string | JsonValue): string => JSON.stringify(value),\n decode: (wire: string | JsonValue): JsonValue =>\n typeof wire === 'string' ? JSON.parse(wire) : wire,\n renderOutputType: renderJsonOutputType,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'json',\n },\n },\n },\n },\n});\n\nconst pgJsonbCodec = codec({\n typeId: PG_JSONB_CODEC_ID,\n targetTypes: ['jsonb'],\n traits: ['equality'],\n encode: (value: string | JsonValue): string => JSON.stringify(value),\n decode: (wire: string | JsonValue): JsonValue =>\n typeof wire === 'string' ? JSON.parse(wire) : wire,\n renderOutputType: renderJsonOutputType,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'jsonb',\n },\n },\n },\n },\n});\n\n// Build codec definitions using the builder DSL\nconst codecs = defineCodecs()\n .add('char', sqlCharCodec)\n .add('varchar', sqlVarcharCodec)\n .add('int', sqlIntCodec)\n .add('float', sqlFloatCodec)\n .add('sql-text', sqlTextCodec)\n .add('sql-timestamp', sqlTimestampCodec)\n .add('text', pgTextCodec)\n .add('character', pgCharCodec)\n .add('character varying', pgVarcharCodec)\n .add('integer', pgIntCodec)\n .add('double precision', pgFloatCodec)\n .add('int4', pgInt4Codec)\n .add('int2', pgInt2Codec)\n .add('int8', pgInt8Codec)\n .add('float4', pgFloat4Codec)\n .add('float8', pgFloat8Codec)\n .add('numeric', pgNumericCodec)\n .add('timestamp', pgTimestampCodec)\n .add('timestamptz', pgTimestamptzCodec)\n .add('time', pgTimeCodec)\n .add('timetz', pgTimetzCodec)\n .add('bool', pgBoolCodec)\n .add('bit', pgBitCodec)\n .add('bit varying', pgVarbitCodec)\n .add('interval', pgIntervalCodec)\n .add('enum', pgEnumCodec)\n .add('json', pgJsonCodec)\n .add('jsonb', pgJsonbCodec);\n\n// Export derived structures directly from codecs builder\nexport const codecDefinitions = codecs.codecDefinitions;\nexport const dataTypes = codecs.dataTypes;\n\nexport type CodecTypes = typeof codecs.CodecTypes;\n"],"mappings":";;;;;;AAEA,MAAM,YAAY;AAElB,SAAS,SAAS,OAA2C;AAC3D,QAAO,OAAO,UAAU,YAAY,UAAU;;AAGhD,SAAS,oBAAoB,KAAqB;AAChD,QAAO,IAC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QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,UAAU,cAAc,CAC5B,IAAI,UAAU,cAAc,CAC5B,IAAI,WAAW,eAAe,CAC9B,IAAI,aAAa,iBAAiB,CAClC,IAAI,eAAe,mBAAmB,CACtC,IAAI,QAAQ,YAAY,CACxB,IAAI,UAAU,cAAc,CAC5B,IAAI,QAAQ,YAAY,CACxB,IAAI,OAAO,WAAW,CACtB,IAAI,eAAe,cAAc,CACjC,IAAI,YAAY,gBAAgB,CAChC,IAAI,QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,SAAS,aAAa;AAG7B,MAAa,mBAAmB,OAAO;AACvC,MAAa,YAAY,OAAO"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Contract } from "@prisma-next/contract/types";
|
|
2
|
-
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
3
|
-
import { SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
|
|
4
|
-
import { DataTransformOperation } from "@prisma-next/framework-components/control";
|
|
5
|
-
import { SqlQueryPlan } from "@prisma-next/sql-relational-core/plan";
|
|
6
|
-
|
|
7
|
-
//#region src/core/migrations/operations/data-transform.d.ts
|
|
8
|
-
|
|
9
|
-
interface Buildable<R = unknown> {
|
|
10
|
-
build(): SqlQueryPlan<R>;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A single-closure producer of a SQL query plan. Shared between
|
|
14
|
-
* `check` and each `run` entry.
|
|
15
|
-
*/
|
|
16
|
-
type DataTransformClosure = () => SqlQueryPlan | Buildable;
|
|
17
|
-
interface DataTransformOptions {
|
|
18
|
-
/** Optional pre-flight query. `undefined` means "no check". */
|
|
19
|
-
readonly check?: DataTransformClosure;
|
|
20
|
-
/** One or more mutation queries to execute. */
|
|
21
|
-
readonly run: DataTransformClosure | readonly DataTransformClosure[];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Concrete Postgres flavor of `DataTransformOperation`, re-exported so the
|
|
25
|
-
* `PostgresMigration.dataTransform` instance method can name it without
|
|
26
|
-
* leaking the framework-components symbol into call sites.
|
|
27
|
-
*/
|
|
28
|
-
type PostgresDataTransformOperation = DataTransformOperation;
|
|
29
|
-
declare function dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions, adapter: SqlControlAdapter<'postgres'>): DataTransformOperation;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { dataTransform as i, DataTransformOptions as n, PostgresDataTransformOperation as r, DataTransformClosure as t };
|
|
32
|
-
//# sourceMappingURL=data-transform-CxFRBIUp.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-transform-CxFRBIUp.d.mts","names":[],"sources":["../src/core/migrations/operations/data-transform.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAwCU;WACC,aAAa;;;;;;KAOZ,oBAAA,SAA6B,eAAe;UAEvC,oBAAA;;mBAEE;;gBAEH,gCAAgC;;;;;;;KAQpC,8BAAA,GAAiC;iBAE7B,gCAAgC,SAAS,uBAC7C,kCAED,+BACA,gCACR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-transform-VfEGzXWt.mjs","names":["runClosures: readonly DataTransformClosure[]"],"sources":["../src/core/migrations/operations/data-transform.ts"],"sourcesContent":["/**\n * User-facing `dataTransform` factory for the Postgres migration authoring\n * surface. Invoked directly inside a `migration.ts` file via the\n * `PostgresMigration` instance method (`this.dataTransform(...)`), which\n * supplies the control adapter from the migration's injected stack:\n *\n * ```ts\n * import endContract from './end-contract.json' with { type: 'json' };\n *\n * class M extends Migration {\n * override get operations() {\n * return [\n * this.dataTransform(endContract, 'backfill emails', {\n * check: () => db.users.count().where(({ email }) => email.isNull()),\n * run: () => db.users.update({ email: '' }).where(({ email }) => email.isNull()),\n * }),\n * ];\n * }\n * }\n * ```\n *\n * The factory accepts lazy closures (`() => SqlQueryPlan | Buildable`),\n * invokes each one, asserts that its `meta.storageHash` matches the\n * `contract` it was handed (→ `PN-MIG-2005` on mismatch), and lowers the\n * plan via the supplied control adapter to a serialized `{sql, params}`\n * payload for `ops.json`. The free factory remains usable standalone\n * (tests, ad-hoc tooling, non-class contexts) by passing the adapter\n * explicitly as the fourth argument.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport { errorDataTransformContractMismatch } from '@prisma-next/errors/migration';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport type {\n DataTransformOperation,\n SerializedQueryPlan,\n} from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\n\ninterface Buildable<R = unknown> {\n build(): SqlQueryPlan<R>;\n}\n\n/**\n * A single-closure producer of a SQL query plan. Shared between\n * `check` and each `run` entry.\n */\nexport type DataTransformClosure = () => SqlQueryPlan | Buildable;\n\nexport interface DataTransformOptions {\n /** Optional pre-flight query. `undefined` means \"no check\". */\n readonly check?: DataTransformClosure;\n /** One or more mutation queries to execute. */\n readonly run: DataTransformClosure | readonly DataTransformClosure[];\n}\n\n/**\n * Concrete Postgres flavor of `DataTransformOperation`, re-exported so the\n * `PostgresMigration.dataTransform` instance method can name it without\n * leaking the framework-components symbol into call sites.\n */\nexport type PostgresDataTransformOperation = DataTransformOperation;\n\nexport function dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n adapter: SqlControlAdapter<'postgres'>,\n): DataTransformOperation {\n const runClosures: readonly DataTransformClosure[] = Array.isArray(options.run)\n ? options.run\n : [options.run as DataTransformClosure];\n return {\n id: `data_migration.${name}`,\n label: `Data transform: ${name}`,\n operationClass: 'data',\n name,\n source: 'migration.ts',\n check: options.check ? invokeAndLower(options.check, contract, adapter, name) : null,\n run: runClosures.map((closure) => invokeAndLower(closure, contract, adapter, name)),\n };\n}\n\nfunction invokeAndLower(\n closure: DataTransformClosure,\n contract: Contract<SqlStorage>,\n adapter: SqlControlAdapter<'postgres'>,\n name: string,\n): SerializedQueryPlan {\n const result = closure();\n const plan = isBuildable(result) ? result.build() : result;\n assertContractMatches(plan, contract, name);\n const lowered = adapter.lower(plan.ast, { contract });\n return { sql: lowered.sql, params: lowered.params };\n}\n\nfunction isBuildable(value: unknown): value is Buildable {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'build' in value &&\n typeof (value as { build: unknown }).build === 'function'\n );\n}\n\nfunction assertContractMatches(\n plan: SqlQueryPlan,\n contract: Contract<SqlStorage>,\n name: string,\n): void {\n if (plan.meta.storageHash !== contract.storage.storageHash) {\n throw errorDataTransformContractMismatch({\n dataTransformName: name,\n expected: contract.storage.storageHash,\n actual: plan.meta.storageHash,\n });\n }\n}\n"],"mappings":";;;AAgEA,SAAgB,cACd,UACA,MACA,SACA,SACwB;CACxB,MAAMA,cAA+C,MAAM,QAAQ,QAAQ,IAAI,GAC3E,QAAQ,MACR,CAAC,QAAQ,IAA4B;AACzC,QAAO;EACL,IAAI,kBAAkB;EACtB,OAAO,mBAAmB;EAC1B,gBAAgB;EAChB;EACA,QAAQ;EACR,OAAO,QAAQ,QAAQ,eAAe,QAAQ,OAAO,UAAU,SAAS,KAAK,GAAG;EAChF,KAAK,YAAY,KAAK,YAAY,eAAe,SAAS,UAAU,SAAS,KAAK,CAAC;EACpF;;AAGH,SAAS,eACP,SACA,UACA,SACA,MACqB;CACrB,MAAM,SAAS,SAAS;CACxB,MAAM,OAAO,YAAY,OAAO,GAAG,OAAO,OAAO,GAAG;AACpD,uBAAsB,MAAM,UAAU,KAAK;CAC3C,MAAM,UAAU,QAAQ,MAAM,KAAK,KAAK,EAAE,UAAU,CAAC;AACrD,QAAO;EAAE,KAAK,QAAQ;EAAK,QAAQ,QAAQ;EAAQ;;AAGrD,SAAS,YAAY,OAAoC;AACvD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,WAAW,SACX,OAAQ,MAA6B,UAAU;;AAInD,SAAS,sBACP,MACA,UACA,MACM;AACN,KAAI,KAAK,KAAK,gBAAgB,SAAS,QAAQ,YAC7C,OAAM,mCAAmC;EACvC,mBAAmB;EACnB,UAAU,SAAS,QAAQ;EAC3B,QAAQ,KAAK,KAAK;EACnB,CAAC"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
//#region src/core/authoring.ts
|
|
2
|
-
const postgresAuthoringTypes = { enum: {
|
|
3
|
-
kind: "typeConstructor",
|
|
4
|
-
args: [{ kind: "string" }, { kind: "stringArray" }],
|
|
5
|
-
output: {
|
|
6
|
-
codecId: "pg/enum@1",
|
|
7
|
-
nativeType: {
|
|
8
|
-
kind: "arg",
|
|
9
|
-
index: 0
|
|
10
|
-
},
|
|
11
|
-
typeParams: { values: {
|
|
12
|
-
kind: "arg",
|
|
13
|
-
index: 1
|
|
14
|
-
} }
|
|
15
|
-
}
|
|
16
|
-
} };
|
|
17
|
-
/**
|
|
18
|
-
* Field presets contributed by the Postgres target pack.
|
|
19
|
-
*
|
|
20
|
-
* These mirror the PSL scalar-to-codec mapping used by the Postgres adapter
|
|
21
|
-
* (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field
|
|
22
|
-
* via the TS callback surface (e.g. `field.int()`) and via the PSL scalar
|
|
23
|
-
* surface (e.g. `Int`) lowers to byte-identical contracts.
|
|
24
|
-
*/
|
|
25
|
-
const postgresAuthoringFieldPresets = {
|
|
26
|
-
text: {
|
|
27
|
-
kind: "fieldPreset",
|
|
28
|
-
output: {
|
|
29
|
-
codecId: "pg/text@1",
|
|
30
|
-
nativeType: "text"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
int: {
|
|
34
|
-
kind: "fieldPreset",
|
|
35
|
-
output: {
|
|
36
|
-
codecId: "pg/int4@1",
|
|
37
|
-
nativeType: "int4"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
bigint: {
|
|
41
|
-
kind: "fieldPreset",
|
|
42
|
-
output: {
|
|
43
|
-
codecId: "pg/int8@1",
|
|
44
|
-
nativeType: "int8"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
float: {
|
|
48
|
-
kind: "fieldPreset",
|
|
49
|
-
output: {
|
|
50
|
-
codecId: "pg/float8@1",
|
|
51
|
-
nativeType: "float8"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
decimal: {
|
|
55
|
-
kind: "fieldPreset",
|
|
56
|
-
output: {
|
|
57
|
-
codecId: "pg/numeric@1",
|
|
58
|
-
nativeType: "numeric"
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
boolean: {
|
|
62
|
-
kind: "fieldPreset",
|
|
63
|
-
output: {
|
|
64
|
-
codecId: "pg/bool@1",
|
|
65
|
-
nativeType: "bool"
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
json: {
|
|
69
|
-
kind: "fieldPreset",
|
|
70
|
-
output: {
|
|
71
|
-
codecId: "pg/jsonb@1",
|
|
72
|
-
nativeType: "jsonb"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
bytes: {
|
|
76
|
-
kind: "fieldPreset",
|
|
77
|
-
output: {
|
|
78
|
-
codecId: "pg/bytea@1",
|
|
79
|
-
nativeType: "bytea"
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
dateTime: {
|
|
83
|
-
kind: "fieldPreset",
|
|
84
|
-
output: {
|
|
85
|
-
codecId: "pg/timestamptz@1",
|
|
86
|
-
nativeType: "timestamptz"
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
createdAt: {
|
|
90
|
-
kind: "fieldPreset",
|
|
91
|
-
output: {
|
|
92
|
-
codecId: "pg/timestamptz@1",
|
|
93
|
-
nativeType: "timestamptz",
|
|
94
|
-
default: {
|
|
95
|
-
kind: "function",
|
|
96
|
-
expression: "now()"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/core/descriptor-meta.ts
|
|
104
|
-
const postgresTargetDescriptorMetaBase = {
|
|
105
|
-
kind: "target",
|
|
106
|
-
familyId: "sql",
|
|
107
|
-
targetId: "postgres",
|
|
108
|
-
id: "postgres",
|
|
109
|
-
version: "0.0.1",
|
|
110
|
-
capabilities: {},
|
|
111
|
-
authoring: {
|
|
112
|
-
type: postgresAuthoringTypes,
|
|
113
|
-
field: postgresAuthoringFieldPresets
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const postgresTargetDescriptorMeta = postgresTargetDescriptorMetaBase;
|
|
117
|
-
|
|
118
|
-
//#endregion
|
|
119
|
-
export { postgresTargetDescriptorMeta as t };
|
|
120
|
-
//# sourceMappingURL=descriptor-meta-BVoVtyp-.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-BVoVtyp-.mjs","names":["postgresTargetDescriptorMeta: typeof postgresTargetDescriptorMetaBase & {\n readonly __codecTypes?: CodecTypes;\n}"],"sources":["../src/core/authoring.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import type {\n AuthoringFieldNamespace,\n AuthoringTypeNamespace,\n} from '@prisma-next/framework-components/authoring';\n\nexport const postgresAuthoringTypes = {\n enum: {\n kind: 'typeConstructor',\n args: [{ kind: 'string' }, { kind: 'stringArray' }],\n output: {\n codecId: 'pg/enum@1',\n nativeType: { kind: 'arg', index: 0 },\n typeParams: {\n values: { kind: 'arg', index: 1 },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n\n/**\n * Field presets contributed by the Postgres target pack.\n *\n * These mirror the PSL scalar-to-codec mapping used by the Postgres adapter\n * (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field\n * via the TS callback surface (e.g. `field.int()`) and via the PSL scalar\n * surface (e.g. `Int`) lowers to byte-identical contracts.\n */\nexport const postgresAuthoringFieldPresets = {\n text: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/text@1',\n nativeType: 'text',\n },\n },\n int: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int4@1',\n nativeType: 'int4',\n },\n },\n bigint: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int8@1',\n nativeType: 'int8',\n },\n },\n float: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/float8@1',\n nativeType: 'float8',\n },\n },\n decimal: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/numeric@1',\n nativeType: 'numeric',\n },\n },\n boolean: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bool@1',\n nativeType: 'bool',\n },\n },\n json: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/jsonb@1',\n nativeType: 'jsonb',\n },\n },\n bytes: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bytea@1',\n nativeType: 'bytea',\n },\n },\n dateTime: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n },\n },\n createdAt: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n default: {\n kind: 'function',\n expression: 'now()',\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n","import { postgresAuthoringFieldPresets, postgresAuthoringTypes } from './authoring';\nimport type { CodecTypes } from './codecs';\n\nconst postgresTargetDescriptorMetaBase = {\n kind: 'target',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n version: '0.0.1',\n capabilities: {},\n authoring: {\n type: postgresAuthoringTypes,\n field: postgresAuthoringFieldPresets,\n },\n} as const;\n\nexport const postgresTargetDescriptorMeta: typeof postgresTargetDescriptorMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = postgresTargetDescriptorMetaBase;\n"],"mappings":";AAKA,MAAa,yBAAyB,EACpC,MAAM;CACJ,MAAM;CACN,MAAM,CAAC,EAAE,MAAM,UAAU,EAAE,EAAE,MAAM,eAAe,CAAC;CACnD,QAAQ;EACN,SAAS;EACT,YAAY;GAAE,MAAM;GAAO,OAAO;GAAG;EACrC,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;GAAG,EAClC;EACF;CACF,EACF;;;;;;;;;AAUD,MAAa,gCAAgC;CAC3C,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,KAAK;EACH,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,QAAQ;EACN,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,SAAS;EACP,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,SAAS;EACP,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,UAAU;EACR,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACb;EACF;CACD,WAAW;EACT,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,SAAS;IACP,MAAM;IACN,YAAY;IACb;GACF;EACF;CACF;;;;ACnGD,MAAM,mCAAmC;CACvC,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,EAAE;CAChB,WAAW;EACT,MAAM;EACN,OAAO;EACR;CACF;AAED,MAAaA,+BAET"}
|