@prisma-next/compat-prisma 0.0.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/README.md +97 -0
- package/dist/exports/index.d.ts +115 -0
- package/dist/exports/index.js +315 -0
- package/dist/exports/index.js.map +1 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# @prisma-next/compat-prisma
|
|
2
|
+
|
|
3
|
+
Compatibility layer for migrating from Prisma ORM to Prisma Next.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The compatibility package provides a compatibility layer that allows existing Prisma ORM code to work with Prisma Next. It provides a subset of Prisma Client API surface that maps to Prisma Next's query builder and runtime.
|
|
8
|
+
|
|
9
|
+
This package is a transition tool for teams migrating from Prisma ORM to Prisma Next. It provides a familiar API surface while using Prisma Next's execution engine under the hood.
|
|
10
|
+
|
|
11
|
+
## Purpose
|
|
12
|
+
|
|
13
|
+
Provide a compatibility layer for Prisma ORM code to work with Prisma Next. Enable gradual migration from Prisma ORM to Prisma Next.
|
|
14
|
+
|
|
15
|
+
## Responsibilities
|
|
16
|
+
|
|
17
|
+
- **Prisma Client API**: Provide subset of Prisma Client API surface
|
|
18
|
+
- **Query Translation**: Translate Prisma Client queries to Prisma Next Plans
|
|
19
|
+
- **Result Mapping**: Map Prisma Next results to Prisma Client result shapes
|
|
20
|
+
|
|
21
|
+
**Non-goals:**
|
|
22
|
+
- Full Prisma Client API compatibility
|
|
23
|
+
- Migration tooling
|
|
24
|
+
- Schema generation
|
|
25
|
+
|
|
26
|
+
## Architecture
|
|
27
|
+
|
|
28
|
+
```mermaid
|
|
29
|
+
flowchart TD
|
|
30
|
+
subgraph "Prisma Client API"
|
|
31
|
+
CLIENT[Prisma Client]
|
|
32
|
+
MODEL[Model Methods]
|
|
33
|
+
QUERY[Query Methods]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
subgraph "Compat Layer"
|
|
37
|
+
COMPAT[Compat Layer]
|
|
38
|
+
TRANSLATE[Query Translator]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
subgraph "Prisma Next"
|
|
42
|
+
SQL[SQL Query]
|
|
43
|
+
RUNTIME[Runtime]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
CLIENT --> MODEL
|
|
47
|
+
CLIENT --> QUERY
|
|
48
|
+
MODEL --> COMPAT
|
|
49
|
+
QUERY --> COMPAT
|
|
50
|
+
COMPAT --> TRANSLATE
|
|
51
|
+
TRANSLATE --> SQL
|
|
52
|
+
SQL --> RUNTIME
|
|
53
|
+
RUNTIME --> COMPAT
|
|
54
|
+
COMPAT --> CLIENT
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Components
|
|
58
|
+
|
|
59
|
+
### Prisma Client (`prisma-client.ts`)
|
|
60
|
+
- Prisma Client compatibility implementation
|
|
61
|
+
- Provides familiar API surface
|
|
62
|
+
- Translates to Prisma Next Plans
|
|
63
|
+
|
|
64
|
+
## Dependencies
|
|
65
|
+
|
|
66
|
+
- **`@prisma-next/contract`**: Contract types
|
|
67
|
+
- **`@prisma-next/runtime`**: Runtime execution
|
|
68
|
+
- **`@prisma-next/sql-query`**: SQL query builder
|
|
69
|
+
- **`@prisma-next/adapter-postgres`**: PostgreSQL adapter
|
|
70
|
+
- **`@prisma-next/driver-postgres`**: PostgreSQL driver
|
|
71
|
+
|
|
72
|
+
## Related Subsystems
|
|
73
|
+
|
|
74
|
+
- **[Runtime & Plugin Framework](../../docs/architecture%20docs/subsystems/4.%20Runtime%20&%20Plugin%20Framework.md)**: Runtime execution
|
|
75
|
+
|
|
76
|
+
## Related ADRs
|
|
77
|
+
|
|
78
|
+
- [ADR 015 - ORM as Optional Extension](../../docs/architecture%20docs/adrs/ADR%20015%20-%20ORM%20as%20Optional%20Extension.md)
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { PrismaClient } from '@prisma-next/compat-prisma';
|
|
84
|
+
|
|
85
|
+
const prisma = new PrismaClient();
|
|
86
|
+
|
|
87
|
+
// Use familiar Prisma Client API
|
|
88
|
+
const users = await prisma.user.findMany({
|
|
89
|
+
where: { active: true },
|
|
90
|
+
select: { id: true, email: true },
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Exports
|
|
95
|
+
|
|
96
|
+
- `.`: Prisma Client compatibility implementation
|
|
97
|
+
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ContractBase } from '@prisma-next/contract/types';
|
|
2
|
+
import { schema } from '@prisma-next/sql-relational-core/schema';
|
|
3
|
+
import { Runtime, RuntimeContext } from '@prisma-next/sql-runtime';
|
|
4
|
+
|
|
5
|
+
type StorageColumn = {
|
|
6
|
+
readonly type: string;
|
|
7
|
+
readonly nullable: boolean;
|
|
8
|
+
};
|
|
9
|
+
type PrimaryKey = {
|
|
10
|
+
readonly columns: readonly string[];
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
};
|
|
13
|
+
type UniqueConstraint = {
|
|
14
|
+
readonly columns: readonly string[];
|
|
15
|
+
readonly name?: string;
|
|
16
|
+
};
|
|
17
|
+
type Index = {
|
|
18
|
+
readonly columns: readonly string[];
|
|
19
|
+
readonly name?: string;
|
|
20
|
+
};
|
|
21
|
+
type ForeignKeyReferences = {
|
|
22
|
+
readonly table: string;
|
|
23
|
+
readonly columns: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
type ForeignKey = {
|
|
26
|
+
readonly columns: readonly string[];
|
|
27
|
+
readonly references: ForeignKeyReferences;
|
|
28
|
+
readonly name?: string;
|
|
29
|
+
};
|
|
30
|
+
type StorageTable = {
|
|
31
|
+
readonly columns: Record<string, StorageColumn>;
|
|
32
|
+
readonly primaryKey?: PrimaryKey;
|
|
33
|
+
readonly uniques: ReadonlyArray<UniqueConstraint>;
|
|
34
|
+
readonly indexes: ReadonlyArray<Index>;
|
|
35
|
+
readonly foreignKeys: ReadonlyArray<ForeignKey>;
|
|
36
|
+
};
|
|
37
|
+
type SqlStorage = {
|
|
38
|
+
readonly tables: Record<string, StorageTable>;
|
|
39
|
+
};
|
|
40
|
+
type SqlMappings = {
|
|
41
|
+
readonly modelToTable?: Record<string, string>;
|
|
42
|
+
readonly tableToModel?: Record<string, string>;
|
|
43
|
+
readonly fieldToColumn?: Record<string, Record<string, string>>;
|
|
44
|
+
readonly columnToField?: Record<string, Record<string, string>>;
|
|
45
|
+
readonly codecTypes: Record<string, {
|
|
46
|
+
readonly output: unknown;
|
|
47
|
+
}>;
|
|
48
|
+
readonly operationTypes: Record<string, Record<string, unknown>>;
|
|
49
|
+
};
|
|
50
|
+
type SqlContract<S extends SqlStorage = SqlStorage, M extends Record<string, unknown> = Record<string, unknown>, R extends Record<string, unknown> = Record<string, unknown>, Map extends SqlMappings = SqlMappings> = ContractBase & {
|
|
51
|
+
readonly targetFamily: string;
|
|
52
|
+
readonly storage: S;
|
|
53
|
+
readonly models: M;
|
|
54
|
+
readonly relations: R;
|
|
55
|
+
readonly mappings: Map;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
interface PrismaClientOptions {
|
|
59
|
+
readonly contract: SqlContract<SqlStorage>;
|
|
60
|
+
readonly runtime?: Runtime;
|
|
61
|
+
readonly connectionString?: string;
|
|
62
|
+
}
|
|
63
|
+
interface FindUniqueArgs {
|
|
64
|
+
readonly where: Record<string, unknown>;
|
|
65
|
+
readonly select?: Record<string, boolean>;
|
|
66
|
+
}
|
|
67
|
+
interface FindManyArgs {
|
|
68
|
+
readonly where?: Record<string, unknown>;
|
|
69
|
+
readonly select?: Record<string, boolean>;
|
|
70
|
+
readonly orderBy?: Record<string, 'asc' | 'desc'>;
|
|
71
|
+
readonly take?: number;
|
|
72
|
+
readonly skip?: number;
|
|
73
|
+
}
|
|
74
|
+
type FindFirstArgs = FindManyArgs;
|
|
75
|
+
type TableFromSchema<Contract extends SqlContract<SqlStorage>> = ReturnType<typeof schema<Contract>>['tables'][string];
|
|
76
|
+
declare class ModelDelegate {
|
|
77
|
+
private readonly runtime;
|
|
78
|
+
private readonly context;
|
|
79
|
+
private readonly contract;
|
|
80
|
+
private readonly table;
|
|
81
|
+
private readonly tableName;
|
|
82
|
+
private readonly tableRef;
|
|
83
|
+
constructor(runtime: Runtime, context: RuntimeContext<SqlContract<SqlStorage>>, contract: SqlContract<SqlStorage>, table: TableFromSchema<SqlContract<SqlStorage>>, tableName: string);
|
|
84
|
+
findUnique(args: FindUniqueArgs): Promise<Record<string, unknown> | null>;
|
|
85
|
+
findFirst(args?: FindFirstArgs): Promise<Record<string, unknown> | null>;
|
|
86
|
+
findMany(args?: FindManyArgs): Promise<Record<string, unknown>[]>;
|
|
87
|
+
create(args: {
|
|
88
|
+
data: Record<string, unknown>;
|
|
89
|
+
}): Promise<Record<string, unknown>>;
|
|
90
|
+
update(_args: {
|
|
91
|
+
where: Record<string, unknown>;
|
|
92
|
+
data: Record<string, unknown>;
|
|
93
|
+
}): Promise<Record<string, unknown>>;
|
|
94
|
+
delete(_args: {
|
|
95
|
+
where: Record<string, unknown>;
|
|
96
|
+
}): Promise<Record<string, unknown>>;
|
|
97
|
+
private validateWhereArgs;
|
|
98
|
+
private unsupportedError;
|
|
99
|
+
}
|
|
100
|
+
declare class PrismaClientImpl {
|
|
101
|
+
readonly runtime: Runtime;
|
|
102
|
+
readonly context: RuntimeContext<SqlContract<SqlStorage>>;
|
|
103
|
+
readonly contract: SqlContract<SqlStorage>;
|
|
104
|
+
readonly schemaHandle: ReturnType<typeof schema>;
|
|
105
|
+
readonly models: Record<string, ModelDelegate>;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
constructor(options: PrismaClientOptions);
|
|
108
|
+
$disconnect(): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
declare class PrismaClient extends PrismaClientImpl {
|
|
111
|
+
readonly user: ModelDelegate;
|
|
112
|
+
constructor(options: PrismaClientOptions);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { PrismaClient };
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
// src/prisma-client.ts
|
|
2
|
+
import { createPostgresAdapter } from "@prisma-next/adapter-postgres/adapter";
|
|
3
|
+
import { createPostgresDriver } from "@prisma-next/driver-postgres/runtime";
|
|
4
|
+
import { sql } from "@prisma-next/sql-lane/sql";
|
|
5
|
+
import { param } from "@prisma-next/sql-relational-core/param";
|
|
6
|
+
import { schema } from "@prisma-next/sql-relational-core/schema";
|
|
7
|
+
import {
|
|
8
|
+
createRuntime,
|
|
9
|
+
createRuntimeContext
|
|
10
|
+
} from "@prisma-next/sql-runtime";
|
|
11
|
+
function isColumnBuilder(value) {
|
|
12
|
+
return value !== null && value !== void 0 && typeof value === "object" && "kind" in value && value.kind === "column";
|
|
13
|
+
}
|
|
14
|
+
var ModelDelegate = class {
|
|
15
|
+
constructor(runtime, context, contract, table, tableName) {
|
|
16
|
+
this.runtime = runtime;
|
|
17
|
+
this.context = context;
|
|
18
|
+
this.contract = contract;
|
|
19
|
+
this.table = table;
|
|
20
|
+
this.tableName = tableName;
|
|
21
|
+
this.tableRef = Object.freeze({
|
|
22
|
+
kind: "table",
|
|
23
|
+
name: tableName
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
tableName;
|
|
27
|
+
tableRef;
|
|
28
|
+
async findUnique(args) {
|
|
29
|
+
const result = await this.findMany({
|
|
30
|
+
...args,
|
|
31
|
+
take: 1
|
|
32
|
+
});
|
|
33
|
+
return result[0] ?? null;
|
|
34
|
+
}
|
|
35
|
+
async findFirst(args = {}) {
|
|
36
|
+
const result = await this.findMany({
|
|
37
|
+
...args,
|
|
38
|
+
take: 1
|
|
39
|
+
});
|
|
40
|
+
return result[0] ?? null;
|
|
41
|
+
}
|
|
42
|
+
async findMany(args = {}) {
|
|
43
|
+
const tableName = this.tableName;
|
|
44
|
+
let query = sql({ context: this.context }).from(this.tableRef);
|
|
45
|
+
if (args.where) {
|
|
46
|
+
this.validateWhereArgs(args.where);
|
|
47
|
+
const whereConditions = [];
|
|
48
|
+
for (const [field, value] of Object.entries(args.where)) {
|
|
49
|
+
const tableDef = this.contract.storage.tables[this.tableName];
|
|
50
|
+
if (!tableDef || !tableDef.columns[field]) {
|
|
51
|
+
throw this.unsupportedError(`Unknown field '${field}' in where clause`);
|
|
52
|
+
}
|
|
53
|
+
const columns = this.table.columns;
|
|
54
|
+
const column = columns[field];
|
|
55
|
+
if (!isColumnBuilder(column)) {
|
|
56
|
+
throw this.unsupportedError(`Invalid column '${field}' in where clause`);
|
|
57
|
+
}
|
|
58
|
+
whereConditions.push({ column, value });
|
|
59
|
+
}
|
|
60
|
+
if (whereConditions.length === 1) {
|
|
61
|
+
const condition = whereConditions[0];
|
|
62
|
+
if (!condition) {
|
|
63
|
+
throw this.unsupportedError("Invalid where condition");
|
|
64
|
+
}
|
|
65
|
+
const column = condition.column;
|
|
66
|
+
const paramPlaceholder = param(`${tableName}_${column.column}`);
|
|
67
|
+
const binaryExpr = column.eq(
|
|
68
|
+
paramPlaceholder
|
|
69
|
+
);
|
|
70
|
+
query = query.where(binaryExpr);
|
|
71
|
+
} else if (whereConditions.length > 1) {
|
|
72
|
+
throw this.unsupportedError("Multiple where conditions (AND/OR) not supported in MVP");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const projection = {};
|
|
76
|
+
if (args.select) {
|
|
77
|
+
for (const [field, include] of Object.entries(args.select)) {
|
|
78
|
+
if (include) {
|
|
79
|
+
const tableDef = this.contract.storage.tables[this.tableName];
|
|
80
|
+
if (!tableDef || !tableDef.columns[field]) {
|
|
81
|
+
throw this.unsupportedError(`Unknown field '${field}' in select clause`);
|
|
82
|
+
}
|
|
83
|
+
const columns = this.table.columns;
|
|
84
|
+
const column = columns[field];
|
|
85
|
+
if (!isColumnBuilder(column)) {
|
|
86
|
+
throw this.unsupportedError(`Invalid column '${field}' in select clause`);
|
|
87
|
+
}
|
|
88
|
+
projection[field] = column;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
const tableDef = this.contract.storage.tables[tableName];
|
|
93
|
+
const tableColumns = this.table.columns;
|
|
94
|
+
if (tableDef && tableColumns) {
|
|
95
|
+
for (const columnName of Object.keys(tableDef.columns)) {
|
|
96
|
+
const column = tableColumns[columnName];
|
|
97
|
+
if (isColumnBuilder(column)) {
|
|
98
|
+
projection[columnName] = column;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (Object.keys(projection).length === 0 && tableColumns) {
|
|
103
|
+
for (const key in tableColumns) {
|
|
104
|
+
const value = tableColumns[key];
|
|
105
|
+
if (isColumnBuilder(value)) {
|
|
106
|
+
projection[key] = value;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (Object.keys(projection).length === 0) {
|
|
111
|
+
throw this.unsupportedError("Select projection cannot be empty");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
query = query.select(projection);
|
|
115
|
+
if (args.orderBy) {
|
|
116
|
+
const orderByEntries = Object.entries(args.orderBy);
|
|
117
|
+
if (orderByEntries.length > 1) {
|
|
118
|
+
throw this.unsupportedError("Multiple orderBy fields not supported in MVP");
|
|
119
|
+
}
|
|
120
|
+
const orderByEntry = orderByEntries[0];
|
|
121
|
+
if (!orderByEntry) {
|
|
122
|
+
throw this.unsupportedError("Invalid orderBy entry");
|
|
123
|
+
}
|
|
124
|
+
const [field, direction] = orderByEntry;
|
|
125
|
+
const tableDef = this.contract.storage.tables[this.tableName];
|
|
126
|
+
if (!tableDef || !tableDef.columns[field]) {
|
|
127
|
+
throw this.unsupportedError(`Unknown field '${field}' in orderBy clause`);
|
|
128
|
+
}
|
|
129
|
+
const columns = this.table.columns;
|
|
130
|
+
const columnValue = columns[field];
|
|
131
|
+
if (!isColumnBuilder(columnValue)) {
|
|
132
|
+
throw this.unsupportedError(`Invalid column '${field}' in orderBy clause`);
|
|
133
|
+
}
|
|
134
|
+
const column = columnValue;
|
|
135
|
+
const orderExpr = direction === "asc" ? column.asc() : column.desc();
|
|
136
|
+
query = query.orderBy(orderExpr);
|
|
137
|
+
}
|
|
138
|
+
if (args.take !== void 0) {
|
|
139
|
+
query = query.limit(args.take);
|
|
140
|
+
}
|
|
141
|
+
if (args.skip !== void 0) {
|
|
142
|
+
throw this.unsupportedError("skip/OFFSET not supported in MVP");
|
|
143
|
+
}
|
|
144
|
+
const paramsMap = {};
|
|
145
|
+
if (args.where) {
|
|
146
|
+
for (const [field, value] of Object.entries(args.where)) {
|
|
147
|
+
paramsMap[`${tableName}_${field}`] = value;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const plan = query.build({ params: paramsMap });
|
|
151
|
+
const results = [];
|
|
152
|
+
for await (const row of this.runtime.execute(
|
|
153
|
+
plan
|
|
154
|
+
)) {
|
|
155
|
+
results.push(row);
|
|
156
|
+
}
|
|
157
|
+
return results;
|
|
158
|
+
}
|
|
159
|
+
async create(args) {
|
|
160
|
+
const tableName = this.tableName;
|
|
161
|
+
const tableDef = this.contract.storage.tables[tableName];
|
|
162
|
+
if (!tableDef) {
|
|
163
|
+
throw new Error(`Table ${tableName} not found in contract`);
|
|
164
|
+
}
|
|
165
|
+
const columns = [];
|
|
166
|
+
const values = [];
|
|
167
|
+
const placeholders = [];
|
|
168
|
+
let paramIndex = 1;
|
|
169
|
+
for (const [field, value] of Object.entries(args.data)) {
|
|
170
|
+
const columnDef = tableDef.columns[field];
|
|
171
|
+
if (!columnDef) {
|
|
172
|
+
throw this.unsupportedError(`Unknown field '${field}' in create data`);
|
|
173
|
+
}
|
|
174
|
+
columns.push(`"${field}"`);
|
|
175
|
+
values.push(value);
|
|
176
|
+
placeholders.push(`$${paramIndex}`);
|
|
177
|
+
paramIndex++;
|
|
178
|
+
}
|
|
179
|
+
if (columns.length === 0) {
|
|
180
|
+
throw this.unsupportedError("create() requires at least one field in data");
|
|
181
|
+
}
|
|
182
|
+
const sqlBuilder = sql({ context: this.context });
|
|
183
|
+
const insertPlan = sqlBuilder.raw(
|
|
184
|
+
`INSERT INTO "${tableName}" (${columns.join(", ")}) VALUES (${placeholders.join(", ")}) RETURNING *`,
|
|
185
|
+
{
|
|
186
|
+
params: values,
|
|
187
|
+
annotations: {
|
|
188
|
+
intent: "write",
|
|
189
|
+
isMutation: true,
|
|
190
|
+
hasWhere: false,
|
|
191
|
+
hasLimit: false
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
const results = [];
|
|
196
|
+
for await (const row of this.runtime.execute(
|
|
197
|
+
insertPlan
|
|
198
|
+
)) {
|
|
199
|
+
results.push(row);
|
|
200
|
+
}
|
|
201
|
+
if (results.length === 0) {
|
|
202
|
+
throw new Error("INSERT did not return a row");
|
|
203
|
+
}
|
|
204
|
+
const result = results[0];
|
|
205
|
+
if (!result) {
|
|
206
|
+
throw new Error("INSERT did not return a row");
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
async update(_args) {
|
|
211
|
+
void _args;
|
|
212
|
+
throw this.unsupportedError("update() mutations are not supported in MVP compatibility layer");
|
|
213
|
+
}
|
|
214
|
+
async delete(_args) {
|
|
215
|
+
void _args;
|
|
216
|
+
throw this.unsupportedError("delete() mutations are not supported in MVP compatibility layer");
|
|
217
|
+
}
|
|
218
|
+
validateWhereArgs(where) {
|
|
219
|
+
for (const [field, value] of Object.entries(where)) {
|
|
220
|
+
if (value === null || value === void 0) {
|
|
221
|
+
throw this.unsupportedError("Null/undefined values in where clause not supported in MVP");
|
|
222
|
+
}
|
|
223
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
224
|
+
throw this.unsupportedError(
|
|
225
|
+
`Complex where predicates (e.g., {${field}: {gt: ...}}) not supported in MVP`
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
if (Array.isArray(value)) {
|
|
229
|
+
throw this.unsupportedError("IN/NOT IN predicates not supported in MVP");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
unsupportedError(message) {
|
|
234
|
+
const error = new Error(message);
|
|
235
|
+
error.code = "CONFIG.INVALID";
|
|
236
|
+
error.category = "CONFIG";
|
|
237
|
+
error.severity = "error";
|
|
238
|
+
return error;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
var PrismaClientImpl = class {
|
|
242
|
+
runtime;
|
|
243
|
+
context;
|
|
244
|
+
contract;
|
|
245
|
+
schemaHandle;
|
|
246
|
+
models = {};
|
|
247
|
+
constructor(options) {
|
|
248
|
+
this.contract = options.contract;
|
|
249
|
+
const adapter = createPostgresAdapter();
|
|
250
|
+
this.context = createRuntimeContext({
|
|
251
|
+
contract: this.contract,
|
|
252
|
+
adapter,
|
|
253
|
+
extensions: []
|
|
254
|
+
});
|
|
255
|
+
if (options.runtime) {
|
|
256
|
+
this.runtime = options.runtime;
|
|
257
|
+
} else {
|
|
258
|
+
const connectionString = options.connectionString ?? process.env["DATABASE_URL"];
|
|
259
|
+
if (!connectionString) {
|
|
260
|
+
throw new Error("DATABASE_URL environment variable or connectionString option is required");
|
|
261
|
+
}
|
|
262
|
+
const driver = createPostgresDriver(connectionString);
|
|
263
|
+
this.runtime = createRuntime({
|
|
264
|
+
adapter,
|
|
265
|
+
driver,
|
|
266
|
+
context: this.context,
|
|
267
|
+
verify: {
|
|
268
|
+
mode: "onFirstUse",
|
|
269
|
+
requireMarker: false
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
this.schemaHandle = schema(this.context);
|
|
274
|
+
for (const [tableName, table] of Object.entries(this.schemaHandle.tables)) {
|
|
275
|
+
const modelName = tableName.charAt(0).toLowerCase() + tableName.slice(1);
|
|
276
|
+
this.models[modelName] = new ModelDelegate(
|
|
277
|
+
this.runtime,
|
|
278
|
+
this.context,
|
|
279
|
+
this.contract,
|
|
280
|
+
table,
|
|
281
|
+
tableName
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
async $disconnect() {
|
|
286
|
+
await this.runtime.close();
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
var PrismaClient = class extends PrismaClientImpl {
|
|
290
|
+
constructor(options) {
|
|
291
|
+
super(options);
|
|
292
|
+
const proxy = new Proxy(this, {
|
|
293
|
+
get(target, prop) {
|
|
294
|
+
if (prop in target && prop !== "models") {
|
|
295
|
+
if (typeof prop === "string" || typeof prop === "number") {
|
|
296
|
+
return target[prop];
|
|
297
|
+
}
|
|
298
|
+
return void 0;
|
|
299
|
+
}
|
|
300
|
+
if (typeof prop === "string" && target.models[prop]) {
|
|
301
|
+
return target.models[prop];
|
|
302
|
+
}
|
|
303
|
+
return void 0;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
for (const [modelName, delegate] of Object.entries(this.models)) {
|
|
307
|
+
proxy[modelName] = delegate;
|
|
308
|
+
}
|
|
309
|
+
return proxy;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
export {
|
|
313
|
+
PrismaClient
|
|
314
|
+
};
|
|
315
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/prisma-client.ts"],"sourcesContent":["import { createPostgresAdapter } from '@prisma-next/adapter-postgres/adapter';\nimport type { ExecutionPlan } from '@prisma-next/contract/types';\nimport { createPostgresDriver } from '@prisma-next/driver-postgres/runtime';\nimport type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { sql } from '@prisma-next/sql-lane/sql';\nimport type { TableRef } from '@prisma-next/sql-relational-core/ast';\nimport { param } from '@prisma-next/sql-relational-core/param';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport { schema } from '@prisma-next/sql-relational-core/schema';\nimport type {\n BinaryBuilder,\n ColumnBuilder,\n OrderBuilder,\n} from '@prisma-next/sql-relational-core/types';\nimport {\n createRuntime,\n createRuntimeContext,\n type Runtime,\n type RuntimeContext,\n} from '@prisma-next/sql-runtime';\n\ninterface PrismaClientOptions {\n readonly contract: SqlContract<SqlStorage>;\n readonly runtime?: Runtime;\n readonly connectionString?: string;\n}\n\ninterface FindUniqueArgs {\n readonly where: Record<string, unknown>;\n readonly select?: Record<string, boolean>;\n}\n\ninterface FindManyArgs {\n readonly where?: Record<string, unknown>;\n readonly select?: Record<string, boolean>;\n readonly orderBy?: Record<string, 'asc' | 'desc'>;\n readonly take?: number;\n readonly skip?: number;\n}\n\ntype FindFirstArgs = FindManyArgs;\n\ntype TableFromSchema<Contract extends SqlContract<SqlStorage>> = ReturnType<\n typeof schema<Contract>\n>['tables'][string];\n\nfunction isColumnBuilder(value: unknown): value is ColumnBuilder {\n return (\n value !== null &&\n value !== undefined &&\n typeof value === 'object' &&\n 'kind' in value &&\n value.kind === 'column'\n );\n}\n\n// NOTE: we can rely on the Prisma ORM's complex type definitions for the method return values, we only need to ensure the compatibility layer behaves correctly at runtime\nclass ModelDelegate {\n private readonly tableName: string;\n private readonly tableRef: TableRef;\n\n constructor(\n private readonly runtime: Runtime,\n private readonly context: RuntimeContext<SqlContract<SqlStorage>>,\n private readonly contract: SqlContract<SqlStorage>,\n private readonly table: TableFromSchema<SqlContract<SqlStorage>>,\n tableName: string,\n ) {\n // Store table name explicitly (from schema key)\n this.tableName = tableName;\n // Create a clean TableRef that preserves the name property\n // Object.assign in TableBuilderImpl may have overwritten name if there's a column named 'name'\n // We preserve the original table for column access but create a clean ref for from() calls\n this.tableRef = Object.freeze({\n kind: 'table' as const,\n name: tableName,\n }) as TableRef;\n }\n\n async findUnique(args: FindUniqueArgs): Promise<Record<string, unknown> | null> {\n const result = await this.findMany({\n ...args,\n take: 1,\n });\n\n return result[0] ?? null;\n }\n\n async findFirst(args: FindFirstArgs = {}): Promise<Record<string, unknown> | null> {\n const result = await this.findMany({\n ...args,\n take: 1,\n });\n\n return result[0] ?? null;\n }\n\n async findMany(args: FindManyArgs = {}): Promise<Record<string, unknown>[]> {\n const tableName = this.tableName;\n let query = sql({ context: this.context }).from(this.tableRef);\n\n // Handle where clause (equality only for MVP)\n if (args.where) {\n this.validateWhereArgs(args.where);\n const whereConditions: Array<{ column: ColumnBuilder; value: unknown }> = [];\n\n for (const [field, value] of Object.entries(args.where)) {\n // Check contract first to validate field exists\n const tableDef = this.contract.storage.tables[this.tableName];\n if (!tableDef || !tableDef.columns[field]) {\n throw this.unsupportedError(`Unknown field '${field}' in where clause`);\n }\n // Access column via columns property to avoid conflicts with table properties\n const columns = this.table.columns;\n const column = columns[field];\n if (!isColumnBuilder(column)) {\n throw this.unsupportedError(`Invalid column '${field}' in where clause`);\n }\n whereConditions.push({ column, value });\n }\n\n if (whereConditions.length === 1) {\n const condition = whereConditions[0];\n if (!condition) {\n throw this.unsupportedError('Invalid where condition');\n }\n const column = condition.column as unknown as ColumnBuilder;\n const paramPlaceholder = param(`${tableName}_${(column as { column: string }).column}`);\n const binaryExpr = (column as { eq: (value: unknown) => BinaryBuilder }).eq(\n paramPlaceholder,\n );\n query = query.where(binaryExpr);\n } else if (whereConditions.length > 1) {\n throw this.unsupportedError('Multiple where conditions (AND/OR) not supported in MVP');\n }\n }\n\n // Handle select projection\n const projection: Record<string, ColumnBuilder> = {};\n if (args.select) {\n for (const [field, include] of Object.entries(args.select)) {\n if (include) {\n // Check contract first, then access column\n const tableDef = this.contract.storage.tables[this.tableName];\n if (!tableDef || !tableDef.columns[field]) {\n throw this.unsupportedError(`Unknown field '${field}' in select clause`);\n }\n const columns = this.table.columns;\n const column = columns[field];\n if (!isColumnBuilder(column)) {\n throw this.unsupportedError(`Invalid column '${field}' in select clause`);\n }\n projection[field] = column;\n }\n }\n } else {\n // Default: select all columns from contract definition\n const tableDef = this.contract.storage.tables[tableName];\n const tableColumns = this.table.columns;\n if (tableDef && tableColumns) {\n for (const columnName of Object.keys(tableDef.columns)) {\n // Access column via columns property to avoid conflicts with table properties like 'name'\n const column = tableColumns[columnName];\n if (isColumnBuilder(column)) {\n projection[columnName] = column;\n }\n }\n }\n\n // Fallback: iterate table columns directly\n if (Object.keys(projection).length === 0 && tableColumns) {\n for (const key in tableColumns) {\n const value = tableColumns[key];\n if (isColumnBuilder(value)) {\n projection[key] = value;\n }\n }\n }\n\n if (Object.keys(projection).length === 0) {\n throw this.unsupportedError('Select projection cannot be empty');\n }\n }\n\n query = query.select(projection);\n\n // Handle orderBy\n if (args.orderBy) {\n const orderByEntries = Object.entries(args.orderBy);\n if (orderByEntries.length > 1) {\n throw this.unsupportedError('Multiple orderBy fields not supported in MVP');\n }\n\n const orderByEntry = orderByEntries[0];\n if (!orderByEntry) {\n throw this.unsupportedError('Invalid orderBy entry');\n }\n const [field, direction] = orderByEntry;\n const tableDef = this.contract.storage.tables[this.tableName];\n if (!tableDef || !tableDef.columns[field]) {\n throw this.unsupportedError(`Unknown field '${field}' in orderBy clause`);\n }\n const columns = this.table.columns;\n const columnValue = columns[field];\n if (!isColumnBuilder(columnValue)) {\n throw this.unsupportedError(`Invalid column '${field}' in orderBy clause`);\n }\n const column = columnValue as unknown as ColumnBuilder;\n\n const orderExpr: OrderBuilder =\n direction === 'asc'\n ? (column as { asc: () => OrderBuilder }).asc()\n : (column as { desc: () => OrderBuilder }).desc();\n query = query.orderBy(orderExpr);\n }\n\n // Handle pagination\n if (args.take !== undefined) {\n query = query.limit(args.take);\n }\n\n if (args.skip !== undefined) {\n throw this.unsupportedError('skip/OFFSET not supported in MVP');\n }\n\n // Build plan with params\n const paramsMap: Record<string, unknown> = {};\n if (args.where) {\n for (const [field, value] of Object.entries(args.where)) {\n paramsMap[`${tableName}_${field}`] = value;\n }\n }\n\n const plan = query.build({ params: paramsMap });\n\n // Execute via runtime\n const results: Record<string, unknown>[] = [];\n for await (const row of this.runtime.execute<Record<string, unknown>>(\n plan as ExecutionPlan<Record<string, unknown>> | SqlQueryPlan<Record<string, unknown>>,\n )) {\n results.push(row);\n }\n\n return results;\n }\n\n async create(args: { data: Record<string, unknown> }): Promise<Record<string, unknown>> {\n const tableName = this.tableName;\n const tableDef = this.contract.storage.tables[tableName];\n\n if (!tableDef) {\n throw new Error(`Table ${tableName} not found in contract`);\n }\n\n // Build INSERT statement using raw SQL (MVP: simple inserts only)\n const columns: string[] = [];\n const values: unknown[] = [];\n const placeholders: string[] = [];\n let paramIndex = 1;\n\n for (const [field, value] of Object.entries(args.data)) {\n const columnDef = tableDef.columns[field];\n if (!columnDef) {\n throw this.unsupportedError(`Unknown field '${field}' in create data`);\n }\n\n // Skip auto-generated fields (id with default, createdAt with default, etc.)\n // For MVP, we'll include all provided fields\n columns.push(`\"${field}\"`);\n values.push(value);\n placeholders.push(`$${paramIndex}`);\n paramIndex++;\n }\n\n if (columns.length === 0) {\n throw this.unsupportedError('create() requires at least one field in data');\n }\n\n // Use raw SQL for INSERT (MVP approach)\n const sqlBuilder = sql({ context: this.context });\n const insertPlan = sqlBuilder.raw(\n `INSERT INTO \"${tableName}\" (${columns.join(', ')}) VALUES (${placeholders.join(', ')}) RETURNING *`,\n {\n params: values,\n annotations: {\n intent: 'write',\n isMutation: true,\n hasWhere: false,\n hasLimit: false,\n },\n },\n );\n\n // Execute and return the created row\n const results: Record<string, unknown>[] = [];\n for await (const row of this.runtime.execute<Record<string, unknown>>(\n insertPlan as ExecutionPlan<Record<string, unknown>> | SqlQueryPlan<Record<string, unknown>>,\n )) {\n results.push(row);\n }\n\n if (results.length === 0) {\n throw new Error('INSERT did not return a row');\n }\n\n const result = results[0];\n if (!result) {\n throw new Error('INSERT did not return a row');\n }\n return result;\n }\n\n async update(_args: {\n where: Record<string, unknown>;\n data: Record<string, unknown>;\n }): Promise<Record<string, unknown>> {\n void _args;\n throw this.unsupportedError('update() mutations are not supported in MVP compatibility layer');\n }\n\n async delete(_args: { where: Record<string, unknown> }): Promise<Record<string, unknown>> {\n void _args;\n throw this.unsupportedError('delete() mutations are not supported in MVP compatibility layer');\n }\n\n private validateWhereArgs(where: Record<string, unknown>): void {\n // MVP: only simple equality is supported\n for (const [field, value] of Object.entries(where)) {\n if (value === null || value === undefined) {\n throw this.unsupportedError('Null/undefined values in where clause not supported in MVP');\n }\n if (typeof value === 'object' && !Array.isArray(value)) {\n throw this.unsupportedError(\n `Complex where predicates (e.g., {${field}: {gt: ...}}) not supported in MVP`,\n );\n }\n if (Array.isArray(value)) {\n throw this.unsupportedError('IN/NOT IN predicates not supported in MVP');\n }\n }\n }\n\n private unsupportedError(message: string): Error {\n const error = new Error(message) as Error & {\n code: string;\n category: string;\n severity: string;\n };\n error.code = 'CONFIG.INVALID';\n error.category = 'CONFIG';\n error.severity = 'error';\n return error;\n }\n}\n\nclass PrismaClientImpl {\n readonly runtime: Runtime;\n readonly context: RuntimeContext<SqlContract<SqlStorage>>;\n readonly contract: SqlContract<SqlStorage>;\n readonly schemaHandle: ReturnType<typeof schema>;\n readonly models: Record<string, ModelDelegate> = {};\n\n // Dynamic model access properties (populated at runtime)\n [key: string]: unknown;\n\n constructor(options: PrismaClientOptions) {\n // Currently only SQL contracts are supported\n this.contract = options.contract;\n\n // Create context with contract and adapter\n const adapter = createPostgresAdapter();\n this.context = createRuntimeContext({\n contract: this.contract,\n adapter,\n extensions: [],\n });\n\n // Initialize runtime if not provided\n if (options.runtime) {\n this.runtime = options.runtime;\n } else {\n const connectionString = options.connectionString ?? process.env['DATABASE_URL'];\n\n if (!connectionString) {\n throw new Error('DATABASE_URL environment variable or connectionString option is required');\n }\n\n const driver = createPostgresDriver(connectionString);\n\n this.runtime = createRuntime({\n adapter,\n driver,\n context: this.context,\n verify: {\n mode: 'onFirstUse',\n requireMarker: false,\n },\n });\n }\n\n // Initialize schema handle\n this.schemaHandle = schema(this.context);\n\n // Build model delegates\n for (const [tableName, table] of Object.entries(this.schemaHandle.tables)) {\n // Convert table name to camelCase model name (e.g., \"user\" -> \"user\", \"User\" -> \"user\")\n const modelName = tableName.charAt(0).toLowerCase() + tableName.slice(1);\n // Pass tableName explicitly since Object.assign in TableBuilderImpl may interfere with name property\n this.models[modelName] = new ModelDelegate(\n this.runtime,\n this.context,\n this.contract,\n table as TableFromSchema<SqlContract<SqlStorage>>,\n tableName,\n );\n }\n }\n\n async $disconnect(): Promise<void> {\n await this.runtime.close();\n }\n}\n\n// Export PrismaClient as a Proxy-wrapped class for dynamic model access\nexport class PrismaClient extends PrismaClientImpl {\n // Declare user model for TypeScript (MVP: assumes user table exists)\n declare readonly user: ModelDelegate;\n\n constructor(options: PrismaClientOptions) {\n super(options);\n const proxy = new Proxy(this, {\n get(target, prop) {\n if (prop in target && prop !== 'models') {\n if (typeof prop === 'string' || typeof prop === 'number') {\n return (target as Record<string | number, unknown>)[prop];\n }\n return undefined;\n }\n\n // Check if it's a model name\n if (typeof prop === 'string' && target.models[prop]) {\n return target.models[prop];\n }\n\n return undefined;\n },\n });\n\n // Copy model properties to instance for TypeScript type checking\n for (const [modelName, delegate] of Object.entries(this.models)) {\n (proxy as Record<string, unknown>)[modelName] = delegate;\n }\n\n // biome-ignore lint/correctness/noConstructorReturn: Proxy pattern requires returning the proxy\n return proxy;\n }\n}\n"],"mappings":";AAAA,SAAS,6BAA6B;AAEtC,SAAS,4BAA4B;AAErC,SAAS,WAAW;AAEpB,SAAS,aAAa;AAEtB,SAAS,cAAc;AAMvB;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AA2BP,SAAS,gBAAgB,OAAwC;AAC/D,SACE,UAAU,QACV,UAAU,UACV,OAAO,UAAU,YACjB,UAAU,SACV,MAAM,SAAS;AAEnB;AAGA,IAAM,gBAAN,MAAoB;AAAA,EAIlB,YACmB,SACA,SACA,UACA,OACjB,WACA;AALiB;AACA;AACA;AACA;AAIjB,SAAK,YAAY;AAIjB,SAAK,WAAW,OAAO,OAAO;AAAA,MAC5B,MAAM;AAAA,MACN,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AAAA,EAnBiB;AAAA,EACA;AAAA,EAoBjB,MAAM,WAAW,MAA+D;AAC9E,UAAM,SAAS,MAAM,KAAK,SAAS;AAAA,MACjC,GAAG;AAAA,MACH,MAAM;AAAA,IACR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AO,QAAQ,KAAK,MAAM,GAAG;AAC/D,MAAC,MAAkC,SAAS,IAAI;AAAA,IAClD;AAGA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prisma-next/compat-prisma",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@prisma-next/contract": "0.0.1",
|
|
11
|
+
"@prisma-next/sql-runtime": "0.0.1",
|
|
12
|
+
"@prisma-next/driver-postgres": "0.0.1",
|
|
13
|
+
"@prisma-next/adapter-postgres": "0.0.1",
|
|
14
|
+
"@prisma-next/sql-lane": "0.0.1",
|
|
15
|
+
"@prisma-next/sql-relational-core": "0.0.1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@prisma/dev": "^0.1.1",
|
|
19
|
+
"@types/pg": "^8.11.10",
|
|
20
|
+
"pg": "^8.11.5",
|
|
21
|
+
"tsup": "^8.3.0",
|
|
22
|
+
"typescript": "^5.9.3",
|
|
23
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
24
|
+
"vitest": "^2.1.1",
|
|
25
|
+
"@prisma-next/test-utils": "0.0.1"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/exports/index.d.ts",
|
|
30
|
+
"import": "./dist/exports/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsup --config tsup.config.ts",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:coverage": "vitest run --coverage",
|
|
37
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
38
|
+
"lint": "biome check . --config-path ../../../biome.json --error-on-warnings",
|
|
39
|
+
"clean": "node ../../scripts/clean.mjs"
|
|
40
|
+
}
|
|
41
|
+
}
|