@effectify/prisma 0.1.1 → 1.0.0

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 (76) hide show
  1. package/dist/src/cli.d.ts +1 -1
  2. package/dist/src/cli.js +9 -9
  3. package/dist/src/commands/init.d.ts +1 -1
  4. package/dist/src/commands/init.js +0 -2
  5. package/dist/src/commands/prisma.d.ts +5 -0
  6. package/dist/src/commands/prisma.js +35 -0
  7. package/dist/src/generators/sql-schema-generator.d.ts +9 -0
  8. package/dist/src/generators/sql-schema-generator.js +50 -58
  9. package/dist/src/services/generator-context.d.ts +6 -0
  10. package/dist/src/services/generator-context.js +3 -0
  11. package/dist/src/services/generator-service.d.ts +14 -0
  12. package/dist/src/services/generator-service.js +121 -0
  13. package/dist/src/services/render-service.d.ts +10 -0
  14. package/dist/src/services/render-service.js +23 -0
  15. package/dist/src/templates/index-custom-error.eta +190 -0
  16. package/{prisma/generated/effect/index.ts → dist/src/templates/index-default.eta} +4 -38
  17. package/dist/src/templates/model.eta +8 -0
  18. package/dist/src/templates/prisma-raw-sql.eta +31 -0
  19. package/{prisma/generated/effect/prisma-repository.ts → dist/src/templates/prisma-repository.eta} +19 -19
  20. package/package.json +25 -18
  21. package/dist/src/commands/generate-effect.d.ts +0 -2
  22. package/dist/src/commands/generate-effect.js +0 -73
  23. package/dist/src/commands/generate-sql-schema.d.ts +0 -2
  24. package/dist/src/commands/generate-sql-schema.js +0 -72
  25. package/dist/src/effect-prisma.d.ts +0 -2
  26. package/dist/src/effect-prisma.js +0 -1771
  27. package/dist/src/generators/prisma-effect-generator.d.ts +0 -1
  28. package/dist/src/generators/prisma-effect-generator.js +0 -446
  29. package/prisma/dev.db +0 -0
  30. package/prisma/generated/client.d.ts +0 -1
  31. package/prisma/generated/client.js +0 -5
  32. package/prisma/generated/default.d.ts +0 -1
  33. package/prisma/generated/default.js +0 -5
  34. package/prisma/generated/edge.d.ts +0 -1
  35. package/prisma/generated/edge.js +0 -141
  36. package/prisma/generated/effect/schemas/enums.ts +0 -6
  37. package/prisma/generated/effect/schemas/index.ts +0 -2
  38. package/prisma/generated/effect/schemas/types.ts +0 -40
  39. package/prisma/generated/index-browser.js +0 -172
  40. package/prisma/generated/index.d.ts +0 -2360
  41. package/prisma/generated/index.js +0 -141
  42. package/prisma/generated/package.json +0 -144
  43. package/prisma/generated/query_compiler_bg.js +0 -2
  44. package/prisma/generated/query_compiler_bg.wasm +0 -0
  45. package/prisma/generated/query_compiler_bg.wasm-base64.js +0 -2
  46. package/prisma/generated/runtime/client.d.ts +0 -3180
  47. package/prisma/generated/runtime/client.js +0 -86
  48. package/prisma/generated/runtime/index-browser.d.ts +0 -87
  49. package/prisma/generated/runtime/index-browser.js +0 -6
  50. package/prisma/generated/runtime/wasm-compiler-edge.js +0 -76
  51. package/prisma/generated/schema.prisma +0 -31
  52. package/prisma/generated/wasm-edge-light-loader.mjs +0 -5
  53. package/prisma/generated/wasm-worker-loader.mjs +0 -5
  54. package/prisma/migrations/20250721164420_init/migration.sql +0 -9
  55. package/prisma/migrations/20250721191716_dumb/migration.sql +0 -49
  56. package/prisma/migrations/migration_lock.toml +0 -3
  57. package/prisma/schema.prisma +0 -31
  58. package/prisma.config.ts +0 -8
  59. package/project.json +0 -48
  60. package/scripts/cleanup-tests.ts +0 -26
  61. package/scripts/generate-test-files.ts +0 -93
  62. package/setup-tests.ts +0 -10
  63. package/src/cli.tsx +0 -23
  64. package/src/commands/generate-effect.ts +0 -109
  65. package/src/commands/generate-sql-schema.ts +0 -109
  66. package/src/commands/init.ts +0 -155
  67. package/src/effect-prisma.ts +0 -1826
  68. package/src/generators/prisma-effect-generator.ts +0 -496
  69. package/src/generators/sql-schema-generator.ts +0 -75
  70. package/test/prisma-model.test.ts +0 -340
  71. package/test/utils.ts +0 -10
  72. package/tsconfig.json +0 -20
  73. package/tsconfig.lib.json +0 -24
  74. package/tsconfig.spec.json +0 -15
  75. package/vitest.config.ts +0 -23
  76. /package/{prisma/generated/effect/prisma-schema.ts → dist/src/templates/prisma-schema.eta} +0 -0
