@bettercms-ai/sdk 1.36.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 +20 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -6
- package/dist/index.d.ts +33 -6
- package/dist/index.js +19 -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, 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';
|
|
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;
|
|
@@ -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,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, 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';
|
|
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;
|
|
@@ -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.
|
|
@@ -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(","),
|
|
@@ -1454,6 +1458,14 @@ function embeds(value) {
|
|
|
1454
1458
|
const e = value.embeds;
|
|
1455
1459
|
return typeof e === "object" && e !== null && typeof e.cards === "object" && e.cards !== null ? e : null;
|
|
1456
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
|
+
}
|
|
1457
1469
|
function isRichText(value) {
|
|
1458
1470
|
return typeof value === "object" && value !== null && !Array.isArray(value) && ("html" in value || "format" in value);
|
|
1459
1471
|
}
|
|
@@ -2056,6 +2068,7 @@ export {
|
|
|
2056
2068
|
resetPublishedContentCache,
|
|
2057
2069
|
resolveSeo,
|
|
2058
2070
|
resolveStega,
|
|
2071
|
+
resolved,
|
|
2059
2072
|
revokeApiKey,
|
|
2060
2073
|
rich,
|
|
2061
2074
|
search,
|