@live-change/access-control-service 0.8.119 → 0.8.120

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.
Files changed (2) hide show
  1. package/invite.js +46 -1
  2. package/package.json +3 -3
package/invite.js CHANGED
@@ -2,6 +2,7 @@ import App from '@live-change/framework'
2
2
  const app = App.app()
3
3
  import definition from './definition.js'
4
4
  const config = definition.config
5
+ import pluralize from 'pluralize'
5
6
 
6
7
  const inviteMessageActionByObjectType = config.inviteMessageActionByObjectType ?? {}
7
8
 
@@ -190,7 +191,7 @@ definition.action({
190
191
  }
191
192
  })
192
193
 
193
- import task from '@live-change/task-service/task.js' // need to import taks.js to avoid circular dependency
194
+ import task from '@live-change/task-service/task.ts' // need to import taks.js to avoid circular dependency
194
195
 
195
196
 
196
197
  for(const contactType of config.contactTypes) {
@@ -368,5 +369,49 @@ for(const contactType of config.contactTypes) {
368
369
  }
369
370
  }, definition)
370
371
 
372
+ definition.action({
373
+ name: 'inviteMany' + pluralize(contactTypeUpperCaseName),
374
+ waitForEvents: true,
375
+ properties: {
376
+ objectType: {
377
+ type: String,
378
+ validation: ['nonEmpty']
379
+ },
380
+ object: {
381
+ type: String,
382
+ validation: ['nonEmpty']
383
+ },
384
+ ...invitationProperties,
385
+ contacts: {
386
+ type: Array,
387
+ of: {
388
+ type: Object,
389
+ properties: contactTypeProperties
390
+ }
391
+ }
392
+ },
393
+ access: (params, { client, context, visibilityTest}) =>
394
+ visibilityTest || access.clientCanInvite(client, params),
395
+ async execute(params, { client, service, trigger, command }, emit) {
396
+ const { [contactTypeName]: contact } = params
397
+ const { objectType, object } = params
398
+
399
+ const myRoles = await access.getClientObjectRoles(client, { objectType, object }, true)
400
+ if(!myRoles.includes('admin')) {
401
+ for(const requestedRole of roles) {
402
+ if(!myRoles.includes(requestedRole)) throw 'notAuthorized'
403
+ }
404
+ }
405
+
406
+ const [ fromType, from ] = client.user ? ['user_User', client.user] : ['session_Session', client.session]
407
+
408
+ await inviteManyTask.start({
409
+ ...params,
410
+ fromType, from,
411
+ ownerType: objectType,
412
+ owner: object,
413
+ }, 'action', command.id )
414
+ }
415
+ })
371
416
 
372
417
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/access-control-service",
3
- "version": "0.8.119",
3
+ "version": "0.8.120",
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.8.119"
24
+ "@live-change/framework": "^0.8.120"
25
25
  },
26
- "gitHead": "1f0bb577d5bfe8b8d355775d7adbd73c789cd1d5",
26
+ "gitHead": "adf31fd8365df0655d88293f96a93734058d3dd4",
27
27
  "type": "module"
28
28
  }