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

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.
@@ -10,7 +10,7 @@ interface ObjMetaData {
10
10
  callback_url: string;
11
11
  }
12
12
  interface UploadOptions {
13
- file: any;
13
+ file: File;
14
14
  arrayMetaData: ObjMetaData[];
15
15
  scanId: string;
16
16
  }
package/dist/esm/utils.js CHANGED
@@ -7,7 +7,6 @@ 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";
11
10
  import { APP_AUTH_BASE_URL, requiredMetaData } from "./constants.js";
12
11
  export function fetchData(options) {
13
12
  return __awaiter(this, void 0, void 0, function* () {
@@ -15,12 +14,16 @@ export function fetchData(options) {
15
14
  console.log(body, "body", path, "path");
16
15
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
17
16
  try {
18
- const res = yield axios.post(apiUrl, body, { headers });
19
- if (res.status >= 200 && res.status < 300) {
20
- return res.data;
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}`);
21
24
  }
22
- console.error(`Error: Unexpected response status ${res.status}`);
23
- return {};
25
+ const data = yield response.json();
26
+ return data;
24
27
  }
25
28
  catch (error) {
26
29
  console.error(error, "while uploading");
@@ -10,7 +10,7 @@ interface ObjMetaData {
10
10
  callback_url: string;
11
11
  }
12
12
  interface UploadOptions {
13
- file: any;
13
+ file: File;
14
14
  arrayMetaData: ObjMetaData[];
15
15
  scanId: string;
16
16
  }
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
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.checkMetaDataValue = exports.checkParameters = exports.fetchData = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
4
  const constants_js_1 = require("./constants.js");
9
5
  async function fetchData(options) {
10
6
  const { path, body, queryParams, baseUrl = constants_js_1.APP_AUTH_BASE_URL, apiKey = "", headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" }, } = options;
11
7
  console.log(body, "body", path, "path");
12
8
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
13
9
  try {
14
- const res = await axios_1.default.post(apiUrl, body, { headers });
15
- if (res.status >= 200 && res.status < 300) {
16
- return res.data;
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}`);
17
17
  }
18
- console.error(`Error: Unexpected response status ${res.status}`);
19
- return {};
18
+ const data = await response.json();
19
+ return data;
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.80",
3
+ "version": "1.0.82",
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
@@ -15,7 +15,7 @@ interface ObjMetaData {
15
15
  }
16
16
 
17
17
  interface UploadOptions {
18
- file: any;
18
+ file: File;
19
19
  arrayMetaData: ObjMetaData[];
20
20
  scanId: string;
21
21
  }