@live-change/framework 0.8.33 → 0.8.35
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/runtime/Action.js
CHANGED
|
@@ -21,7 +21,16 @@ class Action {
|
|
|
21
21
|
service: this.service,
|
|
22
22
|
client: command.client,
|
|
23
23
|
command,
|
|
24
|
-
trigger: (
|
|
24
|
+
trigger: (trigger, data) => this.service.trigger({
|
|
25
|
+
causeType: 'action',
|
|
26
|
+
cause: command.id,
|
|
27
|
+
...trigger
|
|
28
|
+
}, data),
|
|
29
|
+
triggerService: (trigger, data, returnArray = false) => this.service.triggerService({
|
|
30
|
+
causeType: 'action',
|
|
31
|
+
cause: command.id,
|
|
32
|
+
...trigger
|
|
33
|
+
}, data, returnArray)
|
|
25
34
|
}, emit)
|
|
26
35
|
|
|
27
36
|
resultPromise = resultPromise.then(async result => {
|
|
@@ -88,11 +88,11 @@ class ReaderModel {
|
|
|
88
88
|
}
|
|
89
89
|
})
|
|
90
90
|
objectStates.set(ind.to, objectState)
|
|
91
|
-
} else if(!oldObj || oldObj.to
|
|
91
|
+
} else if(!oldObj || oldObj.to !== obj.to) {
|
|
92
92
|
objectState.refs ++
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
if(oldObj && oldObj.to && (!obj || obj.to
|
|
95
|
+
if(oldObj && oldObj.to && (!obj || obj.to !== oldObj.to)) {
|
|
96
96
|
let objectState = objectStates.get(oldObj.to)
|
|
97
97
|
if(objectState) {
|
|
98
98
|
objectState.refs --
|
|
@@ -269,7 +269,7 @@ class ReaderModel {
|
|
|
269
269
|
return reject(new Error('timeout'))
|
|
270
270
|
}, timeout)
|
|
271
271
|
const observer = (signal, value) => {
|
|
272
|
-
if(signal
|
|
272
|
+
if(signal !== 'set') {
|
|
273
273
|
observable.unobserve(observer)
|
|
274
274
|
clearTimeout(timeoutId)
|
|
275
275
|
return reject(new Error(`unknown signal ${signal}`))
|
package/lib/runtime/Service.js
CHANGED
|
@@ -93,12 +93,20 @@ class Service {
|
|
|
93
93
|
console.log("Service", this.definition.name, "started")
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
async trigger(
|
|
97
|
-
return this.app.trigger(
|
|
96
|
+
async trigger(trigger, data) {
|
|
97
|
+
return this.app.trigger({
|
|
98
|
+
causeType: 'service',
|
|
99
|
+
cause: this.name,
|
|
100
|
+
...trigger
|
|
101
|
+
}, data)
|
|
98
102
|
}
|
|
99
103
|
|
|
100
|
-
async triggerService(
|
|
101
|
-
return this.app.triggerService(
|
|
104
|
+
async triggerService(trigger, data, returnArray = false) {
|
|
105
|
+
return this.app.triggerService({
|
|
106
|
+
causeType: 'service',
|
|
107
|
+
cause: this.name,
|
|
108
|
+
...trigger
|
|
109
|
+
}, data, returnArray)
|
|
102
110
|
}
|
|
103
111
|
|
|
104
112
|
}
|
|
@@ -28,7 +28,16 @@ class TriggerHandler {
|
|
|
28
28
|
...trig,
|
|
29
29
|
action: this,
|
|
30
30
|
service: this.service,
|
|
31
|
-
trigger: (
|
|
31
|
+
trigger: (trigger, data) => this.service.trigger({
|
|
32
|
+
causeType: 'trigger',
|
|
33
|
+
cause: trig.id,
|
|
34
|
+
...trigger
|
|
35
|
+
}, data),
|
|
36
|
+
triggerService: (trigger, data, returnArray = false) => this.service.triggerService({
|
|
37
|
+
causeType: 'trigger',
|
|
38
|
+
cause: trig.id,
|
|
39
|
+
...trigger
|
|
40
|
+
}, data, returnArray)
|
|
32
41
|
}, emit)
|
|
33
42
|
|
|
34
43
|
resultPromise = resultPromise.then(async result => {
|
package/lib/updaters/database.js
CHANGED
|
@@ -62,18 +62,24 @@ async function update(changes, service, app, force) {
|
|
|
62
62
|
if(!table) throw new Error("only function indexes are possible without table")
|
|
63
63
|
if(index.multi) {
|
|
64
64
|
if(Array.isArray(index.property)) throw new Error("multi indexes on multiple properties are not supported!")
|
|
65
|
-
const
|
|
66
|
-
|
|
65
|
+
const properties = (Array.isArray(index.property) ? index.property : [index.property]).map(p => p.split('.'))
|
|
66
|
+
const func = async function(input, output, { table, properties }) {
|
|
67
|
+
const value = (obj, property) => {
|
|
67
68
|
let at = obj
|
|
68
69
|
for(const p of property) at = at && at[p]
|
|
69
70
|
if(at === undefined) return []
|
|
70
71
|
if(Array.isArray(at)) return at.map(v => JSON.stringify(v))
|
|
71
72
|
return [at]
|
|
72
73
|
}
|
|
74
|
+
const keys = (obj, id) => {
|
|
75
|
+
const values = value(obj, properties[id])
|
|
76
|
+
if(id === properties.length - 1) return values
|
|
77
|
+
return values.flatMap(v => keys(obj, id + 1).map(k => v + ':' + k))
|
|
78
|
+
}
|
|
73
79
|
await input.table(table).onChange((obj, oldObj) => {
|
|
74
80
|
if(obj && oldObj) {
|
|
75
|
-
let pointers = obj && new Set(
|
|
76
|
-
let oldPointers = oldObj && new Set(
|
|
81
|
+
let pointers = obj && new Set(keys(obj))
|
|
82
|
+
let oldPointers = oldObj && new Set(keys(oldObj))
|
|
77
83
|
for(let pointer of pointers) {
|
|
78
84
|
if(!!oldPointers.has(pointer)) output.change({ id: pointer+'_'+obj.id, to: obj.id }, null)
|
|
79
85
|
}
|
|
@@ -81,16 +87,16 @@ async function update(changes, service, app, force) {
|
|
|
81
87
|
if(!!pointers.has(pointer)) output.change(null, { id: pointer+'_'+obj.id, to: obj.id })
|
|
82
88
|
}
|
|
83
89
|
} else if(obj) {
|
|
84
|
-
|
|
90
|
+
keys(obj).forEach(k => output.change({ id: k+'_'+obj.id, to: obj.id }, null))
|
|
85
91
|
} else if(oldObj) {
|
|
86
|
-
|
|
92
|
+
keys(oldObj).forEach(k => output.change(null, { id: k+'_'+oldObj.id, to: oldObj.id }))
|
|
87
93
|
}
|
|
88
94
|
})
|
|
89
95
|
}
|
|
90
96
|
const functionCode = `(${func})`
|
|
91
97
|
;(globalThis.compiledFunctions = globalThis.compiledFunctions || {})[functionCode] = func
|
|
92
98
|
await dao.requestWithSettings(indexRequestSettings, ['database', 'createIndex'], database, indexName,
|
|
93
|
-
functionCode, {
|
|
99
|
+
functionCode, { properties, table }, index.storage ?? {})
|
|
94
100
|
} else {
|
|
95
101
|
if(!table) throw new Error("only function indexes are possible without table")
|
|
96
102
|
const properties = (Array.isArray(index.property) ? index.property : [index.property]).map(p => p.split('.'))
|
|
@@ -42,12 +42,12 @@ class EventsReader {
|
|
|
42
42
|
this.movePositionForward()
|
|
43
43
|
}).catch(error => {
|
|
44
44
|
console.error("EVENT PROCESSING ERROR", error, "AT EVENT", event.id,
|
|
45
|
-
" -> EVENT PROCESSING STOPPED AT", this.position)
|
|
45
|
+
" -> EVENT PROCESSING STOPPED AT", this.position,' EVENT:', JSON.stringify(event, null, 2))
|
|
46
46
|
if(this.eventsObservable) this.eventsObservable.unobserve(this)
|
|
47
47
|
})
|
|
48
48
|
}
|
|
49
49
|
this.readCount--
|
|
50
|
-
if(this.readCount
|
|
50
|
+
if(this.readCount === 0) this.readMore()
|
|
51
51
|
}
|
|
52
52
|
movePositionForward() {
|
|
53
53
|
let i
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/framework",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.35",
|
|
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.35",
|
|
26
|
+
"@live-change/uid": "^0.8.35"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "90fbb746dc7270895daf17b437ca48c0b0a01c01"
|
|
29
29
|
}
|