Skip to content

Commit 9c5f521

Browse files
author
Rizbir Fahmid Khan
committed
reverting prettier
1 parent 86999f3 commit 9c5f521

File tree

1 file changed

+38
-91
lines changed
  • packages/aws-cdk-lib/aws-stepfunctions/lib/states

1 file changed

+38
-91
lines changed

packages/aws-cdk-lib/aws-stepfunctions/lib/states/task-base.ts

Lines changed: 38 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { Construct } from "constructs";
2-
import { renderJsonPath, State } from "./state";
3-
import * as cloudwatch from "../../../aws-cloudwatch";
4-
import * as iam from "../../../aws-iam";
5-
import * as cdk from "../../../core";
6-
import { Chain } from "../chain";
7-
import { FieldUtils } from "../fields";
8-
import { StateGraph } from "../state-graph";
9-
import { Credentials } from "../task-credentials";
10-
import { CatchProps, IChainable, INextable, RetryProps } from "../types";
1+
import { Construct } from 'constructs';
2+
import { renderJsonPath, State } from './state';
3+
import * as cloudwatch from '../../../aws-cloudwatch';
4+
import * as iam from '../../../aws-iam';
5+
import * as cdk from '../../../core';
6+
import { Chain } from '../chain';
7+
import { FieldUtils } from '../fields';
8+
import { StateGraph } from '../state-graph';
9+
import { Credentials } from '../task-credentials';
10+
import { CatchProps, IChainable, INextable, RetryProps } from '../types';
1111

