teamplay 0.3.12 → 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.
Files changed (2) hide show
  1. package/orm/Signal.js +27 -1
  2. package/package.json +8 -8
package/orm/Signal.js CHANGED
@@ -55,13 +55,29 @@ 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
- return _get([QUERIES, this[HASH], 'ids'])
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 []
@@ -95,6 +111,11 @@ export default class Signal extends Function {
95
111
  * [Symbol.iterator] () {
96
112
  if (this[IS_QUERY]) {
97
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
+ }
98
119
  for (const id of ids) yield getSignal(getRoot(this), [this[SEGMENTS][0], id])
99
120
  } else {
100
121
  const items = _get(this[SEGMENTS])
@@ -108,6 +129,11 @@ export default class Signal extends Function {
108
129
  const collection = this[SEGMENTS][0]
109
130
  const hash = this[HASH]
110
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
+ }
111
137
  return ids.map(
112
138
  id => getSignal(getRoot(this), [collection, id])
113
139
  )[method](...args)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teamplay",
3
- "version": "0.3.12",
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.12",
27
- "@teamplay/cache": "^0.3.12",
28
- "@teamplay/channel": "^0.3.12",
29
- "@teamplay/debug": "^0.3.12",
30
- "@teamplay/schema": "^0.3.12",
31
- "@teamplay/utils": "^0.3.12",
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": "6208e7a077521b4f77fde1c1c4fd06bc90285322"
66
+ "gitHead": "c08d644eb32ef66112285de31a63201771a0eb97"
67
67
  }