# `core/charts/index-format.ts`

<p class="generated-note">Generated from the exports of <a href="https://github.com/altasystem-ai/alta/blob/main/core/charts/index-format.ts"><code>core/charts/index-format.ts</code></a> · <code>npm run docs:gen</code></p>

The index of a chart repository (alta.index/0.1, docs/standards/alta-index-0.1.md): every version of every chart, with its digest, archive, source, locality and audit status. Pure: no disk, no network. The CLI fetches and caches indexes (tools/cli/src/repos.ts), the machine's server lists them (server/lib/market.mjs).

**Standards that cite this file**: [alta.index/0.1: the chart repository index](https://docs.altasystem.ai/reference/advanced/specs/alta-index-0.1)

## Exports

### `INDEX_SCHEMA` 
```ts
const INDEX_SCHEMA = "alta.index/0.1"
```

### `REPO_ID` 
```ts
const REPO_ID = /^[a-z][a-z0-9-]{1,31}$/
```

### `PUBLISHER_ID` 
```ts
const PUBLISHER_ID = /^[a-z0-9][a-z0-9-]{1,38}$/
```

### `Text` 
```ts
type Text = { en: string; fr: string };
```

### `Locality` 
```ts
type Locality = "local" | "local-first" | "cloud";
```

### `LOCALITIES` 
```ts
const LOCALITIES: readonly Locality[]
```

### `LOCALITY_CHECKS` 
```ts
const LOCALITY_CHECKS = ["declared", "linted", "tested"] as const
```

### `RISKS` 
```ts
const RISKS = ["low", "medium", "high"] as const
```

### `AUDIT_STATUSES` 
```ts
const AUDIT_STATUSES = ["pass", "review", "warn", "malicious", "pending", "error"] as const
```

### `AuditStatus` 
```ts
type AuditStatus = (typeof AUDIT_STATUSES)[number];
```

### `AUDIT_INSTALLABLE` 
The statuses that let a version be installed; the others block it.

```ts
const AUDIT_INSTALLABLE: readonly AuditStatus[]
```

### `TIERS` 
```ts
const TIERS = ["official", "verified", "community"] as const
```

### `Tier` 
```ts
type Tier = (typeof TIERS)[number];
```

### `SERVICE_PHASES` 
```ts
const SERVICE_PHASES = ["install", "run"] as const
```

### `SERVICE_ACCOUNTS` 
```ts
const SERVICE_ACCOUNTS = ["none", "free", "paid"] as const
```

### `ATTESTATION_TYPES` 
```ts
const ATTESTATION_TYPES = ["publish", "review", "provenance"] as const
```

### `IndexNeed` 
```ts
interface IndexNeed { id: string; kind: "mind" | "channel"; providers: string[]; local: boolean; optional?: boolean }
```

### `IndexService` 
```ts
interface IndexService { id: string; name: string; hosts: string[]; phase: ("install" | "run")[]; required: boolean; account: "none" | "free" | "paid" }
```

### `IndexVersion` 
```ts
interface IndexVersion {
  version: string; created: string;
  digest: string;
  archive?: { url: string; sha256: string; size: number };
  source: { git: string; commit: string; ref?: string; path?: string };
  license: string; price: "free" | "paid";
  pricing?: { model: "one-time" | "subscription"; amount: number; currency: string; interval?: "month" | "year" };
  locality?: Locality;
  localityRange?: { best: Locality; worst: Locality };
  localityCheck: (typeof LOCALITY_CHECKS)[number];
  services: IndexService[];
  /** What it needs (a mind, a channel), each with the providers it may be bound to and whether one is local. */
  needs?: IndexNeed[];
  capabilities: string[];
  risk?: (typeof RISKS)[number];
  support: Support;
  resources?: unknown; requires?: unknown;
  audit: { status: AuditStatus; at?: string; by?: string };
  attestations?: { type: (typeof ATTESTATION_TYPES)[number]; url: string; keyid?: string }[];
  changes?: Text;
  withdrawn?: { at: string; reason: Text };
}
```

### `IndexChart` 
```ts
interface IndexChart {
  publisher: string;
  kind: string; title: Text; summary: Text; categories?: string[]; keywords?: string[]; icon?: string; homepage?: string;
  deprecated?: boolean; replacedBy?: string; aliases?: string[];
  versions: IndexVersion[];
}
```

### `Publisher` 
```ts
interface Publisher { name: string; url?: string; tier: Tier; keys?: { id: string; alg: "ed25519"; public: string; revoked?: string }[] }
```

### `Index` 
```ts
interface Index {
  schema: typeof INDEX_SCHEMA;
  generatedAt: string;
  repo: { id: string; title: Text; url: string; tier: "official" | "community"; report: string };
  publishers: Record<string, Publisher>;
  charts: Record<string, IndexChart>;
}
```

### `UrlRules` 
```ts
interface UrlRules { allowLoopbackHttp?: boolean }
```

### `urlProblem` 
Problems of an address an index may name (empty = an https URL without credentials).

```ts
function urlProblem(u: unknown, rules: UrlRules = {}): string | undefined
```

### `checkIndex` 
Problems of an index (empty = valid).

```ts
function checkIndex(x: unknown, rules: UrlRules = {}): string[]
```

### `Installable` 
```ts
type Installable = { ok: true; note?: string } | { ok: false; reason: "withdrawn" | "pending" | "error" | "malicious" | "deprecated"; why: string };
```

### `installable` 
May this version be pulled and installed? If not, the sentence that says why (alta-index-0.1 §4).

```ts
function installable(c: Pick<IndexChart, "deprecated" | "replacedBy">, v: Pick<IndexVersion, "withdrawn" | "audit">): Installable
```

### `newestInstallable` 
The newest installable version of a chart, if any.

```ts
function newestInstallable(c: IndexChart): IndexVersion | undefined
```

### `SearchQuery` 
```ts
interface SearchQuery { words?: string[]; locality?: Locality; kind?: string; tier?: Tier; free?: boolean; fits?: Host }
```

### `SearchHit` 
```ts
interface SearchHit {
  id: string; kind: string; title: Text; summary: Text; publisher: string; tier: Tier;
  /** The newest version listed, and the newest one that is installable. */
  version: string; installableVersion?: string;
  locality?: Locality; localityNote?: "local possible" | "local-first possible";
  price: "free" | "paid";
  installable: Installable;
  deprecated?: boolean; replacedBy?: string;
}
```

### `tierOf` 
The tier a chart shows: its publisher's.

```ts
const tierOf = (index: Index, c: IndexChart): Tier => …
```

### `searchIndex` 
The charts of an index that match a query (alta-index-0.1 §5), sorted by id.

```ts
function searchIndex(index: Index, q: SearchQuery = {}): SearchHit[]
```

### `catalogOf` 
A catalog (alta.catalog/0.2) from an index: per chart the pinned version, else the newest installable one.

```ts
function catalogOf(index: Index, pins: Record<string, string> = {}): Catalog
```

### `servicesOf` 
The services of a chart's `external` block, as the index lists them. Read defensively: a chart written before the
field existed has none, and a malformed entry is left out (the chart's own lint reports it).

```ts
function servicesOf(chart: Json): IndexService[]
```

### `needsListOf` 
The needs of a chart as the index lists them: the providers each may be bound to, and whether one is local.

```ts
function needsListOf(chart: Json): IndexNeed[]
```

### `chartEntryOf` 
The chart-level fields of an index entry, from a chart.json.

```ts
function chartEntryOf(chart: Json, publisher: string): Omit<IndexChart, "versions">
```

### `versionOf` 
One version of an index entry, from a chart.json and what the builder knows about it.

```ts
function versionOf(chart: Json, o: { digest: string; created: string; source: IndexVersion["source"]; archive?: IndexVersion["archive"]; audit?: IndexVersion["audit"] }): IndexVersion
```
