IF Commons GitHub

engine/manifest

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-engine FR-008, 0002-engine FR-003, 0002-engine FR-004

The manifest of an extension (commons data 0002-engine FR-003): one typed value that says what the extension is, what it needs and what it adds. A contribution is made by contribute(point, value), so a value of another type than the point's does not compile (FR-004); an extension that loads only when an event happens is a lazyExtension (FR-008).

import { contribute, defineExtension, extensionId, point } from "@intellectual-frontiers/data/engine";
const terms = point<{ readonly term: string }>("governance.vocabulary");
const id = extensionId("privacy");
export const privacy = id.kind === "ok" ? defineExtension({ id: id.value, version: "1.0.0", contributes: [contribute(terms, { term: "email" })] }) : undefined;

Source: commons/data/engine/manifest.ts

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

Activatetypeno test imports it
type Activate = (context: Context) => void | Promise<void>;

What an extension does when it is activated, with the handles it declared.

CONTRACTconst
const CONTRACT: 1

The version of the engine's contract, raised when the engine breaks a manifest. An extension names the one it was written for.

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

Contributioninterfaceno test imports it
interface Contribution

What an extension adds to a point, made by contribute.

MemberTypeWhat it is
point`${string}.${string}`
valueunknown
contributefunction
function contribute<T>(p: ContributionPoint<T>, value: T): Contribution

A contribution to a point, typed by it: a value of another type does not compile.

ParameterWhat it is
pthe point
valuewhat is contributed

Returns: the contribution, frozen

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

defineExtensionfunction
function defineExtension(input: ExtensionInput): Extension

Makes the manifest of an extension.

ParameterWhat it is
inputwhat the extension is, needs and adds

Returns: the manifest, frozen, written for this engine's contract unless said otherwise

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

Entrytype
type Entry = Extension | LazyExtension;

What a project gives compose: an extension, or a lazy one.

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

EventNametype
type EventName = `${string}:${string}`;

The name of an event that starts a lazy extension: a kind and a subject, such as onDialect:postgres.

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

Extensioninterface
interface Extension

An extension: a manifest.

MemberTypeWhat it is
idExtensionId
versionstring
contractnumberThe version of the engine's contract it was written for.
requiresreadonly ExtensionId[]
contributesreadonly Contribution[]
usesreadonly Handle<unknown>[]
activate?Activate

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

ExtensionInputinterfaceno test imports it
interface ExtensionInput

What defineExtension is given: only the identifier and the version are required.

MemberTypeWhat it is
idExtensionId
versionstring
contract?number
requires?readonly ExtensionId[]
contributes?readonly Contribution[]
uses?readonly Handle<unknown>[]
activate?Activate
LazyExtensioninterfaceno test imports it
interface LazyExtension

An extension that is loaded and activated only when one of its events is fired.

MemberTypeWhat it is
lazytrue
idExtensionId
versionstring
contractnumber
requiresreadonly ExtensionId[]
eventsreadonly `${string}:${string}`[]The events that start it.
load() => Promise<Extension>Gives the manifest, such as () => import("./mod.ts").then((m) => m.extension).
LazyInputinterfaceno test imports it
interface LazyInput

What lazyExtension is given.

MemberTypeWhat it is
idExtensionId
versionstring
contract?number
requires?readonly ExtensionId[]
eventsreadonly `${string}:${string}`[]
load() => Promise<Extension>
lazyExtensionfunction
function lazyExtension(input: LazyInput): LazyExtension

Makes a lazy entry: what the engine must know before it loads the extension, and how to load it.

ParameterWhat it is
inputthe identifier, the events and the loader

Returns: the entry, frozen

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

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