@absolutejs/voice 0.0.22-beta.423 → 0.0.22-beta.424
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 +53 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28751,6 +28751,35 @@ var listRecentJsonFiles = async (directory, limit) => {
|
|
|
28751
28751
|
if (limit === 0) {
|
|
28752
28752
|
return [];
|
|
28753
28753
|
}
|
|
28754
|
+
const indexedFiles = await readRecentJsonFileIndex(directory);
|
|
28755
|
+
if (indexedFiles.length >= limit) {
|
|
28756
|
+
return indexedFiles.slice(0, limit).map((entry) => entry.path);
|
|
28757
|
+
}
|
|
28758
|
+
return (await rebuildRecentJsonFileIndex(directory)).slice(0, limit).map((entry) => entry.path);
|
|
28759
|
+
};
|
|
28760
|
+
var recentJsonFileIndexPath = (directory) => join2(directory, ".recent-index");
|
|
28761
|
+
var sortRecentJsonFileIndexEntries = (entries) => entries.sort((left, right) => right.updatedAt - left.updatedAt);
|
|
28762
|
+
var readRecentJsonFileIndex = async (directory) => {
|
|
28763
|
+
try {
|
|
28764
|
+
const payload = await readJsonFile(recentJsonFileIndexPath(directory)) ?? { files: [] };
|
|
28765
|
+
return sortRecentJsonFileIndexEntries(Array.isArray(payload.files) ? payload.files : []);
|
|
28766
|
+
} catch (error) {
|
|
28767
|
+
if (error.code === "ENOENT") {
|
|
28768
|
+
return [];
|
|
28769
|
+
}
|
|
28770
|
+
throw error;
|
|
28771
|
+
}
|
|
28772
|
+
};
|
|
28773
|
+
var writeRecentJsonFileIndex = async (directory, files) => {
|
|
28774
|
+
await mkdir3(directory, {
|
|
28775
|
+
recursive: true
|
|
28776
|
+
});
|
|
28777
|
+
await writeFile(recentJsonFileIndexPath(directory), JSON.stringify({
|
|
28778
|
+
files: sortRecentJsonFileIndexEntries(files).slice(0, 5000),
|
|
28779
|
+
version: 1
|
|
28780
|
+
}));
|
|
28781
|
+
};
|
|
28782
|
+
var rebuildRecentJsonFileIndex = async (directory) => {
|
|
28754
28783
|
const files = await listJsonFiles(directory);
|
|
28755
28784
|
const candidates = await Promise.all(files.map(async (path) => {
|
|
28756
28785
|
try {
|
|
@@ -28765,7 +28794,21 @@ var listRecentJsonFiles = async (directory, limit) => {
|
|
|
28765
28794
|
throw error;
|
|
28766
28795
|
}
|
|
28767
28796
|
}));
|
|
28768
|
-
|
|
28797
|
+
const entries = sortRecentJsonFileIndexEntries(candidates.filter((candidate) => Boolean(candidate)));
|
|
28798
|
+
await writeRecentJsonFileIndex(directory, entries);
|
|
28799
|
+
return entries;
|
|
28800
|
+
};
|
|
28801
|
+
var updateRecentJsonFileIndex = async (directory, path) => {
|
|
28802
|
+
const files = (await readRecentJsonFileIndex(directory)).filter((entry) => entry.path !== path);
|
|
28803
|
+
files.push({
|
|
28804
|
+
path,
|
|
28805
|
+
updatedAt: Date.now()
|
|
28806
|
+
});
|
|
28807
|
+
await writeRecentJsonFileIndex(directory, files);
|
|
28808
|
+
};
|
|
28809
|
+
var removeRecentJsonFileIndexEntry = async (directory, path) => {
|
|
28810
|
+
const files = (await readRecentJsonFileIndex(directory)).filter((entry) => entry.path !== path);
|
|
28811
|
+
await writeRecentJsonFileIndex(directory, files);
|
|
28769
28812
|
};
|
|
28770
28813
|
var shouldUseRecentReadWindow = (filter) => filter.readWindow === "recent" && typeof filter.limit === "number" && filter.limit >= 0;
|
|
28771
28814
|
var omitReadWindow = (filter) => {
|
|
@@ -28965,7 +29008,9 @@ var createVoiceFileExternalObjectMapStore = (options) => {
|
|
|
28965
29008
|
var createVoiceFileTraceEventStore = (options) => {
|
|
28966
29009
|
const append = async (event) => {
|
|
28967
29010
|
const stored = createVoiceTraceEvent(event);
|
|
28968
|
-
|
|
29011
|
+
const path = resolveFilePath(options.directory, stored.id);
|
|
29012
|
+
await writeJsonFile(path, stored, options);
|
|
29013
|
+
await updateRecentJsonFileIndex(options.directory, path);
|
|
28969
29014
|
return stored;
|
|
28970
29015
|
};
|
|
28971
29016
|
const get = async (id) => {
|
|
@@ -28985,9 +29030,11 @@ var createVoiceFileTraceEventStore = (options) => {
|
|
|
28985
29030
|
return filterVoiceTraceEvents(events, omitReadWindow(filter));
|
|
28986
29031
|
};
|
|
28987
29032
|
const remove = async (id) => {
|
|
28988
|
-
|
|
29033
|
+
const path = resolveFilePath(options.directory, id);
|
|
29034
|
+
await rm(path, {
|
|
28989
29035
|
force: true
|
|
28990
29036
|
});
|
|
29037
|
+
await removeRecentJsonFileIndexEntry(options.directory, path);
|
|
28991
29038
|
};
|
|
28992
29039
|
return { append, get, list, remove };
|
|
28993
29040
|
};
|
|
@@ -29035,7 +29082,9 @@ var createVoiceFileAuditEventStore = (options) => {
|
|
|
29035
29082
|
};
|
|
29036
29083
|
const append = async (event) => {
|
|
29037
29084
|
const stored = createVoiceAuditEvent(event);
|
|
29038
|
-
|
|
29085
|
+
const path = resolveFilePath(options.directory, stored.id);
|
|
29086
|
+
await writeJsonFile(path, stored, options);
|
|
29087
|
+
await updateRecentJsonFileIndex(options.directory, path);
|
|
29039
29088
|
return stored;
|
|
29040
29089
|
};
|
|
29041
29090
|
const list = async (filter) => {
|