UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 7.5 kB
"use strict";var _a,_b;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Timeout=exports.IntegrationPattern=exports.TaskStateBase=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cloudwatch=require("../../../aws-cloudwatch"),iam=require("../../../aws-iam"),state_1=require("./state"),chain_1=require("../chain"),fields_1=require("../fields");class TaskStateBase extends state_1.State{constructor(scope,id,props){super(scope,id,props);try{jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_TaskStateBaseProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,TaskStateBase),error}this.endStates=[this],this.timeout=props.timeout,this.taskTimeout=props.taskTimeout,this.heartbeat=props.heartbeat,this.heartbeatTimeout=props.heartbeatTimeout,this.credentials=props.credentials}addRetry(props={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_RetryProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addRetry),error}return super._addRetry(props),this}addCatch(handler,props={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_IChainable(handler),jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_CatchProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addCatch),error}return super._addCatch(handler.startState,props),this}next(next){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_IChainable(next)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.next),error}return super.makeNext(next.startState),chain_1.Chain.sequence(this,next)}toStateJson(){return{...this.renderNextEnd(),...this.renderRetryCatch(),...this.renderTaskBase(),...this._renderTask()}}metric(metricName,props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metric),error}return new cloudwatch.Metric({namespace:"AWS/States",metricName,dimensionsMap:this.taskMetrics?.metricDimensions,statistic:"sum",...props}).attachTo(this)}metricRunTime(props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricRunTime),error}return this.taskMetric(this.taskMetrics?.metricPrefixSingular,"RunTime",{statistic:"avg",...props})}metricScheduleTime(props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricScheduleTime),error}return this.taskMetric(this.taskMetrics?.metricPrefixSingular,"ScheduleTime",{statistic:"avg",...props})}metricTime(props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricTime),error}return this.taskMetric(this.taskMetrics?.metricPrefixSingular,"Time",{statistic:"avg",...props})}metricScheduled(props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricScheduled),error}return this.taskMetric(this.taskMetrics?.metricPrefixPlural,"Scheduled",props)}metricTimedOut(props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricTimedOut),error}return this.taskMetric(this.taskMetrics?.metricPrefixPlural,"TimedOut",props)}metricStarted(props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricStarted),error}return this.taskMetric(this.taskMetrics?.metricPrefixPlural,"Started",props)}metricSucceeded(props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricSucceeded),error}return this.taskMetric(this.taskMetrics?.metricPrefixPlural,"Succeeded",props)}metricFailed(props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricFailed),error}return this.taskMetric(this.taskMetrics?.metricPrefixPlural,"Failed",props)}metricHeartbeatTimedOut(props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricHeartbeatTimedOut),error}return this.taskMetric(this.taskMetrics?.metricPrefixPlural,"HeartbeatTimedOut",props)}whenBoundToGraph(graph){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_StateGraph(graph)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.whenBoundToGraph),error}super.whenBoundToGraph(graph);for(const policyStatement of this.taskPolicies||[])graph.registerPolicyStatement(policyStatement);this.credentials&&graph.registerPolicyStatement(new iam.PolicyStatement({effect:iam.Effect.ALLOW,actions:["sts:AssumeRole"],resources:[this.credentials.role.resource]}))}taskMetric(prefix,suffix,props){if(prefix===void 0)throw new Error("Task does not expose metrics. Use the 'metric()' function to add metrics.");return this.metric(prefix+suffix,props)}renderCredentials(){return this.credentials?fields_1.FieldUtils.renderObject({Credentials:{RoleArn:this.credentials.role.roleArn}}):void 0}renderTaskBase(){return{Type:"Task",Comment:this.comment,TimeoutSeconds:this.timeout?.toSeconds()??this.taskTimeout?.seconds,TimeoutSecondsPath:this.taskTimeout?.path,HeartbeatSeconds:this.heartbeat?.toSeconds()??this.heartbeatTimeout?.seconds,HeartbeatSecondsPath:this.heartbeatTimeout?.path,InputPath:state_1.renderJsonPath(this.inputPath),OutputPath:state_1.renderJsonPath(this.outputPath),ResultPath:state_1.renderJsonPath(this.resultPath),...this.renderResultSelector(),...this.renderCredentials()}}}exports.TaskStateBase=TaskStateBase,_a=JSII_RTTI_SYMBOL_1,TaskStateBase[_a]={fqn:"aws-cdk-lib.aws_stepfunctions.TaskStateBase",version:"2.70.0"};var IntegrationPattern;(function(IntegrationPattern2){IntegrationPattern2.REQUEST_RESPONSE="REQUEST_RESPONSE",IntegrationPattern2.RUN_JOB="RUN_JOB",IntegrationPattern2.WAIT_FOR_TASK_TOKEN="WAIT_FOR_TASK_TOKEN"})(IntegrationPattern=exports.IntegrationPattern||(exports.IntegrationPattern={}));class Timeout{static duration(duration){try{jsiiDeprecationWarnings.aws_cdk_lib_Duration(duration)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.duration),error}return{seconds:duration.toSeconds()}}static at(path){return{path}}}exports.Timeout=Timeout,_b=JSII_RTTI_SYMBOL_1,Timeout[_b]={fqn:"aws-cdk-lib.aws_stepfunctions.Timeout",version:"2.70.0"};