@mgarlik/datastore 0.1.16 → 0.1.17

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
@@ -635,8 +635,8 @@ var buildUri = ({
635
635
  return dataSource.uri || `${dataSource.model || ""}/`;
636
636
  };
637
637
  var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime }) => {
638
- if (dataSource) systemLog("axios", "GET Data Source: ", buildUri({ dataSource, method: "read" }));
639
- else systemLog("axios", "No DataSource for ", id);
638
+ if (dataSource) console.error("[axios] GET Data Source: ", buildUri({ dataSource, method: "read" }));
639
+ else console.error("axios No DataSource for ", id);
640
640
  let persistedData = [];
641
641
  var params = { ...dataSource?.params };
642
642
  if (dataSource?.filter) params.filter = dataSource.filter;
@@ -652,7 +652,7 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
652
652
  if (changeTime) {
653
653
  params.changeTime = changeTime;
654
654
  } else if (isPersisting && SQLite) {
655
- console.time("Persisted Data");
655
+ console.error("[axios] Nacitani dat z SQLite pro ", id, " s parametrem changeTimeFrom: ", params.changeTimeFrom);
656
656
  const qDatum = await SQLite.read(`SELECT * FROM documents WHERE model = '${id}' ORDER BY lastUpdate DESC`);
657
657
  console.warn("[axios] SQLite.read Posledni datum update: ", qDatum[0]?.lastUpdate);
658
658
  if (qDatum[0]?.lastUpdate) params.changeTimeFrom = qDatum[0].lastUpdate;
@@ -669,10 +669,9 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
669
669
  return null;
670
670
  }
671
671
  }).filter((item) => item !== null);
672
- console.timeEnd("Persisted Data");
673
672
  }
674
673
  if (dataSource) {
675
- console.log("Stahuji data z ", buildUri({ dataSource, method: "read" }), " s parametry ", params);
674
+ console.error("[axios] Stahuji data z ", buildUri({ dataSource, method: "read" }), " s parametry ", params);
676
675
  const axiosResponse = await axios.get(buildUri({ dataSource, method: "read" }), { params: serializeParams(params) });
677
676
  if (schema && !dataSource.readAllFields) {
678
677
  const mapBySchema = (element) => {
@@ -710,7 +709,7 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
710
709
  newData = axiosResponse.data.data;
711
710
  }
712
711
  const dataCount = Array.isArray(newData) ? newData.length : "single";
713
- console.log(
712
+ console.error(
714
713
  `[axios](SERVER TIME: ${axiosResponse.data.queryTime}) Data:`,
715
714
  dataCount,
716
715
  "items, Size:",
@@ -723,7 +722,6 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
723
722
  }
724
723
  }
725
724
  if (Array.isArray(newData)) {
726
- console.time("Maping");
727
725
  const map = /* @__PURE__ */ new Map();
728
726
  persistedData.forEach((item) => map.set(item.id, item));
729
727
  newData.forEach((item) => map.set(item.id, item));
@@ -732,17 +730,14 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
732
730
  "axios",
733
731
  `getData - Polozky ${id} persisted: ${persistedData.length}, newData: ${newData.length}, vysledek: ${updatedArray.length}`
734
732
  );
735
- console.timeEnd("Maping");
736
- console.log("================== NEW DATA");
737
- console.log(newData);
733
+ console.error("[axios] NEW DATA: ", newData);
738
734
  return updatedArray;
739
735
  } else {
740
736
  return newData || [];
741
737
  }
742
738
  } catch (e) {
743
739
  const msg = e instanceof Error ? e.message : String(e);
744
- console.warn(`[AXIOS] Warn CHYBABA PRI NACITANI DAT Z:`, JSON.stringify(dataSource, null, 2), "\nChyba:", msg);
745
- console.error(`[AXIOS] CHYBABA PRI NACITANI DAT Z:`, JSON.stringify(dataSource, null, 2), "\nChyba:", msg);
740
+ console.error(`[AXIOS] CHYBACA PRI NACITANI DAT Z:`, JSON.stringify(dataSource, null, 2), "\nChyba:", msg);
746
741
  throw e;
747
742
  }
748
743
  };