UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 2.22 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Schedule=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp};class Schedule{static oneTime(time){const pad=num=>num<10?"0"+num:num,year=time.getFullYear(),month=pad(time.getMonth()+1),day=pad(time.getDate()),hours=pad(time.getHours()),minutes=pad(time.getMinutes()),seconds=pad(time.getSeconds());return new Schedule(`${year}-${month}-${day}T${hours}:${minutes}:${seconds}`)}static rate(duration){try{jsiiDeprecationWarnings().aws_cdk_lib_Duration(duration)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.rate),error}if(duration.toMilliseconds()<core_1().Duration.minutes(1).toMilliseconds())throw new(core_1()).UnscopedValidationError("Duration cannot be less than 1 minute");const maybeRate=(value,unit)=>value>0&&Number.isInteger(value)?`${value} ${unit}`:void 0;let rate=maybeRate(duration.toDays({integral:!1}),"days");return rate===void 0&&(rate=maybeRate(duration.toHours({integral:!1}),"hours")),rate===void 0&&(rate=maybeRate(duration.toMinutes({integral:!0}),"minutes")),new Schedule(`rate(${rate})`)}static cron(options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_CronOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.cron),error}if(options.weekDay!==void 0&&options.day!==void 0)throw new(core_1()).UnscopedValidationError("Cannot supply both 'day' and 'weekDay', use at most one");const minute=options.minute??"*",hour=options.hour??"*",month=options.month??"*",day=options.day??(options.weekDay!==void 0?"?":"*"),weekDay=options.weekDay??"?",year=options.year??"*";return new Schedule(`cron(${minute} ${hour} ${day} ${month} ${weekDay} ${year})`)}constructor(expressionString){this.expressionString=expressionString}}exports.Schedule=Schedule,_a=JSII_RTTI_SYMBOL_1,Schedule[_a]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.Schedule",version:"2.202.0"};