@bettercms-ai/sdk 1.17.0 → 1.19.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 +54 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -4
- package/dist/index.d.ts +53 -4
- package/dist/index.js +54 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _bettercms_ai_types 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
|
-
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';
|
|
2
|
+
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, BetterCMSErrorCode, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, DeliveryComponent, PageMetaJson, SiteSeoDefaults, Page, MediaAsset, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
|
|
3
|
+
export { ApiError, ApiKey, ApiKeyPermission, ApiKeyTokenType, AssertEqual, AuthSession, AuthUser, BetterCMSErrorCode, BlockType, ButtonBlock, ButtonProps, ColumnsBlock, ColumnsProps, Content, ContentBlock, ContentEntry, ContentModel, ContentModelField, ContentPageResult, ContentResponse, DeepReadonly, DeliveryComponent, 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
|
|
|
6
6
|
/**
|
|
@@ -426,7 +426,17 @@ declare class BetterCMSError extends Error {
|
|
|
426
426
|
* hint which field or rule failed (FLO-474). Mirrors the forms client's `fieldErrors`.
|
|
427
427
|
*/
|
|
428
428
|
readonly fieldErrors?: Record<string, string>;
|
|
429
|
-
|
|
429
|
+
/**
|
|
430
|
+
* The parsed response body, when there was one.
|
|
431
|
+
*
|
|
432
|
+
* Several refusals carry STRUCTURED detail that neither `message` nor `fieldErrors` can hold,
|
|
433
|
+
* and which is the whole point of the refusal: a component publish 409s with the full
|
|
434
|
+
* `readiness` tuple (what evidence is missing, whether a human still has to approve it) and
|
|
435
|
+
* 422s with the `issues` naming the Layouts it would break. Collapsing those to a sentence
|
|
436
|
+
* leaves a caller able to report that something failed and not what to do about it.
|
|
437
|
+
*/
|
|
438
|
+
readonly body?: unknown;
|
|
439
|
+
constructor(message: string, status: number, code: BetterCMSErrorCode, bodyCode?: string, fieldErrors?: Record<string, string>, body?: unknown);
|
|
430
440
|
toJSON(): {
|
|
431
441
|
name: string;
|
|
432
442
|
message: string;
|
|
@@ -628,10 +638,40 @@ interface ManagedComponentInput {
|
|
|
628
638
|
name?: string;
|
|
629
639
|
slug?: string;
|
|
630
640
|
category?: string;
|
|
641
|
+
sectionType?: string | null;
|
|
642
|
+
/**
|
|
643
|
+
* The organisational Group, by NAME. The API resolves it against the project's Groups and
|
|
644
|
+
* creates it when missing — a caller filing a whole site's components into folders has a name
|
|
645
|
+
* ("Sections"), never an id.
|
|
646
|
+
*/
|
|
647
|
+
group?: string;
|
|
648
|
+
groupId?: string | null;
|
|
631
649
|
description?: string;
|
|
632
650
|
blockJson?: unknown[];
|
|
633
651
|
props?: unknown[];
|
|
634
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* The catalogue shape: what each component IS, without its block trees.
|
|
655
|
+
*
|
|
656
|
+
* The default list carries every component's draft AND live `blockJson`, which on a
|
|
657
|
+
* componentized site is the largest response this API produces — and a caller asking which
|
|
658
|
+
* components exist wants none of it. This shape also carries `sectionType`, `status` and the
|
|
659
|
+
* Group, the three facts that decide whether a component is insertable, whether it is on the
|
|
660
|
+
* live site, and where an editor finds it.
|
|
661
|
+
*/
|
|
662
|
+
interface ManagedComponentSummary {
|
|
663
|
+
id: string;
|
|
664
|
+
projectId: string | null;
|
|
665
|
+
name: string;
|
|
666
|
+
slug: string;
|
|
667
|
+
category: string;
|
|
668
|
+
sectionType: string | null;
|
|
669
|
+
status: string | null;
|
|
670
|
+
groupId: string | null;
|
|
671
|
+
groupName: string | null;
|
|
672
|
+
updatedAt: string | null;
|
|
673
|
+
builtin?: boolean;
|
|
674
|
+
}
|
|
635
675
|
/**
|
|
636
676
|
* A set of sections that repeat across the project's pages, proposed as one component.
|
|
637
677
|
* Derived per request from the pages' DRAFT blocks — never stored.
|
|
@@ -809,6 +849,9 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
|
|
|
809
849
|
/** Update a form by id (passing `fields` replaces the array). */
|
|
810
850
|
updateForm(id: string, input: ManagedFormInput): Promise<ManagedForm>;
|
|
811
851
|
listComponents(): Promise<ManagedComponent[]>;
|
|
852
|
+
listComponents(options: {
|
|
853
|
+
select: "summary";
|
|
854
|
+
}): Promise<ManagedComponentSummary[]>;
|
|
812
855
|
getComponent(id: string): Promise<ManagedComponent>;
|
|
813
856
|
createComponent(input: ManagedComponentInput): Promise<ManagedComponent>;
|
|
814
857
|
updateComponent(id: string, input: ManagedComponentInput): Promise<ManagedComponent>;
|
|
@@ -1007,6 +1050,12 @@ interface BetterCMSReadClient {
|
|
|
1007
1050
|
listEntries<T = Record<string, unknown>>(opts?: ListEntriesOptions): Promise<DeliveryList<DeliveryEntry<T>>>;
|
|
1008
1051
|
getPage(slug: string): Promise<DeliveryPage | null>;
|
|
1009
1052
|
listPages(opts?: ListPagesOptions): Promise<DeliveryList<DeliveryPage>>;
|
|
1053
|
+
/**
|
|
1054
|
+
* The workspace's reusable component definitions, for resolving `component` blocks.
|
|
1055
|
+
* Under `perspective: "drafts"` this is the DRAFT definition — what makes an SSR render
|
|
1056
|
+
* of a draft page look like the page the editor is showing.
|
|
1057
|
+
*/
|
|
1058
|
+
listComponents(): Promise<DeliveryComponent[]>;
|
|
1010
1059
|
/** Fetch the project-scoped Global Layout for the active perspective. */
|
|
1011
1060
|
getLayout(): Promise<DeliveredLayout | null>;
|
|
1012
1061
|
listForms(opts?: {
|
|
@@ -1431,4 +1480,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
|
|
|
1431
1480
|
declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
|
|
1432
1481
|
declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
|
|
1433
1482
|
|
|
1434
|
-
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, PORTABLE_TEXT_FORMAT, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, 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, portableText, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
|
|
1483
|
+
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 ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, PORTABLE_TEXT_FORMAT, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, 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, portableText, publishManagedLayout, 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,6 +1,6 @@
|
|
|
1
1
|
import * as _bettercms_ai_types 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
|
-
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';
|
|
2
|
+
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, BetterCMSErrorCode, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, DeliveryComponent, PageMetaJson, SiteSeoDefaults, Page, MediaAsset, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
|
|
3
|
+
export { ApiError, ApiKey, ApiKeyPermission, ApiKeyTokenType, AssertEqual, AuthSession, AuthUser, BetterCMSErrorCode, BlockType, ButtonBlock, ButtonProps, ColumnsBlock, ColumnsProps, Content, ContentBlock, ContentEntry, ContentModel, ContentModelField, ContentPageResult, ContentResponse, DeepReadonly, DeliveryComponent, 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
|
|
|
6
6
|
/**
|
|
@@ -426,7 +426,17 @@ declare class BetterCMSError extends Error {
|
|
|
426
426
|
* hint which field or rule failed (FLO-474). Mirrors the forms client's `fieldErrors`.
|
|
427
427
|
*/
|
|
428
428
|
readonly fieldErrors?: Record<string, string>;
|
|
429
|
-
|
|
429
|
+
/**
|
|
430
|
+
* The parsed response body, when there was one.
|
|
431
|
+
*
|
|
432
|
+
* Several refusals carry STRUCTURED detail that neither `message` nor `fieldErrors` can hold,
|
|
433
|
+
* and which is the whole point of the refusal: a component publish 409s with the full
|
|
434
|
+
* `readiness` tuple (what evidence is missing, whether a human still has to approve it) and
|
|
435
|
+
* 422s with the `issues` naming the Layouts it would break. Collapsing those to a sentence
|
|
436
|
+
* leaves a caller able to report that something failed and not what to do about it.
|
|
437
|
+
*/
|
|
438
|
+
readonly body?: unknown;
|
|
439
|
+
constructor(message: string, status: number, code: BetterCMSErrorCode, bodyCode?: string, fieldErrors?: Record<string, string>, body?: unknown);
|
|
430
440
|
toJSON(): {
|
|
431
441
|
name: string;
|
|
432
442
|
message: string;
|
|
@@ -628,10 +638,40 @@ interface ManagedComponentInput {
|
|
|
628
638
|
name?: string;
|
|
629
639
|
slug?: string;
|
|
630
640
|
category?: string;
|
|
641
|
+
sectionType?: string | null;
|
|
642
|
+
/**
|
|
643
|
+
* The organisational Group, by NAME. The API resolves it against the project's Groups and
|
|
644
|
+
* creates it when missing — a caller filing a whole site's components into folders has a name
|
|
645
|
+
* ("Sections"), never an id.
|
|
646
|
+
*/
|
|
647
|
+
group?: string;
|
|
648
|
+
groupId?: string | null;
|
|
631
649
|
description?: string;
|
|
632
650
|
blockJson?: unknown[];
|
|
633
651
|
props?: unknown[];
|
|
634
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* The catalogue shape: what each component IS, without its block trees.
|
|
655
|
+
*
|
|
656
|
+
* The default list carries every component's draft AND live `blockJson`, which on a
|
|
657
|
+
* componentized site is the largest response this API produces — and a caller asking which
|
|
658
|
+
* components exist wants none of it. This shape also carries `sectionType`, `status` and the
|
|
659
|
+
* Group, the three facts that decide whether a component is insertable, whether it is on the
|
|
660
|
+
* live site, and where an editor finds it.
|
|
661
|
+
*/
|
|
662
|
+
interface ManagedComponentSummary {
|
|
663
|
+
id: string;
|
|
664
|
+
projectId: string | null;
|
|
665
|
+
name: string;
|
|
666
|
+
slug: string;
|
|
667
|
+
category: string;
|
|
668
|
+
sectionType: string | null;
|
|
669
|
+
status: string | null;
|
|
670
|
+
groupId: string | null;
|
|
671
|
+
groupName: string | null;
|
|
672
|
+
updatedAt: string | null;
|
|
673
|
+
builtin?: boolean;
|
|
674
|
+
}
|
|
635
675
|
/**
|
|
636
676
|
* A set of sections that repeat across the project's pages, proposed as one component.
|
|
637
677
|
* Derived per request from the pages' DRAFT blocks — never stored.
|
|
@@ -809,6 +849,9 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
|
|
|
809
849
|
/** Update a form by id (passing `fields` replaces the array). */
|
|
810
850
|
updateForm(id: string, input: ManagedFormInput): Promise<ManagedForm>;
|
|
811
851
|
listComponents(): Promise<ManagedComponent[]>;
|
|
852
|
+
listComponents(options: {
|
|
853
|
+
select: "summary";
|
|
854
|
+
}): Promise<ManagedComponentSummary[]>;
|
|
812
855
|
getComponent(id: string): Promise<ManagedComponent>;
|
|
813
856
|
createComponent(input: ManagedComponentInput): Promise<ManagedComponent>;
|
|
814
857
|
updateComponent(id: string, input: ManagedComponentInput): Promise<ManagedComponent>;
|
|
@@ -1007,6 +1050,12 @@ interface BetterCMSReadClient {
|
|
|
1007
1050
|
listEntries<T = Record<string, unknown>>(opts?: ListEntriesOptions): Promise<DeliveryList<DeliveryEntry<T>>>;
|
|
1008
1051
|
getPage(slug: string): Promise<DeliveryPage | null>;
|
|
1009
1052
|
listPages(opts?: ListPagesOptions): Promise<DeliveryList<DeliveryPage>>;
|
|
1053
|
+
/**
|
|
1054
|
+
* The workspace's reusable component definitions, for resolving `component` blocks.
|
|
1055
|
+
* Under `perspective: "drafts"` this is the DRAFT definition — what makes an SSR render
|
|
1056
|
+
* of a draft page look like the page the editor is showing.
|
|
1057
|
+
*/
|
|
1058
|
+
listComponents(): Promise<DeliveryComponent[]>;
|
|
1010
1059
|
/** Fetch the project-scoped Global Layout for the active perspective. */
|
|
1011
1060
|
getLayout(): Promise<DeliveredLayout | null>;
|
|
1012
1061
|
listForms(opts?: {
|
|
@@ -1431,4 +1480,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
|
|
|
1431
1480
|
declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
|
|
1432
1481
|
declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
|
|
1433
1482
|
|
|
1434
|
-
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, PORTABLE_TEXT_FORMAT, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, 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, portableText, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
|
|
1483
|
+
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 ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, PORTABLE_TEXT_FORMAT, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, 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, portableText, publishManagedLayout, 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
|
@@ -35,13 +35,24 @@ var BetterCMSError = class _BetterCMSError extends Error {
|
|
|
35
35
|
* hint which field or rule failed (FLO-474). Mirrors the forms client's `fieldErrors`.
|
|
36
36
|
*/
|
|
37
37
|
fieldErrors;
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The parsed response body, when there was one.
|
|
40
|
+
*
|
|
41
|
+
* Several refusals carry STRUCTURED detail that neither `message` nor `fieldErrors` can hold,
|
|
42
|
+
* and which is the whole point of the refusal: a component publish 409s with the full
|
|
43
|
+
* `readiness` tuple (what evidence is missing, whether a human still has to approve it) and
|
|
44
|
+
* 422s with the `issues` naming the Layouts it would break. Collapsing those to a sentence
|
|
45
|
+
* leaves a caller able to report that something failed and not what to do about it.
|
|
46
|
+
*/
|
|
47
|
+
body;
|
|
48
|
+
constructor(message, status, code, bodyCode, fieldErrors, body) {
|
|
39
49
|
super(message);
|
|
40
50
|
this.name = "BetterCMSError";
|
|
41
51
|
this.status = status;
|
|
42
52
|
this.code = code;
|
|
43
53
|
this.bodyCode = bodyCode;
|
|
44
54
|
this.fieldErrors = fieldErrors;
|
|
55
|
+
this.body = body;
|
|
45
56
|
if (Error.captureStackTrace) {
|
|
46
57
|
Error.captureStackTrace(this, _BetterCMSError);
|
|
47
58
|
}
|
|
@@ -68,6 +79,7 @@ var BetterCMSError = class _BetterCMSError extends Error {
|
|
|
68
79
|
let bodyCode;
|
|
69
80
|
let fieldErrors;
|
|
70
81
|
let code = statusToCode(res.status);
|
|
82
|
+
let raw;
|
|
71
83
|
try {
|
|
72
84
|
const body = await res.json();
|
|
73
85
|
if (body?.errors && typeof body.errors === "object") {
|
|
@@ -83,9 +95,10 @@ var BetterCMSError = class _BetterCMSError extends Error {
|
|
|
83
95
|
if (field) message = `${field}: ${detail}`;
|
|
84
96
|
}
|
|
85
97
|
if (body?.code) bodyCode = body.code;
|
|
98
|
+
raw = body;
|
|
86
99
|
} catch {
|
|
87
100
|
}
|
|
88
|
-
return new _BetterCMSError(message, res.status, code, bodyCode, fieldErrors);
|
|
101
|
+
return new _BetterCMSError(message, res.status, code, bodyCode, fieldErrors, raw);
|
|
89
102
|
}
|
|
90
103
|
};
|
|
91
104
|
|
|
@@ -706,9 +719,10 @@ async function updateForm(client, id, input) {
|
|
|
706
719
|
}
|
|
707
720
|
|
|
708
721
|
// src/methods/management/components.ts
|
|
709
|
-
async function listComponents(client) {
|
|
722
|
+
async function listComponents(client, options) {
|
|
723
|
+
const query = options?.select ? `?select=${options.select}` : "";
|
|
710
724
|
const res = await client.fetchJSON(
|
|
711
|
-
client.url(
|
|
725
|
+
client.url(`/management/components${query}`),
|
|
712
726
|
{ method: "GET" }
|
|
713
727
|
);
|
|
714
728
|
return res.data;
|
|
@@ -949,9 +963,8 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
|
|
|
949
963
|
updateForm(id, input) {
|
|
950
964
|
return updateForm(this, id, input);
|
|
951
965
|
}
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
return listComponents(this);
|
|
966
|
+
listComponents(options) {
|
|
967
|
+
return options?.select ? listComponents(this, { select: options.select }) : listComponents(this);
|
|
955
968
|
}
|
|
956
969
|
getComponent(id) {
|
|
957
970
|
return getComponent(this, id);
|
|
@@ -1130,6 +1143,16 @@ function unwrap(json) {
|
|
|
1130
1143
|
}
|
|
1131
1144
|
return json;
|
|
1132
1145
|
}
|
|
1146
|
+
function tokenSlug(token) {
|
|
1147
|
+
try {
|
|
1148
|
+
const part = token.split(".")[1];
|
|
1149
|
+
if (!part) return null;
|
|
1150
|
+
const json = atob(part.replace(/-/g, "+").replace(/_/g, "/"));
|
|
1151
|
+
return JSON.parse(json).entrySlug ?? null;
|
|
1152
|
+
} catch {
|
|
1153
|
+
return null;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1133
1156
|
function createRequestCache() {
|
|
1134
1157
|
const inflight = /* @__PURE__ */ new Map();
|
|
1135
1158
|
const settled = /* @__PURE__ */ new Map();
|
|
@@ -1230,6 +1253,23 @@ function createClient(options) {
|
|
|
1230
1253
|
return unwrap(await fetchJSON(url));
|
|
1231
1254
|
},
|
|
1232
1255
|
async getPage(slug) {
|
|
1256
|
+
if (draft && previewToken && tokenSlug(previewToken) === slug) {
|
|
1257
|
+
const url = `${apiUrl}/api/v1/preview/${encodeURIComponent(slug)}${qs({
|
|
1258
|
+
token: previewToken,
|
|
1259
|
+
stega: stega ? "1" : void 0
|
|
1260
|
+
})}`;
|
|
1261
|
+
const d = unwrap(await fetchJSON(url));
|
|
1262
|
+
return {
|
|
1263
|
+
slug: d.slug,
|
|
1264
|
+
title: d.title,
|
|
1265
|
+
metaTitle: d.metaTitle ?? null,
|
|
1266
|
+
metaDescription: d.metaDescription ?? null,
|
|
1267
|
+
metaJson: d.metaJson ?? null,
|
|
1268
|
+
blocks: d.blockJson ?? [],
|
|
1269
|
+
updatedAt: d.updatedAt ?? null,
|
|
1270
|
+
publishedAt: d.publishedAt ?? null
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1233
1273
|
let page = 1;
|
|
1234
1274
|
for (; ; ) {
|
|
1235
1275
|
const list = await this.listPages({ page, perPage: 100 });
|
|
@@ -1246,6 +1286,13 @@ function createClient(options) {
|
|
|
1246
1286
|
})}`;
|
|
1247
1287
|
return unwrap(await fetchJSON(url));
|
|
1248
1288
|
},
|
|
1289
|
+
async listComponents() {
|
|
1290
|
+
const url = `${base}/components${qs({
|
|
1291
|
+
perspective: draft ? "draft" : void 0,
|
|
1292
|
+
token: draft ? previewToken : void 0
|
|
1293
|
+
})}`;
|
|
1294
|
+
return unwrap(await fetchJSON(url));
|
|
1295
|
+
},
|
|
1249
1296
|
async getLayout() {
|
|
1250
1297
|
const url = `${base}/layout${draft ? "?perspective=draft" : ""}`;
|
|
1251
1298
|
try {
|