@bettercms-ai/sdk 1.45.0 → 1.46.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-DQhWuKf4.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-DQhWuKf4.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-BZq0vVvs.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
  /**
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-DQhWuKf4.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-DQhWuKf4.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-B2lJr72F.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
  /**
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}` : "";
@@ -1298,6 +1312,7 @@ function createClient(options) {
1298
1312
  perPage: opts?.perPage,
1299
1313
  depth: opts?.depth,
1300
1314
  select: opts?.select?.join(","),
1315
+ ...listQueryParams(opts?.filter, opts?.sort),
1301
1316
  perspective: draft ? "draft" : void 0,
1302
1317
  stega: draft && stega ? "1" : void 0,
1303
1318
  projectId: defaultProjectId,
@@ -1638,6 +1653,16 @@ function resolveSeo(page, defaults = {}, location = {}) {
1638
1653
  };
1639
1654
  }
1640
1655
 
1656
+ // src/webhook.ts
1657
+ async function verifyWebhookSignature(rawBody, header, secret) {
1658
+ const hex = /^sha256=([0-9a-f]{64})$/.exec(header ?? "")?.[1];
1659
+ if (!hex || !secret) return false;
1660
+ const utf8 = new TextEncoder();
1661
+ const key = await crypto.subtle.importKey("raw", utf8.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["verify"]);
1662
+ const signature = Uint8Array.from(hex.match(/../g), (byte) => parseInt(byte, 16));
1663
+ return crypto.subtle.verify("HMAC", key, signature, utf8.encode(rawBody));
1664
+ }
1665
+
1641
1666
  // src/search.ts
1642
1667
  var DEFAULT_BASE_URL4 = "https://api.bettercms.ai";
1643
1668
  async function search(opts) {
@@ -2152,6 +2177,7 @@ export {
2152
2177
  updatePageModel,
2153
2178
  updateWorkspace,
2154
2179
  uploadFormFile,
2155
- uploadMedia
2180
+ uploadMedia,
2181
+ verifyWebhookSignature
2156
2182
  };
2157
2183
  //# sourceMappingURL=index.js.map