@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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
// #!/usr/bin/env tsx
|
|
2
|
-
export {};
|
|
3
|
-
// import fs from 'node:fs/promises'
|
|
4
|
-
// import path from 'node:path'
|
|
5
|
-
// import gh from '@prisma/generator-helper'
|
|
6
|
-
// const header = '// This file was generated by prisma-effect-generator, do not edit manually.\n'
|
|
7
|
-
// // Utility function to convert PascalCase to camelCase
|
|
8
|
-
// function toCamelCase(str) {
|
|
9
|
-
// return str.charAt(0).toLowerCase() + str.slice(1)
|
|
10
|
-
// }
|
|
11
|
-
// // Types for generator options
|
|
12
|
-
// interface GeneratorOptions {
|
|
13
|
-
// dmmf: {
|
|
14
|
-
// datamodel: {
|
|
15
|
-
// models: Array<{
|
|
16
|
-
// name: string
|
|
17
|
-
// fields: Array<{
|
|
18
|
-
// name: string
|
|
19
|
-
// type: string
|
|
20
|
-
// }>
|
|
21
|
-
// }>
|
|
22
|
-
// }
|
|
23
|
-
// }
|
|
24
|
-
// generator: {
|
|
25
|
-
// output?: {
|
|
26
|
-
// value: string
|
|
27
|
-
// }
|
|
28
|
-
// }
|
|
29
|
-
// }
|
|
30
|
-
// // Export the generator function for use in CLI
|
|
31
|
-
// export async function generateEffectPrisma(options: GeneratorOptions) {
|
|
32
|
-
// const models = options.dmmf.datamodel.models
|
|
33
|
-
// const outputDir = options.generator.output?.value
|
|
34
|
-
// if (!outputDir) {
|
|
35
|
-
// throw new Error('No output directory specified')
|
|
36
|
-
// }
|
|
37
|
-
// // Clean output directory
|
|
38
|
-
// await fs.rm(outputDir, { recursive: true, force: true })
|
|
39
|
-
// await fs.mkdir(outputDir, { recursive: true })
|
|
40
|
-
// // Generate unified index file with PrismaService
|
|
41
|
-
// await generateUnifiedService([...models], outputDir)
|
|
42
|
-
// // Generate types file
|
|
43
|
-
// await generateTypes([...models], outputDir)
|
|
44
|
-
// }
|
|
45
|
-
// gh.generatorHandler({
|
|
46
|
-
// onManifest() {
|
|
47
|
-
// return {
|
|
48
|
-
// defaultOutput: '../src/generated/effect-prisma',
|
|
49
|
-
// prettyName: 'Prisma Effect Generator',
|
|
50
|
-
// requiresEngines: ['queryEngine'],
|
|
51
|
-
// }
|
|
52
|
-
// },
|
|
53
|
-
// async onGenerate(options) {
|
|
54
|
-
// await generateEffectPrisma(options)
|
|
55
|
-
// },
|
|
56
|
-
// })
|
|
57
|
-
// function generateErrorTypes(models) {
|
|
58
|
-
// const modelNames = models.map((model) => `"${model.name}"`).join(' | ')
|
|
59
|
-
// const operationNames = [
|
|
60
|
-
// '"findMany"',
|
|
61
|
-
// '"findUnique"',
|
|
62
|
-
// '"findFirst"',
|
|
63
|
-
// '"findUniqueOrThrow"',
|
|
64
|
-
// '"findFirstOrThrow"',
|
|
65
|
-
// '"create"',
|
|
66
|
-
// '"createMany"',
|
|
67
|
-
// '"createManyAndReturn"',
|
|
68
|
-
// '"update"',
|
|
69
|
-
// '"updateMany"',
|
|
70
|
-
// '"upsert"',
|
|
71
|
-
// '"delete"',
|
|
72
|
-
// '"deleteMany"',
|
|
73
|
-
// '"count"',
|
|
74
|
-
// '"aggregate"',
|
|
75
|
-
// '"groupBy"',
|
|
76
|
-
// '"$executeRaw"',
|
|
77
|
-
// '"$executeRawUnsafe"',
|
|
78
|
-
// '"$queryRaw"',
|
|
79
|
-
// '"$queryRawUnsafe"',
|
|
80
|
-
// ].join(' | ')
|
|
81
|
-
// return `
|
|
82
|
-
// // String literal types for exhaustive error handling
|
|
83
|
-
// export type ModelName = ${modelNames}
|
|
84
|
-
// export type OperationName = ${operationNames}
|
|
85
|
-
// // Specific Prisma error types for exhaustive error handling
|
|
86
|
-
// export class PrismaRecordNotFoundError extends Data.TaggedError("PrismaRecordNotFound")<{
|
|
87
|
-
// model: ModelName | "Prisma"
|
|
88
|
-
// operation: OperationName
|
|
89
|
-
// where?: unknown
|
|
90
|
-
// }> {}
|
|
91
|
-
// export class PrismaUniqueConstraintError extends Data.TaggedError("PrismaUniqueConstraint")<{
|
|
92
|
-
// model: ModelName | "Prisma"
|
|
93
|
-
// operation: OperationName
|
|
94
|
-
// field?: string
|
|
95
|
-
// value?: unknown
|
|
96
|
-
// }> {}
|
|
97
|
-
// export class PrismaForeignKeyConstraintError extends Data.TaggedError("PrismaForeignKeyConstraint")<{
|
|
98
|
-
// model: ModelName | "Prisma"
|
|
99
|
-
// operation: OperationName
|
|
100
|
-
// field?: string
|
|
101
|
-
// referencedModel?: string
|
|
102
|
-
// }> {}
|
|
103
|
-
// export class PrismaRequiredFieldError extends Data.TaggedError("PrismaRequiredField")<{
|
|
104
|
-
// model: ModelName | "Prisma"
|
|
105
|
-
// operation: OperationName
|
|
106
|
-
// field: string
|
|
107
|
-
// }> {}
|
|
108
|
-
// export class PrismaConnectionError extends Data.TaggedError("PrismaConnection")<{
|
|
109
|
-
// model: ModelName | "Prisma"
|
|
110
|
-
// operation: OperationName
|
|
111
|
-
// message?: string
|
|
112
|
-
// }> {}
|
|
113
|
-
// export class PrismaValidationError extends Data.TaggedError("PrismaValidation")<{
|
|
114
|
-
// model: ModelName | "Prisma"
|
|
115
|
-
// operation: OperationName
|
|
116
|
-
// message: string
|
|
117
|
-
// }> {}
|
|
118
|
-
// export class PrismaUnknownError extends Data.TaggedError("PrismaUnknown")<{
|
|
119
|
-
// model: ModelName | "Prisma"
|
|
120
|
-
// operation: OperationName
|
|
121
|
-
// originalError: unknown
|
|
122
|
-
// }> {}
|
|
123
|
-
// // Error conversion function
|
|
124
|
-
// function convertPrismaError(error: unknown, model: ModelName | "Prisma", operation: OperationName):
|
|
125
|
-
// | PrismaRecordNotFoundError
|
|
126
|
-
// | PrismaUniqueConstraintError
|
|
127
|
-
// | PrismaForeignKeyConstraintError
|
|
128
|
-
// | PrismaRequiredFieldError
|
|
129
|
-
// | PrismaConnectionError
|
|
130
|
-
// | PrismaValidationError
|
|
131
|
-
// | PrismaUnknownError {
|
|
132
|
-
// // Handle Prisma-specific errors
|
|
133
|
-
// if (error && typeof error === 'object') {
|
|
134
|
-
// const prismaError = error as any
|
|
135
|
-
// // PrismaClientKnownRequestError
|
|
136
|
-
// if (prismaError.code) {
|
|
137
|
-
// switch (prismaError.code) {
|
|
138
|
-
// case 'P2002': // Unique constraint violation
|
|
139
|
-
// return new PrismaUniqueConstraintError({
|
|
140
|
-
// model,
|
|
141
|
-
// operation,
|
|
142
|
-
// field: prismaError.meta?.target?.[0] as string,
|
|
143
|
-
// value: prismaError.meta?.value
|
|
144
|
-
// })
|
|
145
|
-
// case 'P2025': // Record not found
|
|
146
|
-
// case 'P2016': // Query interpretation error (record not found)
|
|
147
|
-
// return new PrismaRecordNotFoundError({
|
|
148
|
-
// model,
|
|
149
|
-
// operation,
|
|
150
|
-
// where: prismaError.meta
|
|
151
|
-
// })
|
|
152
|
-
// case 'P2003': // Foreign key constraint violation
|
|
153
|
-
// case 'P2014': // Required relation violation
|
|
154
|
-
// return new PrismaForeignKeyConstraintError({
|
|
155
|
-
// model,
|
|
156
|
-
// operation,
|
|
157
|
-
// field: prismaError.meta?.field_name as string,
|
|
158
|
-
// referencedModel: prismaError.meta?.model_name as string
|
|
159
|
-
// })
|
|
160
|
-
// case 'P2012': // Missing required field
|
|
161
|
-
// case 'P2011': // Null constraint violation
|
|
162
|
-
// return new PrismaRequiredFieldError({
|
|
163
|
-
// model,
|
|
164
|
-
// operation,
|
|
165
|
-
// field: prismaError.meta?.field as string
|
|
166
|
-
// })
|
|
167
|
-
// case 'P1000': // Authentication failed
|
|
168
|
-
// case 'P1001': // Can't reach database server
|
|
169
|
-
// case 'P1002': // Database server timeout
|
|
170
|
-
// case 'P1008': // Operations timed out
|
|
171
|
-
// return new PrismaConnectionError({
|
|
172
|
-
// model,
|
|
173
|
-
// operation,
|
|
174
|
-
// message: prismaError.message as string
|
|
175
|
-
// })
|
|
176
|
-
// }
|
|
177
|
-
// }
|
|
178
|
-
// // PrismaClientValidationError
|
|
179
|
-
// if (prismaError.name === 'PrismaClientValidationError') {
|
|
180
|
-
// return new PrismaValidationError({
|
|
181
|
-
// model,
|
|
182
|
-
// operation,
|
|
183
|
-
// message: prismaError.message as string
|
|
184
|
-
// })
|
|
185
|
-
// }
|
|
186
|
-
// // PrismaClientInitializationError
|
|
187
|
-
// if (prismaError.name === 'PrismaClientInitializationError') {
|
|
188
|
-
// return new PrismaConnectionError({
|
|
189
|
-
// model,
|
|
190
|
-
// operation,
|
|
191
|
-
// message: prismaError.message as string
|
|
192
|
-
// })
|
|
193
|
-
// }
|
|
194
|
-
// }
|
|
195
|
-
// // Fallback to unknown error
|
|
196
|
-
// return new PrismaUnknownError({
|
|
197
|
-
// model,
|
|
198
|
-
// operation,
|
|
199
|
-
// originalError: error
|
|
200
|
-
// })
|
|
201
|
-
// }`
|
|
202
|
-
// }
|
|
203
|
-
// function generateErrorUnionTypes(models) {
|
|
204
|
-
// return models
|
|
205
|
-
// .map((model) => {
|
|
206
|
-
// const modelName = model.name
|
|
207
|
-
// return `
|
|
208
|
-
// // Error unions for ${modelName}
|
|
209
|
-
// export type ${modelName}FindErrors = PrismaConnectionError | PrismaUnknownError
|
|
210
|
-
// export type ${modelName}FindOrThrowErrors = PrismaRecordNotFoundError | PrismaConnectionError | PrismaUnknownError
|
|
211
|
-
// export type ${modelName}CreateErrors = PrismaUniqueConstraintError | PrismaForeignKeyConstraintError | PrismaRequiredFieldError | PrismaValidationError | PrismaConnectionError | PrismaUnknownError
|
|
212
|
-
// export type ${modelName}UpdateErrors = PrismaRecordNotFoundError | PrismaUniqueConstraintError | PrismaForeignKeyConstraintError | PrismaValidationError | PrismaConnectionError | PrismaUnknownError
|
|
213
|
-
// export type ${modelName}UpsertErrors = PrismaUniqueConstraintError | PrismaForeignKeyConstraintError | PrismaRequiredFieldError | PrismaValidationError | PrismaConnectionError | PrismaUnknownError
|
|
214
|
-
// export type ${modelName}DeleteErrors = PrismaRecordNotFoundError | PrismaForeignKeyConstraintError | PrismaConnectionError | PrismaUnknownError
|
|
215
|
-
// export type ${modelName}AggregateErrors = PrismaConnectionError | PrismaValidationError | PrismaUnknownError`
|
|
216
|
-
// })
|
|
217
|
-
// .join('\n')
|
|
218
|
-
// }
|
|
219
|
-
// function generateRawSqlOperations() {
|
|
220
|
-
// return `
|
|
221
|
-
// // eslint-disable-next-line @typescript-eslint/array-type
|
|
222
|
-
// $executeRaw: (args: Prisma.Sql | [Prisma.Sql, ...any[]]) =>
|
|
223
|
-
// Effect.tryPromise({
|
|
224
|
-
// try: () => (Array.isArray(args) ? client.$executeRaw(args[0], ...args.slice(1)) : client.$executeRaw(args)),
|
|
225
|
-
// catch: (error) => convertPrismaError(error, "Prisma", "$executeRaw")
|
|
226
|
-
// }),
|
|
227
|
-
// // eslint-disable-next-line @typescript-eslint/array-type
|
|
228
|
-
// $executeRawUnsafe: (query: string, ...values: any[]) =>
|
|
229
|
-
// Effect.tryPromise({
|
|
230
|
-
// try: () => client.$executeRawUnsafe(query, ...values),
|
|
231
|
-
// catch: (error) => convertPrismaError(error, "Prisma", "$executeRawUnsafe")
|
|
232
|
-
// }),
|
|
233
|
-
// // eslint-disable-next-line @typescript-eslint/array-type
|
|
234
|
-
// $queryRaw: (args: Prisma.Sql | [Prisma.Sql, ...any[]]) =>
|
|
235
|
-
// Effect.tryPromise({
|
|
236
|
-
// try: () => (Array.isArray(args) ? client.$queryRaw(args[0], ...args.slice(1)) : client.$queryRaw(args)),
|
|
237
|
-
// catch: (error) => convertPrismaError(error, "Prisma", "$queryRaw")
|
|
238
|
-
// }),
|
|
239
|
-
// // eslint-disable-next-line @typescript-eslint/array-type
|
|
240
|
-
// $queryRawUnsafe: (query: string, ...values: any[]) =>
|
|
241
|
-
// Effect.tryPromise({
|
|
242
|
-
// try: () => client.$queryRawUnsafe(query, ...values),
|
|
243
|
-
// catch: (error) => convertPrismaError(error, "Prisma", "$queryRawUnsafe")
|
|
244
|
-
// }),`
|
|
245
|
-
// }
|
|
246
|
-
// function generateModelOperations(models) {
|
|
247
|
-
// return models
|
|
248
|
-
// .map((model) => {
|
|
249
|
-
// const modelName = model.name
|
|
250
|
-
// const modelNameCamel = toCamelCase(modelName)
|
|
251
|
-
// return ` ${modelNameCamel}: {
|
|
252
|
-
// // Find operations
|
|
253
|
-
// findMany: (args?: Prisma.${modelName}FindManyArgs) =>
|
|
254
|
-
// Effect.tryPromise({
|
|
255
|
-
// try: () => client.${modelNameCamel}.findMany(args),
|
|
256
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "findMany")
|
|
257
|
-
// }),
|
|
258
|
-
// findUnique: (args: Prisma.${modelName}FindUniqueArgs) =>
|
|
259
|
-
// Effect.tryPromise({
|
|
260
|
-
// try: () => client.${modelNameCamel}.findUnique(args),
|
|
261
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "findUnique")
|
|
262
|
-
// }),
|
|
263
|
-
// findFirst: (args?: Prisma.${modelName}FindFirstArgs) =>
|
|
264
|
-
// Effect.tryPromise({
|
|
265
|
-
// try: () => client.${modelNameCamel}.findFirst(args),
|
|
266
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "findFirst")
|
|
267
|
-
// }),
|
|
268
|
-
// findUniqueOrThrow: (args: Prisma.${modelName}FindUniqueOrThrowArgs) =>
|
|
269
|
-
// Effect.tryPromise({
|
|
270
|
-
// try: () => client.${modelNameCamel}.findUniqueOrThrow(args),
|
|
271
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "findUniqueOrThrow")
|
|
272
|
-
// }),
|
|
273
|
-
// findFirstOrThrow: (args?: Prisma.${modelName}FindFirstOrThrowArgs) =>
|
|
274
|
-
// Effect.tryPromise({
|
|
275
|
-
// try: () => client.${modelNameCamel}.findFirstOrThrow(args),
|
|
276
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "findFirstOrThrow")
|
|
277
|
-
// }),
|
|
278
|
-
// // Create operations
|
|
279
|
-
// create: (args: Prisma.${modelName}CreateArgs) =>
|
|
280
|
-
// Effect.tryPromise({
|
|
281
|
-
// try: () => client.${modelNameCamel}.create(args),
|
|
282
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "create")
|
|
283
|
-
// }),
|
|
284
|
-
// createMany: (args: Prisma.${modelName}CreateManyArgs) =>
|
|
285
|
-
// Effect.tryPromise({
|
|
286
|
-
// try: () => client.${modelNameCamel}.createMany(args),
|
|
287
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "createMany")
|
|
288
|
-
// }),
|
|
289
|
-
// createManyAndReturn: (args: Prisma.${modelName}CreateManyAndReturnArgs) =>
|
|
290
|
-
// Effect.tryPromise({
|
|
291
|
-
// try: () => client.${modelNameCamel}.createManyAndReturn(args),
|
|
292
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "createManyAndReturn")
|
|
293
|
-
// }),
|
|
294
|
-
// // Update operations
|
|
295
|
-
// update: (args: Prisma.${modelName}UpdateArgs) =>
|
|
296
|
-
// Effect.tryPromise({
|
|
297
|
-
// try: () => client.${modelNameCamel}.update(args),
|
|
298
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "update")
|
|
299
|
-
// }),
|
|
300
|
-
// updateMany: (args: Prisma.${modelName}UpdateManyArgs) =>
|
|
301
|
-
// Effect.tryPromise({
|
|
302
|
-
// try: () => client.${modelNameCamel}.updateMany(args),
|
|
303
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "updateMany")
|
|
304
|
-
// }),
|
|
305
|
-
// upsert: (args: Prisma.${modelName}UpsertArgs) =>
|
|
306
|
-
// Effect.tryPromise({
|
|
307
|
-
// try: () => client.${modelNameCamel}.upsert(args),
|
|
308
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "upsert")
|
|
309
|
-
// }),
|
|
310
|
-
// // Delete operations
|
|
311
|
-
// delete: (args: Prisma.${modelName}DeleteArgs) =>
|
|
312
|
-
// Effect.tryPromise({
|
|
313
|
-
// try: () => client.${modelNameCamel}.delete(args),
|
|
314
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "delete")
|
|
315
|
-
// }),
|
|
316
|
-
// deleteMany: (args?: Prisma.${modelName}DeleteManyArgs) =>
|
|
317
|
-
// Effect.tryPromise({
|
|
318
|
-
// try: () => client.${modelNameCamel}.deleteMany(args),
|
|
319
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "deleteMany")
|
|
320
|
-
// }),
|
|
321
|
-
// // Aggregate operations
|
|
322
|
-
// count: (args?: Prisma.${modelName}CountArgs) =>
|
|
323
|
-
// Effect.tryPromise({
|
|
324
|
-
// try: () => client.${modelNameCamel}.count(args),
|
|
325
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "count")
|
|
326
|
-
// }),
|
|
327
|
-
// aggregate: (args: Prisma.${modelName}AggregateArgs) =>
|
|
328
|
-
// Effect.tryPromise({
|
|
329
|
-
// try: () => client.${modelNameCamel}.aggregate(args),
|
|
330
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "aggregate")
|
|
331
|
-
// }),
|
|
332
|
-
// groupBy: <T extends Prisma.${modelName}GroupByArgs>(args: T) =>
|
|
333
|
-
// Effect.tryPromise({
|
|
334
|
-
// try: () => client.${modelNameCamel}.groupBy(args as any),
|
|
335
|
-
// catch: (error) => convertPrismaError(error, "${modelName}", "groupBy")
|
|
336
|
-
// })
|
|
337
|
-
// }`
|
|
338
|
-
// })
|
|
339
|
-
// .join(',\n\n')
|
|
340
|
-
// }
|
|
341
|
-
// async function generateUnifiedService(models, outputDir) {
|
|
342
|
-
// const errorTypes = generateErrorTypes(models)
|
|
343
|
-
// const errorUnions = generateErrorUnionTypes(models)
|
|
344
|
-
// const rawSqlOperations = generateRawSqlOperations()
|
|
345
|
-
// const modelOperations = generateModelOperations(models)
|
|
346
|
-
// const serviceContent = `${header}
|
|
347
|
-
// import { Context, Data, Effect, Layer } from "effect"
|
|
348
|
-
// import { Service } from "effect/Effect"
|
|
349
|
-
// import { type Prisma, PrismaClient } from "../prisma/index.js"
|
|
350
|
-
// export class PrismaClientService extends Context.Tag("PrismaClientService")<
|
|
351
|
-
// PrismaClientService,
|
|
352
|
-
// {
|
|
353
|
-
// tx: PrismaClient | Prisma.TransactionClient
|
|
354
|
-
// client: PrismaClient
|
|
355
|
-
// }
|
|
356
|
-
// >() {}
|
|
357
|
-
// export const LivePrismaLayer = Layer.effect(
|
|
358
|
-
// PrismaClientService,
|
|
359
|
-
// Effect.sync(() => {
|
|
360
|
-
// const prisma = new PrismaClient()
|
|
361
|
-
// return {
|
|
362
|
-
// // The \`tx\` property (transaction) can be shared and overridden,
|
|
363
|
-
// // but the \`client\` property must always be a PrismaClient instance.
|
|
364
|
-
// tx: prisma,
|
|
365
|
-
// client: prisma
|
|
366
|
-
// }
|
|
367
|
-
// })
|
|
368
|
-
// )
|
|
369
|
-
// ${errorTypes}
|
|
370
|
-
// ${errorUnions}
|
|
371
|
-
// export class PrismaService extends Service<PrismaService>()("PrismaService", {
|
|
372
|
-
// effect: Effect.gen(function* () {
|
|
373
|
-
// const { tx: client } = yield* PrismaClientService
|
|
374
|
-
// return {
|
|
375
|
-
// ${rawSqlOperations}
|
|
376
|
-
// ${modelOperations}
|
|
377
|
-
// }
|
|
378
|
-
// })
|
|
379
|
-
// }) {}
|
|
380
|
-
// `
|
|
381
|
-
// await fs.writeFile(path.join(outputDir, 'index.ts'), serviceContent)
|
|
382
|
-
// }
|
|
383
|
-
// async function generateTypes(models, outputDir) {
|
|
384
|
-
// const modelTypeDefinitions = models
|
|
385
|
-
// .map((model) => {
|
|
386
|
-
// const modelName = model.name
|
|
387
|
-
// const modelNameCamel = toCamelCase(modelName)
|
|
388
|
-
// return ` ${modelNameCamel}: {
|
|
389
|
-
// findMany: (args?: Prisma.${modelName}FindManyArgs) => Effect.Effect<Array<${modelName}>, ${modelName}FindErrors>
|
|
390
|
-
// findUnique: (args: Prisma.${modelName}FindUniqueArgs) => Effect.Effect<${modelName} | null, ${modelName}FindErrors>
|
|
391
|
-
// findFirst: (args?: Prisma.${modelName}FindFirstArgs) => Effect.Effect<${modelName} | null, ${modelName}FindErrors>
|
|
392
|
-
// findUniqueOrThrow: (args: Prisma.${modelName}FindUniqueOrThrowArgs) => Effect.Effect<${modelName}, ${modelName}FindOrThrowErrors>
|
|
393
|
-
// findFirstOrThrow: (args?: Prisma.${modelName}FindFirstOrThrowArgs) => Effect.Effect<${modelName}, ${modelName}FindOrThrowErrors>
|
|
394
|
-
// create: (args: Prisma.${modelName}CreateArgs) => Effect.Effect<${modelName}, ${modelName}CreateErrors>
|
|
395
|
-
// createMany: (args: Prisma.${modelName}CreateManyArgs) => Effect.Effect<Prisma.BatchPayload, ${modelName}CreateErrors>
|
|
396
|
-
// createManyAndReturn: (args: Prisma.${modelName}CreateManyAndReturnArgs) => Effect.Effect<Array<${modelName}>, ${modelName}CreateErrors>
|
|
397
|
-
// update: (args: Prisma.${modelName}UpdateArgs) => Effect.Effect<${modelName}, ${modelName}UpdateErrors>
|
|
398
|
-
// updateMany: (args: Prisma.${modelName}UpdateManyArgs) => Effect.Effect<Prisma.BatchPayload, ${modelName}UpdateErrors>
|
|
399
|
-
// upsert: (args: Prisma.${modelName}UpsertArgs) => Effect.Effect<${modelName}, ${modelName}UpsertErrors>
|
|
400
|
-
// delete: (args: Prisma.${modelName}DeleteArgs) => Effect.Effect<${modelName}, ${modelName}DeleteErrors>
|
|
401
|
-
// deleteMany: (args?: Prisma.${modelName}DeleteManyArgs) => Effect.Effect<Prisma.BatchPayload, ${modelName}DeleteErrors>
|
|
402
|
-
// count: (args?: Prisma.${modelName}CountArgs) => Effect.Effect<number, ${modelName}AggregateErrors>
|
|
403
|
-
// aggregate: (args: Prisma.${modelName}AggregateArgs) => Effect.Effect<any, ${modelName}AggregateErrors>
|
|
404
|
-
// groupBy: <T extends Prisma.${modelName}GroupByArgs>(args: T) => Effect.Effect<any, ${modelName}AggregateErrors>
|
|
405
|
-
// }`
|
|
406
|
-
// })
|
|
407
|
-
// .join('\n')
|
|
408
|
-
// const rawSqlErrorType = 'PrismaConnectionError | PrismaValidationError | PrismaUnknownError'
|
|
409
|
-
// const typeContent = `${header}
|
|
410
|
-
// import type { Effect } from "effect"
|
|
411
|
-
// import type { Prisma } from "../prisma/index.js"
|
|
412
|
-
// import type {
|
|
413
|
-
// ModelName,
|
|
414
|
-
// OperationName,
|
|
415
|
-
// PrismaRecordNotFoundError,
|
|
416
|
-
// PrismaUniqueConstraintError,
|
|
417
|
-
// PrismaForeignKeyConstraintError,
|
|
418
|
-
// PrismaRequiredFieldError,
|
|
419
|
-
// PrismaConnectionError,
|
|
420
|
-
// PrismaValidationError,
|
|
421
|
-
// PrismaUnknownError,
|
|
422
|
-
// ${models.map((model) => ` ${model.name}FindErrors,\n ${model.name}FindOrThrowErrors,\n ${model.name}CreateErrors,\n ${model.name}UpdateErrors,\n ${model.name}UpsertErrors,\n ${model.name}DeleteErrors,\n ${model.name}AggregateErrors`).join(',\n')}
|
|
423
|
-
// } from "./index.js"
|
|
424
|
-
// export type EffectPrismaService = {
|
|
425
|
-
// // eslint-disable-next-line @typescript-eslint/array-type
|
|
426
|
-
// $executeRaw: (args: Prisma.Sql | [Prisma.Sql, ...any[]]) => Effect.Effect<number, ${rawSqlErrorType}>
|
|
427
|
-
// // eslint-disable-next-line @typescript-eslint/array-type
|
|
428
|
-
// $executeRawUnsafe: (query: string, ...values: any[]) => Effect.Effect<number, ${rawSqlErrorType}>
|
|
429
|
-
// // eslint-disable-next-line @typescript-eslint/array-type
|
|
430
|
-
// $queryRaw: (args: Prisma.Sql | [Prisma.Sql, ...any[]]) => Effect.Effect<unknown, ${rawSqlErrorType}>
|
|
431
|
-
// // eslint-disable-next-line @typescript-eslint/array-type
|
|
432
|
-
// $queryRawUnsafe: (query: string, ...values: any[]) => Effect.Effect<unknown, ${rawSqlErrorType}>
|
|
433
|
-
// ${modelTypeDefinitions}
|
|
434
|
-
// }
|
|
435
|
-
// // Individual model types
|
|
436
|
-
// ${models
|
|
437
|
-
// .map(
|
|
438
|
-
// (model) => `
|
|
439
|
-
// // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
440
|
-
// export type ${model.name} = Prisma.${model.name}GetPayload<{}>
|
|
441
|
-
// `,
|
|
442
|
-
// )
|
|
443
|
-
// .join('\n')}
|
|
444
|
-
// `
|
|
445
|
-
// await fs.writeFile(path.join(outputDir, 'types.ts'), typeContent)
|
|
446
|
-
// }
|
package/prisma/dev.db
DELETED
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./index"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./index"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./default"
|
package/prisma/generated/edge.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
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.2.0
|
|
43
|
-
* Query Engine version: 0c8ef2ce45c83248ab3df073180d5eda9e8be7a3
|
|
44
|
-
*/
|
|
45
|
-
Prisma.prismaVersion = {
|
|
46
|
-
client: "7.2.0",
|
|
47
|
-
engine: "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3"
|
|
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.2.0",
|
|
120
|
-
"engineVersion": "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3",
|
|
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/cli.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)
|