@domain-first/project-structure 8.8.0 → 8.9.0
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 +3 -3
- package/dist/287.js +397 -250
- package/dist/947.js +4 -0
- package/dist/agent-cli.d.ts +2 -1
- package/dist/agent-requests.d.ts +2 -0
- package/dist/graph.cjs +4 -0
- package/dist/index.cjs +401 -250
- package/dist/init.cjs +41 -37
- package/dist/integration.cjs +402 -251
- package/dist/integrations/drizzle.d.ts +8 -0
- package/dist/integrations/drizzle.spec.d.ts +1 -0
- package/dist/integrations/index.d.ts +1 -0
- package/dist/integrations/testcontainers.d.ts +1 -1
- package/dist/lint.cjs +4 -0
- package/dist/react.cjs +401 -250
- package/dist/use-cases/add-integration.d.ts +3 -3
- package/package.json +1 -1
- package/skills/df-ps-project-scripts/SKILL.md +22 -5
- package/skills/df-ps-scaffold/references/agent-operations.md +2 -1
- package/skills/df-ps-scaffold/references/generators.md +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Integrations are shown by group, but selected ones run in this order, each one seeing the changes of
|
|
3
3
|
* the previous ones: Storybook configures `frontend.react` for the Swagger UI page
|
|
4
|
-
* of OpenAPI, integration tests read the Prisma
|
|
4
|
+
* of OpenAPI, integration tests read the Prisma and Drizzle configs and the Vitest
|
|
5
5
|
* config, Orval reads the OpenAPI document path.
|
|
6
6
|
*/
|
|
7
|
-
export declare const integrationIds: readonly ["storybook", "rest-endpoint-generator", "in-memory-db", "prisma", "vitest", "playwright", "testcontainers", "openapi", "orval"];
|
|
7
|
+
export declare const integrationIds: readonly ["storybook", "rest-endpoint-generator", "in-memory-db", "prisma", "drizzle", "vitest", "playwright", "testcontainers", "openapi", "orval"];
|
|
8
8
|
export declare const addIntegration: ({ save }?: {
|
|
9
9
|
save?: boolean;
|
|
10
10
|
}) => Promise<string[]>;
|
|
11
11
|
export declare const integrationDescriptions: () => {
|
|
12
|
-
id: "prisma" | "openapi" | "orval" | "rest-endpoint-generator" | "storybook" | "vitest" | "testcontainers" | "in-memory-db" | "playwright";
|
|
12
|
+
id: "prisma" | "drizzle" | "openapi" | "orval" | "rest-endpoint-generator" | "storybook" | "vitest" | "testcontainers" | "in-memory-db" | "playwright";
|
|
13
13
|
name: string;
|
|
14
14
|
group: "backend" | "frontend";
|
|
15
15
|
available: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: df-ps-project-scripts
|
|
3
|
-
description: Rules for running this project's own scripts (package.json) and handling the files they produce — Prisma contract (`contract.prisma`, `prisma:emit`), database migrations (`prisma:migration:plan`, `prisma:migration:apply`), and other codegen. Use when a change needs new or changed database data (models, fields), when planning or creating a migration, when regenerating contract types, or when the user asks to run any project script that writes files.
|
|
3
|
+
description: Rules for running this project's own scripts (package.json) and handling the files they produce — Prisma contract (`contract.prisma`, `prisma:emit`), Drizzle schema (`schema.ts`), database migrations (`prisma:migration:plan`, `prisma:migration:apply`, `drizzle:generate`, `drizzle:migrate`), and other codegen. Use when a change needs new or changed database data (models, fields), when planning or creating a migration, when regenerating contract types, or when the user asks to run any project script that writes files.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Project scripts
|
|
@@ -9,9 +9,9 @@ The project's scripts live in `package.json`. Run them through `npm run <script>
|
|
|
9
9
|
|
|
10
10
|
## Rules
|
|
11
11
|
|
|
12
|
-
1. **No approval needed.** Files written by the project's own scripts (`prisma:emit`, `prisma:migration:plan`, …) aren't "new files" under `df-ps-scaffold` rule 1: run these scripts yourself when the work needs them. Still list them under "Tool runs" in a work plan so the user sees them coming, and report every run.
|
|
13
|
-
2. **The database is changed only by a human.** Never run `prisma:migration:apply` or anything else that touches the database (`prisma db
|
|
14
|
-
3. **Script output is never edited.** Generated migrations, `contract.json`, `contract.d.ts`, and any other output are used as-is: no edits, no deletions, no hand-written copies. Output is wrong → change the source (`contract.prisma`) and run the script again; if that can't fix it (a wrong migration already exists), stop and tell the user.
|
|
12
|
+
1. **No approval needed.** Files written by the project's own scripts (`prisma:emit`, `prisma:migration:plan`, `drizzle:generate`, …) aren't "new files" under `df-ps-scaffold` rule 1: run these scripts yourself when the work needs them. Still list them under "Tool runs" in a work plan so the user sees them coming, and report every run.
|
|
13
|
+
2. **The database is changed only by a human.** Never run `prisma:migration:apply`, `drizzle:migrate` or anything else that touches the database (`prisma db …`, `drizzle-kit push`). When a migration is ready, give the user the command (`! npm run prisma:migration:apply`, `! npm run drizzle:migrate`) and wait.
|
|
14
|
+
3. **Script output is never edited.** Generated migrations, `contract.json`, `contract.d.ts`, and any other output are used as-is: no edits, no deletions, no hand-written copies. Output is wrong → change the source (`contract.prisma`, `schema.ts`) and run the script again; if that can't fix it (a wrong migration already exists), stop and tell the user.
|
|
15
15
|
|
|
16
16
|
## Prisma
|
|
17
17
|
|
|
@@ -27,7 +27,7 @@ Config: `shared-kernel/infrastructure/prisma/prisma.config.ts`. Source: `shared-
|
|
|
27
27
|
|
|
28
28
|
Only when domain and application logic are implemented, and implementing an infrastructure module (repository, command/query) needs data the database doesn't have yet. Not earlier "just in case", and never as the first step of a feature: the domain decides what's stored, not the schema.
|
|
29
29
|
|
|
30
|
-
Order: domain → application → `contract.prisma` + migration → user applies it → infrastructure → endpoints → other codegen → React.
|
|
30
|
+
Order: domain → application → `contract.prisma` / `schema.ts` + migration → user applies it → infrastructure → endpoints → other codegen → React.
|
|
31
31
|
|
|
32
32
|
### Making a migration
|
|
33
33
|
|
|
@@ -38,3 +38,20 @@ Order: domain → application → `contract.prisma` + migration → user applies
|
|
|
38
38
|
5. Check the output: the planned files only, nothing else changed. Report each migration and ask the user to apply them before implementing the infrastructure that depends on them.
|
|
39
39
|
|
|
40
40
|
Types only (no storage change, e.g. after pulling someone's contract change): `npm run prisma:emit`.
|
|
41
|
+
|
|
42
|
+
## Drizzle
|
|
43
|
+
|
|
44
|
+
Config: `shared-kernel/infrastructure/drizzle/drizzle.config.ts`. Source: `shared-kernel/infrastructure/drizzle/schema.ts` (edit by hand, tables with `drizzle-orm/pg-core`). Output: `migrations/` next to it (SQL files and `meta/`, from `drizzle:generate`). The database is created in `shared-kernel/infrastructure/services/drizzle-infrastructure-service.ts`; implementations import tables from `schema.ts`.
|
|
45
|
+
|
|
46
|
+
| Script | Does | Who runs it |
|
|
47
|
+
| ------------------ | ------------------------------------------------------------ | ----------------- |
|
|
48
|
+
| `drizzle:generate` | Writes a SQL migration from the change in `schema.ts`. Offline. | You |
|
|
49
|
+
| `drizzle:migrate` | Applies migrations to the database. | **The user only** |
|
|
50
|
+
|
|
51
|
+
When to migrate: as for Prisma above.
|
|
52
|
+
|
|
53
|
+
1. Edit `schema.ts` for **one** logical change.
|
|
54
|
+
2. Generate it with a name by meaning: `npm run drizzle:generate -- --name add-user`.
|
|
55
|
+
3. Several changes → repeat 1–2 once per change.
|
|
56
|
+
4. When `drizzle:generate` asks whether a column or table is created or renamed, it waits for an answer you can't give: stop it, and ask the user to run `! npm run drizzle:generate -- --name <name>` and answer it.
|
|
57
|
+
5. Check the output: the new SQL file and `meta/` only. Report each migration and ask the user to apply them before implementing the infrastructure that depends on them.
|
|
@@ -139,9 +139,10 @@ Use `operation: "add"` and a nonempty `integrations` array. Select only IDs mark
|
|
|
139
139
|
| `rest-endpoint-generator` | Backend must have `@domain-first/handlers-rest`. `nextAdapter` applies only when `frontend.react.framework` is `next`; omitted means no Next adapter in JSON mode. Existing support files are preserved with a manual connection note as needed. |
|
|
140
140
|
| `in-memory-db` | Backend required. Enables the DB flag and restores missing support files while keeping edited files. No extra fields. |
|
|
141
141
|
| `prisma` | Backend required. `withService` defaults to true; false skips the infrastructure service and its wire. Registers `prisma` implementation choices. Existing incompatible Prisma setups are rejected rather than upgraded. |
|
|
142
|
+
| `drizzle` | Backend required. `withService` defaults to true; false skips the infrastructure service and its wire. Registers `drizzle` implementation choices. A `drizzle.config.*` in the project root is rejected as an existing setup. |
|
|
142
143
|
| `vitest` | Backend required. `replaceTestingLibrary` is required if a different testing library is configured; true changes it to Vitest, false skips this setup. |
|
|
143
144
|
| `playwright` | No extra integration-specific fields. Adds its config, example and scripts. |
|
|
144
|
-
| `testcontainers` | Backend required. With wire: optional `integrationTestTypes`, the saved primary types whose implementations get integration specs (omitted: the configured list stays); missing specs of existing primary implementations are added. Reads staged Prisma/Vitest setup when selected together. Database scripts are generated, not executed. |
|
|
145
|
+
| `testcontainers` | Backend required. With wire: optional `integrationTestTypes`, the saved primary types whose implementations get integration specs (omitted: the configured list stays); missing specs of existing primary implementations are added. Reads staged Prisma/Drizzle/Vitest setup when selected together. Database scripts are generated, not executed. |
|
|
145
146
|
| `openapi` | Backend with `handlers-rest`. `routePrefix` defaults to `/api`; `openapiPath` is computed from the project unless supplied. `withExtractor` defaults to true. `swaggerPage` applies only with React configured and defaults to true there; otherwise omit it. |
|
|
146
147
|
| `orval` | Requires configured `handlers-rest`. `openapiPath` is read from the staged/existing OpenAPI generator when omitted. With React configured, `targets` can be a nonempty list of `hooks`/`client` and defaults to `hooks`. Without React, omit `targets`: the typed client is generated automatically. |
|
|
147
148
|
|
|
@@ -35,7 +35,7 @@ Each chosen module goes into the wire (`wireClass(X, [wireUserRepository])`) and
|
|
|
35
35
|
|
|
36
36
|
An env-branched wire (repository, command/query, port) wires each implementation in isolation: it asks `Dependencies for <Implementation>:` once per implementation, in the order of the wire (main, then test). Each list leaves out only what that implementation already has, and a list with nothing to choose is skipped.
|
|
37
37
|
|
|
38
|
-
It may start with a `Suggested` group, which holds only the system service of the implementation: `prisma-infrastructure-service` for `prisma`, `in-memory-db-infrastructure-service` for `in-memory`. It is listed there only and is **checked**: omitting the implementation's group in JSON keeps it, `[]` selects none. Any other service is an ordinary unchecked item in `Infrastructure services`, whatever its name, so select it explicitly.
|
|
38
|
+
It may start with a `Suggested` group, which holds only the system service of the implementation: `prisma-infrastructure-service` for `prisma`, `drizzle-infrastructure-service` for `drizzle`, `in-memory-db-infrastructure-service` for `in-memory`. It is listed there only and is **checked**: omitting the implementation's group in JSON keeps it, `[]` selects none. Any other service is an ordinary unchecked item in `Infrastructure services`, whatever its name, so select it explicitly.
|
|
39
39
|
|
|
40
40
|
## Remembered and system implementation types
|
|
41
41
|
|