@mgarlik/datastore 0.1.15 → 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.cjs +10 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -705,8 +705,8 @@ var buildUri = ({
|
|
|
705
705
|
return dataSource.uri || `${dataSource.model || ""}/`;
|
|
706
706
|
};
|
|
707
707
|
var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime }) => {
|
|
708
|
-
if (dataSource)
|
|
709
|
-
else
|
|
708
|
+
if (dataSource) console.error("[axios] GET Data Source: ", buildUri({ dataSource, method: "read" }));
|
|
709
|
+
else console.error("axios No DataSource for ", id);
|
|
710
710
|
let persistedData = [];
|
|
711
711
|
var params = { ...dataSource?.params };
|
|
712
712
|
if (dataSource?.filter) params.filter = dataSource.filter;
|
|
@@ -722,15 +722,15 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
722
722
|
if (changeTime) {
|
|
723
723
|
params.changeTime = changeTime;
|
|
724
724
|
} else if (isPersisting && SQLite) {
|
|
725
|
-
console.
|
|
725
|
+
console.error("[axios] Nacitani dat z SQLite pro ", id, " s parametrem changeTimeFrom: ", params.changeTimeFrom);
|
|
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 };
|
|
@@ -739,10 +739,9 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
739
739
|
return null;
|
|
740
740
|
}
|
|
741
741
|
}).filter((item) => item !== null);
|
|
742
|
-
console.timeEnd("Persisted Data");
|
|
743
742
|
}
|
|
744
743
|
if (dataSource) {
|
|
745
|
-
console.
|
|
744
|
+
console.error("[axios] Stahuji data z ", buildUri({ dataSource, method: "read" }), " s parametry ", params);
|
|
746
745
|
const axiosResponse = await import_axios.default.get(buildUri({ dataSource, method: "read" }), { params: serializeParams(params) });
|
|
747
746
|
if (schema && !dataSource.readAllFields) {
|
|
748
747
|
const mapBySchema = (element) => {
|
|
@@ -780,9 +779,8 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
780
779
|
newData = axiosResponse.data.data;
|
|
781
780
|
}
|
|
782
781
|
const dataCount = Array.isArray(newData) ? newData.length : "single";
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
`(SERVER TIME: ${axiosResponse.data.queryTime}) Data:`,
|
|
782
|
+
console.error(
|
|
783
|
+
`[axios](SERVER TIME: ${axiosResponse.data.queryTime}) Data:`,
|
|
786
784
|
dataCount,
|
|
787
785
|
"items, Size:",
|
|
788
786
|
JSON.stringify(newData).length,
|
|
@@ -794,7 +792,6 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
794
792
|
}
|
|
795
793
|
}
|
|
796
794
|
if (Array.isArray(newData)) {
|
|
797
|
-
console.time("Maping");
|
|
798
795
|
const map = /* @__PURE__ */ new Map();
|
|
799
796
|
persistedData.forEach((item) => map.set(item.id, item));
|
|
800
797
|
newData.forEach((item) => map.set(item.id, item));
|
|
@@ -803,16 +800,14 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
803
800
|
"axios",
|
|
804
801
|
`getData - Polozky ${id} persisted: ${persistedData.length}, newData: ${newData.length}, vysledek: ${updatedArray.length}`
|
|
805
802
|
);
|
|
806
|
-
console.
|
|
807
|
-
console.log("================== NEW DATA");
|
|
808
|
-
console.log(newData);
|
|
803
|
+
console.error("[axios] NEW DATA: ", newData);
|
|
809
804
|
return updatedArray;
|
|
810
805
|
} else {
|
|
811
806
|
return newData || [];
|
|
812
807
|
}
|
|
813
808
|
} catch (e) {
|
|
814
809
|
const msg = e instanceof Error ? e.message : String(e);
|
|
815
|
-
console.error(`[AXIOS]
|
|
810
|
+
console.error(`[AXIOS] CHYBACA PRI NACITANI DAT Z:`, JSON.stringify(dataSource, null, 2), "\nChyba:", msg);
|
|
816
811
|
throw e;
|
|
817
812
|
}
|
|
818
813
|
};
|