@sphereon/ssi-sdk.xstate-machine-persistence 0.33.1-next.3 → 0.33.1-next.73

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.
Files changed (45) hide show
  1. package/dist/index.cjs +1014 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/{ssi-sdk.xstate-machine-persistence.d.ts → index.d.cts} +426 -467
  4. package/dist/index.d.ts +425 -5
  5. package/dist/index.js +982 -21
  6. package/dist/index.js.map +1 -1
  7. package/package.json +25 -14
  8. package/plugin.schema.json +80 -320
  9. package/src/__tests__/localAgent.test.ts +1 -0
  10. package/src/__tests__/restAgent.test.ts +4 -1
  11. package/src/__tests__/shared/MachineStatePersistenceAgentLogic.ts +1 -0
  12. package/dist/agent/MachineStatePersistence.d.ts +0 -26
  13. package/dist/agent/MachineStatePersistence.d.ts.map +0 -1
  14. package/dist/agent/MachineStatePersistence.js +0 -197
  15. package/dist/agent/MachineStatePersistence.js.map +0 -1
  16. package/dist/functions/index.d.ts +0 -4
  17. package/dist/functions/index.d.ts.map +0 -1
  18. package/dist/functions/index.js +0 -20
  19. package/dist/functions/index.js.map +0 -1
  20. package/dist/functions/machineRegistration.d.ts +0 -130
  21. package/dist/functions/machineRegistration.d.ts.map +0 -1
  22. package/dist/functions/machineRegistration.js +0 -303
  23. package/dist/functions/machineRegistration.js.map +0 -1
  24. package/dist/functions/stateEventEmitter.d.ts +0 -10
  25. package/dist/functions/stateEventEmitter.d.ts.map +0 -1
  26. package/dist/functions/stateEventEmitter.js +0 -21
  27. package/dist/functions/stateEventEmitter.js.map +0 -1
  28. package/dist/functions/stateMapper.d.ts +0 -34
  29. package/dist/functions/stateMapper.d.ts.map +0 -1
  30. package/dist/functions/stateMapper.js +0 -83
  31. package/dist/functions/stateMapper.js.map +0 -1
  32. package/dist/index.d.ts.map +0 -1
  33. package/dist/tsdoc-metadata.json +0 -11
  34. package/dist/types/IMachineStatePersistence.d.ts +0 -62
  35. package/dist/types/IMachineStatePersistence.d.ts.map +0 -1
  36. package/dist/types/IMachineStatePersistence.js +0 -3
  37. package/dist/types/IMachineStatePersistence.js.map +0 -1
  38. package/dist/types/index.d.ts +0 -3
  39. package/dist/types/index.d.ts.map +0 -1
  40. package/dist/types/index.js +0 -19
  41. package/dist/types/index.js.map +0 -1
  42. package/dist/types/types.d.ts +0 -173
  43. package/dist/types/types.d.ts.map +0 -1
  44. package/dist/types/types.js +0 -13
  45. package/dist/types/types.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,6 +1,426 @@
