@live-change/framework 0.9.166 → 0.9.169
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.
|
@@ -10,68 +10,79 @@ import defaultValidators from '../utils/validators.js'
|
|
|
10
10
|
import { crudChanges, definitionToJSON } from "../utils.js"
|
|
11
11
|
import QueryDefinition, { QueryDefinitionSpecification } from "./QueryDefinition.js"
|
|
12
12
|
|
|
13
|
+
const PROXY_SKIP_SYMBOLS = new Set([
|
|
14
|
+
Symbol.toPrimitive,
|
|
15
|
+
Symbol.iterator,
|
|
16
|
+
Symbol.asyncIterator,
|
|
17
|
+
Symbol.toStringTag,
|
|
18
|
+
Symbol.hasInstance,
|
|
19
|
+
Symbol.match,
|
|
20
|
+
Symbol.replace,
|
|
21
|
+
Symbol.search,
|
|
22
|
+
Symbol.split,
|
|
23
|
+
Symbol.species
|
|
24
|
+
])
|
|
25
|
+
|
|
26
|
+
function proxyGet(definition, kind, name, target, prop, receiver) {
|
|
27
|
+
const runtime = definition._runtime
|
|
28
|
+
const objectRuntime = runtime?.[kind]?.[name]
|
|
29
|
+
const objectName = target.name ?? target.constructor?.name ?? '<anonymous>'
|
|
30
|
+
|
|
31
|
+
// For well-known symbols we don't report missing properties.
|
|
32
|
+
// Prefer the runtime object if it defines the symbol.
|
|
33
|
+
if (typeof prop === 'symbol' && PROXY_SKIP_SYMBOLS.has(prop)) {
|
|
34
|
+
if (objectRuntime && Reflect.has(objectRuntime, prop)) {
|
|
35
|
+
return Reflect.get(objectRuntime, prop, receiver)
|
|
36
|
+
}
|
|
37
|
+
return Reflect.get(target, prop, receiver)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// If the runtime object defines this property, it takes priority.
|
|
41
|
+
if (objectRuntime && Reflect.has(objectRuntime, prop)) {
|
|
42
|
+
return Reflect.get(objectRuntime, prop, receiver)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const existsInTarget = Reflect.has(target, prop)
|
|
46
|
+
const existsInRuntime = Boolean(objectRuntime && Reflect.has(objectRuntime, prop))
|
|
47
|
+
|
|
48
|
+
// Report only when the property exists neither in target nor in runtime.
|
|
49
|
+
if (!existsInTarget && !existsInRuntime) {
|
|
50
|
+
const propLabel = typeof prop === 'symbol' ? prop.toString() : String(prop)
|
|
51
|
+
console.warn(kind, objectName, 'runtime used before created; property', propLabel, 'not found')
|
|
52
|
+
console.trace()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return Reflect.get(target, prop, receiver)
|
|
56
|
+
}
|
|
57
|
+
|
|
13
58
|
function createModelProxy(definition, model) {
|
|
14
59
|
return new Proxy(model, {
|
|
15
60
|
get(target, prop, receiver) {
|
|
16
|
-
|
|
17
|
-
if(runtime) {
|
|
18
|
-
const modelRuntime = runtime.models[model.name]
|
|
19
|
-
if(modelRuntime[prop]) {
|
|
20
|
-
return Reflect.get(modelRuntime, prop, receiver)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const resutlt = Reflect.get(target, prop, receiver)
|
|
24
|
-
if(!resutlt) {
|
|
25
|
-
console.warn("Model", model.name, "runtime used before created; property", prop, "not found")
|
|
26
|
-
console.trace()
|
|
27
|
-
}
|
|
28
|
-
return resutlt
|
|
61
|
+
return proxyGet(definition, 'models', target.name, target, prop, receiver)
|
|
29
62
|
}
|
|
30
63
|
})
|
|
31
64
|
}
|
|
32
65
|
|
|
33
66
|
function createForeignModelProxy(definition, model) {
|
|
34
|
-
let fk = model.serviceName + "_" + model.name
|
|
35
67
|
return new Proxy(model, {
|
|
36
68
|
get(target, prop, receiver) {
|
|
37
|
-
|
|
38
|
-
if(runtime) {
|
|
39
|
-
const modelRuntime = runtime.foreignModels[fk]
|
|
40
|
-
if(modelRuntime[prop]) {
|
|
41
|
-
return Reflect.get(modelRuntime, prop, receiver)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return Reflect.get(target, prop, receiver)
|
|
69
|
+
return proxyGet(definition, 'foreignModels', model.serviceName + "_" + model.name, target, prop, receiver)
|
|
45
70
|
}
|
|
46
71
|
})
|
|
47
72
|
}
|
|
48
73
|
|
|
49
|
-
function createIndexProxy(definition,
|
|
50
|
-
return new Proxy(
|
|
74
|
+
function createIndexProxy(definition, index) {
|
|
75
|
+
return new Proxy(index, {
|
|
51
76
|
get(target, prop, receiver) {
|
|
52
|
-
|
|
53
|
-
if(runtime) {
|
|
54
|
-
const indexRuntime = runtime.indexes[model.name]
|
|
55
|
-
if(indexRuntime[prop]) {
|
|
56
|
-
return Reflect.get(indexRuntime, prop, receiver)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return Reflect.get(target, prop, receiver)
|
|
77
|
+
return proxyGet(definition, 'indexes', index.name, target, prop, receiver)
|
|
60
78
|
}
|
|
61
79
|
})
|
|
62
80
|
}
|
|
63
81
|
|
|
64
|
-
function createForeignIndexProxy(definition,
|
|
65
|
-
return new Proxy(
|
|
82
|
+
function createForeignIndexProxy(definition, index) {
|
|
83
|
+
return new Proxy(index, {
|
|
66
84
|
get(target, prop, receiver) {
|
|
67
|
-
|
|
68
|
-
if(runtime) {
|
|
69
|
-
const indexRuntime = runtime.foreignIndexes[model.name]
|
|
70
|
-
if(indexRuntime[prop]) {
|
|
71
|
-
return Reflect.get(indexRuntime, prop, receiver)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return Reflect.get(target, prop, receiver)
|
|
85
|
+
return proxyGet(definition, 'foreignIndexes', index.name, target, prop, receiver)
|
|
75
86
|
}
|
|
76
87
|
})
|
|
77
88
|
}
|
|
@@ -79,20 +90,12 @@ function createForeignIndexProxy(definition, model) {
|
|
|
79
90
|
function createQueryProxy(definition, query) {
|
|
80
91
|
return new Proxy(query, {
|
|
81
92
|
get(target, prop, receiver) {
|
|
82
|
-
|
|
83
|
-
if(runtime) {
|
|
84
|
-
const queryRuntime = runtime.queries[query.name]
|
|
85
|
-
if(queryRuntime[prop]) {
|
|
86
|
-
return Reflect.get(queryRuntime, prop, receiver)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return Reflect.get(target, prop, receiver)
|
|
93
|
+
return proxyGet(definition, 'queries', query.name, target, prop, receiver)
|
|
90
94
|
}
|
|
91
95
|
})
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
|
|
95
|
-
|
|
96
99
|
export interface ServiceDefinitionSpecification {
|
|
97
100
|
|
|
98
101
|
}
|
package/lib/updaters/database.js
CHANGED
|
@@ -160,7 +160,7 @@ async function update(changes, service, app, force) {
|
|
|
160
160
|
to: obj.id }, null))
|
|
161
161
|
} else if(oldObj) {
|
|
162
162
|
keys(oldObj).forEach(k => output.change(null, {
|
|
163
|
-
id: k+'_'+(hash ? sha1(
|
|
163
|
+
id: k+'_'+(hash ? sha1(oldObj.id, 'base64') : oldObj.id),
|
|
164
164
|
to: oldObj.id }))
|
|
165
165
|
}
|
|
166
166
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/framework",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.169",
|
|
4
4
|
"description": "Live Change Framework - ultimate solution for real time mobile/web apps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/live-change/live-change-stack",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@live-change/dao": "^0.9.
|
|
26
|
-
"@live-change/uid": "^0.9.
|
|
25
|
+
"@live-change/dao": "^0.9.169",
|
|
26
|
+
"@live-change/uid": "^0.9.169",
|
|
27
27
|
"typedoc": "0.28.3",
|
|
28
28
|
"typedoc-plugin-markdown": "^4.6.3",
|
|
29
29
|
"typedoc-plugin-rename-defaults": "^0.7.3"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "6801ab3c35069e825eaef646ede6c6cfaf566bcf"
|
|
32
32
|
}
|