@rebasepro/client 0.2.3 → 0.2.5

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.umd.js CHANGED
@@ -141,6 +141,13 @@
141
141
  } catch (e) {
142
142
  }
143
143
  }
144
+ const getErrorField = (obj, field) => {
145
+ const err = obj?.error;
146
+ if (err && typeof err === "object" && err !== null && field in err) {
147
+ return err[field];
148
+ }
149
+ return obj?.[field];
150
+ };
144
151
  if (res.status === 401 && onUnauthorizedHandler) {
145
152
  const retried = await onUnauthorizedHandler();
146
153
  if (retried) {
@@ -176,9 +183,9 @@
176
183
  }
177
184
  throw new RebaseApiError(
178
185
  retryRes.status,
179
- retryBody?.error?.message || retryBody?.message || fallbackMessage || `Request failed with status ${retryRes.status}`,
180
- retryBody?.error?.code || retryBody?.code,
181
- retryBody?.error?.details || retryBody?.details
186
+ String(getErrorField(retryBody, "message") || fallbackMessage || `Request failed with status ${retryRes.status}`),
187
+ getErrorField(retryBody, "code"),
188
+ getErrorField(retryBody, "details")
182
189
  );
183
190
  }
184
191
  return retryBody;
@@ -192,9 +199,9 @@
192
199
  }
193
200
  throw new RebaseApiError(
194
201
  res.status,
195
- body?.error?.message || body?.message || fallbackMessage || `Request failed with status ${res.status}`,
196
- body?.error?.code || body?.code,
197
- body?.error?.details || body?.details
202
+ String(getErrorField(body, "message") || fallbackMessage || `Request failed with status ${res.status}`),
203
+ getErrorField(body, "code"),
204
+ getErrorField(body, "details")
198
205
  );
199
206
  }
200
207
  return body;
@@ -735,29 +742,6 @@
735
742
  method: "DELETE"
736
743
  });
737
744
  }
738
- async function listRoles() {
739
- return transport.request(adminPath + "/roles", { method: "GET" });
740
- }
741
- async function getRole(roleId) {
742
- return transport.request(adminPath + "/roles/" + encodeURIComponent(roleId), { method: "GET" });
743
- }
744
- async function createRole(data) {
745
- return transport.request(adminPath + "/roles", {
746
- method: "POST",
747
- body: JSON.stringify(data)
748
- });
749
- }
750
- async function updateRole(roleId, data) {
751
- return transport.request(adminPath + "/roles/" + encodeURIComponent(roleId), {
752
- method: "PUT",
753
- body: JSON.stringify(data)
754
- });
755
- }
756
- async function deleteRole(roleId) {
757
- return transport.request(adminPath + "/roles/" + encodeURIComponent(roleId), {
758
- method: "DELETE"
759
- });
760
- }
761
745
  async function bootstrap() {
762
746
  return transport.request(adminPath + "/bootstrap", {
763
747
  method: "POST"
@@ -770,11 +754,6 @@
770
754
  createUser,
771
755
  updateUser,
772
756
  deleteUser,
773
- listRoles,
774
- getRole,
775
- createRole,
776
- updateRole,
777
- deleteRole,
778
757
  bootstrap
779
758
  };
780
759
  }