@live-change/user-service 0.9.197 → 0.9.198
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 +20 -4
- package/contactOrUserProperty.js +8 -4
- package/package.json +4 -4
- package/sessionOrUserItem.js +27 -12
- package/sessionOrUserProperty.js +10 -5
- package/userItem.js +18 -3
- package/userProperty.js +6 -3
package/contactOrUserItem.js
CHANGED
|
@@ -154,6 +154,7 @@ definition.processor(function(service, app) {
|
|
|
154
154
|
name: actionName,
|
|
155
155
|
access: (params, context) => context.client.user
|
|
156
156
|
&& (config.ownerCreateAccess || config.ownerWriteAccess)(params,context),
|
|
157
|
+
skipValidation: true,
|
|
157
158
|
properties: {
|
|
158
159
|
...originalModelProperties,
|
|
159
160
|
[modelPropertyName]: {
|
|
@@ -171,15 +172,27 @@ definition.processor(function(service, app) {
|
|
|
171
172
|
ownerType: 'user_User',
|
|
172
173
|
owner: client.user,
|
|
173
174
|
}
|
|
175
|
+
let newObject = {}
|
|
176
|
+
for(const propertyName of writeableProperties) {
|
|
177
|
+
if(properties.hasOwnProperty(propertyName)) {
|
|
178
|
+
newObject[propertyName] = properties[propertyName]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const data = App.utils.mergeDeep({},
|
|
182
|
+
App.computeDefaults(model, properties, { client, service }), newObject)
|
|
183
|
+
await App.validation.validate({ ...identifiers, ...data }, validators,
|
|
184
|
+
{ source: action, action, service, app, client })
|
|
174
185
|
emit({
|
|
175
186
|
type: eventName,
|
|
176
187
|
[modelPropertyName]: id,
|
|
177
188
|
identifiers,
|
|
178
|
-
data
|
|
189
|
+
data
|
|
179
190
|
})
|
|
180
191
|
return id
|
|
181
192
|
}
|
|
182
193
|
})
|
|
194
|
+
const action = service.actions[actionName]
|
|
195
|
+
const validators = App.validation.getValidators(action, service, action)
|
|
183
196
|
}
|
|
184
197
|
if(config.ownerUpdateAccess || config.ownerWriteAccess) {
|
|
185
198
|
const eventName = modelName + 'Updated'
|
|
@@ -210,8 +223,6 @@ definition.processor(function(service, app) {
|
|
|
210
223
|
updateObject[propertyName] = properties[propertyName]
|
|
211
224
|
}
|
|
212
225
|
}
|
|
213
|
-
const merged = App.utils.mergeDeep({}, entity, updateObject)
|
|
214
|
-
await App.validation.validate(merged, validators, { source: action, action, service, app, client })
|
|
215
226
|
const identifiers = client.user ? {
|
|
216
227
|
ownerType: 'user_User',
|
|
217
228
|
owner: client.user,
|
|
@@ -219,11 +230,16 @@ definition.processor(function(service, app) {
|
|
|
219
230
|
ownerType: 'session_Session',
|
|
220
231
|
owner: client.session,
|
|
221
232
|
}
|
|
233
|
+
const computedUpdates = App.computeUpdates(model, { ...entity, ...properties }, { client, service })
|
|
234
|
+
const data = App.utils.mergeDeep({}, updateObject, computedUpdates)
|
|
235
|
+
const merged = App.utils.mergeDeep({}, entity, data)
|
|
236
|
+
await App.validation.validate({ ...identifiers, ...merged }, validators,
|
|
237
|
+
{ source: action, action, service, app, client })
|
|
222
238
|
emit({
|
|
223
239
|
type: eventName,
|
|
224
240
|
[modelPropertyName]: entity.id,
|
|
225
241
|
identifiers,
|
|
226
|
-
data
|
|
242
|
+
data
|
|
227
243
|
})
|
|
228
244
|
}
|
|
229
245
|
})
|
package/contactOrUserProperty.js
CHANGED
|
@@ -241,7 +241,6 @@ definition.processor(function(service, app) {
|
|
|
241
241
|
}
|
|
242
242
|
const data = App.utils.mergeDeep({},
|
|
243
243
|
App.computeDefaults(model, properties, { client, service } ), newObject)
|
|
244
|
-
await App.validation.validate(data, validators, { source: action, action, service, app, client })
|
|
245
244
|
const identifiers = {
|
|
246
245
|
contactOrUserType: 'user_User',
|
|
247
246
|
contactOrUser: client.user,
|
|
@@ -250,6 +249,8 @@ definition.processor(function(service, app) {
|
|
|
250
249
|
identifiers[key+'Type'] = properties[key+'Type']
|
|
251
250
|
identifiers[key]=properties[key]
|
|
252
251
|
}
|
|
252
|
+
await App.validation.validate({ ...identifiers, ...data }, validators,
|
|
253
|
+
{ source: action, action, service, app, client })
|
|
253
254
|
emit({
|
|
254
255
|
type: eventName,
|
|
255
256
|
identifiers,
|
|
@@ -288,8 +289,6 @@ definition.processor(function(service, app) {
|
|
|
288
289
|
updateObject[propertyName] = properties[propertyName]
|
|
289
290
|
}
|
|
290
291
|
}
|
|
291
|
-
const merged = App.utils.mergeDeep({}, entity, updateObject)
|
|
292
|
-
await App.validation.validate(merged, validators, { source: action, action, service, app, client })
|
|
293
292
|
const identifiers = {
|
|
294
293
|
contactOrUserType: 'user_User',
|
|
295
294
|
contactOrUser: client.user,
|
|
@@ -298,10 +297,15 @@ definition.processor(function(service, app) {
|
|
|
298
297
|
identifiers[key+'Type'] = properties[key+'Type']
|
|
299
298
|
identifiers[key]=properties[key]
|
|
300
299
|
}
|
|
300
|
+
const computedUpdates = App.computeUpdates(model, { ...entity, ...properties }, { client, service })
|
|
301
|
+
const data = App.utils.mergeDeep({}, updateObject, computedUpdates)
|
|
302
|
+
const merged = App.utils.mergeDeep({}, entity, data)
|
|
303
|
+
await App.validation.validate({ ...identifiers, ...merged }, validators,
|
|
304
|
+
{ source: action, action, service, app, client })
|
|
301
305
|
emit({
|
|
302
306
|
type: eventName,
|
|
303
307
|
identifiers,
|
|
304
|
-
data
|
|
308
|
+
data
|
|
305
309
|
})
|
|
306
310
|
}
|
|
307
311
|
})
|
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.198",
|
|
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.198",
|
|
26
|
+
"@live-change/relations-plugin": "^0.9.198",
|
|
27
27
|
"pluralize": "^8.0.0"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "7e485dcbaa2af7fb17052a40238210dc8bdf0c09"
|
|
30
30
|
}
|
package/sessionOrUserItem.js
CHANGED
|
@@ -210,6 +210,7 @@ definition.processor(function(service, app) {
|
|
|
210
210
|
const actionName = 'createMy' + modelName
|
|
211
211
|
service.actions[actionName] = new ActionDefinition({
|
|
212
212
|
name: actionName,
|
|
213
|
+
skipValidation: true,
|
|
213
214
|
access: config.ownerCreateAccess || config.ownerWriteAccess,
|
|
214
215
|
properties: {
|
|
215
216
|
...originalModelProperties,
|
|
@@ -225,21 +226,33 @@ definition.processor(function(service, app) {
|
|
|
225
226
|
const entity = await modelRuntime().get(id)
|
|
226
227
|
if(entity) throw app.logicError("exists")
|
|
227
228
|
const identifiers = client.user ? {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
sessionOrUserType: 'user_User',
|
|
230
|
+
sessionOrUser: client.user,
|
|
231
|
+
} : {
|
|
232
|
+
sessionOrUserType: 'session_Session',
|
|
233
|
+
sessionOrUser: client.session,
|
|
234
|
+
}
|
|
235
|
+
let newObject = {}
|
|
236
|
+
for(const propertyName of writeableProperties) {
|
|
237
|
+
if(properties.hasOwnProperty(propertyName)) {
|
|
238
|
+
newObject[propertyName] = properties[propertyName]
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const data = App.utils.mergeDeep({},
|
|
242
|
+
App.computeDefaults(model, properties, { client, service }), newObject)
|
|
243
|
+
await App.validation.validate({ ...identifiers, ...data }, validators,
|
|
244
|
+
{ source: action, action, service, app, client })
|
|
234
245
|
emit({
|
|
235
246
|
type: eventName,
|
|
236
247
|
[modelPropertyName]: id,
|
|
237
248
|
identifiers,
|
|
238
|
-
data
|
|
249
|
+
data
|
|
239
250
|
})
|
|
240
251
|
return id
|
|
241
252
|
}
|
|
242
253
|
})
|
|
254
|
+
const action = service.actions[actionName]
|
|
255
|
+
const validators = App.validation.getValidators(action, service, action)
|
|
243
256
|
}
|
|
244
257
|
if(config.ownerUpdateAccess || config.ownerWriteAccess) {
|
|
245
258
|
const eventName = modelName + 'Updated'
|
|
@@ -272,10 +285,6 @@ definition.processor(function(service, app) {
|
|
|
272
285
|
updateObject[propertyName] = properties[propertyName]
|
|
273
286
|
}
|
|
274
287
|
}
|
|
275
|
-
const merged = App.utils.mergeDeep({ [modelPropertyName]: properties[modelPropertyName] },
|
|
276
|
-
entity, updateObject)
|
|
277
|
-
|
|
278
|
-
await App.validation.validate(merged, validators, { source: action, action, service, app, client })
|
|
279
288
|
const identifiers = client.user ? {
|
|
280
289
|
sessionOrUserType: 'user_User',
|
|
281
290
|
sessionOrUser: client.user,
|
|
@@ -283,11 +292,17 @@ definition.processor(function(service, app) {
|
|
|
283
292
|
sessionOrUserType: 'session_Session',
|
|
284
293
|
sessionOrUser: client.session,
|
|
285
294
|
}
|
|
295
|
+
const computedUpdates = App.computeUpdates(model, { ...entity, ...properties }, { client, service })
|
|
296
|
+
const data = App.utils.mergeDeep({}, updateObject, computedUpdates)
|
|
297
|
+
const merged = App.utils.mergeDeep({ [modelPropertyName]: properties[modelPropertyName] },
|
|
298
|
+
entity, data)
|
|
299
|
+
await App.validation.validate({ ...identifiers, ...merged }, validators,
|
|
300
|
+
{ source: action, action, service, app, client })
|
|
286
301
|
emit({
|
|
287
302
|
type: eventName,
|
|
288
303
|
[modelPropertyName]: entity.id,
|
|
289
304
|
identifiers,
|
|
290
|
-
data
|
|
305
|
+
data
|
|
291
306
|
})
|
|
292
307
|
}
|
|
293
308
|
})
|
package/sessionOrUserProperty.js
CHANGED
|
@@ -304,8 +304,6 @@ definition.processor(function(service, app) {
|
|
|
304
304
|
updateObject[propertyName] = properties[propertyName]
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
const merged = App.utils.mergeDeep({}, entity, updateObject)
|
|
308
|
-
await App.validation.validate(merged, validators, { source: action, action, service, app, client })
|
|
309
307
|
const identifiers = client.user ? {
|
|
310
308
|
sessionOrUserType: 'user_User',
|
|
311
309
|
sessionOrUser: client.user,
|
|
@@ -317,10 +315,15 @@ definition.processor(function(service, app) {
|
|
|
317
315
|
identifiers[key+'Type'] = properties[key+'Type']
|
|
318
316
|
identifiers[key]=properties[key]
|
|
319
317
|
}
|
|
318
|
+
const computedUpdates = App.computeUpdates(model, { ...entity, ...properties }, { client, service })
|
|
319
|
+
const data = App.utils.mergeDeep({}, updateObject, computedUpdates)
|
|
320
|
+
const merged = App.utils.mergeDeep({}, entity, data)
|
|
321
|
+
await App.validation.validate({ ...identifiers, ...merged }, validators,
|
|
322
|
+
{ source: action, action, service, app, client })
|
|
320
323
|
emit({
|
|
321
324
|
type: eventName,
|
|
322
325
|
identifiers,
|
|
323
|
-
data
|
|
326
|
+
data
|
|
324
327
|
})
|
|
325
328
|
}
|
|
326
329
|
})
|
|
@@ -376,14 +379,16 @@ definition.processor(function(service, app) {
|
|
|
376
379
|
data
|
|
377
380
|
})
|
|
378
381
|
} else {
|
|
379
|
-
const
|
|
382
|
+
const computedUpdates = App.computeUpdates(model, { ...entity, ...properties }, { client, service })
|
|
383
|
+
const data = App.utils.mergeDeep({}, updateObject, computedUpdates)
|
|
384
|
+
const merged = App.utils.mergeDeep({}, entity, data)
|
|
380
385
|
//console.log('V', { ...identifiers, ...merged}, validators)
|
|
381
386
|
await App.validation.validate({ ...identifiers, ...merged}, validators,
|
|
382
387
|
{ source: action, action, service, app, client })
|
|
383
388
|
emit({
|
|
384
389
|
type: updatedEventName,
|
|
385
390
|
identifiers,
|
|
386
|
-
data
|
|
391
|
+
data
|
|
387
392
|
})
|
|
388
393
|
}
|
|
389
394
|
}
|
package/userItem.js
CHANGED
|
@@ -88,6 +88,7 @@ definition.processor(function(service, app) {
|
|
|
88
88
|
const actionName = 'createMyUser' + modelName
|
|
89
89
|
service.actions[actionName] = new ActionDefinition({
|
|
90
90
|
name: actionName,
|
|
91
|
+
skipValidation: true,
|
|
91
92
|
access: config.userCreateAccess || config.userWriteAccess,
|
|
92
93
|
properties: {
|
|
93
94
|
...originalModelProperties,
|
|
@@ -102,17 +103,29 @@ definition.processor(function(service, app) {
|
|
|
102
103
|
const id = properties[modelPropertyName] || app.generateUid()
|
|
103
104
|
const entity = await modelRuntime().get(id)
|
|
104
105
|
if(entity) throw app.logicError("exists")
|
|
106
|
+
let newObject = {}
|
|
107
|
+
for(const propertyName of writeableProperties) {
|
|
108
|
+
if(properties.hasOwnProperty(propertyName)) {
|
|
109
|
+
newObject[propertyName] = properties[propertyName]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const data = App.utils.mergeDeep({},
|
|
113
|
+
App.computeDefaults(model, properties, { client, service }), newObject)
|
|
114
|
+
await App.validation.validate(data, validators,
|
|
115
|
+
{ source: action, action, service, app, client })
|
|
105
116
|
emit({
|
|
106
117
|
type: eventName,
|
|
107
118
|
[modelPropertyName]: id,
|
|
108
119
|
identifiers: {
|
|
109
120
|
user: client.user,
|
|
110
121
|
},
|
|
111
|
-
data
|
|
122
|
+
data
|
|
112
123
|
})
|
|
113
124
|
return id
|
|
114
125
|
}
|
|
115
126
|
})
|
|
127
|
+
const action = service.actions[actionName]
|
|
128
|
+
const validators = App.validation.getValidators(action, service, action)
|
|
116
129
|
}
|
|
117
130
|
if(config.userUpdateAccess || config.userWriteAccess) {
|
|
118
131
|
const eventName = modelName + 'Updated'
|
|
@@ -140,7 +153,9 @@ definition.processor(function(service, app) {
|
|
|
140
153
|
updateObject[propertyName] = properties[propertyName]
|
|
141
154
|
}
|
|
142
155
|
}
|
|
143
|
-
const
|
|
156
|
+
const computedUpdates = App.computeUpdates(model, { ...entity, ...properties }, { client, service })
|
|
157
|
+
const data = App.utils.mergeDeep({}, updateObject, computedUpdates)
|
|
158
|
+
const merged = App.utils.mergeDeep({}, entity, data)
|
|
144
159
|
await App.validation.validate(merged, validators, { source: action, action, service, app, client })
|
|
145
160
|
emit({
|
|
146
161
|
type: eventName,
|
|
@@ -148,7 +163,7 @@ definition.processor(function(service, app) {
|
|
|
148
163
|
identifiers: {
|
|
149
164
|
user: client.user,
|
|
150
165
|
},
|
|
151
|
-
data
|
|
166
|
+
data
|
|
152
167
|
})
|
|
153
168
|
}
|
|
154
169
|
})
|
package/userProperty.js
CHANGED
|
@@ -120,14 +120,17 @@ definition.processor(function(service, app) {
|
|
|
120
120
|
updateObject[propertyName] = properties[propertyName]
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
const
|
|
124
|
-
|
|
123
|
+
const computedUpdates = App.computeUpdates(model, { ...entity, ...properties }, { client, service })
|
|
124
|
+
const data = App.utils.mergeDeep({}, updateObject, computedUpdates)
|
|
125
|
+
const merged = App.utils.mergeDeep({}, entity, data)
|
|
126
|
+
await App.validation.validate({ user: client.user, ...merged }, validators,
|
|
127
|
+
{ source: action, action, service, app, client })
|
|
125
128
|
emit({
|
|
126
129
|
type: eventName,
|
|
127
130
|
identifiers: {
|
|
128
131
|
user: client.user
|
|
129
132
|
},
|
|
130
|
-
data
|
|
133
|
+
data
|
|
131
134
|
})
|
|
132
135
|
}
|
|
133
136
|
})
|