@live-change/relations-plugin 0.6.11 → 0.6.12
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/package.json +3 -3
- package/pluralRelationAnyUtils.js +11 -10
- package/pluralRelationUtils.js +14 -6
- package/propertyOf.js +2 -2
- package/singularRelationAnyUtils.js +17 -12
- package/singularRelationUtils.js +22 -10
- package/utils.js +10 -1
- package/utilsAny.js +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/relations-plugin",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
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.6.
|
|
24
|
+
"@live-change/framework": "^0.6.12",
|
|
25
25
|
"pluralize": "8.0.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "2971bd3c587931c7a33f8f424dd7b22a08e04ab0"
|
|
28
28
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const App = require("@live-change/framework")
|
|
2
2
|
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition } = App
|
|
3
|
-
const { extractTypeAndIdParts, extractIdentifiersWithTypes } = require("./utilsAny.js")
|
|
3
|
+
const { extractTypeAndIdParts, extractIdentifiersWithTypes, prepareAccessControl } = require("./utilsAny.js")
|
|
4
4
|
const { extractObjectData } = require("./utils.js")
|
|
5
5
|
const { extractRange } = App
|
|
6
6
|
|
|
@@ -22,12 +22,7 @@ function defineView(config, context) {
|
|
|
22
22
|
})
|
|
23
23
|
}
|
|
24
24
|
const accessControl = config.readAccessControl || config.writeAccessControl
|
|
25
|
-
|
|
26
|
-
accessControl.objects = accessControl.objects ?? ((params) => otherPropertyNames.map(name => ({
|
|
27
|
-
objectType: params[name + 'Type'],
|
|
28
|
-
object: params[name]
|
|
29
|
-
})))
|
|
30
|
-
}
|
|
25
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
31
26
|
const viewName = joinedOthersPropertyName + context.reverseRelationWord + pluralize(modelName)
|
|
32
27
|
service.views[viewName] = new ViewDefinition({
|
|
33
28
|
name: viewName,
|
|
@@ -59,13 +54,15 @@ function defineCreateAction(config, context) {
|
|
|
59
54
|
} = context
|
|
60
55
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Created'
|
|
61
56
|
const actionName = 'create' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
57
|
+
const accessControl = config.createAccessControl || config.writeAccessControl
|
|
58
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
62
59
|
service.actions[actionName] = new ActionDefinition({
|
|
63
60
|
name: actionName,
|
|
64
61
|
properties: {
|
|
65
62
|
...(model.properties)
|
|
66
63
|
},
|
|
67
64
|
access: config.createAccess || config.writeAccess,
|
|
68
|
-
accessControl
|
|
65
|
+
accessControl,
|
|
69
66
|
skipValidation: true,
|
|
70
67
|
//queuedBy: otherPropertyNames,
|
|
71
68
|
waitForEvents: true,
|
|
@@ -95,6 +92,8 @@ function defineUpdateAction(config, context) {
|
|
|
95
92
|
} = context
|
|
96
93
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Updated'
|
|
97
94
|
const actionName = 'update' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
95
|
+
const accessControl = config.updateAccessControl || config.writeAccessControl
|
|
96
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
98
97
|
service.actions[actionName] = new ActionDefinition({
|
|
99
98
|
name: actionName,
|
|
100
99
|
properties: {
|
|
@@ -105,7 +104,7 @@ function defineUpdateAction(config, context) {
|
|
|
105
104
|
...(model.properties)
|
|
106
105
|
},
|
|
107
106
|
access: config.updateAccess || config.writeAccess,
|
|
108
|
-
accessControl
|
|
107
|
+
accessControl,
|
|
109
108
|
skipValidation: true,
|
|
110
109
|
//queuedBy: otherPropertyNames,
|
|
111
110
|
waitForEvents: true,
|
|
@@ -142,6 +141,8 @@ function defineDeleteAction(config, context) {
|
|
|
142
141
|
} = context
|
|
143
142
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Deleted'
|
|
144
143
|
const actionName = 'delete' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
144
|
+
const accessControl = config.deleteAccessControl || config.writeAccessControl
|
|
145
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
145
146
|
service.actions[actionName] = new ActionDefinition({
|
|
146
147
|
name: actionName,
|
|
147
148
|
properties: {
|
|
@@ -152,7 +153,7 @@ function defineDeleteAction(config, context) {
|
|
|
152
153
|
...identifiers
|
|
153
154
|
},
|
|
154
155
|
access: config.deleteAccess || config.writeAccess,
|
|
155
|
-
accessControl
|
|
156
|
+
accessControl,
|
|
156
157
|
skipValidation: true,
|
|
157
158
|
//queuedBy: otherPropertyNames,
|
|
158
159
|
waitForEvents: true,
|
package/pluralRelationUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const App = require("@live-change/framework")
|
|
2
2
|
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition } = App
|
|
3
|
-
const { extractIdParts, extractRange, extractIdentifiers, extractObjectData } = require("./utils.js")
|
|
3
|
+
const { extractIdParts, extractRange, extractIdentifiers, extractObjectData, prepareAccessControl } = require("./utils.js")
|
|
4
4
|
|
|
5
5
|
const pluralize = require('pluralize')
|
|
6
6
|
|
|
@@ -16,6 +16,8 @@ function defineView(config, context) {
|
|
|
16
16
|
})
|
|
17
17
|
}
|
|
18
18
|
const viewName = joinedOthersPropertyName + context.reverseRelationWord + pluralize(modelName)
|
|
19
|
+
const accessControl = config.readAccessControl || config.writeAccessControl
|
|
20
|
+
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
19
21
|
service.views[viewName] = new ViewDefinition({
|
|
20
22
|
name: viewName,
|
|
21
23
|
properties: {
|
|
@@ -42,17 +44,19 @@ function defineView(config, context) {
|
|
|
42
44
|
function defineCreateAction(config, context) {
|
|
43
45
|
const {
|
|
44
46
|
service, app, model, defaults, modelPropertyName, modelRuntime,
|
|
45
|
-
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName
|
|
47
|
+
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
46
48
|
} = context
|
|
47
49
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Created'
|
|
48
50
|
const actionName = 'set' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
51
|
+
const accessControl = config.createAccessControl || config.writeAccessControl
|
|
52
|
+
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
49
53
|
service.actions[actionName] = new ActionDefinition({
|
|
50
54
|
name: actionName,
|
|
51
55
|
properties: {
|
|
52
56
|
...(model.properties)
|
|
53
57
|
},
|
|
54
58
|
access: config.createAccess || config.writeAccess,
|
|
55
|
-
accessControl
|
|
59
|
+
accessControl,
|
|
56
60
|
skipValidation: true,
|
|
57
61
|
//queuedBy: otherPropertyNames,
|
|
58
62
|
waitForEvents: true,
|
|
@@ -78,10 +82,12 @@ function defineCreateAction(config, context) {
|
|
|
78
82
|
function defineUpdateAction(config, context) {
|
|
79
83
|
const {
|
|
80
84
|
service, app, model, modelRuntime, modelPropertyName,
|
|
81
|
-
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName
|
|
85
|
+
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
82
86
|
} = context
|
|
83
87
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Updated'
|
|
84
88
|
const actionName = 'update' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
89
|
+
const accessControl = config.updateAccessControl || config.writeAccessControl
|
|
90
|
+
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
85
91
|
service.actions[actionName] = new ActionDefinition({
|
|
86
92
|
name: actionName,
|
|
87
93
|
properties: {
|
|
@@ -120,17 +126,19 @@ function defineUpdateAction(config, context) {
|
|
|
120
126
|
function defineDeleteAction(config, context) {
|
|
121
127
|
const {
|
|
122
128
|
service, app, model, modelRuntime, modelPropertyName,
|
|
123
|
-
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName
|
|
129
|
+
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
124
130
|
} = context
|
|
125
131
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Deleted'
|
|
126
132
|
const actionName = 'delete' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
133
|
+
const accessControl = config.deleteAccessControl || config.writeAccessControl
|
|
134
|
+
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
127
135
|
service.actions[actionName] = new ActionDefinition({
|
|
128
136
|
name: actionName,
|
|
129
137
|
properties: {
|
|
130
138
|
...(model.properties)
|
|
131
139
|
},
|
|
132
140
|
access: config.deleteAccess || config.writeAccess,
|
|
133
|
-
accessControl
|
|
141
|
+
accessControl,
|
|
134
142
|
skipValidation: true,
|
|
135
143
|
//queuedBy: otherPropertyNames,
|
|
136
144
|
waitForEvents: true,
|
package/propertyOf.js
CHANGED
|
@@ -19,8 +19,8 @@ module.exports = function(service, app) {
|
|
|
19
19
|
addAccessControlParents(context)
|
|
20
20
|
defineIndex(context.model, context.joinedOthersClassName, context.otherPropertyNames)
|
|
21
21
|
|
|
22
|
-
if(config.readAccess || config.readAccessControl || config.writeAccessControl) {
|
|
23
|
-
defineView({ ...config
|
|
22
|
+
if(config.readAccess || config.writeAccess || config.readAccessControl || config.writeAccessControl) {
|
|
23
|
+
defineView({ ...config }, context)
|
|
24
24
|
}
|
|
25
25
|
if(config.views) {
|
|
26
26
|
for(const view of config.views) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const App = require("@live-change/framework")
|
|
2
2
|
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition } = App
|
|
3
|
-
const { extractTypeAndIdParts, extractIdentifiersWithTypes, generateAnyId } = require("./utilsAny.js")
|
|
3
|
+
const { extractTypeAndIdParts, extractIdentifiersWithTypes, generateAnyId, prepareAccessControl } = require("./utilsAny.js")
|
|
4
4
|
const { extractObjectData } = require("./utils.js")
|
|
5
5
|
const { allCombinations } = require("./combinations.js")
|
|
6
6
|
|
|
@@ -36,12 +36,7 @@ function defineObjectView(config, context) {
|
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
38
|
const accessControl = config.singleAccessControl || config.readAccessControl || config.writeAccessControl
|
|
39
|
-
|
|
40
|
-
accessControl.objects = accessControl.objects ?? ((params) => otherPropertyNames.map(name => ({
|
|
41
|
-
objectType: params[name + 'Type'],
|
|
42
|
-
object: params[name]
|
|
43
|
-
})))
|
|
44
|
-
}
|
|
39
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
45
40
|
const viewName = config.name || ((config.prefix ? (config.prefix + joinedOthersClassName) : joinedOthersPropertyName) +
|
|
46
41
|
context.reverseRelationWord + modelName + (config.suffix || ''))
|
|
47
42
|
service.views[viewName] = new ViewDefinition({
|
|
@@ -67,6 +62,8 @@ function defineRangeViews(config, context) {
|
|
|
67
62
|
const { service, modelRuntime, otherPropertyNames, joinedOthersPropertyName, joinedOthersClassName,
|
|
68
63
|
modelName, others, model } = context
|
|
69
64
|
const identifierCombinations = allCombinations(otherPropertyNames).slice(0, -1)
|
|
65
|
+
const accessControl = config.listAccessControl || config.readAccessControl || config.writeAccessControl
|
|
66
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
70
67
|
for(const combination of identifierCombinations) {
|
|
71
68
|
const propsUpperCase = combination.map(prop => prop[0].toUpperCase() + prop.slice(1))
|
|
72
69
|
const indexName = 'by' + combination.map(prop => prop[0].toUpperCase() + prop.slice(1))
|
|
@@ -81,7 +78,7 @@ function defineRangeViews(config, context) {
|
|
|
81
78
|
...App.rangeProperties,
|
|
82
79
|
},
|
|
83
80
|
access: config.listAccess || config.readAccess,
|
|
84
|
-
accessControl
|
|
81
|
+
accessControl,
|
|
85
82
|
daoPath(params, { client, context }) {
|
|
86
83
|
const owner = []
|
|
87
84
|
for (const key of combination) {
|
|
@@ -101,13 +98,15 @@ function defineSetAction(config, context) {
|
|
|
101
98
|
|
|
102
99
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Set'
|
|
103
100
|
const actionName = 'set' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
101
|
+
const accessControl = config.setAccessControl || config.writeAccessControl
|
|
102
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
104
103
|
service.actions[actionName] = new ActionDefinition({
|
|
105
104
|
name: actionName,
|
|
106
105
|
properties: {
|
|
107
106
|
...(model.properties)
|
|
108
107
|
},
|
|
109
108
|
access: config.setAccess || config.writeAccess,
|
|
110
|
-
accessControl
|
|
109
|
+
accessControl,
|
|
111
110
|
skipValidation: true,
|
|
112
111
|
queuedBy: otherPropertyNames,
|
|
113
112
|
waitForEvents: true,
|
|
@@ -133,13 +132,15 @@ function defineUpdateAction(config, context) {
|
|
|
133
132
|
} = context
|
|
134
133
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Updated'
|
|
135
134
|
const actionName = 'update' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
135
|
+
const accessControl = config.updateAccessControl || config.writeAccessControl
|
|
136
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
136
137
|
service.actions[actionName] = new ActionDefinition({
|
|
137
138
|
name: actionName,
|
|
138
139
|
properties: {
|
|
139
140
|
...(model.properties)
|
|
140
141
|
},
|
|
141
142
|
access: config.updateAccess || config.writeAccess,
|
|
142
|
-
accessControl
|
|
143
|
+
accessControl,
|
|
143
144
|
skipValidation: true,
|
|
144
145
|
queuedBy: otherPropertyNames,
|
|
145
146
|
waitForEvents: true,
|
|
@@ -168,13 +169,15 @@ function defineSetOrUpdateAction(config, context) {
|
|
|
168
169
|
} = context
|
|
169
170
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Updated'
|
|
170
171
|
const actionName = 'setOrUpdate' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
172
|
+
const accessControl = config.setOrUpdateAccessControl || config.writeAccessControl
|
|
173
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
171
174
|
service.actions[actionName] = new ActionDefinition({
|
|
172
175
|
name: actionName,
|
|
173
176
|
properties: {
|
|
174
177
|
...(model.properties)
|
|
175
178
|
},
|
|
176
179
|
access: config.updateAccess || config.writeAccess,
|
|
177
|
-
accessControl
|
|
180
|
+
accessControl,
|
|
178
181
|
skipValidation: true,
|
|
179
182
|
queuedBy: otherPropertyNames,
|
|
180
183
|
waitForEvents: true,
|
|
@@ -202,6 +205,8 @@ function defineResetAction(config, context) {
|
|
|
202
205
|
} = context
|
|
203
206
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Reset'
|
|
204
207
|
const actionName = 'reset' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
208
|
+
const accessControl = config.resetAccessControl || config.writeAccessControl
|
|
209
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
205
210
|
service.actions[actionName] = new ActionDefinition({
|
|
206
211
|
name: actionName,
|
|
207
212
|
properties: {
|
|
@@ -212,7 +217,7 @@ function defineResetAction(config, context) {
|
|
|
212
217
|
...identifiers
|
|
213
218
|
},
|
|
214
219
|
access: config.resetAccess || config.writeAccess,
|
|
215
|
-
accessControl
|
|
220
|
+
accessControl,
|
|
216
221
|
queuedBy: otherPropertyNames,
|
|
217
222
|
waitForEvents: true,
|
|
218
223
|
async execute(properties, {client, service}, emit) {
|
package/singularRelationUtils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const App = require("@live-change/framework")
|
|
2
2
|
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition } = App
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
extractIdentifiers, extractObjectData, generateId, extractIdParts, prepareAccessControl
|
|
5
|
+
} = require("./utils.js")
|
|
4
6
|
|
|
5
7
|
function defineView(config, context) {
|
|
6
8
|
const { service, modelRuntime, otherPropertyNames, joinedOthersPropertyName, joinedOthersClassName,
|
|
@@ -14,6 +16,8 @@ function defineView(config, context) {
|
|
|
14
16
|
}
|
|
15
17
|
const viewName = config.name || ((config.prefix ? (config.prefix + joinedOthersClassName) : joinedOthersPropertyName) +
|
|
16
18
|
'Owned' + modelName + (config.suffix || ''))
|
|
19
|
+
const accessControl = config.readAccessControl || config.writeAccessControl
|
|
20
|
+
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
17
21
|
service.views[viewName] = new ViewDefinition({
|
|
18
22
|
name: viewName,
|
|
19
23
|
properties: {
|
|
@@ -22,8 +26,8 @@ function defineView(config, context) {
|
|
|
22
26
|
returns: {
|
|
23
27
|
type: model,
|
|
24
28
|
},
|
|
25
|
-
access: config.readAccess,
|
|
26
|
-
accessControl
|
|
29
|
+
access: config.readAccess || config.writeAccess,
|
|
30
|
+
accessControl,
|
|
27
31
|
daoPath(properties, { client, context }) {
|
|
28
32
|
const idParts = extractIdParts(otherPropertyNames, properties)
|
|
29
33
|
const id = idParts.length > 1 ? idParts.map(p => JSON.stringify(p)).join(':') : idParts[0]
|
|
@@ -36,17 +40,19 @@ function defineView(config, context) {
|
|
|
36
40
|
function defineSetAction(config, context) {
|
|
37
41
|
const {
|
|
38
42
|
service, app, model, defaults,
|
|
39
|
-
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName
|
|
43
|
+
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
40
44
|
} = context
|
|
41
45
|
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Set'
|
|
42
46
|
const actionName = 'set' + joinedOthersClassName + 'Owned' + modelName
|
|
47
|
+
const accessControl = config.setAccessControl || config.writeAccessControl
|
|
48
|
+
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
43
49
|
service.actions[actionName] = new ActionDefinition({
|
|
44
50
|
name: actionName,
|
|
45
51
|
properties: {
|
|
46
52
|
...(model.properties)
|
|
47
53
|
},
|
|
48
54
|
access: config.setAccess || config.writeAccess,
|
|
49
|
-
accessControl
|
|
55
|
+
accessControl,
|
|
50
56
|
skipValidation: true,
|
|
51
57
|
queuedBy: otherPropertyNames,
|
|
52
58
|
waitForEvents: true,
|
|
@@ -68,17 +74,19 @@ function defineSetAction(config, context) {
|
|
|
68
74
|
function defineUpdateAction(config, context) {
|
|
69
75
|
const {
|
|
70
76
|
service, app, model, modelRuntime,
|
|
71
|
-
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName
|
|
77
|
+
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
72
78
|
} = context
|
|
73
79
|
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Updated'
|
|
74
80
|
const actionName = 'update' + joinedOthersClassName + 'Owned' + modelName
|
|
81
|
+
const accessControl = config.updateAccessControl || config.writeAccessControl
|
|
82
|
+
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
75
83
|
service.actions[actionName] = new ActionDefinition({
|
|
76
84
|
name: actionName,
|
|
77
85
|
properties: {
|
|
78
86
|
...(model.properties)
|
|
79
87
|
},
|
|
80
88
|
access: config.updateAccess || config.writeAccess,
|
|
81
|
-
accessControl
|
|
89
|
+
accessControl,
|
|
82
90
|
skipValidation: true,
|
|
83
91
|
queuedBy: otherPropertyNames,
|
|
84
92
|
waitForEvents: true,
|
|
@@ -103,10 +111,12 @@ function defineUpdateAction(config, context) {
|
|
|
103
111
|
function defineSetOrUpdateAction(config, context) {
|
|
104
112
|
const {
|
|
105
113
|
service, app, model, defaults, modelRuntime,
|
|
106
|
-
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName
|
|
114
|
+
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
107
115
|
} = context
|
|
108
116
|
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Updated'
|
|
109
117
|
const actionName = 'update' + joinedOthersClassName + 'Owned' + modelName
|
|
118
|
+
const accessControl = config.updateAccessControl || config.writeAccessControl
|
|
119
|
+
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
110
120
|
service.actions[actionName] = new ActionDefinition({
|
|
111
121
|
name: actionName,
|
|
112
122
|
properties: {
|
|
@@ -137,10 +147,12 @@ function defineSetOrUpdateAction(config, context) {
|
|
|
137
147
|
function defineResetAction(config, context) {
|
|
138
148
|
const {
|
|
139
149
|
service, modelRuntime, modelPropertyName,
|
|
140
|
-
otherPropertyNames, joinedOthersPropertyName, modelName, joinedOthersClassName, model
|
|
150
|
+
otherPropertyNames, joinedOthersPropertyName, modelName, joinedOthersClassName, model, others
|
|
141
151
|
} = context
|
|
142
152
|
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Reset'
|
|
143
153
|
const actionName = 'reset' + joinedOthersClassName + 'Owned' + modelName
|
|
154
|
+
const accessControl = config.resetAccessControl || config.writeAccessControl
|
|
155
|
+
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
144
156
|
service.actions[actionName] = new ActionDefinition({
|
|
145
157
|
name: actionName,
|
|
146
158
|
properties: {
|
|
@@ -150,7 +162,7 @@ function defineResetAction(config, context) {
|
|
|
150
162
|
}
|
|
151
163
|
},
|
|
152
164
|
access: config.resetAccess || config.writeAccess,
|
|
153
|
-
accessControl
|
|
165
|
+
accessControl,
|
|
154
166
|
queuedBy: otherPropertyNames,
|
|
155
167
|
waitForEvents: true,
|
|
156
168
|
async execute(properties, { client, service }, emit) {
|
package/utils.js
CHANGED
|
@@ -133,7 +133,16 @@ function addAccessControlParents(context) {
|
|
|
133
133
|
)
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
function prepareAccessControl(accessControl, names, types) {
|
|
137
|
+
if(typeof accessControl == 'object') {
|
|
138
|
+
accessControl.objects = accessControl.objects ?? ((params) => names.map((name, index) => ({
|
|
139
|
+
objectType: types[index],
|
|
140
|
+
object: params[name]
|
|
141
|
+
})))
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
136
145
|
module.exports = {
|
|
137
146
|
extractIdParts, extractIdentifiers, extractObjectData, defineProperties, defineIndex,
|
|
138
|
-
processModelsAnnotation, generateId, addAccessControlParents
|
|
147
|
+
processModelsAnnotation, generateId, addAccessControlParents, prepareAccessControl
|
|
139
148
|
}
|
package/utilsAny.js
CHANGED
|
@@ -134,9 +134,19 @@ function addAccessControlAnyParents(context) {
|
|
|
134
134
|
)
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
function prepareAccessControl(accessControl, names) {
|
|
138
|
+
if(typeof accessControl == 'object') {
|
|
139
|
+
accessControl.objects = accessControl.objects ?? ((params) => names.map(name => ({
|
|
140
|
+
objectType: params[name + 'Type'],
|
|
141
|
+
object: params[name]
|
|
142
|
+
})))
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
137
146
|
module.exports = {
|
|
138
147
|
extractTypeAndIdParts, extractIdentifiersWithTypes, defineAnyProperties,
|
|
139
148
|
defineAnyIndex, defineAnyIndexes,
|
|
140
149
|
processModelsAnyAnnotation, generateAnyId,
|
|
141
|
-
addAccessControlAnyParents
|
|
150
|
+
addAccessControlAnyParents,
|
|
151
|
+
prepareAccessControl
|
|
142
152
|
}
|