@scion-scxml/express-middleware 1.0.3 → 2.0.1
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/CHANGES +4 -0
- package/LICENSE +1 -0
- package/lib/index.js +9 -9
- package/package.json +6 -6
package/CHANGES
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
== 2.0.0 ==
|
|
2
|
+
|
|
3
|
+
Modify API handleScxmlEvent to accept kwArgs. Allow handleScxmlEvent to accept an optional executionContext param
|
|
4
|
+
|
|
1
5
|
== 1.0.3 ==
|
|
2
6
|
|
|
3
7
|
Fix issue in scion express middleware: on initializing the new session, it was not waiting for the asynchronous database write to finish before calling the callback, so a subsequent event could be processed before the the serialized session was finished writing to the database
|
package/LICENSE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
SCION is composed of a number of sub-modules. Please see the LICENSE file in each module directory for that module's licensing.
|
package/lib/index.js
CHANGED
|
@@ -106,16 +106,16 @@ module.exports = function ({
|
|
|
106
106
|
function doSend(session, event){
|
|
107
107
|
//console.log('session', session)
|
|
108
108
|
const scxmlName = path.basename(session._model.docUrl, '.scxml')
|
|
109
|
-
handleScxmlEvent(scxmlName, session.opts.sessionid, event, (err, newSnapshot) => {
|
|
109
|
+
handleScxmlEvent({scxmlName, sessionId: session.opts.sessionid, event, cb: (err, newSnapshot) => {
|
|
110
110
|
if(err) throw err
|
|
111
111
|
console.log('new snapshot for event', JSON.stringify(event,4,4), newSnapshot)
|
|
112
|
-
})
|
|
112
|
+
}})
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
//TODO: use the database as an event queue to support multi-tenancy (horizontal scaling)
|
|
116
|
-
function handleScxmlEvent(scxmlName, sessionId,
|
|
117
|
-
//console.log('handleScxmlEvent, scxmlName, sessionId,
|
|
118
|
-
initModelOrFetchFromCache({scxmlName}, (err, fnModel) => {
|
|
116
|
+
function handleScxmlEvent({scxmlName, sessionId, executionContext, event, cb}){
|
|
117
|
+
//console.log('handleScxmlEvent, scxmlName, sessionId, event', scxmlName, sessionId, event)
|
|
118
|
+
initModelOrFetchFromCache({scxmlName, executionContext}, (err, fnModel) => {
|
|
119
119
|
|
|
120
120
|
if(err) return cb(err)
|
|
121
121
|
|
|
@@ -170,10 +170,10 @@ module.exports = function ({
|
|
|
170
170
|
//save the snapshot to the database
|
|
171
171
|
const newSnapshot = sc1.getSnapshot()
|
|
172
172
|
|
|
173
|
-
cb(null, newSnapshot)
|
|
173
|
+
if(cb) cb(null, newSnapshot)
|
|
174
174
|
})
|
|
175
175
|
|
|
176
|
-
sc1.gen(
|
|
176
|
+
sc1.gen(event)
|
|
177
177
|
})
|
|
178
178
|
})
|
|
179
179
|
}
|
|
@@ -225,7 +225,7 @@ module.exports = function ({
|
|
|
225
225
|
|
|
226
226
|
//read the sessionId
|
|
227
227
|
// TODO: handle error where sessionId does not exist
|
|
228
|
-
handleScxmlEvent(scxmlName, sessionId,
|
|
228
|
+
handleScxmlEvent({scxmlName, sessionId, event, cb: (err, newSnapshot) => {
|
|
229
229
|
|
|
230
230
|
if(err) throw err;
|
|
231
231
|
|
|
@@ -233,7 +233,7 @@ module.exports = function ({
|
|
|
233
233
|
sessionId,
|
|
234
234
|
snapshot : newSnapshot
|
|
235
235
|
})
|
|
236
|
-
})
|
|
236
|
+
}})
|
|
237
237
|
|
|
238
238
|
//rehydrate the session
|
|
239
239
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scion-scxml/express-middleware",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@scion-scxml/core": "^2.6.
|
|
13
|
-
"@scion-scxml/dashboard": "^1.0.
|
|
14
|
-
"@scion-scxml/monitor-middleware": "^1.0.
|
|
15
|
-
"@scion-scxml/scxml": "^4.3.
|
|
12
|
+
"@scion-scxml/core": "^2.6.25",
|
|
13
|
+
"@scion-scxml/dashboard": "^1.0.27",
|
|
14
|
+
"@scion-scxml/monitor-middleware": "^1.0.22",
|
|
15
|
+
"@scion-scxml/scxml": "^4.3.28",
|
|
16
16
|
"express": "^4.17.1",
|
|
17
17
|
"mongodb": "^3.6.8",
|
|
18
18
|
"uuid": "^8.3.2"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "ce920c0df2cbf1e96b0ebafa658c1019c43f81d7"
|
|
21
21
|
}
|