PinReftypeno test imports ittype 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.
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.
PinReftypeno test imports ittype 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 ittype PinnedSource = { readonly url: string; readonly ref: PinRef };Where a connector's code comes from, pinned.
SourceErrortypeno test imports ittype SourceError = { readonly kind: "no-pin" } | { readonly kind: "not-https" } | { readonly kind: "branch-not-pinned" };Why a source is refused.
pinSourcefunctionfunction 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.
CONTRACTconstconst CONTRACT: 1The version of the connector contract an entry was written for.
RegistryEntrytypetype 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.
type ConnectorRegistry = ReadonlyMap<ConnectorId, RegistryEntry>;The registry: entries by connector id.
LockErrortypeno test imports ittype 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.
addEntryfunctionfunction addEntry(reg: ConnectorRegistry, e: RegistryEntry): Result<ConnectorRegistry, LockError>The registry with one more entry, or why not.
verifyCopyfunctionfunction verifyCopy(reg: ConnectorRegistry, id: ConnectorId, actual: Sha256): Result<RegistryEntry, LockError>Whether a copy with the digest actual is what the registry pinned for id.
LOCK_SCHEMAconstno test imports itconst LOCK_SCHEMA: "integrations/connector-lock/1"The schema id of a persisted lock.
lockDocumentfunctionfunction 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.
parseLockfunctionfunction 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.