1
+ import { IAbstractMachineStateStore, StoreMachineStatesFindActiveArgs, StoreMachineStateInfo, StoreMachineStateDeleteExpiredArgs } from '@sphereon/ssi-sdk.data-store';
2
+ import { IAgentPlugin, IAgentContext, IPluginMethodMap } from '@veramo/core';
3
+ import { EventObject, StateValue, SCXML, HistoryValue, AnyEventObject, DefaultContext, StateSchema, Typestate, TypegenDisabled, Interpreter, State } from 'xstate';
4
+ import { EventObject as EventObject$1 } from 'xstate/lib/types';
5
+
6
+ /**
7
+ * This class implements the IMachineStatePersistence interface using a datastore.
8
+ *
9
+ * This allows you to store and retrieve the State of a state machine/application by their types.
10
+ *
11
+ * @beta This API may change without a BREAKING CHANGE notice.
12
+ */
13
+ declare class MachineStatePersistence implements IAgentPlugin {
14
+ readonly schema: any;
15
+ readonly methods: IMachineStatePersistence | {};
16
+ readonly eventTypes: Array<string>;
17
+ private readonly _store?;
18
+ get store(): IAbstractMachineStateStore;
19
+ constructor(opts: MachineStatePersistOpts);
20
+ onEvent(event: MachineStatePersistEvent, context: RequiredContext): Promise<void>;
21
+ private machineStateInit;
22
+ private machineStatePersist;
23
+ private machineStatesFindActive;
24
+ private machineStatesDeleteExpired;
25
+ private machineStateGet;
26
+ private machineStateDelete;
27
+ }
28
+
29
+ /**
30
+ * Represents the options for persisting machine state.
31
+ *
32
+ * @typedef {Object} MachineStatePersistOpts
33
+ * @property {IAbstractMachineStateStore} store - The store used to persist the machine state.
34
+ * @property {Array<string>} eventTypes - The types of events to be persisted.
35
+ */
36
+ type MachineStatePersistOpts = {
37
+ store?: IAbstractMachineStateStore;
38
+ eventTypes: Array<string>;
39
+ isRESTClient?: boolean;
40
+ };
41
+ /**
42
+ * Enum representing the types of machine state persist events.
43
+ * @enum {string}
44
+ */
45
+ declare enum MachineStatePersistEventType {
46
+ INIT = "INIT",
47
+ EVERY = "EVERY"
48
+ }
49
+ /**
50
+ * Represents the arguments for deleting expired states from a machine.
51
+ */
52
+ type DeleteExpiredStatesArgs = Pick<StoreMachineStateDeleteExpiredArgs, 'deleteDoneStates' | 'machineName' | 'tenantId'>;
53
+ /**
54
+ * Represents the arguments for finding active states of a store machine.
55
+ */
56
+ type FindActiveStatesArgs = StoreMachineStatesFindActiveArgs;
57
+ /**
58
+ * Represents the result of a state deletion operation.
59
+ *
60
+ * @typedef {number} DeleteStateResult
61
+ */
62
+ type DeleteStateResult = number;
63
+ /**
64
+ * Represents a machine state persist event.
65
+ *
66
+ * @typedef {Object} MachineStatePersistEvent
67
+ * @property {MachineStatePersistEventType} type - The type of the persist event.
68
+ * @property {MachineStatePersistArgs} data - The data associated with the persist event, along with additional properties `_eventCounter` and `_eventDate`.
69
+ * @property {number} data._eventCounter - The counter for the persist event.
70
+ * @property {Date} data._eventDate - The date and time the persist event occurred.
71
+ */
72
+ type MachineStatePersistEvent = {
73
+ type: MachineStatePersistEventType;
74
+ data: Omit<MachineStatePersistArgs, 'machineState'> & {
75
+ _eventCounter: number;
76
+ _eventDate: Date;
77
+ _cleanupOnFinalState: boolean;
78
+ };
79
+ };
80
+ /**
81
+ * Represents a RequiredContext class, which is a type definition for the context required by an agent.
82
+ * It is used to enforce that the agent context implements the necessary interfaces.
83
+ *
84
+ * @typeparam T - The type of the machine state persistence.
85
+ */
86
+ type RequiredContext = IAgentContext<IMachineStatePersistence>;
87
+ /**
88
+ * Represents the information about the current state of a machine.
89
+ * @typedef {Object} MachineStateInfo
90
+ * @property {string} id - The ID of the machine.
91
+ * @property {SerializableState} state - The serializable state of the machine.
92
+ * @property {string} description - The description of the machine state.
93
+ */
94
+ type MachineStateInfo = Omit<StoreMachineStateInfo, 'state'> & {
95
+ state: SerializableState;
96
+ };
97
+ type MachineStatePersistenceOpts = {
98
+ disablePersistence?: boolean;
99
+ customInstanceId?: string;
100
+ existingInstanceId?: string;
101
+ expireInMS?: number;
102
+ expiresAt?: Date;
103
+ };
104
+ type MachineStateInitType = 'new' | 'existing';
105
+ /**
106
+ * Represents the initial state for a machine.
107
+ *
108
+ * @typedef {Object} MachineStateInit
109
+ * @property {string} existingInstanceId - The unique identifier for the machine instance.
110
+ * @property {string} machineName - The name of the machine.
111
+ * @property {string} tenantId - The identifier for the tenant associated with the machine.
112
+ * @property {Date} createdAt - The date and time when the machine was created.
113
+ * @property {Date} expiresAt - The date and time when the machine's state expires.
114
+ */
115
+ type MachineStateInit = Pick<MachineStateInfo, 'instanceId' | 'machineName' | 'tenantId' | 'createdAt' | 'expiresAt'> & {
116
+ stateType: MachineStateInitType;
117
+ machineState?: MachineStateInfo;
118
+ };
119
+ /**
120
+ * Represents the arguments required to initialize the machine state.
121
+ * @typedef {Object} InitMachineStateArgs
122
+ * @property {string} machineName - The name of the machine.
123
+ * @property {Partial<MachineStateInit>} [additionalArgs] - Additional initialization arguments for the machine state.
124
+ */
125
+ type InitMachineStateArgs = Omit<Partial<MachineStateInit>, 'instanceId'> & Pick<MachineStateInfo, 'machineName'> & Pick<MachineStatePersistenceOpts, 'customInstanceId' | 'existingInstanceId'> & {
126
+ cleanupAllOtherInstances?: boolean;
127
+ };
128
+ /**
129
+ * Represents the arguments required to persist the machine state.
130
+ */
131
+ type MachineStatePersistArgs = Omit<MachineStateInit, 'createdAt'> & Pick<MachineStateInfo, 'state' | 'instanceId'> & Partial<Pick<MachineStateInfo, 'updatedCount'>> & {
132
+ cleanupOnFinalState?: boolean;
133
+ };
134
+ /**
135
+ * Represents the arguments required to get machine state.
136
+ * @typedef {Object} MachineStateGetArgs
137
+ * @property {string} existingInstanceId - The ID of the machine instance.
138
+ * @property {string} tenantId - The ID of the tenant the machine belongs to.
139
+ */
140
+ type MachineStateGetArgs = Pick<StoreMachineStateInfo, 'instanceId' | 'tenantId'>;
141
+ /**
142
+ * Represents the arguments required for deleting a machine state.
143
+ *
144
+ * @typedef {object} MachineStateDeleteArgs
145
+ * @property {string} existingInstanceId - The ID of the machine instance to delete the state for.
146
+ * @property {string} tenantId - The ID of the tenant owning the machine instance.
147
+ */
148
+ type MachineStateDeleteArgs = Pick<StoreMachineStateInfo, 'instanceId' | 'tenantId'>;
149
+ /**
150
+ * Represents the information for a started interpreter.
151
+ *
152
+ * @template TContext The type of the context object.
153
+ * @template TStateSchema The type of the state schema.
154
+ * @template TEvent The type of the event object.
155
+ * @template TTypestate The type of the typestate object.
156
+ * @template TResolvedTypesMeta The type of the resolved types meta object.
157
+ */
158
+ type StartedInterpreterInfo<TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
159
+ value: any;
160
+ context: TContext;
161
+ }, TResolvedTypesMeta = TypegenDisabled> = {
162
+ interpreter: Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>;
163
+ machineState?: MachineStateInfo;
164
+ init: MachineStateInit;
165
+ };
166
+ /**
167
+ * Represents the serializable state of a machine.
168
+ *
169
+ * @typedef {Object} SerializableState
170
+ * @property {XStateConfig<any, AnyEventObject>} config - The machine configuration.
171
+ */
172
+ type SerializableState = XStateConfig<any, AnyEventObject>;
173
+ /**
174
+ * The configuration for the XState machine state. Simplified StateConfig object from XState so we have a minimal typed structure
175
+ *
176
+ * @template TContext - The context type for the state.
177
+ * @template TEvent - The event type for the state.
178
+ */
179
+ interface XStateConfig<TContext, TEvent extends EventObject> {
180
+ value: StateValue;
181
+ context: TContext;
182
+ _event: SCXML.Event<TEvent>;
183
+ _sessionid: string | null;
184
+ historyValue?: HistoryValue | undefined;
185
+ history?: any;
186
+ actions?: Array<any>;
187
+ activities?: any;
188
+ meta?: any;
189
+ events?: TEvent[];
190
+ configuration: Array<any>;
191
+ transitions: Array<any>;
192
+ children: Record<string, any>;
193
+ done?: boolean;
194
+ tags?: Set<string>;
195
+ machine?: any;
196
+ }
197
+
198
+ /**
199
+ * The interface definition for a plugin that can issue and verify Verifiable Credentials and Presentations
200
+ * that use JSON-LD format.
201
+ *
202
+ * @remarks Please see {@link https://www.w3.org/TR/vc-data-model | W3C Verifiable Credentials data model}
203
+ *
204
+ * @beta This API is likely to change without a BREAKING CHANGE notice
205
+ */
206
+ interface IMachineStatePersistence extends IPluginMethodMap {
207
+ /**
208
+ * Loads the states of active xstate machines from the database.
209
+ *
210
+ * @param args FindActiveStatesArgs
211
+ * type of the event
212
+ *
213
+ * @returns state or null
214
+ *
215
+ * @beta This API is likely to change without a BREAKING CHANGE notice
216
+ */
217
+ machineStatesFindActive(args: FindActiveStatesArgs): Promise<Array<MachineStateInfo>>;
218
+ /**
219
+ * Deletes the state of an xstate machine in the database.
220
+ *
221
+ * @param args DeleteExpiredStatesArgs
222
+ * type: optional type of the machine
223
+ *
224
+ * @beta This API is likely to change without a BREAKING CHANGE notice
225
+ */
226
+ machineStatesDeleteExpired(args: DeleteExpiredStatesArgs): Promise<DeleteStateResult>;
227
+ /**
228
+ * Initializes a state object for a new machine. Does not persist anything
229
+ * @param args Requires a machineName, instanceId and tenantId are optional
230
+ */
231
+ machineStateInit(args: InitMachineStateArgs): Promise<MachineStateInit>;
232
+ /**
233
+ * Persists the state
234
+ * @param args MachineStatePersistArgs
235
+ *
236
+ * @param context
237
+ * @beta This API is likely to change without a BREAKING CHANGE notice
238
+ */
239
+ machineStatePersist(args: MachineStatePersistArgs, context: RequiredContext): Promise<MachineStateInfo>;
240
+ /**
241
+ * Get a particular machine state by instance id and tenant id
242
+ * @param args instance id and tenant id
243
+ *
244
+ * @param context
245
+ * @beta This API is likely to change without a BREAKING CHANGE notice
246
+ */
247
+ machineStateGet(args: MachineStateGetArgs, context: RequiredContext): Promise<MachineStateInfo>;
248
+ /**
249
+ * Delete a particular machine state by instance id and tenant id
250
+ * @param args instance id and tenant id
251
+ *
252
+ * @param context
253
+ * @beta This API is likely to change without a BREAKING CHANGE notice
254
+ */
255
+ machineStateDelete(args: MachineStateDeleteArgs, context: RequiredContext): Promise<boolean>;
256
+ }
257
+
258
+ /**
259
+ * Initialize the machine state persistence. Returns a unique instanceId and the machine name amongst others
260
+ *
261
+ * @param {Object} opts - The options for initializing the machine state persistence.
262
+ * @param {InitMachineStateArgs} opts - The arguments for initializing the machine state.
263
+ * @param {IAgentContext<any>} opts.context - The agent context.
264
+ * @returns {Promise<MachineStateInit | undefined>} - A promise that resolves to the initialized machine state, or undefined if the agent isn't using the Xstate plugin.
265
+ */
266
+ declare const machineStatePersistInit: (opts: InitMachineStateArgs & Pick<MachineStatePersistenceOpts, "existingInstanceId" | "customInstanceId"> & {
267
+ context: IAgentContext<any>;
268
+ }) => Promise<MachineStateInit | undefined>;
269
+ /**
270
+ * This function allows for the persistence of machine state on every xstate transition. It emits an event with the new state
271
+ * and other relevant data to be handled by the persistence plugin when enabled.
272
+ *
273
+ * @param {Object} opts - The options object.
274
+ * @param {Interpreter} opts.instance - The XState machine interpreter instance.
275
+ * @param {IAgentContext<any>} opts.context - The agent context.
276
+ * @param {MachineStateInit} opts.init - The initial persistence options, containing the unique instanceId.
277
+ * @returns {Promise<void>} - A promise that resolves when the persistence event is emitted.
278
+ */
279
+ declare const machineStatePersistOnTransition: <TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
280
+ value: any;
281
+ context: TContext;
282
+ }, TResolvedTypesMeta = TypegenDisabled>(opts: {
283
+ interpreter: Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>;
284
+ context: IAgentContext<any>;
285
+ init: MachineStateInit;
286
+ cleanupOnFinalState?: boolean;
287
+ }) => Promise<void>;
288
+ /**
289
+ * Persist the initial state of a machine and register it with the given machine instance.
290
+ *
291
+ * @param {InitMachineStateArgs & {instance: Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>, context: IAgentContext<any>}} args - The options for initializing
292
+ * machine state and registering it.
293
+ * @returns {Promise<MachineStateInit | undefined>} - A promise that resolves to the initial state of the machine, or undefined if the agent isn't using the Xstate plugin.
294
+ */
295
+ declare const machineStatePersistRegistration: <TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
296
+ value: any;
297
+ context: TContext;
298
+ }, TResolvedTypesMeta = TypegenDisabled>(args: Omit<InitMachineStateArgs, "machineName"> & Partial<Pick<InitMachineStateArgs, "machineName">> & MachineStatePersistenceOpts & {
299
+ cleanupOnFinalState?: boolean;
300
+ cleanupAllOtherInstances?: boolean;
301
+ interpreter: Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>;
302
+ context: IAgentContext<any>;
303
+ }) => Promise<MachineStateInit | undefined>;
304
+ /**
305
+ * Resumes the interpreter from a given state.
306
+ *
307
+ * @param {Object} args - The arguments for resuming the interpreter.
308
+ * @param {MachineStateInfo} args.machineState - The machine state information.
309
+ * @param {boolean} [args.noRegistration] - If true, no registration will be performed.
310
+ * @param {Interpreter} args.interpreter - The interpreter instance.
311
+ * @param {IAgentContext<IMachineStatePersistence>} args.context - The context for machine state persistence.
312
+ *
313
+ * @returns {Promise<Interpreter>} - A promise that resolves to the resumed interpreter.
314
+ */
315
+ declare const interpreterResumeFromState: <TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
316
+ value: any;
317
+ context: TContext;
318
+ }, TResolvedTypesMeta = TypegenDisabled>(args: {
319
+ machineState: MachineStateInfo;
320
+ noRegistration?: boolean;
321
+ cleanupAllOtherInstances?: boolean;
322
+ cleanupOnFinalState?: boolean;
323
+ interpreter: Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>;
324
+ context: IAgentContext<IMachineStatePersistence>;
325
+ }) => Promise<StartedInterpreterInfo<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>>;
326
+ /**
327
+ * Resumes or starts the interpreter from the initial machine state.
328
+ *
329
+ * @async
330
+ * @param {Object} args - The arguments for the function.
331
+ * @param {MachineStateInit & {stateType?: MachineStateInitType}} args.init - The initialization state of the machine.
332
+ * @param {boolean} args.noRegistration - Whether registration is required, defaults to false.
333
+ * @param {Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>} args.interpreter - The interpreter object.
334
+ * @param {IAgentContext<IMachineStatePersistence>} args.context - The context object.
335
+ * @returns {Promise} - A promise that resolves to the interpreter instance.
336
+ * @throws {Error} - If the machine name from init does not match the interpreter id.
337
+ */
338
+ declare const interpreterStartOrResumeFromInit: <TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
339
+ value: any;
340
+ context: TContext;
341
+ }, TResolvedTypesMeta = TypegenDisabled>(args: {
342
+ init: MachineStateInit & {
343
+ stateType?: MachineStateInitType;
344
+ };
345
+ cleanupAllOtherInstances?: boolean;
346
+ cleanupOnFinalState?: boolean;
347
+ noRegistration?: boolean;
348
+ interpreter: Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>;
349
+ context: IAgentContext<IMachineStatePersistence>;
350
+ }) => Promise<StartedInterpreterInfo<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>>;
351
+ /**
352
+ * Starts or resumes the given state machine interpreter.
353
+ *
354
+ * @async
355
+ * @param {Object} args - The arguments for starting or resuming the interpreter.
356
+ * @param {MachineStateInitType | 'auto'} [args.stateType] - The state type. Defaults to 'auto'.
357
+ * @param {string} [args.instanceId] - The instance ID.
358
+ * @param {string} [args.machineName] - The machine name.
359
+ * @param {string} [args.tenantId] - The tenant ID.
360
+ * @param {boolean} args.singletonCheck - Whether to perform a singleton check or not. If more than one machine instance is found an error will be thrown
361
+ * @param {boolean} [args.noRegistration] - Whether to skip state change event registration or not.
362
+ * @param {Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>} args.interpreter - The interpreter to start or resume.
363
+ * @param {IAgentContext<IMachineStatePersistence>} args.context - The agent context.
364
+ * @returns {Promise} A promise that resolves when the interpreter is started or resumed.
365
+ * @throws {Error} If there are multiple active instances of the machine and singletonCheck is true.
366
+ * @throws {Error} If a new instance was requested with the same ID as an existing active instance.
367
+ * @throws {Error} If the existing state machine with the given machine name and instance ID cannot be found.
368
+ */
369
+ declare const interpreterStartOrResume: <TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
370
+ value: any;
371
+ context: TContext;
372
+ }, TResolvedTypesMeta = TypegenDisabled>(args: {
373
+ stateType?: MachineStateInitType | "auto";
374
+ instanceId?: string;
375
+ machineName?: string;
376
+ tenantId?: string;
377
+ singletonCheck: boolean;
378
+ noRegistration?: boolean;
379
+ cleanupAllOtherInstances?: boolean;
380
+ cleanupOnFinalState?: boolean;
381
+ interpreter: Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>;
382
+ context: IAgentContext<IMachineStatePersistence>;
383
+ }) => Promise<StartedInterpreterInfo<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>>;
384
+
385
+ /**
386
+ * Create a machine state info object useful for the store, based on the provided machine info and existing state.
387
+ *
388
+ * @param {MachineStatePersistArgs} machineInfo - The machine info object.
389
+ * @param {Partial<StoreMachineStateInfo>} [existingState] - The optional existing state object.
390
+ * @returns {StoreMachineStateInfo} - The store machine state info object.
391
+ */
392
+ declare const machineStateToStoreInfo: (machineInfo: MachineStatePersistArgs, existingState?: Partial<StoreMachineStateInfo>) => StoreMachineStateInfo;
393
+ declare const storeInfoToMachineInit: (args: StoreMachineStateInfo & {
394
+ stateType: MachineStateInitType;
395
+ machineState?: MachineStateInfo;
396
+ }) => MachineStateInit;
397
+ declare const machineStateToMachineInit: (machineInfo: MachineStatePersistArgs, existingState: Partial<StoreMachineStateInfo>) => MachineStateInit;
398
+ /**
399
+ * Serializes a machine state to a string representation.
400
+ *
401
+ * @param {State<T, TEvent> | SerializableState | string} state - The machine state to serialize.
402
+ * @returns {string} - The serialized machine state.
403
+ */
404
+ declare const serializeMachineState: <T, TEvent extends EventObject$1>(state: State<T, TEvent> | SerializableState | string) => string;
405
+ /**
406
+ * Deserializes a serialized machine state.
407
+ *
408
+ * @template T - The type of the machine's context.
409
+ * @template TEvent - The type of the events that the machine handles.
410
+ * @param {string} state - The serialized machine state.
411
+ * @returns {State<T, TEvent>} - The deserialized machine state.
412
+ */
413
+ declare const deserializeMachineState: <T, TEvent extends EventObject$1>(state: string) => State<T, TEvent>;
414
+
415
+ /**
416
+ * Emits a machine state persistence event.
417
+ *
418
+ * @param {MachineStatePersistEvent} event - The event to be emitted.
419
+ * @param {RequiredContext} context - The required agent context for the event emission.
420
+ * @returns {void}
421
+ */
422
+ declare const emitMachineStatePersistEvent: (event: MachineStatePersistEvent, context: RequiredContext) => void;
423
+
1
424
  declare const schema: any;
2
- export { schema };
3
- export * from './agent/MachineStatePersistence';
4
- export * from './types';
5
- export * from './functions';
6
- //# sourceMappingURL=index.d.ts.map
425
+
426
+ export { type DeleteExpiredStatesArgs, type DeleteStateResult, type FindActiveStatesArgs, type IMachineStatePersistence, type InitMachineStateArgs, type MachineStateDeleteArgs, type MachineStateGetArgs, type MachineStateInfo, type MachineStateInit, type MachineStateInitType, type MachineStatePersistArgs, type MachineStatePersistEvent, MachineStatePersistEventType, type MachineStatePersistOpts, MachineStatePersistence, type MachineStatePersistenceOpts, type RequiredContext, type SerializableState, type StartedInterpreterInfo, type XStateConfig, deserializeMachineState, emitMachineStatePersistEvent, interpreterResumeFromState, interpreterStartOrResume, interpreterStartOrResumeFromInit, machineStatePersistInit, machineStatePersistOnTransition, machineStatePersistRegistration, machineStateToMachineInit, machineStateToStoreInfo, schema, serializeMachineState, storeInfoToMachineInit };