teamplay 0.1.10 → 0.1.11
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/index.js +1 -1
- package/orm/Signal.js +8 -0
- package/orm/connection.js +5 -0
- package/package.json +8 -8
- package/server.js +3 -1
package/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export const $ = _getRootSignal({ rootId: GLOBAL_ROOT_ID, rootFunction: universa
|
|
|
15
15
|
export default $
|
|
16
16
|
export { default as sub } from './react/universalSub.js'
|
|
17
17
|
export { default as observer } from './react/observer.js'
|
|
18
|
-
export { connection, setConnection, getConnection, fetchOnly, setFetchOnly } from './orm/connection.js'
|
|
18
|
+
export { connection, setConnection, getConnection, fetchOnly, setFetchOnly, publicOnly, setPublicOnly } from './orm/connection.js'
|
|
19
19
|
export { GUID_PATTERN, hasMany, hasOne, hasManyFlags, belongsTo, pickFormFields } from '@teamplay/schema'
|
|
20
20
|
export { aggregation, aggregationHeader } from '@teamplay/utils/aggregation'
|
|
21
21
|
|
package/orm/Signal.js
CHANGED
|
@@ -16,6 +16,7 @@ import { get as _get, set as _set, del as _del, setPublicDoc as _setPublicDoc }
|
|
|
16
16
|
import getSignal, { rawSignal } from './getSignal.js'
|
|
17
17
|
import { IS_QUERY, HASH, QUERIES } from './Query.js'
|
|
18
18
|
import { ROOT_FUNCTION, getRoot } from './Root.js'
|
|
19
|
+
import { publicOnly } from './connection.js'
|
|
19
20
|
|
|
20
21
|
export const SEGMENTS = Symbol('path segments targeting the particular node in the data tree')
|
|
21
22
|
|
|
@@ -82,6 +83,7 @@ export default class Signal extends Function {
|
|
|
82
83
|
if (isPublicCollection(this[SEGMENTS][0])) {
|
|
83
84
|
await _setPublicDoc(this[SEGMENTS], value)
|
|
84
85
|
} else {
|
|
86
|
+
if (publicOnly) throw Error(ERRORS.publicOnly)
|
|
85
87
|
_set(this[SEGMENTS], value)
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -98,6 +100,7 @@ export default class Signal extends Function {
|
|
|
98
100
|
// TODO: implement a json0 operation for pop
|
|
99
101
|
async pop () {
|
|
100
102
|
if (arguments.length > 0) throw Error('Signal.pop() does not accept any arguments')
|
|
103
|
+
if (this[SEGMENTS].length < 2) throw Error('Can\'t pop from a collection or root signal')
|
|
101
104
|
if (this[IS_QUERY]) throw Error('Signal.pop() can\'t be used on a query signal')
|
|
102
105
|
const array = this.get()
|
|
103
106
|
if (!Array.isArray(array) || array.length === 0) return
|
|
@@ -144,6 +147,7 @@ export default class Signal extends Function {
|
|
|
144
147
|
if (this[SEGMENTS].length === 1) throw Error('Can\'t delete the whole collection')
|
|
145
148
|
await _setPublicDoc(this[SEGMENTS], undefined, true)
|
|
146
149
|
} else {
|
|
150
|
+
if (publicOnly) throw Error(ERRORS.publicOnly)
|
|
147
151
|
_del(this[SEGMENTS])
|
|
148
152
|
}
|
|
149
153
|
}
|
|
@@ -241,5 +245,9 @@ const ERRORS = {
|
|
|
241
245
|
noRootFunction: `
|
|
242
246
|
Root signal does not have a root function set.
|
|
243
247
|
You must use getRootSignal({ rootId, rootFunction }) to create a root signal.
|
|
248
|
+
`,
|
|
249
|
+
publicOnly: `
|
|
250
|
+
Can't modify private collections data when 'publicOnly' is enabled.
|
|
251
|
+
On the server you can only work with public collections.
|
|
244
252
|
`
|
|
245
253
|
}
|
package/orm/connection.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export let connection
|
|
2
2
|
export let fetchOnly
|
|
3
|
+
export let publicOnly
|
|
3
4
|
|
|
4
5
|
export function setConnection (_connection) {
|
|
5
6
|
connection = _connection
|
|
@@ -14,6 +15,10 @@ export function setFetchOnly (_fetchOnly) {
|
|
|
14
15
|
fetchOnly = _fetchOnly
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
export function setPublicOnly (_publicOnly) {
|
|
19
|
+
publicOnly = _publicOnly
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
const ERRORS = {
|
|
18
23
|
notSet: `
|
|
19
24
|
Connection is not set.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teamplay",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
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.1.
|
|
27
|
-
"@teamplay/cache": "^0.1.
|
|
28
|
-
"@teamplay/channel": "^0.1.
|
|
29
|
-
"@teamplay/debug": "^0.1.
|
|
30
|
-
"@teamplay/schema": "^0.1.
|
|
31
|
-
"@teamplay/utils": "^0.1.
|
|
26
|
+
"@teamplay/backend": "^0.1.11",
|
|
27
|
+
"@teamplay/cache": "^0.1.11",
|
|
28
|
+
"@teamplay/channel": "^0.1.11",
|
|
29
|
+
"@teamplay/debug": "^0.1.11",
|
|
30
|
+
"@teamplay/schema": "^0.1.11",
|
|
31
|
+
"@teamplay/utils": "^0.1.11",
|
|
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": "1fbdde069e50c6cee18d8bb71c43ed5b06367cac"
|
|
67
67
|
}
|
package/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import createChannel from '@teamplay/channel/server'
|
|
2
|
-
import { connection, setConnection, setFetchOnly } from './orm/connection.js'
|
|
2
|
+
import { connection, setConnection, setFetchOnly, setPublicOnly } from './orm/connection.js'
|
|
3
3
|
|
|
4
4
|
export { default as ShareDB } from 'sharedb'
|
|
5
5
|
export {
|
|
@@ -9,11 +9,13 @@ export {
|
|
|
9
9
|
|
|
10
10
|
export function initConnection (backend, {
|
|
11
11
|
fetchOnly = true,
|
|
12
|
+
publicOnly = true,
|
|
12
13
|
...options
|
|
13
14
|
} = {}) {
|
|
14
15
|
if (!backend) throw Error('backend is required')
|
|
15
16
|
if (connection) throw Error('Connection already exists')
|
|
16
17
|
setConnection(backend.connect())
|
|
17
18
|
setFetchOnly(fetchOnly)
|
|
19
|
+
setPublicOnly(publicOnly)
|
|
18
20
|
return createChannel(backend, options)
|
|
19
21
|
}
|