@bettercms-ai/sdk 1.23.0 → 1.25.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.cjs CHANGED
@@ -74,6 +74,8 @@ __export(index_exports, {
74
74
  getWorkspace: () => getWorkspace,
75
75
  imageUrl: () => import_image_url.imageUrl,
76
76
  imageUrlBuilder: () => import_image_url.default,
77
+ imageValueObjectPosition: () => import_image_url.imageValueObjectPosition,
78
+ imageValueUrl: () => import_image_url.imageValueUrl,
77
79
  inviteMember: () => inviteMember,
78
80
  isBlock: () => import_types.isBlock,
79
81
  isMultiValueField: () => isMultiValueField,
@@ -113,6 +115,7 @@ __export(index_exports, {
113
115
  updateMemberRole: () => updateMemberRole,
114
116
  updateModel: () => updateModel,
115
117
  updatePage: () => updatePage,
118
+ updatePageModel: () => updatePageModel,
116
119
  updateWorkspace: () => updateWorkspace,
117
120
  uploadMedia: () => uploadMedia
118
121
  });
@@ -640,10 +643,18 @@ async function createModel(client, input) {
640
643
  );
641
644
  return res.data;
642
645
  }
643
- async function updateModel(client, id, input) {
646
+ var ifMatchHeaders = (opts) => opts?.ifMatch !== void 0 ? { "If-Match": `W/"${opts.ifMatch}"` } : {};
647
+ async function updateModel(client, id, input, opts) {
644
648
  const res = await client.fetchJSON(
645
649
  client.url(`/management/content/models/${id}`),
646
- { method: "PATCH", body: JSON.stringify(input) }
650
+ { method: "PATCH", body: JSON.stringify(input), headers: ifMatchHeaders(opts) }
651
+ );
652
+ return res.data;
653
+ }
654
+ async function updatePageModel(client, pageId, input, opts) {
655
+ const res = await client.fetchJSON(
656
+ client.url(`/management/pages/${pageId}/model`),
657
+ { method: "PATCH", body: JSON.stringify(input), headers: ifMatchHeaders(opts) }
647
658
  );
648
659
  return res.data;
649
660
  }
@@ -656,11 +667,9 @@ async function createEntry(client, input) {
656
667
  return withWarnings(res);
657
668
  }
658
669
  async function updateEntry(client, id, input, opts) {
659
- const headers = {};
660
- if (opts?.ifMatch !== void 0) headers["If-Match"] = `W/"${opts.ifMatch}"`;
661
670
  const res = await client.fetchJSON(
662
671
  client.url(`/management/content/entries/${id}`),
663
- { method: "PATCH", body: JSON.stringify(input), headers }
672
+ { method: "PATCH", body: JSON.stringify(input), headers: ifMatchHeaders(opts) }
664
673
  );
665
674
  return withWarnings(res);
666
675
  }
@@ -896,10 +905,10 @@ async function extractComponent(client, input) {
896
905
  );
897
906
  return { component: res.data, replaced: res.replaced };
898
907
  }
899
- async function updateComponent(client, id, input) {
908
+ async function updateComponent(client, id, input, opts) {
900
909
  const res = await client.fetchJSON(
901
910
  client.url(`/management/components/${id}`),
902
- { method: "PATCH", body: JSON.stringify(input) }
911
+ { method: "PATCH", body: JSON.stringify(input), headers: ifMatchHeaders(opts) }
903
912
  );
904
913
  return res.data;
905
914
  }
@@ -1027,8 +1036,12 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
1027
1036
  createModel(input) {
1028
1037
  return createModel(this, input);
1029
1038
  }
1030
- updateModel(id, input) {
1031
- return updateModel(this, id, input);
1039
+ updateModel(id, input, opts) {
1040
+ return updateModel(this, id, input, opts);
1041
+ }
1042
+ /** updateModel by page id; `ifMatch` = the page's `backingModel.optimisticVersion`. */
1043
+ updatePageModel(pageId, input, opts) {
1044
+ return updatePageModel(this, pageId, input, opts);
1032
1045
  }
1033
1046
  // ── Page authoring (page-first: singleton + dynamic) ──────────────────────
1034
1047
  listPages() {
@@ -1116,8 +1129,8 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
1116
1129
  createComponent(input) {
1117
1130
  return createComponent(this, input);
1118
1131
  }
1119
- updateComponent(id, input) {
1120
- return updateComponent(this, id, input);
1132
+ updateComponent(id, input, opts) {
1133
+ return updateComponent(this, id, input, opts);
1121
1134
  }
1122
1135
  /** Sections repeating across the project's pages, proposed as components. */
1123
1136
  listExtractionCandidates(projectId) {
@@ -2009,6 +2022,8 @@ var import_types = require("@bettercms-ai/types");
2009
2022
  getWorkspace,
2010
2023
  imageUrl,
2011
2024
  imageUrlBuilder,
2025
+ imageValueObjectPosition,
2026
+ imageValueUrl,
2012
2027
  inviteMember,
2013
2028
  isBlock,
2014
2029
  isMultiValueField,
@@ -2048,6 +2063,7 @@ var import_types = require("@bettercms-ai/types");
2048
2063
  updateMemberRole,
2049
2064
  updateModel,
2050
2065
  updatePage,
2066
+ updatePageModel,
2051
2067
  updateWorkspace,
2052
2068
  uploadMedia
2053
2069
  });