Activatetypeno test imports ittype Activate = (context: Context) => void | Promise<void>;What an extension does when it is activated, with the handles it declared.
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;Activatetypeno test imports ittype Activate = (context: Context) => void | Promise<void>;What an extension does when it is activated, with the handles it declared.
CONTRACTconstconst CONTRACT: 1The version of the engine's contract, raised when the engine breaks a manifest. An extension names the one it was written for.
Contributioninterfaceno test imports itinterface ContributionWhat an extension adds to a point, made by contribute.
| Member | Type | What it is |
|---|---|---|
point | `${string}.${string}` | |
value | unknown |
contributefunctionfunction contribute<T>(p: ContributionPoint<T>, value: T): ContributionA contribution to a point, typed by it: a value of another type does not compile.
| Parameter | What it is |
|---|---|
p | the point |
value | what is contributed |
Returns: the contribution, frozen
defineExtensionfunctionfunction defineExtension(input: ExtensionInput): ExtensionMakes the manifest of an extension.
| Parameter | What it is |
|---|---|
input | what the extension is, needs and adds |
Returns: the manifest, frozen, written for this engine's contract unless said otherwise
Entrytypetype Entry = Extension | LazyExtension;What a project gives compose: an extension, or a lazy one.
EventNametypetype EventName = `${string}:${string}`;The name of an event that starts a lazy extension: a kind and a subject, such as onDialect:postgres.
Extensioninterfaceinterface ExtensionAn extension: a manifest.
| Member | Type | What it is |
|---|---|---|
id | ExtensionId | |
version | string | |
contract | number | The version of the engine's contract it was written for. |
requires | readonly ExtensionId[] | |
contributes | readonly Contribution[] | |
uses | readonly Handle<unknown>[] | |
activate? | Activate |
ExtensionInputinterfaceno test imports itinterface ExtensionInputWhat defineExtension is given: only the identifier and the version are required.
| Member | Type | What it is |
|---|---|---|
id | ExtensionId | |
version | string | |
contract? | number | |
requires? | readonly ExtensionId[] | |
contributes? | readonly Contribution[] | |
uses? | readonly Handle<unknown>[] | |
activate? | Activate |
LazyExtensioninterfaceno test imports itinterface LazyExtensionAn extension that is loaded and activated only when one of its events is fired.
| Member | Type | What it is |
|---|---|---|
lazy | true | |
id | ExtensionId | |
version | string | |
contract | number | |
requires | readonly ExtensionId[] | |
events | readonly `${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 itinterface LazyInputWhat lazyExtension is given.
| Member | Type | What it is |
|---|---|---|
id | ExtensionId | |
version | string | |
contract? | number | |
requires? | readonly ExtensionId[] | |
events | readonly `${string}:${string}`[] | |
load | () => Promise<Extension> |
lazyExtensionfunctionfunction lazyExtension(input: LazyInput): LazyExtensionMakes a lazy entry: what the engine must know before it loads the extension, and how to load it.
| Parameter | What it is |
|---|---|
input | the identifier, the events and the loader |
Returns: the entry, frozen