@swan-admin/swan-ai-measurements 1.0.75 → 1.0.76

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.
@@ -1,144 +1,112 @@
1
- var __awaiter =
2
- (this && this.__awaiter) ||
3
- function (thisArg, _arguments, P, generator) {
4
- function adopt(value) {
5
- return value instanceof P
6
- ? value
7
- : new P(function (resolve) {
8
- resolve(value);
9
- });
10
- }
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
3
  return new (P || (P = Promise))(function (resolve, reject) {
12
- function fulfilled(value) {
13
- try {
14
- step(generator.next(value));
15
- } catch (e) {
16
- reject(e);
17
- }
18
- }
19
- function rejected(value) {
20
- try {
21
- step(generator["throw"](value));
22
- } catch (e) {
23
- reject(e);
24
- }
25
- }
26
- function step(result) {
27
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
28
- }
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
30
8
  });
31
- };
32
- var __classPrivateFieldSet =
33
- (this && this.__classPrivateFieldSet) ||
34
- function (receiver, state, value, kind, f) {
9
+ };
10
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
35
11
  if (kind === "m") throw new TypeError("Private method is not writable");
36
12
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
37
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
38
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
39
- return kind === "a" ? f.call(receiver, value) : f ? (f.value = value) : state.set(receiver, value), value;
40
- };
41
- var __classPrivateFieldGet =
42
- (this && this.__classPrivateFieldGet) ||
43
- function (receiver, state, kind, f) {
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
14
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15
+ };
16
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
44
17
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
45
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
46
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
18
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
47
19
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
48
- };
20
+ };
49
21
  var _FileUpload_uppyIns, _FileUpload_accessKey;
50
22
  import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, UPPY_FILE_UPLOAD_ENDPOINT } from "./constants.js";
51
23
  import { checkMetaDataValue, checkParameters, fetchData } from "./utils.js";
52
- import Uppy from "@uppy/core";
53
- import AwsS3Multipart from "@uppy/aws-s3-multipart";
24
+ const Uppy = require("fix-esm").require("@uppy/core");
25
+ const AwsS3Multipart = require("fix-esm").require("@uppy/aws-s3-multipart");
54
26
  class FileUpload {
55
- constructor(accessKey) {
56
- _FileUpload_uppyIns.set(this, void 0);
57
- _FileUpload_accessKey.set(this, void 0);
58
- __classPrivateFieldSet(this, _FileUpload_accessKey, accessKey, "f");
59
- }
60
- uploadFile(_a) {
61
- return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId }) {
62
- console.log(UPPY_FILE_UPLOAD_ENDPOINT);
63
- if (!checkParameters(file, arrayMetaData, scanId)) {
64
- throw new Error(REQUIRED_MESSAGE);
65
- }
66
- if (!checkMetaDataValue(arrayMetaData)) {
67
- throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
68
- }
69
- return new Promise((resolve, reject) => {
70
- if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
71
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
72
- }
73
- __classPrivateFieldSet(this, _FileUpload_uppyIns, new Uppy({ autoProceed: true }), "f");
74
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").use(AwsS3Multipart, {
75
- limit: 10,
76
- retryDelays: [0, 1000, 3000, 5000],
77
- getChunkSize: () => 5 * 1024 * 1024,
78
- createMultipartUpload: (file) => {
79
- const objectKey = `${scanId}.${file.extension}`;
80
- return fetchData({
81
- path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
82
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
83
- body: {
84
- objectKey,
85
- contentType: file.type,
86
- objectMetadata: arrayMetaData,
87
- },
27
+ constructor(accessKey) {
28
+ _FileUpload_uppyIns.set(this, void 0);
29
+ _FileUpload_accessKey.set(this, void 0);
30
+ __classPrivateFieldSet(this, _FileUpload_accessKey, accessKey, "f");
31
+ }
32
+ uploadFile(_a) {
33
+ return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId }) {
34
+ if (!checkParameters(file, arrayMetaData, scanId)) {
35
+ throw new Error(REQUIRED_MESSAGE);
36
+ }
37
+ if (!checkMetaDataValue(arrayMetaData)) {
38
+ throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
39
+ }
40
+ return new Promise((resolve, reject) => {
41
+ if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
42
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
43
+ }
44
+ __classPrivateFieldSet(this, _FileUpload_uppyIns, new Uppy.default({ autoProceed: true }), "f");
45
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").use(AwsS3Multipart.default, {
46
+ limit: 10,
47
+ retryDelays: [0, 1000, 3000, 5000],
48
+ getChunkSize: () => 5 * 1024 * 1024,
49
+ createMultipartUpload: (file) => {
50
+ const objectKey = `${scanId}.${file.extension}`;
51
+ return fetchData({
52
+ path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
53
+ apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
54
+ body: {
55
+ objectKey,
56
+ contentType: file.type,
57
+ objectMetadata: arrayMetaData,
58
+ },
59
+ });
60
+ },
61
+ completeMultipartUpload: (file, { uploadId, key, parts }) => fetchData({
62
+ path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
63
+ apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
64
+ body: {
65
+ uploadId,
66
+ objectKey: key,
67
+ parts,
68
+ originalFileName: file.name,
69
+ },
70
+ }),
71
+ signPart: (file, partData) => fetchData({
72
+ path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
73
+ apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
74
+ body: {
75
+ objectKey: partData.key,
76
+ uploadId: partData.uploadId,
77
+ partNumber: partData.partNumber,
78
+ },
79
+ }),
80
+ abortMultipartUpload: (file, { uploadId, key }) => fetchData({
81
+ path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
82
+ apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
83
+ body: {
84
+ uploadId,
85
+ objectKey: key,
86
+ originalFileName: file.name,
87
+ },
88
+ }),
89
+ });
90
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").addFile({
91
+ source: "manual",
92
+ name: file.name,
93
+ type: file.type,
94
+ data: file,
95
+ });
96
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-error", (file, error, response) => {
97
+ reject(error);
98
+ });
99
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-success", () => {
100
+ resolve({ message: "file uploaded successfully" });
101
+ });
102
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("complete", (result) => {
103
+ if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
104
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
105
+ }
106
+ });
88
107
  });
