@bettercms-ai/sdk 1.45.0 → 1.47.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
@@ -1,11 +1,12 @@
1
1
  import * as _bettercms_ai_types from '@bettercms-ai/types';
2
2
  import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Page, MediaAsset, FormField, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
3
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, fileFieldLimits, getBlockType, isBlock } from '@bettercms-ai/types';
4
- import { D as DeliveryFormField } from './read-client-E9OHtQAW.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, U as UploadFormFileOptions, h as UploadedFormFile, i as asStringArray, j as createClient, k as fileFieldRefusal, l as formInitialValues, m as isMultiValueField, s as shouldShowField, n as submitForm, t as toggleOption, u as uploadFormFile } from './read-client-E9OHtQAW.cjs';
4
+ import { D as DeliveryFormField } from './read-client-D5jzCGEc.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, U as UploadFormFileOptions, h as UploadedFormFile, i as asStringArray, j as createClient, k as fileFieldRefusal, l as formInitialValues, m as isMultiValueField, s as shouldShowField, n as submitForm, t as toggleOption, u as uploadFormFile } from './read-client-D5jzCGEc.cjs';
6
6
  export { C as CONTENT_APPLIED, a as ContentAppliedMessage, E as EDITOR_FRAME_NAME, c as contentApplied, i as inEditor, o as onContentApplied } from './in-editor-D1vXPgJh.cjs';
7
- export { P as PORTABLE_TEXT_FORMAT, a as PublishedContent, R as ResolvedHolder, b as RichTextValue, S as SearchHit, c as SearchOptions, T as TextOrRich, e as embeds, i as isRichText, l as lines, p as plain, d as portableText, f as publishedContentFile, g as publishedEntry, r as readPublishedContent, h as resetPublishedContentCache, j as resolved, k as rich, s as search } from './read-DTTdE_Xl.cjs';
7
+ export { P as PORTABLE_TEXT_FORMAT, a as PublishedContent, R as ResolvedHolder, b as RichTextValue, S as SearchHit, c as SearchOptions, T as TextOrRich, e as embeds, i as isRichText, l as lines, p as plain, d as portableText, f as publishedContentFile, g as publishedEntry, r as readPublishedContent, h as resetPublishedContentCache, j as resolved, k as rich, s as search } from './read-DlLBgPVS.cjs';
8
8
  export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.cjs';
9
+ export { verifyWebhookSignature } from './webhook.cjs';
9
10
  export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
10
11
 
11
12
  /**
@@ -946,36 +947,61 @@ declare const BetterCMS: {
946
947
  signUp(options: SignUpInput): Promise<AuthResult>;
947
948
  };
948
949
 
949
- /** Provenance describing where a string came from, for editor deep-linking. */
950
+ /**
951
+ * Provenance describing where a string came from, for editor deep-linking. A `stega=2` payload
952
+ * (`{t, id, f}`) is read into this same shape: `type` from `t`, `field` from `f`, and `ws`/`slug`
953
+ * empty, because v2 does not carry them.
954
+ */
950
955
  interface StegaPayload {
951
- /** Workspace slug. */
956
+ /** Workspace slug (v1 only; "" from a v2 payload). */
952
957
  ws: string;
953
- type: "entry" | "page";
958
+ type: "entry" | "page" | "layout" | "component";
954
959
  /** Entry/page id. */
955
960
  id: string;
961
+ /** v1 only; "" from a v2 payload. */
956
962
  slug: string;
957
963
  /** Field key (or block id) the value belongs to. */
958
964
  field: string;
959
965
  /** The binding kind (`text`), where the encoder knows it. */
960
966
  kind?: string;
961
967
  }
962
- /** Append an invisible provenance payload to a string. */
968
+ /** Append an invisible provenance payload to a string (the v1 frame). */
963
969
  declare function encodeStega(clean: string, payload: StegaPayload): string;
964
- /** Extract `{ clean, payload }` from a stega-encoded string, or null if absent. */
970
+ /**
971
+ * Extract `{ clean, payload }` from a stega-encoded string (v1 or v2), or null if absent. `ref` is
972
+ * the field ref, present when the payload names a document.
973
+ */
965
974
  declare function decodeStega(value: string): {
966
975
  clean: string;
967
976
  payload: StegaPayload;
977
+ ref?: string;
968
978
  } | null;
