@xy-planning-network/trees 0.6.0 → 0.7.0-rc-1

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/trees.es.js CHANGED
@@ -1304,28 +1304,20 @@ axios$1.isAxiosError = isAxiosError;
1304
1304
  axios$2.exports = axios$1;
1305
1305
  axios$2.exports.default = axios$1;
1306
1306
  var axios = axios$2.exports;
1307
- const apiDelayReqIntercept = (config) => {
1308
- const delay = config.withDelay || 0;
1307
+ const apiDelayResponseIntercept = (result) => {
1308
+ const delay = result.config.withDelay || 0;
1309
1309
  return new Promise((resolve) => {
1310
1310
  setTimeout(() => {
1311
- resolve(config);
1311
+ resolve(result);
1312
1312
  }, Math.max(delay, 0));
1313
1313
  });
1314
1314
  };
1315
- const apiDataRespIntercept = (response) => {
1316
- var _a;
1317
- if (response.config.dataIntercept && ((_a = response.data) == null ? void 0 : _a.data)) {
1318
- response.data = response.data.data;
1319
- }
1320
- return response;
1321
- };
1322
1315
  const apiAxiosInstance = axios.create({
1323
1316
  baseURL: process.env.VUE_APP_BASE_API_URL || "/api/v1",
1324
1317
  responseType: "json",
1325
1318
  withCredentials: true
1326
1319
  });
1327
- apiAxiosInstance.interceptors.request.use(apiDelayReqIntercept);
1328
- apiAxiosInstance.interceptors.response.use(apiDataRespIntercept);
1320
+ apiAxiosInstance.interceptors.response.use(apiDelayResponseIntercept);
1329
1321
  const BaseAPI = {
1330
1322
  makeRequest(config, opts) {
1331
1323
  const wait = window.setTimeout(() => {
@@ -1333,7 +1325,13 @@ const BaseAPI = {
1333
1325
  useAppSpinner.show();
1334
1326
  }
1335
1327
  }, 200);
1336
- return apiAxiosInstance({ ...config, ...opts }).then((success) => success.data).finally(() => {
1328
+ return apiAxiosInstance({ ...config, ...opts }).then((success) => {
1329
+ var _a;
1330
+ return {
1331
+ data: ((_a = success.data) == null ? void 0 : _a.data) || {},
1332
+ status: success.status
1333
+ };
1334
+ }).finally(() => {
1337
1335
  if (!opts.skipLoader)
1338
1336
  useAppSpinner.hide();
1339
1337
  window.clearTimeout(wait);
@@ -7436,6 +7434,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
7436
7434
  });
7437
7435
  function useBaseAPI(path, method = "GET", initOpts = {}) {
7438
7436
  const result = ref();
7437
+ const status = ref();
7439
7438
  const error = shallowRef();
7440
7439
  const hasFetched = ref(false);
7441
7440
  const isFinished = ref(false);
@@ -7464,16 +7463,22 @@ function useBaseAPI(path, method = "GET", initOpts = {}) {
7464
7463
  };
7465
7464
  return BaseAPI.makeRequest(requestConfig, { ...initOpts, ...opts }).then(
7466
7465
  (success) => {
7467
- result.value = success;
7466
+ result.value = success.data;
7467
+ status.value = success.status;
7468
7468
  error.value = void 0;
7469
7469
  isAborted.value = false;
7470
7470
  return success;
7471
7471
  },
7472
7472
  (err) => {
7473
+ var _a;
7473
7474
  error.value = err;
7475
+ status.value = 0;
7474
7476
  if (axios.isCancel(err)) {
7475
7477
  isAborted.value = true;
7476
7478
  }
7479
+ if (axios.isAxiosError(err)) {
7480
+ status.value = ((_a = err.response) == null ? void 0 : _a.status) || 0;
7481
+ }
7477
7482
  throw err;
7478
7483
  }
7479
7484
  ).finally(() => {
@@ -7489,6 +7494,7 @@ function useBaseAPI(path, method = "GET", initOpts = {}) {
7489
7494
  }
7490
7495
  return {
7491
7496
  result,
7497
+ status,
7492
7498
  error,
7493
7499
  isFinished,
7494
7500
  isLoading,