@sphereon/ssi-sdk.xstate-machine-persistence 0.19.1-next.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +181 -0
- package/dist/agent/MachineStatePersistence.d.ts +26 -0
- package/dist/agent/MachineStatePersistence.d.ts.map +1 -0
- package/dist/agent/MachineStatePersistence.js +194 -0
- package/dist/agent/MachineStatePersistence.js.map +1 -0
- package/dist/functions/index.d.ts +4 -0
- package/dist/functions/index.d.ts.map +1 -0
- package/dist/functions/index.js +20 -0
- package/dist/functions/index.js.map +1 -0
- package/dist/functions/machineRegistration.d.ts +47 -0
- package/dist/functions/machineRegistration.d.ts.map +1 -0
- package/dist/functions/machineRegistration.js +94 -0
- package/dist/functions/machineRegistration.js.map +1 -0
- package/dist/functions/stateEventEmitter.d.ts +10 -0
- package/dist/functions/stateEventEmitter.d.ts.map +1 -0
- package/dist/functions/stateEventEmitter.js +21 -0
- package/dist/functions/stateEventEmitter.js.map +1 -0
- package/dist/functions/stateMapper.d.ts +38 -0
- package/dist/functions/stateMapper.d.ts.map +1 -0
- package/dist/functions/stateMapper.js +78 -0
- package/dist/functions/stateMapper.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/ssi-sdk.xstate-machine-persistence.d.ts +360 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/IMachineStatePersistence.d.ts +62 -0
- package/dist/types/IMachineStatePersistence.d.ts.map +1 -0
- package/dist/types/IMachineStatePersistence.js +3 -0
- package/dist/types/IMachineStatePersistence.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/types.d.ts +150 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +13 -0
- package/dist/types/types.js.map +1 -0
- package/package.json +56 -0
- package/plugin.schema.json +570 -0
- package/src/__tests__/localAgent.test.ts +32 -0
- package/src/__tests__/restAgent.test.ts +73 -0
- package/src/__tests__/shared/MachineStatePersistenceAgentLogic.ts +202 -0
- package/src/agent/MachineStatePersistence.ts +172 -0
- package/src/functions/index.ts +3 -0
- package/src/functions/machineRegistration.ts +115 -0
- package/src/functions/stateEventEmitter.ts +16 -0
- package/src/functions/stateMapper.ts +78 -0
- package/src/index.ts +5 -0
- package/src/types/IMachineStatePersistence.ts +79 -0
- package/src/types/index.ts +2 -0
- package/src/types/types.ts +169 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this fragment.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2021] [Sphereon BV]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<!--suppress HtmlDeprecatedAttribute -->
|
|
2
|
+
<h1 align="center">
|
|
3
|
+
<br>
|
|
4
|
+
<a href="https://www.sphereon.com"><img src="https://sphereon.com/content/themes/sphereon/assets/img/logo.svg" alt="Sphereon" width="400"></a>
|
|
5
|
+
<br>XState Machine Persistence
|
|
6
|
+
<br>Allows to continue xstate machine at a later point in time
|
|
7
|
+
|
|
8
|
+
<br>
|
|
9
|
+
</h1>
|
|
10
|
+
|
|
11
|
+
The XState Persistence Plugin is designed to manage and persist XState machine states, allowing for durable, long-term
|
|
12
|
+
storage of state machines.
|
|
13
|
+
This enables applications to save, load, and delete state machine instances, facilitating seamless state management and
|
|
14
|
+
recovery across sessions.
|
|
15
|
+
|
|
16
|
+
Features:
|
|
17
|
+
|
|
18
|
+
- Load State: Retrieve the current state of an XState machine from persistent storage.
|
|
19
|
+
- Delete Expired States: Automatically remove state instances that have exceeded their lifespan, or are finished
|
|
20
|
+
ensuring efficient use of storage.
|
|
21
|
+
- Persist Machine Snapshot: Save snapshots of XState machine states, allowing for recovery and resumption of stateful
|
|
22
|
+
processes. This can be done manually or it can be automatically registered with any xstate interpreter instance
|
|
23
|
+
|
|
24
|
+
Installation
|
|
25
|
+
|
|
26
|
+
To add the XState Persistence Plugin to your project, run:
|
|
27
|
+
|
|
28
|
+
```shell
|
|
29
|
+
yarn add @sphereon/ssi-sdk.xstate-machine-persistence
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or if you prefer using npm:
|
|
33
|
+
|
|
34
|
+
```shell
|
|
35
|
+
npm install @sphereon/ssi-sdk.xstate-machine-persistence
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
# Usage
|
|
39
|
+
|
|
40
|
+
Configuring the Plugin with Veramo
|
|
41
|
+
|
|
42
|
+
First, ensure you have Veramo set up in your project. Then, integrate the XState Persistence Plugin as follows:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { createAgent } from '@veramo/core'
|
|
46
|
+
import { MachineStatePersistence, DataStoreMachineStateMigrations, DataStoreMachineStateEntities } from '@sphereon/ssi-sdk.xstate-machine-persistence'
|
|
47
|
+
|
|
48
|
+
const dbConnection = await new DataSource({
|
|
49
|
+
type: 'sqlite',
|
|
50
|
+
database: ':memory:',
|
|
51
|
+
logging: 'all',
|
|
52
|
+
migrationsRun: false,
|
|
53
|
+
migrations: DataStoreMachineStateMigrations, // Database migrations for the data store, specific for state machines
|
|
54
|
+
synchronize: false,
|
|
55
|
+
entities: DataStoreMachineStateEntities, // All the entities needed for the data store, related to state machines
|
|
56
|
+
}).initialize()
|
|
57
|
+
|
|
58
|
+
const agent = createAgent({
|
|
59
|
+
plugins: [
|
|
60
|
+
new MachineStatePersistence({
|
|
61
|
+
eventTypes: ['EVERY'], // Enables listening to 'EVERY' events to persist the state on every state change
|
|
62
|
+
store: new MachineStateStore(dbConnection),
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Automatic registration of state change persistence
|
|
69
|
+
|
|
70
|
+
You can use a simple method on an Xstate machine interpreter to automatically persist the latest state on every state
|
|
71
|
+
change of the machine, allowing for later continuation of the machine.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { createMachine, interpret } from 'xstate'
|
|
75
|
+
import { machineStatePersistRegistration } from '@sphereon/ssi-sdk.xstate-machine-persistence'
|
|
76
|
+
|
|
77
|
+
const context = { ...agent.context, agent }
|
|
78
|
+
export const exampleMachine = createMachine({
|
|
79
|
+
predictableActionArguments: true,
|
|
80
|
+
id: 'example',
|
|
81
|
+
context: {},
|
|
82
|
+
initial: 'init',
|
|
83
|
+
states: {
|
|
84
|
+
init: {
|
|
85
|
+
id: 'init',
|
|
86
|
+
on: {
|
|
87
|
+
finalize: {
|
|
88
|
+
target: 'final',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
final: {
|
|
93
|
+
id: 'final',
|
|
94
|
+
type: 'final',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
const instance = interpret(exampleMachine).start()
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* - instance is the Xstate Machine interpreter instance
|
|
103
|
+
* - context is the agent context
|
|
104
|
+
* - machineName is optional. It will be deduced from the machine if not provided. If you use a different name, be sure to use that for any future methods as well
|
|
105
|
+
* - instanceId is optional. Allows you to provide your own unique Id. If not provided a random uuid will be generated
|
|
106
|
+
*/
|
|
107
|
+
const registration = await machineStatePersistRegistration({ instance, context, machineName: exampleMachine.id })
|
|
108
|
+
console.log(JSON.stringify(registration))
|
|
109
|
+
/**
|
|
110
|
+
* {
|
|
111
|
+
* "machineName": "example",
|
|
112
|
+
* "instanceId": "585b72e3-0655-4aee-a575-1234873ea7b0",
|
|
113
|
+
* "createdAt": "2024-03-07T22:47:45.445Z"
|
|
114
|
+
* }
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
// That is all. From this point on the machine will persist the state on every state change. You can use the instanceId value if you want to do anything with the persisted object at a later point in time
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Retrieving machine state info.
|
|
121
|
+
|
|
122
|
+
You can retrieve machine state info in 2 ways. If you know the instanceId, you can directly get it. Otherwise you can query for the active, read not finalized or cleaned up, instances of machine states.
|
|
123
|
+
|
|
124
|
+
Getting a single machine state info object by instance id:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
const machineStateInfo = await agent.machineStateGet({ instanceId })
|
|
128
|
+
console.log(JSON.stringify(machineStateInfo, null, 2))
|
|
129
|
+
/**
|
|
130
|
+
* {
|
|
131
|
+
* "instanceId": "585b72e3-0655-4aee-a575-1234873ea7b0",
|
|
132
|
+
* "sessionId": "x:1", <=== The xtsate session id. Please note that this is only unique for a single xstate instance in memory and will be lost accross restarts
|
|
133
|
+
* "machineName": "example",
|
|
134
|
+
* "latestStateName": "init", <=== The latest state of the xstate machine for easy access
|
|
135
|
+
* "latestEventType": "increment", <=== The latest event of the xstate machine for easy access
|
|
136
|
+
* "state": { <=== This is the actual Xstate state
|
|
137
|
+
* "actions": [],
|
|
138
|
+
* "activities": {},
|
|
139
|
+
* "meta": {},
|
|
140
|
+
* ....
|
|
141
|
+
* },
|
|
142
|
+
* "createdAt": "2024-03-07T23:00:11.438Z",
|
|
143
|
+
* "updatedAt": "2024-03-07T23:00:11.543Z",
|
|
144
|
+
* "updatedCount": 1, <=== The amount of updates applied to the persisted state (the amount of events/statechanges)
|
|
145
|
+
* "expiresAt": null, <=== If this date-time is set, the machine state will not be used anymore
|
|
146
|
+
* "completedAt": null <=== The date-time the instance reached a final state
|
|
147
|
+
* }
|
|
148
|
+
*/
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Getting active machine state info objects by machine name:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const machineStateInfos = await agent.machineStatesFindActive({ machineName: 'example' })
|
|
155
|
+
console.log(JSON.stringify(machineStateInfos[0], null, 2))
|
|
156
|
+
// See console.log example in previous code block
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Manual persistence and cleanup methods
|
|
160
|
+
|
|
161
|
+
Persisting a Machine Snapshot
|
|
162
|
+
|
|
163
|
+
To save the current state of an XState machine:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
await agent.machineStatePersist({
|
|
167
|
+
instanceId: 'your-state-instanceId',
|
|
168
|
+
state: 'You Xstate here',
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Deleting Expired States
|
|
173
|
+
|
|
174
|
+
To clean up expired states from the storage:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
await agent.machineStatesDeleteExpired({
|
|
178
|
+
deleteDoneStates: false, // Optional: If true, will delete any states that are completed. If false, will delete any expired states, no matter whether they are done or not
|
|
179
|
+
machineName: 'example', // Optional: Only delete istances for machines named 'example'
|
|
180
|
+
})
|
|
181
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IAbstractMachineStateStore } from '@sphereon/ssi-sdk.data-store';
|
|
2
|
+
import { IAgentPlugin } from '@veramo/core';
|
|
3
|
+
import { IMachineStatePersistence, MachineStatePersistEvent, MachineStatePersistOpts, RequiredContext } from '../index';
|
|
4
|
+
/**
|
|
5
|
+
* This class implements the IMachineStatePersistence interface using a datastore.
|
|
6
|
+
*
|
|
7
|
+
* This allows you to store and retrieve the State of a state machine/application by their types.
|
|
8
|
+
*
|
|
9
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
10
|
+
*/
|
|
11
|
+
export declare class MachineStatePersistence implements IAgentPlugin {
|
|
12
|
+
readonly schema: any;
|
|
13
|
+
readonly methods: IMachineStatePersistence | {};
|
|
14
|
+
readonly eventTypes: Array<string>;
|
|
15
|
+
private readonly _store?;
|
|
16
|
+
get store(): IAbstractMachineStateStore;
|
|
17
|
+
constructor(opts: MachineStatePersistOpts);
|
|
18
|
+
onEvent(event: MachineStatePersistEvent, context: RequiredContext): Promise<void>;
|
|
19
|
+
private machineStateInit;
|
|
20
|
+
private machineStatePersist;
|
|
21
|
+
private machineStatesFindActive;
|
|
22
|
+
private machineStatesDeleteExpired;
|
|
23
|
+
private machineStateGet;
|
|
24
|
+
private machineStateDelete;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=MachineStatePersistence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MachineStatePersistence.d.ts","sourceRoot":"","sources":["../../src/agent/MachineStatePersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAyB,MAAM,8BAA8B,CAAA;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAM3C,OAAO,EAIL,wBAAwB,EAOxB,wBAAwB,EAExB,uBAAuB,EACvB,eAAe,EAEhB,MAAM,UAAU,CAAA;AAIjB;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IAC1D,QAAQ,CAAC,MAAM,MAAkC;IACjD,QAAQ,CAAC,OAAO,EAAE,wBAAwB,GAAG,EAAE,CAAA;IAC/C,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAA4B;IAEpD,IAAI,KAAK,IAAI,0BAA0B,CAKtC;gBAEW,IAAI,EAAE,uBAAuB;IAqB5B,OAAO,CAAC,KAAK,EAAE,wBAAwB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YAwBhF,gBAAgB;YA8BhB,mBAAmB;YAcnB,uBAAuB;YAWvB,0BAA0B;YAQ1B,eAAe;YASf,kBAAkB;CAOjC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.MachineStatePersistence = void 0;
|
|
39
|
+
const console = __importStar(require("console"));
|
|
40
|
+
const debug_1 = __importDefault(require("debug"));
|
|
41
|
+
const uuid_1 = require("uuid");
|
|
42
|
+
const functions_1 = require("../functions");
|
|
43
|
+
const index_1 = require("../index");
|
|
44
|
+
const debug = (0, debug_1.default)('sphereon:ssi-sdk:machine-state:xstate-persistence');
|
|
45
|
+
/**
|
|
46
|
+
* This class implements the IMachineStatePersistence interface using a datastore.
|
|
47
|
+
*
|
|
48
|
+
* This allows you to store and retrieve the State of a state machine/application by their types.
|
|
49
|
+
*
|
|
50
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
51
|
+
*/
|
|
52
|
+
class MachineStatePersistence {
|
|
53
|
+
get store() {
|
|
54
|
+
if (!this._store) {
|
|
55
|
+
throw Error('No store available in options');
|
|
56
|
+
}
|
|
57
|
+
return this._store;
|
|
58
|
+
}
|
|
59
|
+
constructor(opts) {
|
|
60
|
+
this.schema = index_1.schema.IMachineStatePersistence;
|
|
61
|
+
const { store, eventTypes, isRESTClient } = opts;
|
|
62
|
+
this.eventTypes = eventTypes;
|
|
63
|
+
this.methods = {
|
|
64
|
+
machineStatesFindActive: this.machineStatesFindActive.bind(this),
|
|
65
|
+
machineStatesDeleteExpired: this.machineStatesDeleteExpired.bind(this),
|
|
66
|
+
machineStateInit: this.machineStateInit.bind(this),
|
|
67
|
+
machineStatePersist: this.machineStatePersist.bind(this),
|
|
68
|
+
machineStateGet: this.machineStateGet.bind(this),
|
|
69
|
+
machineStateDelete: this.machineStateDelete.bind(this),
|
|
70
|
+
};
|
|
71
|
+
this._store = store;
|
|
72
|
+
if (isRESTClient) {
|
|
73
|
+
// Methods are delegated to the REMOTE Agent. We need the above eventTypes however, to ensure the local eventBus works
|
|
74
|
+
// We do set the store, because we might have some local and some remote methods
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
else if (!store) {
|
|
78
|
+
throw Error('No store available in options');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
onEvent(event, context) {
|
|
82
|
+
var _a;
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
debug(`Received machine state persistence event '${event.type}' counter: ${event.data._eventCounter}`);
|
|
85
|
+
if (!this.eventTypes.includes(event.type)) {
|
|
86
|
+
console.log(`event type ${event.type} not registered for agent. Registered: ${JSON.stringify(this.eventTypes)}`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// Below we are calling the context of the agent instead of this to make sure the REST client is called when configured
|
|
90
|
+
switch (event.type) {
|
|
91
|
+
case index_1.MachineStatePersistEventType.INIT:
|
|
92
|
+
yield context.agent.machineStateInit(Object.assign({}, event.data));
|
|
93
|
+
break;
|
|
94
|
+
case index_1.MachineStatePersistEventType.EVERY:
|
|
95
|
+
if (event.data.state.done) {
|
|
96
|
+
// TODO: Cleanup on done
|
|
97
|
+
}
|
|
98
|
+
// We are keeping track of the update counter in the events, ensuring we do not process out of order
|
|
99
|
+
yield context.agent.machineStatePersist(Object.assign(Object.assign({}, event.data), { updatedCount: (_a = event.data._eventCounter) !== null && _a !== void 0 ? _a : event.data.updatedCount }));
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
return Promise.reject(Error('Event type not supported'));
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
machineStateInit(args) {
|
|
107
|
+
var _a;
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
const { tenantId, machineName, expiresAt, customInstanceId, existingInstanceId } = args;
|
|
110
|
+
debug(`machineStateInit for machine name ${machineName}, tenant ${tenantId}, custom instance ${customInstanceId}, existing id ${existingInstanceId}`);
|
|
111
|
+
let machineInit = undefined;
|
|
112
|
+
if (customInstanceId && existingInstanceId) {
|
|
113
|
+
return Promise.reject(new Error(`Cannot have both a custom and existing instance id at the same time`));
|
|
114
|
+
}
|
|
115
|
+
else if (existingInstanceId) {
|
|
116
|
+
// An instanceId is provided. First lookup whether this id is persisted, if not an error is thrown
|
|
117
|
+
debug(`machineStateInit is using a previously persisted instance id (${existingInstanceId})`);
|
|
118
|
+
const state = yield this.store.getMachineState({ tenantId, instanceId: existingInstanceId });
|
|
119
|
+
machineInit = (0, functions_1.storeInfoToMachineInit)(Object.assign(Object.assign({}, state), { stateType: 'existing' }));
|
|
120
|
+
}
|
|
121
|
+
else if (customInstanceId) {
|
|
122
|
+
// An custom instanceId is provided.
|
|
123
|
+
debug(`machineStateInit is using a custom instance id (${existingInstanceId})`);
|
|
124
|
+
}
|
|
125
|
+
if (!machineInit) {
|
|
126
|
+
machineInit = {
|
|
127
|
+
machineName,
|
|
128
|
+
tenantId,
|
|
129
|
+
expiresAt,
|
|
130
|
+
instanceId: customInstanceId !== null && customInstanceId !== void 0 ? customInstanceId : (0, uuid_1.v4)(),
|
|
131
|
+
createdAt: (_a = args.createdAt) !== null && _a !== void 0 ? _a : new Date(),
|
|
132
|
+
stateType: 'new',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
debug(`machineStateInit result: ${JSON.stringify(machineInit)}`);
|
|
136
|
+
return machineInit;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
machineStatePersist(args) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
const { instanceId, tenantId, machineName, updatedCount } = args;
|
|
142
|
+
debug(`machineStatePersist for machine name ${machineName}, updateCount: ${updatedCount}, instance ${instanceId} and tenant ${tenantId}...`);
|
|
143
|
+
const queriedStates = yield this.store.findMachineStates({ filter: [{ instanceId, tenantId }] });
|
|
144
|
+
const existingState = queriedStates.length === 1 ? queriedStates[0] : undefined;
|
|
145
|
+
const storeInfoArgs = (0, functions_1.machineStateToStoreInfo)(args, existingState);
|
|
146
|
+
const storedState = yield this.store.persistMachineState(storeInfoArgs);
|
|
147
|
+
const machineStateInfo = Object.assign(Object.assign({}, storedState), { state: (0, functions_1.deserializeMachineState)(storedState.state) });
|
|
148
|
+
debug(`machineStatePersist success for machine name ${machineName}, instance ${instanceId}, update count ${machineStateInfo.updatedCount}, tenant ${tenantId}, last event: ${machineStateInfo.latestEventType}, last state: ${machineStateInfo.latestStateName}`);
|
|
149
|
+
return machineStateInfo;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
machineStatesFindActive(args) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const { machineName, tenantId } = args;
|
|
155
|
+
debug(`machineStateFindActive for machine name ${machineName} and tenant ${tenantId}...`);
|
|
156
|
+
const storedStates = yield this.store.findActiveMachineStates(args);
|
|
157
|
+
const machineStateInfos = storedStates.map((storedState) => {
|
|
158
|
+
return Object.assign(Object.assign({}, storedState), { state: (0, functions_1.deserializeMachineState)(storedState.state) });
|
|
159
|
+
});
|
|
160
|
+
debug(`machineStateFindActive returned ${machineStateInfos.length} results for machine name ${machineName} and tenant ${tenantId}`);
|
|
161
|
+
return machineStateInfos;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
machineStatesDeleteExpired(args) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
const { machineName, tenantId } = args;
|
|
167
|
+
debug(`machineStatesDeleteExpired for machine name ${machineName} and tenant ${tenantId}...`);
|
|
168
|
+
const deleteResult = yield this.store.deleteExpiredMachineStates(args);
|
|
169
|
+
debug(`machineStatesDeleteExpired result for machine name ${machineName} and tenant ${tenantId}: ${deleteResult}`);
|
|
170
|
+
return deleteResult;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
machineStateGet(args, context) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
const { instanceId, tenantId } = args;
|
|
176
|
+
debug(`machineStateGet for machine instance ${instanceId} and tenant ${tenantId}...`);
|
|
177
|
+
const storedState = yield this.store.getMachineState(args);
|
|
178
|
+
const machineInfo = Object.assign(Object.assign({}, storedState), { state: (0, functions_1.deserializeMachineState)(storedState.state) });
|
|
179
|
+
debug(`machineStateGet result for machine instance ${instanceId} and tenant ${tenantId}: ${machineInfo}`);
|
|
180
|
+
return machineInfo;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
machineStateDelete(args, context) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
const { instanceId, tenantId } = args;
|
|
186
|
+
debug(`machineStateDelete for machine instance ${instanceId} and tenant ${tenantId}...`);
|
|
187
|
+
const deleteResult = yield this.store.deleteMachineState(args);
|
|
188
|
+
debug(`machineStateDelete result for machine instance ${instanceId} and tenant ${tenantId}: ${deleteResult}`);
|
|
189
|
+
return deleteResult;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.MachineStatePersistence = MachineStatePersistence;
|
|
194
|
+
//# sourceMappingURL=MachineStatePersistence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MachineStatePersistence.js","sourceRoot":"","sources":["../../src/agent/MachineStatePersistence.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,iDAAkC;AAClC,kDAAyB;AACzB,+BAAmC;AACnC,4CAAuG;AAEvG,oCAgBiB;AAEjB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,mDAAmD,CAAC,CAAA;AAExE;;;;;;GAMG;AACH,MAAa,uBAAuB;IAMlC,IAAI,KAAK;QACP,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,KAAK,CAAC,+BAA+B,CAAC,CAAA;SAC7C;QACD,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,YAAY,IAA6B;QAZhC,WAAM,GAAG,cAAM,CAAC,wBAAwB,C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,EAAE,GAAG,IAAI,CAAA;YACrC,KAAK,CAAC,wCAAwC,UAAU,eAAe,QAAQ,KAAK,CAAC,CAAA;YACrF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;YAC1D,MAAM,WAAW,mCAAQ,WAAW,KAAE,KAAK,EAAE,IAAA,mCAAuB,EAAC,WAAW,CAAC,KAAK,CAAC,GAAE,CAAA;YACzF,KAAK,CAAC,+CAA+C,UAAU,eAAe,QAAQ,KAAK,WAAW,EAAE,CAAC,CAAA;YACzG,OAAO,WAAW,CAAA;QACpB,CAAC;KAAA;IAEa,kBAAkB,CAAC,IAA4B,EAAE,OAAwB;;YACrF,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;YACrC,KAAK,CAAC,2CAA2C,UAAU,eAAe,QAAQ,KAAK,CAAC,CAAA;YACxF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA;YAC9D,KAAK,CAAC,kDAAkD,UAAU,eAAe,QAAQ,KAAK,YAAY,EAAE,CAAC,CAAA;YAC7G,OAAO,YAAY,CAAA;QACrB,CAAC;KAAA;CACF;AAzID,0DAyIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./machineRegistration"), exports);
|
|
18
|
+
__exportStar(require("./stateMapper"), exports);
|
|
19
|
+
__exportStar(require("./stateEventEmitter"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC;AACrC,gDAA6B;AAC7B,sDAAmC"}
|