@bettercms-ai/sdk 1.11.0 → 1.12.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.cjs +59 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -3
- package/dist/index.d.ts +67 -3
- package/dist/index.js +57 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _bettercms_ai_types from '@bettercms-ai/types';
|
|
2
|
-
import { ContentPageResult, Content, ContentModelField, BetterCMSErrorCode, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, PageMetaJson, SiteSeoDefaults, Page, MediaAsset, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
|
|
2
|
+
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, BetterCMSErrorCode, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, PageMetaJson, SiteSeoDefaults, Page, MediaAsset, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
|
|
3
3
|
export { ApiError, ApiKey, ApiKeyPermission, ApiKeyTokenType, AssertEqual, AuthSession, AuthUser, BetterCMSErrorCode, BlockType, ButtonBlock, ButtonProps, ColumnsBlock, ColumnsProps, Content, ContentBlock, ContentEntry, ContentModel, ContentModelField, ContentPageResult, ContentResponse, DeepReadonly, DeliveryEntry, DeliveryList, DeliveryPage, Form, FormBlock, FormField, FormProps, FormSubmission, HeadingBlock, HeadingProps, ImageBlock, ImageProps, MediaAsset, Page, PageMetaJson, PaginatedResult, Perspective, Redirect, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, getBlockType, isBlock } from '@bettercms-ai/types';
|
|
4
4
|
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder } from '@bettercms-ai/image-url';
|
|
5
5
|
|
|
@@ -65,6 +65,7 @@ declare class BetterCMSDeliveryClient {
|
|
|
65
65
|
limit?: number;
|
|
66
66
|
}): Promise<_bettercms_ai_types.Content[]>;
|
|
67
67
|
};
|
|
68
|
+
getLayout(): Promise<DeliveredLayout | null>;
|
|
68
69
|
/** Build the full URL for a content path. */
|
|
69
70
|
url(path: string): string;
|
|
70
71
|
/** Build request headers, including auth if provided. */
|
|
@@ -575,16 +576,35 @@ interface ManagedFormInput {
|
|
|
575
576
|
interface ManagedComponent {
|
|
576
577
|
id: string;
|
|
577
578
|
projectId: string | null;
|
|
579
|
+
allowedOn: string[];
|
|
578
580
|
name: string;
|
|
579
581
|
slug: string;
|
|
580
582
|
category: string;
|
|
581
583
|
description: string | null;
|
|
582
584
|
blockJson: unknown[];
|
|
583
585
|
props: unknown[];
|
|
586
|
+
variantGroupId?: string | null;
|
|
587
|
+
publishedVariantGroupId?: string | null;
|
|
588
|
+
variantInputMappings?: Array<{
|
|
589
|
+
inputId: string;
|
|
590
|
+
targets: Array<{
|
|
591
|
+
blockId: string;
|
|
592
|
+
path: string;
|
|
593
|
+
}>;
|
|
594
|
+
}>;
|
|
595
|
+
publishedVariantInputMappings?: Array<{
|
|
596
|
+
inputId: string;
|
|
597
|
+
targets: Array<{
|
|
598
|
+
blockId: string;
|
|
599
|
+
path: string;
|
|
600
|
+
}>;
|
|
601
|
+
}> | null;
|
|
584
602
|
thumbnail?: string | null;
|
|
585
603
|
}
|
|
586
604
|
/** Create/update input. `blockJson` is the ContentBlock tree; `props` the override allowlist. */
|
|
587
605
|
interface ManagedComponentInput {
|
|
606
|
+
projectId?: string | null;
|
|
607
|
+
allowedOn?: string[];
|
|
588
608
|
name?: string;
|
|
589
609
|
slug?: string;
|
|
590
610
|
category?: string;
|
|
@@ -644,6 +664,41 @@ interface SeoMeta {
|
|
|
644
664
|
jsonLd?: Record<string, unknown>;
|
|
645
665
|
}
|
|
646
666
|
|
|
667
|
+
type ManagedLayoutDocument = {
|
|
668
|
+
scope: "global";
|
|
669
|
+
revision: number;
|
|
670
|
+
etag: string;
|
|
671
|
+
status: string;
|
|
672
|
+
structure: LayoutStructureDocument;
|
|
673
|
+
data: LayoutDataDocument;
|
|
674
|
+
} | {
|
|
675
|
+
scope: "page";
|
|
676
|
+
pageId: string;
|
|
677
|
+
pageSlug: string;
|
|
678
|
+
revision: number;
|
|
679
|
+
etag: string;
|
|
680
|
+
status: string;
|
|
681
|
+
globalStructure: LayoutStructureDocument;
|
|
682
|
+
globalData: LayoutDataDocument;
|
|
683
|
+
override: PageLayoutOverrideDocument;
|
|
684
|
+
};
|
|
685
|
+
interface ManagedLayoutClient {
|
|
686
|
+
url(path: string): string;
|
|
687
|
+
fetchJSON<T>(url: string, init?: RequestInit): Promise<T>;
|
|
688
|
+
}
|
|
689
|
+
interface GetManagedLayoutOptions {
|
|
690
|
+
scope?: "global" | "page";
|
|
691
|
+
pageId?: string;
|
|
692
|
+
/** Required when the management credential is workspace-scoped. */
|
|
693
|
+
projectId?: string;
|
|
694
|
+
}
|
|
695
|
+
interface CommandManagedLayoutInput extends GetManagedLayoutOptions {
|
|
696
|
+
command: ManagementLayoutCommand;
|
|
697
|
+
ifMatch: number;
|
|
698
|
+
}
|
|
699
|
+
declare function getManagedLayout(client: ManagedLayoutClient, opts?: GetManagedLayoutOptions): Promise<ManagedLayoutDocument>;
|
|
700
|
+
declare function commandManagedLayout(client: ManagedLayoutClient, input: CommandManagedLayoutInput): Promise<ManagedLayoutDocument>;
|
|
701
|
+
|
|
647
702
|
interface BetterCMSManagementOptions {
|
|
648
703
|
/** Base URL of the Management API. Defaults to https://api.bettercms.ai/v1 */
|
|
649
704
|
baseUrl?: string;
|
|
@@ -728,6 +783,8 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
|
|
|
728
783
|
component: ManagedComponent;
|
|
729
784
|
replaced: number;
|
|
730
785
|
}>;
|
|
786
|
+
getManagedLayout(opts?: GetManagedLayoutOptions): Promise<ManagedLayoutDocument>;
|
|
787
|
+
commandManagedLayout(input: CommandManagedLayoutInput): Promise<ManagedLayoutDocument>;
|
|
731
788
|
/** Write, rewrite, or translate a piece of copy. Returns the suggested text. */
|
|
732
789
|
writeContent(input: WriteContentInput): Promise<string>;
|
|
733
790
|
/** Generate SEO metadata for a piece of content (title, description, keywords, JSON-LD). */
|
|
@@ -846,7 +903,12 @@ interface CreateClientOptions {
|
|
|
846
903
|
* `/preview/:slug` endpoint. Only used when `perspective === "drafts"`.
|
|
847
904
|
*/
|
|
848
905
|
previewToken?: string;
|
|
849
|
-
/**
|
|
906
|
+
/**
|
|
907
|
+
* Embed invisible visual-editing provenance in draft reads, so a preview build can
|
|
908
|
+
* deep-link each rendered value back to its editor. Requires `perspective: "drafts"`,
|
|
909
|
+
* and then either a `previewToken` or a `content:read:draft` key. Ignored on published
|
|
910
|
+
* reads — the payload must never reach a production build.
|
|
911
|
+
*/
|
|
850
912
|
stega?: boolean;
|
|
851
913
|
/** Per-attempt timeout in ms. Defaults to 10000. */
|
|
852
914
|
timeout?: number;
|
|
@@ -875,6 +937,8 @@ interface BetterCMSReadClient {
|
|
|
875
937
|
listEntries<T = Record<string, unknown>>(opts?: ListEntriesOptions): Promise<DeliveryList<DeliveryEntry<T>>>;
|
|
876
938
|
getPage(slug: string): Promise<DeliveryPage | null>;
|
|
877
939
|
listPages(opts?: ListPagesOptions): Promise<DeliveryList<DeliveryPage>>;
|
|
940
|
+
/** Fetch the project-scoped Global Layout for the active perspective. */
|
|
941
|
+
getLayout(): Promise<DeliveredLayout | null>;
|
|
878
942
|
listForms(opts?: {
|
|
879
943
|
projectId?: string;
|
|
880
944
|
}): Promise<{
|
|
@@ -1262,4 +1326,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
|
|
|
1262
1326
|
declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
|
|
1263
1327
|
declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
|
|
1264
1328
|
|
|
1265
|
-
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 ExtractionCandidate, 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 RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, type UpdateApiKeyInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, 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, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
|
|
1329
|
+
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 CommandManagedLayoutInput, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type PageListOptions, type PendingInvite, type ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, type UpdateApiKeyInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _bettercms_ai_types from '@bettercms-ai/types';
|
|
2
|
-
import { ContentPageResult, Content, ContentModelField, BetterCMSErrorCode, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, PageMetaJson, SiteSeoDefaults, Page, MediaAsset, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
|
|
2
|
+
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, BetterCMSErrorCode, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, PageMetaJson, SiteSeoDefaults, Page, MediaAsset, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
|
|
3
3
|
export { ApiError, ApiKey, ApiKeyPermission, ApiKeyTokenType, AssertEqual, AuthSession, AuthUser, BetterCMSErrorCode, BlockType, ButtonBlock, ButtonProps, ColumnsBlock, ColumnsProps, Content, ContentBlock, ContentEntry, ContentModel, ContentModelField, ContentPageResult, ContentResponse, DeepReadonly, DeliveryEntry, DeliveryList, DeliveryPage, Form, FormBlock, FormField, FormProps, FormSubmission, HeadingBlock, HeadingProps, ImageBlock, ImageProps, MediaAsset, Page, PageMetaJson, PaginatedResult, Perspective, Redirect, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, getBlockType, isBlock } from '@bettercms-ai/types';
|
|
4
4
|
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder } from '@bettercms-ai/image-url';
|
|
5
5
|
|
|
@@ -65,6 +65,7 @@ declare class BetterCMSDeliveryClient {
|
|
|
65
65
|
limit?: number;
|
|
66
66
|
}): Promise<_bettercms_ai_types.Content[]>;
|
|
67
67
|
};
|
|
68
|
+
getLayout(): Promise<DeliveredLayout | null>;
|
|
68
69
|
/** Build the full URL for a content path. */
|
|
69
70
|
url(path: string): string;
|
|
70
71
|
/** Build request headers, including auth if provided. */
|
|
@@ -575,16 +576,35 @@ interface ManagedFormInput {
|
|
|
575
576
|
interface ManagedComponent {
|
|
576
577
|
id: string;
|
|
577
578
|
projectId: string | null;
|
|
579
|
+
allowedOn: string[];
|
|
578
580
|
name: string;
|
|
579
581
|
slug: string;
|
|
580
582
|
category: string;
|
|
581
583
|
description: string | null;
|
|
582
584
|
blockJson: unknown[];
|
|
583
585
|
props: unknown[];
|
|
586
|
+
variantGroupId?: string | null;
|
|
587
|
+
publishedVariantGroupId?: string | null;
|
|
588
|
+
variantInputMappings?: Array<{
|
|
589
|
+
inputId: string;
|
|
590
|
+
targets: Array<{
|
|
591
|
+
blockId: string;
|
|
592
|
+
path: string;
|
|
593
|
+
}>;
|
|
594
|
+
}>;
|
|
595
|
+
publishedVariantInputMappings?: Array<{
|
|
596
|
+
inputId: string;
|
|
597
|
+
targets: Array<{
|
|
598
|
+
blockId: string;
|
|
599
|
+
path: string;
|
|
600
|
+
}>;
|
|
601
|
+
}> | null;
|
|
584
602
|
thumbnail?: string | null;
|
|
585
603
|
}
|
|
586
604
|
/** Create/update input. `blockJson` is the ContentBlock tree; `props` the override allowlist. */
|
|
587
605
|
interface ManagedComponentInput {
|
|
606
|
+
projectId?: string | null;
|
|
607
|
+
allowedOn?: string[];
|
|
588
608
|
name?: string;
|
|
589
609
|
slug?: string;
|
|
590
610
|
category?: string;
|
|
@@ -644,6 +664,41 @@ interface SeoMeta {
|
|
|
644
664
|
jsonLd?: Record<string, unknown>;
|
|
645
665
|
}
|
|
646
666
|
|
|
667
|
+
type ManagedLayoutDocument = {
|
|
668
|
+
scope: "global";
|
|
669
|
+
revision: number;
|
|
670
|
+
etag: string;
|
|
671
|
+
status: string;
|
|
672
|
+
structure: LayoutStructureDocument;
|
|
673
|
+
data: LayoutDataDocument;
|
|
674
|
+
} | {
|
|
675
|
+
scope: "page";
|
|
676
|
+
pageId: string;
|
|
677
|
+
pageSlug: string;
|
|
678
|
+
revision: number;
|
|
679
|
+
etag: string;
|
|
680
|
+
status: string;
|
|
681
|
+
globalStructure: LayoutStructureDocument;
|
|
682
|
+
globalData: LayoutDataDocument;
|
|
683
|
+
override: PageLayoutOverrideDocument;
|
|
684
|
+
};
|
|
685
|
+
interface ManagedLayoutClient {
|
|
686
|
+
url(path: string): string;
|
|
687
|
+
fetchJSON<T>(url: string, init?: RequestInit): Promise<T>;
|
|
688
|
+
}
|
|
689
|
+
interface GetManagedLayoutOptions {
|
|
690
|
+
scope?: "global" | "page";
|
|
691
|
+
pageId?: string;
|
|
692
|
+
/** Required when the management credential is workspace-scoped. */
|
|
693
|
+
projectId?: string;
|
|
694
|
+
}
|
|
695
|
+
interface CommandManagedLayoutInput extends GetManagedLayoutOptions {
|
|
696
|
+
command: ManagementLayoutCommand;
|
|
697
|
+
ifMatch: number;
|
|
698
|
+
}
|
|
699
|
+
declare function getManagedLayout(client: ManagedLayoutClient, opts?: GetManagedLayoutOptions): Promise<ManagedLayoutDocument>;
|
|
700
|
+
declare function commandManagedLayout(client: ManagedLayoutClient, input: CommandManagedLayoutInput): Promise<ManagedLayoutDocument>;
|
|
701
|
+
|
|
647
702
|
interface BetterCMSManagementOptions {
|
|
648
703
|
/** Base URL of the Management API. Defaults to https://api.bettercms.ai/v1 */
|
|
649
704
|
baseUrl?: string;
|
|
@@ -728,6 +783,8 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
|
|
|
728
783
|
component: ManagedComponent;
|
|
729
784
|
replaced: number;
|
|
730
785
|
}>;
|
|
786
|
+
getManagedLayout(opts?: GetManagedLayoutOptions): Promise<ManagedLayoutDocument>;
|
|
787
|
+
commandManagedLayout(input: CommandManagedLayoutInput): Promise<ManagedLayoutDocument>;
|
|
731
788
|
/** Write, rewrite, or translate a piece of copy. Returns the suggested text. */
|
|
732
789
|
writeContent(input: WriteContentInput): Promise<string>;
|
|
733
790
|
/** Generate SEO metadata for a piece of content (title, description, keywords, JSON-LD). */
|
|
@@ -846,7 +903,12 @@ interface CreateClientOptions {
|
|
|
846
903
|
* `/preview/:slug` endpoint. Only used when `perspective === "drafts"`.
|
|
847
904
|
*/
|
|
848
905
|
previewToken?: string;
|
|
849
|
-
/**
|
|
906
|
+
/**
|
|
907
|
+
* Embed invisible visual-editing provenance in draft reads, so a preview build can
|
|
908
|
+
* deep-link each rendered value back to its editor. Requires `perspective: "drafts"`,
|
|
909
|
+
* and then either a `previewToken` or a `content:read:draft` key. Ignored on published
|
|
910
|
+
* reads — the payload must never reach a production build.
|
|
911
|
+
*/
|
|
850
912
|
stega?: boolean;
|
|
851
913
|
/** Per-attempt timeout in ms. Defaults to 10000. */
|
|
852
914
|
timeout?: number;
|
|
@@ -875,6 +937,8 @@ interface BetterCMSReadClient {
|
|
|
875
937
|
listEntries<T = Record<string, unknown>>(opts?: ListEntriesOptions): Promise<DeliveryList<DeliveryEntry<T>>>;
|
|
876
938
|
getPage(slug: string): Promise<DeliveryPage | null>;
|
|
877
939
|
listPages(opts?: ListPagesOptions): Promise<DeliveryList<DeliveryPage>>;
|
|
940
|
+
/** Fetch the project-scoped Global Layout for the active perspective. */
|
|
941
|
+
getLayout(): Promise<DeliveredLayout | null>;
|
|
878
942
|
listForms(opts?: {
|
|
879
943
|
projectId?: string;
|
|
880
944
|
}): Promise<{
|
|
@@ -1262,4 +1326,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
|
|
|
1262
1326
|
declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
|
|
1263
1327
|
declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
|
|
1264
1328
|
|
|
1265
|
-
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 ExtractionCandidate, 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 RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, type UpdateApiKeyInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, 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, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
|
|
1329
|
+
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 CommandManagedLayoutInput, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type PageListOptions, type PendingInvite, type ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, type UpdateApiKeyInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
|
package/dist/index.js
CHANGED
|
@@ -171,6 +171,15 @@ var BetterCMSDeliveryClient = class {
|
|
|
171
171
|
listContentAll(opts) {
|
|
172
172
|
return listContentAll(this, opts);
|
|
173
173
|
}
|
|
174
|
+
async getLayout() {
|
|
175
|
+
try {
|
|
176
|
+
const result = await this.fetchJSON(`${this.baseUrl}/${this.workspace}/layout`);
|
|
177
|
+
return result.data;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (error instanceof BetterCMSError && error.status === 404) return null;
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
174
183
|
/** Build the full URL for a content path. */
|
|
175
184
|
url(path) {
|
|
176
185
|
return `${this.baseUrl}/${this.workspace}/content/${path}`;
|
|
@@ -703,6 +712,27 @@ async function generateSeoMeta(client, input) {
|
|
|
703
712
|
return res.data;
|
|
704
713
|
}
|
|
705
714
|
|
|
715
|
+
// src/methods/management/layout.ts
|
|
716
|
+
async function getManagedLayout(client, opts) {
|
|
717
|
+
const query = new URLSearchParams();
|
|
718
|
+
if (opts?.scope) query.set("scope", opts.scope);
|
|
719
|
+
if (opts?.pageId) query.set("pageId", opts.pageId);
|
|
720
|
+
const result = await client.fetchJSON(
|
|
721
|
+
client.url(`/management/layout${query.size ? `?${query}` : ""}`),
|
|
722
|
+
opts?.projectId ? { headers: { "X-BCMS-Project": opts.projectId } } : void 0
|
|
723
|
+
);
|
|
724
|
+
return result.data;
|
|
725
|
+
}
|
|
726
|
+
async function commandManagedLayout(client, input) {
|
|
727
|
+
const { ifMatch, projectId, ...body } = input;
|
|
728
|
+
const result = await client.fetchJSON(client.url("/management/layout/commands"), {
|
|
729
|
+
method: "POST",
|
|
730
|
+
headers: { "If-Match": `W/"${ifMatch}"`, ...projectId ? { "X-BCMS-Project": projectId } : {} },
|
|
731
|
+
body: JSON.stringify(body)
|
|
732
|
+
});
|
|
733
|
+
return result.data;
|
|
734
|
+
}
|
|
735
|
+
|
|
706
736
|
// src/management-client.ts
|
|
707
737
|
var DEFAULT_BASE_URL2 = "https://api.bettercms.ai/v1";
|
|
708
738
|
var DEFAULT_TIMEOUT2 = 1e4;
|
|
@@ -875,6 +905,13 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
|
|
|
875
905
|
extractComponent(input) {
|
|
876
906
|
return extractComponent(this, input);
|
|
877
907
|
}
|
|
908
|
+
// ── Layout: draft-only Global/page authoring; publishing remains dashboard-gated. ──
|
|
909
|
+
getManagedLayout(opts) {
|
|
910
|
+
return getManagedLayout(this, opts);
|
|
911
|
+
}
|
|
912
|
+
commandManagedLayout(input) {
|
|
913
|
+
return commandManagedLayout(this, input);
|
|
914
|
+
}
|
|
878
915
|
// ── AI (Option B): write/rewrite/translate copy + generate SEO meta (BYOK-metered) ──
|
|
879
916
|
/** Write, rewrite, or translate a piece of copy. Returns the suggested text. */
|
|
880
917
|
writeContent(input) {
|
|
@@ -1080,16 +1117,17 @@ function createClient(options) {
|
|
|
1080
1117
|
return {
|
|
1081
1118
|
perspective,
|
|
1082
1119
|
async getEntry(slug, opts) {
|
|
1083
|
-
const query = qs({
|
|
1084
|
-
depth: opts?.depth,
|
|
1085
|
-
select: opts?.select?.join(",")
|
|
1086
|
-
});
|
|
1087
1120
|
const url = draft && previewToken ? `${apiUrl}/api/v1/preview/${encodeURIComponent(slug)}${qs({
|
|
1088
1121
|
token: previewToken,
|
|
1089
1122
|
depth: opts?.depth,
|
|
1090
1123
|
select: opts?.select?.join(","),
|
|
1091
1124
|
stega: options.stega ? "1" : void 0
|
|
1092
|
-
})}` : `${base}/content-entries/${encodeURIComponent(slug)}${
|
|
1125
|
+
})}` : `${base}/content-entries/${encodeURIComponent(slug)}${qs({
|
|
1126
|
+
depth: opts?.depth,
|
|
1127
|
+
select: opts?.select?.join(","),
|
|
1128
|
+
perspective: draft ? "draft" : void 0,
|
|
1129
|
+
stega: draft && options.stega ? "1" : void 0
|
|
1130
|
+
})}`;
|
|
1093
1131
|
return unwrap(await fetchJSON(url));
|
|
1094
1132
|
},
|
|
1095
1133
|
async listEntries(opts) {
|
|
@@ -1098,7 +1136,9 @@ function createClient(options) {
|
|
|
1098
1136
|
page: opts?.page,
|
|
1099
1137
|
perPage: opts?.perPage,
|
|
1100
1138
|
depth: opts?.depth,
|
|
1101
|
-
select: opts?.select?.join(",")
|
|
1139
|
+
select: opts?.select?.join(","),
|
|
1140
|
+
perspective: draft ? "draft" : void 0,
|
|
1141
|
+
stega: draft && options.stega ? "1" : void 0
|
|
1102
1142
|
})}`;
|
|
1103
1143
|
return unwrap(await fetchJSON(url));
|
|
1104
1144
|
},
|
|
@@ -1119,6 +1159,15 @@ function createClient(options) {
|
|
|
1119
1159
|
})}`;
|
|
1120
1160
|
return unwrap(await fetchJSON(url));
|
|
1121
1161
|
},
|
|
1162
|
+
async getLayout() {
|
|
1163
|
+
const url = `${base}/layout${draft ? "?perspective=draft" : ""}`;
|
|
1164
|
+
try {
|
|
1165
|
+
return unwrap(await fetchJSON(url));
|
|
1166
|
+
} catch (error) {
|
|
1167
|
+
if (error instanceof BetterCMSError && error.status === 404) return null;
|
|
1168
|
+
throw error;
|
|
1169
|
+
}
|
|
1170
|
+
},
|
|
1122
1171
|
async listForms(opts) {
|
|
1123
1172
|
const url = `${base}/forms${qs({
|
|
1124
1173
|
projectId: opts?.projectId ?? defaultProjectId
|
|
@@ -1556,6 +1605,7 @@ export {
|
|
|
1556
1605
|
addModelFields,
|
|
1557
1606
|
addPageFields,
|
|
1558
1607
|
asStringArray,
|
|
1608
|
+
commandManagedLayout,
|
|
1559
1609
|
createApiKey,
|
|
1560
1610
|
createClient,
|
|
1561
1611
|
createEntry,
|
|
@@ -1576,6 +1626,7 @@ export {
|
|
|
1576
1626
|
getBlockType,
|
|
1577
1627
|
getEntry,
|
|
1578
1628
|
getForm2 as getForm,
|
|
1629
|
+
getManagedLayout,
|
|
1579
1630
|
getManagedPage,
|
|
1580
1631
|
getMedia,
|
|
1581
1632
|
getMember,
|