@bettercms-ai/sdk 1.35.0 → 1.37.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/README.md +27 -1
- package/dist/index.cjs +27 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -6
- package/dist/index.d.ts +51 -6
- package/dist/index.js +25 -6
- package/dist/index.js.map +1 -1
- package/dist/read.cjs +1 -1
- package/dist/read.cjs.map +1 -1
- package/dist/read.js +1 -1
- package/dist/read.js.map +1 -1
- package/dist/sections.cjs +1 -1
- package/dist/sections.cjs.map +1 -1
- package/dist/sections.js +1 -1
- package/dist/sections.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, Fieldset, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Page, MediaAsset, FormField, 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';
|
|
2
|
+
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, RichTextResolved, RichTextEmbeds, Page, MediaAsset, FormField, 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, EmbedCard, Form, FormBlock, FormField, FormProps, FormSubmission, HeadingBlock, HeadingProps, ImageBlock, ImageProps, MediaAsset, Page, PageMetaJson, PaginatedResult, Perspective, Redirect, ResolvedAuthor, ResolvedPost, RichTextEmbeds, RichTextResolved, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, getBlockType, isBlock } from '@bettercms-ai/types';
|
|
4
4
|
import { D as DeliveryFormField } from './read-client-tNsCHy0p.cjs';
|
|
5
5
|
export { a as BCMSClientError, E as BCMSErrorCodes, a as BetterCMSError, B as BetterCMSReadClient, C as CreateClientOptions, b as DeliveryForm, c as DeliveryFormFieldType, E as ErrorCodes, F as FormSubmitError, d as FormValue, e as FormValues, G as GetEntryOptions, L as ListEntriesOptions, f as ListPagesOptions, S as SubmitFormOptions, g as SubmitFormResult, h as asStringArray, i as createClient, j as formInitialValues, k as isMultiValueField, s as shouldShowField, l as submitForm, t as toggleOption } from './read-client-tNsCHy0p.cjs';
|
|
6
6
|
export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.cjs';
|
|
@@ -72,6 +72,8 @@ declare class BetterCMSDeliveryClient {
|
|
|
72
72
|
}): Promise<_bettercms_ai_types.Content[]>;
|
|
73
73
|
};
|
|
74
74
|
getLayout(): Promise<DeliveredLayout | null>;
|
|
75
|
+
/** The published pages list (paginated). */
|
|
76
|
+
pagesUrl(): string;
|
|
75
77
|
/** Build the full URL for a content path. */
|
|
76
78
|
url(path: string): string;
|
|
77
79
|
/** Build request headers, including auth if provided. */
|
|
@@ -89,7 +91,7 @@ declare class BetterCMSDeliveryClient {
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
interface BetterCMSAdminOptions {
|
|
92
|
-
/** Base URL of the Admin API. Defaults to https://api.bettercms.ai/v1 */
|
|
94
|
+
/** Base URL of the Admin API. Defaults to https://api.bettercms.ai/api/v1 */
|
|
93
95
|
baseUrl?: string;
|
|
94
96
|
/** BetterAuth session Bearer token. */
|
|
95
97
|
token: string;
|
|
@@ -402,6 +404,8 @@ declare function updateEntry(client: ManagementClient, id: string, input: Update
|
|
|
402
404
|
interface ManagedComponent {
|
|
403
405
|
id: string;
|
|
404
406
|
projectId: string | null;
|
|
407
|
+
/** Whose block it is (list rows only). @see ManagedComponentSummary.ownership */
|
|
408
|
+
ownership?: "page" | "shared" | "project";
|
|
405
409
|
allowedOn: string[];
|
|
406
410
|
name: string;
|
|
407
411
|
slug: string;
|
|
@@ -509,6 +513,8 @@ interface ManagedComponentSummary {
|
|
|
509
513
|
groupName: string | null;
|
|
510
514
|
updatedAt: string | null;
|
|
511
515
|
builtin?: boolean;
|
|
516
|
+
/** Whose block it is: one page's own (`page`), a deliberately `shared` one, or the `project`'s. */
|
|
517
|
+
ownership?: "page" | "shared" | "project";
|
|
512
518
|
}
|
|
513
519
|
/**
|
|
514
520
|
* A set of sections that repeat across the project's pages, proposed as one component.
|
|
@@ -724,7 +730,7 @@ interface PublishManagedLayoutInput {
|
|
|
724
730
|
declare function publishManagedLayout(client: ManagedLayoutClient, input: PublishManagedLayoutInput): Promise<ManagedLayoutDocument>;
|
|
725
731
|
|
|
726
732
|
interface BetterCMSManagementOptions {
|
|
727
|
-
/** Base URL of the Management API. Defaults to https://api.bettercms.ai/v1 */
|
|
733
|
+
/** Base URL of the Management API. Defaults to https://api.bettercms.ai/api/v1 */
|
|
728
734
|
baseUrl?: string;
|
|
729
735
|
/** A content:manage scoped API key. */
|
|
730
736
|
apiKey: string;
|
|
@@ -886,7 +892,7 @@ interface BetterCMSSiteOptions {
|
|
|
886
892
|
workspace: string;
|
|
887
893
|
/** Optional API key for authenticated requests. */
|
|
888
894
|
apiKey?: string;
|
|
889
|
-
/** Base URL of the Delivery API. Defaults to https://api.bettercms.ai/v1. */
|
|
895
|
+
/** Base URL of the Delivery API. Defaults to https://api.bettercms.ai/api/v1/delivery. */
|
|
890
896
|
baseUrl?: string;
|
|
891
897
|
/**
|
|
892
898
|
* Per-attempt request timeout in ms. Defaults to 10000. Each of the 3 retries gets
|
|
@@ -1034,6 +1040,7 @@ declare function onContentApplied(handler: (message: ContentAppliedMessage) => v
|
|
|
1034
1040
|
* <h1 dangerouslySetInnerHTML={{ __html: rich(f.heroTitle) }}/> // React
|
|
1035
1041
|
* seo({ title: plain(page.heroTitle) })
|
|
1036
1042
|
*/
|
|
1043
|
+
|
|
1037
1044
|
/**
|
|
1038
1045
|
* A block in a Body field's `doc`. Bounded vocabulary — the server only emits what it can
|
|
1039
1046
|
* parse back, so an unknown `type` means your SDK is older than the content, not that the
|
|
@@ -1070,6 +1077,20 @@ interface RichTextValue {
|
|
|
1070
1077
|
* field that is always there.
|
|
1071
1078
|
*/
|
|
1072
1079
|
readonly doc?: DocValue;
|
|
1080
|
+
/**
|
|
1081
|
+
* The embeds the server resolved when it built `html`: X cards keyed by canonical url (X's
|
|
1082
|
+
* script, when a site opts in, is the page's, never the value's). `html` already holds each card, so `rich()` never needs this; it is
|
|
1083
|
+
* for renderers of the STRUCTURE (`<PortableText embeds={…}>`). Absent on a value with no embed
|
|
1084
|
+
* and on any envelope written before it existed: read it through `embeds()`.
|
|
1085
|
+
*/
|
|
1086
|
+
readonly embeds?: RichTextEmbeds;
|
|
1087
|
+
/**
|
|
1088
|
+
* What the value's related posts and author bios point at, resolved by the server for THIS
|
|
1089
|
+
* response from the published entries (never stored). `html` already draws them; this is for
|
|
1090
|
+
* renderers of the structure (`<PortableText resolved={…}>`). Absent on a value with neither block.
|
|
1091
|
+
* Read it through `resolved()`.
|
|
1092
|
+
*/
|
|
1093
|
+
readonly resolved?: RichTextResolved;
|
|
1073
1094
|
}
|
|
1074
1095
|
/** The marker on a Portable Text envelope. `format` is a plain string, never a union — see below. */
|
|
1075
1096
|
declare const PORTABLE_TEXT_FORMAT = "portable-text-1";
|
|
@@ -1089,6 +1110,30 @@ declare const PORTABLE_TEXT_FORMAT = "portable-text-1";
|
|
|
1089
1110
|
* the opt-in for consumers that want to render structure with `@portabletext/react` instead.
|
|
1090
1111
|
*/
|
|
1091
1112
|
declare function portableText(value: TextOrRich): readonly unknown[] | null;
|
|
1113
|
+
/**
|
|
1114
|
+
* The value's resolved embeds, for a renderer of its structure (`<PortableText embeds>`), or null:
|
|
1115
|
+
* a bare string, a value with no embed, or an envelope written before embeds existed. Additive,
|
|
1116
|
+
* like `portableText()`: `rich()` reads `html`, which already holds the cards.
|
|
1117
|
+
*/
|
|
1118
|
+
declare function embeds(value: TextOrRich): RichTextEmbeds | null;
|
|
1119
|
+
/** A delivered entry as far as `resolved()` reads it: its entry-level map. */
|
|
1120
|
+
interface ResolvedHolder {
|
|
1121
|
+
readonly resolved?: RichTextResolved | null;
|
|
1122
|
+
readonly data?: unknown;
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* What a rich-text value's related posts and author bios resolved to, for a renderer of its
|
|
1126
|
+
* structure (`<PortableText resolved>`), or null when there is nothing.
|
|
1127
|
+
*
|
|
1128
|
+
* resolved(entry.data.body, entry) // a field value, with the entry it came in
|
|
1129
|
+
* resolved(entry) // the entry's merged map
|
|
1130
|
+
*
|
|
1131
|
+
* An envelope value carries its own (`value.resolved`), which wins. A Body stored as a bare block
|
|
1132
|
+
* array has nowhere to carry one, so delivery puts the entry's merged map beside `data`
|
|
1133
|
+
* (`entry.resolved`): pass the entry and that is what you get. Additive, like `embeds()`: `rich()`
|
|
1134
|
+
* reads `html`, which already draws them.
|
|
1135
|
+
*/
|
|
1136
|
+
declare function resolved(value: TextOrRich | readonly unknown[] | ResolvedHolder, entry?: ResolvedHolder | null): RichTextResolved | null;
|
|
1092
1137
|
/**
|
|
1093
1138
|
* A field that may arrive as either shape. Type author-editable text fields with this and the
|
|
1094
1139
|
* compiler routes you through `plain()`/`rich()`, so a type switch in the CMS can never reach
|
|
@@ -1488,4 +1533,4 @@ interface FramedWindow {
|
|
|
1488
1533
|
/** True inside the editor's canvas. Safe where there is no window (a server render): false. */
|
|
1489
1534
|
declare function inEditor(win?: FramedWindow | undefined): boolean;
|
|
1490
1535
|
|
|
1491
|
-
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, EDITOR_FRAME_NAME, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type RichTextValue, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type TextOrRich, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, commandManagedLayout, contentApplied, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inEditor, inviteMember, isRichText, lines, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveStega, revokeApiKey, rich, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
|
1536
|
+
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, EDITOR_FRAME_NAME, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedHolder, type RichTextValue, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type TextOrRich, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, commandManagedLayout, contentApplied, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, embeds, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inEditor, inviteMember, isRichText, lines, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveStega, resolved, revokeApiKey, rich, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, 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, Fieldset, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Page, MediaAsset, FormField, 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';
|
|
2
|
+
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, RichTextResolved, RichTextEmbeds, Page, MediaAsset, FormField, 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, EmbedCard, Form, FormBlock, FormField, FormProps, FormSubmission, HeadingBlock, HeadingProps, ImageBlock, ImageProps, MediaAsset, Page, PageMetaJson, PaginatedResult, Perspective, Redirect, ResolvedAuthor, ResolvedPost, RichTextEmbeds, RichTextResolved, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, getBlockType, isBlock } from '@bettercms-ai/types';
|
|
4
4
|
import { D as DeliveryFormField } from './read-client-tNsCHy0p.js';
|
|
5
5
|
export { a as BCMSClientError, E as BCMSErrorCodes, a as BetterCMSError, B as BetterCMSReadClient, C as CreateClientOptions, b as DeliveryForm, c as DeliveryFormFieldType, E as ErrorCodes, F as FormSubmitError, d as FormValue, e as FormValues, G as GetEntryOptions, L as ListEntriesOptions, f as ListPagesOptions, S as SubmitFormOptions, g as SubmitFormResult, h as asStringArray, i as createClient, j as formInitialValues, k as isMultiValueField, s as shouldShowField, l as submitForm, t as toggleOption } from './read-client-tNsCHy0p.js';
|
|
6
6
|
export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.js';
|
|
@@ -72,6 +72,8 @@ declare class BetterCMSDeliveryClient {
|
|
|
72
72
|
}): Promise<_bettercms_ai_types.Content[]>;
|
|
73
73
|
};
|
|
74
74
|
getLayout(): Promise<DeliveredLayout | null>;
|
|
75
|
+
/** The published pages list (paginated). */
|
|
76
|
+
pagesUrl(): string;
|
|
75
77
|
/** Build the full URL for a content path. */
|
|
76
78
|
url(path: string): string;
|
|
77
79
|
/** Build request headers, including auth if provided. */
|
|
@@ -89,7 +91,7 @@ declare class BetterCMSDeliveryClient {
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
interface BetterCMSAdminOptions {
|
|
92
|
-
/** Base URL of the Admin API. Defaults to https://api.bettercms.ai/v1 */
|
|
94
|
+
/** Base URL of the Admin API. Defaults to https://api.bettercms.ai/api/v1 */
|
|
93
95
|
baseUrl?: string;
|
|
94
96
|
/** BetterAuth session Bearer token. */
|
|
95
97
|
token: string;
|
|
@@ -402,6 +404,8 @@ declare function updateEntry(client: ManagementClient, id: string, input: Update
|
|
|
402
404
|
interface ManagedComponent {
|
|
403
405
|
id: string;
|
|
404
406
|
projectId: string | null;
|
|
407
|
+
/** Whose block it is (list rows only). @see ManagedComponentSummary.ownership */
|
|
408
|
+
ownership?: "page" | "shared" | "project";
|
|
405
409
|
allowedOn: string[];
|
|
406
410
|
name: string;
|
|
407
411
|
slug: string;
|
|
@@ -509,6 +513,8 @@ interface ManagedComponentSummary {
|
|
|
509
513
|
groupName: string | null;
|
|
510
514
|
updatedAt: string | null;
|
|
511
515
|
builtin?: boolean;
|
|
516
|
+
/** Whose block it is: one page's own (`page`), a deliberately `shared` one, or the `project`'s. */
|
|
517
|
+
ownership?: "page" | "shared" | "project";
|
|
512
518
|
}
|
|
513
519
|
/**
|
|
514
520
|
* A set of sections that repeat across the project's pages, proposed as one component.
|
|
@@ -724,7 +730,7 @@ interface PublishManagedLayoutInput {
|
|
|
724
730
|
declare function publishManagedLayout(client: ManagedLayoutClient, input: PublishManagedLayoutInput): Promise<ManagedLayoutDocument>;
|
|
725
731
|
|
|
726
732
|
interface BetterCMSManagementOptions {
|
|
727
|
-
/** Base URL of the Management API. Defaults to https://api.bettercms.ai/v1 */
|
|
733
|
+
/** Base URL of the Management API. Defaults to https://api.bettercms.ai/api/v1 */
|
|
728
734
|
baseUrl?: string;
|
|
729
735
|
/** A content:manage scoped API key. */
|
|
730
736
|
apiKey: string;
|
|
@@ -886,7 +892,7 @@ interface BetterCMSSiteOptions {
|
|
|
886
892
|
workspace: string;
|
|
887
893
|
/** Optional API key for authenticated requests. */
|
|
888
894
|
apiKey?: string;
|
|
889
|
-
/** Base URL of the Delivery API. Defaults to https://api.bettercms.ai/v1. */
|
|
895
|
+
/** Base URL of the Delivery API. Defaults to https://api.bettercms.ai/api/v1/delivery. */
|
|
890
896
|
baseUrl?: string;
|
|
891
897
|
/**
|
|
892
898
|
* Per-attempt request timeout in ms. Defaults to 10000. Each of the 3 retries gets
|
|
@@ -1034,6 +1040,7 @@ declare function onContentApplied(handler: (message: ContentAppliedMessage) => v
|
|
|
1034
1040
|
* <h1 dangerouslySetInnerHTML={{ __html: rich(f.heroTitle) }}/> // React
|
|
1035
1041
|
* seo({ title: plain(page.heroTitle) })
|
|
1036
1042
|
*/
|
|
1043
|
+
|
|
1037
1044
|
/**
|
|
1038
1045
|
* A block in a Body field's `doc`. Bounded vocabulary — the server only emits what it can
|
|
1039
1046
|
* parse back, so an unknown `type` means your SDK is older than the content, not that the
|
|
@@ -1070,6 +1077,20 @@ interface RichTextValue {
|
|
|
1070
1077
|
* field that is always there.
|
|
1071
1078
|
*/
|
|
1072
1079
|
readonly doc?: DocValue;
|
|
1080
|
+
/**
|
|
1081
|
+
* The embeds the server resolved when it built `html`: X cards keyed by canonical url (X's
|
|
1082
|
+
* script, when a site opts in, is the page's, never the value's). `html` already holds each card, so `rich()` never needs this; it is
|
|
1083
|
+
* for renderers of the STRUCTURE (`<PortableText embeds={…}>`). Absent on a value with no embed
|
|
1084
|
+
* and on any envelope written before it existed: read it through `embeds()`.
|
|
1085
|
+
*/
|
|
1086
|
+
readonly embeds?: RichTextEmbeds;
|
|
1087
|
+
/**
|
|
1088
|
+
* What the value's related posts and author bios point at, resolved by the server for THIS
|
|
1089
|
+
* response from the published entries (never stored). `html` already draws them; this is for
|
|
1090
|
+
* renderers of the structure (`<PortableText resolved={…}>`). Absent on a value with neither block.
|
|
1091
|
+
* Read it through `resolved()`.
|
|
1092
|
+
*/
|
|
1093
|
+
readonly resolved?: RichTextResolved;
|
|
1073
1094
|
}
|
|
1074
1095
|
/** The marker on a Portable Text envelope. `format` is a plain string, never a union — see below. */
|
|
1075
1096
|
declare const PORTABLE_TEXT_FORMAT = "portable-text-1";
|
|
@@ -1089,6 +1110,30 @@ declare const PORTABLE_TEXT_FORMAT = "portable-text-1";
|
|
|
1089
1110
|
* the opt-in for consumers that want to render structure with `@portabletext/react` instead.
|
|
1090
1111
|
*/
|
|
1091
1112
|
declare function portableText(value: TextOrRich): readonly unknown[] | null;
|
|
1113
|
+
/**
|
|
1114
|
+
* The value's resolved embeds, for a renderer of its structure (`<PortableText embeds>`), or null:
|
|
1115
|
+
* a bare string, a value with no embed, or an envelope written before embeds existed. Additive,
|
|
1116
|
+
* like `portableText()`: `rich()` reads `html`, which already holds the cards.
|
|
1117
|
+
*/
|
|
1118
|
+
declare function embeds(value: TextOrRich): RichTextEmbeds | null;
|
|
1119
|
+
/** A delivered entry as far as `resolved()` reads it: its entry-level map. */
|
|
1120
|
+
interface ResolvedHolder {
|
|
1121
|
+
readonly resolved?: RichTextResolved | null;
|
|
1122
|
+
readonly data?: unknown;
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* What a rich-text value's related posts and author bios resolved to, for a renderer of its
|
|
1126
|
+
* structure (`<PortableText resolved>`), or null when there is nothing.
|
|
1127
|
+
*
|
|
1128
|
+
* resolved(entry.data.body, entry) // a field value, with the entry it came in
|
|
1129
|
+
* resolved(entry) // the entry's merged map
|
|
1130
|
+
*
|
|
1131
|
+
* An envelope value carries its own (`value.resolved`), which wins. A Body stored as a bare block
|
|
1132
|
+
* array has nowhere to carry one, so delivery puts the entry's merged map beside `data`
|
|
1133
|
+
* (`entry.resolved`): pass the entry and that is what you get. Additive, like `embeds()`: `rich()`
|
|
1134
|
+
* reads `html`, which already draws them.
|
|
1135
|
+
*/
|
|
1136
|
+
declare function resolved(value: TextOrRich | readonly unknown[] | ResolvedHolder, entry?: ResolvedHolder | null): RichTextResolved | null;
|
|
1092
1137
|
/**
|
|
1093
1138
|
* A field that may arrive as either shape. Type author-editable text fields with this and the
|
|
1094
1139
|
* compiler routes you through `plain()`/`rich()`, so a type switch in the CMS can never reach
|
|
@@ -1488,4 +1533,4 @@ interface FramedWindow {
|
|
|
1488
1533
|
/** True inside the editor's canvas. Safe where there is no window (a server render): false. */
|
|
1489
1534
|
declare function inEditor(win?: FramedWindow | undefined): boolean;
|
|
1490
1535
|
|
|
1491
|
-
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, EDITOR_FRAME_NAME, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type RichTextValue, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type TextOrRich, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, commandManagedLayout, contentApplied, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inEditor, inviteMember, isRichText, lines, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveStega, revokeApiKey, rich, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
|
1536
|
+
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, EDITOR_FRAME_NAME, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedHolder, type RichTextValue, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type TextOrRich, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, commandManagedLayout, contentApplied, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, embeds, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inEditor, inviteMember, isRichText, lines, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveStega, resolved, revokeApiKey, rich, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
package/dist/index.js
CHANGED
|
@@ -144,7 +144,7 @@ async function listContent(client, opts) {
|
|
|
144
144
|
perPage: String(opts?.perPage ?? 20)
|
|
145
145
|
});
|
|
146
146
|
const data = await client.fetchJSON(
|
|
147
|
-
`${client.
|
|
147
|
+
`${client.pagesUrl()}?${params2}`
|
|
148
148
|
);
|
|
149
149
|
return data.data;
|
|
150
150
|
}
|
|
@@ -169,7 +169,7 @@ function listContentAll(client, opts) {
|
|
|
169
169
|
perPage: String(perPage)
|
|
170
170
|
});
|
|
171
171
|
const result = await client.fetchJSON(
|
|
172
|
-
`${client.
|
|
172
|
+
`${client.pagesUrl()}?${params2}`
|
|
173
173
|
);
|
|
174
174
|
const pageData = result.data;
|
|
175
175
|
if (!pageData?.items?.length) break;
|
|
@@ -225,6 +225,10 @@ var BetterCMSDeliveryClient = class {
|
|
|
225
225
|
throw error;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
+
/** The published pages list (paginated). */
|
|
229
|
+
pagesUrl() {
|
|
230
|
+
return `${this.baseUrl}/${this.workspace}/pages`;
|
|
231
|
+
}
|
|
228
232
|
/** Build the full URL for a content path. */
|
|
229
233
|
url(path) {
|
|
230
234
|
return `${this.baseUrl}/${this.workspace}/content/${path}`;
|
|
@@ -361,7 +365,7 @@ function addWebhookMethods(client, projectId) {
|
|
|
361
365
|
}
|
|
362
366
|
|
|
363
367
|
// src/admin-client.ts
|
|
364
|
-
var DEFAULT_BASE_URL = "https://api.bettercms.ai/v1";
|
|
368
|
+
var DEFAULT_BASE_URL = "https://api.bettercms.ai/api/v1";
|
|
365
369
|
var BetterCMSAdminClient = class extends BetterCMSDeliveryClient {
|
|
366
370
|
_token;
|
|
367
371
|
constructor(options) {
|
|
@@ -837,7 +841,7 @@ async function publishManagedLayout(client, input) {
|
|
|
837
841
|
}
|
|
838
842
|
|
|
839
843
|
// src/management-client.ts
|
|
840
|
-
var DEFAULT_BASE_URL2 = "https://api.bettercms.ai/v1";
|
|
844
|
+
var DEFAULT_BASE_URL2 = "https://api.bettercms.ai/api/v1";
|
|
841
845
|
var DEFAULT_TIMEOUT2 = 1e4;
|
|
842
846
|
var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
|
|
843
847
|
timeout;
|
|
@@ -1117,7 +1121,7 @@ function buildAuthResult(data) {
|
|
|
1117
1121
|
}
|
|
1118
1122
|
|
|
1119
1123
|
// src/client.ts
|
|
1120
|
-
var DEFAULT_BASE_URL3 = "https://api.bettercms.ai/v1";
|
|
1124
|
+
var DEFAULT_BASE_URL3 = "https://api.bettercms.ai/api/v1/delivery";
|
|
1121
1125
|
var BetterCMS = {
|
|
1122
1126
|
/**
|
|
1123
1127
|
* Returns a client for fetching published content.
|
|
@@ -1261,7 +1265,7 @@ function createClient(options) {
|
|
|
1261
1265
|
return {
|
|
1262
1266
|
perspective,
|
|
1263
1267
|
async getEntry(slug, opts) {
|
|
1264
|
-
const url = draft && previewToken ? `${apiUrl}/api/v1/preview/${encodeURIComponent(slug)}${qs({
|
|
1268
|
+
const url = draft && previewToken && tokenSlug(previewToken) === slug ? `${apiUrl}/api/v1/preview/${encodeURIComponent(slug)}${qs({
|
|
1265
1269
|
token: previewToken,
|
|
1266
1270
|
depth: opts?.depth,
|
|
1267
1271
|
select: opts?.select?.join(","),
|
|
@@ -1449,6 +1453,19 @@ function portableText(value) {
|
|
|
1449
1453
|
const v = value;
|
|
1450
1454
|
return v.format === PORTABLE_TEXT_FORMAT && Array.isArray(v.value) ? v.value : null;
|
|
1451
1455
|
}
|
|
1456
|
+
function embeds(value) {
|
|
1457
|
+
if (!isRichText(value)) return null;
|
|
1458
|
+
const e = value.embeds;
|
|
1459
|
+
return typeof e === "object" && e !== null && typeof e.cards === "object" && e.cards !== null ? e : null;
|
|
1460
|
+
}
|
|
1461
|
+
var resolvedMap = (r) => typeof r === "object" && r !== null && !Array.isArray(r) ? r : null;
|
|
1462
|
+
function resolved(value, entry) {
|
|
1463
|
+
const own = isRichText(value) ? resolvedMap(value.resolved) : null;
|
|
1464
|
+
if (own) return own;
|
|
1465
|
+
if (entry) return resolvedMap(entry.resolved);
|
|
1466
|
+
const v = value;
|
|
1467
|
+
return v && typeof v === "object" && !Array.isArray(v) && "data" in v ? resolvedMap(v.resolved) : null;
|
|
1468
|
+
}
|
|
1452
1469
|
function isRichText(value) {
|
|
1453
1470
|
return typeof value === "object" && value !== null && !Array.isArray(value) && ("html" in value || "format" in value);
|
|
1454
1471
|
}
|
|
@@ -2002,6 +2019,7 @@ export {
|
|
|
2002
2019
|
deletePage,
|
|
2003
2020
|
deleteSubmission,
|
|
2004
2021
|
deleteWorkspace,
|
|
2022
|
+
embeds,
|
|
2005
2023
|
encodeStega,
|
|
2006
2024
|
entrySeoInput,
|
|
2007
2025
|
formInitialValues,
|
|
@@ -2050,6 +2068,7 @@ export {
|
|
|
2050
2068
|
resetPublishedContentCache,
|
|
2051
2069
|
resolveSeo,
|
|
2052
2070
|
resolveStega,
|
|
2071
|
+
resolved,
|
|
2053
2072
|
revokeApiKey,
|
|
2054
2073
|
rich,
|
|
2055
2074
|
search,
|