Skip to content

Commit 429b79a

Browse files
authored
fix formatting (#854)
1 parent cd3a240 commit 429b79a

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

src/utils/data-formatters/__tests__/format-enum.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('formatEnum', () => {
1212
const input = ['PREFIX_ENUM_SNAKE_VALUE', 'PREFIX_ENUM'] as const;
1313
const output = formatEnum(...input);
1414

15-
expect(output).toEqual('snake_value');
15+
expect(output).toEqual('SNAKE_VALUE');
1616
});
1717

1818
it('should format enum by removing prefix and convert to pascal case when caseFormat is pascal.', () => {
@@ -23,6 +23,6 @@ describe('formatEnum', () => {
2323
] as const;
2424
const output = formatEnum(...input);
2525

26-
expect(output).toEqual('pascal value');
26+
expect(output).toEqual('PascalValue');
2727
});
2828
});

src/utils/data-formatters/format-enum.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import flowRight from 'lodash/flowRight';
1+
import flow from 'lodash/flow';
22
import lowerCase from 'lodash/lowerCase';
33
import snakeCase from 'lodash/snakeCase';
44
import startCase from 'lodash/startCase';
@@ -7,15 +7,11 @@ type Formatter = (value: string) => string;
77

88
const convertToUpper: Formatter = (value: string) => value.toUpperCase();
99

10-
const upperSnakeCase: Formatter = flowRight([snakeCase, convertToUpper]);
10+
const upperSnakeCase: Formatter = flow([snakeCase, convertToUpper]);
1111

1212
const removeWhiteSpace: Formatter = (value: string) => value.replace(/\s/g, '');
1313

14-
const pascalCase: Formatter = flowRight([
15-
lowerCase,
16-
startCase,
17-
removeWhiteSpace,
18-
]);
14+
const pascalCase: Formatter = flow([lowerCase, startCase, removeWhiteSpace]);
1915

2016
// Case formatter map with strict typing
2117
const caseFormatterMap = {

src/utils/data-formatters/format-pending-workflow-history-event/__tests__/index.test.ts.snapshot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ exports[`formatWorkflowHistoryEvent should format workflow pendingActivityTaskSt
2424
"scheduleId": 7,
2525
"scheduledTime": 1970-01-01T00:03:00.000Z,
2626
"startedWorkerIdentity": "worker-1",
27-
"state": "scheduled",
27+
"state": "Scheduled",
2828
}
2929
`;
3030

@@ -52,7 +52,7 @@ exports[`formatWorkflowHistoryEvent should format workflow pendingActivityTaskSt
5252
"scheduleId": 7,
5353
"scheduledTime": 1970-01-01T00:03:00.000Z,
5454
"startedWorkerIdentity": "worker-1",
55-
"state": "started",
55+
"state": "Started",
5656
}
5757
`;
5858

@@ -80,7 +80,7 @@ exports[`formatWorkflowHistoryEvent should format workflow pendingActivityTaskSt
8080
"scheduleId": 7,
8181
"scheduledTime": 1970-01-01T00:03:00.000Z,
8282
"startedWorkerIdentity": "worker-1",
83-
"state": "cancel requested",
83+
"state": "CancelRequested",
8484
}
8585
`;
8686

@@ -93,7 +93,7 @@ exports[`formatWorkflowHistoryEvent should format workflow pendingDecisionTaskSt
9393
"scheduleId": 7,
9494
"scheduledTime": 1970-01-01T00:03:00.000Z,
9595
"startedTime": null,
96-
"state": "scheduled",
96+
"state": "Scheduled",
9797
}
9898
`;
9999

@@ -106,6 +106,6 @@ exports[`formatWorkflowHistoryEvent should format workflow pendingDecisionTaskSt
106106
"scheduleId": 7,
107107
"scheduledTime": 1970-01-01T00:03:00.000Z,
108108
"startedTime": 2024-09-07T22:16:10.599Z,
109-
"state": "started",
109+
"state": "Started",
110110
}
111111
`;

src/utils/data-formatters/format-workflow-history-event/__tests__/index.test.ts.snapshot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ exports[`formatWorkflowHistoryEvent should format workflow activityTaskTimedOutE
117117
"scheduledEventId": 7,
118118
"startedEventId": 9,
119119
"taskId": "22647174813",
120-
"timeoutType": "TIMEOUT_TYPE_START_TO_CLOSE",
120+
"timeoutType": "StartToClose",
121121
"timestamp": 2024-09-07T22:16:10.632Z,
122122
"version": "575102",
123123
}
@@ -528,7 +528,7 @@ exports[`formatWorkflowHistoryEvent should format workflow startChildWorkflowExe
528528
],
529529
"jitterStart": null,
530530
"memo": null,
531-
"parentClosePolicy": "abandon",
531+
"parentClosePolicy": "ABANDON",
532532
"retryPolicy": null,
533533
"searchAttributes": null,
534534
"taskId": "5877269782",
@@ -540,7 +540,7 @@ exports[`formatWorkflowHistoryEvent should format workflow startChildWorkflowExe
540540
"timestamp": 1975-06-21T10:47:51.830Z,
541541
"version": "575102",
542542
"workflowId": "workflow.cancellation-workflow.cancellation.external-child",
543-
"workflowIdReusePolicy": "allow duplicate",
543+
"workflowIdReusePolicy": "AllowDuplicate",
544544
"workflowType": {
545545
"name": "workflow.cancellation.external",
546546
},
@@ -658,7 +658,7 @@ exports[`formatWorkflowHistoryEvent should format workflow workflowExecutionCont
658658
"header": {
659659
"fields": {},
660660
},
661-
"initiator": "cron_schedule",
661+
"initiator": "CRON_SCHEDULE",
662662
"input": [],
663663
"lastCompletionResult": null,
664664
"memo": null,
@@ -725,7 +725,7 @@ exports[`formatWorkflowHistoryEvent should format workflow workflowExecutionStar
725725
"fields": {},
726726
},
727727
"identity": null,
728-
"initiator": "cron_schedule",
728+
"initiator": "CRON_SCHEDULE",
729729
"input": [],
730730
"lastCompletionResult": null,
731731
"memo": null,

src/utils/data-formatters/format-workflow-history-event/format-activity-task-timed-out-event.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import formatEnum from '../format-enum';
12
import formatFailureDetails from '../format-failure-details';
23
import formatPayload from '../format-payload';
34

@@ -10,13 +11,15 @@ const formatActivityTaskTimedOutEvent = ({
1011
lastFailure,
1112
scheduledEventId,
1213
startedEventId,
14+
timeoutType,
1315
...eventAttributes
1416
},
1517
...eventFields
1618
}: ActivityTaskTimedOutEvent) => {
1719
return {
1820
...formatWorkflowCommonEventFields(eventFields),
1921
...eventAttributes,
22+
timeoutType: formatEnum(timeoutType, 'TIMEOUT_TYPE', 'pascal'),
2023
details: formatPayload(details),
2124
lastFailureDetails: formatFailureDetails(lastFailure),
2225
lastFailureReason: lastFailure?.reason || '',

0 commit comments

Comments
 (0)