@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.cjs +7 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -12
- 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,7 +722,7 @@ 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;
|
|
@@ -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,7 +779,7 @@ 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
|
-
console.
|
|
782
|
+
console.error(
|
|
784
783
|
`[axios](SERVER TIME: ${axiosResponse.data.queryTime}) Data:`,
|
|
785
784
|
dataCount,
|
|
786
785
|
"items, Size:",
|
|
@@ -793,7 +792,6 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
793
792
|
}
|
|
794
793
|
}
|
|
795
794
|
if (Array.isArray(newData)) {
|
|
796
|
-
console.time("Maping");
|
|
797
795
|
const map = /* @__PURE__ */ new Map();
|
|
798
796
|
persistedData.forEach((item) => map.set(item.id, item));
|
|
799
797
|
newData.forEach((item) => map.set(item.id, item));
|
|
@@ -802,17 +800,14 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
802
800
|
"axios",
|
|
803
801
|
`getData - Polozky ${id} persisted: ${persistedData.length}, newData: ${newData.length}, vysledek: ${updatedArray.length}`
|
|
804
802
|
);
|
|
805
|
-
console.
|
|
806
|
-
console.log("================== NEW DATA");
|
|
807
|
-
console.log(newData);
|
|
803
|
+
console.error("[axios] NEW DATA: ", newData);
|
|
808
804
|
return updatedArray;
|
|
809
805
|
} else {
|
|
810
806
|
return newData || [];
|
|
811
807
|
}
|
|
812
808
|
} catch (e) {
|
|
813
809
|
const msg = e instanceof Error ? e.message : String(e);
|
|
814
|
-
console.
|
|
815
|
-
console.error(`[AXIOS] CHYBABA PRI NACITANI DAT Z:`, JSON.stringify(dataSource, null, 2), "\nChyba:", msg);
|
|
810
|
+
console.error(`[AXIOS] CHYBACA PRI NACITANI DAT Z:`, JSON.stringify(dataSource, null, 2), "\nChyba:", msg);
|
|
816
811
|
throw e;
|
|
817
812
|
}
|
|
818
813
|
};
|