@@ -0,0 +1,8 @@
1
+ import * as Model from "../prisma-repository.js"
2
+ import { <%= it.model.name %>, <%= it.model.name %>Id } from "../schemas/index.js"
3
+
4
+ export class <%= it.model.name %>Model extends Model.Class<<%= it.model.name %>Model>("<%= it.model.name %>")({
5
+ ...<%= it.model.name %>.fields
6
+ }) {}
7
+
8
+ export { <%= it.model.name %>, <%= it.model.name %>Id }
@@ -0,0 +1,31 @@
1
+ $executeRaw: (args: PrismaNamespace.Sql | [PrismaNamespace.Sql, ...any[]]): Effect.Effect<number, <%= it.errorType %>, PrismaClient> =>
2
+ Effect.flatMap(PrismaClient, ({ tx: client }) =>
3
+ Effect.tryPromise({
4
+ try: () => (Array.isArray(args) ? client.$executeRaw(args[0], ...args.slice(1)) : client.$executeRaw(args)),
5
+ catch: (error) => mapError(error, "$executeRaw", "Prisma")
6
+ })
7
+ ),
8
+
9
+ $executeRawUnsafe: (query: string, ...values: any[]): Effect.Effect<number, <%= it.errorType %>, PrismaClient> =>
10
+ Effect.flatMap(PrismaClient, ({ tx: client }) =>
11
+ Effect.tryPromise({
12
+ try: () => client.$executeRawUnsafe(query, ...values),
13
+ catch: (error) => mapError(error, "$executeRawUnsafe", "Prisma")
14
+ })
15
+ ),
16
+
17
+ $queryRaw: <T = unknown>(args: PrismaNamespace.Sql | [PrismaNamespace.Sql, ...any[]]): Effect.Effect<T, <%= it.errorType %>, PrismaClient> =>
18
+ Effect.flatMap(PrismaClient, ({ tx: client }) =>
19
+ Effect.tryPromise({
20
+ try: () => (Array.isArray(args) ? client.$queryRaw(args[0], ...args.slice(1)) : client.$queryRaw(args)) as Promise<T>,
21
+ catch: (error) => mapError(error, "$queryRaw", "Prisma")
22
+ })
23
+ ),
24
+
25
+ $queryRawUnsafe: <T = unknown>(query: string, ...values: any[]): Effect.Effect<T, <%= it.errorType %>, PrismaClient> =>
26
+ Effect.flatMap(PrismaClient, ({ tx: client }) =>
27
+ Effect.tryPromise({
28
+ try: () => client.$queryRawUnsafe(query, ...values) as Promise<T>,
29
+ catch: (error) => mapError(error, "$queryRawUnsafe", "Prisma")
30
+ })
31
+ ),
@@ -2,7 +2,7 @@
2
2
  /** biome-ignore-all lint/style/useDefaultSwitchClause: <todo> */
3
3
 
4
4
  import * as VariantSchema from '@effect/experimental/VariantSchema'
