effect-tea-persistent
    Preparing search index...

    A program, as program declares it: the pieces the runtime runs every entity of one kind with. A deploy takes it, and a rehearsal runs it without a database or a clock.

    interface Program<T extends Types, Name extends string = string> {
        indexes: Indexes<T>;
        init: (flags: T["flags"], at: Utc) => T["state"] | Rejected<T["rejection"]>;
        keys: Keys<T["key"], T["parameter"]>;
        migrations?: readonly Readonly<
            {
                flags?: (json: Json) => Json;
                inbound?: (json: Json) => Json;
                internal?: (json: Json) => Json;
                operation?: (json: Json) => Json;
                projection?: (json: Json) => Json;
                rejection?: (json: Json) => Json;
                sender?: (json: Json) => Json;
                state?: (json: Json) => Json;
            },
        >[];
        name: Name;
        operations: Runners<T>;
        project: (state: T["state"]) => T["projection"];
        schemas: Schemas<
            T["state"],
            T["flags"],
            T["inbound"],
            T["internal"],
            T["operation"],
            T["rejection"],
            T["sender"],
            T["projection"],
        >;
        topics?: {
            readonly [Name in string]: (
                projection: T["projection"],
            ) => Value<T, Name>
        };
        update: Update<
            T["state"],
            T["inbound"]
            | T["internal"],
            T["sender"],
            T["rejection"],
        >;
        work: (
            state: T["state"],
        ) => Readonly<
            Record<string, Returned<T["operation"], T["internal"]> | undefined>,
        >;
    }

    Type Parameters

    • T extends Types
    • Name extends string = string
    Index
    indexes: Indexes<T>

    What a query across the program's entities may filter and order by, each a pure function of the projection: the read model is the projection, and nothing is queried that a caller cannot read (decision 0032).

    init: (flags: T["flags"], at: Utc) => T["state"] | Rejected<T["rejection"]>

    The first state, or a rejection of the flags: the entity is then not created, nothing is stored, and the creator is answered Rejected (decision 0182).

    keys: Keys<T["key"], T["parameter"]>

    Every key the program's work is held under, with the schema of its parameter, or null for a key without one: the record program makes of the declaration's list (decision 0197). The machine checks work against them (decisions 0037, 0132), and a deploy that renames one is a change of the type (decision 0033).

    migrations?: readonly Readonly<
        {
            flags?: (json: Json) => Json;
            inbound?: (json: Json) => Json;
            internal?: (json: Json) => Json;
            operation?: (json: Json) => Json;
            projection?: (json: Json) => Json;
            rejection?: (json: Json) => Json;
            sender?: (json: Json) => Json;
            state?: (json: Json) => Json;
        },
    >[]

    How the versions before this one are read, in order: the first is the step from version 1 to version 2. A program whose schemas never changed declares none, and is version 1 (decision 0036).

    name: Name

    What other entities read in Address.name, and the runtime stores the entity under.

    operations: Runners<T>

    The runner of each operation, by its tag, with its delivery.

    project: (state: T["state"]) => T["projection"]

    The projection of a state: what callers read, what a query filters on, and what the log publishes.

    schemas: Schemas<
        T["state"],
        T["flags"],
        T["inbound"],
        T["internal"],
        T["operation"],
        T["rejection"],
        T["sender"],
        T["projection"],
    >

    The schemas the declaration gave, by their keys: state, flags, inbound and the others.

    topics?: {
        readonly [Name in string]: (
            projection: T["projection"],
        ) => Value<T, Name>
    }

    The topics of the log, each a pure function that selects, of the projection, the topic's value: a step writes a row in a topic when that changed, and the row gives it. A program that declares none publishes its projection as the one topic projection (decisions 0138, 0140).

    update: Update<
        T["state"],
        T["inbound"]
        | T["internal"],
        T["sender"],
        T["rejection"],
    >

    The next state for an inbound or an internal message, or a rejection of the message.

    work: (
        state: T["state"],
    ) => Readonly<
        Record<string, Returned<T["operation"], T["internal"]> | undefined>,
    >

    The work each state holds, which the machine reads by key, under the keys the program declares.