English
core/charts/catalog.ts
Generated from the exports of core/charts/catalog.ts · npm run docs:gen
The catalog the game reads (alta.catalog/0.2), the right of use of a paid chart (alta.license/0.2) and the pinned git source of a community chart (docs/standards/alta-chart-0.1.md §16). Pure: the signatures themselves are checked by the store with the embedded public key. Also the history of a release on a machine (§14): its records, the refusals of a new revision (pinned, lower version) and the revision a rollback goes back to.
Standards that cite this file: No standard page cites this file yet.
Exports
CHART_ID const
ts
const CHART_ID = /^[a-z][a-z0-9-]{1,40}$/LOCAL_REPO_FOLDERS const
Where a community chart comes from: a git repository pinned on a full commit, with the digest of the chart tree. The folders of this repository a machine installs charts from (each holds chart folders, or is one), before the folders of WORLD_CHARTS (":"-separated). The server and alta repo list read the same list.
ts
const LOCAL_REPO_FOLDERS = ["modules", "agents", "engine"] as constChartSource interface
ts
interface ChartSource { git: string; ref?: string; commit: string; sha256: string }CatalogEntry interface
ts
interface CatalogEntry {
id: string; version: string; kind: string; price: "free" | "paid"; amount?: number; currency?: string;
/** The digest of the chart tree (file paths and contents, sorted): `alta package`. */
sha256: string;
/** The chart folder, relative to the catalog. */
path: string;
default?: boolean; origin?: "alta" | "community"; source?: ChartSource;
}Catalog interface
ts
interface Catalog { schema: "alta.catalog/0.2"; generatedAt: string; charts: CatalogEntry[]; signature?: string }License interface
Right of use of a paid chart, verifiable offline.
ts
interface License { schema: "alta.license/0.2"; chart: string; version: string; holder: string; issuedAt: string; signature: string }checkSource function
Problems of a git source (empty = pinned and well formed).
ts
function checkSource(s: unknown): string[]checkCatalog function
Problems of a catalog (empty = valid).
ts
function checkCatalog(c: unknown, opts: { remote?: boolean; kinds?: readonly string[] } = {}): string[]checkLicense function
Problems of a right of use, by its form.
ts
function checkLicense(l: unknown, chart?: { id: string; version: string }): string[]RELEASE_REASONS const
Why a revision of a release was made.
ts
const RELEASE_REASONS = ["install", "upgrade", "rollback"] as constReleaseReason type
ts
type ReleaseReason = (typeof RELEASE_REASONS)[number];ReleaseRecord interface
One revision of a release, as ~/.local/state/alta/charts/<id>/releases/<revision>.json keeps it (mode 600). The current revision is the one of release.json. values are the owner's choices (never a secret: a chart cannot declare one); valuesDigest lets two revisions be compared without reading them; kept is the copy of the chart folder this revision was installed from (~/.local/share/alta/charts/.versions/<id>/<version>/), what a rollback installs again. migrated: read from an older record (release.json or the archive), never written.
ts
interface ReleaseRecord {
chart: string; revision: number; version: string; digest: string; valuesDigest: string; values?: Record<string, unknown>;
date: string; reason: ReleaseReason; from?: number; kept?: string; migrated?: true;
}canonicalJson function
JSON with sorted keys: one text per value, whatever the order it was written in.
ts
function canonicalJson(v: unknown): stringreleaseHistory function
The history of one release, oldest first, one record per revision. records are the files of releases/; a revision missing there is read from the current release.json or from the archived release records (releases installed before the history existed): migrated by reading, nothing is written or deleted.
ts
function releaseHistory(id: string, records: unknown[], current?: unknown, archived: unknown[] = []): ReleaseRecord[]UPGRADE_REFUSALS const
Why a new revision is refused before anything is written: a pinned release, or a lower version outside a rollback.
ts
const UPGRADE_REFUSALS = ["Pinned", "Downgrade", "FilesEdited"] as constUpgradeRefusal type
ts
type UpgradeRefusal = (typeof UPGRADE_REFUSALS)[number];PIN_REASON_MAX const
The longest reason a pin keeps.
ts
const PIN_REASON_MAX = 200pinReasonProblem function
The problem of a pin reason, or undefined: one line of plain words, 1 to PIN_REASON_MAX characters.
ts
function pinReasonProblem(s: unknown): string | undefinedrevisionRefusal function
Can a release go from installed to target: null, or the refusal and one line. A pinned release never changes, not even forced (unpin it first); a lower version is refused outside a rollback (alta rollback); the same version again is allowed (new values, or the files written again).
ts
function revisionRefusal(installed: { version: string; pinned?: boolean; pinReason?: string } | null | undefined, target: string, reason: ReleaseReason): { refusal: UpgradeRefusal; detail: string } | nullrollbackTarget function
The revision a rollback goes back to: the one asked, or the one before the current.
ts
function rollbackTarget(history: readonly ReleaseRecord[], current: number, wanted?: number): { record: ReleaseRecord } | { error: string }