@effectify/prisma 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@effectify/prisma",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "bin": {
9
- "effect-prisma": "./src/effect-prisma.ts"
9
+ "effect-prisma": "./src/cli.ts"
10
10
  },
11
11
  "exports": {
12
12
  "./prisma": "./prisma/index.ts"
@@ -17,21 +17,24 @@
17
17
  "keywords": [],
18
18
  "author": "",
19
19
  "dependencies": {
20
- "@effect/cli": "0.70.0",
21
- "@effect/platform": "0.91.1",
22
- "@effect/platform-node": "0.97.1",
20
+ "@effect/cli": "0.73.0",
23
21
  "@prisma/adapter-better-sqlite3": "7.0.0",
24
- "@prisma/client": "7.0.0",
25
22
  "@prisma/generator": "^7.0.1",
26
23
  "@prisma/generator-helper": "7.0.0",
27
24
  "better-sqlite3": "12.4.6",
28
- "effect": "3.17.14",
29
- "kysely": "0.28.8",
30
- "prisma-effect-kysely": "1.13.1"
25
+ "eta": "^4.5.0",
26
+ "kysely": "0.28.8"
27
+ },
28
+ "peerDependencies": {
29
+ "@effect/platform": "0.94.0",
30
+ "@effect/platform-node": "0.104.0",
31
+ "effect": "3.19.13",
32
+ "@prisma/client": "7.0.0"
31
33
  },
32
34
  "devDependencies": {
35
+ "prisma-effect-kysely": "1.13.1",
33
36
  "@effect/build-utils": "0.8.9",
34
- "@effect/experimental": "0.57.8",
37
+ "@effect/experimental": "0.58.0",
35
38
  "@effect/language-service": "0.56.0",
36
39
  "@effect/vitest": "0.27.0",
37
40
  "@prisma/internals": "7.0.0",
@@ -48,6 +51,6 @@
48
51
  "prisma:generate": "pnpm dlx prisma generate",
49
52
  "test": "vitest",
50
53
  "dev": "tsx src/messaround.ts",
51
- "cli": "pnpm dlx tsx src/cli.tsx"
54
+ "cli": "pnpm dlx tsx src/cli.ts"
52
55
  }
53
56
  }
package/prisma/dev.db CHANGED
Binary file
@@ -39,12 +39,12 @@ exports.Prisma = Prisma
39
39
  exports.$Enums = {}
40
40
 
41
41
  /**
42
- * Prisma Client JS version: 7.0.0
43
- * Query Engine version: 0c19ccc313cf9911a90d99d2ac2eb0280c76c513
42
+ * Prisma Client JS version: 7.2.0
43
+ * Query Engine version: 0c8ef2ce45c83248ab3df073180d5eda9e8be7a3
44
44
  */
45
45
  Prisma.prismaVersion = {
46
- client: "7.0.0",
47
- engine: "0c19ccc313cf9911a90d99d2ac2eb0280c76c513"
46
+ client: "7.2.0",
47
+ engine: "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3"
48
48
  }
49
49
 
50
50
  Prisma.PrismaClientKnownRequestError = PrismaClientKnownRequestError;
@@ -116,10 +116,10 @@ exports.Prisma.ModelName = {
116
116
  */
117
117
  const config = {
118
118
  "previewFeatures": [],
119
- "clientVersion": "7.0.0",
120
- "engineVersion": "0c19ccc313cf9911a90d99d2ac2eb0280c76c513",
119
+ "clientVersion": "7.2.0",
120
+ "engineVersion": "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3",
121
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"
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
123
  }
124
124
 
125
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\":{}}")
@@ -3,8 +3,6 @@
3
3
  import { Context, Data, Effect, Exit, Layer } from "effect"
4
4
  import { Service } from "effect/Effect"
5
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
6
 
9
7
  // Symbol used to identify intentional rollbacks vs actual errors
10
8
  const ROLLBACK = Symbol.for("prisma.effect.rollback")
@@ -338,8 +336,7 @@ export class Prisma extends Service<Prisma>()("Prisma", {
338
336
  )
339
337
  }
340
338
  ),