969
- /** Remove any stega payload, returning the clean string. */
970
- declare function stripStega(value: string): string;
979
+ /**
980
+ * A value's clean text and the field ref it carries (`entry:e_1:title`, `page:pg_1:hero.title`,
981
+ * `layout:nav:brand`), or `ref: null` when it carries none. What a template uses when it needs both
982
+ * the string to compare and the address to bind.
983
+ */
984
+ declare function stegaSplit(value: string): {
985
+ clean: string;
986
+ ref: string | null;
987
+ };
971
988
  /**
972
989
  * Where a value BEGINS in a rendered page: an empty frame. The canvas brackets every bound
973
990
  * string with it and the payload frame, so a text node can be told inside a value from text
974
991
  * that merely precedes one. @see resolveStega
975
992
  */
976
993
  declare const STEGA_OPEN = "\u2060\u2061";
977
- /** Remove EVERY stega frame, markers included. What a value passes through before it is saved or published. */
978
- declare function stegaClean(value: string): string;
994
+ /**
995
+ * A value with EVERY stega frame taken out, markers included, from every string in it at any depth
996
+ * (arrays and plain objects). The SAME value back when it holds none. What a value passes through
997
+ * before it is compared, used as a key or attribute, saved or published.
998
+ */
999
+ declare function stegaClean<T>(value: T): T;
1000
+ /**
1001
+ * Remove every stega frame. An alias of {@link stegaClean}: it used to remove only the FIRST frame,
1002
+ * which left the payload behind on a `stega=2` value (an open marker, then the payload).
1003
+ */
1004
+ declare const stripStega: typeof stegaClean;
979
1005
  /** The least of a DOM node this needs: a real `Node` satisfies it, and so does a test's plain object. */
