fluncle 0.36.0 → 0.37.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.
Files changed (2) hide show
  1. package/bin/fluncle.mjs +68 -3
  2. package/package.json +1 -1
package/bin/fluncle.mjs CHANGED
@@ -3789,7 +3789,7 @@ function parseVersion(version) {
3789
3789
  var currentVersion, latestReleaseUrl = "https://api.github.com/repos/mauricekleine/fluncle/releases/latest";
3790
3790
  var init_version = __esm(() => {
3791
3791
  init_output();
3792
- currentVersion = "0.36.0".trim() ? "0.36.0".trim() : "0.1.0";
3792
+ currentVersion = "0.37.0".trim() ? "0.37.0".trim() : "0.1.0";
3793
3793
  });
3794
3794
 
3795
3795
  // src/commands/track.ts
@@ -3958,10 +3958,12 @@ var init_add = __esm(() => {
3958
3958
  var exports_admin_tracks = {};
3959
3959
  __export(exports_admin_tracks, {
3960
3960
  vehiclesCommand: () => vehiclesCommand,
3961
- queueCommand: () => queueCommand
3961
+ queueCommand: () => queueCommand,
3962
+ enrichSweepCommand: () => enrichSweepCommand,
3963
+ enrichQueueCommand: () => enrichQueueCommand
3962
3964
  });
3963
3965
  async function fetchAdminTracks(options) {
3964
- const { hasVideo, max, order } = options;
3966
+ const { hasVideo, max, order, status } = options;
3965
3967
  const results = [];
3966
3968
  let cursor;
3967
3969
  do {
@@ -3969,6 +3971,9 @@ async function fetchAdminTracks(options) {
3969
3971
  if (hasVideo !== undefined) {
3970
3972
  params.set("hasVideo", String(hasVideo));
3971
3973
  }
3974
+ if (status !== undefined) {
3975
+ params.set("status", status);
3976
+ }
3972
3977
  if (cursor) {
3973
3978
  params.set("cursor", cursor);
3974
3979
  }
@@ -3990,6 +3995,12 @@ async function fetchAdminTracks(options) {
3990
3995
  async function queueCommand(limit) {
3991
3996
  return fetchAdminTracks({ hasVideo: false, max: limit, order: "asc" });
3992
3997
  }
3998
+ async function enrichQueueCommand(limit) {
3999
+ return fetchAdminTracks({ max: limit, order: "asc", status: "queue" });
4000
+ }
4001
+ async function enrichSweepCommand(limit) {
4002
+ return adminApiPost(`/api/admin/enrich-sweep?limit=${limit}`);
4003
+ }
3993
4004
  async function vehiclesCommand(limit) {
3994
4005
  const tracks = await fetchAdminTracks({ hasVideo: true, max: limit, order: "desc" });
3995
4006
  return tracks.map((track) => ({
@@ -5147,6 +5158,14 @@ function addAdminCommands(program2) {
5147
5158
  const { queueCommand: queueCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
5148
5159
  await runAdminQueue(options, queueCommand2);
5149
5160
  });
5161
+ admin.command("enrich-queue").description("Findings needing (re-)enrichment: pending, failed, or stuck processing").option("--limit <limit>", "Number of findings to show", "10").option("--json", "Print JSON", false).action(async (options) => {
5162
+ const { enrichQueueCommand: enrichQueueCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
5163
+ await runAdminEnrichQueue(options, enrichQueueCommand2);
5164
+ });
5165
+ admin.command("enrich-sweep").description("Re-fire enrichment for everything in the enrich-queue (idempotent self-heal)").option("--limit <limit>", "Max findings to re-trigger", "25").option("--json", "Print JSON", false).action(async (options) => {
5166
+ const { enrichSweepCommand: enrichSweepCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
5167
+ await runAdminEnrichSweep(options, enrichSweepCommand2);
5168
+ });
5150
5169
  admin.command("vehicles").description("Recent video vehicles, newest first (the style ledger for diversity)").option("--limit <limit>", "Number of vehicles to show", "10").option("--json", "Print JSON", false).action(async (options) => {
5151
5170
  const { vehiclesCommand: vehiclesCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
5152
5171
  await runAdminVehicles(options, vehiclesCommand2);
@@ -5707,6 +5726,52 @@ async function runAdminQueue(options, queueCommand2) {
5707
5726
  console.log(trackRows2(tracks).join(`
5708
5727
  `));
5709
5728
  }
5729
+ async function runAdminEnrichQueue(options, enrichQueueCommand2) {
5730
+ const limit = parseListLimit(options.limit);
5731
+ const tracks = await enrichQueueCommand2(limit);
5732
+ if (options.json) {
5733
+ printJson({
5734
+ ok: true,
5735
+ tracks
5736
+ });
5737
+ return;
5738
+ }
5739
+ if (tracks.length === 0) {
5740
+ console.log("Nothing awaiting enrichment. Every finding is enriched.");
5741
+ return;
5742
+ }
5743
+ const { trackRows: trackRows2 } = await Promise.resolve().then(() => exports_format);
5744
+ const noun = tracks.length === 1 ? "finding" : "findings";
5745
+ console.log(`${tracks.length} ${noun} needing (re-)enrichment, oldest first:`);
5746
+ console.log(trackRows2(tracks).join(`
5747
+ `));
5748
+ }
5749
+ async function runAdminEnrichSweep(options, enrichSweepCommand2) {
5750
+ const limit = parseListLimit(options.limit);
5751
+ const result = await enrichSweepCommand2(limit);
5752
+ if (options.json) {
5753
+ printJson({
5754
+ ok: true,
5755
+ reEnriched: result.reEnriched,
5756
+ reEnrichedCount: result.reEnrichedCount,
5757
+ skipped: result.skipped,
5758
+ skippedCount: result.skippedCount
5759
+ });
5760
+ return;
5761
+ }
5762
+ if (result.reEnrichedCount === 0 && result.skippedCount === 0) {
5763
+ console.log("Nothing to sweep. The enrich-queue is empty.");
5764
+ return;
5765
+ }
5766
+ const noun = result.reEnrichedCount === 1 ? "finding" : "findings";
5767
+ console.log(`Re-fired enrichment for ${result.reEnrichedCount} ${noun}.`);
5768
+ for (const entry of result.reEnriched) {
5769
+ console.log(` ${entry.logId || entry.trackId} (was ${entry.status})`);
5770
+ }
5771
+ if (result.skippedCount > 0) {
5772
+ console.log(`Skipped ${result.skippedCount} with no Log ID yet.`);
5773
+ }
5774
+ }
5710
5775
  async function runAdminVehicles(options, vehiclesCommand2) {
5711
5776
  const limit = parseListLimit(options.limit);
5712
5777
  const vehicles = await vehiclesCommand2(limit);
package/package.json CHANGED
@@ -31,5 +31,5 @@
31
31
  "url": "git+https://github.com/mauricekleine/fluncle.git"
32
32
  },
33
33
  "type": "module",
34
- "version": "0.36.0"
34
+ "version": "0.37.0"
35
35
  }