@rawsql-ts/ztd-cli 0.15.0 → 0.17.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 +38 -25
- package/dist/commands/init.d.ts +13 -0
- package/dist/commands/init.js +372 -118
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/lint.d.ts +4 -4
- package/dist/commands/lint.js +60 -40
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/ztdConfig.d.ts +2 -2
- package/dist/commands/ztdConfig.js +26 -12
- package/dist/commands/ztdConfig.js.map +1 -1
- package/dist/utils/optionalDependencies.d.ts +35 -0
- package/dist/utils/optionalDependencies.js +96 -0
- package/dist/utils/optionalDependencies.js.map +1 -0
- package/package.json +18 -10
- package/templates/AGENTS.md +36 -296
- package/templates/README.md +12 -237
- package/templates/dist/drivers/pg-testkit/src/driver/PgTestkitClient.d.ts +38 -0
- package/templates/dist/drivers/pg-testkit/src/driver/PgTestkitClient.js +117 -0
- package/templates/dist/drivers/pg-testkit/src/driver/PgTestkitClient.js.map +1 -0
- package/templates/dist/drivers/pg-testkit/src/driver/createPgTestkitPool.d.ts +4 -0
- package/templates/dist/drivers/pg-testkit/src/driver/createPgTestkitPool.js +71 -0
- package/templates/dist/drivers/pg-testkit/src/driver/createPgTestkitPool.js.map +1 -0
- package/templates/dist/drivers/pg-testkit/src/index.d.ts +5 -0
- package/templates/dist/drivers/pg-testkit/src/index.js +11 -0
- package/templates/dist/drivers/pg-testkit/src/index.js.map +1 -0
- package/templates/dist/drivers/pg-testkit/src/proxy/wrapPgClient.d.ts +3 -0
- package/templates/dist/drivers/pg-testkit/src/proxy/wrapPgClient.js +79 -0
- package/templates/dist/drivers/pg-testkit/src/proxy/wrapPgClient.js.map +1 -0
- package/templates/dist/drivers/pg-testkit/src/types.d.ts +69 -0
- package/templates/dist/drivers/pg-testkit/src/types.js +3 -0
- package/templates/dist/drivers/pg-testkit/src/types.js.map +1 -0
- package/templates/dist/drivers/pg-testkit/src/utils/fixtureState.d.ts +15 -0
- package/templates/dist/drivers/pg-testkit/src/utils/fixtureState.js +34 -0
- package/templates/dist/drivers/pg-testkit/src/utils/fixtureState.js.map +1 -0
- package/templates/dist/drivers/pg-testkit/src/utils/fixtureValidation.d.ts +12 -0
- package/templates/dist/drivers/pg-testkit/src/utils/fixtureValidation.js +53 -0
- package/templates/dist/drivers/pg-testkit/src/utils/fixtureValidation.js.map +1 -0
- package/templates/dist/mapper-core/src/index.d.ts +160 -0
- package/templates/dist/mapper-core/src/index.js +637 -0
- package/templates/dist/mapper-core/src/index.js.map +1 -0
- package/templates/dist/testkit-core/src/errors/index.d.ts +49 -0
- package/templates/dist/testkit-core/src/errors/index.js +111 -0
- package/templates/dist/testkit-core/src/errors/index.js.map +1 -0
- package/templates/dist/testkit-core/src/fixtures/ColumnAffinity.d.ts +5 -0
- package/templates/dist/testkit-core/src/fixtures/ColumnAffinity.js +29 -0
- package/templates/dist/testkit-core/src/fixtures/ColumnAffinity.js.map +1 -0
- package/templates/dist/testkit-core/src/fixtures/DdlFixtureLoader.d.ts +37 -0
- package/templates/dist/testkit-core/src/fixtures/DdlFixtureLoader.js +182 -0
- package/templates/dist/testkit-core/src/fixtures/DdlFixtureLoader.js.map +1 -0
- package/templates/dist/testkit-core/src/fixtures/FixtureProvider.d.ts +20 -0
- package/templates/dist/testkit-core/src/fixtures/FixtureProvider.js +121 -0
- package/templates/dist/testkit-core/src/fixtures/FixtureProvider.js.map +1 -0
- package/templates/dist/testkit-core/src/fixtures/FixtureStore.d.ts +51 -0
- package/templates/dist/testkit-core/src/fixtures/FixtureStore.js +199 -0
- package/templates/dist/testkit-core/src/fixtures/FixtureStore.js.map +1 -0
- package/templates/dist/testkit-core/src/fixtures/TableDefinitionSchemaRegistry.d.ts +10 -0
- package/templates/dist/testkit-core/src/fixtures/TableDefinitionSchemaRegistry.js +28 -0
- package/templates/dist/testkit-core/src/fixtures/TableDefinitionSchemaRegistry.js.map +1 -0
- package/templates/dist/testkit-core/src/fixtures/TableNameResolver.d.ts +18 -0
- package/templates/dist/testkit-core/src/fixtures/TableNameResolver.js +80 -0
- package/templates/dist/testkit-core/src/fixtures/TableNameResolver.js.map +1 -0
- package/templates/dist/testkit-core/src/fixtures/ddlLint.d.ts +59 -0
- package/templates/dist/testkit-core/src/fixtures/ddlLint.js +489 -0
- package/templates/dist/testkit-core/src/fixtures/ddlLint.js.map +1 -0
- package/templates/dist/testkit-core/src/fixtures/naming.d.ts +1 -0
- package/templates/dist/testkit-core/src/fixtures/naming.js +6 -0
- package/templates/dist/testkit-core/src/fixtures/naming.js.map +1 -0
- package/templates/dist/testkit-core/src/index.d.ts +17 -0
- package/templates/dist/testkit-core/src/index.js +47 -0
- package/templates/dist/testkit-core/src/index.js.map +1 -0
- package/templates/dist/testkit-core/src/logger/NoopLogger.d.ts +8 -0
- package/templates/dist/testkit-core/src/logger/NoopLogger.js +16 -0
- package/templates/dist/testkit-core/src/logger/NoopLogger.js.map +1 -0
- package/templates/dist/testkit-core/src/provider/TestkitProvider.d.ts +57 -0
- package/templates/dist/testkit-core/src/provider/TestkitProvider.js +149 -0
- package/templates/dist/testkit-core/src/provider/TestkitProvider.js.map +1 -0
- package/templates/dist/testkit-core/src/rewriter/ResultSelectRewriter.d.ts +43 -0
- package/templates/dist/testkit-core/src/rewriter/ResultSelectRewriter.js +473 -0
- package/templates/dist/testkit-core/src/rewriter/ResultSelectRewriter.js.map +1 -0
- package/templates/dist/testkit-core/src/rewriter/SelectAnalyzer.d.ts +9 -0
- package/templates/dist/testkit-core/src/rewriter/SelectAnalyzer.js +38 -0
- package/templates/dist/testkit-core/src/rewriter/SelectAnalyzer.js.map +1 -0
- package/templates/dist/testkit-core/src/rewriter/SelectFixtureRewriter.d.ts +42 -0
- package/templates/dist/testkit-core/src/rewriter/SelectFixtureRewriter.js +298 -0
- package/templates/dist/testkit-core/src/rewriter/SelectFixtureRewriter.js.map +1 -0
- package/templates/dist/testkit-core/src/sql/SqliteValuesBuilder.d.ts +12 -0
- package/templates/dist/testkit-core/src/sql/SqliteValuesBuilder.js +63 -0
- package/templates/dist/testkit-core/src/sql/SqliteValuesBuilder.js.map +1 -0
- package/templates/dist/testkit-core/src/types/index.d.ts +69 -0
- package/templates/dist/testkit-core/src/types/index.js +3 -0
- package/templates/dist/testkit-core/src/types/index.js.map +1 -0
- package/templates/dist/testkit-core/src/utils/queryHelpers.d.ts +28 -0
- package/templates/dist/testkit-core/src/utils/queryHelpers.js +81 -0
- package/templates/dist/testkit-core/src/utils/queryHelpers.js.map +1 -0
- package/templates/dist/writer-core/src/index.d.ts +34 -0
- package/templates/dist/writer-core/src/index.js +115 -0
- package/templates/dist/writer-core/src/index.js.map +1 -0
- package/templates/dist/ztd-cli/templates/src/db/sql-client.d.ts +20 -0
- package/templates/dist/ztd-cli/templates/src/db/sql-client.js +3 -0
- package/templates/dist/ztd-cli/templates/src/db/sql-client.js.map +1 -0
- package/templates/dist/ztd-cli/templates/src/db/sql-client.ts +24 -0
- package/templates/dist/ztd-cli/templates/src/repositories/user-accounts.d.ts +36 -0
- package/templates/dist/ztd-cli/templates/src/repositories/user-accounts.js +85 -0
- package/templates/dist/ztd-cli/templates/src/repositories/user-accounts.js.map +1 -0
- package/templates/dist/ztd-cli/templates/tests/generated/ztd-row-map.generated.d.ts +20 -0
- package/templates/dist/ztd-cli/templates/tests/generated/ztd-row-map.generated.js +33 -0
- package/templates/dist/ztd-cli/templates/tests/generated/ztd-row-map.generated.js.map +1 -0
- package/templates/dist/ztd-cli/templates/tests/support/global-setup.d.ts +10 -0
- package/templates/dist/ztd-cli/templates/tests/support/global-setup.js +29 -0
- package/templates/dist/ztd-cli/templates/tests/support/global-setup.js.map +1 -0
- package/templates/dist/ztd-cli/templates/tests/support/testkit-client.d.ts +66 -0
- package/templates/dist/ztd-cli/templates/tests/support/testkit-client.js +552 -0
- package/templates/dist/ztd-cli/templates/tests/support/testkit-client.js.map +1 -0
- package/templates/dist/ztd-cli/templates/tests/user-profiles.test.d.ts +1 -0
- package/templates/dist/ztd-cli/templates/tests/user-profiles.test.js +82 -0
- package/templates/dist/ztd-cli/templates/tests/user-profiles.test.js.map +1 -0
- package/templates/dist/ztd-cli/templates/tests/writer-constraints.test.d.ts +1 -0
- package/templates/dist/ztd-cli/templates/tests/writer-constraints.test.js +29 -0
- package/templates/dist/ztd-cli/templates/tests/writer-constraints.test.js.map +1 -0
- package/templates/dist/ztd-cli/templates/tests/ztd-layout.generated.d.ts +7 -0
- package/templates/dist/ztd-cli/templates/tests/ztd-layout.generated.js +10 -0
- package/templates/dist/ztd-cli/templates/tests/ztd-layout.generated.js.map +1 -0
- package/templates/src/AGENTS.md +26 -0
- package/templates/src/catalog/AGENTS.md +37 -0
- package/templates/src/catalog/runtime/AGENTS.md +75 -0
- package/templates/src/catalog/runtime/_coercions.ts +1 -0
- package/templates/src/catalog/runtime/_smoke.runtime.ts +21 -0
- package/templates/src/catalog/specs/AGENTS.md +48 -0
- package/templates/src/catalog/specs/_smoke.spec.arktype.ts +21 -0
- package/templates/src/catalog/specs/_smoke.spec.zod.ts +20 -0
- package/templates/src/db/sql-client.ts +5 -5
- package/templates/src/jobs/AGENTS.md +26 -0
- package/templates/src/jobs/README.md +3 -0
- package/templates/src/repositories/AGENTS.md +118 -0
- package/templates/src/repositories/tables/AGENTS.md +94 -0
- package/templates/src/repositories/tables/README.md +3 -0
- package/templates/src/repositories/views/AGENTS.md +25 -0
- package/templates/src/repositories/views/README.md +3 -0
- package/templates/src/sql/AGENTS.md +77 -0
- package/templates/src/sql/README.md +6 -0
- package/templates/tests/AGENTS.md +43 -129
- package/templates/tests/generated/AGENTS.md +16 -0
- package/templates/tests/smoke.test.ts +5 -0
- package/templates/tests/smoke.validation.test.ts +34 -0
- package/templates/tests/support/AGENTS.md +26 -0
- package/templates/tests/support/global-setup.ts +8 -23
- package/templates/tests/support/testkit-client.ts +13 -741
- package/templates/tests/ztd-layout.generated.ts +0 -2
- package/templates/tsconfig.json +9 -3
- package/templates/ztd/AGENTS.md +11 -142
- package/templates/ztd/README.md +4 -82
- package/templates/ztd/ddl/AGENTS.md +34 -0
- package/templates/ztd/ddl/demo.sql +74 -0
package/README.md
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Scaffold **Zero Table Dependency (ZTD)** projects and keep DDL-derived test types in sync.
|
|
4
4
|
|
|
5
|
-
`@rawsql-ts/ztd-cli` does **not** execute SQL
|
|
5
|
+
`@rawsql-ts/ztd-cli` does **not** execute SQL by itself. It provides an adapter-neutral core that scaffolds a ZTD-ready development environment.
|
|
6
|
+
To actually run ZTD tests, you plug in a database adapter (driver-specific) and a DBMS-specific testkit (for example, `@rawsql-ts/adapter-node-pg` plus `@rawsql-ts/testkit-postgres` for Postgres).
|
|
6
7
|
|
|
7
8
|
## Install
|
|
8
9
|
|
|
@@ -10,13 +11,16 @@ Scaffold **Zero Table Dependency (ZTD)** projects and keep DDL-derived test type
|
|
|
10
11
|
pnpm add -D @rawsql-ts/ztd-cli
|
|
11
12
|
```
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
To run ZTD-style tests, install:
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```
|
|
16
|
+
* a **database adapter** (driver-specific) to execute SQL, and
|
|
17
|
+
* a **DBMS-specific testkit** to handle fixture resolution, query rewriting, and result validation.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
For Postgres, the typical ZTD setup is:
|
|
20
|
+
`@rawsql-ts/adapter-node-pg` (driver adapter) +
|
|
21
|
+
`@rawsql-ts/testkit-postgres` (Postgres-specific testkit).
|
|
22
|
+
|
|
23
|
+
If you run `npx ztd init`, the CLI will install the Postgres driver/testkit stack plus `@rawsql-ts/sql-contract`, and it will always prompt you to select a validator backend (Zod or ArkType). The wizard keeps the required workflow documented in the recipes under `docs/recipes/` (e.g., `docs/recipes/sql-contract.md`, `docs/recipes/validation-zod.md`, and `docs/recipes/validation-arktype.md`), so the implementation path stays centralized and version-controlled.
|
|
20
24
|
|
|
21
25
|
Then use the CLI through `npx ztd` or the installed `ztd` bin.
|
|
22
26
|
|
|
@@ -43,6 +47,12 @@ Then use the CLI through `npx ztd` or the installed `ztd` bin.
|
|
|
43
47
|
|
|
44
48
|
Use `--with-app-interface` to append the application interface guidance block to `AGENTS.md` without generating the ZTD layout or touching other files.
|
|
45
49
|
|
|
50
|
+
```bash
|
|
51
|
+
npx ztd init --yes
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Use `--yes` to overwrite existing scaffold files without prompting (useful for non-interactive runs).
|
|
55
|
+
|
|
46
56
|
2. Put your schema into `ztd/ddl/`:
|
|
47
57
|
|
|
48
58
|
- Edit the starter file (default): `ztd/ddl/public.sql`, or
|
|
@@ -82,7 +92,10 @@ You can introduce ZTD incrementally; existing tests and ORMs can remain untouche
|
|
|
82
92
|
- `AGENTS.md` (copied from the package template unless the project already has one; `--with-app-interface` adds the application interface guidance block at the end)
|
|
83
93
|
- `ztd/AGENTS.md` and `ztd/README.md` (folder-specific instructions that describe the new schema/domain layout)
|
|
84
94
|
- `src/db/sql-client.ts` (optional; generated only with `--with-sqlclient`)
|
|
85
|
-
-
|
|
95
|
+
- `src/sql/views/README.md` + `src/sql/jobs/README.md` (SQL file structure)
|
|
96
|
+
- `src/repositories/views/README.md` + `src/repositories/tables/README.md` (repository structure)
|
|
97
|
+
- `src/jobs/README.md` (job runner structure)
|
|
98
|
+
- Example view SQL/repository and job SQL/runner files for the sample schema
|
|
86
99
|
|
|
87
100
|
The resulting project follows the "DDL -> ztd-config -> tests" flow so you can regenerate everything from SQL-first artifacts.
|
|
88
101
|
|
|
@@ -169,27 +182,27 @@ npx ztd lint path/to/query.sql
|
|
|
169
182
|
```
|
|
170
183
|
|
|
171
184
|
- Accepts a single `.sql` file, glob pattern, or directory (directories expand to `**/*.sql`).
|
|
172
|
-
-
|
|
173
|
-
-
|
|
174
|
-
-
|
|
175
|
-
-
|
|
185
|
+
- Resolves `ZTD_LINT_DATABASE_URL` or `DATABASE_URL` for the database connection. When no URL is configured, it loads `@testcontainers/postgresql` (if installed) to spin up a temporary Postgres container.
|
|
186
|
+
- Dynamically loads the registered adapter (for example `@rawsql-ts/adapter-node-pg` plus `@rawsql-ts/testkit-postgres`) so the rewritten statement is inspected through the fixture pipeline before it runs.
|
|
187
|
+
- Executes each rewritten query using `PREPARE ... AS ...` (falling back to `EXPLAIN`) so Postgres (or your adapter) performs the same parsing/type resolution used in tests.
|
|
188
|
+
- Reports the file path, location, error code/message/detail/hint, and a caret-marked excerpt to make fixes actionable before running tests.
|
|
189
|
+
- Override the database image with `ZTD_LINT_DB_IMAGE` (default `postgres:16-alpine`), or supply a URL to reuse an existing server instead of a container.
|
|
190
|
+
- If the adapter is missing, the command stops early with an error that points you at the adapter package to install or instructs you to set `DATABASE_URL`.
|
|
176
191
|
|
|
177
192
|
## ZTD Testing
|
|
178
193
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
The driver sits downstream of `testkit-core` and applies the rewrite + fixture pipeline before running any database interaction. Install the driver, configure it in your tests, and point it at the row map from `tests/generated/ztd-row-map.generated.ts`.
|
|
194
|
+
The generated `tests/support/testkit-client.ts` is a stub. Replace `createTestkitClient` with a factory that returns an object conforming to `SqlClient` (defined in `src/db/sql-client.ts`). Use it to wire your preferred adapter (for example a Postgres adapter, a mock data source, or a fixture helper) before running the repository tests.
|
|
182
195
|
|
|
183
|
-
|
|
196
|
+
ZTD rewrites every statement into a fixture-friendly shape and expects your adapter to execute the rewritten SQL using the metadata under `tests/generated/ztd-row-map.generated.ts`. The CLI avoids bundling a driver so you can choose whatever stack fits your project; install the necessary adapter package and point it at the generated row map before executing DB-backed suites.
|
|
184
197
|
|
|
185
|
-
|
|
198
|
+
### SQL rewrite logging
|
|
186
199
|
|
|
187
|
-
|
|
200
|
+
If you need to inspect the rewritten SQL, add logging inside your adapter or within `tests/support/testkit-client.ts`. There is no built-in logger in the template, but you can guard logging with environment variables such as:
|
|
188
201
|
|
|
189
|
-
- `ZTD_SQL_LOG=1`
|
|
190
|
-
- `ZTD_SQL_LOG_PARAMS=1`
|
|
202
|
+
- `ZTD_SQL_LOG=1` or `true`: log the raw SQL plus the rewritten statement.
|
|
203
|
+
- `ZTD_SQL_LOG_PARAMS=1` or `true`: include query parameters in the emitted logs.
|
|
191
204
|
|
|
192
|
-
|
|
205
|
+
Add any adapter-specific options or helpers to control logging per call (for example, guard logging with your own `ZtdSqlLogOptions` type) so the test outputs remain deterministic when logging is disabled.
|
|
193
206
|
|
|
194
207
|
## Benchmark summary
|
|
195
208
|
|
|
@@ -199,7 +212,7 @@ This benchmark executes the same repository implementation with two different su
|
|
|
199
212
|
|
|
200
213
|
- End-to-end wall-clock time including runner startup.
|
|
201
214
|
- DB execution time and SQL count so Traditional’s higher SQL volume is explicit.
|
|
202
|
-
- ZTD rewrite and fixture breakdowns so the internal costs of the
|
|
215
|
+
- ZTD rewrite and fixture breakdowns so the internal costs of the testkit-postgres pipeline are visible.
|
|
203
216
|
- Parallelism effects, runner startup costs, and where the break-even point lies as suite size grows.
|
|
204
217
|
|
|
205
218
|
### Assumptions and environment
|
|
@@ -219,7 +232,7 @@ This benchmark compares ZTD-style repository tests against a traditional migrati
|
|
|
219
232
|
|
|
220
233
|
- Repository test cases: 3 (`customer_summary`, `product_ranking`, `sales_summary`)
|
|
221
234
|
- Each test performs: 1 repository call (1 SQL execution per test case)
|
|
222
|
-
- The Traditional workflow wraps every repository execution with migration, seeding, and cleanup SQL, whereas the ZTD workflow captures the same query, feeds it to
|
|
235
|
+
- The Traditional workflow wraps every repository execution with migration, seeding, and cleanup SQL, whereas the ZTD workflow captures the same query, feeds it to the testkit-postgres adapter, and replays the rewritten/select-only statements backed by fixtures.
|
|
223
236
|
- Suite sizes shown in the report:
|
|
224
237
|
- 3 tests (baseline)
|
|
225
238
|
- 30 tests (the same 3 cases repeated to approximate a larger suite)
|
|
@@ -229,7 +242,7 @@ The 30-test suite exists to show how runner overhead amortizes as the number of
|
|
|
229
242
|
#### What is included / excluded
|
|
230
243
|
|
|
231
244
|
- **Runner-included runs (main comparison):** wall-clock time including `pnpm` + `vitest` startup and test execution.
|
|
232
|
-
- **Steady-state section:** measures incremental cost per iteration after the runner is warm (first iteration excluded), to approximate watch/CI-like “many tests per single runner invocation
|
|
245
|
+
- **Steady-state section:** measures incremental cost per iteration after the runner is warm (first iteration excluded), to approximate watch/CI-like “many tests per single runner invocation.”
|
|
233
246
|
- **Container startup:** excluded (the Postgres container is shared across runs).
|
|
234
247
|
|
|
235
248
|
#### Fairness / bias notes (important)
|
|
@@ -336,14 +349,14 @@ Application SQL can omit schema qualifiers (for example, `SELECT ... FROM users`
|
|
|
336
349
|
- **DDL**: SQL files that define schema objects (tables, enums, indexes, etc.).
|
|
337
350
|
- **Row map (`TestRowMap`)**: Generated TypeScript types describing test rows for each table from DDL.
|
|
338
351
|
- **Fixture**: Static rows used by the driver to answer queries deterministically.
|
|
339
|
-
- **Driver**: The package that connects to your database engine and runs the rewrite + fixture pipeline (for example, `@rawsql-ts/
|
|
352
|
+
- **Driver**: The package that connects to your database engine and runs the rewrite + fixture pipeline (for example, `@rawsql-ts/testkit-postgres` plus `@rawsql-ts/adapter-node-pg`).
|
|
340
353
|
|
|
341
354
|
## AI Coding Workflow (Optional)
|
|
342
355
|
|
|
343
356
|
1. Update the relevant `ztd/ddl/<schema>.sql` file (for example, `ztd/ddl/public.sql`) with the desired schema.
|
|
344
357
|
2. Run `npx ztd ztd-config` (or `--watch`) to regenerate the generated outputs under `tests/generated/`.
|
|
345
358
|
3. Use the row map + fixtures to write repositories, tests, and fixtures.
|
|
346
|
-
4. Run tests through
|
|
359
|
+
4. Run tests through the testkit-postgres stack (`@rawsql-ts/testkit-postgres` + `@rawsql-ts/adapter-node-pg`) (or another driver) since `ztd-cli` itself never executes SQL.
|
|
347
360
|
5. When generating code with an AI tool, feed it `tests/generated/ztd-row-map.generated.ts`, `tests/generated/ztd-layout.generated.ts`, `ztd.config.json`, and any AGENTS guidance so it can respect the ZTD contract.
|
|
348
361
|
|
|
349
362
|
## AGENTS.md
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ type PackageInstallKind = 'devDependencies' | 'install';
|
|
|
9
9
|
export interface Prompter {
|
|
10
10
|
selectChoice(question: string, choices: string[]): Promise<number>;
|
|
11
11
|
promptInput(question: string, example?: string): Promise<string>;
|
|
12
|
+
promptInputWithDefault(question: string, defaultValue: string, example?: string): Promise<string>;
|
|
12
13
|
confirm(question: string): Promise<boolean>;
|
|
13
14
|
close(): void;
|
|
14
15
|
}
|
|
@@ -57,10 +58,22 @@ export interface InitCommandOptions {
|
|
|
57
58
|
dependencies?: Partial<ZtdConfigWriterDependencies>;
|
|
58
59
|
withSqlClient?: boolean;
|
|
59
60
|
withAppInterface?: boolean;
|
|
61
|
+
forceOverwrite?: boolean;
|
|
62
|
+
nonInteractive?: boolean;
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
62
65
|
* Run the interactive `ztd init` workflow and return the resulting summary.
|
|
63
66
|
*/
|
|
64
67
|
export declare function runInitCommand(prompter: Prompter, options?: InitCommandOptions): Promise<InitResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Normalizes a schema identifier into the canonical lowercase form used by ztd-cli file naming.
|
|
70
|
+
* Empty input falls back to the configured default schema.
|
|
71
|
+
*/
|
|
72
|
+
export declare function normalizeSchemaName(value: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Sanitizes a normalized schema identifier so it can be used as a filesystem-safe file stem.
|
|
75
|
+
* Returns `schema` when all characters are stripped by sanitization.
|
|
76
|
+
*/
|
|
77
|
+
export declare function sanitizeSchemaFileName(schemaName: string): string;
|
|
65
78
|
export declare function registerInitCommand(program: Command): void;
|
|
66
79
|
export {};
|