IF Commons GitHub

logical/registry

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0005-integrations-observe FR-009, 0005-integrations-observe FR-010, 0005-integrations-observe FR-011

The registry of connectors (commons integrations 0005-integrations-observe): a typed map from a connector id to an entry that pins where the connector came from (a tag or a commit, never a branch) and the SHA-256 of what was taken, a lock that is a persisted document, and the verification of a copy against its pin. Which connectors a consumer runs is the consumer's choice; this is what makes a choice safe to keep.

Source: commons/integrations/src/logical/registry.ts

8 of 13 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

PinReftypeno test imports it
type PinRef = { readonly kind: "tag"; readonly name: string } | { readonly kind: "commit"; readonly sha: string };

What a source is pinned to: a release tag, or a full commit. Never a branch, which moves.

PinnedSourcetypeno test imports it
type PinnedSource = { readonly url: string; readonly ref: PinRef };

Where a connector's code comes from, pinned.

SourceErrortypeno test imports it
type SourceError = { readonly kind: "no-pin" } | { readonly kind: "not-https" } | { readonly kind: "branch-not-pinned" };

Why a source is refused.

pinSourcefunction
function pinSource(text: string): Result<PinnedSource, SourceError>

A source from <https url>@<tag or 40-hex commit>; a ref that is neither a version tag (v1.2.3, 1.2.3) nor a full commit is a branch and is refused.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

CONTRACTconst
const CONTRACT: 1

The version of the connector contract an entry was written for.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

RegistryEntrytype
type RegistryEntry = { readonly id: ConnectorId; readonly title: string; readonly source: PinnedSource; readonly sha256: Sha256; readonly contract: typeof CONTRACT; readonly added: Instant };

One entry of the registry.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

ConnectorRegistrytype
type ConnectorRegistry = ReadonlyMap<ConnectorId, RegistryEntry>;

The registry: entries by connector id.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

LockErrortypeno test imports it
type LockError = { readonly kind: "duplicate"; readonly id: ConnectorId } | { readonly kind: "digest-mismatch"; readonly id: ConnectorId; readonly expected: Sha256; readonly actual: Sha256 } | { readonly kind: "unknown"; readonly id: ConnectorId };

Why an entry is not added or a copy not accepted.

addEntryfunction
function addEntry(reg: ConnectorRegistry, e: RegistryEntry): Result<ConnectorRegistry, LockError>

The registry with one more entry, or why not.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

verifyCopyfunction
function verifyCopy(reg: ConnectorRegistry, id: ConnectorId, actual: Sha256): Result<RegistryEntry, LockError>

Whether a copy with the digest actual is what the registry pinned for id.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

LOCK_SCHEMAconstno test imports it
const LOCK_SCHEMA: "integrations/connector-lock/1"

The schema id of a persisted lock.

lockDocumentfunction
function lockDocument(reg: ConnectorRegistry): { readonly kind: "connector-lock"; readonly schema: "integrations/connector-lock/1"; readonly entries: readonly RegistryEntry[]; }

A lock as the document that is persisted: entries in the order of their ids, so that the same registry is the same text.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

parseLockfunction
function parseLock(input: unknown): Result<ConnectorRegistry, DecodeError | LockError>

Reads a persisted lock back into a registry, refusing a document of another kind or schema, an id or digest that is not one, and an id twice.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.