feat: add defineTrigger and defineAction
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import { IGlobalVariable, IJSONValue } from '@automatisch/types';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import cronTimes from '../../common/cron-times';
|
||||
import getNextCronDateTime from '../../common/get-next-cron-date-time';
|
||||
import getDateTimeObjectRepresentation from '../../common/get-date-time-object';
|
||||
|
||||
export default {
|
||||
export default defineTrigger({
|
||||
name: 'Every week',
|
||||
key: 'everyWeek',
|
||||
description: 'Triggers every week.',
|
||||
@@ -174,14 +175,14 @@ export default {
|
||||
return interval;
|
||||
},
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
async run($) {
|
||||
const nextCronDateTime = getNextCronDateTime(
|
||||
this.getInterval($.step.parameters)
|
||||
);
|
||||
const dateTime = DateTime.now();
|
||||
const dateTimeObjectRepresentation = getDateTimeObjectRepresentation(
|
||||
$.execution.testRun ? nextCronDateTime : dateTime
|
||||
) as IJSONValue;
|
||||
);
|
||||
|
||||
const dataItem = {
|
||||
raw: dateTimeObjectRepresentation,
|
||||
@@ -192,4 +193,4 @@ export default {
|
||||
|
||||
return { data: [dataItem] };
|
||||
},
|
||||
};
|
||||
});
|
||||
|
Reference in New Issue
Block a user