@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/filedatabase.cjs
CHANGED
|
@@ -172,23 +172,18 @@ function defaultFileSynopsisFunction(fileEntry, data) {
|
|
|
172
172
|
const timestamps = [];
|
|
173
173
|
const statusCounts = {};
|
|
174
174
|
for (const item of data) {
|
|
175
|
-
|
|
176
|
-
let status = null;
|
|
175
|
+
if (!item || typeof item !== "object") continue;
|
|
177
176
|
for (const [key, value] of Object.entries(item)) {
|
|
178
177
|
const k = key.toLowerCase();
|
|
179
|
-
if (k
|
|
180
|
-
ts = new Date(value).getTime();
|
|
178
|
+
if (k.endsWith("modificationtimestamp") && value != null && value !== "") {
|
|
179
|
+
const ts = new Date(value).getTime();
|
|
180
|
+
if (!Number.isNaN(ts)) timestamps.push(ts);
|
|
181
181
|
}
|
|
182
|
-
if (k === "standardstatus") {
|
|
183
|
-
status = value;
|
|
182
|
+
if (k === "standardstatus" && value != null && value !== "") {
|
|
183
|
+
const status = String(value);
|
|
184
|
+
statusCounts[status] = (statusCounts[status] || 0) + 1;
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
|
-
if (ts && !isNaN(ts)) {
|
|
187
|
-
timestamps.push(ts);
|
|
188
|
-
}
|
|
189
|
-
if (status !== null && status !== void 0) {
|
|
190
|
-
statusCounts[status] = (statusCounts[status] || 0) + 1;
|
|
191
|
-
}
|
|
192
187
|
}
|
|
193
188
|
const result = { ...fileEntry };
|
|
194
189
|
if (timestamps.length) {
|
|
@@ -207,27 +202,38 @@ function defaultVersionSynopsisFunction(metadata) {
|
|
|
207
202
|
const timestamps = [];
|
|
208
203
|
const statusCounts = {};
|
|
209
204
|
for (const file of metadata.files) {
|
|
210
|
-
if (file
|
|
205
|
+
if (file?.minModificationTimestamp) {
|
|
211
206
|
const minTs = new Date(file.minModificationTimestamp).getTime();
|
|
212
|
-
if (!isNaN(minTs)) timestamps.push(minTs);
|
|
207
|
+
if (!Number.isNaN(minTs)) timestamps.push(minTs);
|
|
213
208
|
}
|
|
214
|
-
if (file
|
|
209
|
+
if (file?.maxModificationTimestamp) {
|
|
215
210
|
const maxTs = new Date(file.maxModificationTimestamp).getTime();
|
|
216
|
-
if (!isNaN(maxTs)) timestamps.push(maxTs);
|
|
211
|
+
if (!Number.isNaN(maxTs)) timestamps.push(maxTs);
|
|
217
212
|
}
|
|
218
|
-
if (file
|
|
213
|
+
if (file?.StandardStatuses && typeof file.StandardStatuses === "object") {
|
|
219
214
|
for (const [status, count] of Object.entries(file.StandardStatuses)) {
|
|
220
|
-
statusCounts[status] = (statusCounts[status] || 0) + count;
|
|
215
|
+
statusCounts[status] = (statusCounts[status] || 0) + Number(count || 0);
|
|
221
216
|
}
|
|
222
217
|
}
|
|
223
218
|
}
|
|
224
219
|
const result = { ...metadata };
|
|
220
|
+
const synopsis = {
|
|
221
|
+
...metadata.synopsis && typeof metadata.synopsis === "object" ? metadata.synopsis : {}
|
|
222
|
+
};
|
|
225
223
|
if (timestamps.length) {
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
const minIso = new Date(Math.min(...timestamps)).toISOString();
|
|
225
|
+
const maxIso = new Date(Math.max(...timestamps)).toISOString();
|
|
226
|
+
result.minModificationTimestamp = minIso;
|
|
227
|
+
result.maxModificationTimestamp = maxIso;
|
|
228
|
+
synopsis.minModificationTimestamp = minIso;
|
|
229
|
+
synopsis.maxModificationTimestamp = maxIso;
|
|
228
230
|
}
|
|
229
231
|
if (Object.keys(statusCounts).length > 0) {
|
|
230
232
|
result.StandardStatuses = statusCounts;
|
|
233
|
+
synopsis.StandardStatuses = statusCounts;
|
|
234
|
+
}
|
|
235
|
+
if (Object.keys(synopsis).length) {
|
|
236
|
+
result.synopsis = synopsis;
|
|
231
237
|
}
|
|
232
238
|
return result;
|
|
233
239
|
}
|
|
@@ -250,6 +256,9 @@ var FileDatabase = class _FileDatabase {
|
|
|
250
256
|
currentRecord = 0;
|
|
251
257
|
hasReadFirstPage = false;
|
|
252
258
|
lastFileData = null;
|
|
259
|
+
/** Cache of the last JSON file parsed during paginated reads (avoid re-parse per page). */
|
|
260
|
+
readFileCache = null;
|
|
261
|
+
// { filePath: string, data: any[] } | null
|
|
253
262
|
metadata;
|
|
254
263
|
// Synopsis calculation functions
|
|
255
264
|
fileSynopsisFunction = null;
|
|
@@ -1016,7 +1025,6 @@ var FileDatabase = class _FileDatabase {
|
|
|
1016
1025
|
let effectivePageSize;
|
|
1017
1026
|
if (nextPage && this.hasReadFirstPage) {
|
|
1018
1027
|
effectivePageSize = pageSize || this.pageSize;
|
|
1019
|
-
this.currentRecord += effectivePageSize;
|
|
1020
1028
|
} else if (!nextPage) {
|
|
1021
1029
|
effectivePageSize = pageSize !== void 0 ? pageSize : this.metadata.totalRecords;
|
|
1022
1030
|
this.currentRecord = 0;
|
|
@@ -1045,8 +1053,14 @@ var FileDatabase = class _FileDatabase {
|
|
|
1045
1053
|
const file = this.metadata.files[i];
|
|
1046
1054
|
const filePath = import_path3.default.join(this.getDestinationPath(this.currentVersion || void 0), file.fileName);
|
|
1047
1055
|
try {
|
|
1048
|
-
|
|
1049
|
-
|
|
1056
|
+
let fileData;
|
|
1057
|
+
if (this.readFileCache?.filePath === filePath && Array.isArray(this.readFileCache.data)) {
|
|
1058
|
+
fileData = this.readFileCache.data;
|
|
1059
|
+
} else {
|
|
1060
|
+
const rawData = await import_fs3.default.promises.readFile(filePath, "utf8");
|
|
1061
|
+
fileData = deserializeData(rawData, this.metadata.dataType);
|
|
1062
|
+
this.readFileCache = { filePath, data: fileData };
|
|
1063
|
+
}
|
|
1050
1064
|
let startIndex = 0;
|
|
1051
1065
|
if (i === currentFileIndex) {
|
|
1052
1066
|
startIndex = this.currentRecord - cumulativeRecords;
|
|
@@ -1060,6 +1074,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
1060
1074
|
throw new FileDatabaseError(`Failed to read file ${file.fileName}: ${error.message}`);
|
|
1061
1075
|
}
|
|
1062
1076
|
}
|
|
1077
|
+
this.currentRecord += recordsRead;
|
|
1063
1078
|
if (result.length > 0) {
|
|
1064
1079
|
if (nextPage || pageSize !== void 0 && pageSize < this.metadata.totalRecords) {
|
|
1065
1080
|
this.hasReadFirstPage = true;
|
|
@@ -1073,6 +1088,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
1073
1088
|
setStartRecord(startRecord) {
|
|
1074
1089
|
this.currentRecord = startRecord - 1;
|
|
1075
1090
|
this.hasReadFirstPage = false;
|
|
1091
|
+
this.readFileCache = null;
|
|
1076
1092
|
}
|
|
1077
1093
|
/**
|
|
1078
1094
|
* Reset read pagination state
|
|
@@ -1080,6 +1096,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
1080
1096
|
resetPagination() {
|
|
1081
1097
|
this.currentRecord = 0;
|
|
1082
1098
|
this.hasReadFirstPage = false;
|
|
1099
|
+
this.readFileCache = null;
|
|
1083
1100
|
}
|
|
1084
1101
|
/**
|
|
1085
1102
|
* List filenames in the table directory.
|