@live-change/relations-plugin 0.7.1 → 0.7.3

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
@@ -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,
@@ -103,6 +111,7 @@ function defineCreateAction(config, context) {
103
111
  [modelPropertyName]: id,
104
112
  data
105
113
  })
114
+ return id
106
115
  }
107
116
  })
108
117
  const action = service.actions[actionName]
@@ -125,7 +134,7 @@ function defineUpdateAction(config, context) {
125
134
  }
126
135
  },
127
136
  access: config.updateAccess || config.writeAccess,
128
- accessControl: config.updateAccessControl || config.writeAccessControl,
137
+ accessControl: entityAccessControl(context, config.updateAccessControl || config.writeAccessControl),
129
138
  skipValidation: true,
130
139
  //queuedBy: otherPropertyNames,
131
140
  waitForEvents: true,
@@ -163,7 +172,7 @@ function defineDeleteAction(config, context) {
163
172
  }
164
173
  },
165
174
  access: config.deleteAccess || config.writeAccess,
166
- accessControl: config.deleteAccessControl || config.writeAccessControl,
175
+ accessControl: entityAccessControl(context, config.deleteAccessControl || config.writeAccessControl),
167
176
  skipValidation: true,
168
177
  waitForEvents: true,
169
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.1",
3
+ "version": "0.7.3",
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.1",
24
+ "@live-change/framework": "^0.7.3",
25
25
  "pluralize": "8.0.0"
26
26
  },
27
- "gitHead": "c2c41e3aae59956b71e22a035b813f8df7836057"
27
+ "gitHead": "678a56933a707927dc21360670f47333159cc2f6"
28
28
  }
@@ -79,6 +79,7 @@ function defineCreateAction(config, context) {
79
79
  [modelPropertyName]: id,
80
80
  identifiers, data
81
81
  })
82
+ return id
82
83
  }
83
84
  })
84
85
  const action = service.actions[actionName]
@@ -73,6 +73,7 @@ function defineCreateAction(config, context) {
73
73
  [modelPropertyName]: id,
74
74
  identifiers, data
75
75
  })
76
+ return id
76
77
  }
77
78
  })
78
79
  const action = service.actions[actionName]
package/utilsAny.js CHANGED
@@ -24,6 +24,12 @@ function extractIdentifiersWithTypes(otherPropertyNames, properties) {
24
24
  }
25
25
 
26
26
  function generateAnyId(otherPropertyNames, properties) {
27
+ console.log("GEN ID", otherPropertyNames, properties, '=>',
28
+ otherPropertyNames
29
+ .map(p => [p+'Type', p])
30
+ .flat()
31
+ .map(p => JSON.stringify(properties[p])).join(':'))
32
+
27
33
  return otherPropertyNames
28
34
  .map(p => [p+'Type', p])
29
35
  .flat()