prisma-effect-schema-generator 0.1.3 → 0.1.4
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/README.md +41 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ updated) on every regeneration.
|
|
|
89
89
|
| `dateAs` | `"DateFromSelf"` | `"Date"` (ISO-string codec) or `"DateFromSelf"` (accepts native `Date`). |
|
|
90
90
|
| `exportModelNames` | `"true"` | Emit `export const ALL_MODEL_NAMES = [...] as const`. |
|
|
91
91
|
| `exportModelNameType` | `"true"` | Emit `export type ModelName = "X" | "Y"`. |
|
|
92
|
-
| `standardSchemaV1` | `"false"` | Wrap
|
|
92
|
+
| `standardSchemaV1` | `"false"` | Wrap schemas in `Schema.standardSchemaV1(...)`. Narrows `Context` to `never` so libraries like TanStack DB accept the schema directly. |
|
|
93
93
|
| `relationColumns` | `"false"` | Emit a separate `Schema.Struct` for each relation that has explicit local foreign-key columns. |
|
|
94
94
|
| `idColumn` | `"false"` | Emit `PRIMARY_KEY_COLUMNS` map from model name to primary-key column (or `null`). |
|
|
95
95
|
| `softDeleteColumn` | `"false"` | Emit `SOFT_DELETE_COLUMNS` map from model name to detected soft-delete column. |
|
|
@@ -168,9 +168,9 @@ export const TABLES: { [M in ModelName]: TableDescriptor } = {
|
|
|
168
168
|
primaryKey: "id",
|
|
169
169
|
softDelete: "deletedAt",
|
|
170
170
|
columns: [
|
|
171
|
-
{ name: "id"
|
|
172
|
-
{ name: "email"
|
|
173
|
-
{ name: "deletedAt"
|
|
171
|
+
{ name: "id", type: 'string', required: true, list: false, unique: true, isEnum: false },
|
|
172
|
+
{ name: "email", type: 'string', required: true, list: false, unique: false, isEnum: false },
|
|
173
|
+
{ name: "deletedAt", type: 'date', required: false, list: false, unique: false, isEnum: false },
|
|
174
174
|
],
|
|
175
175
|
includedInSync: true,
|
|
176
176
|
},
|
|
@@ -249,9 +249,17 @@ export const UserSchema = Schema.standardSchemaV1(Schema.Struct({
|
|
|
249
249
|
email: Schema.String,
|
|
250
250
|
}))
|
|
251
251
|
|
|
252
|
-
//
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
// The wrapped schema still works as an Effect Schema...
|
|
253
|
+
Schema.decodeUnknownSync(UserSchema)({ id: "u1", email: "a@b.c" })
|
|
254
|
+
|
|
255
|
+
// ...and is accepted directly by Standard Schema consumers without
|
|
256
|
+
// casting Context to `never`:
|
|
257
|
+
import { createCollection } from "@tanstack/db"
|
|
258
|
+
|
|
259
|
+
const users = createCollection({
|
|
260
|
+
id: "users",
|
|
261
|
+
schema: UserSchema, // Context is `never`, no `as never` needed
|
|
262
|
+
})
|
|
255
263
|
```
|
|
256
264
|
|
|
257
265
|
## Programmatic use
|
|
@@ -300,6 +308,32 @@ npm test # vitest
|
|
|
300
308
|
npm run typecheck # tsc --noEmit
|
|
301
309
|
```
|
|
302
310
|
|
|
311
|
+
## Related projects
|
|
312
|
+
|
|
313
|
+
### How is this different from `effect-prisma-generator`?
|
|
314
|
+
|
|
315
|
+
This project is focused on **generating Effect Schema values** from your
|
|
316
|
+
Prisma schema—standalone, serializable validators you can use anywhere
|
|
317
|
+
(read-path validation, sync engines, RPC payloads, form validation, etc.).
|
|
318
|
+
|
|
319
|
+
[`m9tdev/effect-prisma-generator`](https://github.com/m9tdev/effect-prisma-generator)
|
|
320
|
+
takes the opposite approach: it generates an **Effect-native service wrapper
|
|
321
|
+
around Prisma Client**, so every Prisma operation returns an `Effect` and
|
|
322
|
+
plugs into Effect's `Layer` / `Context` system. It is great if you want to
|
|
323
|
+
run Prisma through Effect's runtime.
|
|
324
|
+
|
|
325
|
+
| | `prisma-effect-schema-generator` | `effect-prisma-generator` |
|
|
326
|
+
|---|---|---|
|
|
327
|
+
| Output | `Schema.Struct` values + introspection maps | `PrismaService` Effect service |
|
|
328
|
+
| Needs Prisma Client at runtime | No | Yes |
|
|
329
|
+
| Primary use case | Validate rows / introspect schema | Execute Prisma operations in Effect |
|
|
330
|
+
| Relations | Optional `relationColumns` schemas | Full Prisma Client relation API |
|
|
331
|
+
| Errors | Standard `Schema` decode errors | Typed `PrismaError` unions |
|
|
332
|
+
|
|
333
|
+
If you need Effect-powered Prisma Client operations, use
|
|
334
|
+
`effect-prisma-generator`. If you need portable Effect schemas and metadata
|
|
335
|
+
from your schema, use this package.
|
|
336
|
+
|
|
303
337
|
## License
|
|
304
338
|
|
|
305
339
|
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-effect-schema-generator",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Prisma generator that emits Effect Schema values for every model — drop-in validation for your database rows.",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Prisma generator that emits Effect Schema values, relation schemas, and runtime introspection maps (primary keys, soft-delete columns, table descriptors) for every model — drop-in validation for your database rows.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prisma",
|
|
7
7
|
"prisma-generator",
|