@live-change/relations-plugin 0.6.10 → 0.6.11
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 +9 -2
- package/propertyOfAny.js +5 -3
- package/singularRelationAnyUtils.js +11 -5
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.11",
|
|
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.11",
|
|
25
25
|
"pluralize": "8.0.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "99d448214c2df44f42e5d25a08fa50ae79e5bdbe"
|
|
28
28
|
}
|
|
@@ -21,6 +21,13 @@ function defineView(config, context) {
|
|
|
21
21
|
validation: ['nonEmpty']
|
|
22
22
|
})
|
|
23
23
|
}
|
|
24
|
+
const accessControl = config.readAccessControl || config.writeAccessControl
|
|
25
|
+
if(typeof accessControl == 'object') {
|
|
26
|
+
accessControl.objects = accessControl.objects ?? ((params) => otherPropertyNames.map(name => ({
|
|
27
|
+
objectType: params[name + 'Type'],
|
|
28
|
+
object: params[name]
|
|
29
|
+
})))
|
|
30
|
+
}
|
|
24
31
|
const viewName = joinedOthersPropertyName + context.reverseRelationWord + pluralize(modelName)
|
|
25
32
|
service.views[viewName] = new ViewDefinition({
|
|
26
33
|
name: viewName,
|
|
@@ -34,8 +41,8 @@ function defineView(config, context) {
|
|
|
34
41
|
type: model
|
|
35
42
|
}
|
|
36
43
|
},
|
|
37
|
-
access: config.readAccess,
|
|
38
|
-
accessControl
|
|
44
|
+
access: config.readAccess || config.writeAccess,
|
|
45
|
+
accessControl,
|
|
39
46
|
daoPath(properties, { client, context }) {
|
|
40
47
|
const typeAndIdParts = extractTypeAndIdParts(otherPropertyNames, properties)
|
|
41
48
|
const range = extractRange(properties)
|
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) {
|
|
@@ -35,6 +35,13 @@ function defineObjectView(config, context) {
|
|
|
35
35
|
validation: ['nonEmpty']
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
|
+
const accessControl = config.singleAccessControl || config.readAccessControl || config.writeAccessControl
|
|
39
|
+
if(typeof accessControl == 'object') {
|
|
40
|
+
accessControl.objects = accessControl.objects ?? ((params) => otherPropertyNames.map(name => ({
|
|
41
|
+
objectType: params[name + 'Type'],
|
|
42
|
+
object: params[name]
|
|
43
|
+
})))
|
|
44
|
+
}
|
|
38
45
|
const viewName = config.name || ((config.prefix ? (config.prefix + joinedOthersClassName) : joinedOthersPropertyName) +
|
|
39
46
|
context.reverseRelationWord + modelName + (config.suffix || ''))
|
|
40
47
|
service.views[viewName] = new ViewDefinition({
|
|
@@ -45,8 +52,8 @@ function defineObjectView(config, context) {
|
|
|
45
52
|
returns: {
|
|
46
53
|
type: model,
|
|
47
54
|
},
|
|
48
|
-
access: config.readAccess,
|
|
49
|
-
accessControl
|
|
55
|
+
access: config.singleAccess || config.readAccess,
|
|
56
|
+
accessControl,
|
|
50
57
|
daoPath(properties, { client, context }) {
|
|
51
58
|
const typeAndIdParts = extractTypeAndIdParts(otherPropertyNames, properties)
|
|
52
59
|
const id = typeAndIdParts.length > 1 ? typeAndIdParts.map(p => JSON.stringify(p)).join(':') : idParts[0]
|
|
@@ -73,9 +80,8 @@ function defineRangeViews(config, context) {
|
|
|
73
80
|
...identifiers,
|
|
74
81
|
...App.rangeProperties,
|
|
75
82
|
},
|
|
76
|
-
access
|
|
77
|
-
|
|
78
|
-
},
|
|
83
|
+
access: config.listAccess || config.readAccess,
|
|
84
|
+
accessControl: config.listAccessControl || config.readAccessControl || config.writeAccessControl,
|
|
79
85
|
daoPath(params, { client, context }) {
|
|
80
86
|
const owner = []
|
|
81
87
|
for (const key of combination) {
|