@latellu/atlas-cli
v0.1.5
Published
Generate TypeScript types from an Atlas CMS workspace schema
Maintainers
Readme
@latellu/atlas-cli
Generate TypeScript types from an Atlas CMS workspace schema.
Full documentation: https://docs.atlas.latellu.com
The CLI calls GET /api/v1/public/schema on your Atlas backend (the workspace is
derived from the API key) and writes an atlas.types.ts file with:
- one
interfaceper content type (PascalCase name from the slug), selectfields as string-literal unions,- a
Localeunion from the workspace's configured locales, - an
AtlasContentTypesregistry mapping each slug to its interface.
Usage
npx @latellu/atlas-cli generate --api-key=atlas_live_xxx --output=./src/typesOptions
| Flag | Env | Default | Description |
| --- | --- | --- | --- |
| --api-key | ATLAS_API_KEY | — (required) | Workspace API key |
| --url | ATLAS_API_URL | https://api.atlas.latellu.com | Atlas backend base URL (override only for self-hosted) |
| --output | ATLAS_OUTPUT | ./src/atlas.types.ts | Output file, or directory (writes atlas.types.ts inside) |
Example output
// Generated by @latellu/atlas-cli — DO NOT EDIT BY HAND.
// Workspace: museum-kyoto
export type Locale = "en" | "ja";
/** Article (content type: "article") */
export interface Article {
title: string; // localizable
category?: "News" | "Event";
published_at?: string;
featured?: boolean;
cover_image?: string;
author?: string;
}
/** Maps each content-type slug to its entry interface. */
export interface AtlasContentTypes {
"article": Article;
}Localizable fields are typed as their base value in this release; a per-locale representation is planned alongside
@latellu/atlas-sdk.
image,relation, andcontent_type_referencefields (cover_imageandauthorabove) are typed as plainstring— the referenced media ID or entry ID/slug, not a resolved object. Resolve them yourself withatlas.media.get(id)oratlas.entries(type).get(slug)from@latellu/atlas-sdk. See content types for the full list of field types Atlas supports.
