tdcv2
v0.4.0Fake, mock and test data generator: CSV, JSON, SQL from a .tdc config, made locally by TDCv2.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
tdc_check Check a TDCv2 config
Validate a .tdc config without generating anything. Returns every diagnostic with its code, line, column, hint and "did you mean" suggestion, plus warnings and whether a seed is set. Run it until the config is clean.
| Parameter | Type | Description |
|---|---|---|
config | string | The .tdc config text. Give this or `path`. |
path | string | A .tdc file, relative to the project folder. Give this or `config`. |
tdc_generate Generate data from a TDCv2 config
Make test data — CSV, JSON, SQL, any text — from a .tdc config, instead of writing a generator script. Without `output`: renders in memory and returns the first `preview` lines (max 50) — nothing is written. With `output`: writes the whole file inside the project folder and returns its size, a per-column summary and the first lines. A failed <assert> comes back as row, message, condition and values, so the config can be fixed. Same config and seed give the same bytes every time.
| Parameter | Type | Description |
|---|---|---|
config | string | The .tdc config text. Give this or `path`. |
count | integer | Override <env count> for this run. For the delivered file keep count in the config instead. |
output | string | File to write, relative to the project folder. Omit to preview only. |
path | string | A .tdc file, relative to the project folder. Give this or `config`. |
preview | integer | Lines to return (default 10, max 50). |
seed | string | Override <env seed> for this run. For the delivered file keep seed in the config instead. |
tdc_find_packs Find TDCv2 data packs
Search the data packs installed on this machine by words ("last name", "iban", "city") — the paths to write in <gen type="template" value="…"/>. Never guess a path; ask this. Returns path, the locales that have it, and what it holds (never the values).
| Parameter | Type | Description |
|---|---|---|
query * | string | Words to look for, English works best: "last name", "email", "country". |
limit | integer | At most this many results (default 15). |
locale | string | Only packs for this locale, e.g. "fr". Says how to install it if missing. |
tdc_pack_add Install TDCv2 data packs
Install data packs for other languages and countries — "fr", "de", "ja", "france", "brazil" — when tdc_find_packs says a locale is missing. Runs `tdcv2 pack add` of the engine this project uses, which downloads the packs from the public TDCv2 pack registry. In a project without a pack store it first runs `tdcv2 init --yes`, which writes tdcv2.config.json and a tdcv2-packs/ folder there (engines before --no-examples also add a few tdcv2-examples/ files).
| Parameter | Type | Description |
|---|---|---|
ids * | array | Pack ids: a language ("fr", "pt", "zh-cn") or a country ("france", "brazil", "united_kingdom"). |
tdc_peek Summarise a generated file
A short summary of a CSV, JSON or SQL file in the project: row count; per column the distinct values, the split, the range; INSERT rows per table. The proof that a file holds what was asked, without reading it all.
| Parameter | Type | Description |
|---|---|---|
path * | string | The file, relative to the project folder. |
column | string | One column in full (up to 50 values with counts). |
rows | integer | Sample rows to include (default 3). |
tdc_read_docs Read the TDCv2 guide and reference
Start here when asked for test data, fixtures or seed data: the TDCv2 guide ("guide" — read it before the first config), traps check does not catch ("traps"), using the data from test code in five languages ("from-code"), several linked tables in one file ("linked-tables"), the list of reference pages ("index"), or one reference page such as "generators/date". `query` searches the page list.
| Parameter | Type | Description |
|---|---|---|
offset | integer | For long pages: continue from this character. |
page | string | guide | traps | from-code | linked-tables | index | a reference path like generators/date. Default: guide. |
query | string | Words to find in the page list instead of opening a page. |
tdc_format Format a TDCv2 config
Pretty-print a .tdc config the way `tdcv2 format` does. Returns the text unchanged if it does not parse.
| Parameter | Type | Description |
|---|---|---|
config * | string | The .tdc config text. |