@prisma-next/adapter-postgres 0.3.0-dev.7 → 0.3.0-dev.70
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/LICENSE +201 -0
- package/README.md +64 -2
- package/dist/adapter-DtehReRR.mjs +271 -0
- package/dist/adapter-DtehReRR.mjs.map +1 -0
- package/dist/adapter.d.mts +23 -0
- package/dist/adapter.d.mts.map +1 -0
- package/dist/adapter.mjs +3 -0
- package/dist/codec-ids-Bsm9c7ns.mjs +29 -0
- package/dist/codec-ids-Bsm9c7ns.mjs.map +1 -0
- package/dist/codec-types.d.mts +141 -0
- package/dist/codec-types.d.mts.map +1 -0
- package/dist/codec-types.mjs +3 -0
- package/dist/codecs-BfC_5c-4.mjs +207 -0
- package/dist/codecs-BfC_5c-4.mjs.map +1 -0
- package/dist/column-types.d.mts +110 -0
- package/dist/column-types.d.mts.map +1 -0
- package/dist/column-types.mjs +180 -0
- package/dist/column-types.mjs.map +1 -0
- package/dist/control.d.mts +111 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +462 -0
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-ilnFI7bx.mjs +921 -0
- package/dist/descriptor-meta-ilnFI7bx.mjs.map +1 -0
- package/dist/runtime.d.mts +19 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +85 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/sql-utils-CSfAGEwF.mjs +78 -0
- package/dist/sql-utils-CSfAGEwF.mjs.map +1 -0
- package/dist/types-CXO7EB60.d.mts +19 -0
- package/dist/types-CXO7EB60.d.mts.map +1 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +37 -46
- package/src/core/adapter.ts +139 -28
- package/src/core/codec-ids.ts +28 -0
- package/src/core/codecs.ts +325 -23
- package/src/core/control-adapter.ts +400 -178
- package/src/core/default-normalizer.ts +90 -0
- package/src/core/descriptor-meta.ts +221 -9
- package/src/core/enum-control-hooks.ts +735 -0
- package/src/core/json-schema-type-expression.ts +131 -0
- package/src/core/json-schema-validator.ts +53 -0
- package/src/core/parameterized-types.ts +118 -0
- package/src/core/sql-utils.ts +111 -0
- package/src/core/standard-schema.ts +71 -0
- package/src/exports/codec-types.ts +73 -1
- package/src/exports/column-types.ts +233 -9
- package/src/exports/control.ts +16 -9
- package/src/exports/runtime.ts +61 -18
- 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
package/dist/chunk-T6S3A6VT.js
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
codecDefinitions
|
|
3
|
-
} from "./chunk-J3XSOAM2.js";
|
|
4
|
-
|
|
5
|
-
// src/core/adapter.ts
|
|
6
|
-
import { createCodecRegistry, isOperationExpr } from "@prisma-next/sql-relational-core/ast";
|
|
7
|
-
var VECTOR_CODEC_ID = "pg/vector@1";
|
|
8
|
-
var defaultCapabilities = Object.freeze({
|
|
9
|
-
postgres: {
|
|
10
|
-
orderBy: true,
|
|
11
|
-
limit: true,
|
|
12
|
-
lateral: true,
|
|
13
|
-
jsonAgg: true,
|
|
14
|
-
returning: true
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
var PostgresAdapterImpl = class {
|
|
18
|
-
// These fields make the adapter instance structurally compatible with
|
|
19
|
-
// RuntimeAdapterInstance<'sql', 'postgres'> without introducing a runtime-plane dependency.
|
|
20
|
-
familyId = "sql";
|
|
21
|
-
targetId = "postgres";
|
|
22
|
-
profile;
|
|
23
|
-
codecRegistry = (() => {
|
|
24
|
-
const registry = createCodecRegistry();
|
|
25
|
-
for (const definition of Object.values(codecDefinitions)) {
|
|
26
|
-
registry.register(definition.codec);
|
|
27
|
-
}
|
|
28
|
-
return registry;
|
|
29
|
-
})();
|
|
30
|
-
constructor(options) {
|
|
31
|
-
this.profile = Object.freeze({
|
|
32
|
-
id: options?.profileId ?? "postgres/default@1",
|
|
33
|
-
target: "postgres",
|
|
34
|
-
capabilities: defaultCapabilities,
|
|
35
|
-
codecs: () => this.codecRegistry
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
lower(ast, context) {
|
|
39
|
-
let sql;
|
|
40
|
-
const params = context.params ? [...context.params] : [];
|
|
41
|
-
if (ast.kind === "select") {
|
|
42
|
-
sql = renderSelect(ast, context.contract);
|
|
43
|
-
} else if (ast.kind === "insert") {
|
|
44
|
-
sql = renderInsert(ast, context.contract);
|
|
45
|
-
} else if (ast.kind === "update") {
|
|
46
|
-
sql = renderUpdate(ast, context.contract);
|
|
47
|
-
} else if (ast.kind === "delete") {
|
|
48
|
-
sql = renderDelete(ast, context.contract);
|
|
49
|
-
} else {
|
|
50
|
-
throw new Error(`Unsupported AST kind: ${ast.kind}`);
|
|
51
|
-
}
|
|
52
|
-
return Object.freeze({
|
|
53
|
-
profileId: this.profile.id,
|
|
54
|
-
body: Object.freeze({ sql, params })
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
function renderSelect(ast, contract) {
|
|
59
|
-
const selectClause = `SELECT ${renderProjection(ast, contract)}`;
|
|
60
|
-
const fromClause = `FROM ${quoteIdentifier(ast.from.name)}`;
|
|
61
|
-
const joinsClause = ast.joins?.length ? ast.joins.map((join) => renderJoin(join, contract)).join(" ") : "";
|
|
62
|
-
const includesClause = ast.includes?.length ? ast.includes.map((include) => renderInclude(include, contract)).join(" ") : "";
|
|
63
|
-
const whereClause = ast.where ? ` WHERE ${renderWhere(ast.where, contract)}` : "";
|
|
64
|
-
const orderClause = ast.orderBy?.length ? ` ORDER BY ${ast.orderBy.map((order) => {
|
|
65
|
-
const expr = renderExpr(order.expr, contract);
|
|
66
|
-
return `${expr} ${order.dir.toUpperCase()}`;
|
|
67
|
-
}).join(", ")}` : "";
|
|
68
|
-
const limitClause = typeof ast.limit === "number" ? ` LIMIT ${ast.limit}` : "";
|
|
69
|
-
const clauses = [joinsClause, includesClause].filter(Boolean).join(" ");
|
|
70
|
-
return `${selectClause} ${fromClause}${clauses ? ` ${clauses}` : ""}${whereClause}${orderClause}${limitClause}`.trim();
|
|
71
|
-
}
|
|
72
|
-
function renderProjection(ast, contract) {
|
|
73
|
-
return ast.project.map((item) => {
|
|
74
|
-
const expr = item.expr;
|
|
75
|
-
if (expr.kind === "includeRef") {
|
|
76
|
-
const tableAlias = `${expr.alias}_lateral`;
|
|
77
|
-
return `${quoteIdentifier(tableAlias)}.${quoteIdentifier(expr.alias)} AS ${quoteIdentifier(item.alias)}`;
|
|
78
|
-
}
|
|
79
|
-
if (expr.kind === "operation") {
|
|
80
|
-
const operation = renderOperation(expr, contract);
|
|
81
|
-
const alias2 = quoteIdentifier(item.alias);
|
|
82
|
-
return `${operation} AS ${alias2}`;
|
|
83
|
-
}
|
|
84
|
-
if (expr.kind === "literal") {
|
|
85
|
-
const literal = renderLiteral(expr);
|
|
86
|
-
const alias2 = quoteIdentifier(item.alias);
|
|
87
|
-
return `${literal} AS ${alias2}`;
|
|
88
|
-
}
|
|
89
|
-
const column = renderColumn(expr);
|
|
90
|
-
const alias = quoteIdentifier(item.alias);
|
|
91
|
-
return `${column} AS ${alias}`;
|
|
92
|
-
}).join(", ");
|
|
93
|
-
}
|
|
94
|
-
function renderWhere(expr, contract) {
|
|
95
|
-
if (expr.kind === "exists") {
|
|
96
|
-
const notKeyword = expr.not ? "NOT " : "";
|
|
97
|
-
const subquery = renderSelect(expr.subquery, contract);
|
|
98
|
-
return `${notKeyword}EXISTS (${subquery})`;
|
|
99
|
-
}
|
|
100
|
-
return renderBinary(expr, contract);
|
|
101
|
-
}
|
|
102
|
-
function renderBinary(expr, contract) {
|
|
103
|
-
const leftExpr = expr.left;
|
|
104
|
-
const left = renderExpr(leftExpr, contract);
|
|
105
|
-
const rightExpr = expr.right;
|
|
106
|
-
const right = rightExpr.kind === "col" ? renderColumn(rightExpr) : renderParam(rightExpr, contract);
|
|
107
|
-
const leftRendered = isOperationExpr(leftExpr) ? `(${left})` : left;
|
|
108
|
-
const operatorMap = {
|
|
109
|
-
eq: "=",
|
|
110
|
-
neq: "!=",
|
|
111
|
-
gt: ">",
|
|
112
|
-
lt: "<",
|
|
113
|
-
gte: ">=",
|
|
114
|
-
lte: "<="
|
|
115
|
-
};
|
|
116
|
-
return `${leftRendered} ${operatorMap[expr.op]} ${right}`;
|
|
117
|
-
}
|
|
118
|
-
function renderColumn(ref) {
|
|
119
|
-
return `${quoteIdentifier(ref.table)}.${quoteIdentifier(ref.column)}`;
|
|
120
|
-
}
|
|
121
|
-
function renderExpr(expr, contract) {
|
|
122
|
-
if (isOperationExpr(expr)) {
|
|
123
|
-
return renderOperation(expr, contract);
|
|
124
|
-
}
|
|
125
|
-
return renderColumn(expr);
|
|
126
|
-
}
|
|
127
|
-
function renderParam(ref, contract, tableName, columnName) {
|
|
128
|
-
if (contract && tableName && columnName) {
|
|
129
|
-
const tableMeta = contract.storage.tables[tableName];
|
|
130
|
-
const columnMeta = tableMeta?.columns[columnName];
|
|
131
|
-
if (columnMeta?.codecId === VECTOR_CODEC_ID) {
|
|
132
|
-
return `$${ref.index}::vector`;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return `$${ref.index}`;
|
|
136
|
-
}
|
|
137
|
-
function renderLiteral(expr) {
|
|
138
|
-
if (typeof expr.value === "string") {
|
|
139
|
-
return `'${expr.value.replace(/'/g, "''")}'`;
|
|
140
|
-
}
|
|
141
|
-
if (typeof expr.value === "number" || typeof expr.value === "boolean") {
|
|
142
|
-
return String(expr.value);
|
|
143
|
-
}
|
|
144
|
-
if (expr.value === null) {
|
|
145
|
-
return "NULL";
|
|
146
|
-
}
|
|
147
|
-
if (Array.isArray(expr.value)) {
|
|
148
|
-
return `ARRAY[${expr.value.map((v) => renderLiteral({ kind: "literal", value: v })).join(", ")}]`;
|
|
149
|
-
}
|
|
150
|
-
return JSON.stringify(expr.value);
|
|
151
|
-
}
|
|
152
|
-
function renderOperation(expr, contract) {
|
|
153
|
-
const self = renderExpr(expr.self, contract);
|
|
154
|
-
const isVectorOperation = expr.forTypeId === VECTOR_CODEC_ID;
|
|
155
|
-
const args = expr.args.map((arg) => {
|
|
156
|
-
if (arg.kind === "col") {
|
|
157
|
-
return renderColumn(arg);
|
|
158
|
-
}
|
|
159
|
-
if (arg.kind === "param") {
|
|
160
|
-
return isVectorOperation ? `$${arg.index}::vector` : renderParam(arg, contract);
|
|
161
|
-
}
|
|
162
|
-
if (arg.kind === "literal") {
|
|
163
|
-
return renderLiteral(arg);
|
|
164
|
-
}
|
|
165
|
-
if (arg.kind === "operation") {
|
|
166
|
-
return renderOperation(arg, contract);
|
|
167
|
-
}
|
|
168
|
-
const _exhaustive = arg;
|
|
169
|
-
throw new Error(`Unsupported argument kind: ${_exhaustive.kind}`);
|
|
170
|
-
});
|
|
171
|
-
let result = expr.lowering.template;
|
|
172
|
-
result = result.replace(/\$\{self\}/g, self);
|
|
173
|
-
for (let i = 0; i < args.length; i++) {
|
|
174
|
-
result = result.replace(new RegExp(`\\$\\{arg${i}\\}`, "g"), args[i] ?? "");
|
|
175
|
-
}
|
|
176
|
-
if (expr.lowering.strategy === "function") {
|
|
177
|
-
return result;
|
|
178
|
-
}
|
|
179
|
-
return result;
|
|
180
|
-
}
|
|
181
|
-
function renderJoin(join, _contract) {
|
|
182
|
-
const joinType = join.joinType.toUpperCase();
|
|
183
|
-
const table = quoteIdentifier(join.table.name);
|
|
184
|
-
const onClause = renderJoinOn(join.on);
|
|
185
|
-
return `${joinType} JOIN ${table} ON ${onClause}`;
|
|
186
|
-
}
|
|
187
|
-
function renderJoinOn(on) {
|
|
188
|
-
if (on.kind === "eqCol") {
|
|
189
|
-
const left = renderColumn(on.left);
|
|
190
|
-
const right = renderColumn(on.right);
|
|
191
|
-
return `${left} = ${right}`;
|
|
192
|
-
}
|
|
193
|
-
throw new Error(`Unsupported join ON expression kind: ${on.kind}`);
|
|
194
|
-
}
|
|
195
|
-
function renderInclude(include, contract) {
|
|
196
|
-
const alias = include.alias;
|
|
197
|
-
const childProjection = include.child.project.map((item) => {
|
|
198
|
-
const expr = renderExpr(item.expr, contract);
|
|
199
|
-
return `'${item.alias}', ${expr}`;
|
|
200
|
-
}).join(", ");
|
|
201
|
-
const jsonBuildObject = `json_build_object(${childProjection})`;
|
|
202
|
-
const onCondition = renderJoinOn(include.child.on);
|
|
203
|
-
let whereClause = ` WHERE ${onCondition}`;
|
|
204
|
-
if (include.child.where) {
|
|
205
|
-
whereClause += ` AND ${renderWhere(include.child.where, contract)}`;
|
|
206
|
-
}
|
|
207
|
-
const childOrderBy = include.child.orderBy?.length ? ` ORDER BY ${include.child.orderBy.map(
|
|
208
|
-
(order) => `${renderExpr(order.expr, contract)} ${order.dir.toUpperCase()}`
|
|
209
|
-
).join(", ")}` : "";
|
|
210
|
-
const childLimit = typeof include.child.limit === "number" ? ` LIMIT ${include.child.limit}` : "";
|
|
211
|
-
const childTable = quoteIdentifier(include.child.table.name);
|
|
212
|
-
let subquery;
|
|
213
|
-
if (typeof include.child.limit === "number") {
|
|
214
|
-
const columnAliasMap = /* @__PURE__ */ new Map();
|
|
215
|
-
for (const item of include.child.project) {
|
|
216
|
-
if (item.expr.kind === "col") {
|
|
217
|
-
const columnKey = `${item.expr.table}.${item.expr.column}`;
|
|
218
|
-
columnAliasMap.set(columnKey, item.alias);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const innerColumns = include.child.project.map((item) => {
|
|
222
|
-
const expr = renderExpr(item.expr, contract);
|
|
223
|
-
return `${expr} AS ${quoteIdentifier(item.alias)}`;
|
|
224
|
-
}).join(", ");
|
|
225
|
-
const childOrderByWithAliases = include.child.orderBy?.length ? ` ORDER BY ${include.child.orderBy.map((order) => {
|
|
226
|
-
if (order.expr.kind === "col") {
|
|
227
|
-
const columnKey = `${order.expr.table}.${order.expr.column}`;
|
|
228
|
-
const alias2 = columnAliasMap.get(columnKey);
|
|
229
|
-
if (alias2) {
|
|
230
|
-
return `${quoteIdentifier(alias2)} ${order.dir.toUpperCase()}`;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return `${renderExpr(order.expr, contract)} ${order.dir.toUpperCase()}`;
|
|
234
|
-
}).join(", ")}` : "";
|
|
235
|
-
const innerSelect = `SELECT ${innerColumns} FROM ${childTable}${whereClause}${childOrderByWithAliases}${childLimit}`;
|
|
236
|
-
subquery = `(SELECT json_agg(row_to_json(sub.*)) AS ${quoteIdentifier(alias)} FROM (${innerSelect}) sub)`;
|
|
237
|
-
} else if (childOrderBy) {
|
|
238
|
-
subquery = `(SELECT json_agg(${jsonBuildObject}${childOrderBy}) AS ${quoteIdentifier(alias)} FROM ${childTable}${whereClause})`;
|
|
239
|
-
} else {
|
|
240
|
-
subquery = `(SELECT json_agg(${jsonBuildObject}) AS ${quoteIdentifier(alias)} FROM ${childTable}${whereClause})`;
|
|
241
|
-
}
|
|
242
|
-
const tableAlias = `${alias}_lateral`;
|
|
243
|
-
return `LEFT JOIN LATERAL ${subquery} AS ${quoteIdentifier(tableAlias)} ON true`;
|
|
244
|
-
}
|
|
245
|
-
function quoteIdentifier(identifier) {
|
|
246
|
-
return `"${identifier.replace(/"/g, '""')}"`;
|
|
247
|
-
}
|
|
248
|
-
function renderInsert(ast, contract) {
|
|
249
|
-
const table = quoteIdentifier(ast.table.name);
|
|
250
|
-
const columns = Object.keys(ast.values).map((col) => quoteIdentifier(col));
|
|
251
|
-
const tableMeta = contract.storage.tables[ast.table.name];
|
|
252
|
-
const values = Object.entries(ast.values).map(([colName, val]) => {
|
|
253
|
-
if (val.kind === "param") {
|
|
254
|
-
const columnMeta = tableMeta?.columns[colName];
|
|
255
|
-
const isVector = columnMeta?.codecId === VECTOR_CODEC_ID;
|
|
256
|
-
return isVector ? `$${val.index}::vector` : `$${val.index}`;
|
|
257
|
-
}
|
|
258
|
-
if (val.kind === "col") {
|
|
259
|
-
return `${quoteIdentifier(val.table)}.${quoteIdentifier(val.column)}`;
|
|
260
|
-
}
|
|
261
|
-
throw new Error(`Unsupported value kind in INSERT: ${val.kind}`);
|
|
262
|
-
});
|
|
263
|
-
const insertClause = `INSERT INTO ${table} (${columns.join(", ")}) VALUES (${values.join(", ")})`;
|
|
264
|
-
const returningClause = ast.returning?.length ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(", ")}` : "";
|
|
265
|
-
return `${insertClause}${returningClause}`;
|
|
266
|
-
}
|
|
267
|
-
function renderUpdate(ast, contract) {
|
|
268
|
-
const table = quoteIdentifier(ast.table.name);
|
|
269
|
-
const tableMeta = contract.storage.tables[ast.table.name];
|
|
270
|
-
const setClauses = Object.entries(ast.set).map(([col, val]) => {
|
|
271
|
-
const column = quoteIdentifier(col);
|
|
272
|
-
let value;
|
|
273
|
-
if (val.kind === "param") {
|
|
274
|
-
const columnMeta = tableMeta?.columns[col];
|
|
275
|
-
const isVector = columnMeta?.codecId === VECTOR_CODEC_ID;
|
|
276
|
-
value = isVector ? `$${val.index}::vector` : `$${val.index}`;
|
|
277
|
-
} else if (val.kind === "col") {
|
|
278
|
-
value = `${quoteIdentifier(val.table)}.${quoteIdentifier(val.column)}`;
|
|
279
|
-
} else {
|
|
280
|
-
throw new Error(`Unsupported value kind in UPDATE: ${val.kind}`);
|
|
281
|
-
}
|
|
282
|
-
return `${column} = ${value}`;
|
|
283
|
-
});
|
|
284
|
-
const whereClause = ` WHERE ${renderBinary(ast.where, contract)}`;
|
|
285
|
-
const returningClause = ast.returning?.length ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(", ")}` : "";
|
|
286
|
-
return `UPDATE ${table} SET ${setClauses.join(", ")}${whereClause}${returningClause}`;
|
|
287
|
-
}
|
|
288
|
-
function renderDelete(ast, contract) {
|
|
289
|
-
const table = quoteIdentifier(ast.table.name);
|
|
290
|
-
const whereClause = ` WHERE ${renderBinary(ast.where, contract)}`;
|
|
291
|
-
const returningClause = ast.returning?.length ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(", ")}` : "";
|
|
292
|
-
return `DELETE FROM ${table}${whereClause}${returningClause}`;
|
|
293
|
-
}
|
|
294
|
-
function createPostgresAdapter(options) {
|
|
295
|
-
return Object.freeze(new PostgresAdapterImpl(options));
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
export {
|
|
299
|
-
createPostgresAdapter
|
|
300
|
-
};
|
|
301
|
-
//# sourceMappingURL=chunk-T6S3A6VT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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":";;;;;AAkBA,SAAS,qBAAqB,uBAAuB;AAIrD,IAAM,kBAAkB;AAExB,IAAM,sBAAsB,OAAO,OAAO;AAAA,EACxC,UAAU;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AACF,CAAC;AAED,IAAM,sBAAN,MAAmG;AAAA;AAAA;AAAA,EAGxF,WAAW;AAAA,EACX,WAAW;AAAA,EAEX;AAAA,EACQ,iBAAiB,MAAM;AACtC,UAAM,WAAW,oBAAoB;AACrC,eAAW,cAAc,OAAO,OAAO,gBAAgB,GAAG;AACxD,eAAS,SAAS,WAAW,KAAK;AAAA,IACpC;AACA,WAAO;AAAA,EACT,GAAG;AAAA,EAEH,YAAY,SAAkC;AAC5C,SAAK,UAAU,OAAO,OAAO;AAAA,MAC3B,IAAI,SAAS,aAAa;AAAA,MAC1B,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,QAAQ,MAAM,KAAK;AAAA,IACrB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,KAAe,SAA2C;AAC9D,QAAI;AACJ,UAAM,SAAS,QAAQ,SAAS,CAAC,GAAG,QAAQ,MAAM,IAAI,CAAC;AAEvD,QAAI,IAAI,SAAS,UAAU;AACzB,YAAM,aAAa,KAAK,QAAQ,QAAQ;AAAA,IAC1C,WAAW,IAAI,SAAS,UAAU;AAChC,YAAM,aAAa,KAAK,QAAQ,QAAQ;AAAA,IAC1C,WAAW,IAAI,SAAS,UAAU;AAChC,YAAM,aAAa,KAAK,QAAQ,QAAQ;AAAA,IAC1C,WAAW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IAAI,IAAI,KAAK,aAAa,IAAI,IAAI,KAAK;AAAA,IAC5D,WAAW,IAAI,SAAS,OAAO;AAC7B,cAAQ,GAAG,gBAAgB,IAAI,KAAK,CAAC,IAAI,gBAAgB,IAAI,MAAM,CAAC;AAAA,IACtE,OAAO;AACL,YAAM,IAAI,MAAM,qCAAsC,IAAyB,IAAI,EAAE;AAAA,IACvF;AACA,WAAO,GAAG,MAAM,MAAM,KAAK;AAAA,EAC7B,CAAC;AAED,QAAM,cAAc,UAAU,aAAa,IAAI,OAAO,QAAQ,CAAC;AAC/D,QAAM,kBAAkB,IAAI,WAAW,SACnC,cAAc,IAAI,UAAU,IAAI,CAAC,QAAQ,GAAG,gBAAgB,IAAI,KAAK,CAAC,IAAI,gBAAgB,IAAI,MAAM,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,KACnH;AAEJ,SAAO,UAAU,KAAK,QAAQ,WAAW,KAAK,IAAI,CAAC,GAAG,WAAW,GAAG,eAAe;AACrF;AAEA,SAAS,aAAa,KAAgB,UAAqC;AACzE,QAAM,QAAQ,gBAAgB,IAAI,MAAM,IAAI;AAC5C,QAAM,cAAc,UAAU,aAAa,IAAI,OAAO,QAAQ,CAAC;AAC/D,QAAM,kBAAkB,IAAI,WAAW,SACnC,cAAc,IAAI,UAAU,IAAI,CAAC,QAAQ,GAAG,gBAAgB,IAAI,KAAK,CAAC,IAAI,gBAAgB,IAAI,MAAM,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,KACnH;AAEJ,SAAO,eAAe,KAAK,GAAG,WAAW,GAAG,eAAe;AAC7D;AAEO,SAAS,sBAAsB,SAAkC;AACtE,SAAO,OAAO,OAAO,IAAI,oBAAoB,OAAO,CAAC;AACvD;","names":["alias"]}
|
package/dist/core/adapter.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Adapter, AdapterProfile, LowererContext, QueryAst } from '@prisma-next/sql-relational-core/ast';
|
|
2
|
-
import type { PostgresAdapterOptions, PostgresContract, PostgresLoweredStatement } from './types';
|
|
3
|
-
declare class PostgresAdapterImpl implements Adapter<QueryAst, PostgresContract, PostgresLoweredStatement> {
|
|
4
|
-
readonly familyId: "sql";
|
|
5
|
-
readonly targetId: "postgres";
|
|
6
|
-
readonly profile: AdapterProfile<'postgres'>;
|
|
7
|
-
private readonly codecRegistry;
|
|
8
|
-
constructor(options?: PostgresAdapterOptions);
|
|
9
|
-
lower(ast: QueryAst, context: LowererContext<PostgresContract>): Readonly<{
|
|
10
|
-
profileId: string;
|
|
11
|
-
body: Readonly<{
|
|
12
|
-
sql: string;
|
|
13
|
-
params: unknown[];
|
|
14
|
-
}>;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
17
|
-
export declare function createPostgresAdapter(options?: PostgresAdapterOptions): Readonly<PostgresAdapterImpl>;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/core/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EASd,cAAc,EAGd,QAAQ,EAGT,MAAM,sCAAsC,CAAC;AAG9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAclG,cAAM,mBAAoB,YAAW,OAAO,CAAC,QAAQ,EAAE,gBAAgB,EAAE,wBAAwB,CAAC;IAGhG,QAAQ,CAAC,QAAQ,EAAG,KAAK,CAAU;IACnC,QAAQ,CAAC,QAAQ,EAAG,UAAU,CAAU;IAExC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAMzB;gBAEO,OAAO,CAAC,EAAE,sBAAsB;IAS5C,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,CAAC,gBAAgB,CAAC;;;;;;;CAqB/D;AA2VD,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,sBAAsB,iCAErE"}
|
package/dist/core/codecs.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unified codec definitions for Postgres adapter.
|
|
3
|
-
*
|
|
4
|
-
* This file contains a single source of truth for all codec information:
|
|
5
|
-
* - Scalar names
|
|
6
|
-
* - Type IDs
|
|
7
|
-
* - Codec implementations (runtime)
|
|
8
|
-
* - Type information (compile-time)
|
|
9
|
-
*
|
|
10
|
-
* This structure is used both at runtime (to populate the registry) and
|
|
11
|
-
* at compile time (to derive CodecTypes).
|
|
12
|
-
*/
|
|
13
|
-
declare const codecs: import("@prisma-next/sql-relational-core/ast").CodecDefBuilder<{
|
|
14
|
-
text: import("@prisma-next/sql-relational-core/ast").Codec<"pg/text@1", string, string>;
|
|
15
|
-
int4: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int4@1", number, number>;
|
|
16
|
-
int2: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int2@1", number, number>;
|
|
17
|
-
int8: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int8@1", number, number>;
|
|
18
|
-
float4: import("@prisma-next/sql-relational-core/ast").Codec<"pg/float4@1", number, number>;
|
|
19
|
-
float8: import("@prisma-next/sql-relational-core/ast").Codec<"pg/float8@1", number, number>;
|
|
20
|
-
timestamp: import("@prisma-next/sql-relational-core/ast").Codec<"pg/timestamp@1", string | Date, string>;
|
|
21
|
-
timestamptz: import("@prisma-next/sql-relational-core/ast").Codec<"pg/timestamptz@1", string | Date, string>;
|
|
22
|
-
} & Record<"bool", import("@prisma-next/sql-relational-core/ast").Codec<"pg/bool@1", boolean, boolean>>>;
|
|
23
|
-
export declare const codecDefinitions: {
|
|
24
|
-
readonly text: {
|
|
25
|
-
readonly typeId: "pg/text@1";
|
|
26
|
-
readonly scalar: "text";
|
|
27
|
-
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/text@1", string, string>;
|
|
28
|
-
readonly input: string;
|
|
29
|
-
readonly output: string;
|
|
30
|
-
readonly jsType: string;
|
|
31
|
-
};
|
|
32
|
-
readonly int4: {
|
|
33
|
-
readonly typeId: "pg/int4@1";
|
|
34
|
-
readonly scalar: "int4";
|
|
35
|
-
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int4@1", number, number>;
|
|
36
|
-
readonly input: number;
|
|
37
|
-
readonly output: number;
|
|
38
|
-
readonly jsType: number;
|
|
39
|
-
};
|
|
40
|
-
readonly int2: {
|
|
41
|
-
readonly typeId: "pg/int2@1";
|
|
42
|
-
readonly scalar: "int2";
|
|
43
|
-
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int2@1", number, number>;
|
|
44
|
-
readonly input: number;
|
|
45
|
-
readonly output: number;
|
|
46
|
-
readonly jsType: number;
|
|
47
|
-
};
|
|
48
|
-
readonly int8: {
|
|
49
|
-
readonly typeId: "pg/int8@1";
|
|
50
|
-
readonly scalar: "int8";
|
|
51
|
-
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int8@1", number, number>;
|
|
52
|
-
readonly input: number;
|
|
53
|
-
readonly output: number;
|
|
54
|
-
readonly jsType: number;
|
|
55
|
-
};
|
|
56
|
-
readonly float4: {
|
|
57
|
-
readonly typeId: "pg/float4@1";
|
|
58
|
-
readonly scalar: "float4";
|
|
59
|
-
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/float4@1", number, number>;
|
|
60
|
-
readonly input: number;
|
|
61
|
-
readonly output: number;
|
|
62
|
-
readonly jsType: number;
|
|
63
|
-
};
|
|
64
|
-
readonly float8: {
|
|
65
|
-
readonly typeId: "pg/float8@1";
|
|
66
|
-
readonly scalar: "float8";
|
|
67
|
-
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/float8@1", number, number>;
|
|
68
|
-
readonly input: number;
|
|
69
|
-
readonly output: number;
|
|
70
|
-
readonly jsType: number;
|
|
71
|
-
};
|
|
72
|
-
readonly timestamp: {
|
|
73
|
-
readonly typeId: "pg/timestamp@1";
|
|
74
|
-
readonly scalar: "timestamp";
|
|
75
|
-
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/timestamp@1", string | Date, string>;
|
|
76
|
-
readonly input: string;
|
|
77
|
-
readonly output: string;
|
|
78
|
-
readonly jsType: string;
|
|
79
|
-
};
|
|
80
|
-
readonly timestamptz: {
|
|
81
|
-
readonly typeId: "pg/timestamptz@1";
|
|
82
|
-
readonly scalar: "timestamptz";
|
|
83
|
-
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/timestamptz@1", string | Date, string>;
|
|
84
|
-
readonly input: string;
|
|
85
|
-
readonly output: string;
|
|
86
|
-
readonly jsType: string;
|
|
87
|
-
};
|
|
88
|
-
readonly bool: {
|
|
89
|
-
readonly typeId: "pg/bool@1";
|
|
90
|
-
readonly scalar: "bool";
|
|
91
|
-
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/bool@1", boolean, boolean>;
|
|
92
|
-
readonly input: boolean;
|
|
93
|
-
readonly output: boolean;
|
|
94
|
-
readonly jsType: boolean;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
export declare const dataTypes: {
|
|
98
|
-
readonly text: "pg/text@1";
|
|
99
|
-
readonly int4: "pg/int4@1";
|
|
100
|
-
readonly int2: "pg/int2@1";
|
|
101
|
-
readonly int8: "pg/int8@1";
|
|
102
|
-
readonly float4: "pg/float4@1";
|
|
103
|
-
readonly float8: "pg/float8@1";
|
|
104
|
-
readonly timestamp: "pg/timestamp@1";
|
|
105
|
-
readonly timestamptz: "pg/timestamptz@1";
|
|
106
|
-
readonly bool: "pg/bool@1";
|
|
107
|
-
};
|
|
108
|
-
export type CodecTypes = typeof codecs.CodecTypes;
|
|
109
|
-
export {};
|
|
110
|
-
//# sourceMappingURL=codecs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../src/core/codecs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAsKH,QAAA,MAAM,MAAM;;;;;;;;;wGASe,CAAC;AAG5B,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA0B,CAAC;AACxD,eAAO,MAAM,SAAS;;;;;;;;;;CAAmB,CAAC;AAG1C,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,UAAU,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { ControlDriverInstance } from '@prisma-next/core-control-plane/types';
|
|
2
|
-
import type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';
|
|
3
|
-
import type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';
|
|
4
|
-
/**
|
|
5
|
-
* Postgres control plane adapter for control-plane operations like introspection.
|
|
6
|
-
* Provides target-specific implementations for control-plane domain actions.
|
|
7
|
-
*/
|
|
8
|
-
export declare class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
|
|
9
|
-
readonly familyId: "sql";
|
|
10
|
-
readonly targetId: "postgres";
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use targetId instead
|
|
13
|
-
*/
|
|
14
|
-
readonly target: "postgres";
|
|
15
|
-
/**
|
|
16
|
-
* Introspects a Postgres database schema and returns a raw SqlSchemaIR.
|
|
17
|
-
*
|
|
18
|
-
* This is a pure schema discovery operation that queries the Postgres catalog
|
|
19
|
-
* and returns the schema structure without type mapping or contract enrichment.
|
|
20
|
-
* Type mapping and enrichment are handled separately by enrichment helpers.
|
|
21
|
-
*
|
|
22
|
-
* @param driver - ControlDriverInstance<'sql', 'postgres'> instance for executing queries
|
|
23
|
-
* @param contractIR - Optional contract IR for contract-guided introspection (filtering, optimization)
|
|
24
|
-
* @param schema - Schema name to introspect (defaults to 'public')
|
|
25
|
-
* @returns Promise resolving to SqlSchemaIR representing the live database schema
|
|
26
|
-
*/
|
|
27
|
-
introspect(driver: ControlDriverInstance<'sql', 'postgres'>, _contractIR?: unknown, schema?: string): Promise<SqlSchemaIR>;
|
|
28
|
-
/**
|
|
29
|
-
* Gets the Postgres version from the database.
|
|
30
|
-
*/
|
|
31
|
-
private getPostgresVersion;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=control-adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"control-adapter.d.ts","sourceRoot":"","sources":["../../src/core/control-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,KAAK,EAKV,WAAW,EAGZ,MAAM,kCAAkC,CAAC;AAE1C;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,iBAAiB,CAAC,UAAU,CAAC;IAC1E,QAAQ,CAAC,QAAQ,EAAG,KAAK,CAAU;IACnC,QAAQ,CAAC,QAAQ,EAAG,UAAU,CAAU;IACxC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAG,UAAU,CAAU;IAEtC;;;;;;;;;;;OAWG;IACG,UAAU,CACd,MAAM,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,EAChD,WAAW,CAAC,EAAE,OAAO,EACrB,MAAM,SAAW,GAChB,OAAO,CAAC,WAAW,CAAC;IAkUvB;;OAEG;YACW,kBAAkB;CASjC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export declare const postgresAdapterDescriptorMeta: {
|
|
2
|
-
readonly kind: "adapter";
|
|
3
|
-
readonly familyId: "sql";
|
|
4
|
-
readonly targetId: "postgres";
|
|
5
|
-
readonly id: "postgres";
|
|
6
|
-
readonly version: "0.0.1";
|
|
7
|
-
readonly capabilities: {
|
|
8
|
-
readonly postgres: {
|
|
9
|
-
readonly orderBy: true;
|
|
10
|
-
readonly limit: true;
|
|
11
|
-
readonly lateral: true;
|
|
12
|
-
readonly jsonAgg: true;
|
|
13
|
-
readonly returning: true;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
readonly types: {
|
|
17
|
-
readonly codecTypes: {
|
|
18
|
-
readonly import: {
|
|
19
|
-
readonly package: "@prisma-next/adapter-postgres/codec-types";
|
|
20
|
-
readonly named: "CodecTypes";
|
|
21
|
-
readonly alias: "PgTypes";
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
readonly storage: readonly [{
|
|
25
|
-
readonly typeId: "pg/text@1";
|
|
26
|
-
readonly familyId: "sql";
|
|
27
|
-
readonly targetId: "postgres";
|
|
28
|
-
readonly nativeType: "text";
|
|
29
|
-
}, {
|
|
30
|
-
readonly typeId: "pg/int4@1";
|
|
31
|
-
readonly familyId: "sql";
|
|
32
|
-
readonly targetId: "postgres";
|
|
33
|
-
readonly nativeType: "int4";
|
|
34
|
-
}, {
|
|
35
|
-
readonly typeId: "pg/int2@1";
|
|
36
|
-
readonly familyId: "sql";
|
|
37
|
-
readonly targetId: "postgres";
|
|
38
|
-
readonly nativeType: "int2";
|
|
39
|
-
}, {
|
|
40
|
-
readonly typeId: "pg/int8@1";
|
|
41
|
-
readonly familyId: "sql";
|
|
42
|
-
readonly targetId: "postgres";
|
|
43
|
-
readonly nativeType: "int8";
|
|
44
|
-
}, {
|
|
45
|
-
readonly typeId: "pg/float4@1";
|
|
46
|
-
readonly familyId: "sql";
|
|
47
|
-
readonly targetId: "postgres";
|
|
48
|
-
readonly nativeType: "float4";
|
|
49
|
-
}, {
|
|
50
|
-
readonly typeId: "pg/float8@1";
|
|
51
|
-
readonly familyId: "sql";
|
|
52
|
-
readonly targetId: "postgres";
|
|
53
|
-
readonly nativeType: "float8";
|
|
54
|
-
}, {
|
|
55
|
-
readonly typeId: "pg/timestamp@1";
|
|
56
|
-
readonly familyId: "sql";
|
|
57
|
-
readonly targetId: "postgres";
|
|
58
|
-
readonly nativeType: "timestamp";
|
|
59
|
-
}, {
|
|
60
|
-
readonly typeId: "pg/timestamptz@1";
|
|
61
|
-
readonly familyId: "sql";
|
|
62
|
-
readonly targetId: "postgres";
|
|
63
|
-
readonly nativeType: "timestamptz";
|
|
64
|
-
}, {
|
|
65
|
-
readonly typeId: "pg/bool@1";
|
|
66
|
-
readonly familyId: "sql";
|
|
67
|
-
readonly targetId: "postgres";
|
|
68
|
-
readonly nativeType: "bool";
|
|
69
|
-
}];
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=descriptor-meta.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta.d.ts","sourceRoot":"","sources":["../../src/core/descriptor-meta.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwChC,CAAC"}
|
package/dist/core/types.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { SqlContract, SqlStorage, StorageColumn, StorageTable } from '@prisma-next/sql-contract/types';
|
|
2
|
-
import type { BinaryExpr, ColumnRef, DeleteAst, Direction, InsertAst, JoinAst, LiteralExpr, LoweredStatement, OperationExpr, ParamRef, QueryAst, SelectAst, UpdateAst } from '@prisma-next/sql-relational-core/ast';
|
|
3
|
-
export interface PostgresAdapterOptions {
|
|
4
|
-
readonly profileId?: string;
|
|
5
|
-
}
|
|
6
|
-
export type PostgresContract = SqlContract<SqlStorage> & {
|
|
7
|
-
readonly target: 'postgres';
|
|
8
|
-
};
|
|
9
|
-
export type Expr = ColumnRef | ParamRef;
|
|
10
|
-
export interface OrderClause {
|
|
11
|
-
readonly expr: ColumnRef;
|
|
12
|
-
readonly dir: Direction;
|
|
13
|
-
}
|
|
14
|
-
export type PostgresLoweredStatement = LoweredStatement;
|
|
15
|
-
export type { BinaryExpr, ColumnRef, DeleteAst, Direction, InsertAst, JoinAst, LiteralExpr, OperationExpr, ParamRef, QueryAst, SelectAst, StorageColumn, StorageTable, UpdateAst, };
|
|
16
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/core/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACV,MAAM,sCAAsC,CAAC;AAE9C,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAEzF,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC;AAExC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAExD,YAAY,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,WAAW,EACX,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,aAAa,EACb,YAAY,EACZ,SAAS,GACV,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/exports/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/exports/adapter.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|