@live-change/relations-plugin 0.7.2 → 0.7.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 +12 -4
- package/package.json +3 -3
package/entity.js
CHANGED
|
@@ -7,6 +7,14 @@ const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, E
|
|
|
7
7
|
|
|
8
8
|
const annotation = 'entity'
|
|
9
9
|
|
|
10
|
+
function entityAccessControl({service, modelName, modelPropertyName}, accessControl) {
|
|
11
|
+
if(!accessControl) return undefined
|
|
12
|
+
return {
|
|
13
|
+
objects: p => [{ objectType: service.name + '_' + modelName, object: p[modelPropertyName]}],
|
|
14
|
+
...accessControl
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
function defineView(config, context) {
|
|
11
19
|
const { service, modelRuntime, modelPropertyName, modelName, others, model } = context
|
|
12
20
|
const viewName = (config.prefix || '' ) + (config.prefix ? modelName : modelPropertyName) + (config.suffix || '')
|
|
@@ -22,7 +30,7 @@ function defineView(config, context) {
|
|
|
22
30
|
type: model,
|
|
23
31
|
},
|
|
24
32
|
access: config.access,
|
|
25
|
-
accessControl: config.readAccessControl || config.writeAccessControl,
|
|
33
|
+
accessControl: entityAccessControl(context, config.readAccessControl || config.writeAccessControl),
|
|
26
34
|
daoPath(properties, { client, context }) {
|
|
27
35
|
const id = properties[modelPropertyName]
|
|
28
36
|
const path = config.fields ? modelRuntime().limitedPath(id, config.fields) : modelRuntime().path(id)
|
|
@@ -87,7 +95,7 @@ function defineCreateAction(config, context) {
|
|
|
87
95
|
...(model.properties)
|
|
88
96
|
},
|
|
89
97
|
access: config.createAccess || config.writeAccess,
|
|
90
|
-
accessControl: config.createAccessControl || config.writeAccessControl,
|
|
98
|
+
accessControl: entityAccessControl(context, config.createAccessControl || config.writeAccessControl),
|
|
91
99
|
skipValidation: true,
|
|
92
100
|
//queuedBy: otherPropertyNames,
|
|
93
101
|
waitForEvents: true,
|
|
@@ -126,7 +134,7 @@ function defineUpdateAction(config, context) {
|
|
|
126
134
|
}
|
|
127
135
|
},
|
|
128
136
|
access: config.updateAccess || config.writeAccess,
|
|
129
|
-
accessControl: config.updateAccessControl || config.writeAccessControl,
|
|
137
|
+
accessControl: entityAccessControl(context, config.updateAccessControl || config.writeAccessControl),
|
|
130
138
|
skipValidation: true,
|
|
131
139
|
//queuedBy: otherPropertyNames,
|
|
132
140
|
waitForEvents: true,
|
|
@@ -164,7 +172,7 @@ function defineDeleteAction(config, context) {
|
|
|
164
172
|
}
|
|
165
173
|
},
|
|
166
174
|
access: config.deleteAccess || config.writeAccess,
|
|
167
|
-
accessControl: config.deleteAccessControl || config.writeAccessControl,
|
|
175
|
+
accessControl: entityAccessControl(context, config.deleteAccessControl || config.writeAccessControl),
|
|
168
176
|
skipValidation: true,
|
|
169
177
|
waitForEvents: true,
|
|
170
178
|
async execute(properties, { client, service }, emit) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/relations-plugin",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
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.7.
|
|
24
|
+
"@live-change/framework": "^0.7.4",
|
|
25
25
|
"pluralize": "8.0.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "b4634f8267f89859042f176e5430567fd796082e"
|
|
28
28
|
}
|