@live-change/relations-plugin 0.8.30 → 0.8.32
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 +8 -3
- package/package.json +3 -3
- package/pluralRelationAnyUtils.js +2 -3
- package/pluralRelationUtils.js +4 -0
package/changeTriggers.js
CHANGED
|
@@ -8,7 +8,8 @@ async function fireChangeTriggers(context, objectType, identifiers, object, oldD
|
|
|
8
8
|
const changeType = data ? (oldData ? 'update' : 'create') : 'delete'
|
|
9
9
|
await Promise.all([
|
|
10
10
|
app.trigger({
|
|
11
|
-
type: changeType+service.name[0].toUpperCase()+service.name.slice(1)+'_'+modelName,
|
|
11
|
+
type: changeType + service.name[0].toUpperCase() + service.name.slice(1) + '_' + modelName,
|
|
12
|
+
}, {
|
|
12
13
|
objectType,
|
|
13
14
|
object,
|
|
14
15
|
identifiers,
|
|
@@ -16,7 +17,8 @@ async function fireChangeTriggers(context, objectType, identifiers, object, oldD
|
|
|
16
17
|
oldData
|
|
17
18
|
}),
|
|
18
19
|
app.trigger({
|
|
19
|
-
type: changeType+'Object',
|
|
20
|
+
type: changeType + 'Object',
|
|
21
|
+
}, {
|
|
20
22
|
objectType,
|
|
21
23
|
object,
|
|
22
24
|
identifiers,
|
|
@@ -146,7 +148,8 @@ async function copyObject(context, objectType, object, parentType, parent, ident
|
|
|
146
148
|
|
|
147
149
|
const newId = app.generateUid()
|
|
148
150
|
app.trigger({
|
|
149
|
-
type: 'copy'+service.name[0].toUpperCase()+service.name.slice(1)+'_'+modelName,
|
|
151
|
+
type: 'copy' + service.name[0].toUpperCase() + service.name.slice(1) + '_' + modelName,
|
|
152
|
+
}, {
|
|
150
153
|
objectType,
|
|
151
154
|
object: newId,
|
|
152
155
|
from: object,
|
|
@@ -155,6 +158,7 @@ async function copyObject(context, objectType, object, parentType, parent, ident
|
|
|
155
158
|
})
|
|
156
159
|
app.trigger({
|
|
157
160
|
type: 'copyObject',
|
|
161
|
+
}, {
|
|
158
162
|
objectType,
|
|
159
163
|
object: newId,
|
|
160
164
|
from: object,
|
|
@@ -187,6 +191,7 @@ async function triggerCopyOnParentCopyTriggers(
|
|
|
187
191
|
//console.log("COPY TRIGGER", myType, fromId, objectType, object, from, identifiers, data)
|
|
188
192
|
const copyTriggerResults = await app.trigger({
|
|
189
193
|
type: 'copyOnParentCopy'+service.name[0].toUpperCase()+service.name.slice(1)+'_'+modelName,
|
|
194
|
+
}, {
|
|
190
195
|
objectType: myType,
|
|
191
196
|
object: fromId,
|
|
192
197
|
parentType: objectType,
|
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.32",
|
|
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.32",
|
|
26
26
|
"pluralize": "^8.0.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "9ea7767670a99404794087726223064c45d798d3"
|
|
29
29
|
}
|
|
@@ -134,7 +134,7 @@ function getUpdateFunction( validators, validationContext, config, context) {
|
|
|
134
134
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Updated'
|
|
135
135
|
return async function execute(properties, { client, service }, emit) {
|
|
136
136
|
const id = properties[modelPropertyName]
|
|
137
|
-
if(!id) throw 'no_id'
|
|
137
|
+
if(!id) throw new Error('no_id')
|
|
138
138
|
const entity = await modelRuntime().get(id)
|
|
139
139
|
if(!entity) throw 'not_found'
|
|
140
140
|
const entityTypeAndIdParts = extractTypeAndIdParts(otherPropertyNames, entity)
|
|
@@ -147,7 +147,7 @@ function getUpdateFunction( validators, validationContext, config, context) {
|
|
|
147
147
|
extractObjectData(writeableProperties, properties, entity),
|
|
148
148
|
App.computeUpdates(model, { ...entity, ...properties }, { client, service })
|
|
149
149
|
)
|
|
150
|
-
await App.validation.validate({ ...identifiers, ...data }, validators,
|
|
150
|
+
await App.validation.validate({ ...identifiers, ...data, [modelPropertyName]: id }, validators,
|
|
151
151
|
validationContext)
|
|
152
152
|
await fireChangeTriggers(context, objectType, identifiers, id,
|
|
153
153
|
extractObjectData(writeableProperties, entity, {}), data)
|
|
@@ -158,7 +158,6 @@ function getUpdateFunction( validators, validationContext, config, context) {
|
|
|
158
158
|
data
|
|
159
159
|
})
|
|
160
160
|
}
|
|
161
|
-
|
|
162
161
|
}
|
|
163
162
|
|
|
164
163
|
function defineUpdateAction(config, context) {
|
package/pluralRelationUtils.js
CHANGED
|
@@ -319,6 +319,7 @@ function getCopyFunction( validators, validationContext, config, context) {
|
|
|
319
319
|
validationContext)
|
|
320
320
|
app.trigger({
|
|
321
321
|
type: 'copy'+service.name[0].toUpperCase()+service.name.slice(1)+'_'+modelName,
|
|
322
|
+
}, {
|
|
322
323
|
objectType,
|
|
323
324
|
object: newId,
|
|
324
325
|
from: id,
|
|
@@ -327,6 +328,7 @@ function getCopyFunction( validators, validationContext, config, context) {
|
|
|
327
328
|
}),
|
|
328
329
|
app.trigger({
|
|
329
330
|
type: 'copyObject',
|
|
331
|
+
}, {
|
|
330
332
|
objectType,
|
|
331
333
|
object: newId,
|
|
332
334
|
from: id,
|
|
@@ -466,6 +468,7 @@ function defineCopyOnParentCopyTrigger(config, context) {
|
|
|
466
468
|
const newId = app.generateUid()
|
|
467
469
|
app.trigger({
|
|
468
470
|
type: 'copy'+service.name[0].toUpperCase()+service.name.slice(1)+'_'+modelName,
|
|
471
|
+
}, {
|
|
469
472
|
objectType,
|
|
470
473
|
object: newId,
|
|
471
474
|
from: object,
|
|
@@ -474,6 +477,7 @@ function defineCopyOnParentCopyTrigger(config, context) {
|
|
|
474
477
|
})
|
|
475
478
|
app.trigger({
|
|
476
479
|
type: 'copyObject',
|
|
480
|
+
}, {
|
|
477
481
|
objectType,
|
|
478
482
|
object: newId,
|
|
479
483
|
from: object,
|