@swan-admin/swan-ai-measurements 1.0.82 → 1.0.83

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.
@@ -86,17 +86,17 @@ class FileUpload {
86
86
  },
87
87
  });
88
88
  },
89
- completeMultipartUpload: (file, { uploadId, key, parts }) =>
90
- fetchData({
91
- path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
92
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
93
- body: {
94
- uploadId,
95
- objectKey: key,
96
- parts,
97
- originalFileName: file.name,
98
- },
99
- }),
89
+ // completeMultipartUpload: (file: any, { uploadId, key, parts }: { uploadId: string | number; key: string | number; parts: any }) =>
90
+ // fetchData({
91
+ // path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
92
+ // apiKey: this.#accessKey,
93
+ // body: {
94
+ // uploadId,
95
+ // objectKey: key,
96
+ // parts,
97
+ // originalFileName: file.name,
98
+ // },
99
+ // }),
100
100
  signPart: (file, partData) =>
101
101
  fetchData({
102
102
  path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
package/dist/esm/utils.js CHANGED
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import axios from "axios";
10
11
  import { APP_AUTH_BASE_URL, requiredMetaData } from "./constants.js";
11
12
  export function fetchData(options) {
12
13
  return __awaiter(this, void 0, void 0, function* () {
@@ -14,16 +15,12 @@ export function fetchData(options) {
14
15
  console.log(body, "body", path, "path");
15
16
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
16
17
  try {
17
- const response = yield fetch(apiUrl, {
18
- method: "POST",
19
- headers,
20
- body: JSON.stringify(body),
21
- });
22
- if (!response.ok) {
23
- throw new Error(`Error: Unexpected response status ${response.status}`);
18
+ const res = yield axios.post(apiUrl, body, { headers });
19
+ if (res.status >= 200 && res.status < 300) {
20
+ return res.data;
24
21
  }
25
- const data = yield response.json();
26
- return data;
22
+ console.error(`Error: Unexpected response status ${res.status}`);
23
+ return {};
27
24
  }
28
25
  catch (error) {
29
26
  console.error(error, "while uploading");
@@ -38,16 +38,17 @@ class FileUpload {
38
38
  },
39
39
  });
40
40
  },
41
- completeMultipartUpload: (file, { uploadId, key, parts }) => (0, utils_js_1.fetchData)({
42
- path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
43
- apiKey: this.#accessKey,
44
- body: {
45
- uploadId,
46
- objectKey: key,
47
- parts,
48
- originalFileName: file.name,
49
- },
50
- }),
41
+ // completeMultipartUpload: (file: any, { uploadId, key, parts }: { uploadId: string | number; key: string | number; parts: any }) =>
42
+ // fetchData({
43
+ // path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
44
+ // apiKey: this.#accessKey,
45
+ // body: {
46
+ // uploadId,
47
+ // objectKey: key,
48
+ // parts,
49
+ // originalFileName: file.name,
50
+ // },
51
+ // }),
51
52
  signPart: (file, partData) => (0, utils_js_1.fetchData)({
52
53
  path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
53
54
  apiKey: this.#accessKey,
package/dist/utils.js CHANGED
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.checkMetaDataValue = exports.checkParameters = exports.fetchData = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
4
8
  const constants_js_1 = require("./constants.js");
5
9
  async function fetchData(options) {
6
10
  const { path, body, queryParams, baseUrl = constants_js_1.APP_AUTH_BASE_URL, apiKey = "", headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" }, } = options;
7
11
  console.log(body, "body", path, "path");
8
12
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
9
13
  try {
10
- const response = await fetch(apiUrl, {
11
- method: "POST",
12
- headers,
13
- body: JSON.stringify(body),
14
- });
15
- if (!response.ok) {
16
- throw new Error(`Error: Unexpected response status ${response.status}`);
14
+ const res = await axios_1.default.post(apiUrl, body, { headers });
15
+ if (res.status >= 200 && res.status < 300) {
16
+ return res.data;
17
17
  }
18
- const data = await response.json();
19
- return data;
18
+ console.error(`Error: Unexpected response status ${res.status}`);
19
+ return {};
20
20
  }
21
21
  catch (error) {
22
22
  console.error(error, "while uploading");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
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
@@ -57,17 +57,17 @@ export default class FileUpload {
57
57
  },
58
58
  });
59
59
  },
60
- completeMultipartUpload: (file: any, { uploadId, key, parts }: { uploadId: string | number; key: string | number; parts: any }) =>
61
- fetchData({
62
- path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
63
- apiKey: this.#accessKey,
64
- body: {
65
- uploadId,
66
- objectKey: key,
67
- parts,
68
- originalFileName: file.name,
69
- },
70
- }),
60
+ // completeMultipartUpload: (file: any, { uploadId, key, parts }: { uploadId: string | number; key: string | number; parts: any }) =>
61
+ // fetchData({
62
+ // path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
63
+ // apiKey: this.#accessKey,
64
+ // body: {
65
+ // uploadId,
66
+ // objectKey: key,
67
+ // parts,
68
+ // originalFileName: file.name,
69
+ // },
70
+ // }),
71
71
 
72
72
  signPart: (file: any, partData: any) =>
73
73
  fetchData({
package/src/utils.ts CHANGED
@@ -24,18 +24,12 @@ export async function fetchData(options: FetchDataOptions): Promise<any> {
24
24
 
25
25
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
26
26
  try {
27
- const response = await fetch(apiUrl, {
28
- method: "POST",
29
- headers,
30
- body: JSON.stringify(body),
31
- });
32
-
33
- if (!response.ok) {
34
- throw new Error(`Error: Unexpected response status ${response.status}`);
27
+ const res: AxiosResponse<any> = await axios.post(apiUrl, body, { headers });
28
+ if (res.status >= 200 && res.status < 300) {
29
+ return res.data;
35
30
  }
36
-
37
- const data = await response.json();
38
- return data;
31
+ console.error(`Error: Unexpected response status ${res.status}`);
32
+ return {};
39
33
  } catch (error) {
40
34
  console.error(error, "while uploading");
41
35
  return {};