MockTypedViewSpec interface

Module @runic-artifex/views/generated/mock in @runic-artifex/views 0.23.0

interface MockTypedViewSpec

What a generated mock{Name}() knows about its client. Generated code is its only intended caller.

Properties

kind

readonly kind: string;

No documentation.

route

readonly route: string;

The root route.

fields

readonly fields: Readonly<Record<string, FieldCodec>>;

Codecs of value fields by wire name. Other fields, such as content references, are stored as given.

defaults

readonly defaults: MockState;

State the client always receives, such as canSave: true.

checkedFields

readonly checkedFields?: readonly string[];

No documentation.

fieldPaths

readonly fieldPaths?: Readonly<Record<string, readonly (readonly string[])[]>>;

Field paths by member (field-paths/1), such as { lines: [["quantity"]] }.

texts

readonly texts?: readonly string[];

Text members by wire name, which frames and setters change with splices (text-splice/1).

collections

readonly collections?: Readonly<Record<string, FieldCodec & {
    key(item: never): string;
}>>;

Keyed collections by wire name: a row codec and its key.

regions

readonly regions?: Readonly<Record<string, {
    readonly close: boolean;
}>>;

Region collections by wire name (region-collections/1): whether the page can close a region.

queries

readonly queries?: Readonly<Record<string, FieldCodec & {
    key?(item: never): string;
}>>;

Query collections by wire name: a row codec and, when the generator found one, its key.

setters

readonly setters?: Readonly<Record<string, {
    readonly member: string;
    readonly checked?: string;
}>>;

Setters by client method (setTitle): the member's wire name, and the client method of its checked write (writeTitle) when it has one.

commands

readonly commands?: Readonly<Record<string, {
    readonly member: string;
    readonly decodeInput?: (wire: unknown) => unknown;
    readonly available?: string;
    readonly encodeFailure?: (value: unknown) => unknown;
}>>;

Commands by client method (save): the member's wire name, decodeInput for a command with an input, available, the state member of its availability, and encodeFailure for a declared failure. A command with an input also has the client method can{Method}.

scopedCommands

readonly scopedCommands?: readonly string[];

Wire names of scoped commands ([RunicPresentationScoped]). The mock, like a producer, checks the epoch of every command that carries one, so it needs no list; generated mocks may state it.

operations

readonly operations?: Readonly<Record<string, {
    readonly member: string;
    readonly decodeInput?: (wire: unknown) => unknown;
    readonly encodeResult?: (value: unknown) => unknown;
    readonly stream?: boolean;
    readonly encodeFailure?: (value: unknown) => unknown;
}>>;

Operations by client command method (start{Method}). encodeFailure encodes a declared failure.

contract

readonly contract?: string;

The View's operation contract, {view}:{fingerprint}.

interactions

readonly interactions?: Readonly<Record<string, {
    readonly encodeInput: (value: unknown) => unknown;
    readonly decodeOutput: (wire: unknown) => unknown;
}>>;

No documentation.

requests

readonly requests?: Readonly<Record<string, {
    readonly encodeInput: (value: unknown) => unknown;
    readonly contract?: string;
}>>;

View requests by name (view-requests/1): encodeInput encodes a typed input as its wire value. With contract, a registration of another contract is unsupported; without it, any contract of the name is accepted.