1212
/**
1313
* Props that are common to all tasks
@@ -146,6 +146,7 @@ export interface TaskStateBaseProps {
146146
* which are more convenient to use.
147147
*/
148148
export abstract class TaskStateBase extends State implements INextable {
149+
149150
public readonly endStates: INextable[];
150151

151152
protected abstract readonly taskMetrics?: TaskMetricsConfig;
@@ -215,15 +216,12 @@ export abstract class TaskStateBase extends State implements INextable {
215216
*
216217
* @default - sum over 5 minutes
217218
*/
218-
public metric(
219-
metricName: string,
220-
props?: cloudwatch.MetricOptions
221-
): cloudwatch.Metric {
219+
public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
222220
return new cloudwatch.Metric({
223-
namespace: "AWS/States",
221+
namespace: 'AWS/States',
224222
metricName,
225223
dimensionsMap: this.taskMetrics?.metricDimensions,
226-
statistic: "sum",
224+
statistic: 'sum',
227225
...props,
228226
}).attachTo(this);
229227
}
@@ -234,25 +232,16 @@ export abstract class TaskStateBase extends State implements INextable {
234232
* @default - average over 5 minutes
235233
*/
236234
public metricRunTime(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
237-
return this.taskMetric(this.taskMetrics?.metricPrefixSingular, "RunTime", {
238-
statistic: "avg",
239-
...props,
240-
});
235+
return this.taskMetric(this.taskMetrics?.metricPrefixSingular, 'RunTime', { statistic: 'avg', ...props });
241236
}
242237

243238
/**
244239
* The interval, in milliseconds, for which the activity stays in the schedule state.
245240
*
246241
* @default - average over 5 minutes
247242
*/
248-
public metricScheduleTime(
249-
props?: cloudwatch.MetricOptions
250-
): cloudwatch.Metric {
251-
return this.taskMetric(
252-
this.taskMetrics?.metricPrefixSingular,
253-
"ScheduleTime",
254-
{ statistic: "avg", ...props }
255-
);
243+
public metricScheduleTime(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
244+
return this.taskMetric(this.taskMetrics?.metricPrefixSingular, 'ScheduleTime', { statistic: 'avg', ...props });
256245
}
257246

258247
/**
@@ -261,10 +250,7 @@ export abstract class TaskStateBase extends State implements INextable {
261250
* @default - average over 5 minutes
262251
*/
263252
public metricTime(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
264-
return this.taskMetric(this.taskMetrics?.metricPrefixSingular, "Time", {
265-
statistic: "avg",
266-
...props,
267-
});
253+
return this.taskMetric(this.taskMetrics?.metricPrefixSingular, 'Time', { statistic: 'avg', ...props });
268254
}
269255

270256
/**
@@ -273,11 +259,7 @@ export abstract class TaskStateBase extends State implements INextable {
273259
* @default - sum over 5 minutes
274260
*/
275261
public metricScheduled(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
276-
return this.taskMetric(
277-
this.taskMetrics?.metricPrefixPlural,
278-
"Scheduled",
279-
props
280-
);
262+
return this.taskMetric(this.taskMetrics?.metricPrefixPlural, 'Scheduled', props);
281263
}
282264

283265
/**
@@ -286,11 +268,7 @@ export abstract class TaskStateBase extends State implements INextable {
286268
* @default - sum over 5 minutes
287269
*/
288270
public metricTimedOut(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
289-
return this.taskMetric(
290-
this.taskMetrics?.metricPrefixPlural,
291-
"TimedOut",
292-
props
293-
);
271+
return this.taskMetric(this.taskMetrics?.metricPrefixPlural, 'TimedOut', props);
294272
}
295273

296274
/**
@@ -299,11 +277,7 @@ export abstract class TaskStateBase extends State implements INextable {
299277
* @default - sum over 5 minutes
300278
*/
301279
public metricStarted(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
302-
return this.taskMetric(
303-
this.taskMetrics?.metricPrefixPlural,
304-
"Started",
305-
props
306-
);
280+
return this.taskMetric(this.taskMetrics?.metricPrefixPlural, 'Started', props);
307281
}
308282

309283
/**
@@ -312,11 +286,7 @@ export abstract class TaskStateBase extends State implements INextable {
312286
* @default - sum over 5 minutes
313287
*/
314288
public metricSucceeded(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
315-
return this.taskMetric(
316-
this.taskMetrics?.metricPrefixPlural,
317-
"Succeeded",
318-
props
319-
);
289+
return this.taskMetric(this.taskMetrics?.metricPrefixPlural, 'Succeeded', props);
320290
}
321291

322292
/**
@@ -325,26 +295,16 @@ export abstract class TaskStateBase extends State implements INextable {
325295
* @default - sum over 5 minutes
326296
*/
327297
public metricFailed(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
328-
return this.taskMetric(
329-
this.taskMetrics?.metricPrefixPlural,
330-
"Failed",
331-
props
332-
);
298+
return this.taskMetric(this.taskMetrics?.metricPrefixPlural, 'Failed', props);
333299
}
334300

335301
/**
336302
* Metric for the number of times the heartbeat times out for this activity
337303
*
338304
* @default - sum over 5 minutes
339305
*/
340-
public metricHeartbeatTimedOut(
341-
props?: cloudwatch.MetricOptions
342-
): cloudwatch.Metric {
343-
return this.taskMetric(
344-
this.taskMetrics?.metricPrefixPlural,
345-
"HeartbeatTimedOut",
346-
props
347-
);
306+
public metricHeartbeatTimedOut(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
307+
return this.taskMetric(this.taskMetrics?.metricPrefixPlural, 'HeartbeatTimedOut', props);
348308
}
349309

350310
protected whenBoundToGraph(graph: StateGraph) {
@@ -353,13 +313,11 @@ export abstract class TaskStateBase extends State implements INextable {
353313
graph.registerPolicyStatement(policyStatement);
354314
}
355315
if (this.credentials) {
356-
graph.registerPolicyStatement(
357-
new iam.PolicyStatement({
358-
effect: iam.Effect.ALLOW,
359-
actions: ["sts:AssumeRole"],
360-
resources: [this.credentials.role.resource],
361-
})
362-
);
316+
graph.registerPolicyStatement(new iam.PolicyStatement({
317+
effect: iam.Effect.ALLOW,
318+
actions: ['sts:AssumeRole'],
319+
resources: [this.credentials.role.resource],
320+
}));
363321
}
364322
}
365323

@@ -368,35 +326,24 @@ export abstract class TaskStateBase extends State implements INextable {
368326
*/
369327
protected abstract _renderTask(): any;
370328

371-
private taskMetric(
372-
prefix: string | undefined,
373-
suffix: string,
374-
props?: cloudwatch.MetricOptions
375-
): cloudwatch.Metric {
329+
private taskMetric(prefix: string | undefined, suffix: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
376330
if (prefix === undefined) {
377-
throw new Error(
378-
"Task does not expose metrics. Use the 'metric()' function to add metrics."
379-
);
331+
throw new Error('Task does not expose metrics. Use the \'metric()\' function to add metrics.');
380332
}
381333
return this.metric(prefix + suffix, props);
382334
}
383335

384336
private renderCredentials() {
385-
return this.credentials
386-
? FieldUtils.renderObject({
387-
Credentials: { RoleArn: this.credentials.role.roleArn },
388-
})
389-
: undefined;
337+
return this.credentials ? FieldUtils.renderObject({ Credentials: { RoleArn: this.credentials.role.roleArn } }) : undefined;
390338
}
391339

392340
private renderTaskBase() {
393341
return {
394-
Type: "Task",
342+
Type: 'Task',
395343
Comment: this.comment,
396344
TimeoutSeconds: this.timeout?.toSeconds() ?? this.taskTimeout?.seconds,
397345
TimeoutSecondsPath: this.taskTimeout?.path,
398-
HeartbeatSeconds:
399-
this.heartbeat?.toSeconds() ?? this.heartbeatTimeout?.seconds,
346+
HeartbeatSeconds: this.heartbeat?.toSeconds() ?? this.heartbeatTimeout?.seconds,
400347
HeartbeatSecondsPath: this.heartbeatTimeout?.path,
401348
InputPath: renderJsonPath(this.inputPath),
402349
OutputPath: renderJsonPath(this.outputPath),
@@ -447,22 +394,22 @@ export enum IntegrationPattern {
447394
*
448395
* @see https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-default
449396
*/
450-
REQUEST_RESPONSE = "REQUEST_RESPONSE",
397+
REQUEST_RESPONSE = 'REQUEST_RESPONSE',
451398

452399
/**
453400
* Step Functions can wait for a request to complete before progressing to the next state.
454401
*
455402
* @see https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-sync
456403
*/
457-
RUN_JOB = "RUN_JOB",
404+
RUN_JOB = 'RUN_JOB',
458405

459406
/**
460407
* Callback tasks provide a way to pause a workflow until a task token is returned.
461408
* You must set a task token when using the callback pattern
462409
*
463410
* @see https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-wait-token
464411
*/
465-
WAIT_FOR_TASK_TOKEN = "WAIT_FOR_TASK_TOKEN",
412+
WAIT_FOR_TASK_TOKEN = 'WAIT_FOR_TASK_TOKEN',
466413
}
467414

468415
/**

0 commit comments

Comments
 (0)