@live-change/relations-plugin 0.6.10 → 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/itemOfAny.js +1 -1
- package/package.json +3 -3
- package/pluralRelationAnyUtils.js +14 -6
- package/pluralRelationUtils.js +14 -6
- package/propertyOf.js +2 -2
- package/propertyOfAny.js +5 -3
- package/singularRelationAnyUtils.js +21 -10
- package/singularRelationUtils.js +22 -10
- package/utils.js +10 -1
- package/utilsAny.js +11 -1
package/itemOfAny.js
CHANGED
|
@@ -27,7 +27,7 @@ module.exports = function(service, app) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
if(config.readAccess || config.readAccessControl || config.writeAccessControl) {
|
|
30
|
+
if(config.readAccess || config.writeAccess || config.readAccessControl || config.writeAccessControl) {
|
|
31
31
|
defineView(config, context)
|
|
32
32
|
// TODO: multiple views with all properties combinations
|
|
33
33
|
}
|
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
|
|
|
@@ -21,6 +21,8 @@ function defineView(config, context) {
|
|
|
21
21
|
validation: ['nonEmpty']
|
|
22
22
|
})
|
|
23
23
|
}
|
|
24
|
+
const accessControl = config.readAccessControl || config.writeAccessControl
|
|
25
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
24
26
|
const viewName = joinedOthersPropertyName + context.reverseRelationWord + pluralize(modelName)
|
|
25
27
|
service.views[viewName] = new ViewDefinition({
|
|
26
28
|
name: viewName,
|
|
@@ -34,8 +36,8 @@ function defineView(config, context) {
|
|
|
34
36
|
type: model
|
|
35
37
|
}
|
|
36
38
|
},
|
|
37
|
-
access: config.readAccess,
|
|
38
|
-
accessControl
|
|
39
|
+
access: config.readAccess || config.writeAccess,
|
|
40
|
+
accessControl,
|
|
39
41
|
daoPath(properties, { client, context }) {
|
|
40
42
|
const typeAndIdParts = extractTypeAndIdParts(otherPropertyNames, properties)
|
|
41
43
|
const range = extractRange(properties)
|
|
@@ -52,13 +54,15 @@ function defineCreateAction(config, context) {
|
|
|
52
54
|
} = context
|
|
53
55
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Created'
|
|
54
56
|
const actionName = 'create' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
57
|
+
const accessControl = config.createAccessControl || config.writeAccessControl
|
|
58
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
55
59
|
service.actions[actionName] = new ActionDefinition({
|
|
56
60
|
name: actionName,
|
|
57
61
|
properties: {
|
|
58
62
|
...(model.properties)
|
|
59
63
|
},
|
|
60
64
|
access: config.createAccess || config.writeAccess,
|
|
61
|
-
accessControl
|
|
65
|
+
accessControl,
|
|
62
66
|
skipValidation: true,
|
|
63
67
|
//queuedBy: otherPropertyNames,
|
|
64
68
|
waitForEvents: true,
|
|
@@ -88,6 +92,8 @@ function defineUpdateAction(config, context) {
|
|
|
88
92
|
} = context
|
|
89
93
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Updated'
|
|
90
94
|
const actionName = 'update' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
95
|
+
const accessControl = config.updateAccessControl || config.writeAccessControl
|
|
96
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
91
97
|
service.actions[actionName] = new ActionDefinition({
|
|
92
98
|
name: actionName,
|
|
93
99
|
properties: {
|
|
@@ -98,7 +104,7 @@ function defineUpdateAction(config, context) {
|
|
|
98
104
|
...(model.properties)
|
|
99
105
|
},
|
|
100
106
|
access: config.updateAccess || config.writeAccess,
|
|
101
|
-
accessControl
|
|
107
|
+
accessControl,
|
|
102
108
|
skipValidation: true,
|
|
103
109
|
//queuedBy: otherPropertyNames,
|
|
104
110
|
waitForEvents: true,
|
|
@@ -135,6 +141,8 @@ function defineDeleteAction(config, context) {
|
|
|
135
141
|
} = context
|
|
136
142
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Deleted'
|
|
137
143
|
const actionName = 'delete' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
144
|
+
const accessControl = config.deleteAccessControl || config.writeAccessControl
|
|
145
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
138
146
|
service.actions[actionName] = new ActionDefinition({
|
|
139
147
|
name: actionName,
|
|
140
148
|
properties: {
|
|
@@ -145,7 +153,7 @@ function defineDeleteAction(config, context) {
|
|
|
145
153
|
...identifiers
|
|
146
154
|
},
|
|
147
155
|
access: config.deleteAccess || config.writeAccess,
|
|
148
|
-
accessControl
|
|
156
|
+
accessControl,
|
|
149
157
|
skipValidation: true,
|
|
150
158
|
//queuedBy: otherPropertyNames,
|
|
151
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) {
|
package/propertyOfAny.js
CHANGED
|
@@ -22,9 +22,11 @@ module.exports = function(service, app) {
|
|
|
22
22
|
addAccessControlAnyParents(context)
|
|
23
23
|
defineAnyIndexes(context.model, context.otherPropertyNames)
|
|
24
24
|
|
|
25
|
-
if(config.readAccess) {
|
|
26
|
-
defineObjectView(
|
|
27
|
-
|
|
25
|
+
if(config.singleAccess || config.readAccess || config.singleAccessControl || config.readAccessControl) {
|
|
26
|
+
defineObjectView(config, context)
|
|
27
|
+
}
|
|
28
|
+
if(config.listAccess || config.readAccess || config.listAccessControl || config.readAccessControl) {
|
|
29
|
+
defineRangeViews(config, context)
|
|
28
30
|
}
|
|
29
31
|
if(config.views) {
|
|
30
32
|
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
|
|
|
@@ -35,6 +35,8 @@ function defineObjectView(config, context) {
|
|
|
35
35
|
validation: ['nonEmpty']
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
|
+
const accessControl = config.singleAccessControl || config.readAccessControl || config.writeAccessControl
|
|
39
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
38
40
|
const viewName = config.name || ((config.prefix ? (config.prefix + joinedOthersClassName) : joinedOthersPropertyName) +
|
|
39
41
|
context.reverseRelationWord + modelName + (config.suffix || ''))
|
|
40
42
|
service.views[viewName] = new ViewDefinition({
|
|
@@ -45,8 +47,8 @@ function defineObjectView(config, context) {
|
|
|
45
47
|
returns: {
|
|
46
48
|
type: model,
|
|
47
49
|
},
|
|
48
|
-
access: config.readAccess,
|
|
49
|
-
accessControl
|
|
50
|
+
access: config.singleAccess || config.readAccess,
|
|
51
|
+
accessControl,
|
|
50
52
|
daoPath(properties, { client, context }) {
|
|
51
53
|
const typeAndIdParts = extractTypeAndIdParts(otherPropertyNames, properties)
|
|
52
54
|
const id = typeAndIdParts.length > 1 ? typeAndIdParts.map(p => JSON.stringify(p)).join(':') : idParts[0]
|
|
@@ -60,6 +62,8 @@ function defineRangeViews(config, context) {
|
|
|
60
62
|
const { service, modelRuntime, otherPropertyNames, joinedOthersPropertyName, joinedOthersClassName,
|
|
61
63
|
modelName, others, model } = context
|
|
62
64
|
const identifierCombinations = allCombinations(otherPropertyNames).slice(0, -1)
|
|
65
|
+
const accessControl = config.listAccessControl || config.readAccessControl || config.writeAccessControl
|
|
66
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
63
67
|
for(const combination of identifierCombinations) {
|
|
64
68
|
const propsUpperCase = combination.map(prop => prop[0].toUpperCase() + prop.slice(1))
|
|
65
69
|
const indexName = 'by' + combination.map(prop => prop[0].toUpperCase() + prop.slice(1))
|
|
@@ -73,9 +77,8 @@ function defineRangeViews(config, context) {
|
|
|
73
77
|
...identifiers,
|
|
74
78
|
...App.rangeProperties,
|
|
75
79
|
},
|
|
76
|
-
access
|
|
77
|
-
|
|
78
|
-
},
|
|
80
|
+
access: config.listAccess || config.readAccess,
|
|
81
|
+
accessControl,
|
|
79
82
|
daoPath(params, { client, context }) {
|
|
80
83
|
const owner = []
|
|
81
84
|
for (const key of combination) {
|
|
@@ -95,13 +98,15 @@ function defineSetAction(config, context) {
|
|
|
95
98
|
|
|
96
99
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Set'
|
|
97
100
|
const actionName = 'set' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
101
|
+
const accessControl = config.setAccessControl || config.writeAccessControl
|
|
102
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
98
103
|
service.actions[actionName] = new ActionDefinition({
|
|
99
104
|
name: actionName,
|
|
100
105
|
properties: {
|
|
101
106
|
...(model.properties)
|
|
102
107
|
},
|
|
103
108
|
access: config.setAccess || config.writeAccess,
|
|
104
|
-
accessControl
|
|
109
|
+
accessControl,
|
|
105
110
|
skipValidation: true,
|
|
106
111
|
queuedBy: otherPropertyNames,
|
|
107
112
|
waitForEvents: true,
|
|
@@ -127,13 +132,15 @@ function defineUpdateAction(config, context) {
|
|
|
127
132
|
} = context
|
|
128
133
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Updated'
|
|
129
134
|
const actionName = 'update' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
135
|
+
const accessControl = config.updateAccessControl || config.writeAccessControl
|
|
136
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
130
137
|
service.actions[actionName] = new ActionDefinition({
|
|
131
138
|
name: actionName,
|
|
132
139
|
properties: {
|
|
133
140
|
...(model.properties)
|
|
134
141
|
},
|
|
135
142
|
access: config.updateAccess || config.writeAccess,
|
|
136
|
-
accessControl
|
|
143
|
+
accessControl,
|
|
137
144
|
skipValidation: true,
|
|
138
145
|
queuedBy: otherPropertyNames,
|
|
139
146
|
waitForEvents: true,
|
|
@@ -162,13 +169,15 @@ function defineSetOrUpdateAction(config, context) {
|
|
|
162
169
|
} = context
|
|
163
170
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Updated'
|
|
164
171
|
const actionName = 'setOrUpdate' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
172
|
+
const accessControl = config.setOrUpdateAccessControl || config.writeAccessControl
|
|
173
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
165
174
|
service.actions[actionName] = new ActionDefinition({
|
|
166
175
|
name: actionName,
|
|
167
176
|
properties: {
|
|
168
177
|
...(model.properties)
|
|
169
178
|
},
|
|
170
179
|
access: config.updateAccess || config.writeAccess,
|
|
171
|
-
accessControl
|
|
180
|
+
accessControl,
|
|
172
181
|
skipValidation: true,
|
|
173
182
|
queuedBy: otherPropertyNames,
|
|
174
183
|
waitForEvents: true,
|
|
@@ -196,6 +205,8 @@ function defineResetAction(config, context) {
|
|
|
196
205
|
} = context
|
|
197
206
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Reset'
|
|
198
207
|
const actionName = 'reset' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
208
|
+
const accessControl = config.resetAccessControl || config.writeAccessControl
|
|
209
|
+
prepareAccessControl(accessControl, otherPropertyNames)
|
|
199
210
|
service.actions[actionName] = new ActionDefinition({
|
|
200
211
|
name: actionName,
|
|
201
212
|
properties: {
|
|
@@ -206,7 +217,7 @@ function defineResetAction(config, context) {
|
|
|
206
217
|
...identifiers
|
|
207
218
|
},
|
|
208
219
|
access: config.resetAccess || config.writeAccess,
|
|
209
|
-
accessControl
|
|
220
|
+
accessControl,
|
|
210
221
|
queuedBy: otherPropertyNames,
|
|
211
222
|
waitForEvents: true,
|
|
212
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
|
}
|