@absolutejs/voice 0.0.22-beta.427 → 0.0.22-beta.428
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.js +29 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28752,29 +28752,7 @@ var listRecentJsonFiles = async (directory, limit) => {
|
|
|
28752
28752
|
}
|
|
28753
28753
|
const indexedFiles = await readRecentJsonFileIndex(directory);
|
|
28754
28754
|
if (indexedFiles.length >= limit) {
|
|
28755
|
-
|
|
28756
|
-
const missingPaths = new Set;
|
|
28757
|
-
for (const entry of indexedFiles) {
|
|
28758
|
-
try {
|
|
28759
|
-
await stat(entry.path);
|
|
28760
|
-
existingFiles.push(entry);
|
|
28761
|
-
if (existingFiles.length === limit) {
|
|
28762
|
-
break;
|
|
28763
|
-
}
|
|
28764
|
-
} catch (error) {
|
|
28765
|
-
if (error.code === "ENOENT") {
|
|
28766
|
-
missingPaths.add(entry.path);
|
|
28767
|
-
continue;
|
|
28768
|
-
}
|
|
28769
|
-
throw error;
|
|
28770
|
-
}
|
|
28771
|
-
}
|
|
28772
|
-
if (missingPaths.size > 0) {
|
|
28773
|
-
await writeRecentJsonFileIndex(directory, indexedFiles.filter((entry) => !missingPaths.has(entry.path)));
|
|
28774
|
-
}
|
|
28775
|
-
if (existingFiles.length === limit) {
|
|
28776
|
-
return existingFiles.map((entry) => entry.path);
|
|
28777
|
-
}
|
|
28755
|
+
return indexedFiles.slice(0, limit).map((entry) => entry.path);
|
|
28778
28756
|
}
|
|
28779
28757
|
return (await rebuildRecentJsonFileIndex(directory)).slice(0, limit).map((entry) => entry.path);
|
|
28780
28758
|
};
|
|
@@ -28834,6 +28812,32 @@ var removeRecentJsonFileIndexEntry = async (directory, path) => {
|
|
|
28834
28812
|
const files = (await readRecentJsonFileIndex(directory)).filter((entry) => entry.path !== path);
|
|
28835
28813
|
await writeRecentJsonFileIndex(directory, files);
|
|
28836
28814
|
};
|
|
28815
|
+
var isDefined = (value) => value !== undefined;
|
|
28816
|
+
var readRecentJsonFiles = async (directory, limit) => {
|
|
28817
|
+
const files = await listRecentJsonFiles(directory, limit);
|
|
28818
|
+
const missingPaths = new Set;
|
|
28819
|
+
const records = await Promise.all(files.map(async (file) => {
|
|
28820
|
+
try {
|
|
28821
|
+
return await readJsonFile(file);
|
|
28822
|
+
} catch (error) {
|
|
28823
|
+
if (error.code === "ENOENT") {
|
|
28824
|
+
missingPaths.add(file);
|
|
28825
|
+
return;
|
|
28826
|
+
}
|
|
28827
|
+
throw error;
|
|
28828
|
+
}
|
|
28829
|
+
}));
|
|
28830
|
+
if (missingPaths.size > 0) {
|
|
28831
|
+
await writeRecentJsonFileIndex(directory, (await readRecentJsonFileIndex(directory)).filter((entry) => !missingPaths.has(entry.path)));
|
|
28832
|
+
}
|
|
28833
|
+
const existingRecords = records.filter(isDefined);
|
|
28834
|
+
if (existingRecords.length === limit || missingPaths.size === 0) {
|
|
28835
|
+
return existingRecords;
|
|
28836
|
+
}
|
|
28837
|
+
const rebuiltFiles = (await rebuildRecentJsonFileIndex(directory)).slice(0, limit).map((entry) => entry.path);
|
|
28838
|
+
const rebuiltRecords = await Promise.all(rebuiltFiles.map((file) => readJsonFile(file)));
|
|
28839
|
+
return rebuiltRecords;
|
|
28840
|
+
};
|
|
28837
28841
|
var shouldUseRecentReadWindow = (filter) => filter.readWindow === "recent" && typeof filter.limit === "number" && filter.limit >= 0;
|
|
28838
28842
|
var omitReadWindow = (filter) => {
|
|
28839
28843
|
const { readWindow: _readWindow, ...next } = filter;
|
|
@@ -29049,8 +29053,7 @@ var createVoiceFileTraceEventStore = (options) => {
|
|
|
29049
29053
|
}
|
|
29050
29054
|
};
|
|
29051
29055
|
const list = async (filter = {}) => {
|
|
29052
|
-
const
|
|
29053
|
-
const events = await Promise.all(files.map((file) => readJsonFile(file)));
|
|
29056
|
+
const events = shouldUseRecentReadWindow(filter) ? await readRecentJsonFiles(options.directory, filter.limit) : await Promise.all((await listJsonFiles(options.directory)).map((file) => readJsonFile(file)));
|
|
29054
29057
|
return filterVoiceTraceEvents(events, omitReadWindow(filter));
|
|
29055
29058
|
};
|
|
29056
29059
|
const remove = async (id) => {
|
|
@@ -29113,8 +29116,7 @@ var createVoiceFileAuditEventStore = (options) => {
|
|
|
29113
29116
|
};
|
|
29114
29117
|
const list = async (filter) => {
|
|
29115
29118
|
const resolvedFilter = filter ?? {};
|
|
29116
|
-
const
|
|
29117
|
-
const events = await Promise.all(files.map((file) => readJsonFile(file)));
|
|
29119
|
+
const events = shouldUseRecentReadWindow(resolvedFilter) ? await readRecentJsonFiles(options.directory, resolvedFilter.limit) : await Promise.all((await listJsonFiles(options.directory)).map((file) => readJsonFile(file)));
|
|
29118
29120
|
return filterVoiceAuditEvents(events, omitReadWindow(resolvedFilter));
|
|
29119
29121
|
};
|
|
29120
29122
|
return { append, get, list };
|