@effectify/prisma 0.1.2 → 1.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/dist/src/cli.d.ts +1 -1
- package/dist/src/cli.js +9 -9
- package/dist/src/commands/init.d.ts +1 -1
- package/dist/src/commands/init.js +0 -2
- package/dist/src/commands/prisma.d.ts +5 -0
- package/dist/src/commands/prisma.js +35 -0
- package/dist/src/generators/sql-schema-generator.d.ts +9 -0
- package/dist/src/generators/sql-schema-generator.js +50 -58
- package/dist/src/services/generator-context.d.ts +6 -0
- package/dist/src/services/generator-context.js +3 -0
- package/dist/src/services/generator-service.d.ts +14 -0
- package/dist/src/services/generator-service.js +121 -0
- package/dist/src/services/render-service.d.ts +10 -0
- package/dist/src/services/render-service.js +23 -0
- package/{src → dist/src}/templates/index-default.eta +1 -1
- package/dist/src/templates/model.eta +8 -0
- package/{src → dist/src}/templates/prisma-repository.eta +7 -7
- package/package.json +15 -11
- package/dist/src/commands/generate-effect.d.ts +0 -2
- package/dist/src/commands/generate-effect.js +0 -73
- package/dist/src/commands/generate-sql-schema.d.ts +0 -2
- package/dist/src/commands/generate-sql-schema.js +0 -72
- package/dist/src/effect-prisma.d.ts +0 -2
- package/dist/src/effect-prisma.js +0 -1771
- package/dist/src/generators/prisma-effect-generator.d.ts +0 -1
- package/dist/src/generators/prisma-effect-generator.js +0 -446
- package/prisma/dev.db +0 -0
- package/prisma/generated/client.d.ts +0 -1
- package/prisma/generated/client.js +0 -5
- package/prisma/generated/default.d.ts +0 -1
- package/prisma/generated/default.js +0 -5
- package/prisma/generated/edge.d.ts +0 -1
- package/prisma/generated/edge.js +0 -141
- package/prisma/generated/effect/index.ts +0 -392
- package/prisma/generated/effect/models/Todo.ts +0 -6
- package/prisma/generated/effect/prisma-repository.ts +0 -954
- package/prisma/generated/effect/prisma-schema.ts +0 -94
- package/prisma/generated/effect/schemas/enums.ts +0 -6
- package/prisma/generated/effect/schemas/index.ts +0 -2
- package/prisma/generated/effect/schemas/types.ts +0 -40
- package/prisma/generated/index-browser.js +0 -172
- package/prisma/generated/index.d.ts +0 -2376
- package/prisma/generated/index.js +0 -141
- package/prisma/generated/package.json +0 -144
- package/prisma/generated/query_compiler_bg.js +0 -2
- package/prisma/generated/query_compiler_bg.wasm +0 -0
- package/prisma/generated/query_compiler_bg.wasm-base64.js +0 -2
- package/prisma/generated/runtime/client.d.ts +0 -3180
- package/prisma/generated/runtime/client.js +0 -86
- package/prisma/generated/runtime/index-browser.d.ts +0 -87
- package/prisma/generated/runtime/index-browser.js +0 -6
- package/prisma/generated/runtime/wasm-compiler-edge.js +0 -76
- package/prisma/generated/schema.prisma +0 -31
- package/prisma/generated/wasm-edge-light-loader.mjs +0 -5
- package/prisma/generated/wasm-worker-loader.mjs +0 -5
- package/prisma/migrations/20250721164420_init/migration.sql +0 -9
- package/prisma/migrations/20250721191716_dumb/migration.sql +0 -49
- package/prisma/migrations/migration_lock.toml +0 -3
- package/prisma/schema.prisma +0 -31
- package/prisma.config.ts +0 -8
- package/project.json +0 -48
- package/scripts/cleanup-tests.ts +0 -26
- package/scripts/generate-test-files.ts +0 -93
- package/setup-tests.ts +0 -10
- package/src/cli.ts +0 -22
- package/src/commands/init.ts +0 -153
- package/src/commands/prisma.ts +0 -50
- package/src/generators/sql-schema-generator.ts +0 -66
- package/src/services/generator-context.ts +0 -4
- package/src/services/generator-service.ts +0 -178
- package/src/services/render-service.ts +0 -32
- package/src/templates/model.eta +0 -6
- package/test/prisma-model.test.ts +0 -340
- package/test/utils.ts +0 -10
- package/tsconfig.json +0 -20
- package/tsconfig.lib.json +0 -24
- package/tsconfig.spec.json +0 -15
- package/vitest.config.ts +0 -24
- /package/{src → dist/src}/templates/index-custom-error.eta +0 -0
- /package/{src → dist/src}/templates/prisma-raw-sql.eta +0 -0
- /package/{src → dist/src}/templates/prisma-schema.eta +0 -0
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
// This file was generated by prisma-effect-generator, do not edit manually.
|
|
2
|
-
|
|
3
|
-
import { Context, Data, Effect, Exit, Layer } from "effect"
|
|
4
|
-
import { Service } from "effect/Effect"
|
|
5
|
-
import { Prisma as PrismaNamespace, PrismaClient as BasePrismaClient } from "@prisma/client"
|
|
6
|
-
|
|
7
|
-
// Symbol used to identify intentional rollbacks vs actual errors
|
|
8
|
-
const ROLLBACK = Symbol.for("prisma.effect.rollback")
|
|
9
|
-
|
|
10
|
-
// Type for the flat transaction client with commit/rollback control
|
|
11
|
-
type FlatTransactionClient = PrismaNamespace.TransactionClient & {
|
|
12
|
-
$commit: () => Promise<void>
|
|
13
|
-
$rollback: () => Promise<void>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Transaction options for $transaction and $isolatedTransaction */
|
|
17
|
-
type TransactionOptions = {
|
|
18
|
-
maxWait?: number
|
|
19
|
-
timeout?: number
|
|
20
|
-
isolationLevel?: PrismaNamespace.TransactionIsolationLevel
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Context tag for the Prisma client instance.
|
|
25
|
-
* Holds the transaction client (tx) and root client.
|
|
26
|
-
*/
|
|
27
|
-
export class PrismaClient extends Context.Tag("PrismaClient")<
|
|
28
|
-
PrismaClient,
|
|
29
|
-
{
|
|
30
|
-
tx: BasePrismaClient | PrismaNamespace.TransactionClient
|
|
31
|
-
client: BasePrismaClient
|
|
32
|
-
}
|
|
33
|
-
>() {
|
|
34
|
-
static layer = (
|
|
35
|
-
...args: ConstructorParameters<typeof BasePrismaClient>
|
|
36
|
-
) => Layer.scoped(
|
|
37
|
-
PrismaClient,
|
|
38
|
-
Effect.gen(function* () {
|
|
39
|
-
const prisma = new BasePrismaClient(...args)
|
|
40
|
-
yield* Effect.addFinalizer(() => Effect.promise(() => prisma.$disconnect()))
|
|
41
|
-
return { tx: prisma, client: prisma }
|
|
42
|
-
})
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
static layerEffect = <R, E>(
|
|
46
|
-
optionsEffect: Effect.Effect<ConstructorParameters<typeof BasePrismaClient>[0], E, R>
|
|
47
|
-
) => Layer.scoped(
|
|
48
|
-
PrismaClient,
|
|
49
|
-
Effect.gen(function* () {
|
|
50
|
-
const options = yield* optionsEffect
|
|
51
|
-
const prisma = new BasePrismaClient(options)
|
|
52
|
-
yield* Effect.addFinalizer(() => Effect.promise(() => prisma.$disconnect()))
|
|
53
|
-
return { tx: prisma, client: prisma }
|
|
54
|
-
})
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export class PrismaUniqueConstraintError extends Data.TaggedError("PrismaUniqueConstraintError")<{
|
|
59
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
60
|
-
operation: string
|
|
61
|
-
model: string
|
|
62
|
-
}> {}
|
|
63
|
-
|
|
64
|
-
export class PrismaForeignKeyConstraintError extends Data.TaggedError("PrismaForeignKeyConstraintError")<{
|
|
65
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
66
|
-
operation: string
|
|
67
|
-
model: string
|
|
68
|
-
}> {}
|
|
69
|
-
|
|
70
|
-
export class PrismaRecordNotFoundError extends Data.TaggedError("PrismaRecordNotFoundError")<{
|
|
71
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
72
|
-
operation: string
|
|
73
|
-
model: string
|
|
74
|
-
}> {}
|
|
75
|
-
|
|
76
|
-
export class PrismaRelationViolationError extends Data.TaggedError("PrismaRelationViolationError")<{
|
|
77
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
78
|
-
operation: string
|
|
79
|
-
model: string
|
|
80
|
-
}> {}
|
|
81
|
-
|
|
82
|
-
export class PrismaRelatedRecordNotFoundError extends Data.TaggedError("PrismaRelatedRecordNotFoundError")<{
|
|
83
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
84
|
-
operation: string
|
|
85
|
-
model: string
|
|
86
|
-
}> {}
|
|
87
|
-
|
|
88
|
-
export class PrismaTransactionConflictError extends Data.TaggedError("PrismaTransactionConflictError")<{
|
|
89
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
90
|
-
operation: string
|
|
91
|
-
model: string
|
|
92
|
-
}> {}
|
|
93
|
-
|
|
94
|
-
export class PrismaValueTooLongError extends Data.TaggedError("PrismaValueTooLongError")<{
|
|
95
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
96
|
-
operation: string
|
|
97
|
-
model: string
|
|
98
|
-
}> {}
|
|
99
|
-
|
|
100
|
-
export class PrismaValueOutOfRangeError extends Data.TaggedError("PrismaValueOutOfRangeError")<{
|
|
101
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
102
|
-
operation: string
|
|
103
|
-
model: string
|
|
104
|
-
}> {}
|
|
105
|
-
|
|
106
|
-
export class PrismaDbConstraintError extends Data.TaggedError("PrismaDbConstraintError")<{
|
|
107
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
108
|
-
operation: string
|
|
109
|
-
model: string
|
|
110
|
-
}> {}
|
|
111
|
-
|
|
112
|
-
export class PrismaConnectionError extends Data.TaggedError("PrismaConnectionError")<{
|
|
113
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
114
|
-
operation: string
|
|
115
|
-
model: string
|
|
116
|
-
}> {}
|
|
117
|
-
|
|
118
|
-
export class PrismaMissingRequiredValueError extends Data.TaggedError("PrismaMissingRequiredValueError")<{
|
|
119
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
120
|
-
operation: string
|
|
121
|
-
model: string
|
|
122
|
-
}> {}
|
|
123
|
-
|
|
124
|
-
export class PrismaInputValidationError extends Data.TaggedError("PrismaInputValidationError")<{
|
|
125
|
-
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
126
|
-
operation: string
|
|
127
|
-
model: string
|
|
128
|
-
}> {}
|
|
129
|
-
|
|
130
|
-
export type PrismaCreateError =
|
|
131
|
-
| PrismaValueTooLongError
|
|
132
|
-
| PrismaUniqueConstraintError
|
|
133
|
-
| PrismaForeignKeyConstraintError
|
|
134
|
-
| PrismaDbConstraintError
|
|
135
|
-
| PrismaInputValidationError
|
|
136
|
-
| PrismaMissingRequiredValueError
|
|
137
|
-
| PrismaRelatedRecordNotFoundError
|
|
138
|
-
| PrismaValueOutOfRangeError
|
|
139
|
-
| PrismaConnectionError
|
|
140
|
-
| PrismaTransactionConflictError
|
|
141
|
-
|
|
142
|
-
export type PrismaUpdateError =
|
|
143
|
-
| PrismaValueTooLongError
|
|
144
|
-
| PrismaUniqueConstraintError
|
|
145
|
-
| PrismaForeignKeyConstraintError
|
|
146
|
-
| PrismaDbConstraintError
|
|
147
|
-
| PrismaInputValidationError
|
|
148
|
-
| PrismaMissingRequiredValueError
|
|
149
|
-
| PrismaRelationViolationError
|
|
150
|
-
| PrismaRelatedRecordNotFoundError
|
|
151
|
-
| PrismaValueOutOfRangeError
|
|
152
|
-
| PrismaConnectionError
|
|
153
|
-
| PrismaRecordNotFoundError
|
|
154
|
-
| PrismaTransactionConflictError
|
|
155
|
-
|
|
156
|
-
export type PrismaDeleteError =
|
|
157
|
-
| PrismaForeignKeyConstraintError
|
|
158
|
-
| PrismaRelationViolationError
|
|
159
|
-
| PrismaConnectionError
|
|
160
|
-
| PrismaRecordNotFoundError
|
|
161
|
-
| PrismaTransactionConflictError
|
|
162
|
-
|
|
163
|
-
export type PrismaFindOrThrowError =
|
|
164
|
-
| PrismaConnectionError
|
|
165
|
-
| PrismaRecordNotFoundError
|
|
166
|
-
|
|
167
|
-
export type PrismaFindError =
|
|
168
|
-
| PrismaConnectionError
|
|
169
|
-
|
|
170
|
-
export type PrismaDeleteManyError =
|
|
171
|
-
| PrismaForeignKeyConstraintError
|
|
172
|
-
| PrismaRelationViolationError
|
|
173
|
-
| PrismaConnectionError
|
|
174
|
-
| PrismaTransactionConflictError
|
|
175
|
-
|
|
176
|
-
export type PrismaUpdateManyError =
|
|
177
|
-
| PrismaValueTooLongError
|
|
178
|
-
| PrismaUniqueConstraintError
|
|
179
|
-
| PrismaForeignKeyConstraintError
|
|
180
|
-
| PrismaDbConstraintError
|
|
181
|
-
| PrismaInputValidationError
|
|
182
|
-
| PrismaMissingRequiredValueError
|
|
183
|
-
| PrismaValueOutOfRangeError
|
|
184
|
-
| PrismaConnectionError
|
|
185
|
-
| PrismaTransactionConflictError
|
|
186
|
-
|
|
187
|
-
export type PrismaError =
|
|
188
|
-
| PrismaValueTooLongError
|
|
189
|
-
| PrismaUniqueConstraintError
|
|
190
|
-
| PrismaForeignKeyConstraintError
|
|
191
|
-
| PrismaDbConstraintError
|
|
192
|
-
| PrismaInputValidationError
|
|
193
|
-
| PrismaMissingRequiredValueError
|
|
194
|
-
| PrismaRelationViolationError
|
|
195
|
-
| PrismaRelatedRecordNotFoundError
|
|
196
|
-
| PrismaValueOutOfRangeError
|
|
197
|
-
| PrismaConnectionError
|
|
198
|
-
| PrismaRecordNotFoundError
|
|
199
|
-
| PrismaTransactionConflictError
|
|
200
|
-
|
|
201
|
-
// Generic mapper for raw operations and fallback
|
|
202
|
-
const mapError = (error: unknown, operation: string, model: string): PrismaError => {
|
|
203
|
-
if (error instanceof PrismaNamespace.PrismaClientKnownRequestError) {
|
|
204
|
-
switch (error.code) {
|
|
205
|
-
case "P2000":
|
|
206
|
-
return new PrismaValueTooLongError({ cause: error, operation, model });
|
|
207
|
-
case "P2002":
|
|
208
|
-
return new PrismaUniqueConstraintError({ cause: error, operation, model });
|
|
209
|
-
case "P2003":
|
|
210
|
-
return new PrismaForeignKeyConstraintError({ cause: error, operation, model });
|
|
211
|
-
case "P2004":
|
|
212
|
-
return new PrismaDbConstraintError({ cause: error, operation, model });
|
|
213
|
-
case "P2005":
|
|
214
|
-
case "P2006":
|
|
215
|
-
case "P2019":
|
|
216
|
-
return new PrismaInputValidationError({ cause: error, operation, model });
|
|
217
|
-
case "P2011":
|
|
218
|
-
case "P2012":
|
|
219
|
-
return new PrismaMissingRequiredValueError({ cause: error, operation, model });
|
|
220
|
-
case "P2014":
|
|
221
|
-
return new PrismaRelationViolationError({ cause: error, operation, model });
|
|
222
|
-
case "P2015":
|
|
223
|
-
case "P2018":
|
|
224
|
-
return new PrismaRelatedRecordNotFoundError({ cause: error, operation, model });
|
|
225
|
-
case "P2020":
|
|
226
|
-
return new PrismaValueOutOfRangeError({ cause: error, operation, model });
|
|
227
|
-
case "P2024":
|
|
228
|
-
return new PrismaConnectionError({ cause: error, operation, model });
|
|
229
|
-
case "P2025":
|
|
230
|
-
return new PrismaRecordNotFoundError({ cause: error, operation, model });
|
|
231
|
-
case "P2034":
|
|
232
|
-
return new PrismaTransactionConflictError({ cause: error, operation, model });
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
// Unknown errors are not handled and will be treated as defects
|
|
236
|
-
throw error;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Internal helper to begin a callback-free interactive transaction.
|
|
241
|
-
*/
|
|
242
|
-
const $begin = (
|
|
243
|
-
client: BasePrismaClient,
|
|
244
|
-
options?: {
|
|
245
|
-
maxWait?: number
|
|
246
|
-
timeout?: number
|
|
247
|
-
isolationLevel?: PrismaNamespace.TransactionIsolationLevel
|
|
248
|
-
}
|
|
249
|
-
): Effect.Effect<FlatTransactionClient, PrismaError> =>
|
|
250
|
-
Effect.async<FlatTransactionClient, PrismaError>((resume) => {
|
|
251
|
-
let setTxClient: (txClient: PrismaNamespace.TransactionClient) => void
|
|
252
|
-
let commit: () => void
|
|
253
|
-
let rollback: () => void
|
|
254
|
-
|
|
255
|
-
const txClientPromise = new Promise<PrismaNamespace.TransactionClient>((res) => {
|
|
256
|
-
setTxClient = res
|
|
257
|
-
})
|
|
258
|
-
|
|
259
|
-
const txPromise = new Promise<void>((_res, _rej) => {
|
|
260
|
-
commit = () => _res(undefined)
|
|
261
|
-
rollback = () => _rej(ROLLBACK)
|
|
262
|
-
})
|
|
263
|
-
|
|
264
|
-
const tx = client.$transaction((txClient) => {
|
|
265
|
-
setTxClient(txClient)
|
|
266
|
-
return txPromise
|
|
267
|
-
}, options).catch((e) => {
|
|
268
|
-
if (e === ROLLBACK) return
|
|
269
|
-
throw e
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
txClientPromise.then((innerTx) => {
|
|
273
|
-
const proxy = new Proxy(innerTx, {
|
|
274
|
-
get(target, prop) {
|
|
275
|
-
if (prop === "$commit") return () => { commit(); return tx }
|
|
276
|
-
if (prop === "$rollback") return () => { rollback(); return tx }
|
|
277
|
-
return target[prop as keyof typeof target]
|
|
278
|
-
},
|
|
279
|
-
}) as FlatTransactionClient
|
|
280
|
-
resume(Effect.succeed(proxy))
|
|
281
|
-
}).catch((error) => {
|
|
282
|
-
resume(Effect.fail(mapError(error, "$transaction", "Prisma")))
|
|
283
|
-
})
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* The main Prisma service with all database operations.
|
|
288
|
-
* Provides type-safe, effectful access to your Prisma models.
|
|
289
|
-
*/
|
|
290
|
-
export class Prisma extends Service<Prisma>()("Prisma", {
|
|
291
|
-
effect: Effect.gen(function* () {
|
|
292
|
-
return {
|
|
293
|
-
$transaction: <R, E, A>(
|
|
294
|
-
effect: Effect.Effect<A, E, R>,
|
|
295
|
-
options?: TransactionOptions
|
|
296
|
-
) =>
|
|
297
|
-
Effect.flatMap(
|
|
298
|
-
PrismaClient,
|
|
299
|
-
({ client, tx }): Effect.Effect<A, E | PrismaError, R> => {
|
|
300
|
-
const isRootClient = "$transaction" in tx
|
|
301
|
-
if (!isRootClient) {
|
|
302
|
-
return effect
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return Effect.acquireUseRelease(
|
|
306
|
-
$begin(client, options),
|
|
307
|
-
(txClient) =>
|
|
308
|
-
effect.pipe(
|
|
309
|
-
Effect.provideService(PrismaClient, { tx: txClient, client })
|
|
310
|
-
),
|
|
311
|
-
(txClient, exit) =>
|
|
312
|
-
Exit.isSuccess(exit)
|
|
313
|
-
? Effect.promise(() => txClient.$commit())
|
|
314
|
-
: Effect.promise(() => txClient.$rollback())
|
|
315
|
-
)
|
|
316
|
-
}
|
|
317
|
-
),
|
|
318
|
-
|
|
319
|
-
$isolatedTransaction: <R, E, A>(
|
|
320
|
-
effect: Effect.Effect<A, E, R>,
|
|
321
|
-
options?: TransactionOptions
|
|
322
|
-
) =>
|
|
323
|
-
Effect.flatMap(
|
|
324
|
-
PrismaClient,
|
|
325
|
-
({ client }): Effect.Effect<A, E | PrismaError, R> => {
|
|
326
|
-
return Effect.acquireUseRelease(
|
|
327
|
-
$begin(client, options),
|
|
328
|
-
(txClient) =>
|
|
329
|
-
effect.pipe(
|
|
330
|
-
Effect.provideService(PrismaClient, { tx: txClient, client })
|
|
331
|
-
),
|
|
332
|
-
(txClient, exit) =>
|
|
333
|
-
Exit.isSuccess(exit)
|
|
334
|
-
? Effect.promise(() => txClient.$commit())
|
|
335
|
-
: Effect.promise(() => txClient.$rollback())
|
|
336
|
-
)
|
|
337
|
-
}
|
|
338
|
-
),
|
|
339
|
-
$executeRaw: (args: PrismaNamespace.Sql | [PrismaNamespace.Sql, ...any[]]): Effect.Effect<number, PrismaError, PrismaClient> =>
|
|
340
|
-
Effect.flatMap(PrismaClient, ({ tx: client }) =>
|
|
341
|
-
Effect.tryPromise({
|
|
342
|
-
try: () => (Array.isArray(args) ? client.$executeRaw(args[0], ...args.slice(1)) : client.$executeRaw(args)),
|
|
343
|
-
catch: (error) => mapError(error, "$executeRaw", "Prisma")
|
|
344
|
-
})
|
|
345
|
-
),
|
|
346
|
-
|
|
347
|
-
$executeRawUnsafe: (query: string, ...values: any[]): Effect.Effect<number, PrismaError, PrismaClient> =>
|
|
348
|
-
Effect.flatMap(PrismaClient, ({ tx: client }) =>
|
|
349
|
-
Effect.tryPromise({
|
|
350
|
-
try: () => client.$executeRawUnsafe(query, ...values),
|
|
351
|
-
catch: (error) => mapError(error, "$executeRawUnsafe", "Prisma")
|
|
352
|
-
})
|
|
353
|
-
),
|
|
354
|
-
|
|
355
|
-
$queryRaw: <T = unknown>(args: PrismaNamespace.Sql | [PrismaNamespace.Sql, ...any[]]): Effect.Effect<T, PrismaError, PrismaClient> =>
|
|
356
|
-
Effect.flatMap(PrismaClient, ({ tx: client }) =>
|
|
357
|
-
Effect.tryPromise({
|
|
358
|
-
try: () => (Array.isArray(args) ? client.$queryRaw(args[0], ...args.slice(1)) : client.$queryRaw(args)) as Promise<T>,
|
|
359
|
-
catch: (error) => mapError(error, "$queryRaw", "Prisma")
|
|
360
|
-
})
|
|
361
|
-
),
|
|
362
|
-
|
|
363
|
-
$queryRawUnsafe: <T = unknown>(query: string, ...values: any[]): Effect.Effect<T, PrismaError, PrismaClient> =>
|
|
364
|
-
Effect.flatMap(PrismaClient, ({ tx: client }) =>
|
|
365
|
-
Effect.tryPromise({
|
|
366
|
-
try: () => client.$queryRawUnsafe(query, ...values) as Promise<T>,
|
|
367
|
-
catch: (error) => mapError(error, "$queryRawUnsafe", "Prisma")
|
|
368
|
-
})
|
|
369
|
-
),
|
|
370
|
-
}
|
|
371
|
-
})
|
|
372
|
-
}) {
|
|
373
|
-
static layer = (
|
|
374
|
-
...args: ConstructorParameters<typeof BasePrismaClient>
|
|
375
|
-
) => Layer.merge(PrismaClient.layer(...args), Prisma.Default)
|
|
376
|
-
|
|
377
|
-
static layerEffect = <R, E>(
|
|
378
|
-
optionsEffect: Effect.Effect<ConstructorParameters<typeof BasePrismaClient>[0], E, R>
|
|
379
|
-
) => Layer.merge(PrismaClient.layerEffect(optionsEffect), Prisma.Default)
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// ============================================================================
|
|
384
|
-
// Deprecated aliases for backward compatibility
|
|
385
|
-
// ============================================================================
|
|
386
|
-
|
|
387
|
-
export const PrismaClientService = PrismaClient
|
|
388
|
-
export const PrismaService = Prisma
|
|
389
|
-
export const makePrismaLayer = PrismaClient.layer
|
|
390
|
-
export const makePrismaLayerEffect = PrismaClient.layerEffect
|
|
391
|
-
|
|
392
|
-
export * from "./models/Todo.js"
|