@dashild/prisma 0.1.0-alpha.4 → 0.1.0-alpha.7
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 +40 -23
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @dashild/prisma
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The official Prisma generator. Declare it in `schema.prisma`:
|
|
4
4
|
|
|
5
5
|
```prisma
|
|
6
6
|
generator client {
|
|
@@ -14,36 +14,47 @@ generator dashild {
|
|
|
14
14
|
}
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
It writes **one file**: `dashild-metadata.json`. It does not generate resources,
|
|
18
|
+
pages, or clients.
|
|
18
19
|
|
|
19
|
-
##
|
|
20
|
+
## What the artifact contains
|
|
20
21
|
|
|
21
|
-
|
|
|
22
|
+
| Field | Purpose |
|
|
22
23
|
| --- | --- |
|
|
23
|
-
| `formatVersion` | Dashild
|
|
24
|
-
| `schemaPath` |
|
|
25
|
-
| `clientOutput` |
|
|
26
|
-
| `engineVersion` | Hash
|
|
27
|
-
| `models` |
|
|
28
|
-
| `enums` |
|
|
24
|
+
| `formatVersion` | Dashild rejects metadata in a format it does not understand |
|
|
25
|
+
| `schemaPath` | Absolute path to the source schema |
|
|
26
|
+
| `clientOutput` | Absolute path to the Prisma client, when a `prisma-client` generator exists |
|
|
27
|
+
| `engineVersion` | Hash of the engine Prisma used (diagnostic) |
|
|
28
|
+
| `models` | Fields, types, enums, relations, `nativeType`, read-only flags |
|
|
29
|
+
| `enums` | Name and values |
|
|
29
30
|
|
|
30
|
-
`engineVersion`
|
|
31
|
+
`engineVersion` is not the Prisma version: Prisma 7's `options.version` is the
|
|
32
|
+
engine commit. The package version is not exposed to the generator.
|
|
31
33
|
|
|
32
|
-
##
|
|
34
|
+
## Provider resolution (verified with Prisma 7.10.1)
|
|
33
35
|
|
|
34
|
-
**Prisma
|
|
36
|
+
**Prisma does not resolve `provider` as a Node module.** It runs the string
|
|
37
|
+
through `/bin/sh`. `provider = "dashild-prisma-generator"` works only because the
|
|
38
|
+
package publishes a `bin` with that name and npm/pnpm put `node_modules/.bin` on
|
|
39
|
+
`PATH` when running scripts.
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
Consequently, `pnpm prisma generate` (or `npm run ...`) works; invoking the
|
|
42
|
+
Prisma binary from an environment without that `PATH` fails with
|
|
43
|
+
`dashild-prisma-generator: command not found`. The error is explicit, not silent.
|
|
37
44
|
|
|
38
45
|
## Prisma 7
|
|
39
46
|
|
|
40
|
-
-
|
|
41
|
-
|
|
47
|
+
- The datasource `url` is no longer declared in the schema: it lives in
|
|
48
|
+
`prisma.config.ts` or in the client constructor. The fixture does not declare
|
|
49
|
+
it because `generate` does not connect.
|
|
50
|
+
- `@prisma/generator-helper` is CommonJS: the entrypoint loads it with
|
|
51
|
+
`createRequire`, not a named ESM import.
|
|
42
52
|
|
|
43
|
-
##
|
|
53
|
+
## Code
|
|
44
54
|
|
|
45
|
-
- `src/generator.ts` — entrypoint.
|
|
46
|
-
|
|
55
|
+
- `src/generator.ts` — entrypoint. It only registers the handler and writes the
|
|
56
|
+
file.
|
|
57
|
+
- `src/extract.ts` — DMMF → `DashildMetadata`. Pure functions, tested separately.
|
|
47
58
|
|
|
48
59
|
## Tests
|
|
49
60
|
|
|
@@ -51,9 +62,15 @@ Consecuencia: `pnpm prisma generate` (o `npm run ...`) funciona; invocar el bina
|
|
|
51
62
|
pnpm --filter @dashild/prisma test
|
|
52
63
|
```
|
|
53
64
|
|
|
54
|
-
|
|
65
|
+
Two levels:
|
|
55
66
|
|
|
56
|
-
- **
|
|
57
|
-
|
|
67
|
+
- **Integration**: runs a real `prisma generate` over
|
|
68
|
+
`test/fixtures/hostile/schema.prisma` (enum, optionals, `Decimal`, `BigInt`,
|
|
69
|
+
`Json`, `Bytes`, `@db.Text`, `@db.Uuid`, m2o, o2m, and self-relation) and
|
|
70
|
+
verifies the JSON.
|
|
71
|
+
- **Unit**: `resolveClientOutput` with synthetic generators, including the
|
|
72
|
+
`provider` from an environment variable.
|
|
58
73
|
|
|
59
|
-
|
|
74
|
+
The test needs the generator `bin` on `PATH`; it resolves it from the monorepo
|
|
75
|
+
root `.bin`, where pnpm links `@dashild/prisma` (declared as a root
|
|
76
|
+
devDependency for exactly this reason).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashild/prisma",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Official Prisma generator that extracts the metadata Dashild consumes",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dashild/core": "0.1.0-alpha.
|
|
20
|
+
"@dashild/core": "0.1.0-alpha.7",
|
|
21
21
|
"@prisma/generator-helper": "7.10.1"
|
|
22
22
|
},
|
|
23
23
|
"main": "./dist/generator.js",
|