@live-change/relations-plugin 0.5.26 → 0.5.27
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/itemEvents.js +8 -8
- package/package.json +3 -3
- package/pluralRelationAnyUtils.js +1 -0
- package/pluralRelationUtils.js +2 -2
- package/propertyEvents.js +8 -8
- package/singularRelationAnyUtils.js +2 -2
- package/utils.js +1 -1
package/itemEvents.js
CHANGED
|
@@ -3,9 +3,9 @@ const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, E
|
|
|
3
3
|
|
|
4
4
|
function defineCreatedEvent(config, context) {
|
|
5
5
|
const {
|
|
6
|
-
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName
|
|
6
|
+
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName, reverseRelationWord
|
|
7
7
|
} = context
|
|
8
|
-
const eventName = joinedOthersPropertyName +
|
|
8
|
+
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Created'
|
|
9
9
|
service.events[eventName] = new EventDefinition({
|
|
10
10
|
name: eventName,
|
|
11
11
|
execute(properties) {
|
|
@@ -17,9 +17,9 @@ function defineCreatedEvent(config, context) {
|
|
|
17
17
|
|
|
18
18
|
function defineUpdatedEvent(config, context) {
|
|
19
19
|
const {
|
|
20
|
-
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName
|
|
20
|
+
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName, reverseRelationWord
|
|
21
21
|
} = context
|
|
22
|
-
const eventName = joinedOthersPropertyName +
|
|
22
|
+
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Updated'
|
|
23
23
|
service.events[eventName] = new EventDefinition({
|
|
24
24
|
name: eventName,
|
|
25
25
|
execute(properties) {
|
|
@@ -31,9 +31,9 @@ function defineUpdatedEvent(config, context) {
|
|
|
31
31
|
|
|
32
32
|
function defineTransferredEvent(config, context) {
|
|
33
33
|
const {
|
|
34
|
-
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName
|
|
34
|
+
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName, reverseRelationWord
|
|
35
35
|
} = context
|
|
36
|
-
const eventName = joinedOthersPropertyName +
|
|
36
|
+
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Transferred'
|
|
37
37
|
service.events[eventName] = new EventDefinition({
|
|
38
38
|
name: eventName,
|
|
39
39
|
execute(properties) {
|
|
@@ -45,9 +45,9 @@ function defineTransferredEvent(config, context) {
|
|
|
45
45
|
|
|
46
46
|
function defineDeletedEvent(config, context) {
|
|
47
47
|
const {
|
|
48
|
-
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName
|
|
48
|
+
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName, reverseRelationWord
|
|
49
49
|
} = context
|
|
50
|
-
const eventName = joinedOthersPropertyName +
|
|
50
|
+
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Deleted'
|
|
51
51
|
service.events[eventName] = new EventDefinition({
|
|
52
52
|
name: eventName,
|
|
53
53
|
execute(properties) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/relations-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "^0.5.
|
|
24
|
+
"@live-change/framework": "^0.5.27",
|
|
25
25
|
"pluralize": "8.0.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "8cdab8d362794c923e765193d2e786fb29587877"
|
|
28
28
|
}
|
|
@@ -96,6 +96,7 @@ function defineUpdateAction(config, context) {
|
|
|
96
96
|
waitForEvents: true,
|
|
97
97
|
async execute(properties, { client, service }, emit) {
|
|
98
98
|
const id = properties[modelPropertyName]
|
|
99
|
+
if(!id) throw 'no_id'
|
|
99
100
|
const entity = await modelRuntime().get(id)
|
|
100
101
|
if(!entity) throw 'not_found'
|
|
101
102
|
const entityTypeAndIdParts = extractTypeAndIdParts(otherPropertyNames, entity)
|
package/pluralRelationUtils.js
CHANGED
|
@@ -89,7 +89,7 @@ function defineUpdateAction(config, context) {
|
|
|
89
89
|
skipValidation: true,
|
|
90
90
|
//queuedBy: otherPropertyNames,
|
|
91
91
|
waitForEvents: true,
|
|
92
|
-
async execute(properties, {client, service}, emit) {
|
|
92
|
+
async execute(properties, { client, service }, emit) {
|
|
93
93
|
const id = properties[modelPropertyName]
|
|
94
94
|
const entity = await modelRuntime().get(id)
|
|
95
95
|
if(!entity) throw 'not_found'
|
|
@@ -130,7 +130,7 @@ function defineDeleteAction(config, context) {
|
|
|
130
130
|
skipValidation: true,
|
|
131
131
|
//queuedBy: otherPropertyNames,
|
|
132
132
|
waitForEvents: true,
|
|
133
|
-
async execute(properties, {client, service}, emit) {
|
|
133
|
+
async execute(properties, { client, service }, emit) {
|
|
134
134
|
const id = properties[modelPropertyName]
|
|
135
135
|
const entity = await modelRuntime().get(id)
|
|
136
136
|
if(!entity) throw new Error('not_found')
|
package/propertyEvents.js
CHANGED
|
@@ -3,9 +3,9 @@ const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, E
|
|
|
3
3
|
|
|
4
4
|
function defineSetEvent(config, context, generateId) {
|
|
5
5
|
const {
|
|
6
|
-
service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames
|
|
6
|
+
service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames, reverseRelationWord
|
|
7
7
|
} = context
|
|
8
|
-
const eventName = joinedOthersPropertyName +
|
|
8
|
+
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Set'
|
|
9
9
|
service.events[eventName] = new EventDefinition({
|
|
10
10
|
name: eventName,
|
|
11
11
|
execute(properties) {
|
|
@@ -17,9 +17,9 @@ function defineSetEvent(config, context, generateId) {
|
|
|
17
17
|
|
|
18
18
|
function defineUpdatedEvent(config, context, generateId) {
|
|
19
19
|
const {
|
|
20
|
-
service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames
|
|
20
|
+
service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames, reverseRelationWord
|
|
21
21
|
} = context
|
|
22
|
-
const eventName = joinedOthersPropertyName +
|
|
22
|
+
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Updated'
|
|
23
23
|
service.events[eventName] = new EventDefinition({
|
|
24
24
|
name: eventName,
|
|
25
25
|
execute(properties) {
|
|
@@ -31,9 +31,9 @@ function defineUpdatedEvent(config, context, generateId) {
|
|
|
31
31
|
|
|
32
32
|
function defineTransferredEvent(config, context, generateId) {
|
|
33
33
|
const {
|
|
34
|
-
service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames
|
|
34
|
+
service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames, reverseRelationWord
|
|
35
35
|
} = context
|
|
36
|
-
const eventName = joinedOthersPropertyName +
|
|
36
|
+
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Transferred'
|
|
37
37
|
service.events[eventName] = new EventDefinition({
|
|
38
38
|
name: eventName,
|
|
39
39
|
async execute(properties) {
|
|
@@ -53,9 +53,9 @@ function defineTransferredEvent(config, context, generateId) {
|
|
|
53
53
|
|
|
54
54
|
function defineResetEvent(config, context, generateId) {
|
|
55
55
|
const {
|
|
56
|
-
service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames
|
|
56
|
+
service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames, reverseRelationWord
|
|
57
57
|
} = context
|
|
58
|
-
const eventName = joinedOthersPropertyName +
|
|
58
|
+
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Reset'
|
|
59
59
|
service.events[eventName] = new EventDefinition({
|
|
60
60
|
name: eventName,
|
|
61
61
|
execute({ identifiers }) {
|
|
@@ -120,13 +120,13 @@ function defineSetOrUpdateAction(config, context) {
|
|
|
120
120
|
skipValidation: true,
|
|
121
121
|
queuedBy: otherPropertyNames,
|
|
122
122
|
waitForEvents: true,
|
|
123
|
-
async execute(properties, {client, service}, emit) {
|
|
123
|
+
async execute(properties, { client, service }, emit) {
|
|
124
124
|
const identifiers = extractIdentifiersWithTypes(otherPropertyNames, properties)
|
|
125
125
|
const id = generateAnyId(otherPropertyNames, properties)
|
|
126
126
|
const entity = await modelRuntime().get(id)
|
|
127
127
|
const data = extractObjectData(writeableProperties, properties, { ...defaults, ...entity } )
|
|
128
128
|
await App.validation.validate({ ...identifiers, ...data }, validators,
|
|
129
|
-
{source: action, action, service, app, client})
|
|
129
|
+
{ source: action, action, service, app, client })
|
|
130
130
|
emit({
|
|
131
131
|
type: eventName,
|
|
132
132
|
identifiers, data
|
package/utils.js
CHANGED
|
@@ -41,7 +41,7 @@ function extractObjectData(writeableProperties, properties, defaults) {
|
|
|
41
41
|
objectData[propertyName] = properties[propertyName]
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
return App.utils.mergeDeep({}, defaults, objectData)
|
|
44
|
+
return App.utils.mergeDeep({}, defaults, JSON.parse(JSON.stringify(objectData)))
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function defineProperties(model, types, names) {
|