@rxova/journey-core 1.0.0-rc.2 → 1.0.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 +182 -186
- 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 +46 -0
- package/dist/core/helpers.d.ts +46 -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 +78 -79
- 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,191 +0,0 @@
|
|
|
1
|
-
import type { JourneyResolvedTransition, JourneyStepLifecycleCallback, JourneyTransitionsDefinition } from "./transitions.types";
|
|
2
|
-
/** Terminal outcomes reached when a journey completes or is explicitly terminated. */
|
|
3
|
-
export type JourneyTerminal = "COMPLETE" | "TERMINATED";
|
|
4
|
-
/** Union of possible runtime machine statuses. */
|
|
5
|
-
export type JourneyStatus = "idled" | "running" | "completed" | "terminated";
|
|
6
|
-
/** Mode inferred from the journey transition syntax. */
|
|
7
|
-
export type JourneyMode = "linear" | "graph" | "headless";
|
|
8
|
-
/** Wildcard step identifier, exposed as a type-only literal. */
|
|
9
|
-
export type JourneyBuiltInFrom = "*";
|
|
10
|
-
/** Default transition event names supported by machine convenience APIs. */
|
|
11
|
-
export type JourneyDefaultEventType = "goToNextStep" | "goToPreviousStep" | "terminateJourney" | "completeJourney" | "goToStepById";
|
|
12
|
-
/** JSON primitive values accepted inside runtime context. */
|
|
13
|
-
export type JourneyJsonPrimitive = string | number | boolean | null;
|
|
14
|
-
/** JSON-compatible value accepted inside runtime context. */
|
|
15
|
-
export type JourneyJsonValue = JourneyJsonPrimitive | {
|
|
16
|
-
[key: string]: JourneyJsonValue;
|
|
17
|
-
} | JourneyJsonValue[];
|
|
18
|
-
/** JSON-compatible object accepted as the machine context root. */
|
|
19
|
-
export type JourneyJsonObject = {
|
|
20
|
-
[key: string]: JourneyJsonValue;
|
|
21
|
-
};
|
|
22
|
-
/** Derives the full event type union from a user-supplied event map. */
|
|
23
|
-
export type JourneyFullEventType<TEventMap extends Record<string, unknown>> = (keyof TEventMap & string) | JourneyDefaultEventType;
|
|
24
|
-
type JourneyBuiltInSendEventType = Exclude<JourneyDefaultEventType, "goToStepById">;
|
|
25
|
-
type JourneyCustomSendEventType<TEventMap extends Record<string, unknown>> = Exclude<keyof TEventMap & string, JourneyDefaultEventType>;
|
|
26
|
-
/** Union of supported async lifecycle phases. */
|
|
27
|
-
export type JourneyAsyncPhase = "idle" | "evaluating-when" | "error";
|
|
28
|
-
/** Async execution state for a single step. */
|
|
29
|
-
export type JourneyStepAsyncState = {
|
|
30
|
-
phase: JourneyAsyncPhase;
|
|
31
|
-
eventType: string | null;
|
|
32
|
-
transitionId: string | null;
|
|
33
|
-
/** Captured error from a failed guard or lifecycle handler. `null` when no error is present. */
|
|
34
|
-
error: unknown;
|
|
35
|
-
};
|
|
36
|
-
/** Aggregated async state for the machine, keyed by step id. */
|
|
37
|
-
export type JourneyAsyncState<TStepId extends string> = {
|
|
38
|
-
isLoading: boolean;
|
|
39
|
-
byStep: Record<TStepId, JourneyStepAsyncState>;
|
|
40
|
-
};
|
|
41
|
-
/** Minimal event shape used across runtime boundaries. */
|
|
42
|
-
export type JourneyBaseEvent = {
|
|
43
|
-
type: string;
|
|
44
|
-
payload?: unknown;
|
|
45
|
-
};
|
|
46
|
-
/** Resolves payload type for a specific event type from the provided event map. */
|
|
47
|
-
export type JourneyPayloadFor<TEventMap extends Record<string, unknown>, TEvent extends string> = TEvent extends keyof TEventMap ? TEventMap[TEvent] : unknown;
|
|
48
|
-
/** Built-in direct-navigation event that targets a specific step id. */
|
|
49
|
-
export type JourneyGoToEvent<TStepId extends string, TPayload = unknown> = {
|
|
50
|
-
type: "goToStepById";
|
|
51
|
-
stepId: TStepId;
|
|
52
|
-
payload?: TPayload;
|
|
53
|
-
};
|
|
54
|
-
/** Built-in send events supported by machine convenience APIs. */
|
|
55
|
-
export type JourneyBuiltInSendEvent<TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = JourneyGoToEvent<TStepId, JourneyPayloadFor<TEventMap, "goToStepById">> | {
|
|
56
|
-
[TType in JourneyBuiltInSendEventType]: {
|
|
57
|
-
type: TType;
|
|
58
|
-
payload?: JourneyPayloadFor<TEventMap, TType>;
|
|
59
|
-
};
|
|
60
|
-
}[JourneyBuiltInSendEventType];
|
|
61
|
-
/** Custom send events derived from a user-supplied event map. */
|
|
62
|
-
export type JourneyCustomSendEvent<TEventMap extends Record<string, unknown> = Record<never, never>> = {
|
|
63
|
-
[TType in JourneyCustomSendEventType<TEventMap>]: {
|
|
64
|
-
type: TType;
|
|
65
|
-
payload?: JourneyPayloadFor<TEventMap, TType>;
|
|
66
|
-
};
|
|
67
|
-
}[JourneyCustomSendEventType<TEventMap>];
|
|
68
|
-
/** Event union accepted by `JourneyMachine.send`. */
|
|
69
|
-
export type JourneySendEvent<TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = JourneyBuiltInSendEvent<TStepId, TEventMap> | JourneyCustomSendEvent<TEventMap>;
|
|
70
|
-
/** Event union available to transitions and guards for the declared event type set. */
|
|
71
|
-
export type JourneyEvent<TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = JourneySendEvent<TStepId, TEventMap>;
|
|
72
|
-
/** Step definition with optional metadata and lifecycle callbacks. */
|
|
73
|
-
export type JourneyStepDefinition<TContext extends JourneyJsonObject = JourneyJsonObject, TStepId extends string = string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown, THandlers extends Record<string, unknown> = Record<never, never>> = {
|
|
74
|
-
meta?: TStepMeta;
|
|
75
|
-
/** Called when the machine enters this step. */
|
|
76
|
-
onEnter?: JourneyStepLifecycleCallback<TContext, TStepId, TEventMap, THandlers>;
|
|
77
|
-
/** Called when the machine leaves this step. */
|
|
78
|
-
onLeave?: JourneyStepLifecycleCallback<TContext, TStepId, TEventMap, THandlers>;
|
|
79
|
-
};
|
|
80
|
-
/** Timeline of visited steps and current history index. */
|
|
81
|
-
export type JourneyHistory<TStepId extends string> = {
|
|
82
|
-
timeline: readonly TStepId[];
|
|
83
|
-
index: number;
|
|
84
|
-
};
|
|
85
|
-
/** Core snapshot state without async execution details. */
|
|
86
|
-
export type JourneySnapshotStateBase<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
87
|
-
currentStepId: TStepId;
|
|
88
|
-
history: JourneyHistory<TStepId>;
|
|
89
|
-
context: TContext;
|
|
90
|
-
visited: Record<TStepId, boolean>;
|
|
91
|
-
status: JourneyStatus;
|
|
92
|
-
};
|
|
93
|
-
/** Serializable runtime snapshot of the journey state. */
|
|
94
|
-
export type JourneySnapshot<TContext extends JourneyJsonObject, TStepId extends string> = JourneySnapshotStateBase<TContext, TStepId> & {
|
|
95
|
-
async: JourneyAsyncState<TStepId>;
|
|
96
|
-
};
|
|
97
|
-
/** Common read-only computed state exposed by a machine instance. */
|
|
98
|
-
export type JourneyComputedBase<TStepId extends string> = {
|
|
99
|
-
mode: JourneyMode;
|
|
100
|
-
activeStepId: TStepId;
|
|
101
|
-
activeStepIndex: number;
|
|
102
|
-
visitedStepCount: number;
|
|
103
|
-
isLoading: boolean;
|
|
104
|
-
isIdle: boolean;
|
|
105
|
-
isRunning: boolean;
|
|
106
|
-
isComplete: boolean;
|
|
107
|
-
isTerminated: boolean;
|
|
108
|
-
isInitialStep: boolean;
|
|
109
|
-
};
|
|
110
|
-
/** Wizard-style computed state available when transitions use linear array syntax. */
|
|
111
|
-
export type JourneyLinearComputed<TStepId extends string> = JourneyComputedBase<TStepId> & {
|
|
112
|
-
mode: "linear";
|
|
113
|
-
stepCount: number;
|
|
114
|
-
journeyLength: number;
|
|
115
|
-
isFirstStep: boolean;
|
|
116
|
-
isLastStep: boolean;
|
|
117
|
-
stepOrder: readonly TStepId[];
|
|
118
|
-
};
|
|
119
|
-
/** Computed state available when transitions use graph object syntax. */
|
|
120
|
-
export type JourneyGraphComputed<TStepId extends string> = JourneyComputedBase<TStepId> & {
|
|
121
|
-
mode: "graph";
|
|
122
|
-
stepCount?: undefined;
|
|
123
|
-
journeyLength?: undefined;
|
|
124
|
-
isFirstStep?: undefined;
|
|
125
|
-
isLastStep?: undefined;
|
|
126
|
-
stepOrder?: undefined;
|
|
127
|
-
};
|
|
128
|
-
/** Computed state available when transitions are omitted and navigation is headless. */
|
|
129
|
-
export type JourneyHeadlessComputed<TStepId extends string> = JourneyComputedBase<TStepId> & {
|
|
130
|
-
mode: "headless";
|
|
131
|
-
stepCount?: undefined;
|
|
132
|
-
journeyLength?: undefined;
|
|
133
|
-
isFirstStep?: undefined;
|
|
134
|
-
isLastStep?: undefined;
|
|
135
|
-
stepOrder?: undefined;
|
|
136
|
-
};
|
|
137
|
-
/** Mode-aware computed state returned by `JourneyMachine.getComputed()`. */
|
|
138
|
-
export type JourneyComputed<TStepId extends string> = JourneyLinearComputed<TStepId> | JourneyGraphComputed<TStepId> | JourneyHeadlessComputed<TStepId>;
|
|
139
|
-
/** Selector function that derives a value from a machine snapshot. */
|
|
140
|
-
export type JourneySelector<TContext extends JourneyJsonObject, TStepId extends string, TSelected = unknown> = (snapshot: JourneySnapshot<TContext, TStepId>) => TSelected;
|
|
141
|
-
/** Equality function used to compare selected values between snapshot updates. */
|
|
142
|
-
export type JourneyEqualityFn<TValue> = (previous: TValue, next: TValue) => boolean;
|
|
143
|
-
/** Shared definition fields without transition configuration. */
|
|
144
|
-
export type JourneyDefinitionBase<TContext extends JourneyJsonObject, TStepId extends string, TStepMeta = unknown, THandlers extends Record<string, unknown> = Record<never, never>> = {
|
|
145
|
-
/**
|
|
146
|
-
* The step the machine starts on.
|
|
147
|
-
* - **Linear transitions**: optional — defaults to the first element of the
|
|
148
|
-
* transitions array. When provided, must exist in the array and the machine
|
|
149
|
-
* starts from that step (useful for resuming mid-flow).
|
|
150
|
-
* - **Graph / headless**: required.
|
|
151
|
-
*/
|
|
152
|
-
initial?: TStepId;
|
|
153
|
-
context: TContext;
|
|
154
|
-
handlers?: THandlers;
|
|
155
|
-
steps: Record<TStepId, JourneyStepDefinition<TContext, TStepId, Record<never, never>, TStepMeta, THandlers>>;
|
|
156
|
-
};
|
|
157
|
-
/** Full machine definition used to create a journey machine instance. */
|
|
158
|
-
export type JourneyDefinition<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown, THandlers extends Record<string, unknown> = Record<never, never>> = Omit<JourneyDefinitionBase<TContext, TStepId, TStepMeta, THandlers>, "steps"> & {
|
|
159
|
-
steps: Record<TStepId, JourneyStepDefinition<TContext, TStepId, TEventMap, TStepMeta, THandlers>>;
|
|
160
|
-
transitions?: JourneyTransitionsDefinition<TContext, TStepId, TEventMap, THandlers>;
|
|
161
|
-
};
|
|
162
|
-
export type JourneyResolvedDefinition<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown, THandlers extends Record<string, unknown> = Record<never, never>> = Required<Pick<JourneyDefinitionBase<TContext, TStepId, TStepMeta, THandlers>, "initial">> & Omit<JourneyDefinition<TContext, TStepId, TEventMap, TStepMeta, THandlers>, "transitions"> & {
|
|
163
|
-
transitions: readonly JourneyResolvedTransition<TContext, TStepId, TEventMap, THandlers>[];
|
|
164
|
-
};
|
|
165
|
-
export type JourneyExecutionPathEventType<TEventType extends string> = TEventType | JourneyDefaultEventType;
|
|
166
|
-
/** Structural execution path returned by `getExecutionPaths()`. */
|
|
167
|
-
export type JourneyExecutionPath<TStepId extends string, TEventType extends string> = {
|
|
168
|
-
steps: TStepId[];
|
|
169
|
-
events: JourneyExecutionPathEventType<TEventType>[];
|
|
170
|
-
terminated: "final" | "depth" | "cycle" | "limit";
|
|
171
|
-
};
|
|
172
|
-
/** Result returned by structural path enumeration. */
|
|
173
|
-
export type JourneyExecutionPathsResult<TStepId extends string, TEventType extends string> = {
|
|
174
|
-
paths: JourneyExecutionPath<TStepId, TEventType>[];
|
|
175
|
-
truncated: boolean;
|
|
176
|
-
cyclesDetected: boolean;
|
|
177
|
-
};
|
|
178
|
-
/** Options for structural path enumeration from the initial step. */
|
|
179
|
-
export type JourneyExecutionPathOptions = {
|
|
180
|
-
maxDepth?: number;
|
|
181
|
-
maxPaths?: number;
|
|
182
|
-
};
|
|
183
|
-
/** Result returned from send/navigation APIs. */
|
|
184
|
-
export type JourneySendResult<TContext extends JourneyJsonObject, TStepId extends string> = {
|
|
185
|
-
transitioned: boolean;
|
|
186
|
-
transitionId?: string;
|
|
187
|
-
label?: string;
|
|
188
|
-
error?: unknown;
|
|
189
|
-
snapshot: JourneySnapshot<TContext, TStepId>;
|
|
190
|
-
};
|
|
191
|
-
export {};
|
|
@@ -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,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
|
-
};
|