980
1006
  interface StegaNode {
981
1007
  textContent: string | null;
@@ -998,6 +1024,52 @@ declare function resolveStega(node: StegaNode): {
998
1024
  element: StegaNode;
999
1025
  } | null;
1000
1026
 
1027
+ /** A frame found where no rendered text belongs, which a template should have cleaned. */
1028
+ interface StegaLeak {
1029
+ kind: "head" | "attribute" | "script" | "style" | "form" | "comment";
1030
+ /** The field ref the leaked frame carries, when it carries one. */
1031
+ ref: string | null;
1032
+ /** `tag` for text, `tag[attribute]` for an attribute. */
1033
+ where: string;
1034
+ }
1035
+ interface MarkEditableResult {
1036
+ /** Elements stamped from a frame. */
1037
+ stamped: number;
1038
+ leaks: StegaLeak[];
1039
+ /** Values found and left unstamped: sharing their element, or a ref this page cannot stamp. */
1040
+ unresolved: number;
1041
+ }
1042
+ /**
1043
+ * The least of the DOM this needs, so the SDK's types never pull the DOM library into a consumer
1044
+ * that runs on a server: a real `Element` satisfies it, and so does a JSDOM one.
1045
+ */
1046
+ interface MarkNode {
1047
+ nodeType: number;
1048
+ parentNode: MarkNode | null;
1049
+ }
1050
+ interface MarkElement extends MarkNode {
1051
+ tagName: string;
1052
+ namespaceURI: string | null;
1053
+ textContent: string | null;
1054
+ childElementCount: number;
1055
+ attributes: ArrayLike<{
1056
+ name: string;
1057
+ value: string;
1058
+ }>;
1059
+ childNodes: ArrayLike<MarkNode>;
1060
+ /** A `<template>`'s parsed children live here, not in `childNodes`. */
1061
+ content?: {
1062
+ childNodes: ArrayLike<MarkNode>;
1063
+ };
1064
+ hasAttribute(name: string): boolean;
1065
+ setAttribute(name: string, value: string): void;
1066
+ querySelectorAll(selector: string): ArrayLike<MarkElement>;
1067
+ }
1068
+ declare function markEditable(root: MarkElement, opts: {
1069
+ pageId?: string;
1070
+ strip: boolean;
1071
+ }): MarkEditableResult;
1072
+
1001
1073
  /**
1002
1074
  * Admin pages methods.
1003
1075
  * @see openspec/changes/flo-6-backend-sdk-admin/specs/sdk-admin-client/spec.md
@@ -1273,4 +1345,4 @@ interface WebhookListResponse {
1273
1345
  };
1274
1346
  }
1275
1347
 
1276
- export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, 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, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, 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, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveStega, revokeApiKey, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
1348
+ export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, 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 MarkEditableResult, type MarkElement, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaLeak, type StegaNode, type StegaPayload, type SubmissionListOptions, 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, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, markEditable, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveStega, revokeApiKey, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stegaSplit, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import * as _bettercms_ai_types from '@bettercms-ai/types';
2
2
  import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Page, MediaAsset, FormField, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
3
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, fileFieldLimits, getBlockType, isBlock } from '@bettercms-ai/types';
4
- import { D as DeliveryFormField } from './read-client-E9OHtQAW.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, U as UploadFormFileOptions, h as UploadedFormFile, i as asStringArray, j as createClient, k as fileFieldRefusal, l as formInitialValues, m as isMultiValueField, s as shouldShowField, n as submitForm, t as toggleOption, u as uploadFormFile } from './read-client-E9OHtQAW.js';
4
+ import { D as DeliveryFormField } from './read-client-D5jzCGEc.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, U as UploadFormFileOptions, h as UploadedFormFile, i as asStringArray, j as createClient, k as fileFieldRefusal, l as formInitialValues, m as isMultiValueField, s as shouldShowField, n as submitForm, t as toggleOption, u as uploadFormFile } from './read-client-D5jzCGEc.js';
6
6
  export { C as CONTENT_APPLIED, a as ContentAppliedMessage, E as EDITOR_FRAME_NAME, c as contentApplied, i as inEditor, o as onContentApplied } from './in-editor-D1vXPgJh.js';
7
- export { P as PORTABLE_TEXT_FORMAT, a as PublishedContent, R as ResolvedHolder, b as RichTextValue, S as SearchHit, c as SearchOptions, T as TextOrRich, e as embeds, i as isRichText, l as lines, p as plain, d as portableText, f as publishedContentFile, g as publishedEntry, r as readPublishedContent, h as resetPublishedContentCache, j as resolved, k as rich, s as search } from './read-CMasc3wt.js';
7
+ export { P as PORTABLE_TEXT_FORMAT, a as PublishedContent, R as ResolvedHolder, b as RichTextValue, S as SearchHit, c as SearchOptions, T as TextOrRich, e as embeds, i as isRichText, l as lines, p as plain, d as portableText, f as publishedContentFile, g as publishedEntry, r as readPublishedContent, h as resetPublishedContentCache, j as resolved, k as rich, s as search } from './read-CpX17LTf.js';
8
8
  export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.js';
9
+ export { verifyWebhookSignature } from './webhook.js';
9
10
  export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
10
11
 
11
12
  /**
@@ -946,36 +947,61 @@ declare const BetterCMS: {
946
947
  signUp(options: SignUpInput): Promise<AuthResult>;
947
948
  };
948
949
 
949
- /** Provenance describing where a string came from, for editor deep-linking. */
950
+ /**
951
+ * Provenance describing where a string came from, for editor deep-linking. A `stega=2` payload
952
+ * (`{t, id, f}`) is read into this same shape: `type` from `t`, `field` from `f`, and `ws`/`slug`
953
+ * empty, because v2 does not carry them.
954
+ */
950
955
  interface StegaPayload {
951
- /** Workspace slug. */
956
+ /** Workspace slug (v1 only; "" from a v2 payload). */
952
957
  ws: string;
953
- type: "entry" | "page";
958
+ type: "entry" | "page" | "layout" | "component";
954
959
  /** Entry/page id. */
955
960
  id: string;
961
+ /** v1 only; "" from a v2 payload. */
956
962
  slug: string;
957
963
  /** Field key (or block id) the value belongs to. */
958
964
  field: string;
959
965
  /** The binding kind (`text`), where the encoder knows it. */
960
966
  kind?: string;
961
967
  }
962
- /** Append an invisible provenance payload to a string. */
968
+ /** Append an invisible provenance payload to a string (the v1 frame). */
963
969
  declare function encodeStega(clean: string, payload: StegaPayload): string;
964
- /** Extract `{ clean, payload }` from a stega-encoded string, or null if absent. */
970
+ /**
971
+ * Extract `{ clean, payload }` from a stega-encoded string (v1 or v2), or null if absent. `ref` is
972
+ * the field ref, present when the payload names a document.
973
+ */
965
974
  declare function decodeStega(value: string): {
966
975
  clean: string;
967
976
  payload: StegaPayload;
977
+ ref?: string;
968
978
  } | null;
969
- /** Remove any stega payload, returning the clean string. */
970
- declare function stripStega(value: string): string;
979
+ /**
980
+ * A value's clean text and the field ref it carries (`entry:e_1:title`, `page:pg_1:hero.title`,
981
+ * `layout:nav:brand`), or `ref: null` when it carries none. What a template uses when it needs both
982
+ * the string to compare and the address to bind.
983
+ */
984
+ declare function stegaSplit(value: string): {
985
+ clean: string;
986
+ ref: string | null;
987
+ };
971
988
  /**
972
989
  * Where a value BEGINS in a rendered page: an empty frame. The canvas brackets every bound
973
990
  * string with it and the payload frame, so a text node can be told inside a value from text
974
991
  * that merely precedes one. @see resolveStega
975
992
  */
976
993
  declare const STEGA_OPEN = "\u2060\u2061";
977
- /** Remove EVERY stega frame, markers included. What a value passes through before it is saved or published. */
978
- declare function stegaClean(value: string): string;
994
+ /**
995
+ * A value with EVERY stega frame taken out, markers included, from every string in it at any depth
996
+ * (arrays and plain objects). The SAME value back when it holds none. What a value passes through
997
+ * before it is compared, used as a key or attribute, saved or published.
998
+ */
999
+ declare function stegaClean<T>(value: T): T;
1000
+ /**
1001
+ * Remove every stega frame. An alias of {@link stegaClean}: it used to remove only the FIRST frame,
1002
+ * which left the payload behind on a `stega=2` value (an open marker, then the payload).
1003
+ */
1004
+ declare const stripStega: typeof stegaClean;
979
1005
  /** The least of a DOM node this needs: a real `Node` satisfies it, and so does a test's plain object. */
980
1006
  interface StegaNode {
981
1007
  textContent: string | null;
@@ -998,6 +1024,52 @@ declare function resolveStega(node: StegaNode): {
998
1024
  element: StegaNode;
999
1025
  } | null;
1000
1026
 
1027
+ /** A frame found where no rendered text belongs, which a template should have cleaned. */
1028
+ interface StegaLeak {
1029
+ kind: "head" | "attribute" | "script" | "style" | "form" | "comment";
1030
+ /** The field ref the leaked frame carries, when it carries one. */
1031
+ ref: string | null;
1032
+ /** `tag` for text, `tag[attribute]` for an attribute. */
1033
+ where: string;
1034
+ }
1035
+ interface MarkEditableResult {
1036
+ /** Elements stamped from a frame. */
1037
+ stamped: number;
1038
+ leaks: StegaLeak[];
1039
+ /** Values found and left unstamped: sharing their element, or a ref this page cannot stamp. */
1040
+ unresolved: number;
1041
+ }
1042
+ /**
1043
+ * The least of the DOM this needs, so the SDK's types never pull the DOM library into a consumer
1044
+ * that runs on a server: a real `Element` satisfies it, and so does a JSDOM one.
1045
+ */
1046
+ interface MarkNode {
1047
+ nodeType: number;
1048
+ parentNode: MarkNode | null;
1049
+ }
1050
+ interface MarkElement extends MarkNode {
1051
+ tagName: string;
1052
+ namespaceURI: string | null;
1053
+ textContent: string | null;
1054
+ childElementCount: number;
1055
+ attributes: ArrayLike<{
1056
+ name: string;
1057
+ value: string;
1058
+ }>;
1059
+ childNodes: ArrayLike<MarkNode>;
1060
+ /** A `<template>`'s parsed children live here, not in `childNodes`. */
1061
+ content?: {
1062
+ childNodes: ArrayLike<MarkNode>;
1063
+ };
1064
+ hasAttribute(name: string): boolean;
1065
+ setAttribute(name: string, value: string): void;
1066
+ querySelectorAll(selector: string): ArrayLike<MarkElement>;
1067
+ }
1068
+ declare function markEditable(root: MarkElement, opts: {
1069
+ pageId?: string;
1070
+ strip: boolean;
1071
+ }): MarkEditableResult;
1072
+
1001
1073
  /**
1002
1074
  * Admin pages methods.
1003
1075
  * @see openspec/changes/flo-6-backend-sdk-admin/specs/sdk-admin-client/spec.md
@@ -1273,4 +1345,4 @@ interface WebhookListResponse {
1273
1345
  };
1274
1346
  }
1275
1347
 
1276
- export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, 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, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, 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, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveStega, revokeApiKey, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
1348
+ export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, 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 MarkEditableResult, type MarkElement, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaLeak, type StegaNode, type StegaPayload, type SubmissionListOptions, 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, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, markEditable, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveStega, revokeApiKey, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stegaSplit, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
package/dist/index.js CHANGED
@@ -1174,10 +1174,24 @@ var BRANCH_SIGNATURE_HEADER = "X-BCMS-Branch-Signature";
1174
1174
 
1175
1175
  // src/read-client.ts
1176
1176
  var DEFAULT_TIMEOUT3 = 1e4;
1177
+ function listQueryParams(filter, sort) {
1178
+ const text = (v) => Array.isArray(v) ? v.join(",") : String(v);
1179
+ const out = {};
1180
+ for (const [field, cond] of Object.entries(filter ?? {})) {
1181
+ if (cond == null) continue;
1182
+ if (Array.isArray(cond)) out[`filter[${field}][in]`] = text(cond);
1183
+ else if (typeof cond === "object") {
1184
+ for (const [op, v] of Object.entries(cond)) if (v != null) out[`filter[${field}][${op}]`] = text(v);
1185
+ } else out[`filter[${field}]`] = text(cond);
1186
+ }
1187
+ const order = Array.isArray(sort) ? sort.join(",") : sort;
1188
+ if (order) out.sort = order;
1189
+ return out;
1190
+ }
1177
1191
  function qs(params2) {
1178
1192
  const sp = new URLSearchParams();
1179
1193
  for (const [k, v] of Object.entries(params2)) {
1180
- if (v !== void 0 && v !== "") sp.set(k, String(v));
1194
+ if (v !== void 0 && (v !== "" || k.startsWith("filter["))) sp.set(k, String(v));
1181
1195
  }
1182
1196
  const s = sp.toString();
1183
1197
  return s ? `?${s}` : "";
@@ -1273,6 +1287,7 @@ function createClient(options) {
1273
1287
  }
1274
1288
  const draft = perspective === "drafts";
1275
1289
  const stega = options.stega ?? draft;
1290
+ const stegaParam = stega === 2 ? "2" : stega ? "1" : void 0;
1276
1291
  return {
1277
1292
  perspective,
1278
1293
  async getEntry(slug, opts) {
@@ -1280,12 +1295,12 @@ function createClient(options) {
1280
1295
  token: previewToken,
1281
1296
  depth: opts?.depth,
1282
1297
  select: opts?.select?.join(","),
1283
- stega: stega ? "1" : void 0
1298
+ stega: stegaParam
1284
1299
  })}` : `${base}/content-entries/${encodeURIComponent(slug)}${qs({
1285
1300
  depth: opts?.depth,
1286
1301
  select: opts?.select?.join(","),
1287
1302
  perspective: draft ? "draft" : void 0,
1288
- stega: draft && stega ? "1" : void 0,
1303
+ stega: draft ? stegaParam : void 0,
1289
1304
  projectId: defaultProjectId,
1290
1305
  branch
1291
1306
  })}`;
@@ -1298,8 +1313,9 @@ function createClient(options) {
1298
1313
  perPage: opts?.perPage,
1299
1314
  depth: opts?.depth,
1300
1315
  select: opts?.select?.join(","),
1316
+ ...listQueryParams(opts?.filter, opts?.sort),
1301
1317
  perspective: draft ? "draft" : void 0,
1302
- stega: draft && stega ? "1" : void 0,
1318
+ stega: draft ? stegaParam : void 0,
1303
1319
  projectId: defaultProjectId,
1304
1320
  branch
1305
1321
  })}`;
@@ -1309,7 +1325,7 @@ function createClient(options) {
1309
1325
  if (draft && previewToken && tokenSlug(previewToken) === slug) {
1310
1326
  const url = `${apiUrl}/api/v1/preview/${encodeURIComponent(slug)}${qs({
1311
1327
  token: previewToken,
1312
- stega: stega ? "1" : void 0
1328
+ stega: stegaParam
1313
1329
  })}`;
1314
1330
  const d = unwrap(await fetchJSON(url));
1315
1331
  return {
@@ -1339,6 +1355,8 @@ function createClient(options) {
1339
1355
  page: opts?.page,
1340
1356
  perPage: opts?.perPage,
1341
1357
  slug: opts?.slug,
1358
+ // Framed only on a branch, the draft lane of this list; never v1, which frames no blocks.
1359
+ stega: draft && stega === 2 ? "2" : void 0,
1342
1360
  projectId: defaultProjectId,
1343
1361
  branch
1344
1362
  })}`;
@@ -1354,7 +1372,7 @@ function createClient(options) {
1354
1372
  return unwrap(await fetchJSON(url));
1355
1373
  },
1356
1374
  async getLayout() {
1357
- const url = `${base}/layout${qs({ perspective: draft ? "draft" : void 0, projectId: defaultProjectId, branch })}`;
1375
+ const url = `${base}/layout${qs({ perspective: draft ? "draft" : void 0, stega: draft && stega === 2 ? "2" : void 0, projectId: defaultProjectId, branch })}`;
1358
1376
  try {
1359
1377
  return unwrap(await fetchJSON(url));
1360
1378
  } catch (error) {
@@ -1382,7 +1400,7 @@ var ZERO = "\u200B";
1382
1400
  var ONE = "\u200C";
1383
1401
  var START = "\u2060";
1384
1402
  var END = "\u2061";
1385
- var FRAME = new RegExp(`${START}([${ZERO}${ONE}]*)${END}`);
1403
+ var FRAMES = new RegExp(`${START}([${ZERO}${ONE}]*)${END}`, "g");
1386
1404
  function toBits(s) {
1387
1405
  const bytes = new TextEncoder().encode(s);
1388
1406
  let out = "";
@@ -1403,23 +1421,50 @@ function fromBits(bits) {
1403
1421
  function encodeStega(clean, payload) {
1404
1422
  return `${clean}${START}${toBits(JSON.stringify(payload))}${END}`;
1405
1423
  }
1406
- function decodeStega(value) {
1407
- const m = value.match(FRAME);
1408
- if (!m || m[1] == null) return null;
1424
+ var V2_TYPES = { e: "entry", p: "page", l: "layout", c: "component" };
1425
+ function payloadOf(bits) {
1409
1426
  try {
1410
- const payload = JSON.parse(fromBits(m[1]));
1411
- return { clean: value.replace(FRAME, ""), payload };
1427
+ const raw = JSON.parse(fromBits(bits));
1428
+ if (typeof raw.t === "string" && raw.t in V2_TYPES && typeof raw.id === "string" && typeof raw.f === "string") {
1429
+ return { ws: "", type: V2_TYPES[raw.t], id: raw.id, slug: "", field: raw.f };
1430
+ }
1431
+ return raw;
1412
1432
  } catch {
1413
1433
  return null;
1414
1434
  }
1415
1435
  }
1416
- function stripStega(value) {
1417
- return value.replace(FRAME, "");
1436
+ var TARGETS = { entry: 1, page: 1, layout: 1, component: 1 };
1437
+ var stegaRef = (payload) => typeof payload.type === "string" && payload.type in TARGETS && typeof payload.id === "string" && typeof payload.field === "string" ? `${payload.type}:${payload.id}:${payload.field}` : null;
1438
+ function decodeStega(value) {
1439
+ for (const frame of value.matchAll(FRAMES)) {
1440
+ if (!frame[1]) continue;
1441
+ const payload = payloadOf(frame[1]);
1442
+ if (!payload) return null;
1443
+ const ref = stegaRef(payload);
1444
+ return { clean: stegaClean(value), payload, ...ref ? { ref } : {} };
1445
+ }
1446
+ return null;
1447
+ }
1448
+ function stegaSplit(value) {
1449
+ const decoded = decodeStega(value);
1450
+ return { clean: decoded?.clean ?? stegaClean(value), ref: decoded?.ref ?? null };
1418
1451
  }
1419
1452
  var STEGA_OPEN = `${START}${END}`;
1420
- var FRAMES = new RegExp(`${START}([${ZERO}${ONE}]*)${END}`, "g");
1421
1453
  function stegaClean(value) {
1422
- return value.replace(FRAMES, "");
1454
+ if (typeof value === "string") return value.includes(START) ? value.replace(FRAMES, "") : value;
1455
+ if (Array.isArray(value)) {
1456
+ const out = value.map((v) => stegaClean(v));
1457
+ return out.some((v, i) => v !== value[i]) ? out : value;
1458
+ }
1459
+ if (value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
1460
+ const entries = Object.entries(value).map(([k, v]) => [k, stegaClean(v)]);
1461
+ return entries.some(([k, v]) => v !== value[k]) ? Object.fromEntries(entries) : value;
1462
+ }
1463
+ return value;
1464
+ }
1465
+ var stripStega = stegaClean;
1466
+ function stegaFrames(text) {
1467
+ return [...text.matchAll(FRAMES)].map((m) => ({ index: m.index, end: m.index + m[0].length, payload: m[1] ? payloadOf(m[1]) : null, open: !m[1] }));
1423
1468
  }
1424
1469
  function resolveStega(node) {
1425
1470
  let offset = 0;
@@ -1431,22 +1476,126 @@ function resolveStega(node) {
1431
1476
  }
1432
1477
  const text = up.textContent ?? "";
1433
1478
  const opens = [];
1434
- for (const frame of text.matchAll(FRAMES)) {
1435
- if (!frame[1]) {
1479
+ for (const frame of stegaFrames(text)) {
1480
+ if (frame.open) {
1436
1481
  opens.push(frame.index);
1437
1482
  continue;
1438
1483
  }
1439
1484
  const open = opens.pop();
1440
- if (frame.index + frame[0].length <= offset || open === void 0 || open >= offset + length) continue;
1441
- try {
1442
- return { payload: JSON.parse(fromBits(frame[1])), element: up };
1443
- } catch {
1444
- break;
1485
+ if (frame.end <= offset || open === void 0 || open >= offset + length) continue;
1486
+ if (!frame.payload) break;
1487
+ return { payload: frame.payload, element: up };
1488
+ }
1489
+ }
1490
+ return null;
1491
+ }
1492
+
1493
+ // src/mark-editable.ts
1494
+ var BOUND = ["data-bcms-field", "data-bcms-layout-field", "data-bcms-entry-field"];
1495
+ var NOT_PROSE = { SCRIPT: "script", STYLE: "style", NOSCRIPT: "script", TEMPLATE: "script", TITLE: "head", TEXTAREA: "form" };
1496
+ var INLINE_BREAKS = /* @__PURE__ */ new Set(["BR", "WBR"]);
1497
+ var SVG = "http://www.w3.org/2000/svg";
1498
+ var START2 = "\u2060";
1499
+ var isBound = (el) => BOUND.some((name) => el.hasAttribute(name));
1500
+ function refIn(text) {
1501
+ const payload = stegaFrames(text).find((frame) => frame.payload)?.payload;
1502
+ return payload ? stegaRef(payload) : null;
1503
+ }
1504
+ function stampOf(ref, pageId) {
1505
+ const [target, id] = ref.split(":", 2);
1506
+ const path = ref.slice(`${target}:${id}:`.length);
1507
+ if (!path) return null;
1508
+ if (target === "entry") return ["data-bcms-entry-field", ref];
1509
+ if (target === "layout") return ["data-bcms-layout-field", ref];
1510
+ if (target === "page" && pageId && id === pageId) return ["data-bcms-field", path];
1511
+ return null;
1512
+ }
1513
+ function markEditable(root, opts) {
1514
+ const leaks = [];
1515
+ const texts = [];
1516
+ const all = [];
1517
+ const leak = (kind, where, text) => leaks.push({ kind, ref: refIn(text), where });
1518
+ const visit = (el, skip) => {
1519
+ for (const attr of Array.from(el.attributes)) {
1520
+ if (!attr.value.includes(START2)) continue;
1521
+ leak("attribute", `${el.tagName.toLowerCase()}[${attr.name}]`, attr.value);
1522
+ el.setAttribute(attr.name, stegaClean(attr.value));
1523
+ }
1524
+ const own = el.tagName === "HEAD" ? "head" : NOT_PROSE[el.tagName];
1525
+ const next = skip ?? own ?? (el.namespaceURI === SVG ? "bound" : null) ?? (el !== root && isBound(el) ? "bound" : null);
1526
+ for (const node of [...Array.from(el.childNodes), ...Array.from(el.content?.childNodes ?? [])]) {
1527
+ if (node.nodeType === 1) visit(node, next);
1528
+ else if (node.nodeType === 8 && node.data.includes(START2)) {
1529
+ const comment = node;
1530
+ leak("comment", el.tagName.toLowerCase(), comment.data);
1531
+ comment.data = stegaClean(comment.data);
1532
+ } else if (node.nodeType === 3) {
1533
+ const text = node;
1534
+ all.push(text);
1535
+ if (next === null) texts.push(text);
1536
+ else if (next !== "bound" && text.data.includes(START2)) {
1537
+ leak(next, el.tagName.toLowerCase(), text.data);
1538
+ text.data = stegaClean(text.data);
1539
+ }
1445
1540
  }
1446
1541
  }
1542
+ };
1543
+ visit(root, null);
1544
+ const starts = [];
1545
+ let full = "";
1546
+ for (const text of texts) {
1547
+ starts.push(full.length);
1548
+ full += text.data;
1549
+ }
1550
+ const nodeAt = (offset) => {
1551
+ let lo = 0;
1552
+ let hi = starts.length - 1;
1553
+ while (lo < hi) {
1554
+ const mid = lo + hi + 1 >> 1;
1555
+ if (starts[mid] <= offset) lo = mid;
1556
+ else hi = mid - 1;
1557
+ }
1558
+ return lo;
1559
+ };
1560
+ let stamped = 0;
1561
+ let unresolved = 0;
1562
+ const opens = [];
1563
+ for (const frame of stegaFrames(full)) {
1564
+ if (frame.open) {
1565
+ opens.push(frame.index);
1566
+ continue;
1567
+ }
1568
+ const start = opens.pop() ?? starts[nodeAt(frame.index)];
1569
+ if (!frame.payload) continue;
1570
+ const first = texts[nodeAt(start)];
1571
+ const last = texts[nodeAt(frame.end - 1)];
1572
+ const holder = commonElement(first, last);
1573
+ const ref = stegaRef(frame.payload);
1574
+ const stamp = ref ? stampOf(ref, opts.pageId) : null;
1575
+ if (!holder || holder === root || !stamp || !holdsOnly(holder, stegaClean(full.slice(start, frame.end)))) {
1576
+ unresolved += 1;
1577
+ continue;
1578
+ }
1579
+ holder.setAttribute(stamp[0], stamp[1]);
1580
+ holder.setAttribute("data-bcms-kind", "text");
1581
+ holder.setAttribute("data-bcms-match", "stega");
1582
+ stamped += 1;
1583
+ }
1584
+ if (opts.strip) {
1585
+ for (const text of all) if (text.data.includes(START2)) text.data = stegaClean(text.data);
1447
1586
  }
1587
+ return { stamped, leaks, unresolved };
1588
+ }
1589
+ function commonElement(a, b) {
1590
+ const above = /* @__PURE__ */ new Set();
1591
+ for (let n = a.parentNode; n; n = n.parentNode) above.add(n);
1592
+ for (let n = b.parentNode; n; n = n.parentNode) if (above.has(n) && n.nodeType === 1) return n;
1448
1593
  return null;
1449
1594
  }
1595
+ function holdsOnly(el, value) {
1596
+ if (stegaClean(el.textContent ?? "").trim() !== value.trim()) return false;
1597
+ return el.childElementCount === 0 || Array.from(el.querySelectorAll("*")).every((child) => INLINE_BREAKS.has(child.tagName) || stegaClean(child.textContent ?? "").trim() !== "");
1598
+ }
1450
1599
 
1451
1600
  // src/content-applied.ts
1452
1601
  var CONTENT_APPLIED = "bcms:content-applied";
@@ -1605,7 +1754,10 @@ function entrySeoInput(entry) {
1605
1754
  noindex: noindex === true
1606
1755
  };
1607
1756
  }
1608
- function resolveSeo(page, defaults = {}, location = {}) {
1757
+ function resolveSeo(framedPage, framedDefaults = {}, location = {}) {
1758
+ const { title: pageTitle, metaTitle, metaDescription, metaJson, slug, noindex } = framedPage;
1759
+ const page = stegaClean({ title: pageTitle, metaTitle, metaDescription, metaJson, slug, noindex });
1760
+ const defaults = stegaClean(framedDefaults);
1609
1761
  const meta = page.metaJson ?? {};
1610
1762
  const title = page.metaTitle || page.title || "";
1611
1763
  const description = page.metaDescription || defaults.metaDescription || "";
@@ -1638,6 +1790,16 @@ function resolveSeo(page, defaults = {}, location = {}) {
1638
1790
  };
1639
1791
  }
1640
1792
 
1793
+ // src/webhook.ts
1794
+ async function verifyWebhookSignature(rawBody, header, secret) {
1795
+ const hex = /^sha256=([0-9a-f]{64})$/.exec(header ?? "")?.[1];
1796
+ if (!hex || !secret) return false;
1797
+ const utf8 = new TextEncoder();
1798
+ const key = await crypto.subtle.importKey("raw", utf8.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["verify"]);
1799
+ const signature = Uint8Array.from(hex.match(/../g), (byte) => parseInt(byte, 16));
1800
+ return crypto.subtle.verify("HMAC", key, signature, utf8.encode(rawBody));
1801
+ }
1802
+
1641
1803
  // src/search.ts
1642
1804
  var DEFAULT_BASE_URL4 = "https://api.bettercms.ai";
1643
1805
  async function search(opts) {
@@ -2116,6 +2278,7 @@ export {
2116
2278
  listPages,
2117
2279
  listSubmissions,
2118
2280
  listWorkspaces,
2281
+ markEditable,
2119
2282
  onContentApplied,
2120
2283
  plain,
2121
2284
  portableText,
@@ -2140,6 +2303,7 @@ export {
2140
2303
  signInWithGoogle,
2141
2304
  signUp,
2142
2305
  stegaClean,
2306
+ stegaSplit,
2143
2307
  stripStega,
2144
2308
  submitForm,
2145
2309
  toggleOption,
@@ -2152,6 +2316,7 @@ export {
2152
2316
  updatePageModel,
2153
2317
  updateWorkspace,
2154
2318
  uploadFormFile,
2155
- uploadMedia
2319
+ uploadMedia,
2320
+ verifyWebhookSignature
2156
2321
  };
2157
2322
  //# sourceMappingURL=index.js.map