tgraph api
Runs the full NestJS backend generator for every Prisma model tagged with @tg_form().
Static backend utilities
src/
├── decorators/
│ ├── is-admin.decorator.ts
│ └── paginated-search.decorator.ts
├── dtos/
│ ├── api-response.dto.ts
│ ├── paginated-search-query.dto.ts
│ └── paginated-search-result.dto.ts
├── guards/
│ └── admin.guard.ts
└── interceptors/
└── pagiantion.interceptor.ts
- Written at the start of every run by
NestStaticGenerator. - Each file is overwritten in place; there is no merge step and no backup.
- Sub-folders must already exist. If, for example,
src/guardsis missing,fs.promises.writeFilethrows and the command fails. - After writing,
npx prettier --writeruns on the touched files (warnings appear if formatting fails).
Module directories & generated artifacts
For every model with @tg_form():
- Locate module folder
Searches all configured paths inoutput.backend.modules.searchPathsusing camelCase, kebab-case, and plural variants. - Optional creation
If nothing is found, the CLI prompts:
Do you want to create the module directory for <Model>? (y/n)y: creates<defaultRoot>/<kebab-name>/(based onoutput.backend.modules.defaultRoot) and seeds a module file.n: skips this model entirely.
Once a module path exists, the following files are written (overwriting any existing versions):
<modulePath>/
├── create-<camelName>[.<suffix>].dto.ts
├── update-<camelName>[.<suffix>].dto.ts
├── <camelName>[.<suffix>].service.ts
└── <camelName>[.<suffix>].controller.ts
<camelName>is the lower camel case form of the model name.[.<suffix>]is appended whenconfig.suffixis set (e.g., defaultTg⇒.tg).- DTO files are tagged with the
AUTO-GENERATED FILEnotice. - Password fields (
passwordor fields with@tg_format(password)) are omitted from services. - Prettier is invoked on the freshly written files; failures only emit warnings.
Module wiring updates
- If a module folder exists but no
.module.tsfile is present, one is generated using the suffix-aware template. - Existing module files are updated in-place:
- Missing controller/service imports are injected after the last import statement.
- Controllers and providers arrays gain the generated classes if they were absent.
- When new module folders are auto-created, the AppModule file (defaults to
src/app.module.ts) is rewritten. Override withpaths.appModuleif needed:- An
// AUTO-GENERATED IMPORTSblock is created or extended with<Model>Moduleimports. - The
imports: []array gains an auto-generated block listing those modules.
- An
- All edits are textual; manual additions outside the auto-generated sections remain untouched.
Dashboard data provider sync (optional)
- Triggered only if
config.updateDataProvider !== false. - Rewrites the dashboard data provider (defaults to
src/dashboard/src/providers/dataProvider.ts, configurable viapaths.dataProvider) by replacing theconst endpointMapobject with:// Auto-generated API endpointsblock listing each generated controller route.// Custom endpointsblock containing any pre-existing entries that were not in the auto-generated section.
- If the
endpointMapdeclaration is missing, a warning is logged and the file is left unchanged. - File is formatted with Prettier after the rewrite.