@superblocksteam/sdk 0.0.20 → 0.0.21

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/client.js CHANGED
@@ -93,7 +93,7 @@ async function fetchApis(token, superblocksBaseUrl) {
93
93
  }
94
94
  exports.fetchApis = fetchApis;
95
95
  async function registerComponents(applicationId, componentConfigs, token, superblocksBaseUrl) {
96
- var _a, _b, _c;
96
+ var _a, _b, _c, _d, _e, _f, _g;
97
97
  try {
98
98
  const [rootSettings] = await (0, util_2.getSuperblocksMonorepoConfigJson)(true);
99
99
  const config = {
@@ -110,17 +110,15 @@ async function registerComponents(applicationId, componentConfigs, token, superb
110
110
  }
111
111
  catch (e) {
112
112
  if (e instanceof axios_1.AxiosError) {
113
- const message = (_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.responseMeta) === null || _c === void 0 ? void 0 : _c.message;
114
- throw new Error(`Could not register application components
115
- ${message !== null && message !== void 0 ? message : ""}`);
113
+ const message = (_f = (_d = (_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.responseMeta) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : JSON.stringify((_e = e.response) === null || _e === void 0 ? void 0 : _e.data)) !== null && _f !== void 0 ? _f : (_g = e.response) === null || _g === void 0 ? void 0 : _g.statusText;
114
+ throw new Error(`Could not register application components ${message ? "\n" + message : ""}`);
116
115
  }
117
- throw new Error(`Could not register application components
118
- ${e.message}`);
116
+ throw new Error(`Could not register application components ${e.message ? "\n" + e.message : ""}`);
119
117
  }
120
118
  }
121
119
  exports.registerComponents = registerComponents;
122
120
  async function uploadComponents({ applicationId, componentConfigs, files, token, superblocksBaseUrl, }) {
123
- var _a, _b, _c;
121
+ var _a, _b, _c, _d, _e, _f;
124
122
  superblocksBaseUrl = superblocksBaseUrl.replace(/\/$/, "");
125
123
  const bucketeerBaseUrl = (0, util_1.getBucketeerUrlFromSuperblocksUrl)(superblocksBaseUrl);
126
124
  // parse files to source and bundled files based on path
@@ -165,9 +163,9 @@ async function uploadComponents({ applicationId, componentConfigs, files, token,
165
163
  }
166
164
  catch (e) {
167
165
  if (e instanceof axios_1.AxiosError) {
168
- const message = (_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.responseMeta) === null || _c === void 0 ? void 0 : _c.message;
166
+ const message = (_d = (_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.responseMeta) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : (_e = e.response) === null || _e === void 0 ? void 0 : _e.data;
169
167
  throw new Error(`Could not upload application components
170
- ${message}`);
168
+ ${message !== null && message !== void 0 ? message : (_f = e.response) === null || _f === void 0 ? void 0 : _f.statusText}`);
171
169
  }
172
170
  throw new Error(`Could not upload application components
173
171
  ${e.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superblocksteam/sdk",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "Superblocks JS SDK",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {
package/src/client.ts CHANGED
@@ -148,12 +148,21 @@ export async function registerComponents(
148
148
  return response.data;
149
149
  } catch (e: any) {
150
150
  if (e instanceof AxiosError) {
151
- const message = e.response?.data?.responseMeta?.message as string;
152
- throw new Error(`Could not register application components
153
- ${message ?? ""}`);
151
+ const message: string =
152
+ (e.response?.data?.responseMeta?.message as string) ??
153
+ JSON.stringify(e.response?.data) ??
154
+ e.response?.statusText;
155
+ throw new Error(
156
+ `Could not register application components ${
157
+ message ? "\n" + message : ""
158
+ }`
159
+ );
154
160
  }
155
- throw new Error(`Could not register application components
156
- ${e.message as string}`);
161
+ throw new Error(
162
+ `Could not register application components ${
163
+ e.message ? "\n" + (e as Error).message : ""
164
+ }`
165
+ );
157
166
  }
158
167
  }
159
168
 
@@ -227,9 +236,10 @@ export async function uploadComponents({
227
236
  return response.data;
228
237
  } catch (e: any) {
229
238
  if (e instanceof AxiosError) {
230
- const message = e.response?.data?.responseMeta?.message as string;
239
+ const message =
240
+ (e.response?.data?.responseMeta?.message as string) ?? e.response?.data;
231
241
  throw new Error(`Could not upload application components
232
- ${message}`);
242
+ ${message ?? e.response?.statusText}`);
233
243
  }
234
244
  throw new Error(`Could not upload application components
235
245
  ${e.message as string}`);