@live-change/user-service 0.9.194 → 0.9.195
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/contactOrUserItem.js +7 -7
- package/contactOrUserProperty.js +3 -3
- package/index.js +3 -3
- package/package.json +4 -4
- package/sessionOrUserItem.js +7 -7
- package/sessionOrUserProperty.js +3 -3
- package/userItem.js +5 -5
- package/userProperty.js +2 -2
package/contactOrUserItem.js
CHANGED
|
@@ -166,7 +166,7 @@ definition.processor(function(service, app) {
|
|
|
166
166
|
async execute(properties, { client, service }, emit) {
|
|
167
167
|
const id = properties[modelPropertyName] || app.generateUid()
|
|
168
168
|
const entity = await modelRuntime().get(id)
|
|
169
|
-
if(entity) throw
|
|
169
|
+
if(entity) throw app.logicError("exists")
|
|
170
170
|
const identifiers = {
|
|
171
171
|
ownerType: 'user_User',
|
|
172
172
|
owner: client.user,
|
|
@@ -200,10 +200,10 @@ definition.processor(function(service, app) {
|
|
|
200
200
|
waitForEvents: true,
|
|
201
201
|
async execute(properties, { client, service }, emit) {
|
|
202
202
|
const entity = await modelRuntime().get(properties[modelPropertyName])
|
|
203
|
-
if(!entity) throw
|
|
203
|
+
if(!entity) throw app.logicError("not_found")
|
|
204
204
|
if(entity.ownerType === 'user_User') {
|
|
205
|
-
if(entity.owner !== client.user) throw
|
|
206
|
-
} else throw
|
|
205
|
+
if(entity.owner !== client.user) throw app.logicError("not_authorized")
|
|
206
|
+
} else throw app.logicError("not_authorized")
|
|
207
207
|
let updateObject = {}
|
|
208
208
|
for(const propertyName of writeableProperties) {
|
|
209
209
|
if(properties.hasOwnProperty(propertyName)) {
|
|
@@ -247,10 +247,10 @@ definition.processor(function(service, app) {
|
|
|
247
247
|
waitForEvents: true,
|
|
248
248
|
async execute(properties, { client, service }, emit) {
|
|
249
249
|
const entity = await modelRuntime().get(properties[modelPropertyName])
|
|
250
|
-
if(!entity) throw
|
|
250
|
+
if(!entity) throw app.logicError("not_found")
|
|
251
251
|
if(entity.ownerType === 'user_User') {
|
|
252
|
-
if(entity.owner !== client.user) throw
|
|
253
|
-
} else throw
|
|
252
|
+
if(entity.owner !== client.user) throw app.logicError("not_authorized")
|
|
253
|
+
} else throw app.logicError("not_authorized")
|
|
254
254
|
const identifiers = client.user ? {
|
|
255
255
|
ownerType: 'user_User',
|
|
256
256
|
owner: client.user,
|
package/contactOrUserProperty.js
CHANGED
|
@@ -232,7 +232,7 @@ definition.processor(function(service, app) {
|
|
|
232
232
|
for(const extension of extendedWith) owner.push(properties[extension+'Type'], properties[extension])
|
|
233
233
|
const id = owner.map(p => JSON.stringify(p)).join(':')
|
|
234
234
|
const entity = await modelRuntime().get(id)
|
|
235
|
-
if(entity) throw
|
|
235
|
+
if(entity) throw app.logicError("alerady_exists")
|
|
236
236
|
let newObject = {}
|
|
237
237
|
for(const propertyName of writeableProperties) {
|
|
238
238
|
if(properties.hasOwnProperty(propertyName)) {
|
|
@@ -281,7 +281,7 @@ definition.processor(function(service, app) {
|
|
|
281
281
|
for(const extension of extendedWith) owner.push(properties[extension+'Type'], properties[extension])
|
|
282
282
|
const id = owner.map(p => JSON.stringify(p)).join(':')
|
|
283
283
|
const entity = await modelRuntime().get(id)
|
|
284
|
-
if(!entity) throw
|
|
284
|
+
if(!entity) throw app.logicError("not_found")
|
|
285
285
|
let updateObject = {}
|
|
286
286
|
for(const propertyName of writeableProperties) {
|
|
287
287
|
if(properties.hasOwnProperty(propertyName)) {
|
|
@@ -327,7 +327,7 @@ definition.processor(function(service, app) {
|
|
|
327
327
|
for(const extension of extendedWith) owner.push(properties[extension+'Type'], properties[extension])
|
|
328
328
|
const id = owner.map(p => JSON.stringify(p)).join(':')
|
|
329
329
|
const entity = await modelRuntime().get(id)
|
|
330
|
-
if (!entity) throw
|
|
330
|
+
if (!entity) throw app.logicError("not_found")
|
|
331
331
|
const identifiers = {
|
|
332
332
|
contactOrUserType: 'user_User',
|
|
333
333
|
contactOrUser: client.user,
|
package/index.js
CHANGED
|
@@ -48,7 +48,7 @@ definition.trigger({
|
|
|
48
48
|
waitForEvents: true,
|
|
49
49
|
async execute({ user, session }, { client, service }, emit) {
|
|
50
50
|
const userData = await User.get(user)
|
|
51
|
-
if(!userData) throw
|
|
51
|
+
if(!userData) throw app.logicError("userNotFound")
|
|
52
52
|
await service.trigger({ type: 'signedIn' }, {
|
|
53
53
|
session, user
|
|
54
54
|
})
|
|
@@ -63,7 +63,7 @@ definition.action({
|
|
|
63
63
|
name: 'signOut',
|
|
64
64
|
waitForEvents: true,
|
|
65
65
|
async execute({ }, { client, service }, emit) {
|
|
66
|
-
if(!client.user) throw "notSignedIn"
|
|
66
|
+
if(!client.user) throw app.logicError("notSignedIn")
|
|
67
67
|
await service.trigger({ type: 'signedOut' }, {
|
|
68
68
|
session: client.session,
|
|
69
69
|
user: client.user
|
|
@@ -119,7 +119,7 @@ definition.action({
|
|
|
119
119
|
},
|
|
120
120
|
async execute({ to }, { client, service }, emit) {
|
|
121
121
|
const userData = await User.get(to)
|
|
122
|
-
if(!userData) throw
|
|
122
|
+
if(!userData) throw app.logicError("userNotFound")
|
|
123
123
|
await service.trigger({ type: 'signedOut' }, {
|
|
124
124
|
session: client.session,
|
|
125
125
|
user: client.user
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/user-service",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.195",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@live-change/framework": "^0.9.
|
|
26
|
-
"@live-change/relations-plugin": "^0.9.
|
|
25
|
+
"@live-change/framework": "^0.9.195",
|
|
26
|
+
"@live-change/relations-plugin": "^0.9.195",
|
|
27
27
|
"pluralize": "^8.0.0"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "9f61eddae56ddd89aba20988b8e208d948728496"
|
|
30
30
|
}
|
package/sessionOrUserItem.js
CHANGED
|
@@ -223,7 +223,7 @@ definition.processor(function(service, app) {
|
|
|
223
223
|
async execute(properties, { client, service }, emit) {
|
|
224
224
|
const id = properties[modelPropertyName] || app.generateUid()
|
|
225
225
|
const entity = await modelRuntime().get(id)
|
|
226
|
-
if(entity) throw
|
|
226
|
+
if(entity) throw app.logicError("exists")
|
|
227
227
|
const identifiers = client.user ? {
|
|
228
228
|
sessionOrUserType: 'user_User',
|
|
229
229
|
sessionOrUser: client.user,
|
|
@@ -259,12 +259,12 @@ definition.processor(function(service, app) {
|
|
|
259
259
|
waitForEvents: true,
|
|
260
260
|
async execute(properties, { client, service }, emit) {
|
|
261
261
|
const entity = await modelRuntime().get(properties[modelPropertyName])
|
|
262
|
-
if(!entity) throw
|
|
262
|
+
if(!entity) throw app.logicError("not_found")
|
|
263
263
|
if(entity.sessionOrUserType === 'user_User') {
|
|
264
|
-
if(entity.sessionOrUser !== client.user) throw
|
|
264
|
+
if(entity.sessionOrUser !== client.user) throw app.logicError("not_authorized")
|
|
265
265
|
}
|
|
266
266
|
if(entity.sessionOrUserType === 'session_Session') {
|
|
267
|
-
if(entity.sessionOrUser !== client.session) throw
|
|
267
|
+
if(entity.sessionOrUser !== client.session) throw app.logicError("not_authorized")
|
|
268
268
|
}
|
|
269
269
|
let updateObject = {}
|
|
270
270
|
for(const propertyName of writeableProperties) {
|
|
@@ -310,12 +310,12 @@ definition.processor(function(service, app) {
|
|
|
310
310
|
waitForEvents: true,
|
|
311
311
|
async execute(properties, { client, service }, emit) {
|
|
312
312
|
const entity = await modelRuntime().get(properties[modelPropertyName])
|
|
313
|
-
if(!entity) throw
|
|
313
|
+
if(!entity) throw app.logicError("not_found")
|
|
314
314
|
if(entity.sessionOrUserType === 'user_User') {
|
|
315
|
-
if(entity.sessionOrUser !== client.user) throw
|
|
315
|
+
if(entity.sessionOrUser !== client.user) throw app.logicError("not_authorized")
|
|
316
316
|
}
|
|
317
317
|
if(entity.sessionOrUserType === 'session_Session') {
|
|
318
|
-
if(entity.sessionOrUser !== client.session) throw
|
|
318
|
+
if(entity.sessionOrUser !== client.session) throw app.logicError("not_authorized")
|
|
319
319
|
}
|
|
320
320
|
const identifiers = client.user ? {
|
|
321
321
|
sessionOrUserType: 'user_User',
|
package/sessionOrUserProperty.js
CHANGED
|
@@ -247,7 +247,7 @@ definition.processor(function(service, app) {
|
|
|
247
247
|
for(const extension of extendedWith) owner.push(properties[extension+'Type'], properties[extension])
|
|
248
248
|
const id = owner.map(p => JSON.stringify(p)).join(':')
|
|
249
249
|
const entity = await modelRuntime().get(id)
|
|
250
|
-
if(entity) throw
|
|
250
|
+
if(entity) throw app.logicError("alerady_exists")
|
|
251
251
|
let newObject = {}
|
|
252
252
|
for(const propertyName of writeableProperties) {
|
|
253
253
|
if(properties.hasOwnProperty(propertyName)) {
|
|
@@ -297,7 +297,7 @@ definition.processor(function(service, app) {
|
|
|
297
297
|
for(const extension of extendedWith) owner.push(properties[extension+'Type'], properties[extension])
|
|
298
298
|
const id = owner.map(p => JSON.stringify(p)).join(':')
|
|
299
299
|
const entity = await modelRuntime().get(id)
|
|
300
|
-
if(!entity) throw
|
|
300
|
+
if(!entity) throw app.logicError("not_found")
|
|
301
301
|
let updateObject = {}
|
|
302
302
|
for(const propertyName of writeableProperties) {
|
|
303
303
|
if(properties.hasOwnProperty(propertyName)) {
|
|
@@ -408,7 +408,7 @@ definition.processor(function(service, app) {
|
|
|
408
408
|
for(const extension of extendedWith) owner.push(properties[extension+'Type'], properties[extension])
|
|
409
409
|
const id = owner.map(p => JSON.stringify(p)).join(':')
|
|
410
410
|
const entity = await modelRuntime().get(id)
|
|
411
|
-
if (!entity) throw
|
|
411
|
+
if (!entity) throw app.logicError("not_found")
|
|
412
412
|
const identifiers = client.user ? {
|
|
413
413
|
sessionOrUserType: 'user_User',
|
|
414
414
|
sessionOrUser: client.user,
|
package/userItem.js
CHANGED
|
@@ -101,7 +101,7 @@ definition.processor(function(service, app) {
|
|
|
101
101
|
async execute(properties, { client, service }, emit) {
|
|
102
102
|
const id = properties[modelPropertyName] || app.generateUid()
|
|
103
103
|
const entity = await modelRuntime().get(id)
|
|
104
|
-
if(entity) throw
|
|
104
|
+
if(entity) throw app.logicError("exists")
|
|
105
105
|
emit({
|
|
106
106
|
type: eventName,
|
|
107
107
|
[modelPropertyName]: id,
|
|
@@ -132,8 +132,8 @@ definition.processor(function(service, app) {
|
|
|
132
132
|
waitForEvents: true,
|
|
133
133
|
async execute(properties, { client, service }, emit) {
|
|
134
134
|
const entity = await modelRuntime().get(properties[modelPropertyName])
|
|
135
|
-
if(!entity) throw
|
|
136
|
-
if(entity.user !== client.user) throw
|
|
135
|
+
if(!entity) throw app.logicError("not_found")
|
|
136
|
+
if(entity.user !== client.user) throw app.logicError("not_authorized")
|
|
137
137
|
let updateObject = {}
|
|
138
138
|
for(const propertyName of writeableProperties) {
|
|
139
139
|
if(properties.hasOwnProperty(propertyName)) {
|
|
@@ -171,8 +171,8 @@ definition.processor(function(service, app) {
|
|
|
171
171
|
waitForEvents: true,
|
|
172
172
|
async execute(properties, { client, service }, emit) {
|
|
173
173
|
const entity = await modelRuntime().get(properties[modelPropertyName])
|
|
174
|
-
if(!entity) throw
|
|
175
|
-
if(entity.user !== client.user) throw
|
|
174
|
+
if(!entity) throw app.logicError("not_found")
|
|
175
|
+
if(entity.user !== client.user) throw app.logicError("not_authorized")
|
|
176
176
|
emit({
|
|
177
177
|
type: eventName,
|
|
178
178
|
[modelPropertyName]: entity.id,
|
package/userProperty.js
CHANGED
|
@@ -113,7 +113,7 @@ definition.processor(function(service, app) {
|
|
|
113
113
|
waitForEvents: true,
|
|
114
114
|
async execute(properties, { client, service }, emit) {
|
|
115
115
|
const entity = await modelRuntime().get(client.user)
|
|
116
|
-
if(!entity) throw
|
|
116
|
+
if(!entity) throw app.logicError("not_found")
|
|
117
117
|
let updateObject = {}
|
|
118
118
|
for(const propertyName of writeableProperties) {
|
|
119
119
|
if(properties.hasOwnProperty(propertyName)) {
|
|
@@ -145,7 +145,7 @@ definition.processor(function(service, app) {
|
|
|
145
145
|
waitForEvents: true,
|
|
146
146
|
async execute(properties, {client, service}, emit) {
|
|
147
147
|
const entity = await modelRuntime().indexObjectGet('byUser', client.user)
|
|
148
|
-
if (!entity) throw
|
|
148
|
+
if (!entity) throw app.logicError("not_found")
|
|
149
149
|
emit({
|
|
150
150
|
type: eventName,
|
|
151
151
|
identifiers: {
|