@live-change/task-service 0.9.69 → 0.9.70
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 +4 -4
- 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.
|
|
3
|
+
"version": "0.9.70",
|
|
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.
|
|
26
|
-
"@live-change/relations-plugin": "^0.9.
|
|
25
|
+
"@live-change/framework": "^0.9.70",
|
|
26
|
+
"@live-change/relations-plugin": "^0.9.70"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "670c4d516a15a97a699e325674b6f187644537ce"
|
|
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:
|
|
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
|
|
429
|
+
name,
|
|
439
430
|
properties: definition.properties,
|
|
440
|
-
returnsTask:
|
|
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
|
-
|
|
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
|
|