@bettercms-ai/sdk 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -559,6 +559,36 @@ interface ManagedComponentInput {
559
559
  props?: unknown[];
560
560
  }
561
561
 
562
+ /**
563
+ * Management API SDK methods — AI content + SEO actions (Option B, portable skill).
564
+ *
565
+ * These call /api/v1/management/ai/* (key-auth, content:manage scope). Stateless: they
566
+ * return a *suggestion* the caller applies with the content/page methods. The MCP server
567
+ * wraps these as the `write_content` / `generate_seo_meta` tools.
568
+ */
569
+
570
+ interface WriteContentInput {
571
+ /** write = draft from a brief, rewrite = improve existing copy, translate = needs targetLang. */
572
+ action: "write" | "rewrite" | "translate";
573
+ /** The source text (a brief for 'write', the copy to change otherwise). */
574
+ text: string;
575
+ instructions?: string;
576
+ /** Required for 'translate', e.g. "Spanish". */
577
+ targetLang?: string;
578
+ context?: string;
579
+ }
580
+ interface SeoMetaInput {
581
+ /** The content to derive SEO metadata from. */
582
+ text: string;
583
+ context?: string;
584
+ }
585
+ interface SeoMeta {
586
+ metaTitle: string;
587
+ metaDescription: string;
588
+ keywords: string[];
589
+ jsonLd?: Record<string, unknown>;
590
+ }
591
+
562
592
  interface BetterCMSManagementOptions {
563
593
  /** Base URL of the Management API. Defaults to https://api.bettercms.ai/v1 */
564
594
  baseUrl?: string;
@@ -623,6 +653,10 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
623
653
  getComponent(id: string): Promise<ManagedComponent>;
624
654
  createComponent(input: ManagedComponentInput): Promise<ManagedComponent>;
625
655
  updateComponent(id: string, input: ManagedComponentInput): Promise<ManagedComponent>;
656
+ /** Write, rewrite, or translate a piece of copy. Returns the suggested text. */
657
+ writeContent(input: WriteContentInput): Promise<string>;
658
+ /** Generate SEO metadata for a piece of content (title, description, keywords, JSON-LD). */
659
+ generateSeoMeta(input: SeoMetaInput): Promise<SeoMeta>;
626
660
  }
627
661
 
628
662
  interface AuthResult {
@@ -1069,4 +1103,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
1069
1103
  declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
1070
1104
  declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
1071
1105
 
1072
- export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type PageListOptions, type PendingInvite, type ResolvedSeo, type SearchHit, type SearchOptions, type SeoInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type UpdateApiKeyInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, addModelFields, addPageFields, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
1106
+ export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type PageListOptions, type PendingInvite, type ResolvedSeo, type SearchHit, type SearchOptions, type SeoInput, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type UpdateApiKeyInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
package/dist/index.d.ts CHANGED
@@ -559,6 +559,36 @@ interface ManagedComponentInput {
559
559
  props?: unknown[];
560
560
  }
561
561
 
562
+ /**
563
+ * Management API SDK methods — AI content + SEO actions (Option B, portable skill).
564
+ *
565
+ * These call /api/v1/management/ai/* (key-auth, content:manage scope). Stateless: they
566
+ * return a *suggestion* the caller applies with the content/page methods. The MCP server
567
+ * wraps these as the `write_content` / `generate_seo_meta` tools.
568
+ */
569
+
570
+ interface WriteContentInput {
571
+ /** write = draft from a brief, rewrite = improve existing copy, translate = needs targetLang. */
572
+ action: "write" | "rewrite" | "translate";
573
+ /** The source text (a brief for 'write', the copy to change otherwise). */
574
+ text: string;
575
+ instructions?: string;
576
+ /** Required for 'translate', e.g. "Spanish". */
577
+ targetLang?: string;
578
+ context?: string;
579
+ }
580
+ interface SeoMetaInput {
581
+ /** The content to derive SEO metadata from. */
582
+ text: string;
583
+ context?: string;
584
+ }
585
+ interface SeoMeta {
586
+ metaTitle: string;
587
+ metaDescription: string;
588
+ keywords: string[];
589
+ jsonLd?: Record<string, unknown>;
590
+ }
591
+
562
592
  interface BetterCMSManagementOptions {
563
593
  /** Base URL of the Management API. Defaults to https://api.bettercms.ai/v1 */
564
594
  baseUrl?: string;
@@ -623,6 +653,10 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
623
653
  getComponent(id: string): Promise<ManagedComponent>;
624
654
  createComponent(input: ManagedComponentInput): Promise<ManagedComponent>;
625
655
  updateComponent(id: string, input: ManagedComponentInput): Promise<ManagedComponent>;
656
+ /** Write, rewrite, or translate a piece of copy. Returns the suggested text. */
657
+ writeContent(input: WriteContentInput): Promise<string>;
658
+ /** Generate SEO metadata for a piece of content (title, description, keywords, JSON-LD). */
659
+ generateSeoMeta(input: SeoMetaInput): Promise<SeoMeta>;
626
660
  }
627
661
 
628
662
  interface AuthResult {
@@ -1069,4 +1103,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
1069
1103
  declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
1070
1104
  declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
1071
1105
 
1072
- export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type PageListOptions, type PendingInvite, type ResolvedSeo, type SearchHit, type SearchOptions, type SeoInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type UpdateApiKeyInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, addModelFields, addPageFields, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
1106
+ export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type PageListOptions, type PendingInvite, type ResolvedSeo, type SearchHit, type SearchOptions, type SeoInput, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type UpdateApiKeyInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
package/dist/index.js CHANGED
@@ -649,6 +649,22 @@ async function updateComponent(client, id, input) {
649
649
  return res.data;
650
650
  }
651
651
 
652
+ // src/methods/management/ai.ts
653
+ async function writeContent(client, input) {
654
+ const res = await client.fetchJSON(client.url("/management/ai/content"), {
655
+ method: "POST",
656
+ body: JSON.stringify(input)
657
+ });
658
+ return res.data.suggestion;
659
+ }
660
+ async function generateSeoMeta(client, input) {
661
+ const res = await client.fetchJSON(client.url("/management/ai/seo-meta"), {
662
+ method: "POST",
663
+ body: JSON.stringify(input)
664
+ });
665
+ return res.data;
666
+ }
667
+
652
668
  // src/management-client.ts
653
669
  var DEFAULT_BASE_URL2 = "https://api.bettercms.ai/v1";
654
670
  var DEFAULT_TIMEOUT2 = 1e4;
@@ -810,6 +826,15 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
810
826
  updateComponent(id, input) {
811
827
  return updateComponent(this, id, input);
812
828
  }
829
+ // ── AI (Option B): write/rewrite/translate copy + generate SEO meta (BYOK-metered) ──
830
+ /** Write, rewrite, or translate a piece of copy. Returns the suggested text. */
831
+ writeContent(input) {
832
+ return writeContent(this, input);
833
+ }
834
+ /** Generate SEO metadata for a piece of content (title, description, keywords, JSON-LD). */
835
+ generateSeoMeta(input) {
836
+ return generateSeoMeta(this, input);
837
+ }
813
838
  };
814
839
  function sleep2(ms) {
815
840
  return new Promise((resolve) => setTimeout(resolve, ms));