fix: provide step.parameters to Scheduler triggers

This commit is contained in:
Ali BARIN
2022-09-18 14:58:22 +02:00
parent 4183884537
commit 58565fddae
6 changed files with 15 additions and 18 deletions

View File

@@ -1,18 +1,15 @@
import Triggers from './triggers';
import {
IService,
IApp,
IJSONObject,
IConnection,
IFlow,
IStep,
} from '@automatisch/types';
export default class Scheduler implements IService {
triggers: Triggers;
constructor(
appData: IApp,
connectionData: IJSONObject,
parameters: IJSONObject
) {
this.triggers = new Triggers(connectionData, parameters);
constructor(connection: IConnection, flow: IFlow, step: IStep) {
this.triggers = new Triggers(step.parameters);
}
}

View File

@@ -1,4 +1,4 @@
import { IJSONObject } from '@automatisch/types';
import { IStep } from '@automatisch/types';
import EveryHour from './triggers/every-hour';
import EveryDay from './triggers/every-day';
import EveryWeek from './triggers/every-week';
@@ -10,7 +10,7 @@ export default class Triggers {
everyWeek: EveryWeek;
everyMonth: EveryMonth;
constructor(connectionData: IJSONObject, parameters: IJSONObject) {
constructor(parameters: IStep["parameters"]) {
this.everyHour = new EveryHour(parameters);
this.everyDay = new EveryDay(parameters);
this.everyWeek = new EveryWeek(parameters);

View File

@@ -1,12 +1,12 @@
import { DateTime } from 'luxon';
import type { IJSONObject, IJSONValue, ITrigger } from '@automatisch/types';
import type { IStep, IJSONValue, ITrigger } from '@automatisch/types';
import { cronTimes, getNextCronDateTime, getDateTimeObjectRepresentation } from '../utils';
export default class EveryDay implements ITrigger {
triggersOnWeekend?: boolean;
hour?: number;
constructor(parameters: IJSONObject) {
constructor(parameters: IStep["parameters"]) {
if (parameters.triggersOnWeekend) {
this.triggersOnWeekend = parameters.triggersOnWeekend as boolean;
}

View File

@@ -1,11 +1,11 @@
import { DateTime } from 'luxon';
import type { IJSONObject, IJSONValue, ITrigger } from '@automatisch/types';
import type { IStep, IJSONValue, ITrigger } from '@automatisch/types';
import { cronTimes, getNextCronDateTime, getDateTimeObjectRepresentation } from '../utils';
export default class EveryHour implements ITrigger {
triggersOnWeekend?: boolean | string;
constructor(parameters: IJSONObject) {
constructor(parameters: IStep["parameters"]) {
if (parameters.triggersOnWeekend) {
this.triggersOnWeekend = parameters.triggersOnWeekend as string;
}

View File

@@ -1,12 +1,12 @@
import { DateTime } from 'luxon';
import type { IJSONObject, IJSONValue, ITrigger } from '@automatisch/types';
import type { IStep, IJSONValue, ITrigger } from '@automatisch/types';
import { cronTimes, getNextCronDateTime, getDateTimeObjectRepresentation } from '../utils';
export default class EveryMonth implements ITrigger {
day?: number;
hour?: number;
constructor(parameters: IJSONObject) {
constructor(parameters: IStep["parameters"]) {
if (parameters.day) {
this.day = parameters.day as number;
}

View File

@@ -1,12 +1,12 @@
import { DateTime } from 'luxon';
import type { IJSONObject, IJSONValue, ITrigger } from '@automatisch/types';
import type { IStep, IJSONValue, ITrigger } from '@automatisch/types';
import { cronTimes, getNextCronDateTime, getDateTimeObjectRepresentation } from '../utils';
export default class EveryWeek implements ITrigger {
weekday?: number;
hour?: number;
constructor(parameters: IJSONObject) {
constructor(parameters: IStep["parameters"]) {
if (parameters.weekday) {
this.weekday = parameters.weekday as number;
}