feat: port generator to Effect v4 and Prisma 7#24
Open
timzolleis wants to merge 2 commits into
Open
Conversation
- migrate context services: Context.Tag → Context.Service with inverted type params - remove Runtime<R>; use Effect.context<R>() + Effect.runPromiseExitWith(services) - add explicit static layer = Layer.effect(this, this.make) (no auto .Default in v4) - update test runner: Command → ChildProcess/ChildProcessSpawner, FileSystem from effect barrel - upgrade dependencies: effect@4.0.0-beta.83, @effect/vitest@4.0.0-beta.83, @effect/platform-node@4.0.0-beta.83, prisma@^7.8.0 - update docs: .Default → .layer, add v4 beta compatibility note - all 12 tests pass including transaction commit/rollback and error preservation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
Effect v4 is in beta now (and becoming more popular!) - on the discord, people start working with it and its being recommended more and more. Since we use prisma (and this repo) pretty heavily, and want to get started on the v4 migration, having effect v4 support would mean a lot to us
Disclaimer from my side: I opened the PR to main, but I think while effect v4 is in beta, it would make more sense to maintain a separate v4 branch - but thats up to you :)
Summary
Ports the generated
PrismaServiceto Effect v4 (effect@4.0.0-beta.x) and bumps Prisma to 7.8.0. The emitted code now uses the v4 service and runtime APIs:Context.Servicein place ofContext.Tag, an explicit layer in place of the auto-generated.Default, andEffect.context+Effect.runPromiseExitWithinside$transaction(theRuntime<R>API it relied on was removed in v4). The only consumer-facing change isPrismaService.DefaultbecomingPrismaService.layer.Changes
Context.TagtoContext.Service(type params first, id passed to the returned constructor)Service(..., { effect })withContext.Service(..., { make })and add an explicitstatic readonly layer = Layer.effect(this, this.make)$transactionto capture the context withEffect.contextand run it withEffect.runPromiseExitWith, sinceRuntime<R>and its runners no longer exist in v4ChildProcess/ChildProcessSpawner,NodeServices, andFileSystemfrom theeffectbarrel)effect,@effect/vitest, and@effect/platform-nodeto4.0.0-beta.83, andprisma/@prisma/*to^7.8.0.layerand add a v4 beta compatibility noteTesting
All existing integration tests pass (12 total), including transaction commit, rollback, nested transactions, and custom-error preservation, which exercise the new
Effect.context/runPromiseExitWithbridge. The generatedeffect.tsalso typechecks againsteffect@4.0.0-beta.83. Effect v4 is still in beta, so its APIs may shift between releases.Thanks for the great library, especially the transaction API is pretty cool!