@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,173 +0,0 @@
1
- import { IAbstractMachineStateStore, StoreMachineStateDeleteExpiredArgs, StoreMachineStateInfo, StoreMachineStatesFindActiveArgs } from '@sphereon/ssi-sdk.data-store';
2
- import { IAgentContext } from '@veramo/core';
3
- import { AnyEventObject, DefaultContext, EventObject, HistoryValue, Interpreter, SCXML, StateSchema, StateValue, TypegenDisabled, Typestate } from 'xstate';
4
- import { IMachineStatePersistence } from './IMachineStatePersistence';
5
- /**
6
- * Represents the options for persisting machine state.
7
- *
8
- * @typedef {Object} MachineStatePersistOpts
9
- * @property {IAbstractMachineStateStore} store - The store used to persist the machine state.
10
- * @property {Array<string>} eventTypes - The types of events to be persisted.
11
- */
12
- export type MachineStatePersistOpts = {
13
- store?: IAbstractMachineStateStore;
14
- eventTypes: Array<string>;
15
- isRESTClient?: boolean;
16
- };
17
- /**
18
- * Enum representing the types of machine state persist events.
19
- * @enum {string}
20
- */
21
- export declare enum MachineStatePersistEventType {
22
- INIT = "INIT",
23
- EVERY = "EVERY"
24
- }
25
- /**
26
- * Represents the arguments for deleting expired states from a machine.
27
- */
28
- export type DeleteExpiredStatesArgs = Pick<StoreMachineStateDeleteExpiredArgs, 'deleteDoneStates' | 'machineName' | 'tenantId'>;
29
- /**
30
- * Represents the arguments for finding active states of a store machine.
31
- */
32
- export type FindActiveStatesArgs = StoreMachineStatesFindActiveArgs;
33
- /**
34
- * Represents the result of a state deletion operation.
35
- *
36
- * @typedef {number} DeleteStateResult
37
- */
38
- export type DeleteStateResult = number;
39
- /**
40
- * Represents a machine state persist event.
41
- *
42
- * @typedef {Object} MachineStatePersistEvent
43
- * @property {MachineStatePersistEventType} type - The type of the persist event.
44
- * @property {MachineStatePersistArgs} data - The data associated with the persist event, along with additional properties `_eventCounter` and `_eventDate`.
45
- * @property {number} data._eventCounter - The counter for the persist event.
46
- * @property {Date} data._eventDate - The date and time the persist event occurred.
47
- */
48
- export type MachineStatePersistEvent = {
49
- type: MachineStatePersistEventType;
50
- data: Omit<MachineStatePersistArgs, 'machineState'> & {
51
- _eventCounter: number;
52
- _eventDate: Date;
53
- _cleanupOnFinalState: boolean;
54
- };
55
- };
56
- /**
57
- * Represents a RequiredContext class, which is a type definition for the context required by an agent.
58
- * It is used to enforce that the agent context implements the necessary interfaces.
59
- *
60
- * @typeparam T - The type of the machine state persistence.
61
- */
62
- export type RequiredContext = IAgentContext<IMachineStatePersistence>;
63
- /**
64
- * Represents the information about the current state of a machine.
65
- * @typedef {Object} MachineStateInfo
66
- * @property {string} id - The ID of the machine.
67
- * @property {SerializableState} state - The serializable state of the machine.
68
- * @property {string} description - The description of the machine state.
69
- */
70
- export type MachineStateInfo = Omit<StoreMachineStateInfo, 'state'> & {
71
- state: SerializableState;
72
- };
73
- export type MachineStatePersistenceOpts = {
74
- disablePersistence?: boolean;
75
- customInstanceId?: string;
76
- existingInstanceId?: string;
77
- expireInMS?: number;
78
- expiresAt?: Date;
79
- };
80
- export type MachineStateInitType = 'new' | 'existing';
81
- /**
82
- * Represents the initial state for a machine.
83
- *
84
- * @typedef {Object} MachineStateInit
85
- * @property {string} existingInstanceId - The unique identifier for the machine instance.
86
- * @property {string} machineName - The name of the machine.
87
- * @property {string} tenantId - The identifier for the tenant associated with the machine.
88
- * @property {Date} createdAt - The date and time when the machine was created.
89
- * @property {Date} expiresAt - The date and time when the machine's state expires.
90
- */
91
- export type MachineStateInit = Pick<MachineStateInfo, 'instanceId' | 'machineName' | 'tenantId' | 'createdAt' | 'expiresAt'> & {
92
- stateType: MachineStateInitType;
93
- machineState?: MachineStateInfo;
94
- };
95
- /**
96
- * Represents the arguments required to initialize the machine state.
97
- * @typedef {Object} InitMachineStateArgs
98
- * @property {string} machineName - The name of the machine.
99
- * @property {Partial<MachineStateInit>} [additionalArgs] - Additional initialization arguments for the machine state.
100
- */
101
- export type InitMachineStateArgs = Omit<Partial<MachineStateInit>, 'instanceId'> & Pick<MachineStateInfo, 'machineName'> & Pick<MachineStatePersistenceOpts, 'customInstanceId' | 'existingInstanceId'> & {
102
- cleanupAllOtherInstances?: boolean;
103
- };
104
- /**
105
- * Represents the arguments required to persist the machine state.
106
- */
107
- export type MachineStatePersistArgs = Omit<MachineStateInit, 'createdAt'> & Pick<MachineStateInfo, 'state' | 'instanceId'> & Partial<Pick<MachineStateInfo, 'updatedCount'>> & {
108
- cleanupOnFinalState?: boolean;
109
- };
110
- /**
111
- * Represents the arguments required to get machine state.
112
- * @typedef {Object} MachineStateGetArgs
113
- * @property {string} existingInstanceId - The ID of the machine instance.
114
- * @property {string} tenantId - The ID of the tenant the machine belongs to.
115
- */
116
- export type MachineStateGetArgs = Pick<StoreMachineStateInfo, 'instanceId' | 'tenantId'>;
117
- /**
118
- * Represents the arguments required for deleting a machine state.
119
- *
120
- * @typedef {object} MachineStateDeleteArgs
121
- * @property {string} existingInstanceId - The ID of the machine instance to delete the state for.
122
- * @property {string} tenantId - The ID of the tenant owning the machine instance.
123
- */
124
- export type MachineStateDeleteArgs = Pick<StoreMachineStateInfo, 'instanceId' | 'tenantId'>;
125
- /**
126
- * Represents the information for a started interpreter.
127
- *
128
- * @template TContext The type of the context object.
129
- * @template TStateSchema The type of the state schema.
130
- * @template TEvent The type of the event object.
131
- * @template TTypestate The type of the typestate object.
132
- * @template TResolvedTypesMeta The type of the resolved types meta object.
133
- */
134
- export type StartedInterpreterInfo<TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
135
- value: any;
136
- context: TContext;
137
- }, TResolvedTypesMeta = TypegenDisabled> = {
138
- interpreter: Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>;
139
- machineState?: MachineStateInfo;
140
- init: MachineStateInit;
141
- };
142
- /**
143
- * Represents the serializable state of a machine.
144
- *
145
- * @typedef {Object} SerializableState
146
- * @property {XStateConfig<any, AnyEventObject>} config - The machine configuration.
147
- */
148
- export type SerializableState = XStateConfig<any, AnyEventObject>;
149
- /**
150
- * The configuration for the XState machine state. Simplified StateConfig object from XState so we have a minimal typed structure
151
- *
152
- * @template TContext - The context type for the state.
153
- * @template TEvent - The event type for the state.
154
- */
155
- export interface XStateConfig<TContext, TEvent extends EventObject> {
156
- value: StateValue;
157
- context: TContext;
158
- _event: SCXML.Event<TEvent>;
159
- _sessionid: string | null;
160
- historyValue?: HistoryValue | undefined;
161
- history?: any;
162
- actions?: Array<any>;
163
- activities?: any;
164
- meta?: any;
165
- events?: TEvent[];
166
- configuration: Array<any>;
167
- transitions: Array<any>;
168
- children: Record<string, any>;
169
- done?: boolean;
170
- tags?: Set<string>;
171
- machine?: any;
172
- }
173
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,kCAAkC,EAClC,qBAAqB,EACrB,gCAAgC,EACjC,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,WAAW,EACX,KAAK,EACL,WAAW,EACX,UAAU,EACV,eAAe,EACf,SAAS,EACV,MAAM,QAAQ,CAAA;AAEf,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAErE;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAAE,KAAK,CAAC,EAAE,0BAA0B,CAAC;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,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAA;IACxF,YAAY,CAAC,EAAE,gBAAgB,CAAA;IAC/B,IAAI,EAAE,gBAAgB,CAAA;CACvB,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;AAEjE;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAAC,QAAQ,EAAE,MAAM,SAAS,WAAW;IAChE,KAAK,EAAE,UAAU,CAAA;IACjB,OAAO,EAAE,QAAQ,CAAA;IACjB,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;IACvC,OAAO,CAAC,EAAE,GAAG,CAAA;IACb,OAAO,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IACpB,UAAU,CAAC,EAAE,GAAG,CAAA;IAChB,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IACzB,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAClB,OAAO,CAAC,EAAE,GAAG,CAAA;CACd"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MachineStatePersistEventType = void 0;
4
- /**
5
- * Enum representing the types of machine state persist events.
6
- * @enum {string}
7
- */
8
- var MachineStatePersistEventType;
9
- (function (MachineStatePersistEventType) {
10
- MachineStatePersistEventType["INIT"] = "INIT";
11
- MachineStatePersistEventType["EVERY"] = "EVERY";
12
- })(MachineStatePersistEventType || (exports.MachineStatePersistEventType = MachineStatePersistEventType = {}));
13
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":";;;AA+BA;;;GAGG;AACH,IAAY,4BAGX;AAHD,WAAY,4BAA4B;IACtC,6CAAa,CAAA;IACb,+CAAe,CAAA;AACjB,CAAC,EAHW,4BAA4B,4CAA5B,4BAA4B,QAGvC"}