Authorizetypeno test imports ittype Authorize = (tx: Tx, caller: string, permission: string, tenant: string | undefined) => Promise<boolean>;Whether a caller holds a permission in a tenant; the model's, given by the project.
The runtime of operations (commons data 0031-operations): each run in one transaction, its input checked against its contract, its caller authorized, what it wrote held to what it declared, and what it must record in the audit trail recorded in the same transaction. A business outcome is a value, never an exception, so that an outcome that must be kept (a revocation after a reused token) is committed; anything thrown rolls back.
Authorizetypeno test imports ittype Authorize = (tx: Tx, caller: string, permission: string, tenant: string | undefined) => Promise<boolean>;Whether a caller holds a permission in a tenant; the model's, given by the project.
checkInputfunctionno test imports itfunction checkInput(o: Operation, input: Readonly<Record<string, unknown>>): readonly InputError[]The errors of an input against a contract.
defaultContextfunctionfunction defaultContext(pepper?: string): ContextThe default of what an operation is given: the clock, random identifiers and tokens, and SHA-256; a password verifier is the application's.
Implementationtypetype Implementation = (tx: Tx, input: Readonly<Record<string, unknown>>, context: Context) => Promise<Outcome>;How an operation is done.
InputErrortypeno test imports ittype InputError =
| { readonly kind: "missing"; readonly input: string }
| { readonly kind: "unknown"; readonly input: string }
| { readonly kind: "type"; readonly input: string; readonly expected: string };Why an operation refuses its input, as a value.
operationsfunctionfunction operations(schema: LogicalSchema, dialect: Dialect, driver: Driver, contracts: readonly Operation[], implementations: Readonly<Record<string, Implementation>>, options?: RuntimeOptions): Result<Runtime, readonly SetupError[]>The operations of a model, ready to run.
| Parameter | What it is |
|---|---|
schema | the logical schema |
dialect | the dialect |
driver | the database |
contracts | the operations' contracts |
implementations | how each is done, by name |
options | the naming, the schema, what operations are given, how a caller is authorized and where the audit trail is written |
Returns: the runtime, or why it cannot be made
Outcometypeno test imports ittype Outcome = { readonly status: string; readonly commit?: boolean } & Readonly<Record<string, unknown>>;What an operation gives back: a status, what goes with it, and whether to keep what it did (it does, where it does not say).
Runtimeinterfaceinterface RuntimeThe operations of a model, ready to run.
| Member | Type | What it is |
|---|---|---|
names | readonly string[] | |
run | (name: string, input: Readonly<Record<string, unknown>>, caller?: string | undefined) => Promise<Result<Outcome, RunError>> | Runs an operation. |
RuntimeOptionsinterfaceinterface RuntimeOptionsWhat a runtime is made with.
| Member | Type | What it is |
|---|---|---|
naming? | Naming | |
schema? | string | The schema the tables are in. |
context? | Partial<Context> | |
authorize? | Authorize | |
audit? | AuditSink |
SetupErrortypeno test imports ittype SetupError =
| { readonly kind: "no-implementation"; readonly operation: string }
| { readonly kind: "no-contra… (441 characters)type SetupError =
| { readonly kind: "no-implementation"; readonly operation: string }
| { readonly kind: "no-contract"; readonly operation: string }
| { readonly kind: "unknown-table"; readonly operation: string; readonly table: string }
| { readonly kind: "no-authorizer"; readonly operation: string }
| { readonly kind: "no-audit"; readonly operation: string }
| { readonly kind: "no-permission"; readonly operation: string };Why an operation cannot be set up on a database, as a value.