@bettercms-ai/sdk 1.13.0 → 1.13.2

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
@@ -680,6 +680,7 @@ interface SeoMeta {
680
680
 
681
681
  type ManagedLayoutDocument = {
682
682
  scope: "global";
683
+ copy?: "draft" | "published";
683
684
  revision: number;
684
685
  etag: string;
685
686
  status: string;
@@ -687,6 +688,7 @@ type ManagedLayoutDocument = {
687
688
  data: LayoutDataDocument;
688
689
  } | {
689
690
  scope: "page";
691
+ copy?: "draft" | "published";
690
692
  pageId: string;
691
693
  pageSlug: string;
692
694
  revision: number;
@@ -703,6 +705,9 @@ interface ManagedLayoutClient {
703
705
  interface GetManagedLayoutOptions {
704
706
  scope?: "global" | "page";
705
707
  pageId?: string;
708
+ /** Which copy to read — default draft. A publish claim verifies ONLY against the
709
+ * published copy; check the response's `copy` echo (FLO-1188). */
710
+ copy?: "draft" | "published";
706
711
  /** Required when the management credential is workspace-scoped. */
707
712
  projectId?: string;
708
713
  }
@@ -1043,6 +1048,24 @@ interface RichTextValue {
1043
1048
  */
1044
1049
  readonly doc?: DocValue;
1045
1050
  }
1051
+ /** The marker on a Portable Text envelope. `format` is a plain string, never a union — see below. */
1052
+ declare const PORTABLE_TEXT_FORMAT = "portable-text-1";
1053
+ /**
1054
+ * Structured blocks, when the field stores Portable Text.
1055
+ *
1056
+ * ── The compatibility guarantee, stated once ────────────────────────────────────────────
1057
+ * Portable Text did NOT change this envelope. `format`, `value` and `html` are the same three
1058
+ * keys they always were, so `isRichText`, `plain()` and `rich()` keep working untouched — and
1059
+ * they have to, because sites compiled months ago read `.html` directly and cannot be
1060
+ * rebuilt. `bettercms-starter-modern/lib/cms.ts` even carries its OWN copy of `rich()`, baked
1061
+ * into deployments nobody can reach. Storing a bare array instead would have made
1062
+ * `isRichText` return false (it rejects arrays), every shipped `rich()` call return "", and
1063
+ * every one of those pages go blank at 200 OK.
1064
+ *
1065
+ * `portableText()` is therefore ADDITIVE: `html` remains the always-present field, and this is
1066
+ * the opt-in for consumers that want to render structure with `@portabletext/react` instead.
1067
+ */
1068
+ declare function portableText(value: TextOrRich): readonly unknown[] | null;
1046
1069
  /**
1047
1070
  * A field that may arrive as either shape. Type author-editable text fields with this and the
1048
1071
  * compiler routes you through `plain()`/`rich()`, so a type switch in the CMS can never reach
@@ -1357,4 +1380,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
1357
1380
  declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
1358
1381
  declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
1359
1382
 
1360
- 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 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 ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type PageListOptions, type PendingInvite, 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 UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, 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, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
1383
+ 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 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 ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, PORTABLE_TEXT_FORMAT, type PageListOptions, type PendingInvite, 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 UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, 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, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
package/dist/index.d.ts CHANGED
@@ -680,6 +680,7 @@ interface SeoMeta {
680
680
 
681
681
  type ManagedLayoutDocument = {
682
682
  scope: "global";
683
+ copy?: "draft" | "published";
683
684
  revision: number;
684
685
  etag: string;
685
686
  status: string;
@@ -687,6 +688,7 @@ type ManagedLayoutDocument = {
687
688
  data: LayoutDataDocument;
688
689
  } | {
689
690
  scope: "page";
691
+ copy?: "draft" | "published";
690
692
  pageId: string;
691
693
  pageSlug: string;
692
694
  revision: number;
@@ -703,6 +705,9 @@ interface ManagedLayoutClient {
703
705
  interface GetManagedLayoutOptions {
704
706
  scope?: "global" | "page";
705
707
  pageId?: string;
708
+ /** Which copy to read — default draft. A publish claim verifies ONLY against the
709
+ * published copy; check the response's `copy` echo (FLO-1188). */
710
+ copy?: "draft" | "published";
706
711
  /** Required when the management credential is workspace-scoped. */
707
712
  projectId?: string;
708
713
  }
@@ -1043,6 +1048,24 @@ interface RichTextValue {
1043
1048
  */
1044
1049
  readonly doc?: DocValue;
1045
1050
  }
1051
+ /** The marker on a Portable Text envelope. `format` is a plain string, never a union — see below. */
1052
+ declare const PORTABLE_TEXT_FORMAT = "portable-text-1";
1053
+ /**
1054
+ * Structured blocks, when the field stores Portable Text.
1055
+ *
1056
+ * ── The compatibility guarantee, stated once ────────────────────────────────────────────
1057
+ * Portable Text did NOT change this envelope. `format`, `value` and `html` are the same three
1058
+ * keys they always were, so `isRichText`, `plain()` and `rich()` keep working untouched — and
1059
+ * they have to, because sites compiled months ago read `.html` directly and cannot be
1060
+ * rebuilt. `bettercms-starter-modern/lib/cms.ts` even carries its OWN copy of `rich()`, baked
1061
+ * into deployments nobody can reach. Storing a bare array instead would have made
1062
+ * `isRichText` return false (it rejects arrays), every shipped `rich()` call return "", and
1063
+ * every one of those pages go blank at 200 OK.
1064
+ *
1065
+ * `portableText()` is therefore ADDITIVE: `html` remains the always-present field, and this is
1066
+ * the opt-in for consumers that want to render structure with `@portabletext/react` instead.
1067
+ */
1068
+ declare function portableText(value: TextOrRich): readonly unknown[] | null;
1046
1069
  /**
1047
1070
  * A field that may arrive as either shape. Type author-editable text fields with this and the
1048
1071
  * compiler routes you through `plain()`/`rich()`, so a type switch in the CMS can never reach
@@ -1357,4 +1380,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
1357
1380
  declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
1358
1381
  declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
1359
1382
 
1360
- 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 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 ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type PageListOptions, type PendingInvite, 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 UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, 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, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
1383
+ 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 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 ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, PORTABLE_TEXT_FORMAT, type PageListOptions, type PendingInvite, 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 UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, 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, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updateWorkspace, uploadMedia };
package/dist/index.js CHANGED
@@ -508,7 +508,14 @@ var MIME_BY_EXT = {
508
508
  avif: "image/avif",
509
509
  mp4: "video/mp4",
510
510
  webm: "video/webm",
511
- pdf: "application/pdf"
511
+ pdf: "application/pdf",
512
+ // mp3/ogg were server-allowed all along; the SDK sent application/octet-stream for them,
513
+ // which the allowlist then refused — so an agent could never upload audio.
514
+ mp3: "audio/mpeg",
515
+ ogg: "audio/ogg",
516
+ txt: "text/plain",
517
+ md: "text/markdown",
518
+ markdown: "text/markdown"
512
519
  };
513
520
  function basenameOf(p) {
514
521
  const clean = p.split(/[?#]/)[0] ?? p;
@@ -717,6 +724,7 @@ async function getManagedLayout(client, opts) {
717
724
  const query = new URLSearchParams();
718
725
  if (opts?.scope) query.set("scope", opts.scope);
719
726
  if (opts?.pageId) query.set("pageId", opts.pageId);
727
+ if (opts?.copy) query.set("preview", opts.copy);
720
728
  const result = await client.fetchJSON(
721
729
  client.url(`/management/layout${query.size ? `?${query}` : ""}`),
722
730
  opts?.projectId ? { headers: { "X-BCMS-Project": opts.projectId } } : void 0
@@ -1223,6 +1231,12 @@ function stripStega(value) {
1223
1231
  }
1224
1232
 
1225
1233
  // src/richtext.ts
1234
+ var PORTABLE_TEXT_FORMAT = "portable-text-1";
1235
+ function portableText(value) {
1236
+ if (!isRichText(value)) return null;
1237
+ const v = value;
1238
+ return v.format === PORTABLE_TEXT_FORMAT && Array.isArray(v.value) ? v.value : null;
1239
+ }
1226
1240
  function isRichText(value) {
1227
1241
  return typeof value === "object" && value !== null && !Array.isArray(value) && ("html" in value || "format" in value);
1228
1242
  }
@@ -1610,6 +1624,7 @@ export {
1610
1624
  BetterCMSError,
1611
1625
  BetterCMSManagementClient,
1612
1626
  ErrorCodes,
1627
+ PORTABLE_TEXT_FORMAT,
1613
1628
  addModelFields,
1614
1629
  addPageFields,
1615
1630
  asStringArray,
@@ -1659,6 +1674,7 @@ export {
1659
1674
  listSubmissions,
1660
1675
  listWorkspaces,
1661
1676
  plain,
1677
+ portableText,
1662
1678
  publishPage,
1663
1679
  regenerateApiKey,
1664
1680
  removeMember,