@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.js CHANGED
@@ -646,7 +646,7 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
646
646
  if (dataSource?.data) {
647
647
  newData = dataSource.data;
648
648
  } else if (dataSource?.file) {
649
- const response = await fetch(`${process.env.PUBLIC_URL}/${dataSource.file}`);
649
+ const response = await fetch(`/${dataSource.file}`);
650
650
  newData = await response.json();
651
651
  } else {
652
652
  if (changeTime) {
@@ -709,10 +709,11 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
709
709
  } else {
710
710
  newData = axiosResponse.data.data;
711
711
  }
712
+ const dataCount = Array.isArray(newData) ? newData.length : "single";
712
713
  systemLog(
713
714
  "axios",
714
715
  `(SERVER TIME: ${axiosResponse.data.queryTime}) Data:`,
715
- newData.length || "single",
716
+ dataCount,
716
717
  "items, Size:",
717
718
  JSON.stringify(newData).length,
718
719
  "Bytes"
@@ -727,11 +728,10 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
727
728
  const map = /* @__PURE__ */ new Map();
728
729
  persistedData.forEach((item) => map.set(item.id, item));
729
730
  newData.forEach((item) => map.set(item.id, item));
730
- let updatedArray = [];
731
- updatedArray.push(...map.values());
731
+ const updatedArray = Array.from(map.values());
732
732
  systemLog(
733
733
  "axios",
734
- `getData - Polozky ${id} persisted: ${persistedData.length}, newData: ${newData.length}, vysledek: ${updatedArray.length}`
734
+ `getData - Polozky ${id} persisted: ${persistedData.length}, newData: ${newData.length}, vysledek: ${updatedArray.length}`
735
735
  );
736
736
  console.timeEnd("Maping");
737
737
  console.log("================== NEW DATA");
@@ -741,9 +741,9 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
741
741
  return newData || [];
742
742
  }
743
743
  } catch (e) {
744
- console.error(`[AXIOS] CHYBA PRI NACITANI DAT Z: ${JSON.stringify(dataSource, null, 2)}
745
- ${e}`);
746
- return [];
744
+ const msg = e instanceof Error ? e.message : String(e);
745
+ console.error(`[AXIOS] CHYBA PRI NACITANI DAT Z:`, JSON.stringify(dataSource, null, 2), "\nChyba:", msg);
746
+ throw e;
747
747
  }
748
748
  };
749
749
  var postData = async ({ dataSource, variant, schema, val }) => {