@bettercms-ai/sdk 1.36.0 → 1.38.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/draft.cjs +15 -0
- package/dist/draft.cjs.map +1 -1
- package/dist/draft.d.cts +7 -1
- package/dist/draft.d.ts +7 -1
- package/dist/draft.js +14 -0
- package/dist/draft.js.map +1 -1
- package/dist/index.cjs +32 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -8
- package/dist/index.d.ts +35 -8
- package/dist/index.js +31 -12
- package/dist/index.js.map +1 -1
- package/dist/{read-client-tNsCHy0p.d.cts → read-client-B1uDVNKk.d.cts} +6 -0
- package/dist/{read-client-tNsCHy0p.d.ts → read-client-B1uDVNKk.d.ts} +6 -0
- package/dist/read.cjs +13 -7
- package/dist/read.cjs.map +1 -1
- package/dist/read.d.cts +1 -1
- package/dist/read.d.ts +1 -1
- package/dist/read.js +13 -7
- package/dist/read.js.map +1 -1
- package/dist/sections.cjs +13 -7
- package/dist/sections.cjs.map +1 -1
- package/dist/sections.d.cts +1 -1
- package/dist/sections.d.ts +1 -1
- package/dist/sections.js +13 -7
- package/dist/sections.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, 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, RichTextEmbeds, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, getBlockType, isBlock } from '@bettercms-ai/types';
|
|
4
|
-
import { D as DeliveryFormField } from './read-client-
|
|
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-
|
|
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
|
+
import { D as DeliveryFormField } from './read-client-B1uDVNKk.cjs';
|
|
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-B1uDVNKk.cjs';
|
|
6
6
|
export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.cjs';
|
|
7
7
|
export { SearchHit, SearchOptions, search } from './read.cjs';
|
|
8
8
|
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
|
|
@@ -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;
|
|
@@ -728,7 +730,7 @@ interface PublishManagedLayoutInput {
|
|
|
728
730
|
declare function publishManagedLayout(client: ManagedLayoutClient, input: PublishManagedLayoutInput): Promise<ManagedLayoutDocument>;
|
|
729
731
|
|
|
730
732
|
interface BetterCMSManagementOptions {
|
|
731
|
-
/** 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 */
|
|
732
734
|
baseUrl?: string;
|
|
733
735
|
/** A content:manage scoped API key. */
|
|
734
736
|
apiKey: string;
|
|
@@ -890,7 +892,7 @@ interface BetterCMSSiteOptions {
|
|
|
890
892
|
workspace: string;
|
|
891
893
|
/** Optional API key for authenticated requests. */
|
|
892
894
|
apiKey?: string;
|
|
893
|
-
/** 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. */
|
|
894
896
|
baseUrl?: string;
|
|
895
897
|
/**
|
|
896
898
|
* Per-attempt request timeout in ms. Defaults to 10000. Each of the 3 retries gets
|
|
@@ -1082,6 +1084,13 @@ interface RichTextValue {
|
|
|
1082
1084
|
* and on any envelope written before it existed: read it through `embeds()`.
|
|
1083
1085
|
*/
|
|
1084
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;
|
|
1085
1094
|
}
|
|
1086
1095
|
/** The marker on a Portable Text envelope. `format` is a plain string, never a union — see below. */
|
|
1087
1096
|
declare const PORTABLE_TEXT_FORMAT = "portable-text-1";
|
|
@@ -1107,6 +1116,24 @@ declare function portableText(value: TextOrRich): readonly unknown[] | null;
|
|
|
1107
1116
|
* like `portableText()`: `rich()` reads `html`, which already holds the cards.
|
|
1108
1117
|
*/
|
|
1109
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;
|
|
1110
1137
|
/**
|
|
1111
1138
|
* A field that may arrive as either shape. Type author-editable text fields with this and the
|
|
1112
1139
|
* compiler routes you through `plain()`/`rich()`, so a type switch in the CMS can never reach
|
|
@@ -1506,4 +1533,4 @@ interface FramedWindow {
|
|
|
1506
1533
|
/** True inside the editor's canvas. Safe where there is no window (a server render): false. */
|
|
1507
1534
|
declare function inEditor(win?: FramedWindow | undefined): boolean;
|
|
1508
1535
|
|
|
1509
|
-
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, 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, 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,8 +1,8 @@
|
|
|
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, 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, RichTextEmbeds, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, getBlockType, isBlock } from '@bettercms-ai/types';
|
|
4
|
-
import { D as DeliveryFormField } from './read-client-
|
|
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-
|
|
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
|
+
import { D as DeliveryFormField } from './read-client-B1uDVNKk.js';
|
|
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-B1uDVNKk.js';
|
|
6
6
|
export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.js';
|
|
7
7
|
export { SearchHit, SearchOptions, search } from './read.js';
|
|
8
8
|
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
|
|
@@ -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;
|
|
@@ -728,7 +730,7 @@ interface PublishManagedLayoutInput {
|
|
|
728
730
|
declare function publishManagedLayout(client: ManagedLayoutClient, input: PublishManagedLayoutInput): Promise<ManagedLayoutDocument>;
|
|
729
731
|
|
|
730
732
|
interface BetterCMSManagementOptions {
|
|
731
|
-
/** 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 */
|
|
732
734
|
baseUrl?: string;
|
|
733
735
|
/** A content:manage scoped API key. */
|
|
734
736
|
apiKey: string;
|
|
@@ -890,7 +892,7 @@ interface BetterCMSSiteOptions {
|
|
|
890
892
|
workspace: string;
|
|
891
893
|
/** Optional API key for authenticated requests. */
|
|
892
894
|
apiKey?: string;
|
|
893
|
-
/** 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. */
|
|
894
896
|
baseUrl?: string;
|
|
895
897
|
/**
|
|
896
898
|
* Per-attempt request timeout in ms. Defaults to 10000. Each of the 3 retries gets
|
|
@@ -1082,6 +1084,13 @@ interface RichTextValue {
|
|
|
1082
1084
|
* and on any envelope written before it existed: read it through `embeds()`.
|
|
1083
1085
|
*/
|
|
1084
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;
|
|
1085
1094
|
}
|
|
1086
1095
|
/** The marker on a Portable Text envelope. `format` is a plain string, never a union — see below. */
|
|
1087
1096
|
declare const PORTABLE_TEXT_FORMAT = "portable-text-1";
|
|
@@ -1107,6 +1116,24 @@ declare function portableText(value: TextOrRich): readonly unknown[] | null;
|
|
|
1107
1116
|
* like `portableText()`: `rich()` reads `html`, which already holds the cards.
|
|
1108
1117
|
*/
|
|
1109
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;
|
|
1110
1137
|
/**
|
|
1111
1138
|
* A field that may arrive as either shape. Type author-editable text fields with this and the
|
|
1112
1139
|
* compiler routes you through `plain()`/`rich()`, so a type switch in the CMS can never reach
|
|
@@ -1506,4 +1533,4 @@ interface FramedWindow {
|
|
|
1506
1533
|
/** True inside the editor's canvas. Safe where there is no window (a server render): false. */
|
|
1507
1534
|
declare function inEditor(win?: FramedWindow | undefined): boolean;
|
|
1508
1535
|
|
|
1509
|
-
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, 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, 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.
|
|
@@ -1212,6 +1216,7 @@ function createClient(options) {
|
|
|
1212
1216
|
const apiUrl = options.apiUrl.replace(/\/+$/, "");
|
|
1213
1217
|
const { workspace, apiKey, perspective = "published", previewToken } = options;
|
|
1214
1218
|
const defaultProjectId = options.projectId;
|
|
1219
|
+
const branch = options.branch && options.branch !== "main" ? options.branch : void 0;
|
|
1215
1220
|
const timeout = options.timeout ?? DEFAULT_TIMEOUT3;
|
|
1216
1221
|
const base = `${apiUrl}/api/v1/delivery/${workspace}`;
|
|
1217
1222
|
const headers = () => {
|
|
@@ -1261,7 +1266,7 @@ function createClient(options) {
|
|
|
1261
1266
|
return {
|
|
1262
1267
|
perspective,
|
|
1263
1268
|
async getEntry(slug, opts) {
|
|
1264
|
-
const url = draft && previewToken ? `${apiUrl}/api/v1/preview/${encodeURIComponent(slug)}${qs({
|
|
1269
|
+
const url = draft && previewToken && tokenSlug(previewToken) === slug ? `${apiUrl}/api/v1/preview/${encodeURIComponent(slug)}${qs({
|
|
1265
1270
|
token: previewToken,
|
|
1266
1271
|
depth: opts?.depth,
|
|
1267
1272
|
select: opts?.select?.join(","),
|
|
@@ -1271,7 +1276,8 @@ function createClient(options) {
|
|
|
1271
1276
|
select: opts?.select?.join(","),
|
|
1272
1277
|
perspective: draft ? "draft" : void 0,
|
|
1273
1278
|
stega: draft && stega ? "1" : void 0,
|
|
1274
|
-
projectId: defaultProjectId
|
|
1279
|
+
projectId: defaultProjectId,
|
|
1280
|
+
branch
|
|
1275
1281
|
})}`;
|
|
1276
1282
|
return unwrap(await fetchJSON(url));
|
|
1277
1283
|
},
|
|
@@ -1284,7 +1290,8 @@ function createClient(options) {
|
|
|
1284
1290
|
select: opts?.select?.join(","),
|
|
1285
1291
|
perspective: draft ? "draft" : void 0,
|
|
1286
1292
|
stega: draft && stega ? "1" : void 0,
|
|
1287
|
-
projectId: defaultProjectId
|
|
1293
|
+
projectId: defaultProjectId,
|
|
1294
|
+
branch
|
|
1288
1295
|
})}`;
|
|
1289
1296
|
return unwrap(await fetchJSON(url));
|
|
1290
1297
|
},
|
|
@@ -1321,7 +1328,8 @@ function createClient(options) {
|
|
|
1321
1328
|
const url = `${base}/pages${qs({
|
|
1322
1329
|
page: opts?.page,
|
|
1323
1330
|
perPage: opts?.perPage,
|
|
1324
|
-
projectId: defaultProjectId
|
|
1331
|
+
projectId: defaultProjectId,
|
|
1332
|
+
branch
|
|
1325
1333
|
})}`;
|
|
1326
1334
|
return unwrap(await fetchJSON(url));
|
|
1327
1335
|
},
|
|
@@ -1329,12 +1337,13 @@ function createClient(options) {
|
|
|
1329
1337
|
const url = `${base}/components${qs({
|
|
1330
1338
|
perspective: draft ? "draft" : void 0,
|
|
1331
1339
|
token: draft ? previewToken : void 0,
|
|
1332
|
-
projectId: defaultProjectId
|
|
1340
|
+
projectId: defaultProjectId,
|
|
1341
|
+
branch
|
|
1333
1342
|
})}`;
|
|
1334
1343
|
return unwrap(await fetchJSON(url));
|
|
1335
1344
|
},
|
|
1336
1345
|
async getLayout() {
|
|
1337
|
-
const url = `${base}/layout${qs({ perspective: draft ? "draft" : void 0, projectId: defaultProjectId })}`;
|
|
1346
|
+
const url = `${base}/layout${qs({ perspective: draft ? "draft" : void 0, projectId: defaultProjectId, branch })}`;
|
|
1338
1347
|
try {
|
|
1339
1348
|
return unwrap(await fetchJSON(url));
|
|
1340
1349
|
} catch (error) {
|
|
@@ -1344,7 +1353,8 @@ function createClient(options) {
|
|
|
1344
1353
|
},
|
|
1345
1354
|
async listForms(opts) {
|
|
1346
1355
|
const url = `${base}/forms${qs({
|
|
1347
|
-
projectId: opts?.projectId ?? defaultProjectId
|
|
1356
|
+
projectId: opts?.projectId ?? defaultProjectId,
|
|
1357
|
+
branch
|
|
1348
1358
|
})}`;
|
|
1349
1359
|
return unwrap(
|
|
1350
1360
|
await fetchJSON(url)
|
|
@@ -1454,6 +1464,14 @@ function embeds(value) {
|
|
|
1454
1464
|
const e = value.embeds;
|
|
1455
1465
|
return typeof e === "object" && e !== null && typeof e.cards === "object" && e.cards !== null ? e : null;
|
|
1456
1466
|
}
|
|
1467
|
+
var resolvedMap = (r) => typeof r === "object" && r !== null && !Array.isArray(r) ? r : null;
|
|
1468
|
+
function resolved(value, entry) {
|
|
1469
|
+
const own = isRichText(value) ? resolvedMap(value.resolved) : null;
|
|
1470
|
+
if (own) return own;
|
|
1471
|
+
if (entry) return resolvedMap(entry.resolved);
|
|
1472
|
+
const v = value;
|
|
1473
|
+
return v && typeof v === "object" && !Array.isArray(v) && "data" in v ? resolvedMap(v.resolved) : null;
|
|
1474
|
+
}
|
|
1457
1475
|
function isRichText(value) {
|
|
1458
1476
|
return typeof value === "object" && value !== null && !Array.isArray(value) && ("html" in value || "format" in value);
|
|
1459
1477
|
}
|
|
@@ -2056,6 +2074,7 @@ export {
|
|
|
2056
2074
|
resetPublishedContentCache,
|
|
2057
2075
|
resolveSeo,
|
|
2058
2076
|
resolveStega,
|
|
2077
|
+
resolved,
|
|
2059
2078
|
revokeApiKey,
|
|
2060
2079
|
rich,
|
|
2061
2080
|
search,
|