@live-change/relations-plugin 0.6.11 → 0.6.14

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 CHANGED
@@ -3,16 +3,17 @@ const {
3
3
  processModelsAnnotation, extractIdParts, extractIdentifiers, extractObjectData
4
4
  } = require('./utils.js')
5
5
  const App = require("@live-change/framework")
6
+ const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition } = App
6
7
 
7
8
  const annotation = 'entity'
8
9
 
9
10
  function defineView(config, context) {
10
- const { service, modelRuntime, modelName, others, model } = context
11
- const viewName = (config.prefix || '' ) + modelName + (config.suffix || '')
11
+ const { service, modelRuntime, modelPropertyName, modelName, others, model } = context
12
+ const viewName = (config.prefix || '' ) + (config.prefix ? modelName : modelPropertyName) + (config.suffix || '')
12
13
  service.views[viewName] = new ViewDefinition({
13
14
  name: viewName,
14
15
  properties: {
15
- [modelName]: {
16
+ [modelPropertyName]: {
16
17
  type: model,
17
18
  validation: ['nonEmpty']
18
19
  }
@@ -23,7 +24,7 @@ function defineView(config, context) {
23
24
  access: config.access,
24
25
  accessControl: config.readAccessControl || config.writeAccessControl,
25
26
  daoPath(properties, { client, context }) {
26
- const id = properties[modelName]
27
+ const id = properties[modelPropertyName]
27
28
  const path = config.fields ? modelRuntime().limitedPath(id, config.fields) : modelRuntime().path(id)
28
29
  return path
29
30
  }
@@ -204,11 +205,10 @@ module.exports = function(service, app) {
204
205
 
205
206
  const writeableProperties = modelProperties || config.writeableProperties
206
207
  //console.log("PPP", others)
207
- const otherPropertyNames = others.map(other => other.slice(0, 1).toLowerCase() + other.slice(1))
208
208
 
209
209
  const context = {
210
210
  service, app, model, originalModelProperties, modelProperties, modelPropertyName, defaults, modelRuntime,
211
- otherPropertyNames, modelName, writeableProperties, annotation
211
+ modelName, writeableProperties, annotation
212
212
  }
213
213
 
214
214
  if (config.readAccess || config.readAccessControl || config.writeAccessControl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/relations-plugin",
3
- "version": "0.6.11",
3
+ "version": "0.6.14",
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.11",
24
+ "@live-change/framework": "^0.6.14",
25
25
  "pluralize": "8.0.0"
26
26
  },
27
- "gitHead": "99d448214c2df44f42e5d25a08fa50ae79e5bdbe"
27
+ "gitHead": "44cec669125b2af3f0b9318cb70c5cf4647c28c6"
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
- if(typeof accessControl == 'object') {
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: config.createAccessControl || config.writeAccessControl,
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: config.updateAccessControl || config.writeAccessControl,
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: config.deleteAccessControl || config.writeAccessControl,
156
+ accessControl,
156
157
  skipValidation: true,
157
158
  //queuedBy: otherPropertyNames,
158
159
  waitForEvents: true,
@@ -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: config.createAccessControl || config.writeAccessControl,
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: config.deleteAccessControl || config.writeAccessControl,
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, access: config.readAccess }, context)
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
- if(typeof accessControl == 'object') {
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: config.listAccessControl || config.readAccessControl || config.writeAccessControl,
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: config.setAccessControl || config.writeAccessControl,
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: config.updateAccessControl || config.writeAccessControl,
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: config.setAccessControl || config.writeAccessControl,
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: config.resetAccessControl || config.writeAccessControl,
220
+ accessControl,
216
221
  queuedBy: otherPropertyNames,
217
222
  waitForEvents: true,
218
223
  async execute(properties, {client, service}, emit) {
@@ -1,6 +1,8 @@
1
1
  const App = require("@live-change/framework")
2
2
  const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition } = App
3
- const { extractIdentifiers, extractObjectData, generateId, extractIdParts} = require("./utils.js")
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: config.readAccessControl || config.writeAccessControl,
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: config.setAccessControl || config.writeAccessControl,
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: config.updateAccessControl || config.writeAccessControl,
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: config.resetAccessControl || config.writeAccessControl,
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
  }