Files
usenet-indexer/lib/release/source.ts
T
Daan MeijerandClaude Fable 5.1 346493b6c3
Test and deploy / test (push) Failing after 50s
Test and deploy / edge (push) Successful in 1m53s
Test and deploy / deploy (push) Skipped
Voyager 3 schema: the slim catalog (migration 6000, the reset) and blocks (6100)
releases rebuilt without its text copies: poster_id, group_set_id,
bytea keys, source smallint, edge, settled_at as the finish. posters by
id, group_sets. blocks as the lease unit, ranges.block_id. fragments,
range_blocks, release_final, the settler and the fragment merger gone;
release_chunks, rule_counts and rule_samples keyed by block. Cold tables
on CHUNK_TABLESPACE. Migration 6000 truncates the catalog and refuses
without VOYAGER3_RESET=1.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-25 13:44:54 +01:00

37 lines
1.4 KiB
TypeScript

/**
* How a release got its name, as releases.source stores it (a smallint; voyager 3, migration 6000). The names are
* what the edge, the spot inspector and the API use; the numbers never change meaning once written.
*/
export const SOURCES = {
/** A name the subject announces ("name" yEnc (k/N)). */
subject: 1,
/** The post's files, named after the first file (no release name in the subject). */
post: 2,
/** The files' shared stem. */
stem: 3,
/** A Spotnet spot's files that matched no release. */
spot: 4,
/** An NZB's files. */
nzb: 5,
/** One poster's files that differ only by a number sequence, or share a prefix (voyager 3). */
album: 6,
} as const
export type Source = keyof typeof SOURCES
const NAMES = Object.fromEntries(
Object.entries(SOURCES).map(([name, code]) => [code, name])
) as Record<number, Source>
/** The code of a source name; throws for an unknown one (a typo would write a wrong number for good). */
export function sourceCode(name: string): number {
const code = SOURCES[name as Source]
if (code === undefined) throw new Error(`Unknown release source "${name}"`)
return code
}
/** The name of a stored code; "unknown" for one not listed (never written, but a row might be read by an older build). */
export function sourceName(code: number | string | null | undefined): Source | 'unknown' {
return NAMES[Number(code)] ?? 'unknown'
}