@rxova/journey-core 1.0.0-rc.3 → 1.0.1
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 +185 -189
- package/dist/connectors/immer/immer.cjs +2 -0
- package/dist/connectors/immer/immer.cjs.map +7 -0
- package/dist/connectors/immer/immer.d.cts +11 -0
- package/dist/connectors/immer/immer.d.ts +11 -0
- package/dist/connectors/immer/immer.js +2 -0
- package/dist/connectors/immer/immer.js.map +7 -0
- package/dist/connectors/immer/immer.types.d.cts +9 -0
- package/dist/connectors/immer/immer.types.d.ts +9 -0
- package/dist/core/errors.d.cts +57 -0
- package/dist/core/errors.d.ts +57 -0
- package/dist/core/helpers.d.cts +40 -0
- package/dist/core/helpers.d.ts +40 -0
- package/dist/core/machine.d.cts +9 -0
- package/dist/core/machine.d.ts +9 -0
- package/dist/core/runtime.d.cts +115 -0
- package/dist/core/runtime.d.ts +115 -0
- package/dist/core/runtime.types.d.cts +112 -0
- package/dist/core/runtime.types.d.ts +112 -0
- package/dist/core/store.d.cts +31 -0
- package/dist/core/store.d.ts +31 -0
- package/dist/core/types.d.cts +481 -0
- package/dist/core/types.d.ts +481 -0
- package/dist/diagnostics/diagnostics.helpers.d.cts +17 -0
- package/dist/diagnostics/diagnostics.helpers.d.ts +17 -0
- package/dist/diagnostics/diagnostics.types.d.cts +22 -0
- package/dist/diagnostics/diagnostics.types.d.ts +22 -0
- package/dist/graph/bag.types.d.cts +91 -0
- package/dist/graph/bag.types.d.ts +91 -0
- package/dist/graph/graph.d.cts +63 -0
- package/dist/graph/graph.d.ts +63 -0
- package/dist/graph/graph.types.d.cts +212 -0
- package/dist/graph/graph.types.d.ts +212 -0
- package/dist/graph/work.d.cts +81 -0
- package/dist/graph/work.d.ts +81 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/linear/linear.d.cts +33 -0
- package/dist/linear/linear.d.ts +33 -0
- package/dist/linear/linear.types.d.cts +28 -0
- package/dist/linear/linear.types.d.ts +28 -0
- package/dist/plugins/analytics/analytics.d.cts +8 -0
- package/dist/plugins/analytics/analytics.d.ts +8 -0
- package/dist/plugins/analytics/analytics.helpers.d.cts +2 -0
- package/dist/plugins/analytics/analytics.helpers.d.ts +2 -0
- package/dist/plugins/analytics/analytics.types.d.cts +27 -0
- package/dist/plugins/analytics/analytics.types.d.ts +27 -0
- package/dist/plugins/execution-paths/execution-paths.d.cts +7 -4
- package/dist/plugins/execution-paths/execution-paths.d.ts +7 -4
- package/dist/plugins/execution-paths/execution-paths.types.d.cts +21 -0
- package/dist/plugins/execution-paths/execution-paths.types.d.ts +21 -0
- package/dist/plugins/index.cjs +2 -0
- package/dist/plugins/index.cjs.map +7 -0
- package/dist/plugins/index.d.cts +19 -0
- package/dist/plugins/index.d.ts +19 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/index.js.map +7 -0
- package/dist/plugins/persistence/persistence.d.cts +16 -0
- package/dist/plugins/persistence/persistence.d.ts +16 -0
- package/dist/plugins/persistence/persistence.helpers.d.cts +34 -0
- package/dist/plugins/persistence/persistence.helpers.d.ts +34 -0
- package/dist/plugins/persistence/persistence.types.d.cts +63 -0
- package/dist/plugins/persistence/persistence.types.d.ts +63 -0
- package/dist/plugins/replay/replay.d.cts +7 -0
- package/dist/plugins/replay/replay.d.ts +7 -0
- package/dist/plugins/replay/replay.helpers.d.cts +22 -0
- package/dist/plugins/replay/replay.helpers.d.ts +22 -0
- package/dist/plugins/replay/replay.types.d.cts +28 -0
- package/dist/plugins/replay/replay.types.d.ts +28 -0
- package/package.json +61 -80
- package/dist/journey-builder/index.d.cts +0 -5
- package/dist/journey-builder/index.d.ts +0 -5
- package/dist/journey-builder/types.d.cts +0 -126
- package/dist/journey-builder/types.d.ts +0 -126
- package/dist/journey-machine/async-state.d.cts +0 -12
- package/dist/journey-machine/async-state.d.ts +0 -12
- package/dist/journey-machine/computed.d.cts +0 -2
- package/dist/journey-machine/computed.d.ts +0 -2
- package/dist/journey-machine/controls.d.cts +0 -17
- package/dist/journey-machine/controls.d.ts +0 -17
- package/dist/journey-machine/helpers.d.cts +0 -52
- package/dist/journey-machine/helpers.d.ts +0 -52
- package/dist/journey-machine/index.d.cts +0 -3
- package/dist/journey-machine/index.d.ts +0 -3
- package/dist/journey-machine/navigation.d.cts +0 -32
- package/dist/journey-machine/navigation.d.ts +0 -32
- package/dist/journey-machine/plugin-controller.d.cts +0 -15
- package/dist/journey-machine/plugin-controller.d.ts +0 -15
- package/dist/journey-machine/resolve-journey-definition.d.cts +0 -2
- package/dist/journey-machine/resolve-journey-definition.d.ts +0 -2
- package/dist/journey-machine/runtime.d.cts +0 -33
- package/dist/journey-machine/runtime.d.ts +0 -33
- package/dist/journey-machine/send.d.cts +0 -9
- package/dist/journey-machine/send.d.ts +0 -9
- package/dist/plugins/analytics/index.cjs +0 -2
- package/dist/plugins/analytics/index.cjs.map +0 -7
- package/dist/plugins/analytics/index.d.cts +0 -25
- package/dist/plugins/analytics/index.d.ts +0 -25
- package/dist/plugins/analytics/index.js +0 -2
- package/dist/plugins/analytics/index.js.map +0 -7
- package/dist/plugins/autosave/index.cjs +0 -2
- package/dist/plugins/autosave/index.cjs.map +0 -7
- package/dist/plugins/autosave/index.d.cts +0 -17
- package/dist/plugins/autosave/index.d.ts +0 -17
- package/dist/plugins/autosave/index.js +0 -2
- package/dist/plugins/autosave/index.js.map +0 -7
- package/dist/plugins/diagnostics/diagnostics.d.cts +0 -3
- package/dist/plugins/diagnostics/diagnostics.d.ts +0 -3
- package/dist/plugins/diagnostics/index.cjs +0 -2
- package/dist/plugins/diagnostics/index.cjs.map +0 -7
- package/dist/plugins/diagnostics/index.d.cts +0 -15
- package/dist/plugins/diagnostics/index.d.ts +0 -15
- package/dist/plugins/diagnostics/index.js +0 -2
- package/dist/plugins/diagnostics/index.js.map +0 -7
- package/dist/plugins/execution-paths/index.cjs +0 -2
- package/dist/plugins/execution-paths/index.cjs.map +0 -7
- package/dist/plugins/execution-paths/index.d.cts +0 -18
- package/dist/plugins/execution-paths/index.d.ts +0 -18
- package/dist/plugins/execution-paths/index.js +0 -2
- package/dist/plugins/execution-paths/index.js.map +0 -7
- package/dist/plugins/persistence/controller.d.cts +0 -17
- package/dist/plugins/persistence/controller.d.ts +0 -17
- package/dist/plugins/persistence/index.cjs +0 -2
- package/dist/plugins/persistence/index.cjs.map +0 -7
- package/dist/plugins/persistence/index.d.cts +0 -12
- package/dist/plugins/persistence/index.d.ts +0 -12
- package/dist/plugins/persistence/index.js +0 -2
- package/dist/plugins/persistence/index.js.map +0 -7
- package/dist/plugins/replay/index.cjs +0 -2
- package/dist/plugins/replay/index.cjs.map +0 -7
- package/dist/plugins/replay/index.d.cts +0 -27
- package/dist/plugins/replay/index.d.ts +0 -27
- package/dist/plugins/replay/index.js +0 -2
- package/dist/plugins/replay/index.js.map +0 -7
- package/dist/types/analytics.types.d.cts +0 -33
- package/dist/types/analytics.types.d.ts +0 -33
- package/dist/types/autosave.types.d.cts +0 -23
- package/dist/types/autosave.types.d.ts +0 -23
- package/dist/types/diagnostics.types.d.cts +0 -38
- package/dist/types/diagnostics.types.d.ts +0 -38
- package/dist/types/index.d.cts +0 -9
- package/dist/types/index.d.ts +0 -9
- package/dist/types/journey.types.d.cts +0 -191
- package/dist/types/journey.types.d.ts +0 -191
- package/dist/types/machine.types.d.cts +0 -104
- package/dist/types/machine.types.d.ts +0 -104
- package/dist/types/observation.types.d.cts +0 -83
- package/dist/types/observation.types.d.ts +0 -83
- package/dist/types/persistence.types.d.cts +0 -34
- package/dist/types/persistence.types.d.ts +0 -34
- package/dist/types/replay.types.d.cts +0 -35
- package/dist/types/replay.types.d.ts +0 -35
- package/dist/types/transitions.types.d.cts +0 -122
- package/dist/types/transitions.types.d.ts +0 -122
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { JourneyComputed, JourneyDefaultEventType, JourneyDefinition, JourneyEqualityFn, JourneyJsonObject, JourneyPayloadFor, JourneyResolvedDefinition, JourneySelector, JourneySendEvent, JourneySendResult, JourneySnapshot, JourneyTerminal } from "./journey.types";
|
|
2
|
-
import type { JourneyCompleteObservationEvent, JourneyLifecycleErrorPhase, JourneyObservationEvent, JourneyResetObservationEvent, JourneyStartObservationEvent, JourneyTerminateObservationEvent } from "./observation.types";
|
|
3
|
-
/** Reasons why a machine snapshot changed. */
|
|
4
|
-
export type JourneyMachineSnapshotReason = "async" | "context" | "navigation" | "reset" | "start" | "transition";
|
|
5
|
-
export type JourneyLifecycleErrorContext<TStepId extends string> = {
|
|
6
|
-
phase: JourneyLifecycleErrorPhase;
|
|
7
|
-
from: TStepId;
|
|
8
|
-
to: TStepId | JourneyTerminal;
|
|
9
|
-
eventType: string;
|
|
10
|
-
transitionId: string | null;
|
|
11
|
-
label?: string;
|
|
12
|
-
};
|
|
13
|
-
/** Setup context passed to journey plugins when a machine is created. */
|
|
14
|
-
export type JourneyMachinePluginSetupContext<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown, THandlers extends Record<string, unknown> = Record<never, never>> = {
|
|
15
|
-
journey: JourneyDefinition<TContext, TStepId, TEventMap, TStepMeta, THandlers>;
|
|
16
|
-
resolvedJourney: JourneyResolvedDefinition<TContext, TStepId, TEventMap, TStepMeta, THandlers>;
|
|
17
|
-
options: {
|
|
18
|
-
requireExplicitCompletion: boolean;
|
|
19
|
-
defaultTimeoutMs: number | undefined;
|
|
20
|
-
};
|
|
21
|
-
buildInitialSnapshot: () => JourneySnapshot<TContext, TStepId>;
|
|
22
|
-
};
|
|
23
|
-
/** Snapshot-change details exposed to plugins. */
|
|
24
|
-
export type JourneyMachinePluginSnapshotChange<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
25
|
-
previousSnapshot: JourneySnapshot<TContext, TStepId>;
|
|
26
|
-
snapshot: JourneySnapshot<TContext, TStepId>;
|
|
27
|
-
reason: JourneyMachineSnapshotReason;
|
|
28
|
-
};
|
|
29
|
-
/** Hooks returned from a journey plugin setup call. */
|
|
30
|
-
export type JourneyMachinePluginHooks<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown, THandlers extends Record<string, unknown> = Record<never, never>, TExtension extends object = Record<never, never>> = {
|
|
31
|
-
hydrateSnapshot?: (snapshot: JourneySnapshot<TContext, TStepId>) => JourneySnapshot<TContext, TStepId>;
|
|
32
|
-
onSnapshotChange?: (change: JourneyMachinePluginSnapshotChange<TContext, TStepId>) => void;
|
|
33
|
-
augmentMachine?: (context: {
|
|
34
|
-
machine: JourneyMachine<TContext, TStepId, TEventMap, TStepMeta, THandlers>;
|
|
35
|
-
journey: JourneyDefinition<TContext, TStepId, TEventMap, TStepMeta, THandlers>;
|
|
36
|
-
resolvedJourney: JourneyResolvedDefinition<TContext, TStepId, TEventMap, TStepMeta, THandlers>;
|
|
37
|
-
}) => TExtension;
|
|
38
|
-
dispose?: () => void;
|
|
39
|
-
};
|
|
40
|
-
/** Plugin contract for extending journey machines without bloating the base entrypoint. */
|
|
41
|
-
export type JourneyMachinePlugin = {
|
|
42
|
-
name: string;
|
|
43
|
-
__extension__?: object;
|
|
44
|
-
setup: <TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown, THandlers extends Record<string, unknown> = Record<never, never>>(context: JourneyMachinePluginSetupContext<TContext, TStepId, TEventMap, TStepMeta, THandlers>) => JourneyMachinePluginHooks<TContext, TStepId, TEventMap, TStepMeta, THandlers>;
|
|
45
|
-
};
|
|
46
|
-
type JourneyMachinePluginHooksFor<TPlugin, TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown>, TStepMeta, THandlers extends Record<string, unknown>> = TPlugin extends {
|
|
47
|
-
setup: (context: JourneyMachinePluginSetupContext<TContext, TStepId, TEventMap, TStepMeta, THandlers>) => infer THooks;
|
|
48
|
-
} ? THooks : never;
|
|
49
|
-
type JourneyMachinePluginExtensionFor<TPlugin, TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown>, TStepMeta, THandlers extends Record<string, unknown>> = TPlugin extends {
|
|
50
|
-
__extension__?: infer TExtension;
|
|
51
|
-
} ? Exclude<TExtension, undefined> extends never ? JourneyMachinePluginHooksFor<TPlugin, TContext, TStepId, TEventMap, TStepMeta, THandlers> extends {
|
|
52
|
-
augmentMachine?: (...args: never[]) => infer THookExtension;
|
|
53
|
-
} ? THookExtension : Record<never, never> : Exclude<TExtension, undefined> : JourneyMachinePluginHooksFor<TPlugin, TContext, TStepId, TEventMap, TStepMeta, THandlers> extends {
|
|
54
|
-
augmentMachine?: (...args: never[]) => infer THookExtension;
|
|
55
|
-
} ? THookExtension : Record<never, never>;
|
|
56
|
-
type UnionToIntersection<TValue> = [TValue] extends [never] ? Record<never, never> : (TValue extends unknown ? (value: TValue) => void : never) extends (value: infer TIntersection) => void ? TIntersection : Record<never, never>;
|
|
57
|
-
type JourneyTypeParam<TValue> = TValue extends unknown ? unknown : never;
|
|
58
|
-
/** Optional machine features and plugin registration. */
|
|
59
|
-
export type JourneyMachineOptions<TPlugins extends readonly JourneyMachinePlugin[] = readonly JourneyMachinePlugin[]> = {
|
|
60
|
-
requireExplicitCompletion?: boolean;
|
|
61
|
-
defaultTimeoutMs?: number;
|
|
62
|
-
plugins?: TPlugins;
|
|
63
|
-
/**
|
|
64
|
-
* Called when a snapshot or event listener throws an unhandled error.
|
|
65
|
-
* Listener failures are isolated so they never block other listeners or
|
|
66
|
-
* the machine itself — use this hook to report them to your error
|
|
67
|
-
* monitoring system (e.g. Sentry, Datadog).
|
|
68
|
-
*
|
|
69
|
-
* @param error - The thrown value (may not be an `Error` instance).
|
|
70
|
-
* @param context - `"snapshot"` for `subscribe()` listeners,
|
|
71
|
-
* `"event"` for `subscribeEvent()` listeners.
|
|
72
|
-
*/
|
|
73
|
-
onListenerError?: (error: unknown, context: "snapshot" | "event") => void;
|
|
74
|
-
onLifecycleError?: (error: unknown, context: JourneyLifecycleErrorContext<string>) => void;
|
|
75
|
-
};
|
|
76
|
-
type JourneyPayloadForDefaultEvent<TEventMap extends Record<string, unknown>, TDefaultEvent extends JourneyDefaultEventType> = JourneyPayloadFor<TEventMap, TDefaultEvent>;
|
|
77
|
-
/** Runtime machine API for reading snapshots, sending events, and controlling flow. */
|
|
78
|
-
export type JourneyMachine<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown, THandlers extends Record<string, unknown> = Record<never, never>> = JourneyTypeParam<THandlers> & {
|
|
79
|
-
getSnapshot: () => JourneySnapshot<TContext, TStepId>;
|
|
80
|
-
getStepMeta: (stepId: TStepId) => TStepMeta | undefined;
|
|
81
|
-
getComputed: () => JourneyComputed<TStepId>;
|
|
82
|
-
startJourney: () => Promise<JourneySnapshot<TContext, TStepId>>;
|
|
83
|
-
send: (event: JourneySendEvent<TStepId, TEventMap>) => Promise<JourneySendResult<TContext, TStepId>>;
|
|
84
|
-
goToNextStep: () => Promise<JourneySendResult<TContext, TStepId>>;
|
|
85
|
-
goToStepById: (stepId: TStepId) => Promise<JourneySendResult<TContext, TStepId>>;
|
|
86
|
-
terminateJourney: (payload?: JourneyPayloadForDefaultEvent<TEventMap, "terminateJourney">) => Promise<JourneySendResult<TContext, TStepId>>;
|
|
87
|
-
completeJourney: (payload?: JourneyPayloadForDefaultEvent<TEventMap, "completeJourney">) => Promise<JourneySendResult<TContext, TStepId>>;
|
|
88
|
-
goToPreviousStep: (steps?: number) => Promise<JourneySendResult<TContext, TStepId>>;
|
|
89
|
-
goToLastVisitedStep: () => Promise<JourneySendResult<TContext, TStepId>>;
|
|
90
|
-
updateContext: (updater: (context: TContext) => TContext) => Promise<JourneySnapshot<TContext, TStepId>>;
|
|
91
|
-
clearStepError: (stepId?: TStepId) => Promise<JourneySnapshot<TContext, TStepId>>;
|
|
92
|
-
resetJourney: () => Promise<JourneySnapshot<TContext, TStepId>>;
|
|
93
|
-
dispose: () => void;
|
|
94
|
-
subscribe: (listener: () => void) => () => void;
|
|
95
|
-
subscribeSelector: <TSelected>(selector: JourneySelector<TContext, TStepId, TSelected>, listener: (next: TSelected, previous: TSelected) => void, equalityFn?: JourneyEqualityFn<TSelected>) => () => void;
|
|
96
|
-
subscribeEvent: (listener: (event: JourneyObservationEvent<TStepId, TEventMap>) => void) => () => void;
|
|
97
|
-
subscribeStart: (listener: (event: JourneyStartObservationEvent<TStepId>) => void) => () => void;
|
|
98
|
-
subscribeReset: (listener: (event: JourneyResetObservationEvent<TStepId>) => void) => () => void;
|
|
99
|
-
subscribeComplete: (listener: (event: JourneyCompleteObservationEvent<TStepId>) => void) => () => void;
|
|
100
|
-
subscribeTerminate: (listener: (event: JourneyTerminateObservationEvent<TStepId>) => void) => () => void;
|
|
101
|
-
};
|
|
102
|
-
/** Journey machine API augmented by plugin-provided extensions. */
|
|
103
|
-
export type JourneyMachineWithPlugins<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown, THandlers extends Record<string, unknown> = Record<never, never>, TPlugins extends readonly JourneyMachinePlugin[] = readonly JourneyMachinePlugin[]> = JourneyMachine<TContext, TStepId, TEventMap, TStepMeta, THandlers> & UnionToIntersection<JourneyMachinePluginExtensionFor<TPlugins[number], TContext, TStepId, TEventMap, TStepMeta, THandlers>>;
|
|
104
|
-
export {};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { JourneySendEvent, JourneyTerminal } from "./journey.types";
|
|
2
|
-
export type JourneyLifecycleErrorPhase = "step.onLeave" | "transition.onLeave" | "step.onEnter" | "transition.onEnter";
|
|
3
|
-
export type JourneyStartObservationEvent<TStepId extends string> = {
|
|
4
|
-
type: "journey.start";
|
|
5
|
-
stepId: TStepId;
|
|
6
|
-
timestamp: number;
|
|
7
|
-
};
|
|
8
|
-
export type JourneyResetObservationEvent<TStepId extends string> = {
|
|
9
|
-
type: "journey.reset";
|
|
10
|
-
stepId: TStepId;
|
|
11
|
-
timestamp: number;
|
|
12
|
-
};
|
|
13
|
-
export type JourneyTransitionStartObservationEvent<TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = {
|
|
14
|
-
type: "transition.start";
|
|
15
|
-
from: TStepId;
|
|
16
|
-
event: JourneySendEvent<TStepId, TEventMap>;
|
|
17
|
-
timestamp: number;
|
|
18
|
-
};
|
|
19
|
-
export type JourneyTransitionSuccessObservationEvent<TStepId extends string> = {
|
|
20
|
-
type: "transition.success";
|
|
21
|
-
from: TStepId;
|
|
22
|
-
to: TStepId | JourneyTerminal;
|
|
23
|
-
eventType: string;
|
|
24
|
-
transitionId: string | null;
|
|
25
|
-
label?: string;
|
|
26
|
-
timestamp: number;
|
|
27
|
-
};
|
|
28
|
-
export type JourneyTransitionErrorObservationEvent<TStepId extends string> = {
|
|
29
|
-
type: "transition.error";
|
|
30
|
-
from: TStepId;
|
|
31
|
-
eventType: string;
|
|
32
|
-
transitionId: string | null;
|
|
33
|
-
label?: string;
|
|
34
|
-
error: unknown;
|
|
35
|
-
timestamp: number;
|
|
36
|
-
};
|
|
37
|
-
export type JourneyLifecycleErrorObservationEvent<TStepId extends string> = {
|
|
38
|
-
type: "lifecycle.error";
|
|
39
|
-
phase: JourneyLifecycleErrorPhase;
|
|
40
|
-
from: TStepId;
|
|
41
|
-
to: TStepId | JourneyTerminal;
|
|
42
|
-
eventType: string;
|
|
43
|
-
transitionId: string | null;
|
|
44
|
-
label?: string;
|
|
45
|
-
error: unknown;
|
|
46
|
-
timestamp: number;
|
|
47
|
-
};
|
|
48
|
-
export type JourneyStepExitObservationEvent<TStepId extends string> = {
|
|
49
|
-
type: "step.exit";
|
|
50
|
-
stepId: TStepId;
|
|
51
|
-
timestamp: number;
|
|
52
|
-
};
|
|
53
|
-
export type JourneyStepEnterObservationEvent<TStepId extends string> = {
|
|
54
|
-
type: "step.enter";
|
|
55
|
-
stepId: TStepId;
|
|
56
|
-
timestamp: number;
|
|
57
|
-
};
|
|
58
|
-
export type JourneyCompleteObservationEvent<TStepId extends string> = {
|
|
59
|
-
type: "journey.completed";
|
|
60
|
-
stepId: TStepId;
|
|
61
|
-
timestamp: number;
|
|
62
|
-
};
|
|
63
|
-
export type JourneyTerminateObservationEvent<TStepId extends string> = {
|
|
64
|
-
type: "journey.terminated";
|
|
65
|
-
stepId: TStepId;
|
|
66
|
-
timestamp: number;
|
|
67
|
-
};
|
|
68
|
-
export type JourneyPreviousNavigationObservationEvent<TStepId extends string> = {
|
|
69
|
-
type: "navigation.previous";
|
|
70
|
-
from: TStepId;
|
|
71
|
-
to: TStepId;
|
|
72
|
-
requestedSteps: number;
|
|
73
|
-
appliedSteps: number;
|
|
74
|
-
timestamp: number;
|
|
75
|
-
};
|
|
76
|
-
export type JourneyLastVisitedNavigationObservationEvent<TStepId extends string> = {
|
|
77
|
-
type: "navigation.lastVisited";
|
|
78
|
-
from: TStepId;
|
|
79
|
-
to: TStepId;
|
|
80
|
-
timestamp: number;
|
|
81
|
-
};
|
|
82
|
-
/** Observation events emitted by the machine lifecycle/event stream. */
|
|
83
|
-
export type JourneyObservationEvent<TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = JourneyStartObservationEvent<TStepId> | JourneyResetObservationEvent<TStepId> | JourneyTransitionStartObservationEvent<TStepId, TEventMap> | JourneyTransitionSuccessObservationEvent<TStepId> | JourneyTransitionErrorObservationEvent<TStepId> | JourneyLifecycleErrorObservationEvent<TStepId> | JourneyStepExitObservationEvent<TStepId> | JourneyStepEnterObservationEvent<TStepId> | JourneyCompleteObservationEvent<TStepId> | JourneyTerminateObservationEvent<TStepId> | JourneyPreviousNavigationObservationEvent<TStepId> | JourneyLastVisitedNavigationObservationEvent<TStepId>;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { JourneySendEvent, JourneyTerminal } from "./journey.types";
|
|
2
|
-
export type JourneyLifecycleErrorPhase = "step.onLeave" | "transition.onLeave" | "step.onEnter" | "transition.onEnter";
|
|
3
|
-
export type JourneyStartObservationEvent<TStepId extends string> = {
|
|
4
|
-
type: "journey.start";
|
|
5
|
-
stepId: TStepId;
|
|
6
|
-
timestamp: number;
|
|
7
|
-
};
|
|
8
|
-
export type JourneyResetObservationEvent<TStepId extends string> = {
|
|
9
|
-
type: "journey.reset";
|
|
10
|
-
stepId: TStepId;
|
|
11
|
-
timestamp: number;
|
|
12
|
-
};
|
|
13
|
-
export type JourneyTransitionStartObservationEvent<TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = {
|
|
14
|
-
type: "transition.start";
|
|
15
|
-
from: TStepId;
|
|
16
|
-
event: JourneySendEvent<TStepId, TEventMap>;
|
|
17
|
-
timestamp: number;
|
|
18
|
-
};
|
|
19
|
-
export type JourneyTransitionSuccessObservationEvent<TStepId extends string> = {
|
|
20
|
-
type: "transition.success";
|
|
21
|
-
from: TStepId;
|
|
22
|
-
to: TStepId | JourneyTerminal;
|
|
23
|
-
eventType: string;
|
|
24
|
-
transitionId: string | null;
|
|
25
|
-
label?: string;
|
|
26
|
-
timestamp: number;
|
|
27
|
-
};
|
|
28
|
-
export type JourneyTransitionErrorObservationEvent<TStepId extends string> = {
|
|
29
|
-
type: "transition.error";
|
|
30
|
-
from: TStepId;
|
|
31
|
-
eventType: string;
|
|
32
|
-
transitionId: string | null;
|
|
33
|
-
label?: string;
|
|
34
|
-
error: unknown;
|
|
35
|
-
timestamp: number;
|
|
36
|
-
};
|
|
37
|
-
export type JourneyLifecycleErrorObservationEvent<TStepId extends string> = {
|
|
38
|
-
type: "lifecycle.error";
|
|
39
|
-
phase: JourneyLifecycleErrorPhase;
|
|
40
|
-
from: TStepId;
|
|
41
|
-
to: TStepId | JourneyTerminal;
|
|
42
|
-
eventType: string;
|
|
43
|
-
transitionId: string | null;
|
|
44
|
-
label?: string;
|
|
45
|
-
error: unknown;
|
|
46
|
-
timestamp: number;
|
|
47
|
-
};
|
|
48
|
-
export type JourneyStepExitObservationEvent<TStepId extends string> = {
|
|
49
|
-
type: "step.exit";
|
|
50
|
-
stepId: TStepId;
|
|
51
|
-
timestamp: number;
|
|
52
|
-
};
|
|
53
|
-
export type JourneyStepEnterObservationEvent<TStepId extends string> = {
|
|
54
|
-
type: "step.enter";
|
|
55
|
-
stepId: TStepId;
|
|
56
|
-
timestamp: number;
|
|
57
|
-
};
|
|
58
|
-
export type JourneyCompleteObservationEvent<TStepId extends string> = {
|
|
59
|
-
type: "journey.completed";
|
|
60
|
-
stepId: TStepId;
|
|
61
|
-
timestamp: number;
|
|
62
|
-
};
|
|
63
|
-
export type JourneyTerminateObservationEvent<TStepId extends string> = {
|
|
64
|
-
type: "journey.terminated";
|
|
65
|
-
stepId: TStepId;
|
|
66
|
-
timestamp: number;
|
|
67
|
-
};
|
|
68
|
-
export type JourneyPreviousNavigationObservationEvent<TStepId extends string> = {
|
|
69
|
-
type: "navigation.previous";
|
|
70
|
-
from: TStepId;
|
|
71
|
-
to: TStepId;
|
|
72
|
-
requestedSteps: number;
|
|
73
|
-
appliedSteps: number;
|
|
74
|
-
timestamp: number;
|
|
75
|
-
};
|
|
76
|
-
export type JourneyLastVisitedNavigationObservationEvent<TStepId extends string> = {
|
|
77
|
-
type: "navigation.lastVisited";
|
|
78
|
-
from: TStepId;
|
|
79
|
-
to: TStepId;
|
|
80
|
-
timestamp: number;
|
|
81
|
-
};
|
|
82
|
-
/** Observation events emitted by the machine lifecycle/event stream. */
|
|
83
|
-
export type JourneyObservationEvent<TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = JourneyStartObservationEvent<TStepId> | JourneyResetObservationEvent<TStepId> | JourneyTransitionStartObservationEvent<TStepId, TEventMap> | JourneyTransitionSuccessObservationEvent<TStepId> | JourneyTransitionErrorObservationEvent<TStepId> | JourneyLifecycleErrorObservationEvent<TStepId> | JourneyStepExitObservationEvent<TStepId> | JourneyStepEnterObservationEvent<TStepId> | JourneyCompleteObservationEvent<TStepId> | JourneyTerminateObservationEvent<TStepId> | JourneyPreviousNavigationObservationEvent<TStepId> | JourneyLastVisitedNavigationObservationEvent<TStepId>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { JourneyJsonObject, JourneySnapshotStateBase } from "./journey.types";
|
|
2
|
-
export type JourneyPersistedState<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
3
|
-
version: number;
|
|
4
|
-
snapshot: JourneySnapshotStateBase<TContext, TStepId>;
|
|
5
|
-
};
|
|
6
|
-
export type JourneyStorage = {
|
|
7
|
-
getItem: (key: string) => string | null;
|
|
8
|
-
setItem: (key: string, value: string) => void;
|
|
9
|
-
removeItem: (key: string) => void;
|
|
10
|
-
};
|
|
11
|
-
export type JourneyPersistenceOptions<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
12
|
-
key: string;
|
|
13
|
-
storage?: JourneyStorage;
|
|
14
|
-
version?: number;
|
|
15
|
-
clearOnReset?: boolean;
|
|
16
|
-
allowList?: readonly string[];
|
|
17
|
-
blockList?: readonly string[];
|
|
18
|
-
serialize?: (value: JourneyPersistedState<TContext, TStepId>) => string;
|
|
19
|
-
deserialize?: (value: string) => unknown;
|
|
20
|
-
migrate?: (value: unknown, persistedVersion: number) => JourneySnapshotStateBase<TContext, TStepId>;
|
|
21
|
-
onError?: (error: unknown) => void;
|
|
22
|
-
};
|
|
23
|
-
export type ResolvedPersistence<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
24
|
-
key: string;
|
|
25
|
-
storage: JourneyStorage;
|
|
26
|
-
version: number;
|
|
27
|
-
clearOnReset: boolean;
|
|
28
|
-
allowList?: readonly string[];
|
|
29
|
-
blockList: readonly string[];
|
|
30
|
-
serialize: (value: JourneyPersistedState<TContext, TStepId>) => string;
|
|
31
|
-
deserialize: (value: string) => unknown;
|
|
32
|
-
migrate?: (value: unknown, persistedVersion: number) => JourneySnapshotStateBase<TContext, TStepId>;
|
|
33
|
-
onError?: (error: unknown) => void;
|
|
34
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { JourneyJsonObject, JourneySnapshotStateBase } from "./journey.types";
|
|
2
|
-
export type JourneyPersistedState<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
3
|
-
version: number;
|
|
4
|
-
snapshot: JourneySnapshotStateBase<TContext, TStepId>;
|
|
5
|
-
};
|
|
6
|
-
export type JourneyStorage = {
|
|
7
|
-
getItem: (key: string) => string | null;
|
|
8
|
-
setItem: (key: string, value: string) => void;
|
|
9
|
-
removeItem: (key: string) => void;
|
|
10
|
-
};
|
|
11
|
-
export type JourneyPersistenceOptions<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
12
|
-
key: string;
|
|
13
|
-
storage?: JourneyStorage;
|
|
14
|
-
version?: number;
|
|
15
|
-
clearOnReset?: boolean;
|
|
16
|
-
allowList?: readonly string[];
|
|
17
|
-
blockList?: readonly string[];
|
|
18
|
-
serialize?: (value: JourneyPersistedState<TContext, TStepId>) => string;
|
|
19
|
-
deserialize?: (value: string) => unknown;
|
|
20
|
-
migrate?: (value: unknown, persistedVersion: number) => JourneySnapshotStateBase<TContext, TStepId>;
|
|
21
|
-
onError?: (error: unknown) => void;
|
|
22
|
-
};
|
|
23
|
-
export type ResolvedPersistence<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
24
|
-
key: string;
|
|
25
|
-
storage: JourneyStorage;
|
|
26
|
-
version: number;
|
|
27
|
-
clearOnReset: boolean;
|
|
28
|
-
allowList?: readonly string[];
|
|
29
|
-
blockList: readonly string[];
|
|
30
|
-
serialize: (value: JourneyPersistedState<TContext, TStepId>) => string;
|
|
31
|
-
deserialize: (value: string) => unknown;
|
|
32
|
-
migrate?: (value: unknown, persistedVersion: number) => JourneySnapshotStateBase<TContext, TStepId>;
|
|
33
|
-
onError?: (error: unknown) => void;
|
|
34
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { JourneyMachineSnapshotReason } from "./machine.types";
|
|
2
|
-
import type { JourneyJsonObject, JourneySnapshot } from "./journey.types";
|
|
3
|
-
import type { JourneyObservationEvent } from "./observation.types";
|
|
4
|
-
/** Snapshot entry captured by the replay plugin. */
|
|
5
|
-
export type JourneyReplaySnapshotEntry<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
6
|
-
kind: "snapshot";
|
|
7
|
-
timestamp: number;
|
|
8
|
-
reason: JourneyMachineSnapshotReason;
|
|
9
|
-
snapshot: JourneySnapshot<TContext, TStepId>;
|
|
10
|
-
};
|
|
11
|
-
/** Observation event entry captured by the replay plugin. */
|
|
12
|
-
export type JourneyReplayEventEntry<TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = {
|
|
13
|
-
kind: "event";
|
|
14
|
-
timestamp: number;
|
|
15
|
-
event: JourneyObservationEvent<TStepId, TEventMap>;
|
|
16
|
-
};
|
|
17
|
-
/** Ordered replay entry captured from a live machine session. */
|
|
18
|
-
export type JourneyReplayEntry<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = JourneyReplaySnapshotEntry<TContext, TStepId> | JourneyReplayEventEntry<TStepId, TEventMap>;
|
|
19
|
-
/** Full replay session captured from a journey machine. */
|
|
20
|
-
export type JourneyReplaySession<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = {
|
|
21
|
-
version: 1;
|
|
22
|
-
initialSnapshot: JourneySnapshot<TContext, TStepId> | null;
|
|
23
|
-
entries: JourneyReplayEntry<TContext, TStepId, TEventMap>[];
|
|
24
|
-
truncated: boolean;
|
|
25
|
-
};
|
|
26
|
-
/** Runtime options for the replay plugin. */
|
|
27
|
-
export type JourneyReplayPluginOptions = {
|
|
28
|
-
maxEntries?: number;
|
|
29
|
-
captureEvents?: boolean;
|
|
30
|
-
captureSnapshots?: boolean;
|
|
31
|
-
};
|
|
32
|
-
/** Serialization options for `exportReplaySession()`. */
|
|
33
|
-
export type JourneyReplayExportOptions = {
|
|
34
|
-
pretty?: boolean;
|
|
35
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { JourneyMachineSnapshotReason } from "./machine.types";
|
|
2
|
-
import type { JourneyJsonObject, JourneySnapshot } from "./journey.types";
|
|
3
|
-
import type { JourneyObservationEvent } from "./observation.types";
|
|
4
|
-
/** Snapshot entry captured by the replay plugin. */
|
|
5
|
-
export type JourneyReplaySnapshotEntry<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
6
|
-
kind: "snapshot";
|
|
7
|
-
timestamp: number;
|
|
8
|
-
reason: JourneyMachineSnapshotReason;
|
|
9
|
-
snapshot: JourneySnapshot<TContext, TStepId>;
|
|
10
|
-
};
|
|
11
|
-
/** Observation event entry captured by the replay plugin. */
|
|
12
|
-
export type JourneyReplayEventEntry<TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = {
|
|
13
|
-
kind: "event";
|
|
14
|
-
timestamp: number;
|
|
15
|
-
event: JourneyObservationEvent<TStepId, TEventMap>;
|
|
16
|
-
};
|
|
17
|
-
/** Ordered replay entry captured from a live machine session. */
|
|
18
|
-
export type JourneyReplayEntry<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = JourneyReplaySnapshotEntry<TContext, TStepId> | JourneyReplayEventEntry<TStepId, TEventMap>;
|
|
19
|
-
/** Full replay session captured from a journey machine. */
|
|
20
|
-
export type JourneyReplaySession<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = {
|
|
21
|
-
version: 1;
|
|
22
|
-
initialSnapshot: JourneySnapshot<TContext, TStepId> | null;
|
|
23
|
-
entries: JourneyReplayEntry<TContext, TStepId, TEventMap>[];
|
|
24
|
-
truncated: boolean;
|
|
25
|
-
};
|
|
26
|
-
/** Runtime options for the replay plugin. */
|
|
27
|
-
export type JourneyReplayPluginOptions = {
|
|
28
|
-
maxEntries?: number;
|
|
29
|
-
captureEvents?: boolean;
|
|
30
|
-
captureSnapshots?: boolean;
|
|
31
|
-
};
|
|
32
|
-
/** Serialization options for `exportReplaySession()`. */
|
|
33
|
-
export type JourneyReplayExportOptions = {
|
|
34
|
-
pretty?: boolean;
|
|
35
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import type { JourneyBuiltInFrom, JourneyEvent, JourneyFullEventType, JourneyGoToEvent, JourneyHistory, JourneyJsonObject, JourneyPayloadFor, JourneySendEvent, JourneySendResult, JourneySnapshot, JourneyTerminal } from "./journey.types";
|
|
2
|
-
type JourneyTransitionArgsBase<TContext extends JourneyJsonObject, TStepId extends string, THandlers extends Record<string, unknown>> = {
|
|
3
|
-
snapshot: JourneySnapshot<TContext, TStepId>;
|
|
4
|
-
context: Readonly<TContext>;
|
|
5
|
-
from: TStepId;
|
|
6
|
-
timeline: JourneyHistory<TStepId>["timeline"];
|
|
7
|
-
index: number;
|
|
8
|
-
signal: AbortSignal;
|
|
9
|
-
handlers: THandlers;
|
|
10
|
-
};
|
|
11
|
-
type JourneyTransitionEventOfType<TStepId extends string, TEventMap extends Record<string, unknown>, TEventType extends JourneyFullEventType<TEventMap>> = TEventType extends "goToStepById" ? JourneyGoToEvent<TStepId, JourneyPayloadFor<TEventMap, "goToStepById">> : {
|
|
12
|
-
type: TEventType;
|
|
13
|
-
payload?: JourneyPayloadFor<TEventMap, TEventType>;
|
|
14
|
-
};
|
|
15
|
-
export type JourneyDispatch<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown>> = (event: JourneySendEvent<TStepId, TEventMap>) => Promise<JourneySendResult<TContext, TStepId>>;
|
|
16
|
-
export type JourneyLifecycleArgs<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown>, THandlers extends Record<string, unknown>> = {
|
|
17
|
-
snapshot: JourneySnapshot<TContext, TStepId>;
|
|
18
|
-
context: Readonly<TContext>;
|
|
19
|
-
from: TStepId;
|
|
20
|
-
to: TStepId | JourneyTerminal;
|
|
21
|
-
event: {
|
|
22
|
-
type: string;
|
|
23
|
-
payload?: unknown;
|
|
24
|
-
};
|
|
25
|
-
transitionId: string | null;
|
|
26
|
-
label?: string;
|
|
27
|
-
handlers: THandlers;
|
|
28
|
-
signal: AbortSignal;
|
|
29
|
-
dispatch: JourneyDispatch<TContext, TStepId, TEventMap>;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Wrap callback signatures to opt into TypeScript's bivariant parameter checking.
|
|
33
|
-
* This keeps narrow event payload handlers assignable to wider transition slots.
|
|
34
|
-
*/
|
|
35
|
-
type JourneyBivariantCallback<TArgs, TResult> = {
|
|
36
|
-
bivarianceHack(args: TArgs): TResult;
|
|
37
|
-
}["bivarianceHack"];
|
|
38
|
-
export type JourneyStepLifecycleCallback<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown>, THandlers extends Record<string, unknown>> = JourneyBivariantCallback<JourneyLifecycleArgs<TContext, TStepId, TEventMap, THandlers>, void | Promise<void>>;
|
|
39
|
-
export type JourneyTransitionArgs<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = JourneyTransitionArgsBase<TContext, TStepId, THandlers> & {
|
|
40
|
-
event: JourneyEvent<TStepId, TEventMap>;
|
|
41
|
-
};
|
|
42
|
-
export type JourneyTransitionArgsForEvent<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown>, THandlers extends Record<string, unknown>, TEventType extends JourneyFullEventType<TEventMap>> = JourneyTransitionArgsBase<TContext, TStepId, THandlers> & {
|
|
43
|
-
event: JourneyTransitionEventOfType<TStepId, TEventMap, TEventType>;
|
|
44
|
-
};
|
|
45
|
-
export type JourneyTransitionUpdateContextArgsForEvent<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown>, TEventType extends JourneyFullEventType<TEventMap>> = {
|
|
46
|
-
snapshot: JourneySnapshot<TContext, TStepId>;
|
|
47
|
-
context: Readonly<TContext>;
|
|
48
|
-
from: TStepId;
|
|
49
|
-
timeline: JourneyHistory<TStepId>["timeline"];
|
|
50
|
-
index: number;
|
|
51
|
-
event: JourneyTransitionEventOfType<TStepId, TEventMap, TEventType>;
|
|
52
|
-
};
|
|
53
|
-
type JourneyStepTransitionEventType<TEventMap extends Record<string, unknown>> = Exclude<JourneyFullEventType<TEventMap>, "completeJourney" | "terminateJourney" | "goToStepById">;
|
|
54
|
-
type JourneyTerminalTransitionEventType<TEventMap extends Record<string, unknown>> = Extract<JourneyFullEventType<TEventMap>, "completeJourney" | "terminateJourney">;
|
|
55
|
-
export type JourneyTransitionTarget<TStepId extends string> = TStepId | JourneyTerminal;
|
|
56
|
-
type JourneyTransitionBehavior<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown>, THandlers extends Record<string, unknown>, TEventType extends JourneyFullEventType<TEventMap>> = {
|
|
57
|
-
label?: string;
|
|
58
|
-
timeoutMs?: number;
|
|
59
|
-
when?: JourneyBivariantCallback<JourneyTransitionArgsForEvent<TContext, TStepId, TEventMap, THandlers, TEventType>, boolean | Promise<boolean>>;
|
|
60
|
-
updateContext?: JourneyBivariantCallback<JourneyTransitionUpdateContextArgsForEvent<TContext, TStepId, TEventMap, TEventType>, TContext>;
|
|
61
|
-
onEnter?: JourneyStepLifecycleCallback<TContext, TStepId, TEventMap, THandlers>;
|
|
62
|
-
onLeave?: JourneyStepLifecycleCallback<TContext, TStepId, TEventMap, THandlers>;
|
|
63
|
-
};
|
|
64
|
-
type JourneyTransitionConfig<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown>, THandlers extends Record<string, unknown>, TEventType extends JourneyFullEventType<TEventMap>> = JourneyTransitionBehavior<TContext, TStepId, TEventMap, THandlers, TEventType> & {
|
|
65
|
-
from: TStepId | JourneyBuiltInFrom;
|
|
66
|
-
};
|
|
67
|
-
export type JourneyStepEventTransition<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>, TEventType extends JourneyStepTransitionEventType<TEventMap> = JourneyStepTransitionEventType<TEventMap>> = {
|
|
68
|
-
[TSelectedEvent in TEventType]: JourneyTransitionConfig<TContext, TStepId, TEventMap, THandlers, TSelectedEvent> & {
|
|
69
|
-
event: TSelectedEvent;
|
|
70
|
-
to: JourneyTransitionTarget<TStepId>;
|
|
71
|
-
};
|
|
72
|
-
}[TEventType];
|
|
73
|
-
export type JourneyTerminalTransition<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>, TEventType extends JourneyTerminalTransitionEventType<TEventMap> = JourneyTerminalTransitionEventType<TEventMap>> = {
|
|
74
|
-
[TSelectedEvent in TEventType]: JourneyTransitionConfig<TContext, TStepId, TEventMap, THandlers, TSelectedEvent> & {
|
|
75
|
-
event: TSelectedEvent;
|
|
76
|
-
to?: never;
|
|
77
|
-
};
|
|
78
|
-
}[TEventType];
|
|
79
|
-
export type JourneyGoToStepTransition<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = JourneyTransitionConfig<TContext, TStepId, TEventMap, THandlers, "goToStepById"> & {
|
|
80
|
-
event: "goToStepById";
|
|
81
|
-
to: TStepId;
|
|
82
|
-
};
|
|
83
|
-
export type JourneyTransition<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = JourneyStepEventTransition<TContext, TStepId, TEventMap, THandlers> | JourneyTerminalTransition<TContext, TStepId, TEventMap, THandlers> | JourneyGoToStepTransition<TContext, TStepId, TEventMap, THandlers>;
|
|
84
|
-
export type JourneyResolvedTransition<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = JourneyTransition<TContext, TStepId, TEventMap, THandlers> & {
|
|
85
|
-
id: string;
|
|
86
|
-
label?: string;
|
|
87
|
-
};
|
|
88
|
-
export type JourneyGlobalTransition<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = JourneyTransition<TContext, TStepId, TEventMap, THandlers> & {
|
|
89
|
-
from: JourneyBuiltInFrom;
|
|
90
|
-
};
|
|
91
|
-
export type JourneyStepEventGraphEdge<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>, TEventType extends JourneyStepTransitionEventType<TEventMap> = JourneyStepTransitionEventType<TEventMap>> = {
|
|
92
|
-
[TSelectedEvent in TEventType]: JourneyTransitionBehavior<TContext, TStepId, TEventMap, THandlers, TSelectedEvent> & {
|
|
93
|
-
to: JourneyTransitionTarget<TStepId>;
|
|
94
|
-
};
|
|
95
|
-
}[TEventType];
|
|
96
|
-
export type JourneyTerminalGraphEdge<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>, TEventType extends JourneyTerminalTransitionEventType<TEventMap> = JourneyTerminalTransitionEventType<TEventMap>> = {
|
|
97
|
-
[TSelectedEvent in TEventType]: JourneyTransitionBehavior<TContext, TStepId, TEventMap, THandlers, TSelectedEvent> & {
|
|
98
|
-
to?: never;
|
|
99
|
-
};
|
|
100
|
-
}[TEventType];
|
|
101
|
-
export type JourneyGoToStepGraphEdge<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = JourneyTransitionBehavior<TContext, TStepId, TEventMap, THandlers, "goToStepById"> & {
|
|
102
|
-
to: TStepId;
|
|
103
|
-
};
|
|
104
|
-
export type JourneyGraphEdge<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>, TEventType extends JourneyFullEventType<TEventMap> = JourneyFullEventType<TEventMap>> = JourneyStepEventGraphEdge<TContext, TStepId, TEventMap, THandlers, Extract<TEventType, JourneyStepTransitionEventType<TEventMap>>> | JourneyTerminalGraphEdge<TContext, TStepId, TEventMap, THandlers, Extract<TEventType, JourneyTerminalTransitionEventType<TEventMap>>> | (Extract<TEventType, "goToStepById"> extends never ? never : JourneyGoToStepGraphEdge<TContext, TStepId, TEventMap, THandlers>);
|
|
105
|
-
export type JourneyTerminalTransitionShorthand<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown>, THandlers extends Record<string, unknown>, TEventType extends JourneyTerminalTransitionEventType<TEventMap>> = true | readonly [] | readonly JourneyGraphEdge<TContext, TStepId, TEventMap, THandlers, TEventType>[];
|
|
106
|
-
export type JourneyStepTransitions<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = Partial<{
|
|
107
|
-
[TSelectedEvent in JourneyFullEventType<TEventMap>]: TSelectedEvent extends "completeJourney" | "terminateJourney" ? JourneyTerminalTransitionShorthand<TContext, TStepId, TEventMap, THandlers, Extract<TSelectedEvent, JourneyTerminalTransitionEventType<TEventMap>>> : readonly JourneyGraphEdge<TContext, TStepId, TEventMap, THandlers, TSelectedEvent>[];
|
|
108
|
-
}>;
|
|
109
|
-
export type JourneyGlobalKey = "global";
|
|
110
|
-
export type JourneyTransitionGraph<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = Partial<Record<TStepId, JourneyStepTransitions<TContext, TStepId, TEventMap, THandlers>>> & {
|
|
111
|
-
global?: JourneyStepTransitions<TContext, TStepId, TEventMap, THandlers>;
|
|
112
|
-
};
|
|
113
|
-
export type JourneyLinearStep<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = JourneyTransitionBehavior<TContext, TStepId, TEventMap, THandlers, "goToNextStep"> & {
|
|
114
|
-
step: TStepId;
|
|
115
|
-
when?: never;
|
|
116
|
-
to?: never;
|
|
117
|
-
from?: never;
|
|
118
|
-
event?: never;
|
|
119
|
-
};
|
|
120
|
-
export type JourneyLinearTransitions<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = readonly [TStepId, ...(TStepId | JourneyLinearStep<TContext, TStepId, TEventMap, THandlers>)[]];
|
|
121
|
-
export type JourneyTransitionsDefinition<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, THandlers extends Record<string, unknown> = Record<never, never>> = JourneyLinearTransitions<TContext, TStepId, TEventMap, THandlers> | JourneyTransitionGraph<TContext, TStepId, TEventMap, THandlers>;
|
|
122
|
-
export {};
|