5
- import { type PrismaClient as BasePrismaClient, Prisma as PrismaNamespace } from '@prisma/client'
5
+ import { type PrismaClient as BasePrismaClient, Prisma as PrismaNamespace } from '<%= it.clientImportPath %>'
6
6
  import { PrismaClient } from './index.js'
7
7
  import * as Data from 'effect/Data'
8
8
  import * as Effect from 'effect/Effect'
@@ -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
  }),
package/package.json CHANGED
@@ -1,44 +1,51 @@
1
1
  {
2
2
  "name": "@effectify/prisma",
3
- "version": "0.1.1",
3
+ "version": "1.0.0",
4
4
  "description": "",
5
- "main": "index.js",
5
+ "main": "./dist/src/cli.js",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "bin": {
9
- "effect-prisma": "./src/effect-prisma.ts"
9
+ "effect-prisma": "./dist/src/cli.js"
10
10
  },
11
11
  "exports": {
12
- "./prisma": "./prisma/index.ts"
12
+ ".": "./dist/src/cli.js",
13
+ "./prisma": "./dist/prisma/index.js"
13
14
  },
15
+ "files": [
16
+ "dist"
17
+ ],
14
18
  "publishConfig": {
15
19
  "access": "public"
16
20
  },
17
21
  "keywords": [],
18
22
  "author": "",
19
23
  "dependencies": {
20
- "@effect/cli": "0.70.0",
21
- "@effect/platform": "0.91.1",
22
- "@effect/platform-node": "0.97.1",
23
- "@prisma/adapter-better-sqlite3": "7.0.0",
24
- "@prisma/client": "7.0.0",
25
- "@prisma/generator": "^7.0.1",
26
- "@prisma/generator-helper": "7.0.0",
24
+ "@effect/cli": "0.73.0",
25
+ "@prisma/adapter-better-sqlite3": "7.3.0",
26
+ "@prisma/generator": "7.3.0",
27
+ "@prisma/generator-helper": "7.3.0",
27
28
  "better-sqlite3": "12.4.6",
28
- "effect": "3.17.14",
29
- "kysely": "0.28.8",
30
- "prisma-effect-kysely": "1.13.1"
29
+ "eta": "^4.5.0",
30
+ "kysely": "0.28.8"
31
+ },
32
+ "peerDependencies": {
33
+ "@effect/platform": "0.94.0",
34
+ "@effect/platform-node": "0.104.0",
35
+ "effect": "3.19.13",
36
+ "@prisma/client": "7.3.0"
31
37
  },
32
38
  "devDependencies": {
39
+ "prisma-effect-kysely": "5.2.0",
33
40
  "@effect/build-utils": "0.8.9",
34
- "@effect/experimental": "0.57.8",
41
+ "@effect/experimental": "0.58.0",
35
42
  "@effect/language-service": "0.56.0",
36
43
  "@effect/vitest": "0.27.0",
37
- "@prisma/internals": "7.0.0",
44
+ "@prisma/internals": "7.3.0",
38
45
  "@types/better-sqlite3": "7.6.13",
39
46
  "@types/node": "20.19.25",
40
47
  "bun": "1.3.0",
41
- "prisma": "7.0.0",
48
+ "prisma": "7.3.0",
42
49
  "tsx": "4.20.6",
43
50
  "typescript": "5.9.3",
44
51
  "vite-tsconfig-paths": "5.1.4",
@@ -48,6 +55,6 @@
48
55
  "prisma:generate": "pnpm dlx prisma generate",
49
56
  "test": "vitest",
50
57
  "dev": "tsx src/messaround.ts",
51
- "cli": "pnpm dlx tsx src/cli.tsx"
58
+ "cli": "pnpm dlx tsx src/cli.ts"
52
59
  }
53
60
  }