89
- },
90
- completeMultipartUpload: (file, { uploadId, key, parts }) =>
91
- fetchData({
92
- path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
93
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
94
- body: {
95
- uploadId,
96
- objectKey: key,
97
- parts,
98
- originalFileName: file.name,
99
- },
100
- }),
101
- signPart: (file, partData) =>
102
- fetchData({
103
- path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
104
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
105
- body: {
106
- objectKey: partData.key,
107
- uploadId: partData.uploadId,
108
- partNumber: partData.partNumber,
109
- },
110
- }),
111
- abortMultipartUpload: (file, { uploadId, key }) =>
112
- fetchData({
113
- path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
114
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
115
- body: {
116
- uploadId,
117
- objectKey: key,
118
- originalFileName: file.name,
119
- },
120
- }),
121
- });
122
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").addFile({
123
- source: "manual",
124
- name: file.name,
125
- type: file.type,
126
- data: file,
127
- });
128
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-error", (file, error, response) => {
129
- reject(error);
130
108
  });
131
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-success", () => {
132
- resolve({ message: "file uploaded successfully" });
133
- });
134
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("complete", (result) => {
135
- if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
136
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
137
- }
138
- });
139
- });
140
- });
141
- }
109
+ }
142
110
  }
143
- (_FileUpload_uppyIns = new WeakMap()), (_FileUpload_accessKey = new WeakMap());
111
+ _FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap();
144
112
  export default FileUpload;
@@ -6,6 +6,7 @@ export interface FetchDataOptions {
6
6
  baseUrl?: string;
7
7
  apiKey?: string;
8
8
  headers?: Record<string, string>;
9
+ timeout?: number;
9
10
  }
10
11
  export declare function fetchData(options: FetchDataOptions): Promise<any>;
11
12
  export declare function checkParameters(...args: any[]): boolean;
package/dist/esm/utils.js CHANGED
@@ -11,11 +11,12 @@ import axios from "axios";
11
11
  import { APP_AUTH_BASE_URL, requiredMetaData } from "./constants.js";
12
12
  export function fetchData(options) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
