@_publicai/cms
v1.0.5
Published
A lightweight client for interacting with the CMS API
Maintainers
Readme
CMS Client
A lightweight client for interacting with the CMS API.
Installation
npm install @_publicai/cmsUsage
import { CmsClient } from '@_publicai/cms';
const cms = new CmsClient({
baseUrl: 'https://your-api-url',
projectId: 'your-project-id'
});
// Example: Get content for a page
const pageContent = await cms.getPage('homepage');Configuration Options
const cms = new CmsClient({
baseUrl: 'https://your-api-url', // API base URL
projectId: 'your-project-id', // Default project ID
defaultVariant: 'default', // Default variant (optional)
defaultLanguage: 'en', // Default language (optional)
cacheEnabled: true, // Enable caching (optional)
cacheTimeout: 60000 // Cache timeout in ms (optional)
});Available Methods
setProject(projectId): Set the project IDsetVariant(variantId): Set the default variantsetLanguage(language): Set the default languageclearCache(): Clear the cacheget(pageId, entryId, options): Get a single content entrygetPage(pageId, options): Get content for an entire pagegetVariant(variantId, options): Get content for a specific variantgetBatch(keys): Get multiple content entries at oncecreate(pageId, entryId, data, options): Create content entryupdate(pageId, entryId, updates, options): Update content entrydelete(pageId, entryId, options): Delete content entryloadContent(pageId, options): Load all content for a pagebatchCreate(contentItems, options): Create multiple content entriesbatchUpdate(contentUpdates): Update multiple content entries
