teamplay 0.3.11 → 0.3.13
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/orm/Signal.js +33 -2
- package/package.json +8 -8
package/orm/Signal.js
CHANGED
|
@@ -55,19 +55,40 @@ export default class Signal extends Function {
|
|
|
55
55
|
|
|
56
56
|
get () {
|
|
57
57
|
if (arguments.length > 0) throw Error('Signal.get() does not accept any arguments')
|
|
58
|
+
if (this[SEGMENTS].length === 3 && this[SEGMENTS][0] === QUERIES && this[SEGMENTS][2] === 'ids') {
|
|
59
|
+
// TODO: This should never happen, but in reality it happens sometimes
|
|
60
|
+
// Patch getting query ids because sometimes for some reason we are not getting them
|
|
61
|
+
const ids = this[GET](_get)
|
|
62
|
+
if (!Array.isArray(ids)) {
|
|
63
|
+
console.warn('Signal.get() on Query didn\'t find ids', this[SEGMENTS])
|
|
64
|
+
return []
|
|
65
|
+
}
|
|
66
|
+
return ids
|
|
67
|
+
}
|
|
58
68
|
return this[GET](_get)
|
|
59
69
|
}
|
|
60
70
|
|
|
61
71
|
getIds () {
|
|
62
72
|
if (arguments.length > 0) throw Error('Signal.getIds() does not accept any arguments')
|
|
63
73
|
if (this[IS_QUERY]) {
|
|
64
|
-
|
|
74
|
+
const ids = _get([QUERIES, this[HASH], 'ids'])
|
|
75
|
+
if (!Array.isArray(ids)) {
|
|
76
|
+
// TODO: This should never happen, but in reality it happens sometimes
|
|
77
|
+
console.warn('Signal.getIds() on Query didn\'t find ids', [QUERIES, this[HASH], 'ids'])
|
|
78
|
+
return []
|
|
79
|
+
}
|
|
80
|
+
return ids
|
|
65
81
|
} else if (this[IS_AGGREGATION]) {
|
|
66
82
|
const docs = _get(this[SEGMENTS])
|
|
67
83
|
if (!Array.isArray(docs)) return []
|
|
68
84
|
return docs.map(doc => doc._id || doc.id)
|
|
69
85
|
} else {
|
|
70
|
-
|
|
86
|
+
// TODO: this should throw an error in the future
|
|
87
|
+
console.error(
|
|
88
|
+
'Signal.getIds() can only be used on query signals or aggregation signals. ' +
|
|
89
|
+
'Received a regular signal: ' + JSON.stringify(this[SEGMENTS])
|
|
90
|
+
)
|
|
91
|
+
return []
|
|
71
92
|
}
|
|
72
93
|
}
|
|
73
94
|
|
|
@@ -90,6 +111,11 @@ export default class Signal extends Function {
|
|
|
90
111
|
* [Symbol.iterator] () {
|
|
91
112
|
if (this[IS_QUERY]) {
|
|
92
113
|
const ids = _get([QUERIES, this[HASH], 'ids'])
|
|
114
|
+
if (!Array.isArray(ids)) {
|
|
115
|
+
// TODO: This should never happen, but in reality it happens sometimes
|
|
116
|
+
console.warn('Signal iterator on Query didn\'t find ids', [QUERIES, this[HASH], 'ids'])
|
|
117
|
+
return
|
|
118
|
+
}
|
|
93
119
|
for (const id of ids) yield getSignal(getRoot(this), [this[SEGMENTS][0], id])
|
|
94
120
|
} else {
|
|
95
121
|
const items = _get(this[SEGMENTS])
|
|
@@ -103,6 +129,11 @@ export default class Signal extends Function {
|
|
|
103
129
|
const collection = this[SEGMENTS][0]
|
|
104
130
|
const hash = this[HASH]
|
|
105
131
|
const ids = _get([QUERIES, hash, 'ids'])
|
|
132
|
+
if (!Array.isArray(ids)) {
|
|
133
|
+
// TODO: This should never happen, but in reality it happens sometimes
|
|
134
|
+
console.warn('Signal array method on Query didn\'t find ids', [QUERIES, hash, 'ids'], method)
|
|
135
|
+
return nonArrayReturnValue
|
|
136
|
+
}
|
|
106
137
|
return ids.map(
|
|
107
138
|
id => getSignal(getRoot(this), [collection, id])
|
|
108
139
|
)[method](...args)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teamplay",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "Full-stack signals ORM with multiplayer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@nx-js/observer-util": "^4.1.3",
|
|
26
|
-
"@teamplay/backend": "^0.3.
|
|
27
|
-
"@teamplay/cache": "^0.3.
|
|
28
|
-
"@teamplay/channel": "^0.3.
|
|
29
|
-
"@teamplay/debug": "^0.3.
|
|
30
|
-
"@teamplay/schema": "^0.3.
|
|
31
|
-
"@teamplay/utils": "^0.3.
|
|
26
|
+
"@teamplay/backend": "^0.3.13",
|
|
27
|
+
"@teamplay/cache": "^0.3.13",
|
|
28
|
+
"@teamplay/channel": "^0.3.13",
|
|
29
|
+
"@teamplay/debug": "^0.3.13",
|
|
30
|
+
"@teamplay/schema": "^0.3.13",
|
|
31
|
+
"@teamplay/utils": "^0.3.13",
|
|
32
32
|
"diff-match-patch": "^1.0.5",
|
|
33
33
|
"events": "^3.3.0",
|
|
34
34
|
"json0-ot-diff": "^1.1.2",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"license": "MIT",
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "c08d644eb32ef66112285de31a63201771a0eb97"
|
|
67
67
|
}
|