@live-change/task-service 0.9.69 → 0.9.71

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/package.json +4 -4
  2. package/task.ts +15 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/task-service",
3
- "version": "0.9.69",
3
+ "version": "0.9.71",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/framework": "^0.9.69",
26
- "@live-change/relations-plugin": "^0.9.69"
25
+ "@live-change/framework": "^0.9.71",
26
+ "@live-change/relations-plugin": "^0.9.71"
27
27
  },
28
- "gitHead": "04b432a6dda0fa04faecadd7641f9763ee90dc18"
28
+ "gitHead": "422e96a7868c9923b55b300821db6e95e5415502"
29
29
  }
package/task.ts CHANGED
@@ -161,19 +161,7 @@ interface TaskDefinition {
161
161
  * create action for task, action will return object with task property,
162
162
  * @param action - true, or action name
163
163
  */
164
- action?: string | true
165
-
166
- /**
167
- * check if action is accessible for certain user
168
- * @param props
169
- * @param context
170
- */
171
- actionAccess?: (props, context) => boolean
172
-
173
- /**
174
- * action access control settings
175
- */
176
- actionAccessControl?: Object
164
+ action?: string | true | { name: string } // TODO: create ActionDefinition type
177
165
 
178
166
  }
179
167
 
@@ -419,37 +407,37 @@ export default function task(definition:TaskDefinition, serviceDefinition) {
419
407
  serviceDefinition.trigger({
420
408
  name: definition.trigger === true ? definition.name : definition.trigger,
421
409
  properties: definition.properties,
422
- returnsTask: true,
410
+ returnsTask: definition.name,
423
411
  returns: {
424
412
  type: Task
425
413
  },
426
414
  async execute(props, context, emit) {
427
415
  const startResult =
428
- await startTask(taskFunction, props, 'trigger', context.id)
429
- return {
430
- task: startResult.task
431
- }
416
+ await startTask(taskFunction, props, 'trigger', context.reaction.id)
417
+ return startResult.task
432
418
  }
433
419
  })
434
420
  }
435
421
 
436
422
  if(definition.action) {
423
+ const name =
424
+ (definition.action === true && definition.name)
425
+ || (typeof definition.action === 'string' && definition.action)
426
+ || (typeof definition.action === 'object' && definition.action.name)
427
+ || definition.name
437
428
  serviceDefinition.action({
438
- name: definition.action === true ? definition.name : definition.action,
429
+ name,
439
430
  properties: definition.properties,
440
- returnsTask: true,
441
- access: definition.actionAccess,
442
- accessControl: definition.actionAccessControl,
431
+ returnsTask: definition.name,
443
432
  returns: {
444
433
  type: Task
445
434
  },
446
435
  async execute(props, context, emit) {
447
436
  const startResult =
448
- await startTask(taskFunction, { ...props, client: context.client }, 'command', context.id)
449
- return {
450
- task: startResult.task
451
- }
452
- }
437
+ await startTask(taskFunction, { ...props, client: context.client }, 'command', context.command.id)
438
+ return startResult.task
439
+ },
440
+ ...(typeof definition.action === 'object' && definition.action)
453
441
  })
454
442
  }
455
443