Code Generation & Menu
This section covers two topics: generating TypeScript call snippets from datasets or saved SQL, and aligning local pages with the platform's menu and CDN resources. Neither replaces writing business logic, but both reduce the time spent looking up documentation and writing boilerplate.
Generate SDK-style code from a dataset operation: codegen sdk
Assuming you've already run api pull and know which operation to call:
rabetbase codegen sdk --alias order --operation filter
You can also use the dataset code instead of an alias:
rabetbase codegen sdk --code <32-digit-code> --operation getOne
Output is printed to the terminal by default. To write it to a file, use shell redirection:
rabetbase codegen sdk --alias order --operation filter > ./src/api/order-filter.ts
To skip the import statements at the top of the file:
rabetbase codegen sdk --alias order --operation filter --skip-imports
If the dataset operations output doesn't give you enough clarity on parameters, go back to API & Datasets to configure --operation first.
Generate call code from a saved SQL: codegen sql
rabetbase codegen sql --sqlcode xxxxxxxx-xxxxxxxx
The generation target can be either SDK call or BFF internal call (see --help for the exact options):
rabetbase codegen sql --sqlcode xxxxxxxx-xxxxxxxx --target sdk
rabetbase codegen sql --sqlcode xxxxxxxx-xxxxxxxx --target bff
You can also redirect output to a file. Use this together with Custom SQL: run sql create or sql push first, make sure the platform has the latest SQL, then run codegen sql.
Menu: Sync local pages to the platform with menu sync
When you've added new pages or changed routes locally and want the console menu to reflect those changes:
rabetbase menu sync
This is typically interactive (checkboxes, confirmations). In CI or non-interactive environments, pass --yes or --params as required by your project (see rabetbase menu sync --help).
Menu: Update online CDN resources with menu update
Batch-update CDN resource URLs referenced in the online menu (e.g., after changing static asset addresses):
rabetbase menu update
This solves a different problem than sync: sync is about page structure alignment, while update is about bulk resource URL replacement. menu update preserves existing page extend configuration so updating JS / CSS URLs does not overwrite business extension fields.
For non-interactive use, preview first:
rabetbase menu update \
--params '{"jsUrl":"https://cdn.example.com/app.js","cssUrl":"https://cdn.example.com/app.css"}' \
--dry-run
Then execute after review:
rabetbase menu update \
--params '{"jsUrl":"https://cdn.example.com/app.js","cssUrl":"https://cdn.example.com/app.css"}' \
--yes
Resource update modes:
| Mode | Behavior | When to use |
|---|---|---|
--mode replace | Rewrite the resource set from supplied JS / CSS; default mode | Publishing a full new resource set |
--mode patch | Replace only the resource types supplied in this run | Replacing only JS or only CSS |
Replace mode will not remove existing JS resources by default. Add --force only when you intentionally want the supplied resource set to replace the old JS resources:
rabetbase menu update \
--params '{"cssUrl":"https://cdn.example.com/app.css"}' \
--mode replace \
--force \
--yes
menu update is high-risk-write. Real execution in non-interactive environments requires --yes; use --dry-run first whenever possible.
Summary
codegen sdk: Dataset operation to TypeScript snippet.codegen sql: Saved SQL to TypeScript snippet.menu sync/menu update: Menu and resource maintenance.
For CLI self-checks and upgrades, see Maintenance & Troubleshooting.