@live-change/session-service 0.9.196 → 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/package.json +4 -4
- package/sessionItem.js +17 -3
- package/sessionProperty.js +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/session-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/sessionItem.js
CHANGED
|
@@ -62,6 +62,7 @@ definition.processor(function(service, app) {
|
|
|
62
62
|
const actionName = 'createMySession' + modelName
|
|
63
63
|
service.actions[actionName] = new ActionDefinition({
|
|
64
64
|
name: actionName,
|
|
65
|
+
skipValidation: true,
|
|
65
66
|
access: config.sessionCreateAccess || config.sessionWriteAccess,
|
|
66
67
|
properties: {
|
|
67
68
|
...originalModelProperties,
|
|
@@ -76,17 +77,28 @@ definition.processor(function(service, app) {
|
|
|
76
77
|
const id = properties[modelPropertyName] || app.generateUid()
|
|
77
78
|
const entity = await modelRuntime().get(id)
|
|
78
79
|
if(entity) throw app.logicError("exists")
|
|
80
|
+
let newObject = {}
|
|
81
|
+
for(const propertyName of writeableProperties) {
|
|
82
|
+
if(properties.hasOwnProperty(propertyName)) {
|
|
83
|
+
newObject[propertyName] = properties[propertyName]
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const data = App.utils.mergeDeep({},
|
|
87
|
+
App.computeDefaults(model, properties, { client, service }), newObject)
|
|
88
|
+
await App.validation.validate(data, validators, validationContext)
|
|
79
89
|
emit({
|
|
80
90
|
type: eventName,
|
|
81
91
|
[modelPropertyName]: id,
|
|
82
92
|
identifiers: {
|
|
83
93
|
session: client.session,
|
|
84
94
|
},
|
|
85
|
-
data
|
|
95
|
+
data
|
|
86
96
|
})
|
|
87
97
|
return id
|
|
88
98
|
}
|
|
89
99
|
})
|
|
100
|
+
const action = service.actions[actionName]
|
|
101
|
+
const validators = App.validation.getValidators(action, service, action)
|
|
90
102
|
}
|
|
91
103
|
if(config.sessionUpdateAccess || config.sessionWriteAccess) {
|
|
92
104
|
const eventName = modelName + 'Updated'
|
|
@@ -114,7 +126,9 @@ definition.processor(function(service, app) {
|
|
|
114
126
|
updateObject[propertyName] = properties[propertyName]
|
|
115
127
|
}
|
|
116
128
|
}
|
|
117
|
-
const
|
|
129
|
+
const computedUpdates = App.computeUpdates(model, { ...entity, ...properties }, { client, service })
|
|
130
|
+
const data = App.utils.mergeDeep({}, updateObject, computedUpdates)
|
|
131
|
+
const merged = App.utils.mergeDeep({}, entity, data)
|
|
118
132
|
await App.validation.validate(merged, validators, validationContext)
|
|
119
133
|
emit({
|
|
120
134
|
type: eventName,
|
|
@@ -122,7 +136,7 @@ definition.processor(function(service, app) {
|
|
|
122
136
|
identifiers: {
|
|
123
137
|
session: client.session,
|
|
124
138
|
},
|
|
125
|
-
data
|
|
139
|
+
data
|
|
126
140
|
})
|
|
127
141
|
}
|
|
128
142
|
})
|
package/sessionProperty.js
CHANGED
|
@@ -110,14 +110,17 @@ definition.processor(function(service, app) {
|
|
|
110
110
|
updateObject[propertyName] = properties[propertyName]
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
113
|
+
const computedUpdates = App.computeUpdates(model, { ...entity, ...properties }, { client, service })
|
|
114
|
+
const data = App.utils.mergeDeep({}, updateObject, computedUpdates)
|
|
115
|
+
const merged = App.utils.mergeDeep({}, entity, data)
|
|
116
|
+
await App.validation.validate({ session: client.session, ...merged }, validators,
|
|
117
|
+
validationContext)
|
|
115
118
|
emit({
|
|
116
119
|
type: eventName,
|
|
117
120
|
identifiers: {
|
|
118
121
|
session: client.session
|
|
119
122
|
},
|
|
120
|
-
data
|
|
123
|
+
data
|
|
121
124
|
})
|
|
122
125
|
}
|
|
123
126
|
})
|