@mgarlik/datastore 0.1.14 → 0.1.15

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/index.cjs CHANGED
@@ -716,7 +716,7 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
716
716
  if (dataSource?.data) {
717
717
  newData = dataSource.data;
718
718
  } else if (dataSource?.file) {
719
- const response = await fetch(`${process.env.PUBLIC_URL}/${dataSource.file}`);
719
+ const response = await fetch(`/${dataSource.file}`);
720
720
  newData = await response.json();
721
721
  } else {
722
722
  if (changeTime) {
@@ -779,10 +779,11 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
779
779
  } else {
780
780
  newData = axiosResponse.data.data;
781
781
  }
782
+ const dataCount = Array.isArray(newData) ? newData.length : "single";
782
783
  systemLog(
783
784
  "axios",
784
785
  `(SERVER TIME: ${axiosResponse.data.queryTime}) Data:`,
785
- newData.length || "single",
786
+ dataCount,
786
787
  "items, Size:",
787
788
  JSON.stringify(newData).length,
788
789
  "Bytes"
@@ -797,11 +798,10 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
797
798
  const map = /* @__PURE__ */ new Map();
798
799
  persistedData.forEach((item) => map.set(item.id, item));
799
800
  newData.forEach((item) => map.set(item.id, item));
800
- let updatedArray = [];
801
- updatedArray.push(...map.values());
801
+ const updatedArray = Array.from(map.values());
802
802
  systemLog(
803
803
  "axios",
804
- `getData - Polozky ${id} persisted: ${persistedData.length}, newData: ${newData.length}, vysledek: ${updatedArray.length}`
804
+ `getData - Polozky ${id} persisted: ${persistedData.length}, newData: ${newData.length}, vysledek: ${updatedArray.length}`
805
805
  );
806
806
  console.timeEnd("Maping");
807
807
  console.log("================== NEW DATA");
@@ -811,9 +811,9 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
811
811
  return newData || [];
812
812
  }
813
813
  } catch (e) {
814
- console.error(`[AXIOS] CHYBA PRI NACITANI DAT Z: ${JSON.stringify(dataSource, null, 2)}
815
- ${e}`);
816
- return [];
814
+ const msg = e instanceof Error ? e.message : String(e);
815
+ console.error(`[AXIOS] CHYBA PRI NACITANI DAT Z:`, JSON.stringify(dataSource, null, 2), "\nChyba:", msg);
816
+ throw e;
817
817
  }
818
818
  };
819
819
  var postData = async ({ dataSource, variant, schema, val }) => {