@swan-admin/swan-ai-measurements 1.0.78 → 1.0.80
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/esm/utils.d.ts +0 -1
- package/dist/esm/utils.js +6 -9
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +9 -9
- package/package.json +1 -1
- package/src/fileUpload.ts +2 -2
- package/src/utils.ts +0 -1
package/dist/esm/utils.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export interface FetchDataOptions {
|
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
apiKey?: string;
|
|
8
8
|
headers?: Record<string, string>;
|
|
9
|
-
timeout?: number;
|
|
10
9
|
}
|
|
11
10
|
export declare function fetchData(options: FetchDataOptions): Promise<any>;
|
|
12
11
|
export declare function checkParameters(...args: any[]): boolean;
|
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
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
26
|
-
return
|
|
22
|
+
console.error(`Error: Unexpected response status ${res.status}`);
|
|
23
|
+
return {};
|
|
27
24
|
}
|
|
28
25
|
catch (error) {
|
|
29
26
|
console.error(error, "while uploading");
|
package/dist/utils.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export interface FetchDataOptions {
|
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
apiKey?: string;
|
|
8
8
|
headers?: Record<string, string>;
|
|
9
|
-
timeout?: number;
|
|
10
9
|
}
|
|
11
10
|
export declare function fetchData(options: FetchDataOptions): Promise<any>;
|
|
12
11
|
export declare function checkParameters(...args: any[]): boolean;
|
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
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
19
|
-
return
|
|
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
package/src/fileUpload.ts
CHANGED
|
@@ -57,7 +57,7 @@ export default class FileUpload {
|
|
|
57
57
|
},
|
|
58
58
|
});
|
|
59
59
|
},
|
|
60
|
-
completeMultipartUpload: (file: any, { uploadId, key, parts }: any) =>
|
|
60
|
+
completeMultipartUpload: (file: any, { uploadId, key, parts }: { uploadId: string | number; key: string | number; parts: any }) =>
|
|
61
61
|
fetchData({
|
|
62
62
|
path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
|
|
63
63
|
apiKey: this.#accessKey,
|
|
@@ -80,7 +80,7 @@ export default class FileUpload {
|
|
|
80
80
|
},
|
|
81
81
|
}),
|
|
82
82
|
|
|
83
|
-
abortMultipartUpload: (file: any, { uploadId, key }:
|
|
83
|
+
abortMultipartUpload: (file: any, { uploadId, key }: { uploadId: string | number; key: string | number }) =>
|
|
84
84
|
fetchData({
|
|
85
85
|
path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
|
|
86
86
|
apiKey: this.#accessKey,
|