Files
jackwener__opencli/clis/ones/enrich-tasks.ts
jackwener 314bc6f231 refactor: simplify core modules — remove root shims, consolidate error classification, streamline cascade/interceptor, clean up synthesize
1. Remove root-level shim files (errors.ts, logger.ts, registry.ts, types.ts, utils.ts, launcher.ts) — update all ~840 adapter imports to reference src/ directly
2. Consolidate interceptor: reuse shared DISGUISE_FN in tap interceptor instead of reimplementing
3. Unify error classification: single ClassifiedError type with icon/exitCode/hint lookup table, eliminating duplicated pattern matching between resolveExitCode and renderError
4. Simplify cascade probe: replace repetitive switch cases with PROBE_OPTIONS lookup map
12. Clean up synthesize.ts: remove deprecated snake_case field aliases (recommended_args, recommended_columns, recommendedColumnsLegacy) and unnecessary constant aliases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-05 03:06:47 +08:00

48 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* peek 列表只有轻量字段,用 batch tasks/info 补全 summary 等(ONES 文档 #7)
*/
import type { IPage } from '../../src/types.js';
import { onesFetchInPage } from './common.js';
const BATCH_SIZE = 40;
export async function enrichPeekEntriesWithDetails(
page: IPage,
team: string,
entries: Record<string, unknown>[],
skipGoto: boolean,
): Promise<Record<string, unknown>[]> {
const ids = [...new Set(entries.map((e) => String(e.uuid ?? '').trim()).filter(Boolean))];
if (ids.length === 0) return entries;
const byId = new Map<string, Record<string, unknown>>();
try {
for (let i = 0; i < ids.length; i += BATCH_SIZE) {
const slice = ids.slice(i, i + BATCH_SIZE);
const parsed = (await onesFetchInPage(page, `team/${team}/tasks/info`, {
method: 'POST',
body: JSON.stringify({ ids: slice }),
skipGoto,
})) as Record<string, unknown>;
const tasks = Array.isArray(parsed.tasks) ? (parsed.tasks as Record<string, unknown>[]) : [];
for (const t of tasks) {
const id = String(t.uuid ?? '');
if (id) byId.set(id, t);
}
}
} catch {
return entries;
}
if (byId.size === 0) return entries;
return entries.map((e) => {
const id = String(e.uuid ?? '');
const full = id ? byId.get(id) : undefined;
return full ? { ...e, ...full } : e;
});
}