@swan-admin/swan-ai-measurements 1.0.87 → 1.0.89

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.
@@ -146,8 +146,11 @@ class FileUpload {
146
146
  contentType: file.type,
147
147
  objectMetadata: arrayMetaData,
148
148
  },
149
+ throwError: true,
149
150
  });
151
+ console.log(res, "res for start");
150
152
  const totalChunks = getFileChunks(file);
153
+ console.log(totalChunks, "total chunks");
151
154
  for (let i = 0; i < totalChunks.length; i++) {
152
155
  const data = yield fetchData({
153
156
  path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
@@ -157,14 +160,16 @@ class FileUpload {
157
160
  uploadId: res === null || res === void 0 ? void 0 : res.uploadId,
158
161
  partNumber: i + 1,
159
162
  },
163
+ throwError: true,
160
164
  });
165
+ console.log(data, "data for signed url");
161
166
  yield axios.put(data === null || data === void 0 ? void 0 : data.url, totalChunks[i], {
162
167
  headers: { "Content-Type": file.type, "X-Api-Key": __classPrivateFieldGet(this, _FileUpload_accessKey, "f") },
163
168
  });
164
169
  }
165
170
  return { message: "successfully uploaded" };
166
171
  } catch (error) {
167
- throw new Error(`Failed to upload: ${error === null || error === void 0 ? void 0 : error.message}`);
172
+ throw new Error(`Failed to upload: ${(error === null || error === void 0 ? void 0 : error.message) || "something went wrong"}`);
168
173
  }
169
174
  });
170
175
  }
package/dist/esm/utils.js CHANGED
@@ -27,7 +27,7 @@ export function fetchData(options) {
27
27
  catch (error) {
28
28
  console.error(error, "while uploading");
29
29
  if (throwError) {
30
- throw new Error(`Failed to upload: ${error.message}`);
30
+ throw new Error(`Failed to upload: ${(error === null || error === void 0 ? void 0 : error.message) || "something went wrong"}`);
31
31
  }
32
32
  return {};
33
33
  }
@@ -97,8 +97,11 @@ class FileUpload {
97
97
  contentType: file.type,
98
98
  objectMetadata: arrayMetaData,
99
99
  },
100
+ throwError: true,
100
101
  });
102
+ console.log(res, "res for start");
101
103
  const totalChunks = (0, utils_js_1.getFileChunks)(file);
104
+ console.log(totalChunks, "total chunks");
102
105
  for (let i = 0; i < totalChunks.length; i++) {
103
106
  const data = await (0, utils_js_1.fetchData)({
104
107
  path: constants_js_1.FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
@@ -108,13 +111,15 @@ class FileUpload {
108
111
  uploadId: res?.uploadId,
109
112
  partNumber: i + 1,
110
113
  },
114
+ throwError: true,
111
115
  });
116
+ console.log(data, "data for signed url");
112
117
  await axios_1.default.put(data?.url, totalChunks[i], { headers: { "Content-Type": file.type, "X-Api-Key": this.#accessKey } });
113
118
  }
114
119
  return { message: "successfully uploaded" };
115
120
  }
116
121
  catch (error) {
117
- throw new Error(`Failed to upload: ${error?.message}`);
122
+ throw new Error(`Failed to upload: ${error?.message || "something went wrong"}`);
118
123
  }
119
124
  }
120
125
  }
package/dist/utils.js CHANGED
@@ -23,7 +23,7 @@ async function fetchData(options) {
23
23
  catch (error) {
24
24
  console.error(error, "while uploading");
25
25
  if (throwError) {
26
- throw new Error(`Failed to upload: ${error.message}`);
26
+ throw new Error(`Failed to upload: ${error?.message || "something went wrong"}`);
27
27
  }
28
28
  return {};
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.0.87",
3
+ "version": "1.0.89",
4
4
  "description": "provides ai measurement suggestion",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
package/src/fileUpload.ts CHANGED
@@ -120,8 +120,11 @@ export default class FileUpload {
120
120
  contentType: file.type,
121
121
  objectMetadata: arrayMetaData,
122
122
  },
123
+ throwError: true,
123
124
  });
125
+ console.log(res, "res for start");
124
126
  const totalChunks = getFileChunks(file);
127
+ console.log(totalChunks, "total chunks");
125
128
  for (let i = 0; i < totalChunks.length; i++) {
126
129
  const data: { url: string } = await fetchData({
127
130
  path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
@@ -131,12 +134,14 @@ export default class FileUpload {
131
134
  uploadId: res?.uploadId,
132
135
  partNumber: i + 1,
133
136
  },
137
+ throwError: true,
134
138
  });
139
+ console.log(data, "data for signed url");
135
140
  await axios.put(data?.url, totalChunks[i], { headers: { "Content-Type": file.type, "X-Api-Key": this.#accessKey } });
136
141
  }
137
142
  return { message: "successfully uploaded" };
138
143
  } catch (error: any) {
139
- throw new Error(`Failed to upload: ${error?.message}`);
144
+ throw new Error(`Failed to upload: ${error?.message || "something went wrong"}`);
140
145
  }
141
146
  }
142
147
  }
package/src/utils.ts CHANGED
@@ -36,7 +36,7 @@ export async function fetchData(options: FetchDataOptions): Promise<any> {
36
36
  } catch (error: any) {
37
37
  console.error(error, "while uploading");
38
38
  if (throwError) {
39
- throw new Error(`Failed to upload: ${error.message}`);
39
+ throw new Error(`Failed to upload: ${error?.message || "something went wrong"}`);
40
40
  }
41
41
  return {};
42
42
  }