@live-change/relations-plugin 0.8.51 → 0.8.53
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/changeTriggers.js +12 -15
- package/entity.js +1 -1
- package/package.json +3 -3
- package/singularRelationUtils.js +2 -2
package/changeTriggers.js
CHANGED
|
@@ -6,25 +6,22 @@ import {
|
|
|
6
6
|
async function fireChangeTriggers(context, objectType, identifiers, object, oldData, data) {
|
|
7
7
|
const { service, modelName, app } = context
|
|
8
8
|
const changeType = data ? (oldData ? 'update' : 'create') : 'delete'
|
|
9
|
+
//console.log("FIRE CHANGE TRIGGERS", { context, objectType, identifiers, object, oldData, data })
|
|
10
|
+
//console.trace()
|
|
11
|
+
const triggerParameters = { objectType, object, identifiers, data, oldData, changeType }
|
|
9
12
|
await Promise.all([
|
|
10
13
|
app.trigger({
|
|
11
14
|
type: changeType + service.name[0].toUpperCase() + service.name.slice(1) + '_' + modelName,
|
|
12
|
-
},
|
|
13
|
-
objectType,
|
|
14
|
-
object,
|
|
15
|
-
identifiers,
|
|
16
|
-
data,
|
|
17
|
-
oldData
|
|
18
|
-
}),
|
|
15
|
+
}, triggerParameters),
|
|
19
16
|
app.trigger({
|
|
20
17
|
type: changeType + 'Object',
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
18
|
+
}, triggerParameters),
|
|
19
|
+
app.trigger({
|
|
20
|
+
type: 'change' + service.name[0].toUpperCase() + service.name.slice(1) + '_' + modelName,
|
|
21
|
+
}, triggerParameters),
|
|
22
|
+
app.trigger({
|
|
23
|
+
type: 'changeObject',
|
|
24
|
+
}, triggerParameters)
|
|
28
25
|
])
|
|
29
26
|
}
|
|
30
27
|
|
|
@@ -201,7 +198,7 @@ async function triggerCopyOnParentCopyTriggers(
|
|
|
201
198
|
data
|
|
202
199
|
})
|
|
203
200
|
//console.log("COPY TRIGGER RESULTS", copyTriggerResults)
|
|
204
|
-
if(copyTriggerResults.length
|
|
201
|
+
if(copyTriggerResults.length === 0) { // normal copy, without special logic
|
|
205
202
|
await copyObject(context, myType, fromId, objectType, object, identifiers, data, emit)
|
|
206
203
|
}
|
|
207
204
|
})
|
package/entity.js
CHANGED
|
@@ -192,7 +192,7 @@ function getUpdateFunction( validators, validationContext, config, context) {
|
|
|
192
192
|
)
|
|
193
193
|
await App.validation.validate({ ...data }, validators,
|
|
194
194
|
validationContext)
|
|
195
|
-
await fireChangeTriggers(context, null, id,
|
|
195
|
+
await fireChangeTriggers(context, objectType, null, id,
|
|
196
196
|
entity ? extractObjectData(writeableProperties, entity, {}) : null, data)
|
|
197
197
|
emit({
|
|
198
198
|
type: eventName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/relations-plugin",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.53",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@live-change/framework": "^0.8.
|
|
25
|
+
"@live-change/framework": "^0.8.53",
|
|
26
26
|
"pluralize": "^8.0.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "39422adadd1863fa396fc4e875936e09428d6cf1"
|
|
29
29
|
}
|
package/singularRelationUtils.js
CHANGED
|
@@ -216,7 +216,7 @@ function defineSetOrUpdateAction(config, context) {
|
|
|
216
216
|
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
217
217
|
} = context
|
|
218
218
|
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Updated'
|
|
219
|
-
const actionName = '
|
|
219
|
+
const actionName = 'setOrUpdate' + joinedOthersClassName + 'Owned' + modelName
|
|
220
220
|
const accessControl = config.updateAccessControl || config.writeAccessControl
|
|
221
221
|
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
222
222
|
const action = new ActionDefinition({
|
|
@@ -242,7 +242,7 @@ function defineSetOrUpdateTrigger(config, context) {
|
|
|
242
242
|
service, app, model, modelRuntime, objectType,
|
|
243
243
|
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
244
244
|
} = context
|
|
245
|
-
const actionName = '
|
|
245
|
+
const actionName = 'setOrUpdate' + joinedOthersClassName + 'Owned' + modelName
|
|
246
246
|
const triggerName = `${service.name}_${actionName}`
|
|
247
247
|
const trigger = new TriggerDefinition({
|
|
248
248
|
name: triggerName,
|