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