@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,303 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.interpreterStartOrResume = exports.interpreterStartOrResumeFromInit = exports.interpreterResumeFromState = exports.machineStatePersistRegistration = exports.machineStatePersistOnTransition = exports.machineStatePersistInit = void 0;
24
- const xstate_1 = require("xstate");
25
- const waitFor_1 = require("xstate/lib/waitFor");
26
- const types_1 = require("../types");
27
- const stateEventEmitter_1 = require("./stateEventEmitter");
28
- const stateMapper_1 = require("./stateMapper");
29
- /**
30
- * Initialize the machine state persistence. Returns a unique instanceId and the machine name amongst others
31
- *
32
- * @param {Object} opts - The options for initializing the machine state persistence.
33
- * @param {InitMachineStateArgs} opts - The arguments for initializing the machine state.
34
- * @param {IAgentContext<any>} opts.context - The agent context.
35
- * @returns {Promise<MachineStateInit | undefined>} - A promise that resolves to the initialized machine state, or undefined if the agent isn't using the Xstate plugin.
36
- */
37
- const machineStatePersistInit = (opts) => __awaiter(void 0, void 0, void 0, function* () {
38
- // make sure the machine context does not end up in the machine state init args
39
- const { context } = opts, args = __rest(opts, ["context"]);
40
- if (!(context.agent.availableMethods().includes('machineStateInit') && 'machineStateInit' in context.agent)) {
41
- console.log(`IMachineStatePersistence was not exposed in the current agent. Not initializing new persistence object`);
42
- return;
43
- }
44
- return yield context.agent.machineStateInit(args);
45
- });
46
- exports.machineStatePersistInit = machineStatePersistInit;
47
- /**
48
- * This function allows for the persistence of machine state on every xstate transition. It emits an event with the new state
49
- * and other relevant data to be handled by the persistence plugin when enabled.
50
- *
51
- * @param {Object} opts - The options object.
52
- * @param {Interpreter} opts.instance - The XState machine interpreter instance.
53
- * @param {IAgentContext<any>} opts.context - The agent context.
54
- * @param {MachineStateInit} opts.init - The initial persistence options, containing the unique instanceId.
55
- * @returns {Promise<void>} - A promise that resolves when the persistence event is emitted.
56
- */
57
- const machineStatePersistOnTransition = (opts) => __awaiter(void 0, void 0, void 0, function* () {
58
- var _a, _b;
59
- const { cleanupOnFinalState, context, init, interpreter } = opts;
60
- const { machineState } = init, initEventData = __rest(init, ["machineState"]);
61
- if (!(context.agent.availableMethods().includes('machineStatePersist') && 'machineStatePersist' in context.agent)) {
62
- console.log(`IMachineStatePersistence was not exposed in the current agent. Disabling machine state persistence events`);
63
- return;
64
- }
65
- // We are using the event counter and evenDate to ensure we do not overwrite newer states. Events could come in out of order
66
- let _eventCounter = (_b = (_a = init.machineState) === null || _a === void 0 ? void 0 : _a.updatedCount) !== null && _b !== void 0 ? _b : 0;
67
- // XState persistence plugin is available. So let's emit events on every transition, so it can persist the state
68
- interpreter.onChange((_machineContext) => __awaiter(void 0, void 0, void 0, function* () {
69
- /*await (context.agent as TAgent<IMachineStatePersistence>).machineStatePersist({
70
- ...initEventData, // init value with machineState removed, as we are getting the latest state here
71
- state: interpreter.getSnapshot(),
72
- updatedCount: ++_eventCounter,
73
- cleanupOnFinalState: cleanupOnFinalState !== false,
74
- })*/
75
- (0, stateEventEmitter_1.emitMachineStatePersistEvent)({
76
- type: types_1.MachineStatePersistEventType.EVERY,
77
- data: Object.assign(Object.assign({}, initEventData), { state: interpreter.getSnapshot(), _eventCounter: ++_eventCounter, _eventDate: new Date(), _cleanupOnFinalState: cleanupOnFinalState !== false }),
78
- }, context);
79
- }));
80
- if (cleanupOnFinalState && context.agent.availableMethods().includes('machineStateDelete')) {
81
- interpreter.onDone((doneEvent) => {
82
- ;
83
- context.agent.machineStateDelete({
84
- tenantId: initEventData.tenantId,
85
- instanceId: initEventData.instanceId,
86
- });
87
- });
88
- }
89
- });
90
- exports.machineStatePersistOnTransition = machineStatePersistOnTransition;
91
- /**
92
- * Persist the initial state of a machine and register it with the given machine instance.
93
- *
94
- * @param {InitMachineStateArgs & {instance: Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>, context: IAgentContext<any>}} args - The options for initializing
95
- * machine state and registering it.
96
- * @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.
97
- */
98
- const machineStatePersistRegistration = (args) => __awaiter(void 0, void 0, void 0, function* () {
99
- var _a, _b;
100
- const { disablePersistence } = args;
101
- if (disablePersistence === true) {
102
- return;
103
- }
104
- // We use expires in MS first. If not provided, look at expires at. If not provided, the persistence will not expire
105
- const expiresAt = args.expireInMS ? new Date(Date.now() + args.expireInMS) : args.expiresAt;
106
- const machineName = (_b = (_a = args.machineName) !== null && _a !== void 0 ? _a : args.interpreter.machine.id) !== null && _b !== void 0 ? _b : args.interpreter.id;
107
- const init = yield (0, exports.machineStatePersistInit)(Object.assign(Object.assign({}, args), { machineName, expiresAt }));
108
- if (init) {
109
- yield (0, exports.machineStatePersistOnTransition)(Object.assign(Object.assign({}, args), { init }));
110
- }
111
- return init;
112
- });
113
- exports.machineStatePersistRegistration = machineStatePersistRegistration;
114
- const assertNonExpired = (args) => {
115
- const { expiresAt, machineName } = args;
116
- if (expiresAt && expiresAt.getTime() < Date.now()) {
117
- throw new Error(`Cannot resume ${machineName}. It expired at ${expiresAt.toLocaleString()}`);
118
- }
119
- };
120
- /**
121
- * Resumes the interpreter from a given state.
122
- *
123
- * @param {Object} args - The arguments for resuming the interpreter.
124
- * @param {MachineStateInfo} args.machineState - The machine state information.
125
- * @param {boolean} [args.noRegistration] - If true, no registration will be performed.
126
- * @param {Interpreter} args.interpreter - The interpreter instance.
127
- * @param {IAgentContext<IMachineStatePersistence>} args.context - The context for machine state persistence.
128
- *
129
- * @returns {Promise<Interpreter>} - A promise that resolves to the resumed interpreter.
130
- */
131
- const interpreterResumeFromState = (args) => __awaiter(void 0, void 0, void 0, function* () {
132
- const { interpreter, machineState, context, noRegistration, cleanupAllOtherInstances, cleanupOnFinalState } = args;
133
- const { machineName, instanceId, tenantId } = machineState;
134
- assertNonExpired(machineState);
135
- if (noRegistration !== true) {
136
- yield (0, exports.machineStatePersistRegistration)({
137
- stateType: 'existing',
138
- machineName,
139
- tenantId,
140
- existingInstanceId: instanceId,
141
- cleanupAllOtherInstances,
142
- cleanupOnFinalState,
143
- context,
144
- interpreter,
145
- });
146
- }
147
- const state = xstate_1.State.from(machineState.state.value, machineState.state.context);
148
- // @ts-ignore
149
- interpreter.start(state);
150
- // @ts-ignore
151
- yield (0, waitFor_1.waitFor)(interpreter, (awaitState) => awaitState.matches(state.value));
152
- return {
153
- machineState,
154
- init: (0, stateMapper_1.machineStateToMachineInit)(Object.assign(Object.assign({}, machineState), { stateType: 'existing' }), (0, stateMapper_1.machineStateToStoreInfo)(Object.assign(Object.assign({}, machineState), { stateType: 'existing' }))),
155
- interpreter,
156
- };
157
- });
158
- exports.interpreterResumeFromState = interpreterResumeFromState;
159
- /**
160
- * Resumes or starts the interpreter from the initial machine state.
161
- *
162
- * @async
163
- * @param {Object} args - The arguments for the function.
164
- * @param {MachineStateInit & {stateType?: MachineStateInitType}} args.init - The initialization state of the machine.
165
- * @param {boolean} args.noRegistration - Whether registration is required, defaults to false.
166
- * @param {Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>} args.interpreter - The interpreter object.
167
- * @param {IAgentContext<IMachineStatePersistence>} args.context - The context object.
168
- * @returns {Promise} - A promise that resolves to the interpreter instance.
169
- * @throws {Error} - If the machine name from init does not match the interpreter id.
170
- */
171
- const interpreterStartOrResumeFromInit = (args) => __awaiter(void 0, void 0, void 0, function* () {
172
- const { init, noRegistration, interpreter, cleanupOnFinalState, cleanupAllOtherInstances, context } = args;
173
- const { stateType, instanceId, machineName, tenantId, expiresAt } = init;
174
- if (init.machineName !== interpreter.id) {
175
- throw new Error(`Machine state init machine name ${init.machineName} does not match name from state machine interpreter ${interpreter.id}`);
176
- }
177
- assertNonExpired({ machineName, expiresAt });
178
- if (noRegistration !== true) {
179
- yield (0, exports.machineStatePersistRegistration)(Object.assign(Object.assign(Object.assign({ stateType: stateType !== null && stateType !== void 0 ? stateType : 'existing', machineName,
180
- tenantId }, (stateType === 'existing' && { existingInstanceId: instanceId })), (stateType === 'new' && { customInstanceId: instanceId })), { cleanupAllOtherInstances,
181
- cleanupOnFinalState,
182
- context,
183
- interpreter }));
184
- }
185
- let machineState;
186
- if (stateType === 'new') {
187
- interpreter.start();
188
- }
189
- else {
190
- machineState = yield context.agent.machineStateGet({ tenantId, instanceId });
191
- // @ts-ignore
192
- interpreter.start(machineState.state);
193
- }
194
- // We are waiting a bit
195
- yield new Promise((res) => setTimeout(res, 50));
196
- return {
197
- interpreter,
198
- machineState,
199
- init,
200
- };
201
- });
202
- exports.interpreterStartOrResumeFromInit = interpreterStartOrResumeFromInit;
203
- /**
204
- * Starts or resumes the given state machine interpreter.
205
- *
206
- * @async
207
- * @param {Object} args - The arguments for starting or resuming the interpreter.
208
- * @param {MachineStateInitType | 'auto'} [args.stateType] - The state type. Defaults to 'auto'.
209
- * @param {string} [args.instanceId] - The instance ID.
210
- * @param {string} [args.machineName] - The machine name.
211
- * @param {string} [args.tenantId] - The tenant ID.
212
- * @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
213
- * @param {boolean} [args.noRegistration] - Whether to skip state change event registration or not.
214
- * @param {Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>} args.interpreter - The interpreter to start or resume.
215
- * @param {IAgentContext<IMachineStatePersistence>} args.context - The agent context.
216
- * @returns {Promise} A promise that resolves when the interpreter is started or resumed.
217
- * @throws {Error} If there are multiple active instances of the machine and singletonCheck is true.
218
- * @throws {Error} If a new instance was requested with the same ID as an existing active instance.
219
- * @throws {Error} If the existing state machine with the given machine name and instance ID cannot be found.
220
- */
221
- const interpreterStartOrResume = (args) => __awaiter(void 0, void 0, void 0, function* () {
222
- var _a;
223
- const { stateType, singletonCheck, instanceId, tenantId, noRegistration, context, interpreter, cleanupAllOtherInstances, cleanupOnFinalState } = args;
224
- const machineName = (_a = args.machineName) !== null && _a !== void 0 ? _a : interpreter.id;
225
- let activeStates = yield context.agent.machineStatesFindActive({
226
- machineName,
227
- tenantId,
228
- instanceId,
229
- });
230
- if (stateType === 'new' && activeStates.length > 0 && cleanupAllOtherInstances) {
231
- // We cleanup here to not influence the logic below. Normally the agent machineStateInit method does the cleanup
232
- yield Promise.all(activeStates.map((state) => context.agent.machineStateDelete({
233
- tenantId: args.tenantId,
234
- instanceId: state.instanceId,
235
- })));
236
- // We search again, given the delete is using the passed in tenantId, instead of relying on the persisted tenantId. Should not matter, but just making sure
237
- activeStates = yield context.agent.machineStatesFindActive({
238
- machineName,
239
- tenantId,
240
- instanceId,
241
- });
242
- }
243
- if (singletonCheck && activeStates.length > 0) {
244
- if (stateType === 'new' ||
245
- (stateType === 'existing' &&
246
- ((!instanceId && activeStates.length > 1) || (instanceId && activeStates.every((state) => state.instanceId !== instanceId))))) {
247
- return Promise.reject(new Error(`Found ${activeStates.length} active '${machineName}' instances, but only one is allows at the same time`));
248
- }
249
- }
250
- if (stateType === 'new') {
251
- if (instanceId && activeStates.length > 0) {
252
- // Since an instanceId was provided it means the activeStates includes a machine with this instance. But stateType is 'new'
253
- return Promise.reject(new Error(`Found an active '${machineName}' instance with id ${instanceId}, but a new instance was requested with the same id`));
254
- }
255
- const init = yield context.agent.machineStateInit({
256
- stateType: 'new',
257
- customInstanceId: instanceId,
258
- machineName: machineName !== null && machineName !== void 0 ? machineName : interpreter.id,
259
- tenantId,
260
- cleanupAllOtherInstances,
261
- });
262
- return yield (0, exports.interpreterStartOrResumeFromInit)({
263
- init,
264
- noRegistration,
265
- interpreter,
266
- context,
267
- cleanupOnFinalState,
268
- cleanupAllOtherInstances,
269
- });
270
- }
271
- if (activeStates.length === 0) {
272
- if (stateType === 'existing') {
273
- return Promise.reject(new Error(`Could not find existing state machine ${machineName}, instanceId ${instanceId}`));
274
- }
275
- const init = yield context.agent.machineStateInit({
276
- stateType: 'new',
277
- customInstanceId: instanceId,
278
- machineName: machineName !== null && machineName !== void 0 ? machineName : interpreter.id,
279
- tenantId,
280
- cleanupAllOtherInstances,
281
- });
282
- return yield (0, exports.interpreterStartOrResumeFromInit)({
283
- init,
284
- noRegistration,
285
- interpreter,
286
- context,
287
- cleanupOnFinalState,
288
- cleanupAllOtherInstances,
289
- });
290
- }
291
- // activeStates length >= 1
292
- const activeState = activeStates[0];
293
- return (0, exports.interpreterResumeFromState)({
294
- machineState: activeState,
295
- noRegistration,
296
- interpreter,
297
- context,
298
- cleanupOnFinalState,
299
- cleanupAllOtherInstances,
300
- });
301
- });
302
- exports.interpreterStartOrResume = interpreterStartOrResume;
303
- //# sourceMappingURL=machineRegistration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"machineRegistration.js","sourceRoot":"","sources":["../../src/functions/machineRegistration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,mCAAiH;AACjH,gDAA4C;AAC5C,oCASiB;AACjB,2DAAkE;AAClE,+CAAkF;AAElF;;;;;;;GAOG;AACI,MAAM,uBAAuB,GAAG,CACrC,IAGG,EACoC,EAAE;IACzC,+EAA+E;IAC/E,MAAM,EAAE,OAAO,KAAc,IAAI,EAAb,IAAI,UAAK,IAAI,EAA3B,WAAoB,CAAO,CAAA;IACjC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,kBAAkB,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5G,OAAO,CAAC,GAAG,CAAC,wGAAwG,CAAC,CAAA;QACrH,OAAM;IACR,CAAC;IACD,OAAO,MAAO,OAAmD,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;AAChG,CAAC,CAAA,CAAA;AAbY,QAAA,uBAAuB,2BAanC;AAED;;;;;;;;;GASG;AACI,MAAM,+BAA+B,GAAG,CAS7C,IAKD,EAAiB,EAAE;;IAClB,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAChE,MAAM,EAAE,YAAY,KAAuB,IAAI,EAAtB,aAAa,UAAK,IAAI,EAAzC,gBAAkC,CAAO,CAAA;IAC/C,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,qBAAqB,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClH,OAAO,CAAC,GAAG,CAAC,2GAA2G,CAAC,CAAA;QACxH,OAAM;IACR,CAAC;IACD,4HAA4H;IAC5H,IAAI,a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CAAA,CAAA;AA7GY,QAAA,wBAAwB,4BA6GpC"}
@@ -1,10 +0,0 @@
1
- import { MachineStatePersistEvent, RequiredContext } from '../types';
2
- /**
3
- * Emits a machine state persistence event.
4
- *
5
- * @param {MachineStatePersistEvent} event - The event to be emitted.
6
- * @param {RequiredContext} context - The required agent context for the event emission.
7
- * @returns {void}
8
- */
9
- export declare const emitMachineStatePersistEvent: (event: MachineStatePersistEvent, context: RequiredContext) => void;
10
- //# sourceMappingURL=stateEventEmitter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stateEventEmitter.d.ts","sourceRoot":"","sources":["../../src/functions/stateEventEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAIpE;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,UAAW,wBAAwB,WAAW,eAAe,SAOrG,CAAA"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.emitMachineStatePersistEvent = void 0;
7
- const debug_1 = __importDefault(require("debug"));
8
- const debug = (0, debug_1.default)('sphereon:ssi-sdk:machine-state:xstate-persistence');
9
- /**
10
- * Emits a machine state persistence event.
11
- *
12
- * @param {MachineStatePersistEvent} event - The event to be emitted.
13
- * @param {RequiredContext} context - The required agent context for the event emission.
14
- * @returns {void}
15
- */
16
- const emitMachineStatePersistEvent = (event, context) => {
17
- debug(`Emitting machine state persistence event '${event.type}' with counter: ${event.data._eventCounter} and state ${JSON.stringify(event.data.state.value)}`);
18
- void context.agent.emit(event.type, event.data);
19
- };
20
- exports.emitMachineStatePersistEvent = emitMachineStatePersistEvent;
21
- //# sourceMappingURL=stateEventEmitter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stateEventEmitter.js","sourceRoot":"","sources":["../../src/functions/stateEventEmitter.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAGzB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,mDAAmD,CAAC,CAAA;AAExE;;;;;;GAMG;AACI,MAAM,4BAA4B,GAAG,CAAC,KAA+B,EAAE,OAAwB,EAAE,EAAE;IACxG,KAAK,CACH,6CAA6C,KAAK,CAAC,IAAI,mBAAmB,KAAK,CAAC,IAAI,CAAC,aAAa,cAAc,IAAI,CAAC,SAAS,CAC5H,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CACvB,EAAE,CACJ,CAAA;IACD,KAAK,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;AACjD,CAAC,CAAA;AAPY,QAAA,4BAA4B,gCAOxC"}
@@ -1,34 +0,0 @@
1
- import { StoreMachineStateInfo } from '@sphereon/ssi-sdk.data-store';
2
- import { State } from 'xstate';
3
- import { EventObject } from 'xstate/lib/types';
4
- import { MachineStateInfo, MachineStateInit, MachineStateInitType, MachineStatePersistArgs, SerializableState } from '../types';
5
- /**
6
- * Create a machine state info object useful for the store, based on the provided machine info and existing state.
7
- *
8
- * @param {MachineStatePersistArgs} machineInfo - The machine info object.
9
- * @param {Partial<StoreMachineStateInfo>} [existingState] - The optional existing state object.
10
- * @returns {StoreMachineStateInfo} - The store machine state info object.
11
- */
12
- export declare const machineStateToStoreInfo: (machineInfo: MachineStatePersistArgs, existingState?: Partial<StoreMachineStateInfo>) => StoreMachineStateInfo;
13
- export declare const storeInfoToMachineInit: (args: StoreMachineStateInfo & {
14
- stateType: MachineStateInitType;
15
- machineState?: MachineStateInfo;
16
- }) => MachineStateInit;
17
- export declare const machineStateToMachineInit: (machineInfo: MachineStatePersistArgs, existingState: Partial<StoreMachineStateInfo>) => MachineStateInit;
18
- /**
19
- * Serializes a machine state to a string representation.
20
- *
21
- * @param {State<T, TEvent> | SerializableState | string} state - The machine state to serialize.
22
- * @returns {string} - The serialized machine state.
23
- */
24
- export declare const serializeMachineState: <T, TEvent extends EventObject>(state: State<T, TEvent> | SerializableState | string) => string;
25
- /**
26
- * Deserializes a serialized machine state.
27
- *
28
- * @template T - The type of the machine's context.
29
- * @template TEvent - The type of the events that the machine handles.
30
- * @param {string} state - The serialized machine state.
31
- * @returns {State<T, TEvent>} - The deserialized machine state.
32
- */
33
- export declare const deserializeMachineState: <T, TEvent extends EventObject>(state: string) => State<T, TEvent>;
34
- //# sourceMappingURL=stateMapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stateMapper.d.ts","sourceRoot":"","sources":["../../src/functions/stateMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE/H;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,gBACrB,uBAAuB,kBACpB,OAAO,CAAC,qBAAqB,CAAC,KAC7C,qBA0BF,CAAA;AACD,eAAO,MAAM,sBAAsB,SAC3B,qBAAqB,GAAG;IAAE,SAAS,EAAE,oBAAoB,CAAC;IAAC,YAAY,CAAC,EAAE,gBAAgB,CAAA;CAAE,KACjG,gBAWF,CAAA;AAED,eAAO,MAAM,yBAAyB,gBAAiB,uBAAuB,iBAAiB,OAAO,CAAC,qBAAqB,CAAC,KAAG,gBAM/H,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,EAAE,MAAM,SAAS,WAAW,SAAS,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,iBAAiB,GAAG,MAAM,KAAG,MAM3H,CAAA;AACD;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,EAAE,MAAM,SAAS,WAAW,SAAS,MAAM,KAAG,KAAK,CAAC,CAAC,EAAE,MAAM,CAErG,CAAA"}
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializeMachineState = exports.serializeMachineState = exports.machineStateToMachineInit = exports.storeInfoToMachineInit = exports.machineStateToStoreInfo = void 0;
4
- const xstate_1 = require("xstate");
5
- /**
6
- * Create a machine state info object useful for the store, based on the provided machine info and existing state.
7
- *
8
- * @param {MachineStatePersistArgs} machineInfo - The machine info object.
9
- * @param {Partial<StoreMachineStateInfo>} [existingState] - The optional existing state object.
10
- * @returns {StoreMachineStateInfo} - The store machine state info object.
11
- */
12
- const machineStateToStoreInfo = (machineInfo, existingState) => {
13
- var _a, _b, _c;
14
- const { state, machineName, tenantId, expiresAt, instanceId, updatedCount } = machineInfo;
15
- const existing = existingState !== null && existingState !== void 0 ? existingState : { machineName, createdAt: new Date(), expiresAt };
16
- const stateInstance = xstate_1.State.create(machineInfo.state);
17
- let latestStateName = undefined;
18
- if (stateInstance.value) {
19
- latestStateName = typeof stateInstance.value === 'string' ? stateInstance.value : JSON.stringify(stateInstance.value);
20
- }
21
- if (latestStateName === '{}') {
22
- latestStateName = undefined;
23
- }
24
- return {
25
- instanceId,
26
- updatedCount: updatedCount !== null && updatedCount !== void 0 ? updatedCount : ((existing === null || existing === void 0 ? void 0 : existing.updatedCount) ? existing.updatedCount++ : 0),
27
- sessionId: (_a = stateInstance._sessionid) !== null && _a !== void 0 ? _a : undefined,
28
- machineName,
29
- state: (0, exports.serializeMachineState)(state),
30
- tenantId,
31
- latestStateName,
32
- latestEventType: stateInstance.event.type,
33
- updatedAt: new Date(),
34
- expiresAt,
35
- createdAt: (_b = existing.createdAt) !== null && _b !== void 0 ? _b : new Date(),
36
- completedAt: (_c = existing.completedAt) !== null && _c !== void 0 ? _c : (stateInstance.done ? new Date() : undefined),
37
- };
38
- };
39
- exports.machineStateToStoreInfo = machineStateToStoreInfo;
40
- const storeInfoToMachineInit = (args) => {
41
- const { instanceId, machineName, tenantId, expiresAt, createdAt, stateType, machineState } = args;
42
- return {
43
- stateType,
44
- machineName,
45
- tenantId,
46
- expiresAt,
47
- instanceId,
48
- createdAt,
49
- machineState,
50
- };
51
- };
52
- exports.storeInfoToMachineInit = storeInfoToMachineInit;
53
- const machineStateToMachineInit = (machineInfo, existingState) => {
54
- return (0, exports.storeInfoToMachineInit)(Object.assign(Object.assign({}, (0, exports.machineStateToStoreInfo)(machineInfo, existingState)), { stateType: 'existing', machineState: machineInfo.machineState }));
55
- };
56
- exports.machineStateToMachineInit = machineStateToMachineInit;
57
- /**
58
- * Serializes a machine state to a string representation.
59
- *
60
- * @param {State<T, TEvent> | SerializableState | string} state - The machine state to serialize.
61
- * @returns {string} - The serialized machine state.
62
- */
63
- const serializeMachineState = (state) => {
64
- if (typeof state === 'string') {
65
- return state;
66
- }
67
- const jsonState = 'toJSON' in state ? state.toJSON() : state;
68
- return JSON.stringify(jsonState);
69
- };
70
- exports.serializeMachineState = serializeMachineState;
71
- /**
72
- * Deserializes a serialized machine state.
73
- *
74
- * @template T - The type of the machine's context.
75
- * @template TEvent - The type of the events that the machine handles.
76
- * @param {string} state - The serialized machine state.
77
- * @returns {State<T, TEvent>} - The deserialized machine state.
78
- */
79
- const deserializeMachineState = (state) => {
80
- return xstate_1.State.create(JSON.parse(state));
81
- };
82
- exports.deserializeMachineState = deserializeMachineState;
83
- //# sourceMappingURL=stateMapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stateMapper.js","sourceRoot":"","sources":["../../src/functions/stateMapper.ts"],"names":[],"mappings":";;;AACA,mCAA8B;AAI9B;;;;;;GAMG;AACI,MAAM,uBAAuB,GAAG,CACrC,WAAoC,EACpC,aAA8C,EACvB,EAAE;;IACzB,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,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+0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,cAAc,iCAAiC,CAAA;AAC/C,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA"}
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.5"
9
- }
10
- ]
11
- }
@@ -1,62 +0,0 @@
1
- import { IPluginMethodMap } from '@veramo/core';
2
- import { DeleteExpiredStatesArgs, DeleteStateResult, FindActiveStatesArgs, MachineStateInfo, MachineStateInit, InitMachineStateArgs, RequiredContext, MachineStatePersistArgs, MachineStateGetArgs, MachineStateDeleteArgs } from './types';
3
- /**
4
- * The interface definition for a plugin that can issue and verify Verifiable Credentials and Presentations
5
- * that use JSON-LD format.
6
- *
7
- * @remarks Please see {@link https://www.w3.org/TR/vc-data-model | W3C Verifiable Credentials data model}
8
- *
9
- * @beta This API is likely to change without a BREAKING CHANGE notice
10
- */
11
- export interface IMachineStatePersistence extends IPluginMethodMap {
12
- /**
13
- * Loads the states of active xstate machines from the database.
14
- *
15
- * @param args FindActiveStatesArgs
16
- * type of the event
17
- *
18
- * @returns state or null
19
- *
20
- * @beta This API is likely to change without a BREAKING CHANGE notice
21
- */
22
- machineStatesFindActive(args: FindActiveStatesArgs): Promise<Array<MachineStateInfo>>;
23
- /**
24
- * Deletes the state of an xstate machine in the database.
25
- *
26
- * @param args DeleteExpiredStatesArgs
27
- * type: optional type of the machine
28
- *
29
- * @beta This API is likely to change without a BREAKING CHANGE notice
30
- */
31
- machineStatesDeleteExpired(args: DeleteExpiredStatesArgs): Promise<DeleteStateResult>;
32
- /**
33
- * Initializes a state object for a new machine. Does not persist anything
34
- * @param args Requires a machineName, instanceId and tenantId are optional
35
- */
36
- machineStateInit(args: InitMachineStateArgs): Promise<MachineStateInit>;
37
- /**
38
- * Persists the state
39
- * @param args MachineStatePersistArgs
40
- *
41
- * @param context
42
- * @beta This API is likely to change without a BREAKING CHANGE notice
43
- */
44
- machineStatePersist(args: MachineStatePersistArgs, context: RequiredContext): Promise<MachineStateInfo>;
45
- /**
46
- * Get a particular machine state by instance id and tenant id
47
- * @param args instance id and tenant id
48
- *
49
- * @param context
50
- * @beta This API is likely to change without a BREAKING CHANGE notice
51
- */
52
- machineStateGet(args: MachineStateGetArgs, context: RequiredContext): Promise<MachineStateInfo>;
53
- /**
54
- * Delete a particular machine state by instance id and tenant id
55
- * @param args instance id and tenant id
56
- *
57
- * @param context
58
- * @beta This API is likely to change without a BREAKING CHANGE notice
59
- */
60
- machineStateDelete(args: MachineStateDeleteArgs, context: RequiredContext): Promise<boolean>;
61
- }
62
- //# sourceMappingURL=IMachineStatePersistence.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IMachineStatePersistence.d.ts","sourceRoot":"","sources":["../../src/types/IMachineStatePersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,SAAS,CAAA;AAEhB;;;;;;;GAOG;AACH,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAChE;;;;;;;;;OASG;IACH,uBAAuB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAErF;;;;;;;OAOG;IACH,0BAA0B,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAErF;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAEvE;;;;;;OAMG;IACH,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAEvG;;;;;;OAMG;IACH,eAAe,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAE/F;;;;;;OAMG;IACH,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC7F"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IMachineStatePersistence.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IMachineStatePersistence.js","sourceRoot":"","sources":["../../src/types/IMachineStatePersistence.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- export * from './IMachineStatePersistence';
2
- export * from './types';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,SAAS,CAAA"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./IMachineStatePersistence"), exports);
18
- __exportStar(require("./types"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA0C;AAC1C,0CAAuB"}