- const { path, body, queryParams, baseUrl = APP_AUTH_BASE_URL, apiKey = "", headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" }, } = options;
14
+ const { path, body, queryParams, baseUrl = APP_AUTH_BASE_URL, apiKey = "", headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" }, timeout = 5000, // Default timeout value in milliseconds (adjust as needed)
15
+ } = options;
15
16
  console.log(body, "body", path, "path");
16
17
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
17
18
  try {
18
- const res = yield axios.post(apiUrl, body, { headers });
19
+ const res = yield axios.post(apiUrl, body, { headers, timeout });
19
20
  if (res.status >= 200 && res.status < 300) {
20
21
  return res.data;
21
22
  }
@@ -2,90 +2,92 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const constants_js_1 = require("./constants.js");
4
4
  const utils_js_1 = require("./utils.js");
5
- const Uppy = require("fix-esm").require("@uppy/core");
6
- const AwsS3Multipart = require("fix-esm").require("@uppy/aws-s3-multipart");
5
+ import Uppy from "@uppy/core";
6
+ import AwsS3Multipart from "@uppy/aws-s3-multipart";
7
7
  class FileUpload {
8
- #uppyIns;
9
- #accessKey;
10
- constructor(accessKey) {
11
- this.#accessKey = accessKey;
8
+ #uppyIns;
9
+ #accessKey;
10
+ constructor(accessKey) {
11
+ this.#accessKey = accessKey;
12
+ }
13
+ async uploadFile({ file, arrayMetaData, scanId }) {
14
+ if (!(0, utils_js_1.checkParameters)(file, arrayMetaData, scanId)) {
15
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
12
16
  }
13
- async uploadFile({ file, arrayMetaData, scanId }) {
14
- console.log(constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT);
15
- if (!(0, utils_js_1.checkParameters)(file, arrayMetaData, scanId)) {
16
- throw new Error(constants_js_1.REQUIRED_MESSAGE);
17
- }
18
- if (!(0, utils_js_1.checkMetaDataValue)(arrayMetaData)) {
19
- throw new Error(constants_js_1.REQUIRED_MESSAGE_FOR_META_DATA);
20
- }
21
- return new Promise((resolve, reject) => {
22
- if (this.#uppyIns) {
23
- this.#uppyIns.close();
24
- }
25
- this.#uppyIns = new Uppy.default({ autoProceed: true });
26
- this.#uppyIns.use(AwsS3Multipart.default, {
27
- limit: 10,
28
- retryDelays: [0, 1000, 3000, 5000],
29
- getChunkSize: () => 5 * 1024 * 1024,
30
- createMultipartUpload: (file) => {
31
- const objectKey = `${scanId}.${file.extension}`;
32
- return (0, utils_js_1.fetchData)({
33
- path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
34
- apiKey: this.#accessKey,
35
- body: {
36
- objectKey,
37
- contentType: file.type,
38
- objectMetadata: arrayMetaData,
39
- },
40
- });
41
- },
42
- completeMultipartUpload: (file, { uploadId, key, parts }) => (0, utils_js_1.fetchData)({
43
- path: constants_js_1.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
- }),
52
- signPart: (file, partData) => (0, utils_js_1.fetchData)({
53
- path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
54
- apiKey: this.#accessKey,
55
- body: {
56
- objectKey: partData.key,
57
- uploadId: partData.uploadId,
58
- partNumber: partData.partNumber,
59
- },
60
- }),
61
- abortMultipartUpload: (file, { uploadId, key }) => (0, utils_js_1.fetchData)({
62
- path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
63
- apiKey: this.#accessKey,
64
- body: {
65
- uploadId,
66
- objectKey: key,
67
- originalFileName: file.name,
68
- },
69
- }),
70
- });
71
- this.#uppyIns.addFile({
72
- source: "manual",
73
- name: file.name,
74
- type: file.type,
75
- data: file,
76
- });
77
- this.#uppyIns.on("upload-error", (file, error, response) => {
78
- reject(error);
79
- });
80
- this.#uppyIns.on("upload-success", () => {
81
- resolve({ message: "file uploaded successfully" });
82
- });
83
- this.#uppyIns.on("complete", (result) => {
84
- if (this.#uppyIns) {
85
- this.#uppyIns.close();
86
- }
87
- });
88
- });
17
+ if (!(0, utils_js_1.checkMetaDataValue)(arrayMetaData)) {
18
+ throw new Error(constants_js_1.REQUIRED_MESSAGE_FOR_META_DATA);
89
19
  }
20
+ return new Promise((resolve, reject) => {
21
+ if (this.#uppyIns) {
22
+ this.#uppyIns.close();
23
+ }
24
+ this.#uppyIns = new Uppy({ autoProceed: true });
25
+ this.#uppyIns.use(AwsS3Multipart, {
26
+ limit: 10,
27
+ retryDelays: [0, 1000, 3000, 5000],
28
+ getChunkSize: () => 5 * 1024 * 1024,
29
+ createMultipartUpload: (file) => {
30
+ const objectKey = `${scanId}.${file.extension}`;
31
+ return (0, utils_js_1.fetchData)({
32
+ path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
33
+ apiKey: this.#accessKey,
34
+ body: {
35
+ objectKey,
36
+ contentType: file.type,
37
+ objectMetadata: arrayMetaData,
38
+ },
39
+ });
40
+ },
41
+ completeMultipartUpload: (file, { uploadId, key, parts }) =>
42
+ (0, utils_js_1.fetchData)({
43
+ path: constants_js_1.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
+ }),
52
+ signPart: (file, partData) =>
53
+ (0, utils_js_1.fetchData)({
54
+ path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
55
+ apiKey: this.#accessKey,
56
+ body: {
57
+ objectKey: partData.key,
58
+ uploadId: partData.uploadId,
59
+ partNumber: partData.partNumber,
60
+ },
61
+ }),
62
+ abortMultipartUpload: (file, { uploadId, key }) =>
63
+ (0, utils_js_1.fetchData)({
64
+ path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
65
+ apiKey: this.#accessKey,
66
+ body: {
67
+ uploadId,
68
+ objectKey: key,
69
+ originalFileName: file.name,
70
+ },
71
+ }),
72
+ });
73
+ this.#uppyIns.addFile({
74
+ source: "manual",
75
+ name: file.name,
76
+ type: file.type,
77
+ data: file,
78
+ });
79
+ this.#uppyIns.on("upload-error", (file, error, response) => {
80
+ reject(error);
81
+ });
82
+ this.#uppyIns.on("upload-success", () => {
83
+ resolve({ message: "file uploaded successfully" });
84
+ });
85
+ this.#uppyIns.on("complete", (result) => {
86
+ if (this.#uppyIns) {
87
+ this.#uppyIns.close();
88
+ }
89
+ });
90
+ });
91
+ }
90
92
  }
