@prisma-next/adapter-postgres 0.3.0-pr.93.4 → 0.3.0-pr.94.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter-vLVsbQbI.mjs +208 -0
- package/dist/adapter-vLVsbQbI.mjs.map +1 -0
- package/dist/adapter.d.mts +22 -0
- package/dist/adapter.d.mts.map +1 -0
- package/dist/adapter.mjs +4 -0
- package/dist/codec-types.d.mts +41 -0
- package/dist/codec-types.d.mts.map +1 -0
- package/dist/codec-types.mjs +3 -0
- package/dist/codecs-C27nqnIR.mjs +101 -0
- package/dist/codecs-C27nqnIR.mjs.map +1 -0
- package/dist/column-types.d.mts +16 -0
- package/dist/column-types.d.mts.map +1 -0
- package/dist/column-types.mjs +41 -0
- package/dist/column-types.mjs.map +1 -0
- package/dist/control.d.mts +12 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +233 -0
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-CROp5TMm.mjs +82 -0
- package/dist/descriptor-meta-CROp5TMm.mjs.map +1 -0
- package/dist/runtime.d.mts +18 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +19 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/types-BWJKZyMa.d.mts +19 -0
- package/dist/types-BWJKZyMa.d.mts.map +1 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +26 -40
- package/dist/chunk-HD5YISNQ.js +0 -47
- package/dist/chunk-HD5YISNQ.js.map +0 -1
- package/dist/chunk-J3XSOAM2.js +0 -162
- package/dist/chunk-J3XSOAM2.js.map +0 -1
- package/dist/chunk-T6S3A6VT.js +0 -301
- package/dist/chunk-T6S3A6VT.js.map +0 -1
- package/dist/core/adapter.d.ts +0 -19
- package/dist/core/adapter.d.ts.map +0 -1
- package/dist/core/codecs.d.ts +0 -110
- package/dist/core/codecs.d.ts.map +0 -1
- package/dist/core/control-adapter.d.ts +0 -33
- package/dist/core/control-adapter.d.ts.map +0 -1
- package/dist/core/descriptor-meta.d.ts +0 -72
- package/dist/core/descriptor-meta.d.ts.map +0 -1
- package/dist/core/types.d.ts +0 -16
- package/dist/core/types.d.ts.map +0 -1
- package/dist/exports/adapter.d.ts +0 -2
- package/dist/exports/adapter.d.ts.map +0 -1
- package/dist/exports/adapter.js +0 -8
- package/dist/exports/adapter.js.map +0 -1
- package/dist/exports/codec-types.d.ts +0 -11
- package/dist/exports/codec-types.d.ts.map +0 -1
- package/dist/exports/codec-types.js +0 -7
- package/dist/exports/codec-types.js.map +0 -1
- package/dist/exports/column-types.d.ts +0 -17
- package/dist/exports/column-types.d.ts.map +0 -1
- package/dist/exports/column-types.js +0 -49
- package/dist/exports/column-types.js.map +0 -1
- package/dist/exports/control.d.ts +0 -8
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -279
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -15
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -20
- package/dist/exports/runtime.js.map +0 -1
- package/dist/exports/types.d.ts +0 -2
- package/dist/exports/types.d.ts.map +0 -1
- package/dist/exports/types.js +0 -1
- package/dist/exports/types.js.map +0 -1
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { t as codecDefinitions } from "./codecs-C27nqnIR.mjs";
|
|
2
|
+
import { createCodecRegistry, isOperationExpr } from "@prisma-next/sql-relational-core/ast";
|
|
3
|
+
|
|
4
|
+
//#region src/core/adapter.ts
|
|
5
|
+
const VECTOR_CODEC_ID = "pg/vector@1";
|
|
6
|
+
const defaultCapabilities = Object.freeze({ postgres: {
|
|
7
|
+
orderBy: true,
|
|
8
|
+
limit: true,
|
|
9
|
+
lateral: true,
|
|
10
|
+
jsonAgg: true,
|
|
11
|
+
returning: true
|
|
12
|
+
} });
|
|
13
|
+
var PostgresAdapterImpl = class {
|
|
14
|
+
familyId = "sql";
|
|
15
|
+
targetId = "postgres";
|
|
16
|
+
profile;
|
|
17
|
+
codecRegistry = (() => {
|
|
18
|
+
const registry = createCodecRegistry();
|
|
19
|
+
for (const definition of Object.values(codecDefinitions)) registry.register(definition.codec);
|
|
20
|
+
return registry;
|
|
21
|
+
})();
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.profile = Object.freeze({
|
|
24
|
+
id: options?.profileId ?? "postgres/default@1",
|
|
25
|
+
target: "postgres",
|
|
26
|
+
capabilities: defaultCapabilities,
|
|
27
|
+
codecs: () => this.codecRegistry
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
lower(ast, context) {
|
|
31
|
+
let sql;
|
|
32
|
+
const params = context.params ? [...context.params] : [];
|
|
33
|
+
if (ast.kind === "select") sql = renderSelect(ast, context.contract);
|
|
34
|
+
else if (ast.kind === "insert") sql = renderInsert(ast, context.contract);
|
|
35
|
+
else if (ast.kind === "update") sql = renderUpdate(ast, context.contract);
|
|
36
|
+
else if (ast.kind === "delete") sql = renderDelete(ast, context.contract);
|
|
37
|
+
else throw new Error(`Unsupported AST kind: ${ast.kind}`);
|
|
38
|
+
return Object.freeze({
|
|
39
|
+
profileId: this.profile.id,
|
|
40
|
+
body: Object.freeze({
|
|
41
|
+
sql,
|
|
42
|
+
params
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function renderSelect(ast, contract) {
|
|
48
|
+
const selectClause = `SELECT ${renderProjection(ast, contract)}`;
|
|
49
|
+
const fromClause = `FROM ${quoteIdentifier(ast.from.name)}`;
|
|
50
|
+
const joinsClause = ast.joins?.length ? ast.joins.map((join) => renderJoin(join, contract)).join(" ") : "";
|
|
51
|
+
const includesClause = ast.includes?.length ? ast.includes.map((include) => renderInclude(include, contract)).join(" ") : "";
|
|
52
|
+
const whereClause = ast.where ? ` WHERE ${renderWhere(ast.where, contract)}` : "";
|
|
53
|
+
const orderClause = ast.orderBy?.length ? ` ORDER BY ${ast.orderBy.map((order) => {
|
|
54
|
+
return `${renderExpr(order.expr, contract)} ${order.dir.toUpperCase()}`;
|
|
55
|
+
}).join(", ")}` : "";
|
|
56
|
+
const limitClause = typeof ast.limit === "number" ? ` LIMIT ${ast.limit}` : "";
|
|
57
|
+
const clauses = [joinsClause, includesClause].filter(Boolean).join(" ");
|
|
58
|
+
return `${selectClause} ${fromClause}${clauses ? ` ${clauses}` : ""}${whereClause}${orderClause}${limitClause}`.trim();
|
|
59
|
+
}
|
|
60
|
+
function renderProjection(ast, contract) {
|
|
61
|
+
return ast.project.map((item) => {
|
|
62
|
+
const expr = item.expr;
|
|
63
|
+
if (expr.kind === "includeRef") return `${quoteIdentifier(`${expr.alias}_lateral`)}.${quoteIdentifier(expr.alias)} AS ${quoteIdentifier(item.alias)}`;
|
|
64
|
+
if (expr.kind === "operation") return `${renderOperation(expr, contract)} AS ${quoteIdentifier(item.alias)}`;
|
|
65
|
+
if (expr.kind === "literal") return `${renderLiteral(expr)} AS ${quoteIdentifier(item.alias)}`;
|
|
66
|
+
return `${renderColumn(expr)} AS ${quoteIdentifier(item.alias)}`;
|
|
67
|
+
}).join(", ");
|
|
68
|
+
}
|
|
69
|
+
function renderWhere(expr, contract) {
|
|
70
|
+
if (expr.kind === "exists") return `${expr.not ? "NOT " : ""}EXISTS (${renderSelect(expr.subquery, contract)})`;
|
|
71
|
+
return renderBinary(expr, contract);
|
|
72
|
+
}
|
|
73
|
+
function renderBinary(expr, contract) {
|
|
74
|
+
const leftExpr = expr.left;
|
|
75
|
+
const left = renderExpr(leftExpr, contract);
|
|
76
|
+
const rightExpr = expr.right;
|
|
77
|
+
const right = rightExpr.kind === "col" ? renderColumn(rightExpr) : renderParam(rightExpr, contract);
|
|
78
|
+
return `${isOperationExpr(leftExpr) ? `(${left})` : left} ${{
|
|
79
|
+
eq: "=",
|
|
80
|
+
neq: "!=",
|
|
81
|
+
gt: ">",
|
|
82
|
+
lt: "<",
|
|
83
|
+
gte: ">=",
|
|
84
|
+
lte: "<="
|
|
85
|
+
}[expr.op]} ${right}`;
|
|
86
|
+
}
|
|
87
|
+
function renderColumn(ref) {
|
|
88
|
+
return `${quoteIdentifier(ref.table)}.${quoteIdentifier(ref.column)}`;
|
|
89
|
+
}
|
|
90
|
+
function renderExpr(expr, contract) {
|
|
91
|
+
if (isOperationExpr(expr)) return renderOperation(expr, contract);
|
|
92
|
+
return renderColumn(expr);
|
|
93
|
+
}
|
|
94
|
+
function renderParam(ref, contract, tableName, columnName) {
|
|
95
|
+
if (contract && tableName && columnName) {
|
|
96
|
+
if ((contract.storage.tables[tableName]?.columns[columnName])?.codecId === VECTOR_CODEC_ID) return `$${ref.index}::vector`;
|
|
97
|
+
}
|
|
98
|
+
return `$${ref.index}`;
|
|
99
|
+
}
|
|
100
|
+
function renderLiteral(expr) {
|
|
101
|
+
if (typeof expr.value === "string") return `'${expr.value.replace(/'/g, "''")}'`;
|
|
102
|
+
if (typeof expr.value === "number" || typeof expr.value === "boolean") return String(expr.value);
|
|
103
|
+
if (expr.value === null) return "NULL";
|
|
104
|
+
if (Array.isArray(expr.value)) return `ARRAY[${expr.value.map((v) => renderLiteral({
|
|
105
|
+
kind: "literal",
|
|
106
|
+
value: v
|
|
107
|
+
})).join(", ")}]`;
|
|
108
|
+
return JSON.stringify(expr.value);
|
|
109
|
+
}
|
|
110
|
+
function renderOperation(expr, contract) {
|
|
111
|
+
const self = renderExpr(expr.self, contract);
|
|
112
|
+
const isVectorOperation = expr.forTypeId === VECTOR_CODEC_ID;
|
|
113
|
+
const args = expr.args.map((arg) => {
|
|
114
|
+
if (arg.kind === "col") return renderColumn(arg);
|
|
115
|
+
if (arg.kind === "param") return isVectorOperation ? `$${arg.index}::vector` : renderParam(arg, contract);
|
|
116
|
+
if (arg.kind === "literal") return renderLiteral(arg);
|
|
117
|
+
if (arg.kind === "operation") return renderOperation(arg, contract);
|
|
118
|
+
const _exhaustive = arg;
|
|
119
|
+
throw new Error(`Unsupported argument kind: ${_exhaustive.kind}`);
|
|
120
|
+
});
|
|
121
|
+
let result = expr.lowering.template;
|
|
122
|
+
result = result.replace(/\$\{self\}/g, self);
|
|
123
|
+
for (let i = 0; i < args.length; i++) result = result.replace(new RegExp(`\\$\\{arg${i}\\}`, "g"), args[i] ?? "");
|
|
124
|
+
if (expr.lowering.strategy === "function") return result;
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
function renderJoin(join, _contract) {
|
|
128
|
+
return `${join.joinType.toUpperCase()} JOIN ${quoteIdentifier(join.table.name)} ON ${renderJoinOn(join.on)}`;
|
|
129
|
+
}
|
|
130
|
+
function renderJoinOn(on) {
|
|
131
|
+
if (on.kind === "eqCol") return `${renderColumn(on.left)} = ${renderColumn(on.right)}`;
|
|
132
|
+
throw new Error(`Unsupported join ON expression kind: ${on.kind}`);
|
|
133
|
+
}
|
|
134
|
+
function renderInclude(include, contract) {
|
|
135
|
+
const alias = include.alias;
|
|
136
|
+
const jsonBuildObject = `json_build_object(${include.child.project.map((item) => {
|
|
137
|
+
const expr = renderExpr(item.expr, contract);
|
|
138
|
+
return `'${item.alias}', ${expr}`;
|
|
139
|
+
}).join(", ")})`;
|
|
140
|
+
let whereClause = ` WHERE ${renderJoinOn(include.child.on)}`;
|
|
141
|
+
if (include.child.where) whereClause += ` AND ${renderWhere(include.child.where, contract)}`;
|
|
142
|
+
const childOrderBy = include.child.orderBy?.length ? ` ORDER BY ${include.child.orderBy.map((order) => `${renderExpr(order.expr, contract)} ${order.dir.toUpperCase()}`).join(", ")}` : "";
|
|
143
|
+
const childLimit = typeof include.child.limit === "number" ? ` LIMIT ${include.child.limit}` : "";
|
|
144
|
+
const childTable = quoteIdentifier(include.child.table.name);
|
|
145
|
+
let subquery;
|
|
146
|
+
if (typeof include.child.limit === "number") {
|
|
147
|
+
const columnAliasMap = /* @__PURE__ */ new Map();
|
|
148
|
+
for (const item of include.child.project) if (item.expr.kind === "col") {
|
|
149
|
+
const columnKey = `${item.expr.table}.${item.expr.column}`;
|
|
150
|
+
columnAliasMap.set(columnKey, item.alias);
|
|
151
|
+
}
|
|
152
|
+
const innerColumns = include.child.project.map((item) => {
|
|
153
|
+
return `${renderExpr(item.expr, contract)} AS ${quoteIdentifier(item.alias)}`;
|
|
154
|
+
}).join(", ");
|
|
155
|
+
const childOrderByWithAliases = include.child.orderBy?.length ? ` ORDER BY ${include.child.orderBy.map((order) => {
|
|
156
|
+
if (order.expr.kind === "col") {
|
|
157
|
+
const columnKey = `${order.expr.table}.${order.expr.column}`;
|
|
158
|
+
const alias$1 = columnAliasMap.get(columnKey);
|
|
159
|
+
if (alias$1) return `${quoteIdentifier(alias$1)} ${order.dir.toUpperCase()}`;
|
|
160
|
+
}
|
|
161
|
+
return `${renderExpr(order.expr, contract)} ${order.dir.toUpperCase()}`;
|
|
162
|
+
}).join(", ")}` : "";
|
|
163
|
+
const innerSelect = `SELECT ${innerColumns} FROM ${childTable}${whereClause}${childOrderByWithAliases}${childLimit}`;
|
|
164
|
+
subquery = `(SELECT json_agg(row_to_json(sub.*)) AS ${quoteIdentifier(alias)} FROM (${innerSelect}) sub)`;
|
|
165
|
+
} else if (childOrderBy) subquery = `(SELECT json_agg(${jsonBuildObject}${childOrderBy}) AS ${quoteIdentifier(alias)} FROM ${childTable}${whereClause})`;
|
|
166
|
+
else subquery = `(SELECT json_agg(${jsonBuildObject}) AS ${quoteIdentifier(alias)} FROM ${childTable}${whereClause})`;
|
|
167
|
+
const tableAlias = `${alias}_lateral`;
|
|
168
|
+
return `LEFT JOIN LATERAL ${subquery} AS ${quoteIdentifier(tableAlias)} ON true`;
|
|
169
|
+
}
|
|
170
|
+
function quoteIdentifier(identifier) {
|
|
171
|
+
return `"${identifier.replace(/"/g, "\"\"")}"`;
|
|
172
|
+
}
|
|
173
|
+
function renderInsert(ast, contract) {
|
|
174
|
+
const table = quoteIdentifier(ast.table.name);
|
|
175
|
+
const columns = Object.keys(ast.values).map((col) => quoteIdentifier(col));
|
|
176
|
+
const tableMeta = contract.storage.tables[ast.table.name];
|
|
177
|
+
const values = Object.entries(ast.values).map(([colName, val]) => {
|
|
178
|
+
if (val.kind === "param") return (tableMeta?.columns[colName])?.codecId === VECTOR_CODEC_ID ? `$${val.index}::vector` : `$${val.index}`;
|
|
179
|
+
if (val.kind === "col") return `${quoteIdentifier(val.table)}.${quoteIdentifier(val.column)}`;
|
|
180
|
+
throw new Error(`Unsupported value kind in INSERT: ${val.kind}`);
|
|
181
|
+
});
|
|
182
|
+
return `${`INSERT INTO ${table} (${columns.join(", ")}) VALUES (${values.join(", ")})`}${ast.returning?.length ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(", ")}` : ""}`;
|
|
183
|
+
}
|
|
184
|
+
function renderUpdate(ast, contract) {
|
|
185
|
+
const table = quoteIdentifier(ast.table.name);
|
|
186
|
+
const tableMeta = contract.storage.tables[ast.table.name];
|
|
187
|
+
const setClauses = Object.entries(ast.set).map(([col, val]) => {
|
|
188
|
+
const column = quoteIdentifier(col);
|
|
189
|
+
let value;
|
|
190
|
+
if (val.kind === "param") value = (tableMeta?.columns[col])?.codecId === VECTOR_CODEC_ID ? `$${val.index}::vector` : `$${val.index}`;
|
|
191
|
+
else if (val.kind === "col") value = `${quoteIdentifier(val.table)}.${quoteIdentifier(val.column)}`;
|
|
192
|
+
else throw new Error(`Unsupported value kind in UPDATE: ${val.kind}`);
|
|
193
|
+
return `${column} = ${value}`;
|
|
194
|
+
});
|
|
195
|
+
const whereClause = ` WHERE ${renderBinary(ast.where, contract)}`;
|
|
196
|
+
const returningClause = ast.returning?.length ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(", ")}` : "";
|
|
197
|
+
return `UPDATE ${table} SET ${setClauses.join(", ")}${whereClause}${returningClause}`;
|
|
198
|
+
}
|
|
199
|
+
function renderDelete(ast, contract) {
|
|
200
|
+
return `DELETE FROM ${quoteIdentifier(ast.table.name)}${` WHERE ${renderBinary(ast.where, contract)}`}${ast.returning?.length ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(", ")}` : ""}`;
|
|
201
|
+
}
|
|
202
|
+
function createPostgresAdapter(options) {
|
|
203
|
+
return Object.freeze(new PostgresAdapterImpl(options));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
//#endregion
|
|
207
|
+
export { createPostgresAdapter as t };
|
|
208
|
+
//# sourceMappingURL=adapter-vLVsbQbI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-vLVsbQbI.mjs","names":["sql: string","_exhaustive: never","subquery: string","alias","value: string"],"sources":["../src/core/adapter.ts"],"sourcesContent":["import type {\n Adapter,\n AdapterProfile,\n BinaryExpr,\n ColumnRef,\n DeleteAst,\n ExistsExpr,\n IncludeRef,\n InsertAst,\n JoinAst,\n LiteralExpr,\n LowererContext,\n OperationExpr,\n ParamRef,\n QueryAst,\n SelectAst,\n UpdateAst,\n} from '@prisma-next/sql-relational-core/ast';\nimport { createCodecRegistry, isOperationExpr } from '@prisma-next/sql-relational-core/ast';\nimport { codecDefinitions } from './codecs';\nimport type { PostgresAdapterOptions, PostgresContract, PostgresLoweredStatement } from './types';\n\nconst VECTOR_CODEC_ID = 'pg/vector@1' as const;\n\nconst defaultCapabilities = Object.freeze({\n postgres: {\n orderBy: true,\n limit: true,\n lateral: true,\n jsonAgg: true,\n returning: true,\n },\n});\n\nclass PostgresAdapterImpl implements Adapter<QueryAst, PostgresContract, PostgresLoweredStatement> {\n // These fields make the adapter instance structurally compatible with\n // RuntimeAdapterInstance<'sql', 'postgres'> without introducing a runtime-plane dependency.\n readonly familyId = 'sql' as const;\n readonly targetId = 'postgres' as const;\n\n readonly profile: AdapterProfile<'postgres'>;\n private readonly codecRegistry = (() => {\n const registry = createCodecRegistry();\n for (const definition of Object.values(codecDefinitions)) {\n registry.register(definition.codec);\n }\n return registry;\n })();\n\n constructor(options?: PostgresAdapterOptions) {\n this.profile = Object.freeze({\n id: options?.profileId ?? 'postgres/default@1',\n target: 'postgres',\n capabilities: defaultCapabilities,\n codecs: () => this.codecRegistry,\n });\n }\n\n lower(ast: QueryAst, context: LowererContext<PostgresContract>) {\n let sql: string;\n const params = context.params ? [...context.params] : [];\n\n if (ast.kind === 'select') {\n sql = renderSelect(ast, context.contract);\n } else if (ast.kind === 'insert') {\n sql = renderInsert(ast, context.contract);\n } else if (ast.kind === 'update') {\n sql = renderUpdate(ast, context.contract);\n } else if (ast.kind === 'delete') {\n sql = renderDelete(ast, context.contract);\n } else {\n throw new Error(`Unsupported AST kind: ${(ast as { kind: string }).kind}`);\n }\n\n return Object.freeze({\n profileId: this.profile.id,\n body: Object.freeze({ sql, params }),\n });\n }\n}\n\nfunction renderSelect(ast: SelectAst, contract?: PostgresContract): string {\n const selectClause = `SELECT ${renderProjection(ast, contract)}`;\n const fromClause = `FROM ${quoteIdentifier(ast.from.name)}`;\n\n const joinsClause = ast.joins?.length\n ? ast.joins.map((join) => renderJoin(join, contract)).join(' ')\n : '';\n const includesClause = ast.includes?.length\n ? ast.includes.map((include) => renderInclude(include, contract)).join(' ')\n : '';\n\n const whereClause = ast.where ? ` WHERE ${renderWhere(ast.where, contract)}` : '';\n const orderClause = ast.orderBy?.length\n ? ` ORDER BY ${ast.orderBy\n .map((order) => {\n const expr = renderExpr(order.expr as ColumnRef | OperationExpr, contract);\n return `${expr} ${order.dir.toUpperCase()}`;\n })\n .join(', ')}`\n : '';\n const limitClause = typeof ast.limit === 'number' ? ` LIMIT ${ast.limit}` : '';\n\n const clauses = [joinsClause, includesClause].filter(Boolean).join(' ');\n return `${selectClause} ${fromClause}${clauses ? ` ${clauses}` : ''}${whereClause}${orderClause}${limitClause}`.trim();\n}\n\nfunction renderProjection(ast: SelectAst, contract?: PostgresContract): string {\n return ast.project\n .map((item) => {\n const expr = item.expr as ColumnRef | IncludeRef | OperationExpr | LiteralExpr;\n if (expr.kind === 'includeRef') {\n // For include references, select the column from the LATERAL join alias\n // The LATERAL subquery returns a single column (the JSON array) with the alias\n // The table is aliased as {alias}_lateral, and the column inside is aliased as the include alias\n // We select it using table_alias.column_alias\n const tableAlias = `${expr.alias}_lateral`;\n return `${quoteIdentifier(tableAlias)}.${quoteIdentifier(expr.alias)} AS ${quoteIdentifier(item.alias)}`;\n }\n if (expr.kind === 'operation') {\n const operation = renderOperation(expr, contract);\n const alias = quoteIdentifier(item.alias);\n return `${operation} AS ${alias}`;\n }\n if (expr.kind === 'literal') {\n const literal = renderLiteral(expr);\n const alias = quoteIdentifier(item.alias);\n return `${literal} AS ${alias}`;\n }\n const column = renderColumn(expr as ColumnRef);\n const alias = quoteIdentifier(item.alias);\n return `${column} AS ${alias}`;\n })\n .join(', ');\n}\n\nfunction renderWhere(expr: BinaryExpr | ExistsExpr, contract?: PostgresContract): string {\n if (expr.kind === 'exists') {\n const notKeyword = expr.not ? 'NOT ' : '';\n const subquery = renderSelect(expr.subquery, contract);\n return `${notKeyword}EXISTS (${subquery})`;\n }\n return renderBinary(expr, contract);\n}\n\nfunction renderBinary(expr: BinaryExpr, contract?: PostgresContract): string {\n const leftExpr = expr.left as ColumnRef | OperationExpr;\n const left = renderExpr(leftExpr, contract);\n // Handle both ParamRef and ColumnRef on the right side\n // (ColumnRef can appear in EXISTS subqueries for correlation)\n const rightExpr = expr.right as ParamRef | ColumnRef;\n const right =\n rightExpr.kind === 'col'\n ? renderColumn(rightExpr)\n : renderParam(rightExpr as ParamRef, contract);\n // Only wrap in parentheses if it's an operation expression\n const leftRendered = isOperationExpr(leftExpr) ? `(${left})` : left;\n\n // Map operators to SQL symbols\n const operatorMap: Record<BinaryExpr['op'], string> = {\n eq: '=',\n neq: '!=',\n gt: '>',\n lt: '<',\n gte: '>=',\n lte: '<=',\n };\n\n return `${leftRendered} ${operatorMap[expr.op]} ${right}`;\n}\n\nfunction renderColumn(ref: ColumnRef): string {\n return `${quoteIdentifier(ref.table)}.${quoteIdentifier(ref.column)}`;\n}\n\nfunction renderExpr(expr: ColumnRef | OperationExpr, contract?: PostgresContract): string {\n if (isOperationExpr(expr)) {\n return renderOperation(expr, contract);\n }\n return renderColumn(expr);\n}\n\nfunction renderParam(\n ref: ParamRef,\n contract?: PostgresContract,\n tableName?: string,\n columnName?: string,\n): string {\n // Cast vector parameters to vector type for PostgreSQL\n if (contract && tableName && columnName) {\n const tableMeta = contract.storage.tables[tableName];\n const columnMeta = tableMeta?.columns[columnName];\n if (columnMeta?.codecId === VECTOR_CODEC_ID) {\n return `$${ref.index}::vector`;\n }\n }\n return `$${ref.index}`;\n}\n\nfunction renderLiteral(expr: LiteralExpr): string {\n if (typeof expr.value === 'string') {\n return `'${expr.value.replace(/'/g, \"''\")}'`;\n }\n if (typeof expr.value === 'number' || typeof expr.value === 'boolean') {\n return String(expr.value);\n }\n if (expr.value === null) {\n return 'NULL';\n }\n if (Array.isArray(expr.value)) {\n return `ARRAY[${expr.value.map((v: unknown) => renderLiteral({ kind: 'literal', value: v })).join(', ')}]`;\n }\n return JSON.stringify(expr.value);\n}\n\nfunction renderOperation(expr: OperationExpr, contract?: PostgresContract): string {\n const self = renderExpr(expr.self, contract);\n // For vector operations, cast param arguments to vector type\n const isVectorOperation = expr.forTypeId === VECTOR_CODEC_ID;\n const args = expr.args.map((arg: ColumnRef | ParamRef | LiteralExpr | OperationExpr) => {\n if (arg.kind === 'col') {\n return renderColumn(arg);\n }\n if (arg.kind === 'param') {\n // Cast vector operation parameters to vector type\n return isVectorOperation ? `$${arg.index}::vector` : renderParam(arg, contract);\n }\n if (arg.kind === 'literal') {\n return renderLiteral(arg);\n }\n if (arg.kind === 'operation') {\n return renderOperation(arg, contract);\n }\n const _exhaustive: never = arg;\n throw new Error(`Unsupported argument kind: ${(_exhaustive as { kind: string }).kind}`);\n });\n\n let result = expr.lowering.template;\n result = result.replace(/\\$\\{self\\}/g, self);\n for (let i = 0; i < args.length; i++) {\n result = result.replace(new RegExp(`\\\\$\\\\{arg${i}\\\\}`, 'g'), args[i] ?? '');\n }\n\n if (expr.lowering.strategy === 'function') {\n return result;\n }\n\n return result;\n}\n\nfunction renderJoin(join: JoinAst, _contract?: PostgresContract): string {\n const joinType = join.joinType.toUpperCase();\n const table = quoteIdentifier(join.table.name);\n const onClause = renderJoinOn(join.on);\n return `${joinType} JOIN ${table} ON ${onClause}`;\n}\n\nfunction renderJoinOn(on: JoinAst['on']): string {\n if (on.kind === 'eqCol') {\n const left = renderColumn(on.left);\n const right = renderColumn(on.right);\n return `${left} = ${right}`;\n }\n throw new Error(`Unsupported join ON expression kind: ${on.kind}`);\n}\n\nfunction renderInclude(\n include: NonNullable<SelectAst['includes']>[number],\n contract?: PostgresContract,\n): string {\n const alias = include.alias;\n\n // Build the lateral subquery\n const childProjection = include.child.project\n .map((item: { alias: string; expr: ColumnRef | OperationExpr }) => {\n const expr = renderExpr(item.expr, contract);\n return `'${item.alias}', ${expr}`;\n })\n .join(', ');\n\n const jsonBuildObject = `json_build_object(${childProjection})`;\n\n // Build the ON condition from the include's ON clause - this goes in the WHERE clause\n const onCondition = renderJoinOn(include.child.on);\n\n // Build WHERE clause: combine ON condition with any additional WHERE clauses\n let whereClause = ` WHERE ${onCondition}`;\n if (include.child.where) {\n whereClause += ` AND ${renderWhere(include.child.where, contract)}`;\n }\n\n // Add ORDER BY if present - it goes inside json_agg() call\n const childOrderBy = include.child.orderBy?.length\n ? ` ORDER BY ${include.child.orderBy\n .map(\n (order: { expr: ColumnRef | OperationExpr; dir: string }) =>\n `${renderExpr(order.expr, contract)} ${order.dir.toUpperCase()}`,\n )\n .join(', ')}`\n : '';\n\n // Add LIMIT if present\n const childLimit = typeof include.child.limit === 'number' ? ` LIMIT ${include.child.limit}` : '';\n\n // Build the lateral subquery\n // When ORDER BY is present without LIMIT, it goes inside json_agg() call: json_agg(expr ORDER BY ...)\n // When LIMIT is present (with or without ORDER BY), we need to wrap in a subquery\n const childTable = quoteIdentifier(include.child.table.name);\n let subquery: string;\n if (typeof include.child.limit === 'number') {\n // With LIMIT, we need to wrap in a subquery\n // Select individual columns in inner query, then aggregate\n // Create a map of column references to their aliases for ORDER BY\n // Only ColumnRef can be mapped (OperationExpr doesn't have table/column properties)\n const columnAliasMap = new Map<string, string>();\n for (const item of include.child.project) {\n if (item.expr.kind === 'col') {\n const columnKey = `${item.expr.table}.${item.expr.column}`;\n columnAliasMap.set(columnKey, item.alias);\n }\n }\n\n const innerColumns = include.child.project\n .map((item: { alias: string; expr: ColumnRef | OperationExpr }) => {\n const expr = renderExpr(item.expr, contract);\n return `${expr} AS ${quoteIdentifier(item.alias)}`;\n })\n .join(', ');\n\n // For ORDER BY, use column aliases if the column is in the SELECT list\n const childOrderByWithAliases = include.child.orderBy?.length\n ? ` ORDER BY ${include.child.orderBy\n .map((order: { expr: ColumnRef | OperationExpr; dir: string }) => {\n if (order.expr.kind === 'col') {\n const columnKey = `${order.expr.table}.${order.expr.column}`;\n const alias = columnAliasMap.get(columnKey);\n if (alias) {\n return `${quoteIdentifier(alias)} ${order.dir.toUpperCase()}`;\n }\n }\n return `${renderExpr(order.expr, contract)} ${order.dir.toUpperCase()}`;\n })\n .join(', ')}`\n : '';\n\n const innerSelect = `SELECT ${innerColumns} FROM ${childTable}${whereClause}${childOrderByWithAliases}${childLimit}`;\n subquery = `(SELECT json_agg(row_to_json(sub.*)) AS ${quoteIdentifier(alias)} FROM (${innerSelect}) sub)`;\n } else if (childOrderBy) {\n // With ORDER BY but no LIMIT, ORDER BY goes inside json_agg()\n subquery = `(SELECT json_agg(${jsonBuildObject}${childOrderBy}) AS ${quoteIdentifier(alias)} FROM ${childTable}${whereClause})`;\n } else {\n // No ORDER BY or LIMIT\n subquery = `(SELECT json_agg(${jsonBuildObject}) AS ${quoteIdentifier(alias)} FROM ${childTable}${whereClause})`;\n }\n\n // Return the LATERAL join with ON true (the condition is in the WHERE clause)\n // The subquery returns a single column (the JSON array) with the alias\n // We use a different alias for the table to avoid ambiguity when selecting the column\n const tableAlias = `${alias}_lateral`;\n return `LEFT JOIN LATERAL ${subquery} AS ${quoteIdentifier(tableAlias)} ON true`;\n}\n\nfunction quoteIdentifier(identifier: string): string {\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\nfunction renderInsert(ast: InsertAst, contract: PostgresContract): string {\n const table = quoteIdentifier(ast.table.name);\n const columns = Object.keys(ast.values).map((col) => quoteIdentifier(col));\n const tableMeta = contract.storage.tables[ast.table.name];\n const values = Object.entries(ast.values).map(([colName, val]) => {\n if (val.kind === 'param') {\n const columnMeta = tableMeta?.columns[colName];\n const isVector = columnMeta?.codecId === VECTOR_CODEC_ID;\n return isVector ? `$${val.index}::vector` : `$${val.index}`;\n }\n if (val.kind === 'col') {\n return `${quoteIdentifier(val.table)}.${quoteIdentifier(val.column)}`;\n }\n throw new Error(`Unsupported value kind in INSERT: ${(val as { kind: string }).kind}`);\n });\n\n const insertClause = `INSERT INTO ${table} (${columns.join(', ')}) VALUES (${values.join(', ')})`;\n const returningClause = ast.returning?.length\n ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(', ')}`\n : '';\n\n return `${insertClause}${returningClause}`;\n}\n\nfunction renderUpdate(ast: UpdateAst, contract: PostgresContract): string {\n const table = quoteIdentifier(ast.table.name);\n const tableMeta = contract.storage.tables[ast.table.name];\n const setClauses = Object.entries(ast.set).map(([col, val]) => {\n const column = quoteIdentifier(col);\n let value: string;\n if (val.kind === 'param') {\n const columnMeta = tableMeta?.columns[col];\n const isVector = columnMeta?.codecId === VECTOR_CODEC_ID;\n value = isVector ? `$${val.index}::vector` : `$${val.index}`;\n } else if (val.kind === 'col') {\n value = `${quoteIdentifier(val.table)}.${quoteIdentifier(val.column)}`;\n } else {\n throw new Error(`Unsupported value kind in UPDATE: ${(val as { kind: string }).kind}`);\n }\n return `${column} = ${value}`;\n });\n\n const whereClause = ` WHERE ${renderBinary(ast.where, contract)}`;\n const returningClause = ast.returning?.length\n ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(', ')}`\n : '';\n\n return `UPDATE ${table} SET ${setClauses.join(', ')}${whereClause}${returningClause}`;\n}\n\nfunction renderDelete(ast: DeleteAst, contract?: PostgresContract): string {\n const table = quoteIdentifier(ast.table.name);\n const whereClause = ` WHERE ${renderBinary(ast.where, contract)}`;\n const returningClause = ast.returning?.length\n ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(', ')}`\n : '';\n\n return `DELETE FROM ${table}${whereClause}${returningClause}`;\n}\n\nexport function createPostgresAdapter(options?: PostgresAdapterOptions) {\n return Object.freeze(new PostgresAdapterImpl(options));\n}\n"],"mappings":";;;;AAsBA,MAAM,kBAAkB;AAExB,MAAM,sBAAsB,OAAO,OAAO,EACxC,UAAU;CACR,SAAS;CACT,OAAO;CACP,SAAS;CACT,SAAS;CACT,WAAW;CACZ,EACF,CAAC;AAEF,IAAM,sBAAN,MAAmG;CAGjG,AAAS,WAAW;CACpB,AAAS,WAAW;CAEpB,AAAS;CACT,AAAiB,uBAAuB;EACtC,MAAM,WAAW,qBAAqB;AACtC,OAAK,MAAM,cAAc,OAAO,OAAO,iBAAiB,CACtD,UAAS,SAAS,WAAW,MAAM;AAErC,SAAO;KACL;CAEJ,YAAY,SAAkC;AAC5C,OAAK,UAAU,OAAO,OAAO;GAC3B,IAAI,SAAS,aAAa;GAC1B,QAAQ;GACR,cAAc;GACd,cAAc,KAAK;GACpB,CAAC;;CAGJ,MAAM,KAAe,SAA2C;EAC9D,IAAIA;EACJ,MAAM,SAAS,QAAQ,SAAS,CAAC,GAAG,QAAQ,OAAO,GAAG,EAAE;AAExD,MAAI,IAAI,SAAS,SACf,OAAM,aAAa,KAAK,QAAQ,SAAS;WAChC,IAAI,SAAS,SACtB,OAAM,aAAa,KAAK,QAAQ,SAAS;WAChC,IAAI,SAAS,SACtB,OAAM,aAAa,KAAK,QAAQ,SAAS;WA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K,GAAG,cAAc;;AAGtE,SAAS,aAAa,KAAgB,UAAqC;AAOzE,QAAO,eANO,gBAAgB,IAAI,MAAM,KAAK,GACzB,UAAU,aAAa,IAAI,OAAO,SAAS,KACvC,IAAI,WAAW,SACnC,cAAc,IAAI,UAAU,KAAK,QAAQ,GAAG,gBAAgB,IAAI,MAAM,CAAC,GAAG,gBAAgB,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,KACnH;;AAKN,SAAgB,sBAAsB,SAAkC;AACtE,QAAO,OAAO,OAAO,IAAI,oBAAoB,QAAQ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { c as PostgresContract, l as PostgresLoweredStatement, s as PostgresAdapterOptions } from "./types-BWJKZyMa.mjs";
|
|
2
|
+
import { Adapter, AdapterProfile, LowererContext, QueryAst } from "@prisma-next/sql-relational-core/ast";
|
|
3
|
+
|
|
4
|
+
//#region src/core/adapter.d.ts
|
|
5
|
+
declare class PostgresAdapterImpl implements Adapter<QueryAst, PostgresContract, PostgresLoweredStatement> {
|
|
6
|
+
readonly familyId: "sql";
|
|
7
|
+
readonly targetId: "postgres";
|
|
8
|
+
readonly profile: AdapterProfile<'postgres'>;
|
|
9
|
+
private readonly codecRegistry;
|
|
10
|
+
constructor(options?: PostgresAdapterOptions);
|
|
11
|
+
lower(ast: QueryAst, context: LowererContext<PostgresContract>): Readonly<{
|
|
12
|
+
profileId: string;
|
|
13
|
+
body: Readonly<{
|
|
14
|
+
sql: string;
|
|
15
|
+
params: unknown[];
|
|
16
|
+
}>;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
declare function createPostgresAdapter(options?: PostgresAdapterOptions): Readonly<PostgresAdapterImpl>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { createPostgresAdapter };
|
|
22
|
+
//# sourceMappingURL=adapter.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.mts","names":[],"sources":["../src/core/adapter.ts"],"sourcesContent":[],"mappings":";;;;cAkCM,mBAAA,YAA+B,QAAQ,UAAU,kBAAkB;;EAAnE,SAAA,QAAA,EAAA,UAAoB;EAAmB,SAAA,OAAA,EAMzB,cANyB,CAAA,UAAA,CAAA;EAAU,iBAAA,aAAA;EAAkB,WAAA,CAAA,OAAA,CAAA,EAejD,sBAfiD;EAMrD,KAAA,CAAA,GAAA,EAkBP,QAlBO,EAAA,OAAA,EAkBY,cAlBZ,CAkB2B,gBAlB3B,CAAA,CAAA,EAkB4C,QAlB5C,CAAA;IASI,SAAA,EAAA,MAAA;IASX,IAAA,UAAA,CAAA;MAAkC,GAAA,EAAA,MAAA;MAAf,MAAA,EAAA,OAAA,EAAA;;EAAgC,CAAA,CAAA;;AAxBpB,iBAwY5B,qBAAA,CAxY4B,OAAA,CAAA,EAwYI,sBAxYJ,CAAA,EAwY0B,QAxY1B,CAwY0B,mBAxY1B,CAAA"}
|
package/dist/adapter.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as _prisma_next_sql_relational_core_ast0 from "@prisma-next/sql-relational-core/ast";
|
|
2
|
+
|
|
3
|
+
//#region src/core/codecs.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Unified codec definitions for Postgres adapter.
|
|
7
|
+
*
|
|
8
|
+
* This file contains a single source of truth for all codec information:
|
|
9
|
+
* - Scalar names
|
|
10
|
+
* - Type IDs
|
|
11
|
+
* - Codec implementations (runtime)
|
|
12
|
+
* - Type information (compile-time)
|
|
13
|
+
*
|
|
14
|
+
* This structure is used both at runtime (to populate the registry) and
|
|
15
|
+
* at compile time (to derive CodecTypes).
|
|
16
|
+
*/
|
|
17
|
+
declare const codecs: _prisma_next_sql_relational_core_ast0.CodecDefBuilder<{
|
|
18
|
+
text: _prisma_next_sql_relational_core_ast0.Codec<"pg/text@1", string, string>;
|
|
19
|
+
int4: _prisma_next_sql_relational_core_ast0.Codec<"pg/int4@1", number, number>;
|
|
20
|
+
int2: _prisma_next_sql_relational_core_ast0.Codec<"pg/int2@1", number, number>;
|
|
21
|
+
int8: _prisma_next_sql_relational_core_ast0.Codec<"pg/int8@1", number, number>;
|
|
22
|
+
float4: _prisma_next_sql_relational_core_ast0.Codec<"pg/float4@1", number, number>;
|
|
23
|
+
float8: _prisma_next_sql_relational_core_ast0.Codec<"pg/float8@1", number, number>;
|
|
24
|
+
timestamp: _prisma_next_sql_relational_core_ast0.Codec<"pg/timestamp@1", string | Date, string>;
|
|
25
|
+
timestamptz: _prisma_next_sql_relational_core_ast0.Codec<"pg/timestamptz@1", string | Date, string>;
|
|
26
|
+
} & Record<"bool", _prisma_next_sql_relational_core_ast0.Codec<"pg/bool@1", boolean, boolean>>>;
|
|
27
|
+
declare const dataTypes: {
|
|
28
|
+
readonly text: "pg/text@1";
|
|
29
|
+
readonly int4: "pg/int4@1";
|
|
30
|
+
readonly int2: "pg/int2@1";
|
|
31
|
+
readonly int8: "pg/int8@1";
|
|
32
|
+
readonly float4: "pg/float4@1";
|
|
33
|
+
readonly float8: "pg/float8@1";
|
|
34
|
+
readonly timestamp: "pg/timestamp@1";
|
|
35
|
+
readonly timestamptz: "pg/timestamptz@1";
|
|
36
|
+
readonly bool: "pg/bool@1";
|
|
37
|
+
};
|
|
38
|
+
type CodecTypes = typeof codecs.CodecTypes;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { type CodecTypes, dataTypes };
|
|
41
|
+
//# sourceMappingURL=codec-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-types.d.mts","names":[],"sources":["../src/core/codecs.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;cAiLM,8CAAM;QASe,qCAAA,CAAA;;;mDATf,CAAA,WAAA,EAAA,MAAA,EAAA,MAAA,CAAA;EAAA,MAAA,6CAAA,CAAA,aAAA,EAAA,MAAA,EAAA,MAAA,CAAA;EAaC,MAAA,6CAA4B,CAAA,aAAA,EAAA,MAAA,EAAA,MAAA,CAAA;EAG7B,SAAA,6CAAqC,CAAA,gBAAA,EAAA,MAAA,OAAA,EAAA,MAAA,CAAA;;;cAHpC;;;;;;;;;;;KAGD,UAAA,UAAoB,MAAA,CAAO"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { codec, defineCodecs } from "@prisma-next/sql-relational-core/ast";
|
|
2
|
+
|
|
3
|
+
//#region src/core/codecs.ts
|
|
4
|
+
/**
|
|
5
|
+
* Unified codec definitions for Postgres adapter.
|
|
6
|
+
*
|
|
7
|
+
* This file contains a single source of truth for all codec information:
|
|
8
|
+
* - Scalar names
|
|
9
|
+
* - Type IDs
|
|
10
|
+
* - Codec implementations (runtime)
|
|
11
|
+
* - Type information (compile-time)
|
|
12
|
+
*
|
|
13
|
+
* This structure is used both at runtime (to populate the registry) and
|
|
14
|
+
* at compile time (to derive CodecTypes).
|
|
15
|
+
*/
|
|
16
|
+
const pgTextCodec = codec({
|
|
17
|
+
typeId: "pg/text@1",
|
|
18
|
+
targetTypes: ["text"],
|
|
19
|
+
encode: (value) => value,
|
|
20
|
+
decode: (wire) => wire,
|
|
21
|
+
meta: { db: { sql: { postgres: { nativeType: "text" } } } }
|
|
22
|
+
});
|
|
23
|
+
const pgInt4Codec = codec({
|
|
24
|
+
typeId: "pg/int4@1",
|
|
25
|
+
targetTypes: ["int4"],
|
|
26
|
+
encode: (value) => value,
|
|
27
|
+
decode: (wire) => wire,
|
|
28
|
+
meta: { db: { sql: { postgres: { nativeType: "integer" } } } }
|
|
29
|
+
});
|
|
30
|
+
const pgInt2Codec = codec({
|
|
31
|
+
typeId: "pg/int2@1",
|
|
32
|
+
targetTypes: ["int2"],
|
|
33
|
+
encode: (value) => value,
|
|
34
|
+
decode: (wire) => wire,
|
|
35
|
+
meta: { db: { sql: { postgres: { nativeType: "smallint" } } } }
|
|
36
|
+
});
|
|
37
|
+
const pgInt8Codec = codec({
|
|
38
|
+
typeId: "pg/int8@1",
|
|
39
|
+
targetTypes: ["int8"],
|
|
40
|
+
encode: (value) => value,
|
|
41
|
+
decode: (wire) => wire,
|
|
42
|
+
meta: { db: { sql: { postgres: { nativeType: "bigint" } } } }
|
|
43
|
+
});
|
|
44
|
+
const pgFloat4Codec = codec({
|
|
45
|
+
typeId: "pg/float4@1",
|
|
46
|
+
targetTypes: ["float4"],
|
|
47
|
+
encode: (value) => value,
|
|
48
|
+
decode: (wire) => wire,
|
|
49
|
+
meta: { db: { sql: { postgres: { nativeType: "real" } } } }
|
|
50
|
+
});
|
|
51
|
+
const pgFloat8Codec = codec({
|
|
52
|
+
typeId: "pg/float8@1",
|
|
53
|
+
targetTypes: ["float8"],
|
|
54
|
+
encode: (value) => value,
|
|
55
|
+
decode: (wire) => wire,
|
|
56
|
+
meta: { db: { sql: { postgres: { nativeType: "double precision" } } } }
|
|
57
|
+
});
|
|
58
|
+
const pgTimestampCodec = codec({
|
|
59
|
+
typeId: "pg/timestamp@1",
|
|
60
|
+
targetTypes: ["timestamp"],
|
|
61
|
+
encode: (value) => {
|
|
62
|
+
if (value instanceof Date) return value.toISOString();
|
|
63
|
+
if (typeof value === "string") return value;
|
|
64
|
+
return String(value);
|
|
65
|
+
},
|
|
66
|
+
decode: (wire) => {
|
|
67
|
+
if (typeof wire === "string") return wire;
|
|
68
|
+
if (wire instanceof Date) return wire.toISOString();
|
|
69
|
+
return String(wire);
|
|
70
|
+
},
|
|
71
|
+
meta: { db: { sql: { postgres: { nativeType: "timestamp without time zone" } } } }
|
|
72
|
+
});
|
|
73
|
+
const pgTimestamptzCodec = codec({
|
|
74
|
+
typeId: "pg/timestamptz@1",
|
|
75
|
+
targetTypes: ["timestamptz"],
|
|
76
|
+
encode: (value) => {
|
|
77
|
+
if (value instanceof Date) return value.toISOString();
|
|
78
|
+
if (typeof value === "string") return value;
|
|
79
|
+
return String(value);
|
|
80
|
+
},
|
|
81
|
+
decode: (wire) => {
|
|
82
|
+
if (typeof wire === "string") return wire;
|
|
83
|
+
if (wire instanceof Date) return wire.toISOString();
|
|
84
|
+
return String(wire);
|
|
85
|
+
},
|
|
86
|
+
meta: { db: { sql: { postgres: { nativeType: "timestamp with time zone" } } } }
|
|
87
|
+
});
|
|
88
|
+
const pgBoolCodec = codec({
|
|
89
|
+
typeId: "pg/bool@1",
|
|
90
|
+
targetTypes: ["bool"],
|
|
91
|
+
encode: (value) => value,
|
|
92
|
+
decode: (wire) => wire,
|
|
93
|
+
meta: { db: { sql: { postgres: { nativeType: "boolean" } } } }
|
|
94
|
+
});
|
|
95
|
+
const codecs = defineCodecs().add("text", pgTextCodec).add("int4", pgInt4Codec).add("int2", pgInt2Codec).add("int8", pgInt8Codec).add("float4", pgFloat4Codec).add("float8", pgFloat8Codec).add("timestamp", pgTimestampCodec).add("timestamptz", pgTimestamptzCodec).add("bool", pgBoolCodec);
|
|
96
|
+
const codecDefinitions = codecs.codecDefinitions;
|
|
97
|
+
const dataTypes = codecs.dataTypes;
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { dataTypes as n, codecDefinitions as t };
|
|
101
|
+
//# sourceMappingURL=codecs-C27nqnIR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs-C27nqnIR.mjs","names":[],"sources":["../src/core/codecs.ts"],"sourcesContent":["/**\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 { codec, defineCodecs } from '@prisma-next/sql-relational-core/ast';\n\n// Create individual codec instances\nconst pgTextCodec = codec({\n typeId: 'pg/text@1',\n targetTypes: ['text'],\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 pgInt4Codec = codec<'pg/int4@1', number, number>({\n typeId: 'pg/int4@1',\n targetTypes: ['int4'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'integer',\n },\n },\n },\n },\n});\n\nconst pgInt2Codec = codec<'pg/int2@1', number, number>({\n typeId: 'pg/int2@1',\n targetTypes: ['int2'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'smallint',\n },\n },\n },\n },\n});\n\nconst pgInt8Codec = codec<'pg/int8@1', number, number>({\n typeId: 'pg/int8@1',\n targetTypes: ['int8'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bigint',\n },\n },\n },\n },\n});\n\nconst pgFloat4Codec = codec<'pg/float4@1', number, number>({\n typeId: 'pg/float4@1',\n targetTypes: ['float4'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'real',\n },\n },\n },\n },\n});\n\nconst pgFloat8Codec = codec<'pg/float8@1', number, number>({\n typeId: 'pg/float8@1',\n targetTypes: ['float8'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'double precision',\n },\n },\n },\n },\n});\n\nconst pgTimestampCodec = codec<'pg/timestamp@1', string | Date, string>({\n typeId: 'pg/timestamp@1',\n targetTypes: ['timestamp'],\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 (typeof wire === 'string') return wire;\n if (wire instanceof Date) return wire.toISOString();\n return String(wire);\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp without time zone',\n },\n },\n },\n },\n});\n\nconst pgTimestamptzCodec = codec<'pg/timestamptz@1', string | Date, string>({\n typeId: 'pg/timestamptz@1',\n targetTypes: ['timestamptz'],\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 (typeof wire === 'string') return wire;\n if (wire instanceof Date) return wire.toISOString();\n return String(wire);\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp with time zone',\n },\n },\n },\n },\n});\n\nconst pgBoolCodec = codec<'pg/bool@1', boolean, boolean>({\n typeId: 'pg/bool@1',\n targetTypes: ['bool'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'boolean',\n },\n },\n },\n },\n});\n\n// Build codec definitions using the builder DSL\nconst codecs = defineCodecs()\n .add('text', pgTextCodec)\n .add('int4', pgInt4Codec)\n .add('int2', pgInt2Codec)\n .add('int8', pgInt8Codec)\n .add('float4', pgFloat4Codec)\n .add('float8', pgFloat8Codec)\n .add('timestamp', pgTimestampCodec)\n .add('timestamptz', pgTimestamptzCodec)\n .add('bool', pgBoolCodec);\n\n// Export derived structures directly from codecs builder\nexport const codecDefinitions = codecs.codecDefinitions;\nexport const dataTypes = codecs.dataTypes;\n\n// Export types derived from codecs builder\nexport type CodecTypes = typeof codecs.CodecTypes;\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAM,cAAc,MAAM;CACxB,QAAQ;CACR,aAAa,CAAC,OAAO;CACrB,SAAS,UAA0B;CACnC,SAAS,SAAyB;CAClC,MAAM,EACJ,IAAI,EACF,KAAK,EACH,UAAU,EACR,YAAY,QACb,EACF,EACF,EACF;CACF,CAAC;AAEF,MAAM,cAAc,MAAmC;CACrD,QAAQ;CACR,aAAa,CAAC,OAAO;CACrB,SAAS,UAAU;CACnB,SAAS,SAAS;CAClB,MAAM,EACJ,IAAI,EACF,KAAK,EACH,UAAU,EACR,YAAY,WACb,EACF,EACF,EACF;CACF,CAAC;AAEF,MAAM,cAAc,MAAmC;CACrD,QAAQ;CACR,aAAa,CAAC,OAAO;CACrB,SAAS,UAAU;CACnB,SAAS,SAAS;CAClB,MAAM,EACJ,IAAI,EACF,KAAK,EACH,UAAU,EACR,YAAY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AU,QAAO;AACrC,MAAI,gBAAgB,KAAM,QAAO,KAAK,aAAa;AACnD,SAAO,OAAO,KAAK;;CAErB,MAAM,EACJ,IAAI,EACF,KAAK,EACH,UAAU,EACR,YAAY,4BACb,EACF,EACF,EACF;CACF,CAAC;AAEF,MAAM,cAAc,MAAqC;CACvD,QAAQ;CACR,aAAa,CAAC,OAAO;CACrB,SAAS,UAAU;CACnB,SAAS,SAAS;CAClB,MAAM,EACJ,IAAI,EACF,KAAK,EACH,UAAU,EACR,YAAY,WACb,EACF,EACF,EACF;CACF,CAAC;AAGF,MAAM,SAAS,cAAc,CAC1B,IAAI,QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,UAAU,cAAc,CAC5B,IAAI,UAAU,cAAc,CAC5B,IAAI,aAAa,iBAAiB,CAClC,IAAI,eAAe,mBAAmB,CACtC,IAAI,QAAQ,YAAY;AAG3B,MAAa,mBAAmB,OAAO;AACvC,MAAa,YAAY,OAAO"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ColumnTypeDescriptor } from "@prisma-next/contract-authoring";
|
|
2
|
+
|
|
3
|
+
//#region src/exports/column-types.d.ts
|
|
4
|
+
|
|
5
|
+
declare const textColumn: ColumnTypeDescriptor;
|
|
6
|
+
declare const int4Column: ColumnTypeDescriptor;
|
|
7
|
+
declare const int2Column: ColumnTypeDescriptor;
|
|
8
|
+
declare const int8Column: ColumnTypeDescriptor;
|
|
9
|
+
declare const float4Column: ColumnTypeDescriptor;
|
|
10
|
+
declare const float8Column: ColumnTypeDescriptor;
|
|
11
|
+
declare const timestampColumn: ColumnTypeDescriptor;
|
|
12
|
+
declare const timestamptzColumn: ColumnTypeDescriptor;
|
|
13
|
+
declare const boolColumn: ColumnTypeDescriptor;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { boolColumn, float4Column, float8Column, int2Column, int4Column, int8Column, textColumn, timestampColumn, timestamptzColumn };
|
|
16
|
+
//# sourceMappingURL=column-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-types.d.mts","names":[],"sources":["../src/exports/column-types.ts"],"sourcesContent":[],"mappings":";;;;AA6Ba,cApBA,UAoBc,EApBF,oBAuBf;AAEG,cApBA,UAoBc,EApBF,oBAuBf;AAEG,cApBA,UAuBH,EAvBe,oBAoBK;AAKjB,cApBA,UAuBH,EAvBe,oBAoBO;AAKnB,cApBA,YAoBY,EApBE,oBAuBjB;cAlBG,cAAc;cAKd,iBAAiB;cAKjB,mBAAmB;cAKnB,YAAY"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/exports/column-types.ts
|
|
2
|
+
const textColumn = {
|
|
3
|
+
codecId: "pg/text@1",
|
|
4
|
+
nativeType: "text"
|
|
5
|
+
};
|
|
6
|
+
const int4Column = {
|
|
7
|
+
codecId: "pg/int4@1",
|
|
8
|
+
nativeType: "int4"
|
|
9
|
+
};
|
|
10
|
+
const int2Column = {
|
|
11
|
+
codecId: "pg/int2@1",
|
|
12
|
+
nativeType: "int2"
|
|
13
|
+
};
|
|
14
|
+
const int8Column = {
|
|
15
|
+
codecId: "pg/int8@1",
|
|
16
|
+
nativeType: "int8"
|
|
17
|
+
};
|
|
18
|
+
const float4Column = {
|
|
19
|
+
codecId: "pg/float4@1",
|
|
20
|
+
nativeType: "float4"
|
|
21
|
+
};
|
|
22
|
+
const float8Column = {
|
|
23
|
+
codecId: "pg/float8@1",
|
|
24
|
+
nativeType: "float8"
|
|
25
|
+
};
|
|
26
|
+
const timestampColumn = {
|
|
27
|
+
codecId: "pg/timestamp@1",
|
|
28
|
+
nativeType: "timestamp"
|
|
29
|
+
};
|
|
30
|
+
const timestamptzColumn = {
|
|
31
|
+
codecId: "pg/timestamptz@1",
|
|
32
|
+
nativeType: "timestamptz"
|
|
33
|
+
};
|
|
34
|
+
const boolColumn = {
|
|
35
|
+
codecId: "pg/bool@1",
|
|
36
|
+
nativeType: "bool"
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { boolColumn, float4Column, float8Column, int2Column, int4Column, int8Column, textColumn, timestampColumn, timestamptzColumn };
|
|
41
|
+
//# sourceMappingURL=column-types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-types.mjs","names":["textColumn: ColumnTypeDescriptor","int4Column: ColumnTypeDescriptor","int2Column: ColumnTypeDescriptor","int8Column: ColumnTypeDescriptor","float4Column: ColumnTypeDescriptor","float8Column: ColumnTypeDescriptor","timestampColumn: ColumnTypeDescriptor","timestamptzColumn: ColumnTypeDescriptor","boolColumn: ColumnTypeDescriptor"],"sources":["../src/exports/column-types.ts"],"sourcesContent":["/**\n * Column type descriptors for Postgres adapter.\n *\n * These descriptors provide both codecId and nativeType for use in contract authoring.\n * They are derived from the same source of truth as codec definitions and manifests.\n */\n\nimport type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';\n\nexport const textColumn: ColumnTypeDescriptor = {\n codecId: 'pg/text@1',\n nativeType: 'text',\n} as const;\n\nexport const int4Column: ColumnTypeDescriptor = {\n codecId: 'pg/int4@1',\n nativeType: 'int4',\n} as const;\n\nexport const int2Column: ColumnTypeDescriptor = {\n codecId: 'pg/int2@1',\n nativeType: 'int2',\n} as const;\n\nexport const int8Column: ColumnTypeDescriptor = {\n codecId: 'pg/int8@1',\n nativeType: 'int8',\n} as const;\n\nexport const float4Column: ColumnTypeDescriptor = {\n codecId: 'pg/float4@1',\n nativeType: 'float4',\n} as const;\n\nexport const float8Column: ColumnTypeDescriptor = {\n codecId: 'pg/float8@1',\n nativeType: 'float8',\n} as const;\n\nexport const timestampColumn: ColumnTypeDescriptor = {\n codecId: 'pg/timestamp@1',\n nativeType: 'timestamp',\n} as const;\n\nexport const timestamptzColumn: ColumnTypeDescriptor = {\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n} as const;\n\nexport const boolColumn: ColumnTypeDescriptor = {\n codecId: 'pg/bool@1',\n nativeType: 'bool',\n} as const;\n"],"mappings":";AASA,MAAaA,aAAmC;CAC9C,SAAS;CACT,YAAY;CACb;AAED,MAAaC,aAAmC;CAC9C,SAAS;CACT,YAAY;CACb;AAED,MAAaC,aAAmC;CAC9C,SAAS;CACT,YAAY;CACb;AAED,MAAaC,aAAmC;CAC9C,SAAS;CACT,YAAY;CACb;AAED,MAAaC,eAAqC;CAChD,SAAS;CACT,YAAY;CACb;AAED,MAAaC,eAAqC;CAChD,SAAS;CACT,YAAY;CACb;AAED,MAAaC,kBAAwC;CACnD,SAAS;CACT,YAAY;CACb;AAED,MAAaC,oBAA0C;CACrD,SAAS;CACT,YAAY;CACb;AAED,MAAaC,aAAmC;CAC9C,SAAS;CACT,YAAY;CACb"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ControlAdapterDescriptor } from "@prisma-next/core-control-plane/types";
|
|
2
|
+
import { SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
|
|
3
|
+
|
|
4
|
+
//#region src/exports/control.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Postgres adapter descriptor for CLI config.
|
|
8
|
+
*/
|
|
9
|
+
declare const postgresAdapterDescriptor: ControlAdapterDescriptor<'sql', 'postgres', SqlControlAdapter<'postgres'>>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { postgresAdapterDescriptor as default };
|
|
12
|
+
//# sourceMappingURL=control.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"sourcesContent":[],"mappings":";;;;;;;AACiF;cAO3E,2BAA2B,4CAG/B"}
|