@mgarlik/datastore 0.1.14 → 0.1.16
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 +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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(
|
|
719
|
+
const response = await fetch(`/${dataSource.file}`);
|
|
720
720
|
newData = await response.json();
|
|
721
721
|
} else {
|
|
722
722
|
if (changeTime) {
|
|
@@ -724,13 +724,13 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
724
724
|
} else if (isPersisting && SQLite) {
|
|
725
725
|
console.time("Persisted Data");
|
|
726
726
|
const qDatum = await SQLite.read(`SELECT * FROM documents WHERE model = '${id}' ORDER BY lastUpdate DESC`);
|
|
727
|
-
|
|
727
|
+
console.warn("[axios] SQLite.read Posledni datum update: ", qDatum[0]?.lastUpdate);
|
|
728
728
|
if (qDatum[0]?.lastUpdate) params.changeTimeFrom = qDatum[0].lastUpdate;
|
|
729
729
|
persistedData = qDatum.map((item) => {
|
|
730
730
|
try {
|
|
731
731
|
const parsedData = typeof item.data === "string" ? JSON.parse(item.data) : item.data;
|
|
732
732
|
if (!parsedData || typeof parsedData !== "object" || Array.isArray(parsedData)) {
|
|
733
|
-
|
|
733
|
+
console.warn("[axios] SQLite.read Preskakuji neplatny dokument:", item.id);
|
|
734
734
|
return null;
|
|
735
735
|
}
|
|
736
736
|
return { id: item.id, ...parsedData };
|
|
@@ -779,10 +779,10 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
779
779
|
} else {
|
|
780
780
|
newData = axiosResponse.data.data;
|
|
781
781
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
`(SERVER TIME: ${axiosResponse.data.queryTime}) Data:`,
|
|
785
|
-
|
|
782
|
+
const dataCount = Array.isArray(newData) ? newData.length : "single";
|
|
783
|
+
console.log(
|
|
784
|
+
`[axios](SERVER TIME: ${axiosResponse.data.queryTime}) Data:`,
|
|
785
|
+
dataCount,
|
|
786
786
|
"items, Size:",
|
|
787
787
|
JSON.stringify(newData).length,
|
|
788
788
|
"Bytes"
|
|
@@ -797,11 +797,10 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
797
797
|
const map = /* @__PURE__ */ new Map();
|
|
798
798
|
persistedData.forEach((item) => map.set(item.id, item));
|
|
799
799
|
newData.forEach((item) => map.set(item.id, item));
|
|
800
|
-
|
|
801
|
-
updatedArray.push(...map.values());
|
|
800
|
+
const updatedArray = Array.from(map.values());
|
|
802
801
|
systemLog(
|
|
803
802
|
"axios",
|
|
804
|
-
`getData - Polozky ${id} persisted: ${persistedData.length}, newData: ${newData.length},
|
|
803
|
+
`getData - Polozky ${id} persisted: ${persistedData.length}, newData: ${newData.length}, vysledek: ${updatedArray.length}`
|
|
805
804
|
);
|
|
806
805
|
console.timeEnd("Maping");
|
|
807
806
|
console.log("================== NEW DATA");
|
|
@@ -811,9 +810,10 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
811
810
|
return newData || [];
|
|
812
811
|
}
|
|
813
812
|
} catch (e) {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
813
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
814
|
+
console.warn(`[AXIOS] Warn CHYBABA PRI NACITANI DAT Z:`, JSON.stringify(dataSource, null, 2), "\nChyba:", msg);
|
|
815
|
+
console.error(`[AXIOS] CHYBABA 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 }) => {
|