@live-change/framework 0.6.4 → 0.6.7
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.
|
@@ -2,11 +2,13 @@ function getAccessMethod(access) {
|
|
|
2
2
|
if(typeof access == 'function') {
|
|
3
3
|
return access
|
|
4
4
|
} else if(Array.isArray(access)) {
|
|
5
|
-
return (params, {service, client}) => {
|
|
6
|
-
|
|
5
|
+
return (params, { service, client }) => {
|
|
6
|
+
if(client.roles.includes('administrator')) return true
|
|
7
|
+
if(client.roles.includes('admin')) return true
|
|
8
|
+
for(let role of access) if(client.roles.includes(role)) return true
|
|
7
9
|
return false
|
|
8
10
|
}
|
|
9
11
|
} else throw new Error("unknown view access definition "+access)
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
module.exports = getAccessMethod
|
|
14
|
+
module.exports = getAccessMethod
|
|
@@ -39,10 +39,14 @@ class ReaderModel {
|
|
|
39
39
|
})`, { tableName: this.tableName, id, fields }]
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
rangePath(range = {}) {
|
|
43
|
-
if(typeof range != 'object') {
|
|
44
|
-
const
|
|
45
|
-
|
|
42
|
+
rangePath(range = {}, pathRange = null) {
|
|
43
|
+
if(typeof range != 'object' || Array.isArray(range)) {
|
|
44
|
+
const values = Array.isArray(range) ? range : [range]
|
|
45
|
+
const prefix = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')
|
|
46
|
+
if(pathRange) {
|
|
47
|
+
return this.rangePath(utils.prefixRange(pathRange, prefix, prefix))
|
|
48
|
+
}
|
|
49
|
+
return this.rangePath({ gte: prefix+':', lte: prefix+'_\xFF\xFF\xFF\xFF' })
|
|
46
50
|
}
|
|
47
51
|
if(Array.isArray(range)) this.rangePath(range.join(','))
|
|
48
52
|
return ['database', 'tableRange', this.service.databaseName, this.tableName, range]
|
|
@@ -101,7 +105,9 @@ class ReaderModel {
|
|
|
101
105
|
}
|
|
102
106
|
})
|
|
103
107
|
}
|
|
104
|
-
})`, { indexName: this.tableName+'_'+index, tableName: this.tableName, range }
|
|
108
|
+
})`, { indexName: this.tableName+'_'+index, tableName: this.tableName, range },
|
|
109
|
+
this.modelName+'.indexRange'
|
|
110
|
+
]
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
sortedIndexRangePath(index, range = {}, pathRange = null) {
|
|
@@ -152,7 +158,7 @@ class ReaderModel {
|
|
|
152
158
|
let outputState = outputStates.get(oldObj.id)
|
|
153
159
|
if(outputState) {
|
|
154
160
|
outputState.refs --
|
|
155
|
-
|
|
161
|
+
output.debug("INDEX DELETE", oldObj.id, "REFS", outputState.refs)
|
|
156
162
|
if(outputState.refs <= 0) {
|
|
157
163
|
outputState.reader.unobserve(outputState.observer)
|
|
158
164
|
outputStates.delete(oldObj.id)
|
|
@@ -162,7 +168,9 @@ class ReaderModel {
|
|
|
162
168
|
}
|
|
163
169
|
})
|
|
164
170
|
}
|
|
165
|
-
})`, { indexName: this.tableName+'_'+index, tableName: this.tableName, range }
|
|
171
|
+
})`, { indexName: this.tableName+'_'+index, tableName: this.tableName, range },
|
|
172
|
+
this.modelName+'.sortedIndexRange'
|
|
173
|
+
]
|
|
166
174
|
}
|
|
167
175
|
|
|
168
176
|
indexObjectPath(index, range = {}, pathRange = null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/framework",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Live Change Framework - ultimate solution for real time mobile/web apps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/live-change/live-change-framework",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@live-change/dao": "0.
|
|
25
|
-
"@live-change/dao-websocket": "0.4.
|
|
26
|
-
"@live-change/db": "0.5.
|
|
27
|
-
"@live-change/db-store-level": "0.5.
|
|
28
|
-
"@live-change/db-store-lmdb": "0.5.
|
|
24
|
+
"@live-change/dao": "0.5.0",
|
|
25
|
+
"@live-change/dao-websocket": "0.4.13",
|
|
26
|
+
"@live-change/db": "0.5.13",
|
|
27
|
+
"@live-change/db-store-level": "0.5.13",
|
|
28
|
+
"@live-change/db-store-lmdb": "0.5.13",
|
|
29
29
|
"@live-change/sockjs": "^0.4.0-rc.1",
|
|
30
|
-
"@live-change/uid": "0.6.
|
|
30
|
+
"@live-change/uid": "^0.6.7",
|
|
31
31
|
"cookie": "^0.4.1",
|
|
32
32
|
"express": "^4.17.1",
|
|
33
33
|
"os-service": "^2.2.0",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"tape": "^5.3.2",
|
|
36
36
|
"websocket": "^1.0.34"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "a7da9fe3eab0de40fd465b9fc29a0a73047e86ab"
|
|
39
39
|
}
|