@bettercms-ai/sdk 1.37.0 → 1.39.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,8 +1,8 @@
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, RichTextResolved, RichTextEmbeds, 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, getBlockType, isBlock } from '@bettercms-ai/types';
4
- import { D as DeliveryFormField } from './read-client-tNsCHy0p.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, h as asStringArray, i as createClient, j as formInitialValues, k as isMultiValueField, s as shouldShowField, l as submitForm, t as toggleOption } from './read-client-tNsCHy0p.cjs';
4
+ import { D as DeliveryFormField } from './read-client-CnkVzNP0.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, h as asStringArray, i as createClient, j as formInitialValues, k as isMultiValueField, s as shouldShowField, l as submitForm, t as toggleOption } from './read-client-CnkVzNP0.cjs';
6
6
  export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.cjs';
7
7
  export { SearchHit, SearchOptions, search } from './read.cjs';
8
8
  export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
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, RichTextResolved, RichTextEmbeds, 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, getBlockType, isBlock } from '@bettercms-ai/types';
4
- import { D as DeliveryFormField } from './read-client-tNsCHy0p.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, h as asStringArray, i as createClient, j as formInitialValues, k as isMultiValueField, s as shouldShowField, l as submitForm, t as toggleOption } from './read-client-tNsCHy0p.js';
4
+ import { D as DeliveryFormField } from './read-client-CnkVzNP0.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, h as asStringArray, i as createClient, j as formInitialValues, k as isMultiValueField, s as shouldShowField, l as submitForm, t as toggleOption } from './read-client-CnkVzNP0.js';
6
6
  export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.js';
7
7
  export { SearchHit, SearchOptions, search } from './read.js';
8
8
  export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
package/dist/index.js CHANGED
@@ -1163,6 +1163,10 @@ var BetterCMS = {
1163
1163
  }
1164
1164
  };
1165
1165
 
1166
+ // src/draft.ts
1167
+ var enc = new TextEncoder();
1168
+ var BRANCH_SIGNATURE_HEADER = "X-BCMS-Branch-Signature";
1169
+
1166
1170
  // src/read-client.ts
1167
1171
  var DEFAULT_TIMEOUT3 = 1e4;
1168
1172
  function qs(params2) {
@@ -1216,11 +1220,13 @@ function createClient(options) {
1216
1220
  const apiUrl = options.apiUrl.replace(/\/+$/, "");
1217
1221
  const { workspace, apiKey, perspective = "published", previewToken } = options;
1218
1222
  const defaultProjectId = options.projectId;
1223
+ const branch = options.branch && options.branch !== "main" ? options.branch : void 0;
1219
1224
  const timeout = options.timeout ?? DEFAULT_TIMEOUT3;
1220
1225
  const base = `${apiUrl}/api/v1/delivery/${workspace}`;
1221
1226
  const headers = () => {
1222
1227
  const h = { "Content-Type": "application/json" };
1223
1228
  if (apiKey) h["X-API-Key"] = apiKey;
1229
+ if (branch && options.branchSignature) h[BRANCH_SIGNATURE_HEADER] = options.branchSignature;
1224
1230
  return h;
1225
1231
  };
1226
1232
  const collapse = options.cache && perspective === "published" ? createRequestCache() : void 0;
@@ -1275,7 +1281,8 @@ function createClient(options) {
1275
1281
  select: opts?.select?.join(","),
1276
1282
  perspective: draft ? "draft" : void 0,
1277
1283
  stega: draft && stega ? "1" : void 0,
1278
- projectId: defaultProjectId
1284
+ projectId: defaultProjectId,
1285
+ branch
1279
1286
  })}`;
1280
1287
  return unwrap(await fetchJSON(url));
1281
1288
  },
@@ -1288,7 +1295,8 @@ function createClient(options) {
1288
1295
  select: opts?.select?.join(","),
1289
1296
  perspective: draft ? "draft" : void 0,
1290
1297
  stega: draft && stega ? "1" : void 0,
1291
- projectId: defaultProjectId
1298
+ projectId: defaultProjectId,
1299
+ branch
1292
1300
  })}`;
1293
1301
  return unwrap(await fetchJSON(url));
1294
1302
  },
@@ -1325,7 +1333,8 @@ function createClient(options) {
1325
1333
  const url = `${base}/pages${qs({
1326
1334
  page: opts?.page,
1327
1335
  perPage: opts?.perPage,
1328
- projectId: defaultProjectId
1336
+ projectId: defaultProjectId,
1337
+ branch
1329
1338
  })}`;
1330
1339
  return unwrap(await fetchJSON(url));
1331
1340
  },
@@ -1333,12 +1342,13 @@ function createClient(options) {
1333
1342
  const url = `${base}/components${qs({
1334
1343
  perspective: draft ? "draft" : void 0,
1335
1344
  token: draft ? previewToken : void 0,
1336
- projectId: defaultProjectId
1345
+ projectId: defaultProjectId,
1346
+ branch
1337
1347
  })}`;
1338
1348
  return unwrap(await fetchJSON(url));
1339
1349
  },
1340
1350
  async getLayout() {
1341
- const url = `${base}/layout${qs({ perspective: draft ? "draft" : void 0, projectId: defaultProjectId })}`;
1351
+ const url = `${base}/layout${qs({ perspective: draft ? "draft" : void 0, projectId: defaultProjectId, branch })}`;
1342
1352
  try {
1343
1353
  return unwrap(await fetchJSON(url));
1344
1354
  } catch (error) {
@@ -1348,7 +1358,8 @@ function createClient(options) {
1348
1358
  },
1349
1359
  async listForms(opts) {
1350
1360
  const url = `${base}/forms${qs({
1351
- projectId: opts?.projectId ?? defaultProjectId
1361
+ projectId: opts?.projectId ?? defaultProjectId,
1362
+ branch
1352
1363
  })}`;
1353
1364
  return unwrap(
1354
1365
  await fetchJSON(url)