@nmakarov/cli-toolkit 0.40.0 → 0.44.0
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/cli-runner.cjs +43 -8
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +43 -8
- package/dist/cli-runner.js.map +1 -1
- package/dist/filedatabase.cjs +40 -23
- package/dist/filedatabase.cjs.map +1 -1
- package/dist/filedatabase.js +40 -23
- package/dist/filedatabase.js.map +1 -1
- package/dist/http-client2.cjs +14 -3
- package/dist/http-client2.cjs.map +1 -1
- package/dist/http-client2.js +14 -3
- package/dist/http-client2.js.map +1 -1
- package/dist/index.cjs +83 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +83 -30
- package/dist/index.js.map +1 -1
- package/dist/mock-server.cjs +14 -3
- package/dist/mock-server.cjs.map +1 -1
- package/dist/mock-server.js +14 -3
- package/dist/mock-server.js.map +1 -1
- package/dist/tasks.cjs +57 -10
- package/dist/tasks.cjs.map +1 -1
- package/dist/tasks.js +57 -10
- package/dist/tasks.js.map +1 -1
- package/package.json +1 -1
package/dist/http-client2.js
CHANGED
|
@@ -255,6 +255,9 @@ var FileDatabase = class _FileDatabase {
|
|
|
255
255
|
currentRecord = 0;
|
|
256
256
|
hasReadFirstPage = false;
|
|
257
257
|
lastFileData = null;
|
|
258
|
+
/** Cache of the last JSON file parsed during paginated reads (avoid re-parse per page). */
|
|
259
|
+
readFileCache = null;
|
|
260
|
+
// { filePath: string, data: any[] } | null
|
|
258
261
|
metadata;
|
|
259
262
|
// Synopsis calculation functions
|
|
260
263
|
fileSynopsisFunction = null;
|
|
@@ -1021,7 +1024,6 @@ var FileDatabase = class _FileDatabase {
|
|
|
1021
1024
|
let effectivePageSize;
|
|
1022
1025
|
if (nextPage && this.hasReadFirstPage) {
|
|
1023
1026
|
effectivePageSize = pageSize || this.pageSize;
|
|
1024
|
-
this.currentRecord += effectivePageSize;
|
|
1025
1027
|
} else if (!nextPage) {
|
|
1026
1028
|
effectivePageSize = pageSize !== void 0 ? pageSize : this.metadata.totalRecords;
|
|
1027
1029
|
this.currentRecord = 0;
|
|
@@ -1050,8 +1052,14 @@ var FileDatabase = class _FileDatabase {
|
|
|
1050
1052
|
const file = this.metadata.files[i];
|
|
1051
1053
|
const filePath = path3.join(this.getDestinationPath(this.currentVersion || void 0), file.fileName);
|
|
1052
1054
|
try {
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
+
let fileData;
|
|
1056
|
+
if (this.readFileCache?.filePath === filePath && Array.isArray(this.readFileCache.data)) {
|
|
1057
|
+
fileData = this.readFileCache.data;
|
|
1058
|
+
} else {
|
|
1059
|
+
const rawData = await fs3.promises.readFile(filePath, "utf8");
|
|
1060
|
+
fileData = deserializeData(rawData, this.metadata.dataType);
|
|
1061
|
+
this.readFileCache = { filePath, data: fileData };
|
|
1062
|
+
}
|
|
1055
1063
|
let startIndex = 0;
|
|
1056
1064
|
if (i === currentFileIndex) {
|
|
1057
1065
|
startIndex = this.currentRecord - cumulativeRecords;
|
|
@@ -1065,6 +1073,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
1065
1073
|
throw new FileDatabaseError(`Failed to read file ${file.fileName}: ${error.message}`);
|
|
1066
1074
|
}
|
|
1067
1075
|
}
|
|
1076
|
+
this.currentRecord += recordsRead;
|
|
1068
1077
|
if (result.length > 0) {
|
|
1069
1078
|
if (nextPage || pageSize !== void 0 && pageSize < this.metadata.totalRecords) {
|
|
1070
1079
|
this.hasReadFirstPage = true;
|
|
@@ -1078,6 +1087,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
1078
1087
|
setStartRecord(startRecord) {
|
|
1079
1088
|
this.currentRecord = startRecord - 1;
|
|
1080
1089
|
this.hasReadFirstPage = false;
|
|
1090
|
+
this.readFileCache = null;
|
|
1081
1091
|
}
|
|
1082
1092
|
/**
|
|
1083
1093
|
* Reset read pagination state
|
|
@@ -1085,6 +1095,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
1085
1095
|
resetPagination() {
|
|
1086
1096
|
this.currentRecord = 0;
|
|
1087
1097
|
this.hasReadFirstPage = false;
|
|
1098
|
+
this.readFileCache = null;
|
|
1088
1099
|
}
|
|
1089
1100
|
/**
|
|
1090
1101
|
* List filenames in the table directory.
|