API reference > @kontsedal/olas-core
olas-core package
Classes
Class | Description |
|---|---|
Rejection from Deliberately NOT an Reaching this usually means a callback outlived its controller — a confirm dialog answered after the panel behind it closed, a retry button in a toast that outlives the view. Two fixes, in order of preference:
| |
|
Functions
Function | Description |
|---|---|
Batch synchronous signal writes so subscribers see one notification at the end of the batch rather than one per write. Returns whatever | |
Bind a query value to this controller's root, for imperative reads and writes outside a subscription (§5.5, §6.4). | |
Bind an infinite query to this controller's root (§5.11). The handle's methods act on the entry's pages array. | |
Create a Spec §20.1. The graph is glitch-free: a | |
A controller-local cache — one fetcher, no sharing, no cache key (§5.1). ts Unlike | |
Create a standalone emitter. Handlers persist until explicitly unsubscribed (or the emitter is disposed). Use this for emitters that live outside any single controller — typically in deps. Use Pass | |
A reactive form field owned by this controller's lifetime (§8.1). ts
A free function rather than a | |
A dynamic list of fields or forms (§8.5). ts
| |
A form aggregating fields, nested forms and field arrays (§8.3). ts | |
A write owned by this controller's lifetime (§6). Either inline: ts or from a module-scope ts Needs a query engine: mutations participate in the root's in-flight accounting, which | |
A write owned by this controller's lifetime, from an inline spec (§6): the write, its policy and its lifecycle hooks in one object. Needs a query engine on the root. | |
Subscribe this controller to a shared cache entry (§5.2). ts Needs a query engine on the root: With | |
Subscribe this controller to a shared cache entry (§5.2). The third argument is a key thunk, or Needs a query engine on the root. | |
Subscribe this controller to an infinite query (§5.11). The subscription adds Needs a query engine on the root. | |
Construct a root controller. Root factories take no props — startup config goes in
| |
Create a
Spec §16.5. | |
Lag a signal by
| |
Wrap an async validator with a debounce. The debounce timer resets on every value change. While debouncing or the request is in flight, the field's A | |
Create a controller definition. The factory is stored on the returned object and invoked during
| |
Define a shared paginated query, named by its | |
Define a mutation at module scope. The definition is registered by ts
| |
Identity helper that types an object literal as an | |
Define a shared query, cached per root and named by its | |
Create a scope. The returned value is the typed handle passed to | |
Run Returns a | |
Reject strings that don't look like an email. Empty / null pass (use with | |
True iff Spec: §20.12. Node 17+ exposes a global DOMException, so the instanceof branch works server-side; the name-based branch is the portable fallback. | |
Reject numbers greater than | |
Reject strings / arrays longer than | |
Reject numbers less than | |
Reject strings / arrays shorter than | |
Reject any value that isn't boolean | |
Reject strings that don't match the supplied | |
Build a query engine, the value | |
Reject empty values (undefined, null, empty string, empty array). Booleans always pass. | |
Serialize a value as a JavaScript expression that is safe inside an inline ts The result is Throws what | |
Create a writable Spec §20.1. For a single-pass non-tracked read use | |
Rate-limit a signal so it emits at most once per
The returned handle exposes | |
Run | |
Wrap any Standard-Schema-compatible schema (Zod 4, Valibot 1, ArkType 2, …) as an Olas validator. Returns **all** issues as Standard Schema validators may be sync or async; this wrapper threads through whichever the schema returns —
|
Interfaces
Interface | Description |
|---|---|
App-wide deps available on every controller's Default shape carries an index signature so untyped reads compile (as ts | |
Per-mutation plugin settings, carried on | |
Per-query plugin settings, carried on ts |
Type Aliases
Type Alias | Description |
|---|---|
An entry gained its first subscriber, or lost its last one. | |
The ten reactive signals + four actions a subscriber sees for any async resource (
Actions: -
| |
Lifecycle phase of an async resource. | |
Options for | |
The reactive surface returned by | |
Extract the union of every branch's controller Api. Distributes over R. | |
Heterogeneous form of
| |
Constraint for the factory form's return shape. | |
Homogeneous form of | |
A read-only derived signal — alias of | |
The handle returned by | |
Extract a controller's Api type. | |
Extract a controller's Props type. | |
| |
The shape of The bus replays a snapshot of the *live controller tree* to every new subscriber synchronously inside
| |
Snapshot of one live cache entry — produced by | |
Distribute DebugEventMeta across every variant of the union. Written as a distributive conditional (not a plain | |
The set of event bodies emitted by a root. | |
Correlation fields stamped onto — or shared across — every DebugEvent. All optional: consumers building events by hand (and the devtools store's | |
| |
Optional configuration for | |
One entry inside a | |
SSR-serializable snapshot of a root's | |
Synchronous fan-out event bus. Handlers run in the order they subscribed. Emission iterates a SNAPSHOT of the handler set taken at the start of Handlers are stored in a
Spec §7, §20.6. | |
Optional escape hatch for emit-time handler throws. If supplied, a thrown handler is reported here and emission continues with the remaining handlers (spec §20.6 — one throwing handler must not block the rest). If absent, the throw is logged via | |
Context passed to a root's
The remaining fields are correlation hooks for telemetry adapters (Sentry / OpenTelemetry breadcrumbs / Datadog RUM): | |
Signature of | |
What a | |
Per-fetch context: the | |
A reactive form field. Extends | |
A dynamically-sized list of A field array is a | |
The errors of one field-array item: | |
Options for | |
An array-level validator, for rules such as "at least one item". It sees every item's value. A | |
The value of a | |
Options for | |
A bidirectional
ts | |
A nested form. Created via A form is a | |
The errors of a | |
A single validation issue, optionally targeting a descendant of a form tree.
Segments are object keys ( | |
Options for | |
What | |
A form-level validator, for rules across fields. It sees the whole | |
The plain value of a | |
Per-fetch context for an infinite query: the page to fetch, the | |
Module-scoped handle for a paginated query. Mirrors | |
Imperative paginated-query operations bound to one root. | |
Configuration for
| |
What
| |
A cache entry was invalidated. | |
What seeds one field-array item: the field's | |
Handle returned by | |
A cache owned by one controller — no sharing across the tree. Returned by | |
Options for | |
What a | |
What | |
A running mutation. Created via Spec §6, §20.5. | |
How concurrent calls to Spec §6.1. | |
A module-scope mutation, returned by | |
The half of a mutation that describes the write itself, for | |
One step of a mutation run. Every run emits A | |
The per-owner half of a mutation: what | |
Runs mutations registered with | |
A mutation as a plugin sees it. | |
Call signature for Defined as a variadic-tuple conditional so consumers see the right shape without writing | |
The configuration object passed to | |
Connectivity and focus, as the query engine sees them. | |
How a query behaves with respect to the network reachability signal.
| |
A plugin: a named ts Spec §13. | |
What | |
What one root offers a plugin during and after | |
A module-scoped shared query handle. Bind a subscriber via | |
Imperative query operations bound to one root, without a subscription. | |
Defaults for every query, infinite query and Derived via Deliberately NOT defaultable: - Every default applies to infinite queries too. A focus or reconnect refetch of an infinite query re-fetches every loaded page. | |
The query engine — pass one to ts **Why it is a separate value.** **It is a definition, not an instance.** Each root that adopts it gets its own **The client is created eagerly**, inside | |
Options for | |
The root's query cache, addressed by query | |
A query as a plugin sees it: its identity, kind and plugin settings. | |
| |
Configuration passed to The fetcher's first argument is a | |
What | |
Options passed to A | |
Read-only reactive value. Reading | |
Periodic background refetch while an entry has subscribers. A number is a fixed gap in ms. A function is resolved **once per scheduling decision** — on every tick, for the *next* gap — and receives the entry's latest data through a non-subscribing read: ts The contract:
For infinite queries | |
A cache entry left the cache: its last subscriber went away and | |
Backoff in ms. A number is constant delay; a function computes per-attempt. | |
Retry policy for queries and mutations. | |
The handle | |
Configuration passed to | |
Typed cross-tree data slot. Provided by an ancestor via | |
Options for | |
Multi-select state for tables / lists with bulk actions (spec §16.5). Plain function — not bound to | |
Writable reactive value. | |
Returned by
Both are idempotent and mutually exclusive (calling one disables the other). Safe to call after the owning entry has been disposed. | |
Standard Schema v1 — the cross-library validation contract adopted by Zod 4, Valibot 1, ArkType 2, and others. See https://standardschema.dev.`I` is the schema's input type and We type-only-import the shape so consumers don't take a new runtime dep: any object with a | |
One failure a Standard Schema reports: its message, and the path to the value that failed. | |
What a Standard Schema's | |
Options for | |
What | |
Options for | |
Options for | |
A
Both are no-ops when nothing is pending. | |
When a field's validators are first allowed to run.
| |
Checks one value: | |
What a Validator may return synchronously. A plain | |
A cache entry's data changed. | |
Options for | |
What produced a cache write:
|