@live-change/framework 0.8.15 → 0.8.16
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/lib/App.js +17 -10
- package/lib/definition/ModelDefinition.js +2 -1
- package/package.json +4 -4
package/lib/App.js
CHANGED
|
@@ -142,16 +142,22 @@ class App {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
async getOldServiceDefinition( serviceName ) {
|
|
146
|
+
let oldServiceJson = await this.dao.get(['database', 'tableObject', this.databaseName, 'services', serviceName])
|
|
147
|
+
if(!oldServiceJson) {
|
|
148
|
+
oldServiceJson = this.createServiceDefinition({name: serviceName}).toJSON()
|
|
149
|
+
}
|
|
150
|
+
return oldServiceJson
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
async updateService( service, { updaters, force } = {}) {
|
|
146
154
|
const profileOp = await this.profileLog.begin({
|
|
147
155
|
operation: "updateService", serviceName: service.name, force
|
|
148
156
|
})
|
|
149
157
|
|
|
150
158
|
this.dao.request(['database', 'createTable'], this.databaseName, 'services').catch(e => 'ok')
|
|
151
|
-
let oldServiceJson = await this.
|
|
152
|
-
|
|
153
|
-
oldServiceJson = this.createServiceDefinition({name: service.name}).toJSON()
|
|
154
|
-
}
|
|
159
|
+
let oldServiceJson = await this.getOldServiceDefinition(service.name)
|
|
160
|
+
|
|
155
161
|
let changes = this.computeChanges(oldServiceJson, service)
|
|
156
162
|
//console.log("OLD SERVICE", JSON.stringify(oldServiceJson, null, ' '))
|
|
157
163
|
//console.log("NEW SERVICE", JSON.stringify(service.toJSON(), null, ' '))
|
|
@@ -436,13 +442,13 @@ class App {
|
|
|
436
442
|
}
|
|
437
443
|
|
|
438
444
|
async waitForEvents(reportId, events, timeout) {
|
|
439
|
-
if(events.length
|
|
445
|
+
if(events.length === 0) {
|
|
440
446
|
console.log("no events, no need to wait", reportId)
|
|
441
447
|
return
|
|
442
448
|
}
|
|
443
449
|
const [action, id] = reportId.split('_')
|
|
444
|
-
const triggerId = action
|
|
445
|
-
const commandId = action
|
|
450
|
+
const triggerId = action === 'trigger' ? id : undefined
|
|
451
|
+
const commandId = action === 'command' ? id : undefined
|
|
446
452
|
const profileOp = await this.profileLog.begin({
|
|
447
453
|
operation: "waitForEvents", action: action, commandId, triggerId, reportId, events, timeout
|
|
448
454
|
})
|
|
@@ -451,7 +457,7 @@ class App {
|
|
|
451
457
|
let finishedEvents = []
|
|
452
458
|
const handleError = (message) => {
|
|
453
459
|
console.error(`waitForEvents error: `, message)
|
|
454
|
-
const eventsNotDone = events.filter(event => finished.find(e => e.id
|
|
460
|
+
const eventsNotDone = events.filter(event => finished.find(e => e.id === event.id))
|
|
455
461
|
if(eventsNotDone.length > 0) {
|
|
456
462
|
console.error(" pending events:")
|
|
457
463
|
for(const event of eventsNotDone) {
|
|
@@ -465,7 +471,7 @@ class App {
|
|
|
465
471
|
['database', 'tableObject', this.databaseName, 'eventReports', reportId]
|
|
466
472
|
)
|
|
467
473
|
const reportsObserver = (signal, data) => {
|
|
468
|
-
if(signal
|
|
474
|
+
if(signal !== 'set') {
|
|
469
475
|
handleError(`unknown signal ${signal} with data: ${data}`)
|
|
470
476
|
}
|
|
471
477
|
if(data == null) return /// wait for real data
|
|
@@ -473,7 +479,7 @@ class App {
|
|
|
473
479
|
finishedEvents = data.finished
|
|
474
480
|
if(finishedEvents.length >= events.length) {
|
|
475
481
|
const eventsNotDone = events.filter(event => data.finished.find(e => e.id == event.id))
|
|
476
|
-
if(eventsNotDone.length
|
|
482
|
+
if(eventsNotDone.length !== 0) {
|
|
477
483
|
const eventsDone = events.filter(event => !data.finished.find(e => e.id == event.id))
|
|
478
484
|
console.error("waitForEvents - finished events does not match!")
|
|
479
485
|
console.error(" finished events:")
|
|
@@ -498,6 +504,7 @@ class App {
|
|
|
498
504
|
setTimeout(() => {
|
|
499
505
|
if(done) return
|
|
500
506
|
observable.unobserve(reportsObserver)
|
|
507
|
+
console.error("events timeout", reportId)
|
|
501
508
|
handleError('timeout')
|
|
502
509
|
}, timeout)
|
|
503
510
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/framework",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.16",
|
|
4
4
|
"description": "Live Change Framework - ultimate solution for real time mobile/web apps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/live-change/live-change-stack",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@live-change/dao": "^0.8.
|
|
26
|
-
"@live-change/uid": "^0.8.
|
|
25
|
+
"@live-change/dao": "^0.8.16",
|
|
26
|
+
"@live-change/uid": "^0.8.16"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "b8ac84cbe1a8c435c7b5003dfc64ddc41a4e15a6"
|
|
29
29
|
}
|