@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.js
CHANGED
|
@@ -134,23 +134,18 @@ function defaultFileSynopsisFunction(fileEntry, data) {
|
|
|
134
134
|
const timestamps = [];
|
|
135
135
|
const statusCounts = {};
|
|
136
136
|
for (const item of data) {
|
|
137
|
-
|
|
138
|
-
let status = null;
|
|
137
|
+
if (!item || typeof item !== "object") continue;
|
|
139
138
|
for (const [key, value] of Object.entries(item)) {
|
|
140
139
|
const k = key.toLowerCase();
|
|
141
|
-
if (k
|
|
142
|
-
ts = new Date(value).getTime();
|
|
140
|
+
if (k.endsWith("modificationtimestamp") && value != null && value !== "") {
|
|
141
|
+
const ts = new Date(value).getTime();
|
|
142
|
+
if (!Number.isNaN(ts)) timestamps.push(ts);
|
|
143
143
|
}
|
|
144
|
-
if (k === "standardstatus") {
|
|
145
|
-
status = value;
|
|
144
|
+
if (k === "standardstatus" && value != null && value !== "") {
|
|
145
|
+
const status = String(value);
|
|
146
|
+
statusCounts[status] = (statusCounts[status] || 0) + 1;
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
|
-
if (ts && !isNaN(ts)) {
|
|
149
|
-
timestamps.push(ts);
|
|
150
|
-
}
|
|
151
|
-
if (status !== null && status !== void 0) {
|
|
152
|
-
statusCounts[status] = (statusCounts[status] || 0) + 1;
|
|
153
|
-
}
|
|
154
149
|
}
|
|
155
150
|
const result = { ...fileEntry };
|
|
156
151
|
if (timestamps.length) {
|
|
@@ -169,27 +164,38 @@ function defaultVersionSynopsisFunction(metadata) {
|
|
|
169
164
|
const timestamps = [];
|
|
170
165
|
const statusCounts = {};
|
|
171
166
|
for (const file of metadata.files) {
|
|
172
|
-
if (file
|
|
167
|
+
if (file?.minModificationTimestamp) {
|
|
173
168
|
const minTs = new Date(file.minModificationTimestamp).getTime();
|
|
174
|
-
if (!isNaN(minTs)) timestamps.push(minTs);
|
|
169
|
+
if (!Number.isNaN(minTs)) timestamps.push(minTs);
|
|
175
170
|
}
|
|
176
|
-
if (file
|
|
171
|
+
if (file?.maxModificationTimestamp) {
|
|
177
172
|
const maxTs = new Date(file.maxModificationTimestamp).getTime();
|
|
178
|
-
if (!isNaN(maxTs)) timestamps.push(maxTs);
|
|
173
|
+
if (!Number.isNaN(maxTs)) timestamps.push(maxTs);
|
|
179
174
|
}
|
|
180
|
-
if (file
|
|
175
|
+
if (file?.StandardStatuses && typeof file.StandardStatuses === "object") {
|
|
181
176
|
for (const [status, count] of Object.entries(file.StandardStatuses)) {
|
|
182
|
-
statusCounts[status] = (statusCounts[status] || 0) + count;
|
|
177
|
+
statusCounts[status] = (statusCounts[status] || 0) + Number(count || 0);
|
|
183
178
|
}
|
|
184
179
|
}
|
|
185
180
|
}
|
|
186
181
|
const result = { ...metadata };
|
|
182
|
+
const synopsis = {
|
|
183
|
+
...metadata.synopsis && typeof metadata.synopsis === "object" ? metadata.synopsis : {}
|
|
184
|
+
};
|
|
187
185
|
if (timestamps.length) {
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
const minIso = new Date(Math.min(...timestamps)).toISOString();
|
|
187
|
+
const maxIso = new Date(Math.max(...timestamps)).toISOString();
|
|
188
|
+
result.minModificationTimestamp = minIso;
|
|
189
|
+
result.maxModificationTimestamp = maxIso;
|
|
190
|
+
synopsis.minModificationTimestamp = minIso;
|
|
191
|
+
synopsis.maxModificationTimestamp = maxIso;
|
|
190
192
|
}
|
|
191
193
|
if (Object.keys(statusCounts).length > 0) {
|
|
192
194
|
result.StandardStatuses = statusCounts;
|
|
195
|
+
synopsis.StandardStatuses = statusCounts;
|
|
196
|
+
}
|
|
197
|
+
if (Object.keys(synopsis).length) {
|
|
198
|
+
result.synopsis = synopsis;
|
|
193
199
|
}
|
|
194
200
|
return result;
|
|
195
201
|
}
|
|
@@ -212,6 +218,9 @@ var FileDatabase = class _FileDatabase {
|
|
|
212
218
|
currentRecord = 0;
|
|
213
219
|
hasReadFirstPage = false;
|
|
214
220
|
lastFileData = null;
|
|
221
|
+
/** Cache of the last JSON file parsed during paginated reads (avoid re-parse per page). */
|
|
222
|
+
readFileCache = null;
|
|
223
|
+
// { filePath: string, data: any[] } | null
|
|
215
224
|
metadata;
|
|
216
225
|
// Synopsis calculation functions
|
|
217
226
|
fileSynopsisFunction = null;
|
|
@@ -978,7 +987,6 @@ var FileDatabase = class _FileDatabase {
|
|
|
978
987
|
let effectivePageSize;
|
|
979
988
|
if (nextPage && this.hasReadFirstPage) {
|
|
980
989
|
effectivePageSize = pageSize || this.pageSize;
|
|
981
|
-
this.currentRecord += effectivePageSize;
|
|
982
990
|
} else if (!nextPage) {
|
|
983
991
|
effectivePageSize = pageSize !== void 0 ? pageSize : this.metadata.totalRecords;
|
|
984
992
|
this.currentRecord = 0;
|
|
@@ -1007,8 +1015,14 @@ var FileDatabase = class _FileDatabase {
|
|
|
1007
1015
|
const file = this.metadata.files[i];
|
|
1008
1016
|
const filePath = path3.join(this.getDestinationPath(this.currentVersion || void 0), file.fileName);
|
|
1009
1017
|
try {
|
|
1010
|
-
|
|
1011
|
-
|
|
1018
|
+
let fileData;
|
|
1019
|
+
if (this.readFileCache?.filePath === filePath && Array.isArray(this.readFileCache.data)) {
|
|
1020
|
+
fileData = this.readFileCache.data;
|
|
1021
|
+
} else {
|
|
1022
|
+
const rawData = await fs3.promises.readFile(filePath, "utf8");
|
|
1023
|
+
fileData = deserializeData(rawData, this.metadata.dataType);
|
|
1024
|
+
this.readFileCache = { filePath, data: fileData };
|
|
1025
|
+
}
|
|
1012
1026
|
let startIndex = 0;
|
|
1013
1027
|
if (i === currentFileIndex) {
|
|
1014
1028
|
startIndex = this.currentRecord - cumulativeRecords;
|
|
@@ -1022,6 +1036,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
1022
1036
|
throw new FileDatabaseError(`Failed to read file ${file.fileName}: ${error.message}`);
|
|
1023
1037
|
}
|
|
1024
1038
|
}
|
|
1039
|
+
this.currentRecord += recordsRead;
|
|
1025
1040
|
if (result.length > 0) {
|
|
1026
1041
|
if (nextPage || pageSize !== void 0 && pageSize < this.metadata.totalRecords) {
|
|
1027
1042
|
this.hasReadFirstPage = true;
|
|
@@ -1035,6 +1050,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
1035
1050
|
setStartRecord(startRecord) {
|
|
1036
1051
|
this.currentRecord = startRecord - 1;
|
|
1037
1052
|
this.hasReadFirstPage = false;
|
|
1053
|
+
this.readFileCache = null;
|
|
1038
1054
|
}
|
|
1039
1055
|
/**
|
|
1040
1056
|
* Reset read pagination state
|
|
@@ -1042,6 +1058,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
1042
1058
|
resetPagination() {
|
|
1043
1059
|
this.currentRecord = 0;
|
|
1044
1060
|
this.hasReadFirstPage = false;
|
|
1061
|
+
this.readFileCache = null;
|
|
1045
1062
|
}
|
|
1046
1063
|
/**
|
|
1047
1064
|
* List filenames in the table directory.
|