@objectstack/client 4.1.0 → 4.2.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.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -2623,11 +2623,14 @@ var ObjectStackClient = class {
|
|
|
2623
2623
|
});
|
|
2624
2624
|
return this.unwrapResponse(res);
|
|
2625
2625
|
},
|
|
2626
|
-
update: async (object, id, data) => {
|
|
2626
|
+
update: async (object, id, data, opts) => {
|
|
2627
2627
|
const route = this.getRoute("data");
|
|
2628
|
+
const headers = {};
|
|
2629
|
+
if (opts?.ifMatch) headers["If-Match"] = String(opts.ifMatch);
|
|
2628
2630
|
const res = await this.fetch(`${this.baseUrl}${route}/${object}/${id}`, {
|
|
2629
2631
|
method: "PATCH",
|
|
2630
|
-
body: JSON.stringify(data)
|
|
2632
|
+
body: JSON.stringify(data),
|
|
2633
|
+
...Object.keys(headers).length ? { headers } : {}
|
|
2631
2634
|
});
|
|
2632
2635
|
return this.unwrapResponse(res);
|
|
2633
2636
|
},
|
|
@@ -2659,10 +2662,13 @@ var ObjectStackClient = class {
|
|
|
2659
2662
|
});
|
|
2660
2663
|
return this.unwrapResponse(res);
|
|
2661
2664
|
},
|
|
2662
|
-
delete: async (object, id) => {
|
|
2665
|
+
delete: async (object, id, opts) => {
|
|
2663
2666
|
const route = this.getRoute("data");
|
|
2667
|
+
const headers = {};
|
|
2668
|
+
if (opts?.ifMatch) headers["If-Match"] = String(opts.ifMatch);
|
|
2664
2669
|
const res = await this.fetch(`${this.baseUrl}${route}/${object}/${id}`, {
|
|
2665
|
-
method: "DELETE"
|
|
2670
|
+
method: "DELETE",
|
|
2671
|
+
...Object.keys(headers).length ? { headers } : {}
|
|
2666
2672
|
});
|
|
2667
2673
|
return this.unwrapResponse(res);
|
|
2668
2674
|
},
|
|
@@ -2882,7 +2888,7 @@ var ObjectStackClient = class {
|
|
|
2882
2888
|
status: res.status,
|
|
2883
2889
|
error: errorBody
|
|
2884
2890
|
});
|
|
2885
|
-
const errorMessage = errorBody?.message
|
|
2891
|
+
const errorMessage = errorBody?.message ?? errorBody?.error?.message ?? (typeof errorBody?.error === "string" ? errorBody.error : void 0) ?? res.statusText;
|
|
2886
2892
|
const errorCode = errorBody?.code || errorBody?.error?.code;
|
|
2887
2893
|
const error = new Error(`[ObjectStack] ${errorCode ? `${errorCode}: ` : ""}${errorMessage}`);
|
|
2888
2894
|
error.code = errorCode;
|