@absolutejs/voice 0.0.22-beta.426 → 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.
Files changed (2) hide show
  1. package/dist/index.js +30 -29
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25054,8 +25054,7 @@ var resolveSessions2 = async (options) => {
25054
25054
  if (!options.store) {
25055
25055
  return [];
25056
25056
  }
25057
- const summaries = await options.store.list();
25058
- const ids = options.sessionIds ?? summaries.map((summary) => summary.id);
25057
+ const ids = options.sessionIds ?? (await options.store.list()).map((summary) => summary.id);
25059
25058
  const hydrated = await Promise.all(ids.slice(0, options.limit ?? 25).map((id) => options.store?.get(id)));
25060
25059
  const sessions = [];
25061
25060
  for (const session of hydrated) {
@@ -28753,29 +28752,7 @@ var listRecentJsonFiles = async (directory, limit) => {
28753
28752
  }
28754
28753
  const indexedFiles = await readRecentJsonFileIndex(directory);
28755
28754
  if (indexedFiles.length >= limit) {
28756
- const existingFiles = [];
28757
- const missingPaths = new Set;
28758
- for (const entry of indexedFiles) {
28759
- try {
28760
- await stat(entry.path);
28761
- existingFiles.push(entry);
28762
- if (existingFiles.length === limit) {
28763
- break;
28764
- }
28765
- } catch (error) {
28766
- if (error.code === "ENOENT") {
28767
- missingPaths.add(entry.path);
28768
- continue;
28769
- }
28770
- throw error;
28771
- }
28772
- }
28773
- if (missingPaths.size > 0) {
28774
- await writeRecentJsonFileIndex(directory, indexedFiles.filter((entry) => !missingPaths.has(entry.path)));
28775
- }
28776
- if (existingFiles.length === limit) {
28777
- return existingFiles.map((entry) => entry.path);
28778
- }
28755
+ return indexedFiles.slice(0, limit).map((entry) => entry.path);
28779
28756
  }
28780
28757
  return (await rebuildRecentJsonFileIndex(directory)).slice(0, limit).map((entry) => entry.path);
28781
28758
  };
@@ -28835,6 +28812,32 @@ var removeRecentJsonFileIndexEntry = async (directory, path) => {
28835
28812
  const files = (await readRecentJsonFileIndex(directory)).filter((entry) => entry.path !== path);
28836
28813
  await writeRecentJsonFileIndex(directory, files);
28837
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
+ };
28838
28841
  var shouldUseRecentReadWindow = (filter) => filter.readWindow === "recent" && typeof filter.limit === "number" && filter.limit >= 0;
28839
28842
  var omitReadWindow = (filter) => {
28840
28843
  const { readWindow: _readWindow, ...next } = filter;
@@ -29050,8 +29053,7 @@ var createVoiceFileTraceEventStore = (options) => {
29050
29053
  }
29051
29054
  };
29052
29055
  const list = async (filter = {}) => {
29053
- const files = shouldUseRecentReadWindow(filter) ? await listRecentJsonFiles(options.directory, filter.limit) : await listJsonFiles(options.directory);
29054
- 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)));
29055
29057
  return filterVoiceTraceEvents(events, omitReadWindow(filter));
29056
29058
  };
29057
29059
  const remove = async (id) => {
@@ -29114,8 +29116,7 @@ var createVoiceFileAuditEventStore = (options) => {
29114
29116
  };
29115
29117
  const list = async (filter) => {
29116
29118
  const resolvedFilter = filter ?? {};
29117
- const files = shouldUseRecentReadWindow(resolvedFilter) ? await listRecentJsonFiles(options.directory, resolvedFilter.limit) : await listJsonFiles(options.directory);
29118
- 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)));
29119
29120
  return filterVoiceAuditEvents(events, omitReadWindow(resolvedFilter));
29120
29121
  };
29121
29122
  return { append, get, list };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.426",
3
+ "version": "0.0.22-beta.428",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",