@@ -1,2 +0,0 @@
1
- import * as Command from '@effect/cli/Command';
2
- export declare const generateEffectCommand: Command.Command<"generate-effect", never, Error | import("@effect/platform/Error").PlatformError, {}>;
@@ -1,73 +0,0 @@
1
- import * as Command from '@effect/cli/Command';
2
- import * as FileSystem from '@effect/platform/FileSystem';
3
- import * as NodeFileSystem from '@effect/platform-node/NodeFileSystem';
4
- import * as NodePath from '@effect/platform-node/NodePath';
5
- import * as Console from 'effect/Console';
6
- import * as Effect from 'effect/Effect';
7
- import * as Match from 'effect/Match';
8
- // import { generateEffectPrisma } from '../generators/prisma-effect-generator.js'
9
- // Check if file exists
10
- const fileExists = (path) => Effect.gen(function* () {
11
- const fs = yield* FileSystem.FileSystem;
12
- return yield* fs.exists(path);
13
- });
14
- // Detect package manager using pattern matching
15
- const detectPackageManager = () => Effect.gen(function* () {
16
- const pnpmExists = yield* fileExists('pnpm-lock.yaml');
17
- const bunExists = yield* fileExists('bun.lockb');
18
- const npmExists = yield* fileExists('package-lock.json');
19
- // Create a tuple to match against
20
- const lockFiles = [pnpmExists, bunExists, npmExists];
21
- return Match.value(lockFiles).pipe(Match.when([true, false, false], () => 'pnpm'), Match.when([false, true, false], () => 'bun'), Match.when([false, false, true], () => 'npm'), Match.orElse(() => 'npm'));
22
- });
23
- // Check if Prisma schema exists
24
- const checkPrismaSchema = () => Effect.gen(function* () {
25
- const schemaExists = yield* fileExists('prisma/schema.prisma');
26
- if (!schemaExists) {
27
- yield* Console.log('❌ Prisma schema not found.');
28
- yield* Console.log('');
29
- yield* Console.log('Please run the following command first:');
30
- const packageManager = yield* detectPackageManager();
31
- const initCommand = Match.value(packageManager).pipe(Match.when('pnpm', () => 'pnpm dlx prisma init'), Match.when('bun', () => 'bunx prisma init'), Match.when('npm', () => 'npx prisma init'), Match.exhaustive);
32
- yield* Console.log(` ${initCommand}`);
33
- yield* Effect.fail(new Error('Prisma schema not found'));
34
- }
35
- });
36
- // Execute the Effect generator
37
- const generateEffectServices = () => Effect.gen(function* () {
38
- // Check if we're being called by Prisma (no interactive output)
39
- const isCalledByPrisma = process.env.PRISMA_GENERATOR_INVOCATION === 'true' ||
40
- process.argv.includes('--generator') ||
41
- !process.stdout.isTTY;
42
- if (!isCalledByPrisma) {
43
- yield* Console.log('🔧 Running Effect generator...');
44
- }
45
- // Check if Prisma schema exists
46
- yield* checkPrismaSchema();
47
- // Note: We don't need to check for local generator files
48
- // since we're importing from our own package
49
- if (!isCalledByPrisma) {
50
- yield* Console.log('🚀 Executing Effect generator...');
51
- }
52
- // Execute the generator function
53
- yield* Effect.tryPromise({
54
- try: () => {
55
- // Create mock options for the generator
56
- // const mockOptions = {
57
- // dmmf: { datamodel: { models: [] } }, // Empty models for now
58
- // generator: { output: { value: 'src/generated/effect-prisma' } },
59
- // }
60
- return Promise.resolve();
61
- // return generateEffectPrisma(mockOptions)
62
- },
63
- catch: (error) => new Error(`Generator execution failed: ${error}`),
64
- });
65
- if (!isCalledByPrisma) {
66
- yield* Console.log('✅ Effect generator executed successfully!');
67
- yield* Console.log('💡 Generated files are available in the configured output directory');
68
- }
69
- // Ensure the effect completes and exits
70
- yield* Effect.sync(() => process.exit(0));
71
- });
72
- // Export the generate-effect command
73
- export const generateEffectCommand = Command.make('generate-effect', {}, () => generateEffectServices().pipe(Effect.provide(NodeFileSystem.layer), Effect.provide(NodePath.layer)));
@@ -1,2 +0,0 @@
1
- import * as Command from '@effect/cli/Command';
2
- export declare const generateSqlSchemaCommand: Command.Command<"generate-sql-schema", never, Error | import("@effect/platform/Error").PlatformError, {}>;
@@ -1,72 +0,0 @@
1
- import * as Command from '@effect/cli/Command';
2
- import * as FileSystem from '@effect/platform/FileSystem';
3
- import * as NodeFileSystem from '@effect/platform-node/NodeFileSystem';
4
- import * as NodePath from '@effect/platform-node/NodePath';
5
- import * as Console from 'effect/Console';
6
- import * as Effect from 'effect/Effect';
7
- import * as Match from 'effect/Match';
8
- // import { generateSqlSchema } from '../generators/sql-schema-generator.js'
9
- // Check if file exists
10
- const fileExists = (path) => Effect.gen(function* () {
11
- const fs = yield* FileSystem.FileSystem;
12
- return yield* fs.exists(path);
13
- });
14
- // Detect package manager using pattern matching
15
- const detectPackageManager = () => Effect.gen(function* () {
16
- const pnpmExists = yield* fileExists('pnpm-lock.yaml');
17
- const bunExists = yield* fileExists('bun.lockb');
18
- const npmExists = yield* fileExists('package-lock.json');
19
- // Create a tuple to match against
20
- const lockFiles = [pnpmExists, bunExists, npmExists];
21
- return Match.value(lockFiles).pipe(Match.when([true, false, false], () => 'pnpm'), Match.when([false, true, false], () => 'bun'), Match.when([false, false, true], () => 'npm'), Match.orElse(() => 'npm'));
22
- });
23
- // Check if Prisma schema exists
24
- const checkPrismaSchema = () => Effect.gen(function* () {
25
- const schemaExists = yield* fileExists('prisma/schema.prisma');
26
- if (!schemaExists) {
27
- yield* Console.log('❌ Prisma schema not found.');
28
- yield* Console.log('');
29
- yield* Console.log('Please run the following command first:');
30
- const packageManager = yield* detectPackageManager();
31
- const initCommand = Match.value(packageManager).pipe(Match.when('pnpm', () => 'pnpm dlx prisma init'), Match.when('bun', () => 'bunx prisma init'), Match.when('npm', () => 'npx prisma init'), Match.exhaustive);
32
- yield* Console.log(` ${initCommand}`);
33
- yield* Effect.fail(new Error('Prisma schema not found'));
34
- }
35
- });
36
- // Execute the SQL schema generator
37
- const generateSqlSchemaServices = () => Effect.gen(function* () {
38
- // Check if we're being called by Prisma (no interactive output)
39
- const isCalledByPrisma = process.env.PRISMA_GENERATOR_INVOCATION === 'true' ||
40
- process.argv.includes('--generator') ||
41
- !process.stdout.isTTY;
42
- if (!isCalledByPrisma) {
43
- yield* Console.log('🔧 Running SQL schema generator...');
44
- }
45
- // Check if Prisma schema exists
46
- yield* checkPrismaSchema();
47
- // Note: We don't need to check for local generator files
48
- // since we're importing from our own package
49
- if (!isCalledByPrisma) {
50
- yield* Console.log('🚀 Executing SQL schema generator...');
51
- }
52
- // Execute the generator function
53
- yield* Effect.tryPromise({
54
- try: () => {
55
- // Create mock options for the generator
56
- // const mockOptions = {
57
- // generator: { output: { value: 'src/generated' } },
58
- // }
59
- // return generateSqlSchema(mockOptions)
60
- return Promise.resolve();
61
- },
62
- catch: (error) => new Error(`Generator execution failed: ${error}`),
63
- });
64
- if (!isCalledByPrisma) {
65
- yield* Console.log('✅ SQL schema generator executed successfully!');
66
- yield* Console.log('💡 Generated files are available in the configured output directory');
67
- }
68
- // Ensure the effect completes and exits
69
- yield* Effect.sync(() => process.exit(0));
70
- });
71
- // Export the generate-sql-schema command
72
- export const generateSqlSchemaCommand = Command.make('generate-sql-schema', {}, () => generateSqlSchemaServices().pipe(Effect.provide(NodeFileSystem.layer), Effect.provide(NodePath.layer)));
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env -S pnpm dlx tsx
2
- export {};