@live-change/relations-plugin 0.8.2 → 0.8.4
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/entity.js +21 -0
- package/itemEvents.js +51 -0
- package/package.json +3 -3
- package/propertyEvents.js +29 -0
- package/utils.js +6 -0
- package/utilsAny.js +10 -0
package/entity.js
CHANGED
|
@@ -49,6 +49,14 @@ function defineCreatedEvent(config, context) {
|
|
|
49
49
|
const eventName = modelName + 'Created'
|
|
50
50
|
service.events[eventName] = new EventDefinition({
|
|
51
51
|
name: eventName,
|
|
52
|
+
properties: {
|
|
53
|
+
[modelPropertyName]: {
|
|
54
|
+
type: String,
|
|
55
|
+
},
|
|
56
|
+
data: {
|
|
57
|
+
type: Object
|
|
58
|
+
}
|
|
59
|
+
},
|
|
52
60
|
execute(properties) {
|
|
53
61
|
const id = properties[modelPropertyName]
|
|
54
62
|
return modelRuntime().create({ ...properties.data, id })
|
|
@@ -63,6 +71,14 @@ function defineUpdatedEvent(config, context) {
|
|
|
63
71
|
const eventName = modelName + 'Updated'
|
|
64
72
|
service.events[eventName] = new EventDefinition({
|
|
65
73
|
name: eventName,
|
|
74
|
+
properties: {
|
|
75
|
+
[modelPropertyName]: {
|
|
76
|
+
type: String,
|
|
77
|
+
},
|
|
78
|
+
data: {
|
|
79
|
+
type: Object
|
|
80
|
+
}
|
|
81
|
+
},
|
|
66
82
|
execute(properties) {
|
|
67
83
|
const id = properties[modelPropertyName]
|
|
68
84
|
return modelRuntime().update(id, { ...properties.data, id })
|
|
@@ -77,6 +93,11 @@ function defineDeletedEvent(config, context) {
|
|
|
77
93
|
const eventName = modelName + 'Deleted'
|
|
78
94
|
service.events[eventName] = new EventDefinition({
|
|
79
95
|
name: eventName,
|
|
96
|
+
properties: {
|
|
97
|
+
[modelPropertyName]: {
|
|
98
|
+
type: String,
|
|
99
|
+
}
|
|
100
|
+
},
|
|
80
101
|
execute(properties) {
|
|
81
102
|
const id = properties[modelPropertyName]
|
|
82
103
|
return modelRuntime().delete(id)
|
package/itemEvents.js
CHANGED
|
@@ -9,6 +9,18 @@ function defineCreatedEvent(config, context) {
|
|
|
9
9
|
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Created'
|
|
10
10
|
service.events[eventName] = new EventDefinition({
|
|
11
11
|
name: eventName,
|
|
12
|
+
properties: {
|
|
13
|
+
[modelPropertyName]: {
|
|
14
|
+
type: String,
|
|
15
|
+
validation: ['nonEmpty']
|
|
16
|
+
},
|
|
17
|
+
data: {
|
|
18
|
+
type: Object
|
|
19
|
+
},
|
|
20
|
+
identifiers: {
|
|
21
|
+
type: Object
|
|
22
|
+
}
|
|
23
|
+
},
|
|
12
24
|
execute(properties) {
|
|
13
25
|
const id = properties[modelPropertyName]
|
|
14
26
|
return modelRuntime().create({ ...properties.data, ...properties.identifiers, id })
|
|
@@ -23,6 +35,18 @@ function defineUpdatedEvent(config, context) {
|
|
|
23
35
|
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Updated'
|
|
24
36
|
service.events[eventName] = new EventDefinition({
|
|
25
37
|
name: eventName,
|
|
38
|
+
properties: {
|
|
39
|
+
[modelPropertyName]: {
|
|
40
|
+
type: String,
|
|
41
|
+
validation: ['nonEmpty']
|
|
42
|
+
},
|
|
43
|
+
data: {
|
|
44
|
+
type: Object
|
|
45
|
+
},
|
|
46
|
+
identifiers: {
|
|
47
|
+
type: Object
|
|
48
|
+
}
|
|
49
|
+
},
|
|
26
50
|
execute(properties) {
|
|
27
51
|
const id = properties[modelPropertyName]
|
|
28
52
|
return modelRuntime().update(id, { ...properties.data, ...properties.identifiers, id })
|
|
@@ -37,6 +61,15 @@ function defineTransferredEvent(config, context) {
|
|
|
37
61
|
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Transferred'
|
|
38
62
|
service.events[eventName] = new EventDefinition({
|
|
39
63
|
name: eventName,
|
|
64
|
+
properties: {
|
|
65
|
+
[modelPropertyName]: {
|
|
66
|
+
type: String,
|
|
67
|
+
validation: ['nonEmpty']
|
|
68
|
+
},
|
|
69
|
+
to: {
|
|
70
|
+
type: Object
|
|
71
|
+
}
|
|
72
|
+
},
|
|
40
73
|
execute(properties) {
|
|
41
74
|
const id = properties[modelPropertyName]
|
|
42
75
|
return modelRuntime().update(id, { ...properties.to, id })
|
|
@@ -51,6 +84,12 @@ function defineDeletedEvent(config, context) {
|
|
|
51
84
|
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Deleted'
|
|
52
85
|
service.events[eventName] = new EventDefinition({
|
|
53
86
|
name: eventName,
|
|
87
|
+
properties: {
|
|
88
|
+
[modelPropertyName]: {
|
|
89
|
+
type: String,
|
|
90
|
+
validation: ['nonEmpty']
|
|
91
|
+
}
|
|
92
|
+
},
|
|
54
93
|
execute(properties) {
|
|
55
94
|
const id = properties[modelPropertyName]
|
|
56
95
|
return modelRuntime().delete(id)
|
|
@@ -65,6 +104,18 @@ function defineCopyEvent(config, context) {
|
|
|
65
104
|
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Copied'
|
|
66
105
|
service.events[eventName] = new EventDefinition({
|
|
67
106
|
name: eventName,
|
|
107
|
+
properties: {
|
|
108
|
+
[modelPropertyName]: {
|
|
109
|
+
type: String,
|
|
110
|
+
validation: ['nonEmpty']
|
|
111
|
+
},
|
|
112
|
+
data: {
|
|
113
|
+
type: Object
|
|
114
|
+
},
|
|
115
|
+
identifiers: {
|
|
116
|
+
type: Object
|
|
117
|
+
}
|
|
118
|
+
},
|
|
68
119
|
execute(properties) {
|
|
69
120
|
const id = properties[modelPropertyName]
|
|
70
121
|
console.log("COPY CREATE", { ...properties.data, ...properties.identifiers, id })
|
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.4",
|
|
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.4",
|
|
26
26
|
"pluralize": "^8.0.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "cdc66924576866cd3b476e5a0e8956de54c6d8d9"
|
|
29
29
|
}
|
package/propertyEvents.js
CHANGED
|
@@ -9,6 +9,14 @@ function defineSetEvent(config, context, generateId) {
|
|
|
9
9
|
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Set'
|
|
10
10
|
service.events[eventName] = new EventDefinition({
|
|
11
11
|
name: eventName,
|
|
12
|
+
properties: {
|
|
13
|
+
data: {
|
|
14
|
+
type: Object
|
|
15
|
+
},
|
|
16
|
+
identifiers: {
|
|
17
|
+
type: Object
|
|
18
|
+
}
|
|
19
|
+
},
|
|
12
20
|
execute(properties) {
|
|
13
21
|
const id = generateId(otherPropertyNames, properties.identifiers)
|
|
14
22
|
return modelRuntime().create({ ...properties.data, ...properties.identifiers, id })
|
|
@@ -23,6 +31,14 @@ function defineUpdatedEvent(config, context, generateId) {
|
|
|
23
31
|
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Updated'
|
|
24
32
|
service.events[eventName] = new EventDefinition({
|
|
25
33
|
name: eventName,
|
|
34
|
+
properties: {
|
|
35
|
+
data: {
|
|
36
|
+
type: Object
|
|
37
|
+
},
|
|
38
|
+
identifiers: {
|
|
39
|
+
type: Object
|
|
40
|
+
}
|
|
41
|
+
},
|
|
26
42
|
execute(properties) {
|
|
27
43
|
const id = generateId(otherPropertyNames, properties.identifiers)
|
|
28
44
|
return modelRuntime().update(id, { ...properties.data, ...properties.identifiers })
|
|
@@ -37,6 +53,14 @@ function defineTransferredEvent(config, context, generateId) {
|
|
|
37
53
|
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Transferred'
|
|
38
54
|
service.events[eventName] = new EventDefinition({
|
|
39
55
|
name: eventName,
|
|
56
|
+
properties: {
|
|
57
|
+
from: {
|
|
58
|
+
type: Object
|
|
59
|
+
},
|
|
60
|
+
to: {
|
|
61
|
+
type: Object
|
|
62
|
+
}
|
|
63
|
+
},
|
|
40
64
|
async execute(properties) {
|
|
41
65
|
const fromId = generateId(otherPropertyNames, properties.from)
|
|
42
66
|
const toId = generateId(otherPropertyNames, properties.to)
|
|
@@ -59,6 +83,11 @@ function defineResetEvent(config, context, generateId) {
|
|
|
59
83
|
const eventName = joinedOthersPropertyName + reverseRelationWord + modelName + 'Reset'
|
|
60
84
|
service.events[eventName] = new EventDefinition({
|
|
61
85
|
name: eventName,
|
|
86
|
+
properties: {
|
|
87
|
+
identifiers: {
|
|
88
|
+
type: Object
|
|
89
|
+
}
|
|
90
|
+
},
|
|
62
91
|
execute({ identifiers }) {
|
|
63
92
|
const id = generateId(otherPropertyNames, identifiers)
|
|
64
93
|
return modelRuntime().delete(id)
|
package/utils.js
CHANGED
|
@@ -158,6 +158,12 @@ function defineDeleteByOwnerEvents(config, context, generateId) {
|
|
|
158
158
|
const eventName = propertyName + reverseRelationWord + modelName + 'DeleteByOwner'
|
|
159
159
|
service.events[eventName] = new EventDefinition({
|
|
160
160
|
name: eventName,
|
|
161
|
+
properties: {
|
|
162
|
+
owner: {
|
|
163
|
+
type: String,
|
|
164
|
+
validation: ['nonEmpty']
|
|
165
|
+
}
|
|
166
|
+
},
|
|
161
167
|
async execute({owner}) {
|
|
162
168
|
const runtime = modelRuntime()
|
|
163
169
|
const tableName = runtime.tableName
|
package/utilsAny.js
CHANGED
|
@@ -167,6 +167,16 @@ function defineDeleteByOwnerEvents(config, context, generateId) {
|
|
|
167
167
|
const eventName = propertyName + reverseRelationWord + modelName + 'DeleteByOwner'
|
|
168
168
|
service.events[eventName] = new EventDefinition({
|
|
169
169
|
name: eventName,
|
|
170
|
+
properties: {
|
|
171
|
+
ownerType: {
|
|
172
|
+
type: String,
|
|
173
|
+
validation: ['nonEmpty']
|
|
174
|
+
},
|
|
175
|
+
owner: {
|
|
176
|
+
type: String,
|
|
177
|
+
validation: ['nonEmpty']
|
|
178
|
+
}
|
|
179
|
+
},
|
|
170
180
|
async execute({ ownerType, owner }) {
|
|
171
181
|
const runtime = modelRuntime()
|
|
172
182
|
const tableName = runtime.tableName
|