Prisma generator producing Effect Schema types with Kysely-compatible column metadata, branded IDs, and intelligent UUID detection.
bun add prisma-effect-kyselygenerator effect_schemas {
provider = "prisma-effect-kysely"
output = "./generated/effect"
}npx prisma generateThree files: enums.ts, types.ts, index.ts.
import { Schema } from "effect";
import { columnType, generated, Selectable } from "prisma-effect-kysely";
// Branded ID
export const UserId = Schema.UUID.pipe(Schema.brand("UserId"));
export type UserId = typeof UserId.Type;
// Model schema
export const User = Schema.Struct({
id: columnType(Schema.UUID, Schema.Never, Schema.Never),
email: Schema.String,
createdAt: generated(Schema.DateFromSelf),
});
export type User = typeof User;
// Kysely DB interface
export interface DB {
User: Selectable<User>;
}import { Selectable, Insertable, Updateable } from "prisma-effect-kysely";
import { User, UserId, DB } from "./generated";
function getUser(id: UserId): Promise<User> { ... }
type UserSelect = Selectable<typeof User>;
type UserInsert = Insertable<typeof User>;
type UserUpdate = Updateable<typeof User>;
const db = new Kysely<DB>({ ... });Schema names are PascalCase regardless of Prisma model name (session_preference → SessionPreference).
@default/@updatedAt→generated()(omitted from insert, optional in update)@idwith@default→columnType(type, Never, Never)(read-only)- Optional fields →
Schema.NullOr(type) - Foreign keys → branded ID type from target model
| Prisma | Effect Schema |
|---|---|
| String | Schema.String |
| Int / Float | Schema.Number |
| BigInt | Schema.BigInt |
| Decimal | Schema.String |
| Boolean | Schema.Boolean |
| DateTime | Schema.DateFromSelf |
| Json | Schema.Unknown |
| Bytes | Schema.Uint8Array |
| Enum | Schema.Literal(...) |
| UUID | Schema.UUID |
Arrays → Schema.Array(t). Nullable → Schema.NullOr(t).
Priority order:
- Native type:
@db.Uuid - Documentation:
@db.Uuidin field comment - Field name pattern:
id,*_id,*_uuid,uuid
Use @customType in field docs to override Effect Schema:
model User {
/// @customType(Schema.String.pipe(Schema.email()))
email String @unique
/// @customType(Schema.Number.pipe(Schema.positive()))
age Int
}Supported on all Prisma scalar types.
Prisma columns A/B map to semantic snake_case fields via Schema.fromKey:
export const ProductToProductTag = Schema.Struct({
product_id: Schema.propertySignature(
columnType(Schema.UUID, Schema.Never, Schema.Never)
).pipe(Schema.fromKey("A")),
product_tag_id: Schema.propertySignature(
columnType(Schema.UUID, Schema.Never, Schema.Never)
).pipe(Schema.fromKey("B")),
});| Entry | Contents |
|---|---|
prisma-effect-kysely |
Type utilities + runtime helpers (default import) |
prisma-effect-kysely/generator |
Prisma generator binary entry |
prisma-effect-kysely/kysely |
getSchemas, columnType, generated, type utils |
prisma-effect-kysely/error |
NotFoundError, QueryError, QueryParseError, ... |
prisma-effect-kysely/runtime |
All runtime utilities |
bun install
bun run test
bun run typecheck
bun run build
bun run prepublishOnly # lint + typecheck + test + buildUses Changesets.
bun changeset # add changeset
git add .changeset/ && git commit -m "docs: changeset"
git pushCI opens a "Version Packages" PR. Merging it publishes to npm, tags, and creates a GitHub release. Requires NPM_TOKEN repo secret.
MIT