@live-change/relations-plugin 0.9.163 → 0.9.165

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/relations-plugin",
3
- "version": "0.9.163",
3
+ "version": "0.9.165",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/framework": "^0.9.163",
25
+ "@live-change/framework": "^0.9.165",
26
26
  "pluralize": "^8.0.0"
27
27
  },
28
28
  "devDependencies": {
@@ -30,5 +30,5 @@
30
30
  "typedoc-plugin-markdown": "^4.6.3",
31
31
  "typedoc-plugin-rename-defaults": "^0.7.3"
32
32
  },
33
- "gitHead": "c410e1dacd07daed9a5c55367abd7f19d9a575cc"
33
+ "gitHead": "687dab16bd0c6594544cdab70cd7eecc17bb510c"
34
34
  }
@@ -53,11 +53,11 @@ export interface EntityContext {
53
53
  }
54
54
 
55
55
 
56
- export function entityAccessControl({service, modelName, modelPropertyName}, accessControl) {
56
+ export function entityAccessControl({service, modelName, modelPropertyName}, accessControl, noObjects = false) {
57
57
  if(!accessControl) return undefined
58
58
  if(Array.isArray(accessControl)) accessControl = { roles: accessControl }
59
59
  return {
60
- objects: p => [{ objectType: service.name + '_' + modelName, object: p[modelPropertyName]}],
60
+ objects: noObjects ? undefined : p => [{ objectType: service.name + '_' + modelName, object: p[modelPropertyName]}],
61
61
  ...accessControl
62
62
  }
63
63
  }
@@ -191,7 +191,7 @@ export function defineCreateAction(config, context) {
191
191
  name: actionName,
192
192
  properties: { ...model.properties },
193
193
  access: config.createAccess || config.writeAccess,
194
- accessControl: entityAccessControl(context, config.createAccessControl || config.writeAccessControl),
194
+ accessControl: entityAccessControl(context, config.createAccessControl || config.writeAccessControl, true),
195
195
  skipValidation: true,
196
196
  //queuedBy: otherPropertyNames,
197
197
  waitForEvents: true,
@@ -339,9 +339,13 @@ function getResetFunction(config, context) {
339
339
  if (!entity) throw new Error('not_found')
340
340
  await fireChangeTriggers(context, objectType, identifiers, id,
341
341
  entity ? extractObjectData(writeableProperties, entity, {}) : null, null, trigger)
342
+
342
343
  emit({
343
- type: eventName,
344
- identifiers
344
+ type: eventName,
345
+ identifiers: {
346
+ ...identifiers,
347
+ [modelPropertyName]: properties[modelPropertyName]
348
+ }
345
349
  })
346
350
  return id
347
351
  }
package/src/utilsAny.ts CHANGED
@@ -220,22 +220,22 @@ export function addAccessControlAnyParents(context) {
220
220
  )
221
221
  }
222
222
 
223
- export function prepareAccessControl(accessControl, names) {
223
+ export function prepareAccessControl(accessControl, names, types = undefined) {
224
224
  if(typeof accessControl == 'object') {
225
- accessControl.objects = accessControl.objects ?? ((params) => names.map(name => ({
226
- objectType: params[name + 'Type'],
225
+ accessControl.objects = accessControl.objects ?? ((params) => names.map((name, index) => ({
226
+ objectType: types?.[index] ?? params[name + 'Type'],
227
227
  object: params[name]
228
228
  })))
229
229
  }
230
230
  }
231
231
 
232
- export function cloneAndPrepareAccessControl(accessControl, names) {
232
+ export function cloneAndPrepareAccessControl(accessControl, names, types = undefined) {
233
233
  if(!accessControl) return accessControl
234
234
  if(Array.isArray(accessControl)) {
235
235
  accessControl = { roles: accessControl}
236
236
  }
237
237
  const newAccessControl = { ...accessControl }
238
- prepareAccessControl(newAccessControl, names)
238
+ prepareAccessControl(newAccessControl, names, types)
239
239
  return newAccessControl
240
240
  }
241
241