@rawsql-ts/ztd-cli 0.19.0 → 0.20.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
CHANGED
|
@@ -111,7 +111,7 @@ How to read that layout:
|
|
|
111
111
|
* `src/domain`, `src/application`, and `src/presentation/http` are where generic WebAPI work should begin.
|
|
112
112
|
* `src/infrastructure/persistence`, `src/sql`, `src/catalog`, and `ztd/ddl` are the ZTD-owned persistence side.
|
|
113
113
|
* `tests/generated` is generated output. Recreate it with `ztd ztd-config` instead of editing it manually.
|
|
114
|
-
*
|
|
114
|
+
* Optional AI guidance files can be generated when you explicitly request them, but the default scaffold stays focused on consumer-facing project files.
|
|
115
115
|
|
|
116
116
|
## Choose The Right Happy Path
|
|
117
117
|
|
|
@@ -158,8 +158,6 @@ After `ztd init` you should see:
|
|
|
158
158
|
| `tests/smoke.validation.test.ts` | Validator integration smoke test |
|
|
159
159
|
| `tests/support/testkit-client.ts` | Driver wiring placeholder |
|
|
160
160
|
| `src/catalog/specs/` | Spec and runtime files for the smoke contract |
|
|
161
|
-
| `CONTEXT.md` | Agent-focused project invariants and recommended command usage |
|
|
162
|
-
| `.ztd/agents/manifest.json` | Managed AI guidance index with security notices and entrypoints |
|
|
163
161
|
|
|
164
162
|
```bash
|
|
165
163
|
# 4. Generate test types from the demo DDL
|
|
@@ -184,6 +182,7 @@ All smoke tests should pass. You now have a working ZTD project.
|
|
|
184
182
|
|
|
185
183
|
* Replace the demo DDL with your own schema, or inspect an explicit target with `npx ztd ddl pull --url <target>`
|
|
186
184
|
* Re-run `npx ztd ztd-config` whenever DDL changes (or use `--watch`)
|
|
185
|
+
* Add AI guidance files only if you want them in the repo: `npx ztd init --with-ai-guidance`
|
|
187
186
|
* Install visible AGENTS files only if you want them in the repo: `npx ztd agents install`
|
|
188
187
|
* Wire a real driver in `tests/support/testkit-client.ts` (see [adapter-node-pg](../adapters/adapter-node-pg) for Postgres)
|
|
189
188
|
* Write domain tests against generated `TestRowMap` types
|
|
@@ -214,6 +213,7 @@ mkdir /tmp/my-ztd-dogfood && cd /tmp/my-ztd-dogfood
|
|
|
214
213
|
node "<LOCAL_SOURCE_ROOT>/packages/ztd-cli/dist/index.js" init \
|
|
215
214
|
--workflow empty \
|
|
216
215
|
--validator zod \
|
|
216
|
+
--with-ai-guidance \
|
|
217
217
|
--local-source-root "<LOCAL_SOURCE_ROOT>"
|
|
218
218
|
|
|
219
219
|
# 4. Install the scaffolded dependencies
|
|
@@ -314,7 +314,7 @@ Most write-capable commands support `--dry-run` and `--json <payload>` for autom
|
|
|
314
314
|
|
|
315
315
|
| Command | Description |
|
|
316
316
|
|---------|-------------|
|
|
317
|
-
| `ztd init` | Create a ZTD-ready project layout (DDL folder, config, test stubs). Flags: `--yes`, `--workflow <pg_dump\|empty\|demo>`, `--validator <zod\|arktype>`, `--with-sqlclient`, `--with-app-interface`, `--local-source-root <path>` |
|
|
317
|
+
| `ztd init` | Create a ZTD-ready project layout (DDL folder, config, test stubs). Flags: `--yes`, `--workflow <pg_dump\|empty\|demo>`, `--validator <zod\|arktype>`, `--with-ai-guidance`, `--with-sqlclient`, `--with-app-interface`, `--local-source-root <path>` |
|
|
318
318
|
| `ztd agents install` | Materialize visible `AGENTS.md` files from the managed templates |
|
|
319
319
|
| `ztd agents status` | Report internal/visible AGENTS state and drift signals |
|
|
320
320
|
| `ztd ztd-config` | Generate `TestRowMap` and layout from DDL files. Flags: `--watch`, `--quiet` |
|
package/package.json
CHANGED
package/templates/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Next steps:
|
|
|
29
29
|
8. Use `ztd model-gen --probe-mode live`, `ztd ddl pull`, or `ztd ddl diff` only for explicit target inspection by passing `--url` or a complete `--db-*` flag set.
|
|
30
30
|
9. If you generate migration SQL artifacts, apply them with your deployment tooling instead of `ztd-cli`.
|
|
31
31
|
|
|
32
|
-
If this project was scaffolded with `ztd init --local-source-root <monorepo-root>`, first run `pnpm install` (or `pnpm install --ignore-workspace` when nested under another `pnpm-workspace.yaml`), then `pnpm typecheck`, then `pnpm test`, then `pnpm ztd ztd-config`.
|
|
32
|
+
If this project was scaffolded with `ztd init --local-source-root <monorepo-root>`, first run `pnpm install` (or `pnpm install --ignore-workspace` when nested under another `pnpm-workspace.yaml`), then `pnpm typecheck`, then `pnpm test`, then `pnpm ztd ztd-config`. The scaffold keeps `@rawsql-ts/sql-contract` as a normal package import even in local-source developer mode.
|
|
33
33
|
|
|
34
34
|
For schema-change impact checks, `npx ztd query uses` defaults to the `impact` view. Table add / column add checks usually work with the default scan, while table rename / column rename / column type change checks often benefit from `--exclude-generated` so review-only specs under `src/catalog/specs/generated` do not add noise. The flag is optional and does not change the default scan set.
|
|
35
35
|
|
|
@@ -35,4 +35,4 @@ Next steps:
|
|
|
35
35
|
8. Treat `ddl pull` and `ddl diff` as explicit target inspection commands that require `--url` or a complete `--db-*` flag set.
|
|
36
36
|
9. If you generate migration SQL artifacts, apply them outside `ztd-cli`.
|
|
37
37
|
|
|
38
|
-
If this project was scaffolded with `ztd init --local-source-root <monorepo-root>`, first run `pnpm install` (or `pnpm install --ignore-workspace` when nested under another `pnpm-workspace.yaml`), then `pnpm typecheck`, then `pnpm test`, then `pnpm ztd ztd-config`.
|
|
38
|
+
If this project was scaffolded with `ztd init --local-source-root <monorepo-root>`, first run `pnpm install` (or `pnpm install --ignore-workspace` when nested under another `pnpm-workspace.yaml`), then `pnpm typecheck`, then `pnpm test`, then `pnpm ztd ztd-config`. The scaffold keeps `@rawsql-ts/sql-contract` as a normal package import even in local-source developer mode.
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Runtime coercions run BEFORE validator schemas.
|
|
2
|
-
// See docs/recipes/mapping-vs-validation.md for pipeline details.
|
|
3
|
-
export function normalizeTimestamp(value: unknown, fieldName?: string): Date {
|
|
4
|
-
const fieldLabel = fieldName?.trim() ? ` for "${fieldName}"` : '';
|
|
5
|
-
|
|
6
|
-
// Preserve valid Date instances while rejecting invalid dates eagerly.
|
|
7
|
-
if (value instanceof Date) {
|
|
8
|
-
if (Number.isNaN(value.getTime())) {
|
|
9
|
-
throw new Error(`Invalid Date value${fieldLabel}.`);
|
|
10
|
-
}
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Parse driver-returned timestamp strings after trimming transport whitespace.
|
|
15
|
-
if (typeof value === 'string') {
|
|
16
|
-
const trimmed = value.trim();
|
|
17
|
-
if (!trimmed) {
|
|
18
|
-
throw new Error(`Expected a non-empty timestamp string${fieldLabel}.`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const timestamp = Date.parse(trimmed);
|
|
22
|
-
if (Number.isNaN(timestamp)) {
|
|
23
|
-
throw new Error(`Invalid timestamp string${fieldLabel}: "${value}".`);
|
|
24
|
-
}
|
|
25
|
-
return new Date(timestamp);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const actualType = value === null ? 'null' : typeof value;
|
|
29
|
-
throw new Error(`Expected Date or timestamp string${fieldLabel}, received ${actualType}.`);
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@rawsql-ts/sql-contract';
|