feat: add defineTrigger and defineAction

This commit is contained in:
Ali BARIN
2022-10-15 22:16:10 +02:00
parent ee9d095454
commit 92a2d68a81
23 changed files with 147 additions and 131 deletions

View File

@@ -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] };
},
};
});