baysecms-cli
v1.0.9
Published
CLI for BayseCMS schema push and code generation workflows
Readme
BayseCMS CLI
Schema-as-code, codegen, and content migration for BayseCMS delivery APIs.
Install
npm install -D baysecms-cliQuick start
- Copy templates from
node_modules/baysecms-cli/templates/or use the hospitality starter. - Configure
baysecms.config.jsonwithapiUrland auth. - Push schema:
baysecms schema push --publish - Generate client helpers:
baysecms codegen --out src/lib/baysecms
Add to package.json:
{
"scripts": {
"baysecms:codegen": "baysecms codegen --out src/lib/baysecms",
"baysecms:schema:export": "baysecms schema export --out baysecms.schema.json"
}
}Commands
| Command | Description |
|---------|-------------|
| baysecms schema push | Push baysecms.schema.json draft to cloud |
| baysecms schema export | Export latest published schema JSON |
| baysecms codegen | Generate TypeScript types + data fetchers |
| baysecms migrate tags-to-references | Map tag strings to reference IDs |
Auth
Set BAYSECMS_API_KEY (recommended) or BAYSECMS_TOKEN plus optional tenant/workspace headers.
Codegen behavior
- Uses highest published version per
schemaIdfromGET /v2/schemas. reference→{Collection}Item;array+reference→{Collection}Item[].- Generated
data.tspasses customfetchwithnext.revalidate(default 3600s, override viaBAYSECMS_REVALIDATE). - Published delivery returns stable
/v2/media/*image URLs (not short-lived presigned URLs).
Reference fields
In the admin schema editor, enable Allow multiple references for AmenitiesItem[]-style fields.
Delivery resolves references to nested published documents in /v2/content responses.
Breaking schema changes
When changing field types (e.g. tags → reference), migrate content:
baysecms migrate tags-to-references --collection rooms --field amenities --target amenitiesThen re-run codegen after publishing the new schema version.
Recommended amenity fields
title, slug (from title), description, icon (image), sort-order (number).
API endpoints
| Endpoint | Purpose |
|----------|---------|
| GET /v2/schemas | List schema versions (alias of /schemas) |
| GET /v2/content?schema=rooms | Delivery list with resolved references |
| GET /v2/content/:schema/:slug | Single item by slug |
| GET /v2/media/* | Stable public media proxy |
Auth: x-api-key header or Bearer JWT + x-workspace-id.
