@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,27 +0,0 @@
|
|
|
1
|
-
import type { JourneyJsonObject, JourneyMachine, JourneyReplayExportOptions, JourneyReplayPluginOptions, JourneyReplaySession, JourneySnapshot } from "../../types";
|
|
2
|
-
/** Serializes a replay session into a JSON string safe for logging or export. */
|
|
3
|
-
export declare const serializeReplaySession: <TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>>(session: JourneyReplaySession<TContext, TStepId, TEventMap>, options?: JourneyReplayExportOptions) => string;
|
|
4
|
-
export type JourneyReplayMachineExtension<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>> = {
|
|
5
|
-
getReplaySession: () => JourneyReplaySession<TContext, TStepId, TEventMap>;
|
|
6
|
-
clearReplaySession: () => void;
|
|
7
|
-
exportReplaySession: (options?: JourneyReplayExportOptions) => string;
|
|
8
|
-
};
|
|
9
|
-
export type JourneyReplayMachine<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown, THandlers extends Record<string, unknown> = Record<never, never>> = JourneyMachine<TContext, TStepId, TEventMap, TStepMeta, THandlers> & JourneyReplayMachineExtension<TContext, TStepId, TEventMap>;
|
|
10
|
-
/** Creates a plugin that records snapshot and lifecycle activity into a replay session. */
|
|
11
|
-
export declare const createReplayPlugin: (options?: JourneyReplayPluginOptions) => {
|
|
12
|
-
name: string;
|
|
13
|
-
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>>() => {
|
|
14
|
-
hydrateSnapshot: (snapshot: JourneySnapshot<TContext, TStepId>) => JourneySnapshot<TContext, TStepId>;
|
|
15
|
-
onSnapshotChange: ({ snapshot, reason }: import("../../types").JourneyMachinePluginSnapshotChange<TContext, TStepId>) => void;
|
|
16
|
-
augmentMachine: ({ machine }: {
|
|
17
|
-
machine: JourneyMachine<TContext, TStepId, TEventMap, TStepMeta, THandlers>;
|
|
18
|
-
journey: import("../..").JourneyDefinition<TContext, TStepId, TEventMap, TStepMeta, THandlers>;
|
|
19
|
-
resolvedJourney: import("../../types").JourneyResolvedDefinition<TContext, TStepId, TEventMap, TStepMeta, THandlers>;
|
|
20
|
-
}) => {
|
|
21
|
-
getReplaySession: () => JourneyReplaySession<JourneyJsonObject, string, Record<string, unknown>>;
|
|
22
|
-
clearReplaySession: () => void;
|
|
23
|
-
exportReplaySession: (exportOptions?: JourneyReplayExportOptions) => string;
|
|
24
|
-
};
|
|
25
|
-
dispose: () => void;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var J=n=>typeof n!="number"||!Number.isFinite(n)?500:Math.max(1,Math.trunc(n)),a=(n,e=new WeakSet)=>{if(n===null||typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="bigint")return n.toString();if(typeof n>"u")return null;if(typeof n=="function"||typeof n=="symbol")return`[unsupported:${typeof n}]`;if(n instanceof Error)return{name:n.name,message:n.message,...n.stack?{stack:n.stack}:{}};if(n instanceof Date)return n.toISOString();if(Array.isArray(n))return n.map(r=>a(r,e));if(typeof n=="object"){if(e.has(n))return"[circular]";e.add(n);let r={};for(let[p,s]of Object.entries(n))r[p]=a(s,e);return e.delete(n),r}return String(n)},g=(n,e)=>JSON.stringify(a(n),null,e?.pretty?2:void 0),S=(n={})=>{let e=n.captureEvents??!0,r=n.captureSnapshots??!0,p=J(n.maxEntries),s=null,i=[],y=!1,u,c=t=>{i.length>=p&&(i.shift(),y=!0),i.push(t)},d=()=>({version:1,initialSnapshot:s,entries:[...i],truncated:y});return{name:"replay",setup:()=>({hydrateSnapshot:t=>(s=t,t),onSnapshotChange:({snapshot:t,reason:o})=>{r&&c({kind:"snapshot",timestamp:Date.now(),reason:o,snapshot:t})},augmentMachine:({machine:t})=>(e&&(u=t.subscribeEvent(o=>{c({kind:"event",timestamp:o.timestamp,event:o})})),{getReplaySession:()=>d(),clearReplaySession:()=>{s=t.getSnapshot(),i.length=0,y=!1},exportReplaySession:o=>g(d(),o)}),dispose:()=>{u?.()}})}};export{S as createReplayPlugin,g as serializeReplaySession};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/plugins/replay/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n JourneyJsonObject,\n JourneyMachine,\n JourneyMachinePlugin,\n JourneyObservationEvent,\n JourneyReplayEntry,\n JourneyReplayExportOptions,\n JourneyReplayPluginOptions,\n JourneyReplaySession,\n JourneySnapshot\n} from \"../../types\";\n\nconst normalizeMaxEntries = (value: number | undefined) => {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n return 500;\n }\n\n return Math.max(1, Math.trunc(value));\n};\n\nconst toSerializable = (value: unknown, seen = new WeakSet<object>()): unknown => {\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n return value;\n }\n\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n\n if (typeof value === \"undefined\") {\n return null;\n }\n\n if (typeof value === \"function\" || typeof value === \"symbol\") {\n return `[unsupported:${typeof value}]`;\n }\n\n if (value instanceof Error) {\n return {\n name: value.name,\n message: value.message,\n ...(value.stack ? { stack: value.stack } : {})\n };\n }\n\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => toSerializable(item, seen));\n }\n\n if (typeof value === \"object\") {\n if (seen.has(value)) {\n return \"[circular]\";\n }\n\n seen.add(value);\n const output: Record<string, unknown> = {};\n for (const [key, item] of Object.entries(value)) {\n output[key] = toSerializable(item, seen);\n }\n seen.delete(value);\n return output;\n }\n\n return String(value);\n};\n\n/** Serializes a replay session into a JSON string safe for logging or export. */\nexport const serializeReplaySession = <\n TContext extends JourneyJsonObject,\n TStepId extends string,\n TEventMap extends Record<string, unknown> = Record<never, never>\n>(\n session: JourneyReplaySession<TContext, TStepId, TEventMap>,\n options?: JourneyReplayExportOptions\n) => JSON.stringify(toSerializable(session), null, options?.pretty ? 2 : undefined);\n\nexport type JourneyReplayMachineExtension<\n TContext extends JourneyJsonObject,\n TStepId extends string,\n TEventMap extends Record<string, unknown> = Record<never, never>\n> = {\n getReplaySession: () => JourneyReplaySession<TContext, TStepId, TEventMap>;\n clearReplaySession: () => void;\n exportReplaySession: (options?: JourneyReplayExportOptions) => string;\n};\n\nexport type JourneyReplayMachine<\n TContext extends JourneyJsonObject,\n TStepId extends string,\n TEventMap extends Record<string, unknown> = Record<never, never>,\n TStepMeta = unknown,\n THandlers extends Record<string, unknown> = Record<never, never>\n> = JourneyMachine<TContext, TStepId, TEventMap, TStepMeta, THandlers> &\n JourneyReplayMachineExtension<TContext, TStepId, TEventMap>;\n\n/** Creates a plugin that records snapshot and lifecycle activity into a replay session. */\nexport const createReplayPlugin = (options: JourneyReplayPluginOptions = {}) => {\n const captureEvents = options.captureEvents ?? true;\n const captureSnapshots = options.captureSnapshots ?? true;\n const maxEntries = normalizeMaxEntries(options.maxEntries);\n\n let initialSnapshot: JourneySnapshot<JourneyJsonObject, string> | null = null;\n const entries: JourneyReplayEntry<JourneyJsonObject, string, Record<string, unknown>>[] = [];\n let truncated = false;\n let unsubscribeEvents: (() => void) | undefined;\n\n const pushEntry = (\n entry: JourneyReplayEntry<JourneyJsonObject, string, Record<string, unknown>>\n ) => {\n if (entries.length >= maxEntries) {\n entries.shift();\n truncated = true;\n }\n\n entries.push(entry);\n };\n\n const buildSession = () =>\n ({\n version: 1 as const,\n initialSnapshot,\n entries: [...entries],\n truncated\n }) satisfies JourneyReplaySession<JourneyJsonObject, string, Record<string, unknown>>;\n\n return {\n name: \"replay\",\n setup: () => ({\n hydrateSnapshot: (snapshot) => {\n initialSnapshot = snapshot as JourneySnapshot<JourneyJsonObject, string>;\n return snapshot;\n },\n onSnapshotChange: ({ snapshot, reason }) => {\n if (!captureSnapshots) {\n return;\n }\n\n pushEntry({\n kind: \"snapshot\",\n timestamp: Date.now(),\n reason,\n snapshot: snapshot as JourneySnapshot<JourneyJsonObject, string>\n });\n },\n augmentMachine: ({ machine }) => {\n if (captureEvents) {\n unsubscribeEvents = machine.subscribeEvent((event) => {\n pushEntry({\n kind: \"event\",\n timestamp: event.timestamp,\n event: event as JourneyObservationEvent<string, Record<string, unknown>>\n });\n });\n }\n\n return {\n getReplaySession: () =>\n buildSession() as JourneyReplaySession<\n JourneyJsonObject,\n string,\n Record<string, unknown>\n >,\n clearReplaySession: () => {\n initialSnapshot = machine.getSnapshot() as JourneySnapshot<JourneyJsonObject, string>;\n entries.length = 0;\n truncated = false;\n },\n exportReplaySession: (exportOptions?: JourneyReplayExportOptions) =>\n serializeReplaySession(buildSession(), exportOptions)\n };\n },\n dispose: () => {\n unsubscribeEvents?.();\n }\n })\n } satisfies JourneyMachinePlugin;\n};\n"],
|
|
5
|
-
"mappings": "AAYA,IAAMA,EAAuBC,GACvB,OAAOA,GAAU,UAAY,CAAC,OAAO,SAASA,CAAK,EAC9C,IAGF,KAAK,IAAI,EAAG,KAAK,MAAMA,CAAK,CAAC,EAGhCC,EAAiB,CAACD,EAAgBE,EAAO,IAAI,UAA+B,CAChF,GACEF,IAAU,MACV,OAAOA,GAAU,UACjB,OAAOA,GAAU,UACjB,OAAOA,GAAU,UAEjB,OAAOA,EAGT,GAAI,OAAOA,GAAU,SACnB,OAAOA,EAAM,SAAS,EAGxB,GAAI,OAAOA,EAAU,IACnB,OAAO,KAGT,GAAI,OAAOA,GAAU,YAAc,OAAOA,GAAU,SAClD,MAAO,gBAAgB,OAAOA,CAAK,IAGrC,GAAIA,aAAiB,MACnB,MAAO,CACL,KAAMA,EAAM,KACZ,QAASA,EAAM,QACf,GAAIA,EAAM,MAAQ,CAAE,MAAOA,EAAM,KAAM,EAAI,CAAC,CAC9C,EAGF,GAAIA,aAAiB,KACnB,OAAOA,EAAM,YAAY,EAG3B,GAAI,MAAM,QAAQA,CAAK,EACrB,OAAOA,EAAM,IAAKG,GAASF,EAAeE,EAAMD,CAAI,CAAC,EAGvD,GAAI,OAAOF,GAAU,SAAU,CAC7B,GAAIE,EAAK,IAAIF,CAAK,EAChB,MAAO,aAGTE,EAAK,IAAIF,CAAK,EACd,IAAMI,EAAkC,CAAC,EACzC,OAAW,CAACC,EAAKF,CAAI,IAAK,OAAO,QAAQH,CAAK,EAC5CI,EAAOC,CAAG,EAAIJ,EAAeE,EAAMD,CAAI,EAEzC,OAAAA,EAAK,OAAOF,CAAK,EACVI,CACT,CAEA,OAAO,OAAOJ,CAAK,CACrB,EAGaM,EAAyB,CAKpCC,EACAC,IACG,KAAK,UAAUP,EAAeM,CAAO,EAAG,KAAMC,GAAS,OAAS,EAAI,MAAS,EAsBrEC,EAAqB,CAACD,EAAsC,CAAC,IAAM,CAC9E,IAAME,EAAgBF,EAAQ,eAAiB,GACzCG,EAAmBH,EAAQ,kBAAoB,GAC/CI,EAAab,EAAoBS,EAAQ,UAAU,EAErDK,EAAqE,KACnEC,EAAoF,CAAC,EACvFC,EAAY,GACZC,EAEEC,EACJC,GACG,CACCJ,EAAQ,QAAUF,IACpBE,EAAQ,MAAM,EACdC,EAAY,IAGdD,EAAQ,KAAKI,CAAK,CACpB,EAEMC,EAAe,KAClB,CACC,QAAS,EACT,gBAAAN,EACA,QAAS,CAAC,GAAGC,CAAO,EACpB,UAAAC,CACF,GAEF,MAAO,CACL,KAAM,SACN,MAAO,KAAO,CACZ,gBAAkBK,IAChBP,EAAkBO,EACXA,GAET,iBAAkB,CAAC,CAAE,SAAAA,EAAU,OAAAC,CAAO,IAAM,CACrCV,GAILM,EAAU,CACR,KAAM,WACN,UAAW,KAAK,IAAI,EACpB,OAAAI,EACA,SAAUD,CACZ,CAAC,CACH,EACA,eAAgB,CAAC,CAAE,QAAAE,CAAQ,KACrBZ,IACFM,EAAoBM,EAAQ,eAAgBC,GAAU,CACpDN,EAAU,CACR,KAAM,QACN,UAAWM,EAAM,UACjB,MAAOA,CACT,CAAC,CACH,CAAC,GAGI,CACL,iBAAkB,IAChBJ,EAAa,EAKf,mBAAoB,IAAM,CACxBN,EAAkBS,EAAQ,YAAY,EACtCR,EAAQ,OAAS,EACjBC,EAAY,EACd,EACA,oBAAsBS,GACpBlB,EAAuBa,EAAa,EAAGK,CAAa,CACxD,GAEF,QAAS,IAAM,CACbR,IAAoB,CACtB,CACF,EACF,CACF",
|
|
6
|
-
"names": ["normalizeMaxEntries", "value", "toSerializable", "seen", "item", "output", "key", "serializeReplaySession", "session", "options", "createReplayPlugin", "captureEvents", "captureSnapshots", "maxEntries", "initialSnapshot", "entries", "truncated", "unsubscribeEvents", "pushEntry", "entry", "buildSession", "snapshot", "reason", "machine", "event", "exportOptions"]
|
|
7
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { JourneyObservationEvent, JourneyTransitionSuccessObservationEvent } from "./observation.types";
|
|
2
|
-
import type { JourneyJsonObject, JourneyTerminal } from "./journey.types";
|
|
3
|
-
/** Standard analytics event names emitted by the analytics plugin. */
|
|
4
|
-
export type JourneyAnalyticsEventName = "journey_started" | "step_viewed" | "step_exited" | "transition_started" | "transition_succeeded" | "transition_failed" | "journey_completed" | "journey_terminated" | "navigation_previous" | "navigation_last_visited" | (string & {});
|
|
5
|
-
/** Analytics payload emitted by the analytics plugin. */
|
|
6
|
-
export type JourneyAnalyticsEventPayload<TContext extends JourneyJsonObject, TStepId extends string, TStepMeta> = Record<string, unknown> & {
|
|
7
|
-
context?: TContext;
|
|
8
|
-
stepId?: TStepId;
|
|
9
|
-
stepMeta?: TStepMeta;
|
|
10
|
-
from?: TStepId;
|
|
11
|
-
to?: TStepId | JourneyTerminal;
|
|
12
|
-
fromStepMeta?: TStepMeta;
|
|
13
|
-
toStepMeta?: TStepMeta;
|
|
14
|
-
durationMs?: number;
|
|
15
|
-
dwellMs?: number;
|
|
16
|
-
eventType?: string;
|
|
17
|
-
transitionId?: JourneyTransitionSuccessObservationEvent<TStepId>["transitionId"];
|
|
18
|
-
label?: JourneyTransitionSuccessObservationEvent<TStepId>["label"];
|
|
19
|
-
};
|
|
20
|
-
/** Event envelope passed to analytics trackers. */
|
|
21
|
-
export type JourneyAnalyticsTrackedEvent<TContext extends JourneyJsonObject, TStepId extends string, TStepMeta> = {
|
|
22
|
-
name: JourneyAnalyticsEventName;
|
|
23
|
-
timestamp: number;
|
|
24
|
-
machineId?: string;
|
|
25
|
-
payload: JourneyAnalyticsEventPayload<TContext, TStepId, TStepMeta>;
|
|
26
|
-
};
|
|
27
|
-
/** Options for the analytics plugin. */
|
|
28
|
-
export type JourneyAnalyticsPluginOptions<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown> = {
|
|
29
|
-
track: (event: JourneyAnalyticsTrackedEvent<TContext, TStepId, TStepMeta>) => void;
|
|
30
|
-
machineId?: string;
|
|
31
|
-
includeStepMeta?: boolean;
|
|
32
|
-
onError?: (error: unknown, event?: JourneyObservationEvent<TStepId, TEventMap> | JourneyAnalyticsTrackedEvent<TContext, TStepId, TStepMeta>) => void;
|
|
33
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { JourneyObservationEvent, JourneyTransitionSuccessObservationEvent } from "./observation.types";
|
|
2
|
-
import type { JourneyJsonObject, JourneyTerminal } from "./journey.types";
|
|
3
|
-
/** Standard analytics event names emitted by the analytics plugin. */
|
|
4
|
-
export type JourneyAnalyticsEventName = "journey_started" | "step_viewed" | "step_exited" | "transition_started" | "transition_succeeded" | "transition_failed" | "journey_completed" | "journey_terminated" | "navigation_previous" | "navigation_last_visited" | (string & {});
|
|
5
|
-
/** Analytics payload emitted by the analytics plugin. */
|
|
6
|
-
export type JourneyAnalyticsEventPayload<TContext extends JourneyJsonObject, TStepId extends string, TStepMeta> = Record<string, unknown> & {
|
|
7
|
-
context?: TContext;
|
|
8
|
-
stepId?: TStepId;
|
|
9
|
-
stepMeta?: TStepMeta;
|
|
10
|
-
from?: TStepId;
|
|
11
|
-
to?: TStepId | JourneyTerminal;
|
|
12
|
-
fromStepMeta?: TStepMeta;
|
|
13
|
-
toStepMeta?: TStepMeta;
|
|
14
|
-
durationMs?: number;
|
|
15
|
-
dwellMs?: number;
|
|
16
|
-
eventType?: string;
|
|
17
|
-
transitionId?: JourneyTransitionSuccessObservationEvent<TStepId>["transitionId"];
|
|
18
|
-
label?: JourneyTransitionSuccessObservationEvent<TStepId>["label"];
|
|
19
|
-
};
|
|
20
|
-
/** Event envelope passed to analytics trackers. */
|
|
21
|
-
export type JourneyAnalyticsTrackedEvent<TContext extends JourneyJsonObject, TStepId extends string, TStepMeta> = {
|
|
22
|
-
name: JourneyAnalyticsEventName;
|
|
23
|
-
timestamp: number;
|
|
24
|
-
machineId?: string;
|
|
25
|
-
payload: JourneyAnalyticsEventPayload<TContext, TStepId, TStepMeta>;
|
|
26
|
-
};
|
|
27
|
-
/** Options for the analytics plugin. */
|
|
28
|
-
export type JourneyAnalyticsPluginOptions<TContext extends JourneyJsonObject, TStepId extends string, TEventMap extends Record<string, unknown> = Record<never, never>, TStepMeta = unknown> = {
|
|
29
|
-
track: (event: JourneyAnalyticsTrackedEvent<TContext, TStepId, TStepMeta>) => void;
|
|
30
|
-
machineId?: string;
|
|
31
|
-
includeStepMeta?: boolean;
|
|
32
|
-
onError?: (error: unknown, event?: JourneyObservationEvent<TStepId, TEventMap> | JourneyAnalyticsTrackedEvent<TContext, TStepId, TStepMeta>) => void;
|
|
33
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { JourneyMachineSnapshotReason } from "./machine.types";
|
|
2
|
-
import type { JourneyPersistenceOptions } from "./persistence.types";
|
|
3
|
-
import type { JourneyJsonObject, JourneySnapshot } from "./journey.types";
|
|
4
|
-
/** Autosave lifecycle status reported by the autosave plugin. */
|
|
5
|
-
export type JourneyAutosaveStatus = "idle" | "pending" | "saved" | "error";
|
|
6
|
-
/** Runtime autosave state exposed through the autosave plugin extension. */
|
|
7
|
-
export type JourneyAutosaveState = {
|
|
8
|
-
status: JourneyAutosaveStatus;
|
|
9
|
-
lastSavedAt?: number;
|
|
10
|
-
pendingReason?: JourneyMachineSnapshotReason;
|
|
11
|
-
error?: unknown;
|
|
12
|
-
};
|
|
13
|
-
/** Options for the autosave plugin. */
|
|
14
|
-
export type JourneyAutosavePluginOptions<TContext extends JourneyJsonObject, TStepId extends string> = JourneyPersistenceOptions<TContext, TStepId> & {
|
|
15
|
-
debounceMs?: number;
|
|
16
|
-
hydrate?: boolean;
|
|
17
|
-
saveOn?: readonly JourneyMachineSnapshotReason[];
|
|
18
|
-
onSaved?: (details: {
|
|
19
|
-
snapshot: JourneySnapshot<TContext, TStepId>;
|
|
20
|
-
reason: JourneyMachineSnapshotReason;
|
|
21
|
-
timestamp: number;
|
|
22
|
-
}) => void;
|
|
23
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { JourneyMachineSnapshotReason } from "./machine.types";
|
|
2
|
-
import type { JourneyPersistenceOptions } from "./persistence.types";
|
|
3
|
-
import type { JourneyJsonObject, JourneySnapshot } from "./journey.types";
|
|
4
|
-
/** Autosave lifecycle status reported by the autosave plugin. */
|
|
5
|
-
export type JourneyAutosaveStatus = "idle" | "pending" | "saved" | "error";
|
|
6
|
-
/** Runtime autosave state exposed through the autosave plugin extension. */
|
|
7
|
-
export type JourneyAutosaveState = {
|
|
8
|
-
status: JourneyAutosaveStatus;
|
|
9
|
-
lastSavedAt?: number;
|
|
10
|
-
pendingReason?: JourneyMachineSnapshotReason;
|
|
11
|
-
error?: unknown;
|
|
12
|
-
};
|
|
13
|
-
/** Options for the autosave plugin. */
|
|
14
|
-
export type JourneyAutosavePluginOptions<TContext extends JourneyJsonObject, TStepId extends string> = JourneyPersistenceOptions<TContext, TStepId> & {
|
|
15
|
-
debounceMs?: number;
|
|
16
|
-
hydrate?: boolean;
|
|
17
|
-
saveOn?: readonly JourneyMachineSnapshotReason[];
|
|
18
|
-
onSaved?: (details: {
|
|
19
|
-
snapshot: JourneySnapshot<TContext, TStepId>;
|
|
20
|
-
reason: JourneyMachineSnapshotReason;
|
|
21
|
-
timestamp: number;
|
|
22
|
-
}) => void;
|
|
23
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { JourneyBuiltInFrom, JourneyMode } from "./journey.types";
|
|
2
|
-
/** Structural diagnostic issue codes returned by journey diagnostics. */
|
|
3
|
-
export type JourneyDiagnosticsIssueCode = "cycle-detected" | "dead-end-step" | "no-terminal-path" | "shadowed-transition" | "unreachable-step";
|
|
4
|
-
/** Severity assigned to a diagnostics issue. */
|
|
5
|
-
export type JourneyDiagnosticsIssueSeverity = "warning" | "error";
|
|
6
|
-
/** Options that affect structural journey diagnostics. */
|
|
7
|
-
export type JourneyDiagnosticsOptions = {
|
|
8
|
-
requireExplicitCompletion?: boolean;
|
|
9
|
-
};
|
|
10
|
-
/** A single diagnostics issue discovered while analyzing a journey definition. */
|
|
11
|
-
export type JourneyDiagnosticsIssue<TStepId extends string, TEventType extends string> = {
|
|
12
|
-
code: JourneyDiagnosticsIssueCode;
|
|
13
|
-
severity: JourneyDiagnosticsIssueSeverity;
|
|
14
|
-
message: string;
|
|
15
|
-
stepId?: TStepId;
|
|
16
|
-
from?: TStepId | JourneyBuiltInFrom;
|
|
17
|
-
eventType?: TEventType;
|
|
18
|
-
transitionId?: string;
|
|
19
|
-
label?: string;
|
|
20
|
-
steps?: readonly TStepId[];
|
|
21
|
-
};
|
|
22
|
-
/** Aggregate diagnostics summary for a journey definition. */
|
|
23
|
-
export type JourneyDiagnosticsSummary = {
|
|
24
|
-
mode: JourneyMode;
|
|
25
|
-
stepCount: number;
|
|
26
|
-
reachableStepCount: number;
|
|
27
|
-
unreachableStepCount: number;
|
|
28
|
-
deadEndCount: number;
|
|
29
|
-
cycleCount: number;
|
|
30
|
-
shadowedTransitionCount: number;
|
|
31
|
-
graphChecksSkipped: boolean;
|
|
32
|
-
terminalPathExists: boolean;
|
|
33
|
-
};
|
|
34
|
-
/** Result returned by `getJourneyDiagnostics()`. */
|
|
35
|
-
export type JourneyDiagnosticsResult<TStepId extends string, TEventType extends string> = {
|
|
36
|
-
issues: JourneyDiagnosticsIssue<TStepId, TEventType>[];
|
|
37
|
-
summary: JourneyDiagnosticsSummary;
|
|
38
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { JourneyBuiltInFrom, JourneyMode } from "./journey.types";
|
|
2
|
-
/** Structural diagnostic issue codes returned by journey diagnostics. */
|
|
3
|
-
export type JourneyDiagnosticsIssueCode = "cycle-detected" | "dead-end-step" | "no-terminal-path" | "shadowed-transition" | "unreachable-step";
|
|
4
|
-
/** Severity assigned to a diagnostics issue. */
|
|
5
|
-
export type JourneyDiagnosticsIssueSeverity = "warning" | "error";
|
|
6
|
-
/** Options that affect structural journey diagnostics. */
|
|
7
|
-
export type JourneyDiagnosticsOptions = {
|
|
8
|
-
requireExplicitCompletion?: boolean;
|
|
9
|
-
};
|
|
10
|
-
/** A single diagnostics issue discovered while analyzing a journey definition. */
|
|
11
|
-
export type JourneyDiagnosticsIssue<TStepId extends string, TEventType extends string> = {
|
|
12
|
-
code: JourneyDiagnosticsIssueCode;
|
|
13
|
-
severity: JourneyDiagnosticsIssueSeverity;
|
|
14
|
-
message: string;
|
|
15
|
-
stepId?: TStepId;
|
|
16
|
-
from?: TStepId | JourneyBuiltInFrom;
|
|
17
|
-
eventType?: TEventType;
|
|
18
|
-
transitionId?: string;
|
|
19
|
-
label?: string;
|
|
20
|
-
steps?: readonly TStepId[];
|
|
21
|
-
};
|
|
22
|
-
/** Aggregate diagnostics summary for a journey definition. */
|
|
23
|
-
export type JourneyDiagnosticsSummary = {
|
|
24
|
-
mode: JourneyMode;
|
|
25
|
-
stepCount: number;
|
|
26
|
-
reachableStepCount: number;
|
|
27
|
-
unreachableStepCount: number;
|
|
28
|
-
deadEndCount: number;
|
|
29
|
-
cycleCount: number;
|
|
30
|
-
shadowedTransitionCount: number;
|
|
31
|
-
graphChecksSkipped: boolean;
|
|
32
|
-
terminalPathExists: boolean;
|
|
33
|
-
};
|
|
34
|
-
/** Result returned by `getJourneyDiagnostics()`. */
|
|
35
|
-
export type JourneyDiagnosticsResult<TStepId extends string, TEventType extends string> = {
|
|
36
|
-
issues: JourneyDiagnosticsIssue<TStepId, TEventType>[];
|
|
37
|
-
summary: JourneyDiagnosticsSummary;
|
|
38
|
-
};
|
package/dist/types/index.d.cts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type { JourneyAnalyticsEventName, JourneyAnalyticsEventPayload, JourneyAnalyticsPluginOptions, JourneyAnalyticsTrackedEvent } from "./analytics.types";
|
|
2
|
-
export type { JourneyAutosavePluginOptions, JourneyAutosaveState, JourneyAutosaveStatus } from "./autosave.types";
|
|
3
|
-
export type { JourneyDiagnosticsIssue, JourneyDiagnosticsIssueCode, JourneyDiagnosticsIssueSeverity, JourneyDiagnosticsOptions, JourneyDiagnosticsResult, JourneyDiagnosticsSummary } from "./diagnostics.types";
|
|
4
|
-
export type { JourneyAsyncPhase, JourneyAsyncState, JourneyBaseEvent, JourneyBuiltInFrom, JourneyBuiltInSendEvent, JourneyCustomSendEvent, JourneyComputed, JourneyComputedBase, JourneyDefaultEventType, JourneyDefinition, JourneyDefinitionBase, JourneyEqualityFn, JourneyEvent, JourneyJsonObject, JourneyJsonPrimitive, JourneyJsonValue, JourneyExecutionPath, JourneyExecutionPathEventType, JourneyExecutionPathOptions, JourneyExecutionPathsResult, JourneyFullEventType, JourneyGoToEvent, JourneyGraphComputed, JourneyHeadlessComputed, JourneyHistory, JourneyLinearComputed, JourneyMode, JourneyPayloadFor, JourneyResolvedDefinition, JourneySelector, JourneySendEvent, JourneySendResult, JourneySnapshot, JourneySnapshotStateBase, JourneyStatus, JourneyStepAsyncState, JourneyStepDefinition, JourneyTerminal } from "./journey.types";
|
|
5
|
-
export type { JourneyCompleteObservationEvent, JourneyLifecycleErrorObservationEvent, JourneyLifecycleErrorPhase, JourneyLastVisitedNavigationObservationEvent, JourneyObservationEvent, JourneyPreviousNavigationObservationEvent, JourneyResetObservationEvent, JourneyStartObservationEvent, JourneyStepEnterObservationEvent, JourneyStepExitObservationEvent, JourneyTerminateObservationEvent, JourneyTransitionErrorObservationEvent, JourneyTransitionStartObservationEvent, JourneyTransitionSuccessObservationEvent } from "./observation.types";
|
|
6
|
-
export type { JourneyLifecycleErrorContext, JourneyMachine, JourneyMachineOptions, JourneyMachinePlugin, JourneyMachinePluginHooks, JourneyMachinePluginSetupContext, JourneyMachinePluginSnapshotChange, JourneyMachineSnapshotReason, JourneyMachineWithPlugins } from "./machine.types";
|
|
7
|
-
export type { JourneyDispatch, JourneyGlobalKey, JourneyLifecycleArgs, JourneyGlobalTransition, JourneyGoToStepGraphEdge, JourneyTransitionArgsForEvent, JourneyTransitionUpdateContextArgsForEvent, JourneyGoToStepTransition, JourneyGraphEdge, JourneyLinearStep, JourneyLinearTransitions, JourneyStepEventGraphEdge, JourneyStepEventTransition, JourneyStepLifecycleCallback, JourneyStepTransitions, JourneyTerminalGraphEdge, JourneyTerminalTransition, JourneyResolvedTransition, JourneyTransition, JourneyTransitionArgs, JourneyTransitionGraph, JourneyTransitionTarget, JourneyTransitionsDefinition } from "./transitions.types";
|
|
8
|
-
export type { JourneyPersistedState, JourneyPersistenceOptions, JourneyStorage } from "./persistence.types";
|
|
9
|
-
export type { JourneyReplayEntry, JourneyReplayEventEntry, JourneyReplayExportOptions, JourneyReplayPluginOptions, JourneyReplaySession, JourneyReplaySnapshotEntry } from "./replay.types";
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type { JourneyAnalyticsEventName, JourneyAnalyticsEventPayload, JourneyAnalyticsPluginOptions, JourneyAnalyticsTrackedEvent } from "./analytics.types";
|
|
2
|
-
export type { JourneyAutosavePluginOptions, JourneyAutosaveState, JourneyAutosaveStatus } from "./autosave.types";
|
|
3
|
-
export type { JourneyDiagnosticsIssue, JourneyDiagnosticsIssueCode, JourneyDiagnosticsIssueSeverity, JourneyDiagnosticsOptions, JourneyDiagnosticsResult, JourneyDiagnosticsSummary } from "./diagnostics.types";
|
|
4
|
-
export type { JourneyAsyncPhase, JourneyAsyncState, JourneyBaseEvent, JourneyBuiltInFrom, JourneyBuiltInSendEvent, JourneyCustomSendEvent, JourneyComputed, JourneyComputedBase, JourneyDefaultEventType, JourneyDefinition, JourneyDefinitionBase, JourneyEqualityFn, JourneyEvent, JourneyJsonObject, JourneyJsonPrimitive, JourneyJsonValue, JourneyExecutionPath, JourneyExecutionPathEventType, JourneyExecutionPathOptions, JourneyExecutionPathsResult, JourneyFullEventType, JourneyGoToEvent, JourneyGraphComputed, JourneyHeadlessComputed, JourneyHistory, JourneyLinearComputed, JourneyMode, JourneyPayloadFor, JourneyResolvedDefinition, JourneySelector, JourneySendEvent, JourneySendResult, JourneySnapshot, JourneySnapshotStateBase, JourneyStatus, JourneyStepAsyncState, JourneyStepDefinition, JourneyTerminal } from "./journey.types";
|
|
5
|
-
export type { JourneyCompleteObservationEvent, JourneyLifecycleErrorObservationEvent, JourneyLifecycleErrorPhase, JourneyLastVisitedNavigationObservationEvent, JourneyObservationEvent, JourneyPreviousNavigationObservationEvent, JourneyResetObservationEvent, JourneyStartObservationEvent, JourneyStepEnterObservationEvent, JourneyStepExitObservationEvent, JourneyTerminateObservationEvent, JourneyTransitionErrorObservationEvent, JourneyTransitionStartObservationEvent, JourneyTransitionSuccessObservationEvent } from "./observation.types";
|
|
6
|
-
export type { JourneyLifecycleErrorContext, JourneyMachine, JourneyMachineOptions, JourneyMachinePlugin, JourneyMachinePluginHooks, JourneyMachinePluginSetupContext, JourneyMachinePluginSnapshotChange, JourneyMachineSnapshotReason, JourneyMachineWithPlugins } from "./machine.types";
|
|
7
|
-
export type { JourneyDispatch, JourneyGlobalKey, JourneyLifecycleArgs, JourneyGlobalTransition, JourneyGoToStepGraphEdge, JourneyTransitionArgsForEvent, JourneyTransitionUpdateContextArgsForEvent, JourneyGoToStepTransition, JourneyGraphEdge, JourneyLinearStep, JourneyLinearTransitions, JourneyStepEventGraphEdge, JourneyStepEventTransition, JourneyStepLifecycleCallback, JourneyStepTransitions, JourneyTerminalGraphEdge, JourneyTerminalTransition, JourneyResolvedTransition, JourneyTransition, JourneyTransitionArgs, JourneyTransitionGraph, JourneyTransitionTarget, JourneyTransitionsDefinition } from "./transitions.types";
|
|
8
|
-
export type { JourneyPersistedState, JourneyPersistenceOptions, JourneyStorage } from "./persistence.types";
|
|
9
|
-
export type { JourneyReplayEntry, JourneyReplayEventEntry, JourneyReplayExportOptions, JourneyReplayPluginOptions, JourneyReplaySession, JourneyReplaySnapshotEntry } from "./replay.types";
|
|
@@ -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 {};
|