@bettercms-ai/sdk 1.23.0 → 1.24.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 +23 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -13
- package/dist/index.d.ts +61 -13
- package/dist/index.js +22 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -113,6 +113,7 @@ __export(index_exports, {
|
|
|
113
113
|
updateMemberRole: () => updateMemberRole,
|
|
114
114
|
updateModel: () => updateModel,
|
|
115
115
|
updatePage: () => updatePage,
|
|
116
|
+
updatePageModel: () => updatePageModel,
|
|
116
117
|
updateWorkspace: () => updateWorkspace,
|
|
117
118
|
uploadMedia: () => uploadMedia
|
|
118
119
|
});
|
|
@@ -640,10 +641,18 @@ async function createModel(client, input) {
|
|
|
640
641
|
);
|
|
641
642
|
return res.data;
|
|
642
643
|
}
|
|
643
|
-
|
|
644
|
+
var ifMatchHeaders = (opts) => opts?.ifMatch !== void 0 ? { "If-Match": `W/"${opts.ifMatch}"` } : {};
|
|
645
|
+
async function updateModel(client, id, input, opts) {
|
|
644
646
|
const res = await client.fetchJSON(
|
|
645
647
|
client.url(`/management/content/models/${id}`),
|
|
646
|
-
{ method: "PATCH", body: JSON.stringify(input) }
|
|
648
|
+
{ method: "PATCH", body: JSON.stringify(input), headers: ifMatchHeaders(opts) }
|
|
649
|
+
);
|
|
650
|
+
return res.data;
|
|
651
|
+
}
|
|
652
|
+
async function updatePageModel(client, pageId, input, opts) {
|
|
653
|
+
const res = await client.fetchJSON(
|
|
654
|
+
client.url(`/management/pages/${pageId}/model`),
|
|
655
|
+
{ method: "PATCH", body: JSON.stringify(input), headers: ifMatchHeaders(opts) }
|
|
647
656
|
);
|
|
648
657
|
return res.data;
|
|
649
658
|
}
|
|
@@ -656,11 +665,9 @@ async function createEntry(client, input) {
|
|
|
656
665
|
return withWarnings(res);
|
|
657
666
|
}
|
|
658
667
|
async function updateEntry(client, id, input, opts) {
|
|
659
|
-
const headers = {};
|
|
660
|
-
if (opts?.ifMatch !== void 0) headers["If-Match"] = `W/"${opts.ifMatch}"`;
|
|
661
668
|
const res = await client.fetchJSON(
|
|
662
669
|
client.url(`/management/content/entries/${id}`),
|
|
663
|
-
{ method: "PATCH", body: JSON.stringify(input), headers }
|
|
670
|
+
{ method: "PATCH", body: JSON.stringify(input), headers: ifMatchHeaders(opts) }
|
|
664
671
|
);
|
|
665
672
|
return withWarnings(res);
|
|
666
673
|
}
|
|
@@ -896,10 +903,10 @@ async function extractComponent(client, input) {
|
|
|
896
903
|
);
|
|
897
904
|
return { component: res.data, replaced: res.replaced };
|
|
898
905
|
}
|
|
899
|
-
async function updateComponent(client, id, input) {
|
|
906
|
+
async function updateComponent(client, id, input, opts) {
|
|
900
907
|
const res = await client.fetchJSON(
|
|
901
908
|
client.url(`/management/components/${id}`),
|
|
902
|
-
{ method: "PATCH", body: JSON.stringify(input) }
|
|
909
|
+
{ method: "PATCH", body: JSON.stringify(input), headers: ifMatchHeaders(opts) }
|
|
903
910
|
);
|
|
904
911
|
return res.data;
|
|
905
912
|
}
|
|
@@ -1027,8 +1034,12 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
|
|
|
1027
1034
|
createModel(input) {
|
|
1028
1035
|
return createModel(this, input);
|
|
1029
1036
|
}
|
|
1030
|
-
updateModel(id, input) {
|
|
1031
|
-
return updateModel(this, id, input);
|
|
1037
|
+
updateModel(id, input, opts) {
|
|
1038
|
+
return updateModel(this, id, input, opts);
|
|
1039
|
+
}
|
|
1040
|
+
/** updateModel by page id; `ifMatch` = the page's `backingModel.optimisticVersion`. */
|
|
1041
|
+
updatePageModel(pageId, input, opts) {
|
|
1042
|
+
return updatePageModel(this, pageId, input, opts);
|
|
1032
1043
|
}
|
|
1033
1044
|
// ── Page authoring (page-first: singleton + dynamic) ──────────────────────
|
|
1034
1045
|
listPages() {
|
|
@@ -1116,8 +1127,8 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
|
|
|
1116
1127
|
createComponent(input) {
|
|
1117
1128
|
return createComponent(this, input);
|
|
1118
1129
|
}
|
|
1119
|
-
updateComponent(id, input) {
|
|
1120
|
-
return updateComponent(this, id, input);
|
|
1130
|
+
updateComponent(id, input, opts) {
|
|
1131
|
+
return updateComponent(this, id, input, opts);
|
|
1121
1132
|
}
|
|
1122
1133
|
/** Sections repeating across the project's pages, proposed as components. */
|
|
1123
1134
|
listExtractionCandidates(projectId) {
|
|
@@ -2048,6 +2059,7 @@ var import_types = require("@bettercms-ai/types");
|
|
|
2048
2059
|
updateMemberRole,
|
|
2049
2060
|
updateModel,
|
|
2050
2061
|
updatePage,
|
|
2062
|
+
updatePageModel,
|
|
2051
2063
|
updateWorkspace,
|
|
2052
2064
|
uploadMedia
|
|
2053
2065
|
});
|