91
93
  exports.default = FileUpload;
package/dist/utils.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface FetchDataOptions {
6
6
  baseUrl?: string;
7
7
  apiKey?: string;
8
8
  headers?: Record<string, string>;
9
+ timeout?: number;
9
10
  }
10
11
  export declare function fetchData(options: FetchDataOptions): Promise<any>;
11
12
  export declare function checkParameters(...args: any[]): boolean;
package/dist/utils.js CHANGED
@@ -7,11 +7,12 @@ exports.checkMetaDataValue = exports.checkParameters = exports.fetchData = void
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const constants_js_1 = require("./constants.js");
9
9
  async function fetchData(options) {
10
- const { path, body, queryParams, baseUrl = constants_js_1.APP_AUTH_BASE_URL, apiKey = "", headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" }, } = options;
10
+ const { path, body, queryParams, baseUrl = constants_js_1.APP_AUTH_BASE_URL, apiKey = "", headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" }, timeout = 5000, // Default timeout value in milliseconds (adjust as needed)
11
+ } = options;
11
12
  console.log(body, "body", path, "path");
12
13
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
13
14
  try {
14
- const res = await axios_1.default.post(apiUrl, body, { headers });
15
+ const res = await axios_1.default.post(apiUrl, body, { headers, timeout });
15
16
  if (res.status >= 200 && res.status < 300) {
16
17
  return res.data;
17
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.0.75",
3
+ "version": "1.0.76",
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
@@ -29,8 +29,6 @@ export default class FileUpload {
29
29
  }
30
30
 
31
31
  async uploadFile({ file, arrayMetaData, scanId }: UploadOptions) {
32
- console.log(UPPY_FILE_UPLOAD_ENDPOINT);
33
-
34
32
  if (!checkParameters(file, arrayMetaData, scanId)) {
35
33
  throw new Error(REQUIRED_MESSAGE);
36
34
  }
@@ -59,7 +57,7 @@ export default class FileUpload {
59
57
  },
60
58
  });
61
59
  },
62
- completeMultipartUpload: (file: any, { uploadId, key, parts }: { uploadId: string | number; key: string | number; parts: any }) =>
60
+ completeMultipartUpload: (file: any, { uploadId, key, parts }: any) =>
63
61
  fetchData({
64
62
  path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
65
63
  apiKey: this.#accessKey,
@@ -82,7 +80,7 @@ export default class FileUpload {
82
80
  },
83
81
  }),
84
82
 
85
- abortMultipartUpload: (file: any, { uploadId, key }: { uploadId: string | number; key: string | number }) =>
83
+ abortMultipartUpload: (file: any, { uploadId, key }: any) =>
86
84
  fetchData({
87
85
  path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
88
86
  apiKey: this.#accessKey,
package/src/utils.ts CHANGED
@@ -8,6 +8,7 @@ export interface FetchDataOptions {
8
8
  baseUrl?: string;
9
9
  apiKey?: string;
10
10
  headers?: Record<string, string>;
11
+ timeout?: number;
11
12
  }
12
13
 
13
14
  export async function fetchData(options: FetchDataOptions): Promise<any> {
@@ -18,12 +19,14 @@ export async function fetchData(options: FetchDataOptions): Promise<any> {
18
19
  baseUrl = APP_AUTH_BASE_URL,
19
20
  apiKey = "",
20
21
  headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" },
22
+ timeout = 5000, // Default timeout value in milliseconds (adjust as needed)
21
23
  } = options;
24
+
22
25
  console.log(body, "body", path, "path");
23
26
 
24
27
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
25
28
  try {
26
- const res: AxiosResponse<any> = await axios.post(apiUrl, body, { headers });
29
+ const res: AxiosResponse<any> = await axios.post(apiUrl, body, { headers, timeout });
27
30
  if (res.status >= 200 && res.status < 300) {
28
31
  return res.data;
29
32
  }