namespace · packages/metakit/src/transition.ts:13
export * as Transition from './transition.js' Guarded, single-step state transitions (Transition<State, Input, Emit, Supplied>).
Pure data: a when guard over { state, input, supplied }, a list of
writes, each "this path becomes this value", and a list of
records it emits (Transition.emit), each a tag, fields and a condition:
data describing a Command, never running one. Transition.opaque declares
the footprint of a step written as code.
The same Transition drives Transition.step, child lifting
(Transition.lift), SQL's guarded UPDATE, and static readers.
In the guides Members Transition.add# function · packages/metakit/src/transition.ts:87
function add < State , Input , V extends number | null , Supplied = NoSupplied >(
target: StatePath < TransitionEnv < State , Input , Supplied >, V >,
amount: ExprInput < TransitionEnv < State , Input , Supplied >, NoInfer < V >>,
) : WriteEquation < State , Input , V , Supplied > Declare that a number in state grows by amount (a decrement adds the
negated amount): target := target + amount, refused past the safe range
and null where either is null, as Num.add is.
Transition.append# function · packages/metakit/src/transitionLists.ts:188
function append < State , Input , E , Supplied = NoSupplied >(
list: List < State , Input , Supplied , E >,
element: ElementInput < TransitionEnv < State , Input , Supplied >, NoInfer < E >>,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied > The list with element at the end. Two appends do not commute: the order shows.
Transition.assertLiftablePath# function · packages/metakit/src/transitionLift.ts:35
function assertLiftablePath (
path: Pick < PathType < never , unknown >, 'segments' | 'ast' >,
) : void Refuse lifting along a path whose Schema AST is or passes through an Option.
Transition.BinaryOver# interface · packages/metakit/src/transition.ts:97
interface BinaryOver < V > {
readonly descriptor: Node . ForeignOp & {
readonly args: readonly [
{
readonly Type: V
},
{
readonly Type: V
},
]
readonly result: {
readonly Type: V
}
}
} Show all 15 lines A declared binary operation (S, S) => S whose Schema's type is V.
Transition.can# function · packages/metakit/src/can.ts:22
function can < State , Input , Emit , Supplied >(
transition: Transition < State , Input , Emit , Supplied >,
partial: NoInfer < Expr . PartialEnv < TransitionEnv < State , Input , Supplied >>>,
options?: Expr . ReaderOptions ,
) : Verdict . Verdict < Refusal > Partially evaluate transition.when against a partial { state, input,
supplied } environment (e.g. { state: currentAccount }), as Expr.judge
does: a guard known to refuse is False carrying the refusal, since the
step refuses it too.
Transition.combine# function · packages/metakit/src/transition.ts:108
function combine < State , Input , V , Supplied = NoSupplied >(
target: StatePath < TransitionEnv < State , Input , Supplied >, V >,
op: BinaryOver < NonNullable < NoInfer < V >>>,
value: ExprInput < TransitionEnv < State , Input , Supplied >, NoInferEach < V >>,
) : WriteEquation < State , Input , V , Supplied > Declare that target in state is combined with value through a declared
binary operation op: target := op(target, value).
type · packages/metakit/src/transitionLists.ts:50
type ElementInput < Env , E > =
| ExprInput < Env , E >
| (E extends Readonly < Record < string , unknown >>
? {
readonly [K in keyof E ]: ExprInput < Env , Path . Read < E [K ]>>
}
: never ) An element given to a list write: an expression for the whole element, or one per field.
Transition.emit# function · packages/metakit/src/transition.ts:130
function emit <
const Tag extends string ,
const F extends Readonly < Record < string , unknown >> & {
readonly _tag?: never
},
W extends ExprInput < never , boolean | null > = true ,
>(
tag: Tag ,
fields: F ,
options?: {
readonly when?: W
},
) : Emitted <
UnionToIntersection <
{
[K in keyof F ]: F [K ] extends ExprType < infer E , unknown > ? E : unknown
} [keyof F ]
> &
(W extends ExprType < infer E , unknown > ? E : unknown ),
{
readonly _tag: Tag
} & {
readonly [K in keyof F ]: ValueOfInput < F [K ]>
}
> Show all 25 lines A record a step emits: tag, and each field's value over the state before
the step, as the written values are. With when, only where it is true.
A field that needs the state after reads the written value's expression.
Transition.EmitOfEntries# type · packages/metakit/src/transitionShape.ts:49
type EmitOfEntries < Entries > =
Entries extends ReadonlyArray < infer Entry >
? Entry extends Emitted < never , infer E >
? E
: never
: never What a list of Transition.emit entries gives: the union of their records.
Transition.EmitSpec# interface · packages/metakit/src/transitionShape.ts:36
interface EmitSpec {
readonly tag: string
readonly fields: ReadonlyArray < readonly [string , Node . Node ]>
readonly when: Option . Option < Node . Node >
} One record a step emits: a tag, a field per name, and a condition (none: always).
Transition.Emitted# interface · packages/metakit/src/transitionShape.ts:43
interface Emitted < in Env , out E > extends EmitSpec {
readonly _tag: 'Emitted'
readonly _types?: {
readonly env : ( env: Env ) => void
readonly out : () => E
}
} A record a transition emits, built by Transition.emit: E is what a step gives for it.
Transition.evaluateStep# function · packages/metakit/src/transitionRun.ts:96
function evaluateStep < State , Input , Emit , Supplied >(
transition: Transition < State , Input , Emit , Supplied >,
state: State ,
input: Input ,
[ supplied, options] : SuppliedArgs < Supplied >,
onWrite ?: (
write: WriteEquation < State , Input , unknown , Supplied >,
before: State ,
after: State ,
) => void ,
) : Result . Result < StepResult < State , Emit >, Refused > step, calling onWrite for each write that changed the state; stepObserved is its one caller.
Transition.exclude# function · packages/metakit/src/transitionLists.ts:382
function exclude <
State ,
Input ,
E extends number | string ,
Supplied = NoSupplied ,
>(
list: List < State , Input , Supplied , E >,
value: ExprInput < TransitionEnv < State , Input , Supplied >, NoInfer < E > | null >,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied > A set held as a sorted list of scalars, with value taken out.
function · packages/metakit/src/transition.ts:317
function footprint < State , Input , Emit , Supplied >(
transition: Transition < State , Input , Emit , Supplied >,
) : {
readonly reads: Option . Option < ReadonlyArray < ReadonlyArray < string >>>
readonly stateReads: Option . Option < ReadonlyArray < ReadonlyArray < string >>>
readonly writes: ReadonlyArray < ReadonlyArray < string >>
} Static read and write footprints of transition. The reads include the tag
of each union a write goes under to a field some variants lack, which the
step reads to refuse it on another variant.
Transition.include# function · packages/metakit/src/transitionLists.ts:375
function include <
State ,
Input ,
E extends number | string ,
Supplied = NoSupplied ,
>(
list: List < State , Input , Supplied , E >,
value: ExprInput < TransitionEnv < State , Input , Supplied >, NoInfer < E > | null >,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied > A set held as a list of scalars kept in ascending order, with value added unless it is there.
Transition.insert# function · packages/metakit/src/transitionLists.ts:195
function insert <
State ,
Input ,
E ,
K extends keyof E & string ,
Supplied = NoSupplied ,
>(
list: List < State , Input , Supplied , E >,
element: ElementInput < TransitionEnv < State , Input , Supplied >, NoInfer < E >>,
options?: KeyOption < E , K >,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied > The list with element at the end, unless an element has its key; then the list as it was.
Transition.isLazy# function · packages/metakit/src/transition.ts:400
function isLazy (
value: unknown ,
) : value is LazyTransition < unknown , unknown , unknown , unknown > Whether value is a LazyTransition.
Transition.lazy# function · packages/metakit/src/transition.ts:364
function lazy < State , Input = unknown , Emit = never , Supplied = NoSupplied >(
loader : () => Promise <
| Transition < State , Input , Emit , Supplied >
| {
readonly default: Transition < State , Input , Emit , Supplied >
}
>,
) : LazyTransition < State , Input , Emit , Supplied > Wrap a dynamic import of a Transition so callers can check isLoaded(),
read current(), or await resolve() (deduplicating concurrent loads and
clearing in-flight state on rejection so a retry can succeed).
Transition.LazyTransition# interface · packages/metakit/src/transition.ts:352
interface LazyTransition <
State ,
Input = unknown ,
Emit = never ,
Supplied = NoSupplied ,
> {
readonly _tag: 'LazyTransition'
readonly isLoaded : () => boolean
readonly current : () => Option . Option <
Transition < State , Input , Emit , Supplied >
>
readonly resolve : () => Promise < Transition < State , Input , Emit , Supplied >>
} A transition whose implementation loads on demand.
Transition.lift# function · packages/metakit/src/transitionLift.ts:133
function lift <
Outer ,
Inner ,
Input ,
Emit ,
Supplied = NoSupplied ,
InputServices = unknown ,
>(
path: PathType < Outer , Inner | null | undefined >,
transition: Transition < Inner , Input , Emit , Supplied , InputServices >,
) : Transition < Outer , Input , Emit , Supplied , InputServices > Lift a child Transition<Inner, Input, Emit> along Path<Outer, Inner> so
it operates inside a larger Outer model, propagating exact read/write
footprints automatically. path may lead to a nullable or optional field:
the lifted transition is refused where the model
holds no child at path: its guard is false there (Guard , never
GuardRefused), the child's guard is not evaluated, and a write never
invents the struct it writes into. Throws at definition time when
path targets an Option field (lift along a nullable field instead).
A path from Path.from(schema) (or Path.compose onto one) gives the lifted transition schema as its
state Schema; one made from raw segments leaves it unknown, and Sql.toUpdate
refuses a write under a field it cannot tell may hold null.
Transition.make# function · packages/metakit/src/transition.ts:194
function make <
S extends Schema . Top ,
I extends Schema . Top ,
const Entries extends ReadonlyArray <
Emitted < TransitionEnv < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>, unknown >
> = readonly [],
Sup extends SuppliedShape = NoSupplied ,
>( config: {
readonly state: S
readonly input: I
readonly supplied?: Sup
readonly when ?: (
env: TransitionPaths < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
) => ExprInput <
TransitionEnv < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
boolean | null
>
readonly apply : (
env: TransitionPaths < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
) => ReadonlyArray <
WriteEquation < S ['Type' ], I ['Type' ], unknown , Path . EnvOf < Sup >>
>
readonly emits ?: (
env: TransitionPaths < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
) => Entries
readonly ensures ?: (
env: TransitionPostPaths < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
) => ExprInput <
TransitionPostEnv < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
boolean | null
>
}) : Transition <
S ['Type' ],
I ['Type' ],
EmitOfEntries < Entries >,
Path . EnvOf < Sup >,
I ['DecodingServices' ] | I ['EncodingServices' ]
> Show all 38 lines Construct a Transition from state and input Schemas, and the Schemas
of the values it is supplied when it runs.
Transition.move# function · packages/metakit/src/transitionLists.ts:418
function move < State , Input , E , Supplied = NoSupplied >(
list: List < State , Input , Supplied , E >,
value: KeyValue < State , Input , Supplied , E , 'id' & keyof E >,
toIndex: ExprInput < TransitionEnv < State , Input , Supplied >, number >,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied >
function move <
State ,
Input ,
E ,
K extends keyof E & string ,
Supplied = NoSupplied ,
>(
list: List < State , Input , Supplied , E >,
value: KeyValue < State , Input , Supplied , E , K >,
toIndex: ExprInput < TransitionEnv < State , Input , Supplied >, number >,
options: KeyOption < E , K >,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied > Show all 17 lines The list with every element whose key is value moved, as one block in
their order, to toIndex of the list without them (clamped to
[0, length of that list]). Commutes with nothing; idempotent (a block
already at toIndex, or no match, keeps the list's identity).
Transition.NoSupplied# type · packages/metakit/src/transitionShape.ts:12
type NoSupplied = {
readonly [K in never ]: never
} A transition that takes no supplied input.
Transition.opaque# function · packages/metakit/src/transitionOpaque.ts:58
function opaque <
S extends Schema . Top ,
I extends Schema . Top ,
Sup extends SuppliedShape = NoSupplied ,
E = never ,
>( config: {
readonly name: string
readonly state: S
readonly input: I
readonly supplied?: Sup
readonly when ?: (
env: TransitionPaths < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
) => ExprInput <
TransitionEnv < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
boolean | null
>
readonly reads : (
env: TransitionPaths < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
) => ReadonlyArray <
PathType < TransitionEnv < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>, unknown >
>
readonly writes : (
env: TransitionPaths < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
) => ReadonlyArray <
StatePath < TransitionEnv < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>, unknown >
>
readonly run : (
state: S ['Type' ],
input: I ['Type' ],
supplied: Path . EnvOf < Sup >,
) => S ['Type' ]
readonly emits ?: (
env: TransitionPaths < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>,
) => ReadonlyArray <
Emitted < TransitionEnv < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >>, E >
>
}) : Transition <
S ['Type' ],
I ['Type' ],
E ,
Path . EnvOf < Sup >,
I ['DecodingServices' ] | I ['EncodingServices' ]
> Show all 43 lines Declare a step written as code: the paths reads and writes name are its
footprint, and run computes the next state from the state, the input and
the supplied values. A step is refused where when is not true; run
throws where it changes a path writes does not name.
Transition.Patch# type · packages/metakit/src/transitionLists.ts:71
type Patch < Env , E > = {
readonly [F in keyof E ]?: ExprInput < Env , Path . Read < E [F ]>>
} The fields a patch sets of an element, each from an expression over it: no other key compiles.
Transition.patch# function · packages/metakit/src/transitionLists.ts:292
function patch <
State ,
Input ,
E ,
const P extends PatchBound < State , Input , Supplied , E >,
Supplied = NoSupplied ,
>(
list: List < State , Input , Supplied , E >,
value: KeyValue < State , Input , Supplied , E , 'id' & keyof E >,
set: PatchOf < E , P >,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied >
function patch <
State ,
Input ,
E ,
K extends keyof E & string ,
const P extends PatchBound < State , Input , Supplied , E >,
Supplied = NoSupplied ,
>(
list: List < State , Input , Supplied , E >,
value: KeyValue < State , Input , Supplied , E , K >,
set: PatchOf < E , P >,
options: KeyOption < E , K >,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied > Show all 24 lines Each element whose key is value changed by set; every one with it, where two share it.
Transition.patchWhere# function · packages/metakit/src/transitionLists.ts:343
function patchWhere <
State ,
Input ,
E ,
const P extends PatchBound < State , Input , Supplied , E >,
Supplied = NoSupplied ,
>(
list: List < State , Input , Supplied , E >,
test: Test < State , Input , Supplied , NoInfer < E >>,
set: PatchOf < E , P >,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied > Each element that passes test changed by set.
Transition.pathsOf# function · packages/metakit/src/transitionShape.ts:134
function pathsOf <
S extends Schema . Top ,
I extends Schema . Top ,
Sup extends SuppliedShape ,
>(
state: S ,
input: I ,
supplied: Sup ,
) : TransitionPaths < S ['Type' ], I ['Type' ], Path . EnvOf < Sup >> The accessors of { state, input, supplied }, each typed by its Schema.
Transition.readingNodes# function · packages/metakit/src/transition.ts:301
function readingNodes < State , Input , Emit , Supplied >(
transition: Transition < State , Input , Emit , Supplied >,
) : ReadonlyArray < Node . Node > The nodes of a transition that read: its guard, each written value, and each emitted record.
Transition.Refused# class · packages/metakit/src/transitionRun.ts:29
class Refused extends Data. TaggedError ('Refused' )<{
readonly why: Why
}> {} A failed step or dispatch. Match on why for the cause, or read reason for its text.
Transition.remove# function · packages/metakit/src/transitionLists.ts:243
function remove < State , Input , E , Supplied = NoSupplied >(
list: List < State , Input , Supplied , E >,
value: KeyValue < State , Input , Supplied , E , 'id' & keyof E >,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied >
function remove <
State ,
Input ,
E ,
K extends keyof E & string ,
Supplied = NoSupplied ,
>(
list: List < State , Input , Supplied , E >,
value: KeyValue < State , Input , Supplied , E , K >,
options: KeyOption < E , K >,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied > Show all 15 lines The list without the elements whose key is value; every one with it, where
two share it. A helper: removeWhere(list, each => Eq.is(key(each), value)).
Transition.removeWhere# function · packages/metakit/src/transitionLists.ts:269
function removeWhere < State , Input , E , Supplied = NoSupplied >(
list: List < State , Input , Supplied , E >,
test: Test < State , Input , Supplied , NoInfer < E >>,
) : WriteEquation < State , Input , ReadonlyArray < E >, Supplied > The list without the elements that pass test; an element whose test is null stays.
Transition.replace# function · packages/metakit/src/transitionReplace.ts:42
function replace <
State ,
Input ,
V ,
M extends NonNullable < V >,
Supplied = NoSupplied ,
>(
target: StatePath < TransitionEnv < State , Input , Supplied >, V >,
member: Schema . Top & {
readonly Type: M
},
fields: ReplaceFields < TransitionEnv < State , Input , Supplied >, M >,
) : WriteEquation < State , Input , V , Supplied > target := the value of member whose fields are fields, each an
expression over the state before the step. member is the struct
target holds, or one member of the union of structs it holds; a field
the member declares as a literal (the tag) is its literal, and an optional
key not given is left out. The old value's fields are gone: nothing is
kept from what the target held. Throws where member is not one of
target's Schema, where a field the member requires is not given, or
where one it does not declare is.
Transition.ReplaceFields# type · packages/metakit/src/transitionReplace.ts:25
type ReplaceFields < Env , M > = {
readonly [K in keyof M as K extends '_tag' ? never : K ]: ExprInput <
Env ,
NoInfer < Path . Read < M [K ]>>
>
} The fields replace takes for a value of M: an expression per field,
each as a path reads it, the tag left out (the member's Schema gives it),
and an optional key optional.
Transition.run# function · packages/metakit/src/transitionRun.ts:328
function run < State , Input , Emit , Supplied >(
transition: Transition < State , Input , Emit , Supplied >,
state: NoInfer < State >,
input: NoInfer < Input >,
... args: SuppliedArgs < Supplied >
) : Result . Result < State , Refused > Execute transition on (state, input), returning Result<State, Refused>.
Transition.set# function · packages/metakit/src/transition.ts:73
function set < State , Input , V , Supplied = NoSupplied >(
target: StatePath < TransitionEnv < State , Input , Supplied >, V >,
value: ExprInput < TransitionEnv < State , Input , Supplied >, NoInferEach < V >>,
) : WriteEquation < State , Input , V , Supplied > Declare a write to a path inside state. Strictly requires a Path rooted
in state (such as state.balance from apply: ({ state, input }) => [...]).
The target decides the type: a value wider than the field is refused. Where the field is
a tagged union, a literal of any member is accepted, picked by its _tag.
Transition.setAt# function · packages/metakit/src/transitionLists.ts:396
function setAt <
State ,
Input ,
T extends ReadonlyArray < unknown >,
I extends ExprInput < TransitionEnv < State , Input , Supplied >, number > &
PositionFor < T >,
Supplied = NoSupplied ,
>(
list: StatePath < TransitionEnv < State , Input , Supplied >, T >,
index: I ,
value: ExprInput <
TransitionEnv < State , Input , Supplied >,
NoInferEach < ValueAt < T , I >>
>,
) : WriteEquation < State , Input , T , Supplied > Show all 15 lines The list with its element at index (counted from 0) replaced by value:
Transition.setAt(state.board, input.cell, input.player). The step is
refused where index names no element of the list or is not a safe
integer. Its value is Arr.with(list, index, value), which a guard or a
rule over the state after the step reads. Commutes with nothing; twice is
once.
Transition.step# function · packages/metakit/src/transitionRun.ts:88
function step < State , Input , Emit , Supplied >(
transition: Transition < State , Input , Emit , Supplied >,
state: NoInfer < State >,
input: NoInfer < Input >,
... args: SuppliedArgs < Supplied >
) : Result . Result < StepResult < State , Emit >, Refused > Execute transition on (state, input) with the values it is supplied,
returning the next state and the records it emits, or
Result.fail(Refused): where input or supplied is not a value of its
Schema (the proofs of a transition assume each is), where when is not
true, where a written or emitted value or an emit's condition is refused,
where a write targets a field inside an Option or under a missing parent,
or where it writes a field of a union's variants that the variant the
state holds there does not declare ({ _tag: 'Closed' } and a write of
phase.draft, which only Editing has), or where it writes the union's
tag alone to another variant.
All right-hand sides evaluate against the pre-state (simultaneous update).
A no-op returns the exact state reference it was given. A transition
that calls a foreign operation runs only with options.foreign holding
its implementation; otherwise the call is refused as unsupported.
Transition.StepResult# type · packages/metakit/src/transitionRun.ts:66
type StepResult < State , Emit > = {
readonly state: State
readonly emitted: ReadonlyArray < Emit >
} Transition.SuppliedArgs# type · packages/metakit/src/transitionRun.ts:50
type SuppliedArgs < Supplied > = [keyof Supplied ] extends [never ]
? [supplied? : NoInfer < Supplied > | undefined , options? : ReaderOptions ]
: [supplied: NoInfer < Supplied >, options? : ReaderOptions ] What step takes for a transition's supplied values: nothing for one that declares none.
Transition.SuppliedShape# type · packages/metakit/src/transitionShape.ts:152
type SuppliedShape = Readonly < Record < string , Schema . Top >> The Schema of each supplied value, by name: { now: Schema.Int, id: Schema.String }.
Transition.targetOf# function · packages/metakit/src/transitionShape.ts:155
function targetOf ( target: unknown , name: string ) : ReadonlyArray < string > A write's target, checked to lie under state, without the leading segment.
Transition.Transition# interface · packages/metakit/src/transitionShape.ts:103
interface Transition <
State ,
Input ,
Emit = never ,
Supplied = NoSupplied ,
InputServices = unknown ,
>
extends Pipeable . Pipeable {
readonly _tag: 'Transition'
readonly stateSchema: Option . Option <
Schema . Codec < State , unknown , unknown , unknown >
>
readonly inputSchema: Option . Option <
Schema . Codec < Input , unknown , InputServices , InputServices >
>
readonly suppliedSchema: Option . Option <
Schema . Codec < Supplied , unknown , unknown , unknown >
>
readonly when: ExprType < TransitionEnv < State , Input , Supplied >, boolean | null >
readonly writes: ReadonlyArray < WriteEquation < State , Input , unknown , Supplied >>
readonly emits: ReadonlyArray < EmitSpec >
readonly ensures: Option . Option <
ExprType < TransitionPostEnv < State , Input , Supplied >, boolean | null >
>
readonly _emit ?: () => Emit
readonly _supplied ?: () => Supplied
} Show all 27 lines A guarded, single-step transition over State, Input and the Supplied
values. InputServices bounds the services decoding or encoding its input
Schema needs: never for one that needs none, unknown where nothing
recorded it.
Transition.TransitionEnv# interface · packages/metakit/src/transitionShape.ts:20
interface TransitionEnv < State , Input , Supplied = NoSupplied > {
readonly state: State
readonly input: Input
readonly supplied: Supplied
} Environment shape seen by a Transition's when, writes, and emits.
supplied holds what no caller passes and no state holds (the time, a new
id, who asks): whoever runs the step reads or makes each value once and
passes it, so the step stays a function of its arguments.
Transition.TransitionPaths# interface · packages/metakit/src/transitionShape.ts:127
interface TransitionPaths < State , Input , Supplied > {
readonly state: PathAccessor <
TransitionEnv < State , Input , Supplied >,
State ,
true
>
readonly input: PathAccessor < TransitionEnv < State , Input , Supplied >, Input >
readonly supplied: PathAccessor <
TransitionEnv < State , Input , Supplied >,
Supplied
>
} The paths a transition's functions are given: one accessor per slice.
Transition.TransitionPostEnv# interface · packages/metakit/src/transitionShape.ts:57
interface TransitionPostEnv < State , Input , Supplied = NoSupplied > {
readonly state: State
readonly input: Input
readonly supplied: Supplied
readonly next: State
} Environment available inside Transition.make's optional ensures postcondition.
Transition.TransitionPostPaths# interface · packages/metakit/src/transitionShape.ts:65
interface TransitionPostPaths < State , Input , Supplied > {
readonly state: PathAccessor < TransitionPostEnv < State , Input , Supplied >, State >
readonly input: PathAccessor < TransitionPostEnv < State , Input , Supplied >, Input >
readonly supplied: PathAccessor <
TransitionPostEnv < State , Input , Supplied >,
Supplied
>
readonly next: PathAccessor < TransitionPostEnv < State , Input , Supplied >, State >
} Path accessors passed to Transition.make's optional ensures postcondition.
Transition.transitionProto# const · packages/metakit/src/transitionShape.ts:73
const transitionProto: {
[x: symbol ]: ( this: {
readonly writes: ReadonlyArray <{ readonly target: ReadonlyArray < string > }>
}) => string
pipe ( this: unknown ) : unknown
toJSON ( this: {
readonly writes: ReadonlyArray <{ readonly target: ReadonlyArray < string > }>
readonly emits: ReadonlyArray <{ readonly tag: string }>
}) : { _id: string ; writes: string []; emits: string [] }
toString ( this: {
readonly writes: ReadonlyArray <{ readonly target: ReadonlyArray < string > }>
}) : string
} Shared prototype giving every Transition Effect Pipeable and Inspectable support.
Transition.Way# const · packages/metakit/src/transitionWay.ts:39
const Way: Data . TaggedEnum . Constructor <
| { readonly _tag: 'set' }
| {
readonly _tag: 'replace'
readonly fields: ReadonlyArray < readonly [string , Node . Node ]>
}
| {
readonly _tag: 'move'
readonly key: string
readonly value: Node . Node
readonly toIndex: Node . Node
}
| { readonly _tag: 'add' ; readonly amount: Node . Node }
| {
readonly _tag: 'combine'
readonly op: Node . ForeignOp
readonly value: Node . Node
}
| { readonly _tag: 'append' ; readonly element: ReadonlyArray < Node . Node > }
| {
readonly _tag: 'insert'
readonly element: ReadonlyArray < Node . Node >
readonly key: string
}
| {
readonly _tag: 'removeWhere'
readonly test: Node . Node
readonly binder: Node . Binder
}
| {
readonly _tag: 'patch'
readonly key: string
readonly value: Node . Node
readonly set: ReadonlyArray < readonly [string , Node . Node ]>
readonly binder: Node . Binder
}
| {
readonly _tag: 'patchWhere'
readonly test: Node . Node
readonly set: ReadonlyArray < readonly [string , Node . Node ]>
readonly binder: Node . Binder
}
| { readonly _tag: 'include' ; readonly value: Node . Node }
| { readonly _tag: 'exclude' ; readonly value: Node . Node }
| {
readonly _tag: 'setAt'
readonly index: Node . Node
readonly value: Node . Node
}
> Show all 50 lines The shape of a write's value, with the operands used by the write laws.
Transition.wayOf# function · packages/metakit/src/transitionWay.ts:127
function wayOf ( write: Write ) : Way Recognise how a write changes its target. Unrecognised values are set.
Transition.WayOfWriting# type · packages/metakit/src/ops/ways.ts:23
type WayOfWriting =
| 'set'
| 'add'
| 'combine'
| 'append'
| 'insert'
| 'removeWhere'
| 'patch'
| 'patchWhere'
| 'include'
| 'exclude'
| 'move'
| 'replace'
| 'setAt' How a transition changes one path.
Transition.WaysByTag# type · packages/metakit/src/transitionWay.ts:42
type WaysByTag = {
readonly [W in WayOfWriting ]: Extract <
Way ,
{
readonly _tag: W
}
>
} Each way of writing, by its tag.
Transition.Why# const · packages/metakit/src/transitionRun.ts:26
const Why: Data . TaggedEnum . Constructor <
| { readonly _tag: 'Input' }
| { readonly _tag: 'Supplied' }
| { readonly _tag: 'UnknownMessage' ; readonly tag: string }
| { readonly _tag: 'Guard' ; readonly answer: false | null }
| { readonly _tag: 'GuardRefused' ; readonly refusal: Node . Refusal }
| { readonly _tag: 'Evaluation' ; readonly refusal: Node . Refusal }
| {
readonly _tag: 'Unwritable'
readonly target: ReadonlyArray < string >
readonly detail: string
}
> The reason a transition could not run or a machine could not dispatch its message.
Transition.WriteEquation# interface · packages/metakit/src/transitionShape.ts:27
interface WriteEquation < State , Input , V = unknown , Supplied = NoSupplied > {
readonly _tag: 'WriteEquation'
readonly target: ReadonlyArray < string >
readonly value: ExprType < TransitionEnv < State , Input , Supplied >, V >
} A single typed write target := value.
Transition.writtenPaths# function · packages/metakit/src/transition.ts:293
function writtenPaths (
write: Pick < WriteEquation < never , never , unknown , never >, 'target' | 'value' >,
) : ReadonlyArray < ReadonlyArray < string >> The paths a write changes, from the state: its target, or, for a patch
or patchWhere, each field it sets of every element (todos.*.title).