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