@typeonce/effect-machine 0.31.2 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -162
- package/dist/Machine.d.ts +495 -284
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +91 -111
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/atom.d.ts +3 -4
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/atom.js +0 -2
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/childRegistry.d.ts +52 -0
- package/dist/internal/machine/childRegistry.d.ts.map +1 -0
- package/dist/internal/machine/childRegistry.js +74 -0
- package/dist/internal/machine/childRegistry.js.map +1 -0
- package/dist/internal/machine/cluster.d.ts +2 -3
- package/dist/internal/machine/cluster.d.ts.map +1 -1
- package/dist/internal/machine/cluster.js.map +1 -1
- package/dist/internal/machine/configuration.d.ts.map +1 -1
- package/dist/internal/machine/configuration.js +14 -4
- package/dist/internal/machine/configuration.js.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts +1 -0
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +97 -53
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +4 -2
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/invocationDefinition.d.ts +35 -0
- package/dist/internal/machine/invocationDefinition.d.ts.map +1 -0
- package/dist/internal/machine/invocationDefinition.js +21 -0
- package/dist/internal/machine/invocationDefinition.js.map +1 -0
- package/dist/internal/machine/invocationEvent.d.ts +0 -2
- package/dist/internal/machine/invocationEvent.d.ts.map +1 -1
- package/dist/internal/machine/invocationEvent.js +0 -8
- package/dist/internal/machine/invocationEvent.js.map +1 -1
- package/dist/internal/machine/machine.d.ts +21 -43
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +134 -403
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +13 -19
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +63 -35
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.d.ts +6 -8
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +1 -0
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/protocol.d.ts +2 -2
- package/dist/internal/machine/protocol.d.ts.map +1 -1
- package/dist/internal/machine/protocol.js +4 -18
- package/dist/internal/machine/protocol.js.map +1 -1
- package/dist/internal/machine/readiness.d.ts +1 -1
- package/dist/internal/machine/readiness.d.ts.map +1 -1
- package/dist/internal/machine/requirements.d.ts +4 -0
- package/dist/internal/machine/requirements.d.ts.map +1 -0
- package/dist/internal/machine/requirements.js +2 -0
- package/dist/internal/machine/requirements.js.map +1 -0
- package/dist/internal/machine/runtime.d.ts +4 -58
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +1 -69
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/serialization.d.ts.map +1 -1
- package/dist/internal/machine/serialization.js +16 -0
- package/dist/internal/machine/serialization.js.map +1 -1
- package/dist/internal/machine/stateDefinition.d.ts +3 -1
- package/dist/internal/machine/stateDefinition.d.ts.map +1 -1
- package/dist/internal/machine/stateDefinition.js +36 -2
- package/dist/internal/machine/stateDefinition.js.map +1 -1
- package/dist/internal/machine/targetBuilder.d.ts +16 -0
- package/dist/internal/machine/targetBuilder.d.ts.map +1 -0
- package/dist/internal/machine/targetBuilder.js +333 -0
- package/dist/internal/machine/targetBuilder.js.map +1 -0
- package/dist/internal/machine/topology.js +3 -3
- package/dist/internal/machine/topology.js.map +1 -1
- package/dist/internal/machine/transition.d.ts +16 -0
- package/dist/internal/machine/transition.d.ts.map +1 -0
- package/dist/internal/machine/transition.js +2 -0
- package/dist/internal/machine/transition.js.map +1 -0
- package/dist/internal/testing/machine/finiteModel.d.ts.map +1 -1
- package/dist/internal/testing/machine/finiteModel.js +11 -13
- package/dist/internal/testing/machine/finiteModel.js.map +1 -1
- package/dist/internal/testing/machine/format.d.ts +7 -0
- package/dist/internal/testing/machine/format.d.ts.map +1 -0
- package/dist/internal/testing/machine/format.js +104 -0
- package/dist/internal/testing/machine/format.js.map +1 -0
- package/dist/internal/testing/machine/probe.d.ts +1 -1
- package/dist/internal/testing/machine/probe.d.ts.map +1 -1
- package/dist/internal/testing/machine/probe.js +1 -1
- package/dist/internal/testing/machine/probe.js.map +1 -1
- package/dist/internal/testing/machine/referenceModel.d.ts.map +1 -1
- package/dist/internal/testing/machine/referenceModel.js +15 -19
- package/dist/internal/testing/machine/referenceModel.js.map +1 -1
- package/dist/internal/testing/machine/trace.d.ts +1 -1
- package/dist/internal/testing/machine/trace.d.ts.map +1 -1
- package/dist/internal/testing/machine/trace.js +3 -3
- package/dist/internal/testing/machine/trace.js.map +1 -1
- package/dist/internal/testing/machine/value.d.ts +8 -0
- package/dist/internal/testing/machine/value.d.ts.map +1 -0
- package/dist/internal/testing/machine/value.js +82 -0
- package/dist/internal/testing/machine/value.js.map +1 -0
- package/dist/internal/testing/machine/verification.d.ts +2 -13
- package/dist/internal/testing/machine/verification.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.js +21 -113
- package/dist/internal/testing/machine/verification.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +89 -104
- package/dist/testing/MachineTest.d.ts.map +1 -1
- package/dist/testing/MachineTest.js +70 -84
- package/dist/testing/MachineTest.js.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.d.ts +10 -13
- package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.js +5 -8
- package/dist/unstable/cluster/ClusterMachine.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +26 -61
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js +17 -26
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/docs/agent-guide.md +45 -45
- package/docs/effect-atom-react.md +35 -63
- package/docs/machine-review.md +7 -7
- package/docs/root-api.md +259 -0
- package/package.json +1 -1
- package/src/Machine.ts +1053 -538
- package/src/internal/machine/atom.ts +3 -13
- package/src/internal/machine/childRegistry.ts +141 -0
- package/src/internal/machine/cluster.ts +5 -14
- package/src/internal/machine/configuration.ts +20 -4
- package/src/internal/machine/executionPlan.ts +109 -52
- package/src/internal/machine/invocation.ts +10 -6
- package/src/internal/machine/invocationDefinition.ts +52 -0
- package/src/internal/machine/invocationEvent.ts +0 -8
- package/src/internal/machine/machine.ts +222 -716
- package/src/internal/machine/planner.ts +74 -62
- package/src/internal/machine/process.ts +14 -21
- package/src/internal/machine/protocol.ts +9 -32
- package/src/internal/machine/readiness.ts +1 -0
- package/src/internal/machine/requirements.ts +11 -0
- package/src/internal/machine/runtime.ts +17 -186
- package/src/internal/machine/serialization.ts +22 -0
- package/src/internal/machine/stateDefinition.ts +36 -3
- package/src/internal/machine/targetBuilder.ts +525 -0
- package/src/internal/machine/topology.ts +3 -3
- package/src/internal/machine/transition.ts +26 -0
- package/src/internal/testing/machine/finiteModel.ts +23 -24
- package/src/internal/testing/machine/format.ts +120 -0
- package/src/internal/testing/machine/probe.ts +4 -4
- package/src/internal/testing/machine/referenceModel.ts +25 -17
- package/src/internal/testing/machine/trace.ts +4 -4
- package/src/internal/testing/machine/value.ts +77 -0
- package/src/internal/testing/machine/verification.ts +904 -1109
- package/src/testing/MachineTest.ts +103 -114
- package/src/unstable/cluster/ClusterMachine.ts +10 -20
- package/src/unstable/reactivity/AtomMachine.ts +42 -79
|
@@ -9,15 +9,19 @@ import type * as Schema from "effect/Schema";
|
|
|
9
9
|
import type { FastCheck } from "effect/testing";
|
|
10
10
|
import type { EnsureExecutable } from "../internal/machine/readiness.js";
|
|
11
11
|
import type { SchemaArbitraryReport } from "../internal/testing/machine/arbitrary.js";
|
|
12
|
+
import * as ExplorationImpl from "../internal/testing/machine/exploration.js";
|
|
12
13
|
import type { FiniteModel } from "../internal/testing/machine/finiteModel.js";
|
|
13
|
-
import
|
|
14
|
-
import * as
|
|
14
|
+
import * as InvariantTest from "../internal/testing/machine/invariant.js";
|
|
15
|
+
import * as ProbeTest from "../internal/testing/machine/probe.js";
|
|
16
|
+
import * as ReferenceModel from "../internal/testing/machine/referenceModel.js";
|
|
17
|
+
import type * as RuntimeTest from "../internal/testing/machine/runtime.js";
|
|
18
|
+
import * as RuntimeInvariantTest from "../internal/testing/machine/runtimeInvariant.js";
|
|
15
19
|
import type { VerificationError } from "../internal/testing/machine/verification.js";
|
|
16
20
|
import type * as Machine from "../Machine.js";
|
|
17
|
-
export { advanceCommand, type CausalRuntimeAssertionContext, type CausalRuntimeCommandActual, CausalRuntimeCommandFailure, type CausalRuntimeCommandRecord, type CausalRuntimeCommandResult, type CausalRuntimeInspectionContext, type CausalRuntimeModelOptions, type CausalRuntimeModelStep, type CausalRuntimeTranscript, type CausalVerificationAwaitContext, type CausalVerificationOptions, type CausalVerificationTranscript, checkpointCommand, type EnqueuedRuntimeAssertionContext, type EnqueuedRuntimeCommandActual, type EnqueuedRuntimeCommandRecord, type EnqueuedRuntimeInspectionContext, type EnqueuedRuntimeModelOptions, type EnqueuedRuntimeModelStep, type EnqueuedRuntimeTranscript, formatCausalTranscript, formatEnqueuedTranscript, formatRuntimeTranscript, runCausalCommands, runEnqueuedCommands, runRuntimeCommands, type RuntimeAssertionContext, type RuntimeAwait, type RuntimeCommand, type RuntimeCommandActual, RuntimeCommandFailure, type RuntimeCommandRecord, type RuntimeCommandResult, type RuntimeCommands, runtimeCommands, type RuntimeCommandsDiagnostics, type RuntimeCommandsOptions, type RuntimeInspectionContext, type RuntimeModelOptions, type RuntimeModelStep, RuntimeObservationError, RuntimeSynchronization, type RuntimeTranscript, sendCommand, stopCommand, verifyCausalCommands } from "../internal/testing/machine/
|
|
18
|
-
export type { SchemaArbitraryOpaqueFilterWarning, SchemaArbitraryReport, SchemaArbitraryWarning } from "../internal/testing/machine/
|
|
19
|
-
export { compileModel, type FiniteAtomicState, type FiniteAutomaticTransition, type FiniteCompoundState, type FiniteEventTransition, type FiniteFinalState, type FiniteHistoryMutation, type FiniteHistoryScenario, type FiniteHistoryState, type FiniteHistoryTransfer, type FiniteModel, type FiniteModelDiagnostics, type FiniteModelOptions, type FiniteModels, finiteModels, type FiniteParallelState, type FiniteState, type FiniteTransition, type FiniteTransitionTrigger } from "../internal/testing/machine/
|
|
20
|
-
export { ModelVerificationError, type ModelVerificationField, type ModelVerificationLocation, type ModelVerificationMismatch, type ReferenceCompletion, type ReferenceHistoryRecord, type ReferenceInitialStep, type ReferenceMicrostep, type ReferenceState, type ReferenceStateValue, type ReferenceStep, type ReferenceTrace, type ReferenceTransition } from "../internal/testing/machine/
|
|
21
|
+
export { advanceCommand, type CausalRuntimeAssertionContext, type CausalRuntimeCommandActual, CausalRuntimeCommandFailure, type CausalRuntimeCommandRecord, type CausalRuntimeCommandResult, type CausalRuntimeInspectionContext, type CausalRuntimeModelOptions, type CausalRuntimeModelStep, type CausalRuntimeTranscript, type CausalVerificationAwaitContext, type CausalVerificationOptions, type CausalVerificationTranscript, checkpointCommand, type EnqueuedRuntimeAssertionContext, type EnqueuedRuntimeCommandActual, type EnqueuedRuntimeCommandRecord, type EnqueuedRuntimeInspectionContext, type EnqueuedRuntimeModelOptions, type EnqueuedRuntimeModelStep, type EnqueuedRuntimeTranscript, formatCausalTranscript, formatEnqueuedTranscript, formatRuntimeTranscript, runCausalCommands, runEnqueuedCommands, runRuntimeCommands, type RuntimeAssertionContext, type RuntimeAwait, type RuntimeCommand, type RuntimeCommandActual, RuntimeCommandFailure, type RuntimeCommandRecord, type RuntimeCommandResult, type RuntimeCommands, runtimeCommands, type RuntimeCommandsDiagnostics, type RuntimeCommandsOptions, type RuntimeInspectionContext, type RuntimeModelOptions, type RuntimeModelStep, RuntimeObservationError, RuntimeSynchronization, type RuntimeTranscript, sendCommand, stopCommand, verifyCausalCommands } from "../internal/testing/machine/runtime.js";
|
|
22
|
+
export type { SchemaArbitraryOpaqueFilterWarning, SchemaArbitraryReport, SchemaArbitraryWarning } from "../internal/testing/machine/arbitrary.js";
|
|
23
|
+
export { compileModel, type FiniteAtomicState, type FiniteAutomaticTransition, type FiniteCompoundState, type FiniteEventTransition, type FiniteFinalState, type FiniteHistoryMutation, type FiniteHistoryScenario, type FiniteHistoryState, type FiniteHistoryTransfer, type FiniteModel, type FiniteModelDiagnostics, type FiniteModelOptions, type FiniteModels, finiteModels, type FiniteParallelState, type FiniteState, type FiniteTransition, type FiniteTransitionTrigger } from "../internal/testing/machine/finiteModel.js";
|
|
24
|
+
export { ModelVerificationError, type ModelVerificationField, type ModelVerificationLocation, type ModelVerificationMismatch, type ReferenceCompletion, type ReferenceHistoryRecord, type ReferenceInitialStep, type ReferenceMicrostep, type ReferenceState, type ReferenceStateValue, type ReferenceStep, type ReferenceTrace, type ReferenceTransition } from "../internal/testing/machine/referenceModel.js";
|
|
21
25
|
/**
|
|
22
26
|
* Purely interprets a finite hierarchical model without compiling a
|
|
23
27
|
* machine.
|
|
@@ -43,10 +47,10 @@ type RootReadyMachine<M extends AnyMachine> = ReadyMachine<M> & Machine.Machine.
|
|
|
43
47
|
* @since 0.4.0
|
|
44
48
|
*/
|
|
45
49
|
export type Scenario<M extends AnyMachine> = Machine.Machine.InputSchema<M> extends typeof Schema.Void ? {
|
|
46
|
-
readonly events: ReadonlyArray<Machine.Machine.InputEvent<M
|
|
50
|
+
readonly events: ReadonlyArray<Machine.Machine.EventInput<Machine.Machine.InputEvent<M>>>;
|
|
47
51
|
} : {
|
|
48
52
|
readonly input: InputValue<M>;
|
|
49
|
-
readonly events: ReadonlyArray<Machine.Machine.InputEvent<M
|
|
53
|
+
readonly events: ReadonlyArray<Machine.Machine.EventInput<Machine.Machine.InputEvent<M>>>;
|
|
50
54
|
};
|
|
51
55
|
/**
|
|
52
56
|
* Options for schema-derived scenario generation.
|
|
@@ -113,22 +117,19 @@ export interface Scenarios<M extends AnyMachine> {
|
|
|
113
117
|
*
|
|
114
118
|
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
115
119
|
* class Reset extends Schema.TaggedClass<Reset>("Reset")("Reset", {}) {}
|
|
116
|
-
* const States = Machine.
|
|
120
|
+
* const States = Machine.state({ initial: "Idle", states: { Idle } })
|
|
117
121
|
* const machine = Machine.make({
|
|
118
|
-
*
|
|
119
|
-
* events: Machine.
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* resolve: ({ target }) => target.from()
|
|
123
|
-
* }
|
|
124
|
-
* }).handle({
|
|
122
|
+
* root: States,
|
|
123
|
+
* events: Machine.eventsFromSchemas(Reset),
|
|
124
|
+
* initialConfiguration: root => root.resolve(({ target }) => target.from(tree => tree.Idle.from()))
|
|
125
|
+
* }).handle({ states: {
|
|
125
126
|
* Idle: {
|
|
126
127
|
* on: {
|
|
127
128
|
* Reset: (to) =>
|
|
128
|
-
* to.
|
|
129
|
+
* to.branch.Idle().resolve(({ target }) => target.from())
|
|
129
130
|
* }
|
|
130
131
|
* }
|
|
131
|
-
* })
|
|
132
|
+
* } })
|
|
132
133
|
*
|
|
133
134
|
* const generated = MachineTest.scenarios(machine, { maxEvents: 5 })
|
|
134
135
|
* ```
|
|
@@ -162,7 +163,7 @@ export interface Microstep<M extends AnyMachine, Requirements = Machine.Machine.
|
|
|
162
163
|
readonly transitions: ReadonlyArray<Machine.Machine.RetainedTransition<StatePath<M>, Machine.Machine.TagOf<Machine.Machine.Events<M>[number]>, StateNodePath<M>>>;
|
|
163
164
|
readonly commands: ReadonlyArray<Machine.Command>;
|
|
164
165
|
readonly raisedEvents: ReadonlyArray<Machine.Machine.Event<M>>;
|
|
165
|
-
readonly emittedEvents: ReadonlyArray<Machine.Machine.
|
|
166
|
+
readonly emittedEvents: ReadonlyArray<Machine.Machine.EmittedEvent<M>>;
|
|
166
167
|
readonly exitPaths: ReadonlyArray<string>;
|
|
167
168
|
readonly entryPaths: ReadonlyArray<string>;
|
|
168
169
|
readonly changed: boolean;
|
|
@@ -178,7 +179,7 @@ export type InitialPlan<M extends AnyMachine> = {
|
|
|
178
179
|
readonly initialEntryPaths: ReadonlyArray<StatePath<M>>;
|
|
179
180
|
readonly state: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
180
181
|
readonly commands: ReadonlyArray<Machine.Command>;
|
|
181
|
-
readonly emittedEvents: ReadonlyArray<Machine.Machine.
|
|
182
|
+
readonly emittedEvents: ReadonlyArray<Machine.Machine.EmittedEvent<M>>;
|
|
182
183
|
readonly microsteps: ReadonlyArray<Microstep<M, Machine.Machine.InitialServices<M> | Machine.Machine.Services<M>>>;
|
|
183
184
|
} & PlanCompletion<M>;
|
|
184
185
|
/**
|
|
@@ -188,9 +189,10 @@ export type InitialPlan<M extends AnyMachine> = {
|
|
|
188
189
|
* @since 0.4.0
|
|
189
190
|
*/
|
|
190
191
|
export type EventPlan<M extends AnyMachine> = {
|
|
192
|
+
readonly event: Machine.Machine.InputEvent<M>;
|
|
191
193
|
readonly next: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
192
194
|
readonly commands: ReadonlyArray<Machine.Command>;
|
|
193
|
-
readonly emittedEvents: ReadonlyArray<Machine.Machine.
|
|
195
|
+
readonly emittedEvents: ReadonlyArray<Machine.Machine.EmittedEvent<M>>;
|
|
194
196
|
readonly microsteps: ReadonlyArray<Microstep<M>>;
|
|
195
197
|
} & PlanCompletion<M>;
|
|
196
198
|
/**
|
|
@@ -252,9 +254,10 @@ export type ProbeMicrostep<M extends AnyMachine> = Omit<Microstep<M>, "transitio
|
|
|
252
254
|
* @since 0.4.0
|
|
253
255
|
*/
|
|
254
256
|
export type ProbePlan<M extends AnyMachine> = {
|
|
257
|
+
readonly event: Machine.Machine.InputEvent<M>;
|
|
255
258
|
readonly next: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
256
259
|
readonly commands: ReadonlyArray<Machine.Command>;
|
|
257
|
-
readonly emittedEvents: ReadonlyArray<Machine.Machine.
|
|
260
|
+
readonly emittedEvents: ReadonlyArray<Machine.Machine.EmittedEvent<M>>;
|
|
258
261
|
readonly microsteps: ReadonlyArray<ProbeMicrostep<M>>;
|
|
259
262
|
} & PlanCompletion<M>;
|
|
260
263
|
/**
|
|
@@ -289,12 +292,12 @@ export interface ProbeStep<M extends AnyMachine> {
|
|
|
289
292
|
*/
|
|
290
293
|
export interface Probe<M extends AnyMachine, Error = never, Output = never> {
|
|
291
294
|
readonly machine: M;
|
|
292
|
-
readonly ref: Machine.MachineRef<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Machine.Machine.InputEvent<M
|
|
293
|
-
readonly sendAndAwait: (event: Machine.Machine.InputEvent<M
|
|
295
|
+
readonly ref: Machine.MachineRef<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Machine.Machine.EventInput<Machine.Machine.InputEvent<M>>, Error, Output>;
|
|
296
|
+
readonly sendAndAwait: (event: Machine.Machine.EventInput<Machine.Machine.InputEvent<M>>) => Effect.Effect<ProbeStep<M>, Error | Machine.MachineSchemaDecodeError | Machine.StoppedError>;
|
|
294
297
|
/** Constructors for asynchronous observation after a causal command. */
|
|
295
298
|
readonly await: {
|
|
296
|
-
readonly none:
|
|
297
|
-
readonly until: (predicate: (snapshot: Machine.RuntimeSnapshot<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Error, Output>) => boolean) =>
|
|
299
|
+
readonly none: RuntimeTest.RuntimeAwait<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Error, Output>;
|
|
300
|
+
readonly until: (predicate: (snapshot: Machine.RuntimeSnapshot<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Error, Output>) => boolean) => RuntimeTest.RuntimeAwait<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Error, Output>;
|
|
298
301
|
};
|
|
299
302
|
}
|
|
300
303
|
/**
|
|
@@ -304,7 +307,7 @@ export interface Probe<M extends AnyMachine, Error = never, Output = never> {
|
|
|
304
307
|
* @category errors
|
|
305
308
|
* @since 0.4.0
|
|
306
309
|
*/
|
|
307
|
-
export { ProbeUnavailableError } from "../internal/testing/machine/
|
|
310
|
+
export { ProbeUnavailableError } from "../internal/testing/machine/probe.js";
|
|
308
311
|
/**
|
|
309
312
|
* Attaches testing-only causal event delivery to a running statechart.
|
|
310
313
|
*
|
|
@@ -320,15 +323,12 @@ export { ProbeUnavailableError } from "../internal/testing/machine/verification.
|
|
|
320
323
|
* import { MachineTest } from "@typeonce/effect-machine/testing"
|
|
321
324
|
*
|
|
322
325
|
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
323
|
-
* const States = Machine.
|
|
326
|
+
* const States = Machine.state({ initial: "Idle", states: { Idle } })
|
|
324
327
|
* const machine = Machine.make({
|
|
325
|
-
*
|
|
326
|
-
* events: Machine.
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
* resolve: ({ target }) => target.from()
|
|
330
|
-
* }
|
|
331
|
-
* }).handle({ Idle: {} })
|
|
328
|
+
* root: States,
|
|
329
|
+
* events: Machine.eventsFromSchemas(),
|
|
330
|
+
* initialConfiguration: root => root.resolve(({ target }) => target.from(tree => tree.Idle.from()))
|
|
331
|
+
* }).handle({ states: { Idle: {} } })
|
|
332
332
|
*
|
|
333
333
|
* const program = Effect.gen(function*() {
|
|
334
334
|
* const ref = yield* Machine.start(machine)
|
|
@@ -339,7 +339,7 @@ export { ProbeUnavailableError } from "../internal/testing/machine/verification.
|
|
|
339
339
|
* @category runtime testing
|
|
340
340
|
* @since 0.4.0
|
|
341
341
|
*/
|
|
342
|
-
export declare const probe: <M extends AnyMachine, Error, Output>(machine: ReadyMachine<M>, ref: Machine.MachineRef<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Machine.Machine.InputEvent<M
|
|
342
|
+
export declare const probe: <M extends AnyMachine, Error, Output>(machine: ReadyMachine<M>, ref: Machine.MachineRef<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Machine.Machine.EventInput<Machine.Machine.InputEvent<M>>, Error, Output>) => Effect.Effect<Probe<M, Error, Output>, ProbeTest.ProbeUnavailableError>;
|
|
343
343
|
/**
|
|
344
344
|
* The runtime error channel exposed by a managed reference for a machine.
|
|
345
345
|
*
|
|
@@ -355,8 +355,8 @@ export type RuntimeInvariantErrorChannel<M extends AnyMachine> = Machine.Machine
|
|
|
355
355
|
*/
|
|
356
356
|
export interface CausalRuntimeEvidenceRecord<M extends AnyMachine, Error, Output> {
|
|
357
357
|
readonly index: number;
|
|
358
|
-
readonly command:
|
|
359
|
-
readonly actual:
|
|
358
|
+
readonly command: RuntimeTest.RuntimeCommand<Machine.Machine.InputEvent<M>>;
|
|
359
|
+
readonly actual: RuntimeTest.CausalRuntimeCommandActual<M, Error, Output, unknown>;
|
|
360
360
|
}
|
|
361
361
|
/**
|
|
362
362
|
* The model-independent evidence shared by causal command transcripts.
|
|
@@ -365,7 +365,7 @@ export interface CausalRuntimeEvidenceRecord<M extends AnyMachine, Error, Output
|
|
|
365
365
|
* @since 0.4.0
|
|
366
366
|
*/
|
|
367
367
|
export interface CausalRuntimeEvidence<M extends AnyMachine, Error, Output> {
|
|
368
|
-
readonly commands: ReadonlyArray<
|
|
368
|
+
readonly commands: ReadonlyArray<RuntimeTest.RuntimeCommand<Machine.Machine.InputEvent<M>>>;
|
|
369
369
|
readonly initial: Machine.RuntimeSnapshot<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Error, Output>;
|
|
370
370
|
readonly records: ReadonlyArray<CausalRuntimeEvidenceRecord<M, Error, Output>>;
|
|
371
371
|
readonly final: Machine.RuntimeSnapshot<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Error, Output>;
|
|
@@ -392,8 +392,8 @@ export type RuntimeSnapshotObservation = "initial" | "command" | "awaited" | "fi
|
|
|
392
392
|
*/
|
|
393
393
|
export interface RuntimeInvariantRecord<M extends AnyMachine> {
|
|
394
394
|
readonly index: number;
|
|
395
|
-
readonly command:
|
|
396
|
-
readonly result:
|
|
395
|
+
readonly command: RuntimeTest.RuntimeCommand<Machine.Machine.InputEvent<M>>;
|
|
396
|
+
readonly result: RuntimeTest.CausalRuntimeCommandResult<M>;
|
|
397
397
|
readonly snapshot: Machine.RuntimeSnapshot<Machine.Machine.Snapshot<Machine.Machine.States<M>>, RuntimeInvariantErrorChannel<M>, Machine.Machine.Output<M>>;
|
|
398
398
|
readonly awaited: ReadonlyArray<Machine.RuntimeSnapshot<Machine.Machine.Snapshot<Machine.Machine.States<M>>, RuntimeInvariantErrorChannel<M>, Machine.Machine.Output<M>>>;
|
|
399
399
|
}
|
|
@@ -404,7 +404,7 @@ export interface RuntimeInvariantRecord<M extends AnyMachine> {
|
|
|
404
404
|
* @since 0.4.0
|
|
405
405
|
*/
|
|
406
406
|
export interface RuntimeInvariantTranscript<M extends AnyMachine> {
|
|
407
|
-
readonly commands: ReadonlyArray<
|
|
407
|
+
readonly commands: ReadonlyArray<RuntimeTest.RuntimeCommand<Machine.Machine.InputEvent<M>>>;
|
|
408
408
|
readonly initial: Machine.RuntimeSnapshot<Machine.Machine.Snapshot<Machine.Machine.States<M>>, RuntimeInvariantErrorChannel<M>, Machine.Machine.Output<M>>;
|
|
409
409
|
readonly records: ReadonlyArray<RuntimeInvariantRecord<M>>;
|
|
410
410
|
readonly final: Machine.RuntimeSnapshot<Machine.Machine.Snapshot<Machine.Machine.States<M>>, RuntimeInvariantErrorChannel<M>, Machine.Machine.Output<M>>;
|
|
@@ -423,8 +423,8 @@ export interface RuntimeSnapshotInvariantContext<M extends AnyMachine> {
|
|
|
423
423
|
readonly phase: RuntimeSnapshotObservation;
|
|
424
424
|
readonly commandIndex: number | undefined;
|
|
425
425
|
readonly awaitedIndex: number | undefined;
|
|
426
|
-
readonly command:
|
|
427
|
-
readonly result:
|
|
426
|
+
readonly command: RuntimeTest.RuntimeCommand<Machine.Machine.InputEvent<M>> | undefined;
|
|
427
|
+
readonly result: RuntimeTest.CausalRuntimeCommandResult<M> | undefined;
|
|
428
428
|
}
|
|
429
429
|
/**
|
|
430
430
|
* Evidence passed to an invariant for one completed causal command.
|
|
@@ -438,8 +438,8 @@ export interface RuntimeCommandInvariantContext<M extends AnyMachine> {
|
|
|
438
438
|
readonly record: RuntimeInvariantRecord<M>;
|
|
439
439
|
readonly previous: RuntimeInvariantRecord<M> | undefined;
|
|
440
440
|
readonly index: number;
|
|
441
|
-
readonly command:
|
|
442
|
-
readonly result:
|
|
441
|
+
readonly command: RuntimeTest.RuntimeCommand<Machine.Machine.InputEvent<M>>;
|
|
442
|
+
readonly result: RuntimeTest.CausalRuntimeCommandResult<M>;
|
|
443
443
|
readonly snapshot: RuntimeInvariantRecord<M>["snapshot"];
|
|
444
444
|
readonly awaited: RuntimeInvariantRecord<M>["awaited"];
|
|
445
445
|
}
|
|
@@ -564,7 +564,7 @@ export interface RuntimeInvariantViolation<M extends AnyMachine = AnyMachine> {
|
|
|
564
564
|
readonly commandIndex: number | undefined;
|
|
565
565
|
readonly awaitedIndex?: number;
|
|
566
566
|
readonly phase?: RuntimeSnapshotObservation;
|
|
567
|
-
readonly command?:
|
|
567
|
+
readonly command?: RuntimeTest.RuntimeCommand<Machine.Machine.InputEvent<M>>;
|
|
568
568
|
readonly message: string;
|
|
569
569
|
}
|
|
570
570
|
/**
|
|
@@ -573,21 +573,21 @@ export interface RuntimeInvariantViolation<M extends AnyMachine = AnyMachine> {
|
|
|
573
573
|
* @category errors
|
|
574
574
|
* @since 0.4.0
|
|
575
575
|
*/
|
|
576
|
-
export { RuntimeInvariantError } from "../internal/testing/machine/
|
|
576
|
+
export { RuntimeInvariantError } from "../internal/testing/machine/runtimeInvariant.js";
|
|
577
577
|
/**
|
|
578
578
|
* Checks runtime invariants and returns their complete non-vacuity report.
|
|
579
579
|
*
|
|
580
580
|
* @category verification
|
|
581
581
|
* @since 0.4.0
|
|
582
582
|
*/
|
|
583
|
-
export declare const checkRuntimeInvariants: <M extends AnyMachine, Error, Output>(machine: M, transcript: CausalRuntimeEvidence<M, Error, Output>, invariants: ReadonlyArray<RuntimeInvariant<M>>) => Effect.Effect<RuntimeInvariantReport,
|
|
583
|
+
export declare const checkRuntimeInvariants: <M extends AnyMachine, Error, Output>(machine: M, transcript: CausalRuntimeEvidence<M, Error, Output>, invariants: ReadonlyArray<RuntimeInvariant<M>>) => Effect.Effect<RuntimeInvariantReport, RuntimeInvariantTest.RuntimeInvariantError<M>>;
|
|
584
584
|
/**
|
|
585
585
|
* Asserts runtime invariants against an existing causal transcript.
|
|
586
586
|
*
|
|
587
587
|
* @category verification
|
|
588
588
|
* @since 0.4.0
|
|
589
589
|
*/
|
|
590
|
-
export declare const assertRuntimeInvariants: <M extends AnyMachine, Error, Output>(machine: M, transcript: CausalRuntimeEvidence<M, Error, Output>, invariants: ReadonlyArray<RuntimeInvariant<M>>) => Effect.Effect<void,
|
|
590
|
+
export declare const assertRuntimeInvariants: <M extends AnyMachine, Error, Output>(machine: M, transcript: CausalRuntimeEvidence<M, Error, Output>, invariants: ReadonlyArray<RuntimeInvariant<M>>) => Effect.Effect<void, RuntimeInvariantTest.RuntimeInvariantError<M>>;
|
|
591
591
|
/**
|
|
592
592
|
* One disagreement between pure planning and a causally processed send.
|
|
593
593
|
*
|
|
@@ -596,7 +596,7 @@ export declare const assertRuntimeInvariants: <M extends AnyMachine, Error, Outp
|
|
|
596
596
|
*/
|
|
597
597
|
export interface PlannerRuntimeAgreementViolation<M extends AnyMachine = AnyMachine> {
|
|
598
598
|
readonly commandIndex: number;
|
|
599
|
-
readonly command:
|
|
599
|
+
readonly command: RuntimeTest.RuntimeCommand<Machine.Machine.InputEvent<M>>;
|
|
600
600
|
readonly field: "planning" | "handled" | "configurationChanged" | "planNext" | "after" | "completion" | "commands" | "emittedEvents" | "microsteps";
|
|
601
601
|
readonly message: string;
|
|
602
602
|
}
|
|
@@ -606,14 +606,14 @@ export interface PlannerRuntimeAgreementViolation<M extends AnyMachine = AnyMach
|
|
|
606
606
|
* @category errors
|
|
607
607
|
* @since 0.4.0
|
|
608
608
|
*/
|
|
609
|
-
export { PlannerRuntimeAgreementError } from "../internal/testing/machine/
|
|
609
|
+
export { PlannerRuntimeAgreementError } from "../internal/testing/machine/runtimeInvariant.js";
|
|
610
610
|
/**
|
|
611
611
|
* Checks that every processed public send agrees with a fresh pure plan.
|
|
612
612
|
*
|
|
613
613
|
* @category verification
|
|
614
614
|
* @since 0.4.0
|
|
615
615
|
*/
|
|
616
|
-
export declare const assertPlannerRuntimeAgreement: <M extends AnyMachine, Error, Output>(machine: RootReadyMachine<M>, transcript: CausalRuntimeEvidence<M, Error, Output>) => Effect.Effect<void,
|
|
616
|
+
export declare const assertPlannerRuntimeAgreement: <M extends AnyMachine, Error, Output>(machine: RootReadyMachine<M>, transcript: CausalRuntimeEvidence<M, Error, Output>) => Effect.Effect<void, RuntimeInvariantTest.PlannerRuntimeAgreementError<M>, RunServices<M>>;
|
|
617
617
|
/**
|
|
618
618
|
* The result of evaluating one semantic invariant.
|
|
619
619
|
*
|
|
@@ -791,15 +791,12 @@ export declare const Invariant: {
|
|
|
791
791
|
* class Count extends Schema.TaggedClass<Count>("Count")("Count", {
|
|
792
792
|
* value: Schema.Number
|
|
793
793
|
* }) {}
|
|
794
|
-
* const States = Machine.
|
|
794
|
+
* const States = Machine.state({ initial: "Count", states: { Count } })
|
|
795
795
|
* const machine = Machine.make({
|
|
796
|
-
*
|
|
797
|
-
* events: Machine.
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
* resolve: ({ target }) => target.decoded(new Count({ value: 0 }))
|
|
801
|
-
* }
|
|
802
|
-
* }).handle({ Count: {} })
|
|
796
|
+
* root: States,
|
|
797
|
+
* events: Machine.eventsFromSchemas(),
|
|
798
|
+
* initialConfiguration: root => root.resolve(({ target }) => target.from(tree => tree.Count.decoded(new Count({ value: 0 }))))
|
|
799
|
+
* }).handle({ states: { Count: {} } })
|
|
803
800
|
*
|
|
804
801
|
* const nonNegative = MachineTest.invariants(machine).state(
|
|
805
802
|
* "count is non-negative",
|
|
@@ -875,7 +872,7 @@ export interface InvariantViolation<M extends AnyMachine = AnyMachine> {
|
|
|
875
872
|
* @category errors
|
|
876
873
|
* @since 0.4.0
|
|
877
874
|
*/
|
|
878
|
-
export { InvariantError } from "../internal/testing/machine/
|
|
875
|
+
export { InvariantError } from "../internal/testing/machine/invariant.js";
|
|
879
876
|
/**
|
|
880
877
|
* Checks user-defined semantic invariants against an existing planner trace.
|
|
881
878
|
*
|
|
@@ -886,7 +883,7 @@ export { InvariantError } from "../internal/testing/machine/verification.js";
|
|
|
886
883
|
* @category verification
|
|
887
884
|
* @since 0.4.0
|
|
888
885
|
*/
|
|
889
|
-
export declare const checkInvariants: <M extends AnyMachine>(machine: M, trace: Trace<M>, invariants: ReadonlyArray<Invariant<M>>) => Effect.Effect<InvariantReport,
|
|
886
|
+
export declare const checkInvariants: <M extends AnyMachine>(machine: M, trace: Trace<M>, invariants: ReadonlyArray<Invariant<M>>) => Effect.Effect<InvariantReport, InvariantTest.InvariantError<M>>;
|
|
890
887
|
/**
|
|
891
888
|
* Asserts user-defined semantic invariants and discards the success report.
|
|
892
889
|
*
|
|
@@ -897,7 +894,7 @@ export declare const checkInvariants: <M extends AnyMachine>(machine: M, trace:
|
|
|
897
894
|
* @category verification
|
|
898
895
|
* @since 0.4.0
|
|
899
896
|
*/
|
|
900
|
-
export declare const assertInvariants: <M extends AnyMachine>(machine: M, trace: Trace<M>, invariants: ReadonlyArray<Invariant<M>>) => Effect.Effect<void,
|
|
897
|
+
export declare const assertInvariants: <M extends AnyMachine>(machine: M, trace: Trace<M>, invariants: ReadonlyArray<Invariant<M>>) => Effect.Effect<void, InvariantTest.InvariantError<M>>;
|
|
901
898
|
/**
|
|
902
899
|
* User-defined identity for a logical exploration state.
|
|
903
900
|
*
|
|
@@ -1083,23 +1080,20 @@ export type ExploreOptions<M extends AnyMachine, Key extends ExplorationKey = Ex
|
|
|
1083
1080
|
* value: Schema.Number
|
|
1084
1081
|
* }) {}
|
|
1085
1082
|
* class Increment extends Schema.TaggedClass<Increment>("Increment")("Increment", {}) {}
|
|
1086
|
-
* const States = Machine.
|
|
1083
|
+
* const States = Machine.state({ initial: "Count", states: { Count } })
|
|
1087
1084
|
* const machine = Machine.make({
|
|
1088
|
-
*
|
|
1089
|
-
* events: Machine.
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
* resolve: ({ target }) => target.decoded(new Count({ value: 0 }))
|
|
1093
|
-
* }
|
|
1094
|
-
* }).handle({
|
|
1085
|
+
* root: States,
|
|
1086
|
+
* events: Machine.eventsFromSchemas(Increment),
|
|
1087
|
+
* initialConfiguration: root => root.resolve(({ target }) => target.from(tree => tree.Count.decoded(new Count({ value: 0 }))))
|
|
1088
|
+
* }).handle({ states: {
|
|
1095
1089
|
* Count: {
|
|
1096
1090
|
* on: {
|
|
1097
1091
|
* Increment: (to) =>
|
|
1098
|
-
* to.
|
|
1092
|
+
* to.branch.Count().resolve(({ state, target }) =>
|
|
1099
1093
|
* target.decoded(new Count({ value: state.value + 1 })))
|
|
1100
1094
|
* }
|
|
1101
1095
|
* }
|
|
1102
|
-
* })
|
|
1096
|
+
* } })
|
|
1103
1097
|
*
|
|
1104
1098
|
* const explored = MachineTest.explore(machine, {
|
|
1105
1099
|
* events: ({ snapshot }) => snapshot.value.value < 2 ? [new Increment({})] : [],
|
|
@@ -1110,7 +1104,7 @@ export type ExploreOptions<M extends AnyMachine, Key extends ExplorationKey = Ex
|
|
|
1110
1104
|
* @category exploration
|
|
1111
1105
|
* @since 0.4.0
|
|
1112
1106
|
*/
|
|
1113
|
-
export declare const explore: <M extends AnyMachine, Key extends ExplorationKey>(machine: RootReadyMachine<M>, options: ExploreOptions<M, Key>) => Effect.Effect<Exploration<M, Key>, RunFailure<RunError<M>, M> |
|
|
1107
|
+
export declare const explore: <M extends AnyMachine, Key extends ExplorationKey>(machine: RootReadyMachine<M>, options: ExploreOptions<M, Key>) => Effect.Effect<Exploration<M, Key>, RunFailure<RunError<M>, M> | InvariantTest.InvariantError<M>, RunServices<M>>;
|
|
1114
1108
|
/**
|
|
1115
1109
|
* A predicate over one explored logical state.
|
|
1116
1110
|
*
|
|
@@ -1131,7 +1125,7 @@ export type ReachabilityFailure = "NotFound" | "UnexpectedMatch" | "Inconclusive
|
|
|
1131
1125
|
* @category errors
|
|
1132
1126
|
* @since 0.4.0
|
|
1133
1127
|
*/
|
|
1134
|
-
export { ReachabilityError } from "../internal/testing/machine/
|
|
1128
|
+
export { ReachabilityError } from "../internal/testing/machine/exploration.js";
|
|
1135
1129
|
/**
|
|
1136
1130
|
* Finds the first, and therefore shortest, explored state matching a
|
|
1137
1131
|
* predicate.
|
|
@@ -1149,7 +1143,7 @@ export declare const findShortest: <M extends AnyMachine, Key extends Exploratio
|
|
|
1149
1143
|
* @category exploration
|
|
1150
1144
|
* @since 0.4.0
|
|
1151
1145
|
*/
|
|
1152
|
-
export declare const assertReachable: <M extends AnyMachine, Key extends ExplorationKey>(exploration: Exploration<M, Key>, name: string, predicate: ExplorationPredicate<M, Key>) => Effect.Effect<ExplorationNode<M, Key>,
|
|
1146
|
+
export declare const assertReachable: <M extends AnyMachine, Key extends ExplorationKey>(exploration: Exploration<M, Key>, name: string, predicate: ExplorationPredicate<M, Key>) => Effect.Effect<ExplorationNode<M, Key>, ExplorationImpl.ReachabilityError<M, Key>>;
|
|
1153
1147
|
/**
|
|
1154
1148
|
* Requires that no explored state matches a predicate.
|
|
1155
1149
|
*
|
|
@@ -1159,7 +1153,7 @@ export declare const assertReachable: <M extends AnyMachine, Key extends Explora
|
|
|
1159
1153
|
* @category exploration
|
|
1160
1154
|
* @since 0.4.0
|
|
1161
1155
|
*/
|
|
1162
|
-
export declare const assertUnreachable: <M extends AnyMachine, Key extends ExplorationKey>(exploration: Exploration<M, Key>, name: string, predicate: ExplorationPredicate<M, Key>) => Effect.Effect<void,
|
|
1156
|
+
export declare const assertUnreachable: <M extends AnyMachine, Key extends ExplorationKey>(exploration: Exploration<M, Key>, name: string, predicate: ExplorationPredicate<M, Key>) => Effect.Effect<void, ExplorationImpl.ReachabilityError<M, Key>>;
|
|
1163
1157
|
/**
|
|
1164
1158
|
* Checks a real planner trace against the independent finite statechart model
|
|
1165
1159
|
* interpreter.
|
|
@@ -1193,7 +1187,7 @@ export type RunFailure<Cause, M extends AnyMachine = AnyMachine> = {
|
|
|
1193
1187
|
readonly scenario: Scenario<M>;
|
|
1194
1188
|
readonly phase: "event";
|
|
1195
1189
|
readonly eventIndex: number;
|
|
1196
|
-
readonly event: Machine.Machine.InputEvent<M
|
|
1190
|
+
readonly event: Machine.Machine.EventInput<Machine.Machine.InputEvent<M>>;
|
|
1197
1191
|
readonly initial: InitialTrace<M>;
|
|
1198
1192
|
readonly steps: ReadonlyArray<TraceStep<M>>;
|
|
1199
1193
|
readonly cause: Cause;
|
|
@@ -1232,15 +1226,12 @@ export type RunServices<M extends AnyMachine> = IsAny<Machine.PlanningServices<M
|
|
|
1232
1226
|
* import { MachineTest } from "@typeonce/effect-machine/testing"
|
|
1233
1227
|
*
|
|
1234
1228
|
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
1235
|
-
* const States = Machine.
|
|
1229
|
+
* const States = Machine.state({ initial: "Idle", states: { Idle } })
|
|
1236
1230
|
* const machine = Machine.make({
|
|
1237
|
-
*
|
|
1238
|
-
* events: Machine.
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1241
|
-
* resolve: ({ target }) => target.from()
|
|
1242
|
-
* }
|
|
1243
|
-
* }).handle({ Idle: {} })
|
|
1231
|
+
* root: States,
|
|
1232
|
+
* events: Machine.eventsFromSchemas(),
|
|
1233
|
+
* initialConfiguration: root => root.resolve(({ target }) => target.from(tree => tree.Idle.from()))
|
|
1234
|
+
* }).handle({ states: { Idle: {} } })
|
|
1244
1235
|
*
|
|
1245
1236
|
* const trace = MachineTest.run(machine, { events: [] })
|
|
1246
1237
|
* ```
|
|
@@ -1465,15 +1456,12 @@ export interface Coverage<M extends AnyMachine> {
|
|
|
1465
1456
|
* import { MachineTest } from "@typeonce/effect-machine/testing"
|
|
1466
1457
|
*
|
|
1467
1458
|
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
1468
|
-
* const States = Machine.
|
|
1459
|
+
* const States = Machine.state({ initial: "Idle", states: { Idle } })
|
|
1469
1460
|
* const machine = Machine.make({
|
|
1470
|
-
*
|
|
1471
|
-
* events: Machine.
|
|
1472
|
-
*
|
|
1473
|
-
*
|
|
1474
|
-
* resolve: ({ target }) => target.from()
|
|
1475
|
-
* }
|
|
1476
|
-
* }).handle({ Idle: {} })
|
|
1461
|
+
* root: States,
|
|
1462
|
+
* events: Machine.eventsFromSchemas(),
|
|
1463
|
+
* initialConfiguration: root => root.resolve(({ target }) => target.from(tree => tree.Idle.from()))
|
|
1464
|
+
* }).handle({ states: { Idle: {} } })
|
|
1477
1465
|
*
|
|
1478
1466
|
* const report = Effect.map(
|
|
1479
1467
|
* MachineTest.run(machine, { events: [] }),
|
|
@@ -1522,7 +1510,7 @@ export interface ObservedGraphMicrostep<M extends AnyMachine> {
|
|
|
1522
1510
|
readonly event: Machine.Machine.Event<M> | Machine.InitialEvent;
|
|
1523
1511
|
readonly transitions: Microstep<M, any>["transitions"];
|
|
1524
1512
|
readonly raisedEvents: ReadonlyArray<Machine.Machine.Event<M>>;
|
|
1525
|
-
readonly emittedEvents: ReadonlyArray<Machine.Machine.
|
|
1513
|
+
readonly emittedEvents: ReadonlyArray<Machine.Machine.EmittedEvent<M>>;
|
|
1526
1514
|
readonly exitPaths: ReadonlyArray<StatePath<M>>;
|
|
1527
1515
|
readonly entryPaths: ReadonlyArray<StatePath<M>>;
|
|
1528
1516
|
readonly changed: boolean;
|
|
@@ -1635,15 +1623,12 @@ export interface VerifyOptions {
|
|
|
1635
1623
|
* import { MachineTest } from "@typeonce/effect-machine/testing"
|
|
1636
1624
|
*
|
|
1637
1625
|
* class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
|
|
1638
|
-
* const States = Machine.
|
|
1626
|
+
* const States = Machine.state({ initial: "Idle", states: { Idle } })
|
|
1639
1627
|
* const machine = Machine.make({
|
|
1640
|
-
*
|
|
1641
|
-
* events: Machine.
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
* resolve: ({ target }) => target.from()
|
|
1645
|
-
* }
|
|
1646
|
-
* }).handle({ Idle: {} })
|
|
1628
|
+
* root: States,
|
|
1629
|
+
* events: Machine.eventsFromSchemas(),
|
|
1630
|
+
* initialConfiguration: root => root.resolve(({ target }) => target.from(tree => tree.Idle.from()))
|
|
1631
|
+
* }).handle({ states: { Idle: {} } })
|
|
1647
1632
|
*
|
|
1648
1633
|
* const checked = Effect.gen(function*() {
|
|
1649
1634
|
* const trace = yield* MachineTest.run(machine, { events: [] })
|