@live-change/relations-plugin 0.9.0 → 0.9.2
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 +1 -1
- package/itemEvents.js +4 -4
- package/package.json +3 -3
- package/pluralRelationUtils.js +2 -6
- package/utils.js +1 -1
- package/utilsAny.js +4 -4
package/changeTriggers.js
CHANGED
|
@@ -68,7 +68,7 @@ async function triggerDeleteOnParentDeleteTriggers(
|
|
|
68
68
|
extractObjectData(writeableProperties, entity, {}), null)
|
|
69
69
|
})
|
|
70
70
|
if (found) {
|
|
71
|
-
const eventName =
|
|
71
|
+
const eventName = modelName + 'DeleteByOwner'
|
|
72
72
|
emit({
|
|
73
73
|
type: eventName,
|
|
74
74
|
ownerType: objectType,
|
package/itemEvents.js
CHANGED
|
@@ -32,7 +32,7 @@ function defineUpdatedEvent(config, context) {
|
|
|
32
32
|
const {
|
|
33
33
|
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName, reverseRelationWord
|
|
34
34
|
} = context
|
|
35
|
-
const eventName =
|
|
35
|
+
const eventName = modelName + 'Updated'
|
|
36
36
|
service.events[eventName] = new EventDefinition({
|
|
37
37
|
name: eventName,
|
|
38
38
|
properties: {
|
|
@@ -58,7 +58,7 @@ function defineTransferredEvent(config, context) {
|
|
|
58
58
|
const {
|
|
59
59
|
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName, reverseRelationWord
|
|
60
60
|
} = context
|
|
61
|
-
const eventName =
|
|
61
|
+
const eventName = modelName + 'Transferred'
|
|
62
62
|
service.events[eventName] = new EventDefinition({
|
|
63
63
|
name: eventName,
|
|
64
64
|
properties: {
|
|
@@ -81,7 +81,7 @@ function defineDeletedEvent(config, context) {
|
|
|
81
81
|
const {
|
|
82
82
|
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName, reverseRelationWord
|
|
83
83
|
} = context
|
|
84
|
-
const eventName =
|
|
84
|
+
const eventName = modelName + 'Deleted'
|
|
85
85
|
service.events[eventName] = new EventDefinition({
|
|
86
86
|
name: eventName,
|
|
87
87
|
properties: {
|
|
@@ -101,7 +101,7 @@ function defineCopyEvent(config, context) {
|
|
|
101
101
|
const {
|
|
102
102
|
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName, reverseRelationWord
|
|
103
103
|
} = context
|
|
104
|
-
const eventName =
|
|
104
|
+
const eventName = modelName + 'Copied'
|
|
105
105
|
service.events[eventName] = new EventDefinition({
|
|
106
106
|
name: eventName,
|
|
107
107
|
properties: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/relations-plugin",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
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.9.
|
|
25
|
+
"@live-change/framework": "^0.9.2",
|
|
26
26
|
"pluralize": "^8.0.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "353f5aa8d66fec68587825db5ba09f63b08f4dee"
|
|
29
29
|
}
|
package/pluralRelationUtils.js
CHANGED
|
@@ -156,7 +156,7 @@ function getUpdateFunction( validators, validationContext, config, context) {
|
|
|
156
156
|
service, app, model, modelPropertyName, modelRuntime, objectType,
|
|
157
157
|
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
158
158
|
} = context
|
|
159
|
-
const eventName =
|
|
159
|
+
const eventName = modelName + 'Updated'
|
|
160
160
|
return async function execute(properties, { client, service }, emit) {
|
|
161
161
|
const id = properties[modelPropertyName]
|
|
162
162
|
const entity = await modelRuntime().get(id)
|
|
@@ -272,7 +272,6 @@ function defineDeleteAction(config, context) {
|
|
|
272
272
|
service, app, model, modelRuntime, modelPropertyName, objectType,
|
|
273
273
|
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
274
274
|
} = context
|
|
275
|
-
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Deleted'
|
|
276
275
|
const actionName = 'delete' + modelName
|
|
277
276
|
const accessControl = config.deleteAccessControl || config.writeAccessControl
|
|
278
277
|
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
@@ -304,7 +303,6 @@ function defineDeleteTrigger(config, context) {
|
|
|
304
303
|
service, app, model, modelPropertyName, modelRuntime, objectType,
|
|
305
304
|
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
306
305
|
} = context
|
|
307
|
-
const eventName = modelName + 'Deleted'
|
|
308
306
|
const actionName = 'delete' + modelName
|
|
309
307
|
const triggerName = `${service.name}_${actionName}`
|
|
310
308
|
const trigger = new TriggerDefinition({
|
|
@@ -332,7 +330,7 @@ function getCopyFunction( validators, validationContext, config, context) {
|
|
|
332
330
|
service, app, model, modelPropertyName, modelRuntime, objectType,
|
|
333
331
|
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
334
332
|
} = context
|
|
335
|
-
const eventName =
|
|
333
|
+
const eventName = modelName + 'Copied'
|
|
336
334
|
return async function execute(properties, { client, service }, emit) {
|
|
337
335
|
const id = properties[modelPropertyName]
|
|
338
336
|
const entity = await modelRuntime().get(id)
|
|
@@ -388,7 +386,6 @@ function defineCopyAction(config, context) {
|
|
|
388
386
|
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others,
|
|
389
387
|
identifiers
|
|
390
388
|
} = context
|
|
391
|
-
const eventName = modelName + 'Copied'
|
|
392
389
|
const actionName = 'copy' + modelName
|
|
393
390
|
const accessControl = config.copyAccessControl
|
|
394
391
|
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
@@ -425,7 +422,6 @@ function defineCopyTrigger(config, context) {
|
|
|
425
422
|
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others,
|
|
426
423
|
identifiers
|
|
427
424
|
} = context
|
|
428
|
-
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Copied'
|
|
429
425
|
const actionName = 'copy' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
430
426
|
const triggerName = `${service.name}_${actionName}`
|
|
431
427
|
const trigger = new TriggerDefinition({
|
package/utils.js
CHANGED
|
@@ -164,7 +164,7 @@ export function defineDeleteByOwnerEvents(config, context, generateId) {
|
|
|
164
164
|
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName, otherPropertyNames, reverseRelationWord
|
|
165
165
|
} = context
|
|
166
166
|
for(const propertyName of otherPropertyNames) {
|
|
167
|
-
const eventName =
|
|
167
|
+
const eventName = modelName + 'DeleteByOwner'
|
|
168
168
|
service.events[eventName] = new EventDefinition({
|
|
169
169
|
name: eventName,
|
|
170
170
|
properties: {
|
package/utilsAny.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "@live-change/framework"
|
|
6
6
|
import { allCombinations } from "./combinations.js"
|
|
7
7
|
import { fireChangeTriggers, registerParentDeleteTriggers } from "./changeTriggers.js"
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
|
|
10
10
|
function extractTypeAndIdParts(otherPropertyNames, properties) {
|
|
11
11
|
const typeAndIdParts = []
|
|
@@ -163,12 +163,12 @@ function prepareAccessControl(accessControl, names) {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
function defineDeleteByOwnerEvents(config, context
|
|
166
|
+
function defineDeleteByOwnerEvents(config, context) {
|
|
167
167
|
const {
|
|
168
168
|
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName, otherPropertyNames, reverseRelationWord
|
|
169
169
|
} = context
|
|
170
170
|
for(const propertyName of otherPropertyNames) {
|
|
171
|
-
const eventName =
|
|
171
|
+
const eventName = modelName + 'DeleteByOwner'
|
|
172
172
|
service.events[eventName] = new EventDefinition({
|
|
173
173
|
name: eventName,
|
|
174
174
|
properties: {
|
|
@@ -196,7 +196,7 @@ function defineDeleteByOwnerEvents(config, context, generateId) {
|
|
|
196
196
|
}])
|
|
197
197
|
const deletePromises = bucket.map(({to}) => runtime.delete(to))
|
|
198
198
|
await Promise.all(deletePromises)
|
|
199
|
-
} while (bucket.length
|
|
199
|
+
} while (bucket.length === bucketSize)
|
|
200
200
|
}
|
|
201
201
|
})
|
|
202
202
|
}
|