@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,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)));
|