@bettercms-ai/sdk 1.27.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -527,7 +527,7 @@ declare class BetterCMSError extends Error {
527
527
  * every published site while the builder happily offers it. `radio`/`checkboxes`
528
528
  * were exactly that gap.
529
529
  */
530
- type DeliveryFormFieldType = "text" | "email" | "phone" | "url" | "number" | "date" | "textarea" | "select" | "radio" | "checkboxes" | "checkbox" | "consent" | "hidden";
530
+ type DeliveryFormFieldType = "text" | "email" | "phone" | "url" | "number" | "date" | "textarea" | "select" | "radio" | "checkboxes" | "checkbox" | "consent" | "hidden" | "step";
531
531
  interface DeliveryFormField {
532
532
  key: string;
533
533
  label: string;
@@ -792,6 +792,8 @@ interface ManagedComponentInput {
792
792
  * variant family, which is started from it when it has none.
793
793
  */
794
794
  variantOf?: string;
795
+ /** Create only: a built-in section id (`builtin:<key>`) to copy in; the fields you send win. */
796
+ from?: string;
795
797
  /** Update only: prop chrome by prop path (`cta.label`). Any of these, or `override`, needs `ifMatch`. */
796
798
  propUi?: Record<string, Record<string, unknown> | null>;
797
799
  propGroup?: Record<string, Record<string, unknown> | null>;
@@ -1242,6 +1244,8 @@ interface StegaPayload {
1242
1244
  slug: string;
1243
1245
  /** Field key (or block id) the value belongs to. */
1244
1246
  field: string;
1247
+ /** The binding kind (`text`), where the encoder knows it. */
1248
+ kind?: string;
1245
1249
  }
1246
1250
  /** Append an invisible provenance payload to a string. */
1247
1251
  declare function encodeStega(clean: string, payload: StegaPayload): string;
@@ -1252,6 +1256,72 @@ declare function decodeStega(value: string): {
1252
1256
  } | null;
1253
1257
  /** Remove any stega payload, returning the clean string. */
1254
1258
  declare function stripStega(value: string): string;
1259
+ /**
1260
+ * Where a value BEGINS in a rendered page: an empty frame. The canvas brackets every bound
1261
+ * string with it and the payload frame, so a text node can be told inside a value from text
1262
+ * that merely precedes one. @see resolveStega
1263
+ */
1264
+ declare const STEGA_OPEN = "\u2060\u2061";
1265
+ /** Remove EVERY stega frame, markers included. What a value passes through before it is saved or published. */
1266
+ declare function stegaClean(value: string): string;
1267
+ /** The least of a DOM node this needs: a real `Node` satisfies it, and so does a test's plain object. */
1268
+ interface StegaNode {
1269
+ textContent: string | null;
1270
+ parentNode: StegaNode | null;
1271
+ childNodes?: ArrayLike<StegaNode>;
1272
+ }
1273
+ /**
1274
+ * Which value does this node render? Its payload and the nearest ancestor that holds the whole
1275
+ * value, or null when the node's text belongs to none.
1276
+ *
1277
+ * By CONTENT, not by attribute: a splitting library cuts a heading into one element per
1278
+ * character, a marquee clones its track, a component redraws its children, and the element a
1279
+ * build stamped is gone or copied. The string survives all of that, in order, across however
1280
+ * many text nodes: climbing from the clicked node, the first ancestor whose text holds a value
1281
+ * (its open marker to its payload frame) that overlaps the node is the value's extent.
1282
+ * Every copy of a value resolves to the same payload.
1283
+ */
1284
+ declare function resolveStega(node: StegaNode): {
1285
+ payload: StegaPayload;
1286
+ element: StegaNode;
1287
+ } | null;
1288
+
1289
+ /**
1290
+ * `bcms:content-applied` — what the visual editor tells a page after it has applied an edit to
1291
+ * the page's DOM.
1292
+ *
1293
+ * An edit changes how tall a heading is. Everything on the page that measured the layout once
1294
+ * (ScrollTrigger's start and end positions, Lenis's scroll limit, a carousel's slide widths, a
1295
+ * text splitter's lines) is now wrong, and only the page's own code can measure again. So the
1296
+ * editor posts one message to the frame's window after each applied edit, and the site listens:
1297
+ *
1298
+ * onContentApplied(() => ScrollTrigger.refresh());
1299
+ *
1300
+ * A published page receives no such message: nothing there posts it, and the listener is inert.
1301
+ */
1302
+ /** The `type` of the message. */
1303
+ declare const CONTENT_APPLIED = "bcms:content-applied";
1304
+ interface ContentAppliedMessage {
1305
+ type: typeof CONTENT_APPLIED;
1306
+ /** The field addresses whose rendering changed; empty when the editor does not say. */
1307
+ fields: string[];
1308
+ }
1309
+ /** The message the editor posts: `frame.contentWindow.postMessage(contentApplied(fields), origin)`. */
1310
+ declare const contentApplied: (fields?: readonly string[]) => ContentAppliedMessage;
1311
+ /** The least of `window` this needs. */
1312
+ interface MessageTarget {
1313
+ addEventListener(type: "message", listener: (event: {
1314
+ data: unknown;
1315
+ }) => void): void;
1316
+ removeEventListener(type: "message", listener: (event: {
1317
+ data: unknown;
1318
+ }) => void): void;
1319
+ }
1320
+ /**
1321
+ * Run `handler` after every edit the editor applies to this page. Returns the function that
1322
+ * stops listening. Safe to call where there is no window (a server render): it does nothing.
1323
+ */
1324
+ declare function onContentApplied(handler: (message: ContentAppliedMessage) => void, target?: MessageTarget | undefined): () => void;
1255
1325
 
1256
1326
  /**
1257
1327
  * Reading a rich-text field, for any site.
@@ -1825,4 +1895,4 @@ interface WebhookListResponse {
1825
1895
  };
1826
1896
  }
1827
1897
 
1828
- export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type 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 ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, type UpdateApiKeyInput, type 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, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
1898
+ export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type 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 ResolvedSeo, type RichTextValue, STEGA_OPEN, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, 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, asStringArray, commandManagedLayout, contentApplied, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, resolveStega, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
package/dist/index.d.ts CHANGED
@@ -527,7 +527,7 @@ declare class BetterCMSError extends Error {
527
527
  * every published site while the builder happily offers it. `radio`/`checkboxes`
528
528
  * were exactly that gap.
529
529
  */
530
- type DeliveryFormFieldType = "text" | "email" | "phone" | "url" | "number" | "date" | "textarea" | "select" | "radio" | "checkboxes" | "checkbox" | "consent" | "hidden";
530
+ type DeliveryFormFieldType = "text" | "email" | "phone" | "url" | "number" | "date" | "textarea" | "select" | "radio" | "checkboxes" | "checkbox" | "consent" | "hidden" | "step";
531
531
  interface DeliveryFormField {
532
532
  key: string;
533
533
  label: string;
@@ -792,6 +792,8 @@ interface ManagedComponentInput {
792
792
  * variant family, which is started from it when it has none.
793
793
  */
794
794
  variantOf?: string;
795
+ /** Create only: a built-in section id (`builtin:<key>`) to copy in; the fields you send win. */
796
+ from?: string;
795
797
  /** Update only: prop chrome by prop path (`cta.label`). Any of these, or `override`, needs `ifMatch`. */
796
798
  propUi?: Record<string, Record<string, unknown> | null>;
797
799
  propGroup?: Record<string, Record<string, unknown> | null>;
@@ -1242,6 +1244,8 @@ interface StegaPayload {
1242
1244
  slug: string;
1243
1245
  /** Field key (or block id) the value belongs to. */
1244
1246
  field: string;
1247
+ /** The binding kind (`text`), where the encoder knows it. */
1248
+ kind?: string;
1245
1249
  }
1246
1250
  /** Append an invisible provenance payload to a string. */
1247
1251
  declare function encodeStega(clean: string, payload: StegaPayload): string;
@@ -1252,6 +1256,72 @@ declare function decodeStega(value: string): {
1252
1256
  } | null;
1253
1257
  /** Remove any stega payload, returning the clean string. */
1254
1258
  declare function stripStega(value: string): string;
1259
+ /**
1260
+ * Where a value BEGINS in a rendered page: an empty frame. The canvas brackets every bound
1261
+ * string with it and the payload frame, so a text node can be told inside a value from text
1262
+ * that merely precedes one. @see resolveStega
1263
+ */
1264
+ declare const STEGA_OPEN = "\u2060\u2061";
1265
+ /** Remove EVERY stega frame, markers included. What a value passes through before it is saved or published. */
1266
+ declare function stegaClean(value: string): string;
1267
+ /** The least of a DOM node this needs: a real `Node` satisfies it, and so does a test's plain object. */
1268
+ interface StegaNode {
1269
+ textContent: string | null;
1270
+ parentNode: StegaNode | null;
1271
+ childNodes?: ArrayLike<StegaNode>;
1272
+ }
1273
+ /**
1274
+ * Which value does this node render? Its payload and the nearest ancestor that holds the whole
1275
+ * value, or null when the node's text belongs to none.
1276
+ *
1277
+ * By CONTENT, not by attribute: a splitting library cuts a heading into one element per
1278
+ * character, a marquee clones its track, a component redraws its children, and the element a
1279
+ * build stamped is gone or copied. The string survives all of that, in order, across however
1280
+ * many text nodes: climbing from the clicked node, the first ancestor whose text holds a value
1281
+ * (its open marker to its payload frame) that overlaps the node is the value's extent.
1282
+ * Every copy of a value resolves to the same payload.
1283
+ */
1284
+ declare function resolveStega(node: StegaNode): {
1285
+ payload: StegaPayload;
1286
+ element: StegaNode;
1287
+ } | null;
1288
+
1289
+ /**
1290
+ * `bcms:content-applied` — what the visual editor tells a page after it has applied an edit to
1291
+ * the page's DOM.
1292
+ *
1293
+ * An edit changes how tall a heading is. Everything on the page that measured the layout once
1294
+ * (ScrollTrigger's start and end positions, Lenis's scroll limit, a carousel's slide widths, a
1295
+ * text splitter's lines) is now wrong, and only the page's own code can measure again. So the
1296
+ * editor posts one message to the frame's window after each applied edit, and the site listens:
1297
+ *
1298
+ * onContentApplied(() => ScrollTrigger.refresh());
1299
+ *
1300
+ * A published page receives no such message: nothing there posts it, and the listener is inert.
1301
+ */
1302
+ /** The `type` of the message. */
1303
+ declare const CONTENT_APPLIED = "bcms:content-applied";
1304
+ interface ContentAppliedMessage {
1305
+ type: typeof CONTENT_APPLIED;
1306
+ /** The field addresses whose rendering changed; empty when the editor does not say. */
1307
+ fields: string[];
1308
+ }
1309
+ /** The message the editor posts: `frame.contentWindow.postMessage(contentApplied(fields), origin)`. */
1310
+ declare const contentApplied: (fields?: readonly string[]) => ContentAppliedMessage;
1311
+ /** The least of `window` this needs. */
1312
+ interface MessageTarget {
1313
+ addEventListener(type: "message", listener: (event: {
1314
+ data: unknown;
1315
+ }) => void): void;
1316
+ removeEventListener(type: "message", listener: (event: {
1317
+ data: unknown;
1318
+ }) => void): void;
1319
+ }
1320
+ /**
1321
+ * Run `handler` after every edit the editor applies to this page. Returns the function that
1322
+ * stops listening. Safe to call where there is no window (a server render): it does nothing.
1323
+ */
1324
+ declare function onContentApplied(handler: (message: ContentAppliedMessage) => void, target?: MessageTarget | undefined): () => void;
1255
1325
 
1256
1326
  /**
1257
1327
  * Reading a rich-text field, for any site.
@@ -1825,4 +1895,4 @@ interface WebhookListResponse {
1825
1895
  };
1826
1896
  }
1827
1897
 
1828
- export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type 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 ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, type UpdateApiKeyInput, type 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, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
1898
+ export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type 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 ResolvedSeo, type RichTextValue, STEGA_OPEN, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, 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, asStringArray, commandManagedLayout, contentApplied, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, resolveStega, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
package/dist/index.js CHANGED
@@ -1395,6 +1395,52 @@ function decodeStega(value) {
1395
1395
  function stripStega(value) {
1396
1396
  return value.replace(FRAME, "");
1397
1397
  }
1398
+ var STEGA_OPEN = `${START}${END}`;
1399
+ var FRAMES = new RegExp(`${START}([${ZERO}${ONE}]*)${END}`, "g");
1400
+ function stegaClean(value) {
1401
+ return value.replace(FRAMES, "");
1402
+ }
1403
+ function resolveStega(node) {
1404
+ let offset = 0;
1405
+ const length = node.textContent?.length ?? 0;
1406
+ for (let cur = node, up = node.parentNode; up; cur = up, up = up.parentNode) {
1407
+ for (const sibling of Array.from(up.childNodes ?? [])) {
1408
+ if (sibling === cur) break;
1409
+ offset += sibling.textContent?.length ?? 0;
1410
+ }
1411
+ const text = up.textContent ?? "";
1412
+ const opens = [];
1413
+ for (const frame of text.matchAll(FRAMES)) {
1414
+ if (!frame[1]) {
1415
+ opens.push(frame.index);
1416
+ continue;
1417
+ }
1418
+ const open = opens.pop();
1419
+ if (frame.index + frame[0].length <= offset || open === void 0 || open >= offset + length) continue;
1420
+ try {
1421
+ return { payload: JSON.parse(fromBits(frame[1])), element: up };
1422
+ } catch {
1423
+ break;
1424
+ }
1425
+ }
1426
+ }
1427
+ return null;
1428
+ }
1429
+
1430
+ // src/content-applied.ts
1431
+ var CONTENT_APPLIED = "bcms:content-applied";
1432
+ var contentApplied = (fields = []) => ({ type: CONTENT_APPLIED, fields: [...fields] });
1433
+ function onContentApplied(handler, target = globalThis.window) {
1434
+ if (!target) return () => {
1435
+ };
1436
+ const listener = (event) => {
1437
+ const data = event.data;
1438
+ if (!data || typeof data !== "object" || data.type !== CONTENT_APPLIED) return;
1439
+ handler({ type: CONTENT_APPLIED, fields: Array.isArray(data.fields) ? data.fields.filter((f) => typeof f === "string") : [] });
1440
+ };
1441
+ target.addEventListener("message", listener);
1442
+ return () => target.removeEventListener("message", listener);
1443
+ }
1398
1444
 
1399
1445
  // src/richtext.ts
1400
1446
  var PORTABLE_TEXT_FORMAT = "portable-text-1";
@@ -1862,6 +1908,7 @@ function shouldShowField(field, values) {
1862
1908
  function formInitialValues(form, prefill = {}) {
1863
1909
  const values = {};
1864
1910
  for (const field of form.fields) {
1911
+ if (field.type === "step") continue;
1865
1912
  if (field.type === "checkbox" || field.type === "consent") {
1866
1913
  values[field.key] = false;
1867
1914
  } else if (field.type === "checkboxes") {
@@ -1912,12 +1959,15 @@ export {
1912
1959
  BetterCMSDeliveryClient,
1913
1960
  BetterCMSError,
1914
1961
  BetterCMSManagementClient,
1962
+ CONTENT_APPLIED,
1915
1963
  ErrorCodes,
1916
1964
  PORTABLE_TEXT_FORMAT,
1965
+ STEGA_OPEN,
1917
1966
  addModelFields,
1918
1967
  addPageFields,
1919
1968
  asStringArray,
1920
1969
  commandManagedLayout,
1970
+ contentApplied,
1921
1971
  createApiKey,
1922
1972
  createClient,
1923
1973
  createEntry,
@@ -1965,6 +2015,7 @@ export {
1965
2015
  listPages,
1966
2016
  listSubmissions,
1967
2017
  listWorkspaces,
2018
+ onContentApplied,
1968
2019
  plain,
1969
2020
  portableText,
1970
2021
  publishManagedLayout,
@@ -1976,6 +2027,7 @@ export {
1976
2027
  removeMember,
1977
2028
  resetPublishedContentCache,
1978
2029
  resolveSeo,
2030
+ resolveStega,
1979
2031
  revokeApiKey,
1980
2032
  rich,
1981
2033
  search,
@@ -1985,6 +2037,7 @@ export {
1985
2037
  signInWithGithub,
1986
2038
  signInWithGoogle,
1987
2039
  signUp,
2040
+ stegaClean,
1988
2041
  stripStega,
1989
2042
  submitForm,
1990
2043
  toggleOption,