341
-
342
- $executeRaw: (args: PrismaNamespace.Sql | [PrismaNamespace.Sql, ...any[]]): Effect.Effect<number, PrismaError, PrismaClient> =>
339
+ $executeRaw: (args: PrismaNamespace.Sql | [PrismaNamespace.Sql, ...any[]]): Effect.Effect<number, PrismaError, PrismaClient> =>
343
340
  Effect.flatMap(PrismaClient, ({ tx: client }) =>
344
341
  Effect.tryPromise({
345
342
  try: () => (Array.isArray(args) ? client.$executeRaw(args[0], ...args.slice(1)) : client.$executeRaw(args)),
@@ -392,6 +389,4 @@ export const PrismaService = Prisma
392
389
  export const makePrismaLayer = PrismaClient.layer
393
390
  export const makePrismaLayerEffect = PrismaClient.layerEffect
394
391
 
395
- export class TodoModel extends Model.Class<TodoModel>("Todo")({
396
- ..._Todo.fields
397
- }) {}
392
+ export * from "./models/Todo.js"
@@ -0,0 +1,6 @@
1
+ import * as Model from "../prisma-repository.js"
2
+ import { _Todo } from "../schemas/index.js"
3
+
4
+ export class TodoModel extends Model.Class<TodoModel>("Todo")({
5
+ ..._Todo.fields
6
+ }) {}
@@ -387,7 +387,7 @@ export {
387
387
  * @since 1.0.0
388
388
  * @category constructors
389
389
  * @example
390
- * ```ts
390
+ * \`\`\`ts
391
391
  * import { Schema } from "effect"
392
392
  * import { Model } from "@effect/sql"
393
393
  *
@@ -420,7 +420,7 @@ export {
420
420
  * return this.name.toUpperCase()
421
421
  * }
422
422
  * }
423
- * ```
423
+ * \`\`\`
424
424
  */
425
425
  Class,
426
426
  /**
@@ -585,7 +585,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
585
585
  ): Effect.Effect<Option.Option<S['Type']>, never, S['Context'] | S['findUnique']['Context']> =>
586
586
  findUniqueSchema((args as any).where).pipe(
587
587
  Effect.catchTag('ParseError', Effect.die),
588
- Effect.withSpan(`${options.spanPrefix}.findUnique`, {
588
+ Effect.withSpan(`\${options.spanPrefix}.findUnique`, {
589
589
  captureStackTrace: false,
590
590
  attributes: { ...(args as any).where },
591
591
  }),
@@ -611,7 +611,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
611
611
  Effect.map((result) => result as S['Type']),
612
612
  Effect.catchTag('ParseError', Effect.die),
613
613
  Effect.catchTag('NoSuchElementException', Effect.die),
614
- Effect.withSpan(`${options.spanPrefix}.findUniqueOrThrow`, {
614
+ Effect.withSpan(`\${options.spanPrefix}.findUniqueOrThrow`, {
615
615
  captureStackTrace: false,
616
616
  attributes: { ...(args as any).where },
617
617
  }),
@@ -633,7 +633,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
633
633
  ): Effect.Effect<Option.Option<S['Type']>, never, S['Context'] | S['findFirst']['Context']> =>
634
634
  findFirstSchema(args).pipe(
635
635
  Effect.catchTag('ParseError', Effect.die),
636
- Effect.withSpan(`${options.spanPrefix}.findFirst`, {
636
+ Effect.withSpan(`\${options.spanPrefix}.findFirst`, {
637
637
  captureStackTrace: false,
638
638
  attributes: { ...(args as any) },
639
639
  }),
@@ -657,7 +657,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
657
657
  Effect.map((result) => result as S['Type']),
658
658
  Effect.catchTag('ParseError', Effect.die),
659
659
  Effect.catchTag('NoSuchElementException', Effect.die),
660
- Effect.withSpan(`${options.spanPrefix}.findFirstOrThrow`, {
660
+ Effect.withSpan(`\${options.spanPrefix}.findFirstOrThrow`, {
661
661
  captureStackTrace: false,
662
662
  attributes: { ...(args as any) },
663
663
  }),
@@ -679,7 +679,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
679
679
  ): Effect.Effect<Array<S['Type']>, never, S['Context'] | S['findMany']['Context']> =>
680
680
  findManySchema(args).pipe(
681
681
  Effect.catchTag('ParseError', Effect.die),
682
- Effect.withSpan(`${options.spanPrefix}.findMany`, {
682
+ Effect.withSpan(`\${options.spanPrefix}.findMany`, {
683
683
  captureStackTrace: false,
684
684
  attributes: { ...(args as any) },
685
685
  }),
@@ -701,7 +701,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
701
701
  createSchema((args as any).data).pipe(
702
702
  Effect.catchTag('ParseError', Effect.die),
703
703
  Effect.catchTag('NoSuchElementException', Effect.die),
704
- Effect.withSpan(`${options.spanPrefix}.create`, {
704
+ Effect.withSpan(`\${options.spanPrefix}.create`, {
705
705
  captureStackTrace: false,
706
706
  attributes: { ...(args as any).data },
707
707
  }),
@@ -725,7 +725,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
725
725
  Effect.map((res) => res as unknown as PrismaNamespace.BatchPayload),
726
726
  Effect.catchTag('ParseError', Effect.die),
727
727
  Effect.catchTag('NoSuchElementException', Effect.die),
728
- Effect.withSpan(`${options.spanPrefix}.createMany`, {
728
+ Effect.withSpan(`\${options.spanPrefix}.createMany`, {
729
729
  captureStackTrace: false,
730
730
  attributes: { ...(args as any).data },
731
731
  }),
@@ -749,7 +749,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
749
749
  ): Effect.Effect<Array<S['Type']>, never, S['Context'] | S['createManyAndReturn']['Context']> =>
750
750
  createManyAndReturnSchema((args as any).data).pipe(
751
751
  Effect.catchTag('ParseError', Effect.die),
752
- Effect.withSpan(`${options.spanPrefix}.createManyAndReturn`, {
752
+ Effect.withSpan(`\${options.spanPrefix}.createManyAndReturn`, {
753
753
  captureStackTrace: false,
754
754
  attributes: { ...(args as any).data },
755
755
  }),
@@ -771,7 +771,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
771
771
  countSchema(args).pipe(
772
772
  Effect.catchTag('ParseError', Effect.die),
773
773
  Effect.catchTag('NoSuchElementException', Effect.die),
774
- Effect.withSpan(`${options.spanPrefix}.count`, {
774
+ Effect.withSpan(`\${options.spanPrefix}.count`, {
775
775
  captureStackTrace: false,
776
776
  attributes: { ...(args as any) },
777
777
  }),
@@ -793,7 +793,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
793
793
  updateSchema(args).pipe(
794
794
  Effect.catchTag('ParseError', Effect.die),
795
795
  Effect.catchTag('NoSuchElementException', Effect.die),
796
- Effect.withSpan(`${options.spanPrefix}.update`, {
796
+ Effect.withSpan(`\${options.spanPrefix}.update`, {
797
797
  captureStackTrace: false,
798
798
  attributes: { ...(args as any) },
799
799
  }),
@@ -815,7 +815,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
815
815
  deleteSchema(args).pipe(
816
816
  Effect.catchTag('ParseError', Effect.die),
817
817
  Effect.catchTag('NoSuchElementException', Effect.die),
818
- Effect.withSpan(`${options.spanPrefix}.delete`, {
818
+ Effect.withSpan(`\${options.spanPrefix}.delete`, {
819
819
  captureStackTrace: false,
820
820
  attributes: { ...(args as any) },
821
821
  }),
@@ -837,7 +837,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
837
837
  upsertSchema(args).pipe(
838
838
  Effect.catchTag('ParseError', Effect.die),
839
839
  Effect.catchTag('NoSuchElementException', Effect.die),
840
- Effect.withSpan(`${options.spanPrefix}.upsert`, {
840
+ Effect.withSpan(`\${options.spanPrefix}.upsert`, {
841
841
  captureStackTrace: false,
842
842
  attributes: { ...(args as any) },
843
843
  }),
@@ -859,7 +859,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
859
859
  aggregateSchema(args).pipe(
860
860
  Effect.catchTag('ParseError', Effect.die),
861
861
  Effect.catchTag('NoSuchElementException', Effect.die),
862
- Effect.withSpan(`${options.spanPrefix}.aggregate`, {
862
+ Effect.withSpan(`\${options.spanPrefix}.aggregate`, {
863
863
  captureStackTrace: false,
864
864
  attributes: { ...(args as any) },
865
865
  }),
@@ -880,7 +880,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
880
880
  ): Effect.Effect<unknown, never, S['Context']> =>
881
881
  groupBySchema(args).pipe(
882
882
  Effect.catchTag('ParseError', Effect.die),
883
- Effect.withSpan(`${options.spanPrefix}.groupBy`, {
883
+ Effect.withSpan(`\${options.spanPrefix}.groupBy`, {
884
884
  captureStackTrace: false,
885
885
  attributes: { ...(args as any) },
886
886
  }),
@@ -903,7 +903,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
903
903
  Effect.map((res) => res as unknown as PrismaNamespace.BatchPayload),
904
904
  Effect.catchTag('ParseError', Effect.die),
905
905
  Effect.catchTag('NoSuchElementException', Effect.die),
906
- Effect.withSpan(`${options.spanPrefix}.updateMany`, {
906
+ Effect.withSpan(`\${options.spanPrefix}.updateMany`, {
907
907
  captureStackTrace: false,
908
908
  attributes: { ...(args as any) },
909
909
  }),
@@ -926,7 +926,7 @@ export const make = <S extends Any, M extends keyof BasePrismaClient>(
926
926
  Effect.map((res) => res as unknown as PrismaNamespace.BatchPayload),
927
927
  Effect.catchTag('ParseError', Effect.die),
928
928
  Effect.catchTag('NoSuchElementException', Effect.die),
929
- Effect.withSpan(`${options.spanPrefix}.deleteMany`, {
929
+ Effect.withSpan(`\${options.spanPrefix}.deleteMany`, {
930
930
  captureStackTrace: false,
931
931
  attributes: { ...(args as any) },
932
932
  }),
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated: 2025-12-19T02:36:20.247Z
2
+ * Generated: 2025-12-22T03:33:11.297Z
3
3
  * DO NOT EDIT MANUALLY
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated: 2025-12-19T02:36:20.248Z
2
+ * Generated: 2025-12-22T03:33:11.298Z
3
3
  * DO NOT EDIT MANUALLY
4
4
  */
5
5
 
@@ -24,12 +24,12 @@ exports.Prisma = Prisma
24
24
  exports.$Enums = {}
25
25
 
26
26
  /**
27
- * Prisma Client JS version: 7.0.0
28
- * Query Engine version: 0c19ccc313cf9911a90d99d2ac2eb0280c76c513
27
+ * Prisma Client JS version: 7.2.0
28
+ * Query Engine version: 0c8ef2ce45c83248ab3df073180d5eda9e8be7a3
29
29
  */
30
30
  Prisma.prismaVersion = {
31
- client: "7.0.0",
32
- engine: "0c19ccc313cf9911a90d99d2ac2eb0280c76c513"
31
+ client: "7.2.0",
32
+ engine: "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3"
33
33
  }
34
34
 
35
35
  Prisma.PrismaClientKnownRequestError = () => {
@@ -31,7 +31,7 @@ export type Todo = $Result.DefaultSelection<Prisma.$TodoPayload>
31
31
  * ```
32
32
  *
33
33
  *
34
- * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client).
34
+ * Read more in our [docs](https://pris.ly/d/client).
35
35
  */
36
36
  export class PrismaClient<
37
37
  ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
@@ -52,7 +52,7 @@ export class PrismaClient<
52
52
  * ```
53
53
  *
54
54
  *
55
- * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client).
55
+ * Read more in our [docs](https://pris.ly/d/client).
56
56
  */
57
57
 
58
58
  constructor(optionsArg ?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>);
@@ -75,7 +75,7 @@ export class PrismaClient<
75
75
  * const result = await prisma.$executeRaw`UPDATE User SET cool = ${true} WHERE email = ${'user@email.com'};`
76
76
  * ```
77
77
  *
78
- * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
78
+ * Read more in our [docs](https://pris.ly/d/raw-queries).
79
79
  */
80
80
  $executeRaw<T = unknown>(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise<number>;
81
81
 
@@ -87,7 +87,7 @@ export class PrismaClient<
87
87
  * const result = await prisma.$executeRawUnsafe('UPDATE User SET cool = $1 WHERE email = $2 ;', true, 'user@email.com')
88
88
  * ```
89
89
  *
90
- * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
90
+ * Read more in our [docs](https://pris.ly/d/raw-queries).
91
91
  */
92
92
  $executeRawUnsafe<T = unknown>(query: string, ...values: any[]): Prisma.PrismaPromise<number>;
93
93
 
@@ -98,7 +98,7 @@ export class PrismaClient<
98
98
  * const result = await prisma.$queryRaw`SELECT * FROM User WHERE id = ${1} OR email = ${'user@email.com'};`
99
99
  * ```
100
100
  *
101
- * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
101
+ * Read more in our [docs](https://pris.ly/d/raw-queries).
102
102
  */
103
103
  $queryRaw<T = unknown>(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise<T>;
104
104
 
@@ -110,7 +110,7 @@ export class PrismaClient<
110
110
  * const result = await prisma.$queryRawUnsafe('SELECT * FROM User WHERE id = $1 OR email = $2;', 1, 'user@email.com')
111
111
  * ```
112
112
  *
113
- * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access).
113
+ * Read more in our [docs](https://pris.ly/d/raw-queries).
114
114
  */
115
115
  $queryRawUnsafe<T = unknown>(query: string, ...values: any[]): Prisma.PrismaPromise<T>;
116
116
 
@@ -195,8 +195,8 @@ export namespace Prisma {
195
195
  export import Exact = $Public.Exact
196
196
 
197
197
  /**
198
- * Prisma Client JS version: 7.0.0
199
- * Query Engine version: 0c19ccc313cf9911a90d99d2ac2eb0280c76c513
198
+ * Prisma Client JS version: 7.2.0
199
+ * Query Engine version: 0c8ef2ce45c83248ab3df073180d5eda9e8be7a3
200
200
  */
201
201
  export type PrismaVersion = {
202
202
  client: string
@@ -727,7 +727,7 @@ export namespace Prisma {
727
727
  * { emit: 'stdout', level: 'error' }
728
728
  *
729
729
  * ```
730
- * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/logging#the-log-option).
730
+ * Read more in our [docs](https://pris.ly/d/logging).
731
731
  */
732
732
  log?: (LogLevel | LogDefinition)[]
733
733
  /**
@@ -763,6 +763,22 @@ export namespace Prisma {
763
763
  * ```
764
764
  */
765
765
  omit?: Prisma.GlobalOmitConfig
766
+ /**
767
+ * SQL commenter plugins that add metadata to SQL queries as comments.
768
+ * Comments follow the sqlcommenter format: https://google.github.io/sqlcommenter/
769
+ *
770
+ * @example
771
+ * ```
772
+ * const prisma = new PrismaClient({
773
+ * adapter,
774
+ * comments: [
775
+ * traceContext(),
776
+ * queryInsights(),
777
+ * ],
778
+ * })
779
+ * ```
780
+ */
781
+ comments?: runtime.SqlCommenterPlugin[]
766
782
  }
767
783
  export type GlobalOmitConfig = {
768
784
  todo?: TodoOmit
@@ -39,12 +39,12 @@ exports.Prisma = Prisma
39
39
  exports.$Enums = {}
40
40
 
41
41
  /**
42
- * Prisma Client JS version: 7.0.0
43
- * Query Engine version: 0c19ccc313cf9911a90d99d2ac2eb0280c76c513
42
+ * Prisma Client JS version: 7.2.0
43
+ * Query Engine version: 0c8ef2ce45c83248ab3df073180d5eda9e8be7a3
44
44
  */
45
45
  Prisma.prismaVersion = {
46
- client: "7.0.0",
47
- engine: "0c19ccc313cf9911a90d99d2ac2eb0280c76c513"
46
+ client: "7.2.0",
47
+ engine: "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3"
48
48
  }
49
49
 
50
50
  Prisma.PrismaClientKnownRequestError = PrismaClientKnownRequestError;
@@ -117,10 +117,10 @@ exports.Prisma.ModelName = {
117
117
  */
118
118
  const config = {
119
119
  "previewFeatures": [],
120
- "clientVersion": "7.0.0",
121
- "engineVersion": "0c19ccc313cf9911a90d99d2ac2eb0280c76c513",
120
+ "clientVersion": "7.2.0",
121
+ "engineVersion": "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3",
122
122
  "activeProvider": "sqlite",
123
- "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
+ "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"
124
124
  }
125
125
 
126
126
  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\":{}}")
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "prisma-client-6049e14c78939c23b21f84476c179957d3bf141bcd454f540cf8461d1c5d40bc",
2
+ "name": "prisma-client-c2036edccdea0fc0f3eabd0a7a86ac999c01bb6043fee901fc5748228f0d90d3",
3
3
  "main": "index.js",
4
4
  "types": "index.d.ts",
5
5
  "browser": "default.js",
@@ -109,10 +109,10 @@
109
109
  },
110
110
  "./*": "./*"
111
111
  },
112
- "version": "7.0.0",
112
+ "version": "7.2.0",
113
113
  "sideEffects": false,
114
114
  "dependencies": {
115
- "@prisma/client-runtime-utils": "7.0.0"
115
+ "@prisma/client-runtime-utils": "7.2.0"
116
116
  },
117
117
  "imports": {
118
118
  "#wasm-compiler-loader": {
@@ -12,7 +12,7 @@ generator effect_schemas {
12
12
  }
13
13
 
14
14
  generator effect {
15
- provider = "tsx ./src/effect-prisma.ts"
15
+ provider = "tsx ./src/cli.ts"
16
16
  output = "./generated/effect"
17
17
  clientImportPath = "@prisma/client"
18
18
  importFileExtension = "js"
@@ -12,7 +12,7 @@ generator effect_schemas {
12
12
  }
13
13
 
14
14
  generator effect {
15
- provider = "tsx ./src/effect-prisma.ts"
15
+ provider = "tsx ./src/cli.ts"
16
16
  output = "./generated/effect"
17
17
  clientImportPath = "@prisma/client"
18
18
  importFileExtension = "js"
package/src/cli.ts ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env -S pnpm dlx tsx
2
+
3
+ import * as Command from '@effect/cli/Command'
4
+ import * as NodeContext from '@effect/platform-node/NodeContext'
5
+ import * as NodeRuntime from '@effect/platform-node/NodeRuntime'
6
+ import * as Effect from 'effect/Effect'
7
+ import * as Layer from 'effect/Layer'
8
+ import { initCommand } from './commands/init.js'
9
+ import { prismaCommand } from './commands/prisma.js'
10
+ import { GeneratorService } from './services/generator-service.js'
11
+ import { RenderService } from './services/render-service.js'
12
+
13
+ const cli = Command.run(prismaCommand.pipe(Command.withSubcommands([initCommand])), {
14
+ name: '@effectify/prisma CLI',
15
+ version: '0.1.0',
16
+ })
17
+
18
+ const GeneratorLayer = GeneratorService.Live.pipe(Layer.provide(RenderService.Live), Layer.provide(NodeContext.layer))
19
+
20
+ const MainLayer = Layer.mergeAll(GeneratorLayer, RenderService.Live, NodeContext.layer)
21
+
22
+ cli(process.argv).pipe(Effect.provide(MainLayer), NodeRuntime.runMain)
@@ -138,11 +138,9 @@ generator sqlSchema {
138
138
  yield* Console.log(' 2. Run: @effectify/prisma prisma generate-effect')
139
139
  yield* Console.log(' 3. Run: @effectify/prisma prisma generate-sql-schema')
140
140
 
141
- // Ensure the effect completes and exits
142
141
  yield* Effect.sync(() => process.exit(0))
143
142
  })
144
143
 
145
- // Export the init command
146
144
  export const initCommand = Command.make(
147
145
  'init',
148
146
  {
@@ -0,0 +1,50 @@
1
+ import * as Command from '@effect/cli/Command'
2
+ import type * as NodeContext from '@effect/platform-node/NodeContext'
3
+ import type { GeneratorOptions } from '@prisma/generator-helper'
4
+ import generatorHelper from '@prisma/generator-helper'
5
+ import * as Deferred from 'effect/Deferred'
6
+ import * as Effect from 'effect/Effect'
7
+ import * as Layer from 'effect/Layer'
8
+ import * as Runtime from 'effect/Runtime'
9
+ import * as Stream from 'effect/Stream'
10
+ import { GeneratorContext } from '../services/generator-context.js'
11
+ import { GeneratorService } from '../services/generator-service.js'
12
+ import type { RenderService } from '../services/render-service.js'
13
+
14
+ export const prismaCommand = Command.make('prisma', {}, () =>
15
+ Effect.gen(function* () {
16
+ const generator = yield* GeneratorService
17
+ const runtime = yield* Effect.runtime<GeneratorService | RenderService | NodeContext.NodeContext>()
18
+ const run = Runtime.runPromise(runtime)
19
+
20
+ const events = Stream.async<[GeneratorOptions, Deferred.Deferred<void, unknown>]>((emit) => {
21
+ generatorHelper.generatorHandler({
22
+ onManifest() {
23
+ return {
24
+ defaultOutput: '../generated/effect',
25
+ prettyName: 'Prisma Effect Generator',
26
+ requiresEngines: [],
27
+ }
28
+ },
29
+ async onGenerate(options) {
30
+ await run(
31
+ Effect.gen(function* () {
32
+ const deferred = yield* Deferred.make<void, unknown>()
33
+ yield* Effect.promise(() => emit.single([options, deferred]))
34
+ yield* Deferred.await(deferred)
35
+ }),
36
+ )
37
+ },
38
+ })
39
+ })
40
+
41
+ yield* events.pipe(
42
+ Stream.runForEach(([options, deferred]) =>
43
+ generator.generate.pipe(
44
+ Effect.provide(Layer.succeed(GeneratorContext, options)),
45
+ Effect.intoDeferred(deferred),
46
+ ),
47
+ ),
48
+ )
49
+ }),
50
+ )
@@ -10,8 +10,6 @@ const header = `-- This file was generated by sql-schema-generator, do not edit
10
10
  -- Generated at: ${new Date().toISOString()}
11
11
 
12
12
  `
13
-
14
- // Types for generator options
15
13
  type SqlGeneratorOptions = {
16
14
  generator: {
17
15
  output?: {
@@ -20,7 +18,6 @@ type SqlGeneratorOptions = {
20
18
  }
21
19
  }
22
20
 
23
- // Export the generator function for use in CLI
24
21
  export async function generateSqlSchema(options: SqlGeneratorOptions) {
25
22
  const outputDir = options.generator.output?.value || '../generated'
26
23
  const datasourceUrl = 'prisma/dev.db'
@@ -29,25 +26,19 @@ export async function generateSqlSchema(options: SqlGeneratorOptions) {
29
26
  throw new Error('No datasource URL found')
30
27
  }
31
28
 
32
- // Ensure output directory exists
33
29
  await fs.mkdir(outputDir, { recursive: true })
34
30
 
35
31
  try {
36
- // Extract the database path from the URL (assuming sqlite)
37
32
  let dbPath = datasourceUrl
38
33
  if (dbPath.startsWith('file:')) {
39
34
  dbPath = dbPath.replace('file:', '')
40
35
  }
41
36
 
42
- // Make path relative to current working directory if needed
43
37
  if (!path.isAbsolute(dbPath)) {
44
38
  dbPath = path.resolve(process.cwd(), dbPath)
45
39
  }
46
40
 
47
- // Use sqlite3 to dump only the schema (no data)
48
41
  const schemaOutput = execSync(`sqlite3 "${dbPath}" ".schema"`, { encoding: 'utf8' })
49
-
50
- // Write the schema to the output file
51
42
  const outputPath = path.join(outputDir, 'schema.sql')
52
43
  await fs.writeFile(outputPath, header + schemaOutput)
53
44
  } catch (error) {
@@ -0,0 +1,4 @@
1
+ import type { GeneratorOptions } from '@prisma/generator-helper'
2
+ import * as Context from 'effect/Context'
3
+
4
+ export class GeneratorContext extends Context.Tag('GeneratorContext')<GeneratorContext, GeneratorOptions>() {}