@bettercms-ai/sdk 1.10.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 +82 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -3
- package/dist/index.d.ts +138 -3
- package/dist/index.js +80 -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. */
|
|
@@ -274,6 +275,14 @@ interface CreateModelInput {
|
|
|
274
275
|
description?: string;
|
|
275
276
|
fields?: ContentModelField[];
|
|
276
277
|
projectId?: string;
|
|
278
|
+
/**
|
|
279
|
+
* 'model' (default) = a collection with entries of its own. 'block' = a type instantiable
|
|
280
|
+
* only inside another model's `modular` field; entry creation against it is refused.
|
|
281
|
+
*
|
|
282
|
+
* CREATE-ONLY, and absent from UpdateModelInput on purpose: flipping a populated model into
|
|
283
|
+
* a block would orphan every entry it already has.
|
|
284
|
+
*/
|
|
285
|
+
kind?: "model" | "block";
|
|
277
286
|
}
|
|
278
287
|
interface UpdateModelInput {
|
|
279
288
|
name?: string;
|
|
@@ -567,16 +576,35 @@ interface ManagedFormInput {
|
|
|
567
576
|
interface ManagedComponent {
|
|
568
577
|
id: string;
|
|
569
578
|
projectId: string | null;
|
|
579
|
+
allowedOn: string[];
|
|
570
580
|
name: string;
|
|
571
581
|
slug: string;
|
|
572
582
|
category: string;
|
|
573
583
|
description: string | null;
|
|
574
584
|
blockJson: unknown[];
|
|
575
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;
|
|
576
602
|
thumbnail?: string | null;
|
|
577
603
|
}
|
|
578
604
|
/** Create/update input. `blockJson` is the ContentBlock tree; `props` the override allowlist. */
|
|
579
605
|
interface ManagedComponentInput {
|
|
606
|
+
projectId?: string | null;
|
|
607
|
+
allowedOn?: string[];
|
|
580
608
|
name?: string;
|
|
581
609
|
slug?: string;
|
|
582
610
|
category?: string;
|
|
@@ -584,6 +612,27 @@ interface ManagedComponentInput {
|
|
|
584
612
|
blockJson?: unknown[];
|
|
585
613
|
props?: unknown[];
|
|
586
614
|
}
|
|
615
|
+
/**
|
|
616
|
+
* A set of sections that repeat across the project's pages, proposed as one component.
|
|
617
|
+
* Derived per request from the pages' DRAFT blocks — never stored.
|
|
618
|
+
*/
|
|
619
|
+
interface ExtractionCandidate {
|
|
620
|
+
/** Identifies the shape. Pass it back to `extractComponent`; it is re-verified server-side. */
|
|
621
|
+
hash: string;
|
|
622
|
+
blockType: string;
|
|
623
|
+
uses: number;
|
|
624
|
+
suggestedName: string;
|
|
625
|
+
blockJson: unknown[];
|
|
626
|
+
/** The leaves that differ between copies, which become the component's editable props. */
|
|
627
|
+
props: unknown[];
|
|
628
|
+
sites: {
|
|
629
|
+
pageId: string;
|
|
630
|
+
title: string;
|
|
631
|
+
slug: string;
|
|
632
|
+
blockId: string;
|
|
633
|
+
overrides: Record<string, unknown>;
|
|
634
|
+
}[];
|
|
635
|
+
}
|
|
587
636
|
|
|
588
637
|
/**
|
|
589
638
|
* Management API SDK methods — AI content + SEO actions (Option B, portable skill).
|
|
@@ -615,6 +664,41 @@ interface SeoMeta {
|
|
|
615
664
|
jsonLd?: Record<string, unknown>;
|
|
616
665
|
}
|
|
617
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
|
+
|
|
618
702
|
interface BetterCMSManagementOptions {
|
|
619
703
|
/** Base URL of the Management API. Defaults to https://api.bettercms.ai/v1 */
|
|
620
704
|
baseUrl?: string;
|
|
@@ -687,6 +771,20 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
|
|
|
687
771
|
getComponent(id: string): Promise<ManagedComponent>;
|
|
688
772
|
createComponent(input: ManagedComponentInput): Promise<ManagedComponent>;
|
|
689
773
|
updateComponent(id: string, input: ManagedComponentInput): Promise<ManagedComponent>;
|
|
774
|
+
/** Sections repeating across the project's pages, proposed as components. */
|
|
775
|
+
listExtractionCandidates(projectId?: string): Promise<ExtractionCandidate[]>;
|
|
776
|
+
/** Fold one candidate into a component and repoint every occurrence at it. */
|
|
777
|
+
extractComponent(input: {
|
|
778
|
+
hash: string;
|
|
779
|
+
name: string;
|
|
780
|
+
slug: string;
|
|
781
|
+
projectId?: string;
|
|
782
|
+
}): Promise<{
|
|
783
|
+
component: ManagedComponent;
|
|
784
|
+
replaced: number;
|
|
785
|
+
}>;
|
|
786
|
+
getManagedLayout(opts?: GetManagedLayoutOptions): Promise<ManagedLayoutDocument>;
|
|
787
|
+
commandManagedLayout(input: CommandManagedLayoutInput): Promise<ManagedLayoutDocument>;
|
|
690
788
|
/** Write, rewrite, or translate a piece of copy. Returns the suggested text. */
|
|
691
789
|
writeContent(input: WriteContentInput): Promise<string>;
|
|
692
790
|
/** Generate SEO metadata for a piece of content (title, description, keywords, JSON-LD). */
|
|
@@ -805,7 +903,12 @@ interface CreateClientOptions {
|
|
|
805
903
|
* `/preview/:slug` endpoint. Only used when `perspective === "drafts"`.
|
|
806
904
|
*/
|
|
807
905
|
previewToken?: string;
|
|
808
|
-
/**
|
|
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
|
+
*/
|
|
809
912
|
stega?: boolean;
|
|
810
913
|
/** Per-attempt timeout in ms. Defaults to 10000. */
|
|
811
914
|
timeout?: number;
|
|
@@ -834,6 +937,8 @@ interface BetterCMSReadClient {
|
|
|
834
937
|
listEntries<T = Record<string, unknown>>(opts?: ListEntriesOptions): Promise<DeliveryList<DeliveryEntry<T>>>;
|
|
835
938
|
getPage(slug: string): Promise<DeliveryPage | null>;
|
|
836
939
|
listPages(opts?: ListPagesOptions): Promise<DeliveryList<DeliveryPage>>;
|
|
940
|
+
/** Fetch the project-scoped Global Layout for the active perspective. */
|
|
941
|
+
getLayout(): Promise<DeliveredLayout | null>;
|
|
837
942
|
listForms(opts?: {
|
|
838
943
|
projectId?: string;
|
|
839
944
|
}): Promise<{
|
|
@@ -887,12 +992,42 @@ declare function stripStega(value: string): string;
|
|
|
887
992
|
* <h1 dangerouslySetInnerHTML={{ __html: rich(f.heroTitle) }}/> // React
|
|
888
993
|
* seo({ title: plain(page.heroTitle) })
|
|
889
994
|
*/
|
|
995
|
+
/**
|
|
996
|
+
* A block in a Body field's `doc`. Bounded vocabulary — the server only emits what it can
|
|
997
|
+
* parse back, so an unknown `type` means your SDK is older than the content, not that the
|
|
998
|
+
* content is malformed. Handle the default case rather than exhausting on it.
|
|
999
|
+
*/
|
|
1000
|
+
type DocBlock = {
|
|
1001
|
+
/**
|
|
1002
|
+
* Stable within THIS document only — never a global key. Two different entries both have a
|
|
1003
|
+
* block called "0.0". A cross-document anchor is (entryId, fieldKey, id).
|
|
1004
|
+
*
|
|
1005
|
+
* Ids on content authored before block ids existed are derived from position, so they SHIFT
|
|
1006
|
+
* when that document is edited. Do not persist an id as a bookmark unless you know it came
|
|
1007
|
+
* from the editor rather than from the positional fallback.
|
|
1008
|
+
*/
|
|
1009
|
+
readonly id: string;
|
|
1010
|
+
readonly type: string;
|
|
1011
|
+
readonly [key: string]: unknown;
|
|
1012
|
+
};
|
|
1013
|
+
/** The `doc` rendition of a Body field — a versioned block array. */
|
|
1014
|
+
type DocValue = {
|
|
1015
|
+
readonly version: 1;
|
|
1016
|
+
readonly blocks: readonly DocBlock[];
|
|
1017
|
+
};
|
|
890
1018
|
/** The canonical rich-text envelope returned by the Delivery API. */
|
|
891
1019
|
interface RichTextValue {
|
|
892
1020
|
readonly format?: string;
|
|
893
1021
|
readonly value?: unknown;
|
|
894
1022
|
/** Server-rendered, sanitized HTML. Computed on write. */
|
|
895
1023
|
readonly html?: string;
|
|
1024
|
+
/**
|
|
1025
|
+
* Structured blocks — present on `document` (Body) fields only, and NOT guaranteed even
|
|
1026
|
+
* there: it is derived at write time, so an entry saved before this existed carries none
|
|
1027
|
+
* until its next save. There is no backfill. Always branch on its absence; `html` is the
|
|
1028
|
+
* field that is always there.
|
|
1029
|
+
*/
|
|
1030
|
+
readonly doc?: DocValue;
|
|
896
1031
|
}
|
|
897
1032
|
/**
|
|
898
1033
|
* A field that may arrive as either shape. Type author-editable text fields with this and the
|
|
@@ -1191,4 +1326,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
|
|
|
1191
1326
|
declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
|
|
1192
1327
|
declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
|
|
1193
1328
|
|
|
1194
|
-
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 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. */
|
|
@@ -274,6 +275,14 @@ interface CreateModelInput {
|
|
|
274
275
|
description?: string;
|
|
275
276
|
fields?: ContentModelField[];
|
|
276
277
|
projectId?: string;
|
|
278
|
+
/**
|
|
279
|
+
* 'model' (default) = a collection with entries of its own. 'block' = a type instantiable
|
|
280
|
+
* only inside another model's `modular` field; entry creation against it is refused.
|
|
281
|
+
*
|
|
282
|
+
* CREATE-ONLY, and absent from UpdateModelInput on purpose: flipping a populated model into
|
|
283
|
+
* a block would orphan every entry it already has.
|
|
284
|
+
*/
|
|
285
|
+
kind?: "model" | "block";
|
|
277
286
|
}
|
|
278
287
|
interface UpdateModelInput {
|
|
279
288
|
name?: string;
|
|
@@ -567,16 +576,35 @@ interface ManagedFormInput {
|
|
|
567
576
|
interface ManagedComponent {
|
|
568
577
|
id: string;
|
|
569
578
|
projectId: string | null;
|
|
579
|
+
allowedOn: string[];
|
|
570
580
|
name: string;
|
|
571
581
|
slug: string;
|
|
572
582
|
category: string;
|
|
573
583
|
description: string | null;
|
|
574
584
|
blockJson: unknown[];
|
|
575
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;
|
|
576
602
|
thumbnail?: string | null;
|
|
577
603
|
}
|
|
578
604
|
/** Create/update input. `blockJson` is the ContentBlock tree; `props` the override allowlist. */
|
|
579
605
|
interface ManagedComponentInput {
|
|
606
|
+
projectId?: string | null;
|
|
607
|
+
allowedOn?: string[];
|
|
580
608
|
name?: string;
|
|
581
609
|
slug?: string;
|
|
582
610
|
category?: string;
|
|
@@ -584,6 +612,27 @@ interface ManagedComponentInput {
|
|
|
584
612
|
blockJson?: unknown[];
|
|
585
613
|
props?: unknown[];
|
|
586
614
|
}
|
|
615
|
+
/**
|
|
616
|
+
* A set of sections that repeat across the project's pages, proposed as one component.
|
|
617
|
+
* Derived per request from the pages' DRAFT blocks — never stored.
|
|
618
|
+
*/
|
|
619
|
+
interface ExtractionCandidate {
|
|
620
|
+
/** Identifies the shape. Pass it back to `extractComponent`; it is re-verified server-side. */
|
|
621
|
+
hash: string;
|
|
622
|
+
blockType: string;
|
|
623
|
+
uses: number;
|
|
624
|
+
suggestedName: string;
|
|
625
|
+
blockJson: unknown[];
|
|
626
|
+
/** The leaves that differ between copies, which become the component's editable props. */
|
|
627
|
+
props: unknown[];
|
|
628
|
+
sites: {
|
|
629
|
+
pageId: string;
|
|
630
|
+
title: string;
|
|
631
|
+
slug: string;
|
|
632
|
+
blockId: string;
|
|
633
|
+
overrides: Record<string, unknown>;
|
|
634
|
+
}[];
|
|
635
|
+
}
|
|
587
636
|
|
|
588
637
|
/**
|
|
589
638
|
* Management API SDK methods — AI content + SEO actions (Option B, portable skill).
|
|
@@ -615,6 +664,41 @@ interface SeoMeta {
|
|
|
615
664
|
jsonLd?: Record<string, unknown>;
|
|
616
665
|
}
|
|
617
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
|
+
|
|
618
702
|
interface BetterCMSManagementOptions {
|
|
619
703
|
/** Base URL of the Management API. Defaults to https://api.bettercms.ai/v1 */
|
|
620
704
|
baseUrl?: string;
|
|
@@ -687,6 +771,20 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
|
|
|
687
771
|
getComponent(id: string): Promise<ManagedComponent>;
|
|
688
772
|
createComponent(input: ManagedComponentInput): Promise<ManagedComponent>;
|
|
689
773
|
updateComponent(id: string, input: ManagedComponentInput): Promise<ManagedComponent>;
|
|
774
|
+
/** Sections repeating across the project's pages, proposed as components. */
|
|
775
|
+
listExtractionCandidates(projectId?: string): Promise<ExtractionCandidate[]>;
|
|
776
|
+
/** Fold one candidate into a component and repoint every occurrence at it. */
|
|
777
|
+
extractComponent(input: {
|
|
778
|
+
hash: string;
|
|
779
|
+
name: string;
|
|
780
|
+
slug: string;
|
|
781
|
+
projectId?: string;
|
|
782
|
+
}): Promise<{
|
|
783
|
+
component: ManagedComponent;
|
|
784
|
+
replaced: number;
|
|
785
|
+
}>;
|
|
786
|
+
getManagedLayout(opts?: GetManagedLayoutOptions): Promise<ManagedLayoutDocument>;
|
|
787
|
+
commandManagedLayout(input: CommandManagedLayoutInput): Promise<ManagedLayoutDocument>;
|
|
690
788
|
/** Write, rewrite, or translate a piece of copy. Returns the suggested text. */
|
|
691
789
|
writeContent(input: WriteContentInput): Promise<string>;
|
|
692
790
|
/** Generate SEO metadata for a piece of content (title, description, keywords, JSON-LD). */
|
|
@@ -805,7 +903,12 @@ interface CreateClientOptions {
|
|
|
805
903
|
* `/preview/:slug` endpoint. Only used when `perspective === "drafts"`.
|
|
806
904
|
*/
|
|
807
905
|
previewToken?: string;
|
|
808
|
-
/**
|
|
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
|
+
*/
|
|
809
912
|
stega?: boolean;
|
|
810
913
|
/** Per-attempt timeout in ms. Defaults to 10000. */
|
|
811
914
|
timeout?: number;
|
|
@@ -834,6 +937,8 @@ interface BetterCMSReadClient {
|
|
|
834
937
|
listEntries<T = Record<string, unknown>>(opts?: ListEntriesOptions): Promise<DeliveryList<DeliveryEntry<T>>>;
|
|
835
938
|
getPage(slug: string): Promise<DeliveryPage | null>;
|
|
836
939
|
listPages(opts?: ListPagesOptions): Promise<DeliveryList<DeliveryPage>>;
|
|
940
|
+
/** Fetch the project-scoped Global Layout for the active perspective. */
|
|
941
|
+
getLayout(): Promise<DeliveredLayout | null>;
|
|
837
942
|
listForms(opts?: {
|
|
838
943
|
projectId?: string;
|
|
839
944
|
}): Promise<{
|
|
@@ -887,12 +992,42 @@ declare function stripStega(value: string): string;
|
|
|
887
992
|
* <h1 dangerouslySetInnerHTML={{ __html: rich(f.heroTitle) }}/> // React
|
|
888
993
|
* seo({ title: plain(page.heroTitle) })
|
|
889
994
|
*/
|
|
995
|
+
/**
|
|
996
|
+
* A block in a Body field's `doc`. Bounded vocabulary — the server only emits what it can
|
|
997
|
+
* parse back, so an unknown `type` means your SDK is older than the content, not that the
|
|
998
|
+
* content is malformed. Handle the default case rather than exhausting on it.
|
|
999
|
+
*/
|
|
1000
|
+
type DocBlock = {
|
|
1001
|
+
/**
|
|
1002
|
+
* Stable within THIS document only — never a global key. Two different entries both have a
|
|
1003
|
+
* block called "0.0". A cross-document anchor is (entryId, fieldKey, id).
|
|
1004
|
+
*
|
|
1005
|
+
* Ids on content authored before block ids existed are derived from position, so they SHIFT
|
|
1006
|
+
* when that document is edited. Do not persist an id as a bookmark unless you know it came
|
|
1007
|
+
* from the editor rather than from the positional fallback.
|
|
1008
|
+
*/
|
|
1009
|
+
readonly id: string;
|
|
1010
|
+
readonly type: string;
|
|
1011
|
+
readonly [key: string]: unknown;
|
|
1012
|
+
};
|
|
1013
|
+
/** The `doc` rendition of a Body field — a versioned block array. */
|
|
1014
|
+
type DocValue = {
|
|
1015
|
+
readonly version: 1;
|
|
1016
|
+
readonly blocks: readonly DocBlock[];
|
|
1017
|
+
};
|
|
890
1018
|
/** The canonical rich-text envelope returned by the Delivery API. */
|
|
891
1019
|
interface RichTextValue {
|
|
892
1020
|
readonly format?: string;
|
|
893
1021
|
readonly value?: unknown;
|
|
894
1022
|
/** Server-rendered, sanitized HTML. Computed on write. */
|
|
895
1023
|
readonly html?: string;
|
|
1024
|
+
/**
|
|
1025
|
+
* Structured blocks — present on `document` (Body) fields only, and NOT guaranteed even
|
|
1026
|
+
* there: it is derived at write time, so an entry saved before this existed carries none
|
|
1027
|
+
* until its next save. There is no backfill. Always branch on its absence; `html` is the
|
|
1028
|
+
* field that is always there.
|
|
1029
|
+
*/
|
|
1030
|
+
readonly doc?: DocValue;
|
|
896
1031
|
}
|
|
897
1032
|
/**
|
|
898
1033
|
* A field that may arrive as either shape. Type author-editable text fields with this and the
|
|
@@ -1191,4 +1326,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
|
|
|
1191
1326
|
declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
|
|
1192
1327
|
declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
|
|
1193
1328
|
|
|
1194
|
-
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 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}`;
|
|
@@ -664,6 +673,21 @@ async function createComponent(client, input) {
|
|
|
664
673
|
});
|
|
665
674
|
return res.data;
|
|
666
675
|
}
|
|
676
|
+
async function listExtractionCandidates(client, projectId) {
|
|
677
|
+
const qs3 = projectId ? `?projectId=${encodeURIComponent(projectId)}` : "";
|
|
678
|
+
const res = await client.fetchJSON(
|
|
679
|
+
client.url(`/management/components/extraction-candidates${qs3}`),
|
|
680
|
+
{ method: "GET" }
|
|
681
|
+
);
|
|
682
|
+
return res.data;
|
|
683
|
+
}
|
|
684
|
+
async function extractComponent(client, input) {
|
|
685
|
+
const res = await client.fetchJSON(
|
|
686
|
+
client.url("/management/components/extract"),
|
|
687
|
+
{ method: "POST", body: JSON.stringify(input) }
|
|
688
|
+
);
|
|
689
|
+
return { component: res.data, replaced: res.replaced };
|
|
690
|
+
}
|
|
667
691
|
async function updateComponent(client, id, input) {
|
|
668
692
|
const res = await client.fetchJSON(
|
|
669
693
|
client.url(`/management/components/${id}`),
|
|
@@ -688,6 +712,27 @@ async function generateSeoMeta(client, input) {
|
|
|
688
712
|
return res.data;
|
|
689
713
|
}
|
|
690
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
|
+
|
|
691
736
|
// src/management-client.ts
|
|
692
737
|
var DEFAULT_BASE_URL2 = "https://api.bettercms.ai/v1";
|
|
693
738
|
var DEFAULT_TIMEOUT2 = 1e4;
|
|
@@ -852,6 +897,21 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
|
|
|
852
897
|
updateComponent(id, input) {
|
|
853
898
|
return updateComponent(this, id, input);
|
|
854
899
|
}
|
|
900
|
+
/** Sections repeating across the project's pages, proposed as components. */
|
|
901
|
+
listExtractionCandidates(projectId) {
|
|
902
|
+
return listExtractionCandidates(this, projectId);
|
|
903
|
+
}
|
|
904
|
+
/** Fold one candidate into a component and repoint every occurrence at it. */
|
|
905
|
+
extractComponent(input) {
|
|
906
|
+
return extractComponent(this, input);
|
|
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
|
+
}
|
|
855
915
|
// ── AI (Option B): write/rewrite/translate copy + generate SEO meta (BYOK-metered) ──
|
|
856
916
|
/** Write, rewrite, or translate a piece of copy. Returns the suggested text. */
|
|
857
917
|
writeContent(input) {
|
|
@@ -1057,16 +1117,17 @@ function createClient(options) {
|
|
|
1057
1117
|
return {
|
|
1058
1118
|
perspective,
|
|
1059
1119
|
async getEntry(slug, opts) {
|
|
1060
|
-
const query = qs({
|
|
1061
|
-
depth: opts?.depth,
|
|
1062
|
-
select: opts?.select?.join(",")
|
|
1063
|
-
});
|
|
1064
1120
|
const url = draft && previewToken ? `${apiUrl}/api/v1/preview/${encodeURIComponent(slug)}${qs({
|
|
1065
1121
|
token: previewToken,
|
|
1066
1122
|
depth: opts?.depth,
|
|
1067
1123
|
select: opts?.select?.join(","),
|
|
1068
1124
|
stega: options.stega ? "1" : void 0
|
|
1069
|
-
})}` : `${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
|
+
})}`;
|
|
1070
1131
|
return unwrap(await fetchJSON(url));
|
|
1071
1132
|
},
|
|
1072
1133
|
async listEntries(opts) {
|
|
@@ -1075,7 +1136,9 @@ function createClient(options) {
|
|
|
1075
1136
|
page: opts?.page,
|
|
1076
1137
|
perPage: opts?.perPage,
|
|
1077
1138
|
depth: opts?.depth,
|
|
1078
|
-
select: opts?.select?.join(",")
|
|
1139
|
+
select: opts?.select?.join(","),
|
|
1140
|
+
perspective: draft ? "draft" : void 0,
|
|
1141
|
+
stega: draft && options.stega ? "1" : void 0
|
|
1079
1142
|
})}`;
|
|
1080
1143
|
return unwrap(await fetchJSON(url));
|
|
1081
1144
|
},
|
|
@@ -1096,6 +1159,15 @@ function createClient(options) {
|
|
|
1096
1159
|
})}`;
|
|
1097
1160
|
return unwrap(await fetchJSON(url));
|
|
1098
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
|
+
},
|
|
1099
1171
|
async listForms(opts) {
|
|
1100
1172
|
const url = `${base}/forms${qs({
|
|
1101
1173
|
projectId: opts?.projectId ?? defaultProjectId
|
|
@@ -1533,6 +1605,7 @@ export {
|
|
|
1533
1605
|
addModelFields,
|
|
1534
1606
|
addPageFields,
|
|
1535
1607
|
asStringArray,
|
|
1608
|
+
commandManagedLayout,
|
|
1536
1609
|
createApiKey,
|
|
1537
1610
|
createClient,
|
|
1538
1611
|
createEntry,
|
|
@@ -1553,6 +1626,7 @@ export {
|
|
|
1553
1626
|
getBlockType,
|
|
1554
1627
|
getEntry,
|
|
1555
1628
|
getForm2 as getForm,
|
|
1629
|
+
getManagedLayout,
|
|
1556
1630
|
getManagedPage,
|
|
1557
1631
|
getMedia,
|
|
1558
1632
|
getMember,
|