Skip to content

Commit e7dad23

Browse files
committed
feat: add ability to search workflows by activity id
Signed-off-by: ItsRoy69 <jyotirmoyroy649@gmail.com>
1 parent dce87ac commit e7dad23

7 files changed

Lines changed: 21 additions & 5 deletions

src/lib/stores/search-attributes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const searchAttributes: Readable<SearchAttributes> = derived(
2424
([$allSearchAttributes]) => ({
2525
...$allSearchAttributes.customAttributes,
2626
...$allSearchAttributes.systemAttributes,
27+
ActivityId: SEARCH_ATTRIBUTE_TYPE.KEYWORD,
2728
}),
2829
);
2930

@@ -172,6 +173,7 @@ export const sortedSearchAttributeOptions: Readable<SearchAttributeOption[]> =
172173
'WorkflowId',
173174
'WorkflowType',
174175
'RunId',
176+
'ActivityId',
175177
'StartTime',
176178
'CloseTime',
177179
];

src/lib/types/workflows.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export type FilterParameters = {
118118
executionStatus?: WorkflowStatus;
119119
timeRange?: Duration | string;
120120
query?: string;
121+
activityId?: string;
121122
};
122123

123124
export type ArchiveFilterParameters = Omit<FilterParameters, 'timeRange'> & {

src/lib/utilities/query/filter-workflow-query.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export type QueryKey =
1818
| 'CloseTime'
1919
| 'ExecutionTime'
2020
| 'ExecutionStatus'
21-
| 'RunId';
21+
| 'RunId'
22+
| 'ActivityId';
2223

2324
type FilterValue = string | Duration;
2425

@@ -29,6 +30,7 @@ const filterKeys: Readonly<Record<string, QueryKey>> = {
2930
executionStatus: 'ExecutionStatus',
3031
closeTime: 'CloseTime',
3132
runId: 'RunId',
33+
activityId: 'ActivityId',
3234
} as const;
3335

3436
const isValid = (value: unknown, conditional: string): boolean => {

src/lib/utilities/query/list-workflow-query.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ export type QueryKey =
1414
| 'StartTime'
1515
| 'CloseTime'
1616
| 'ExecutionTime'
17-
| 'ExecutionStatus';
17+
| 'ExecutionStatus'
18+
| 'ActivityId';
1819

1920
export type FilterKey =
2021
| 'workflowId'
2122
| 'workflowType'
2223
| 'timeRange'
2324
| 'executionStatus'
24-
| 'closeTime';
25+
| 'closeTime'
26+
| 'activityId';
2527

2628
type FilterValue = string | Duration;
2729

@@ -31,6 +33,7 @@ const queryKeys: Readonly<Record<string, QueryKey>> = {
3133
timeRange: 'StartTime',
3234
executionStatus: 'ExecutionStatus',
3335
closeTime: 'CloseTime',
36+
activityId: 'ActivityId',
3437
} as const;
3538

3639
const filterKeys: readonly FilterKey[] = [
@@ -39,6 +42,7 @@ const filterKeys: readonly FilterKey[] = [
3942
'timeRange',
4043
'executionStatus',
4144
'closeTime',
45+
'activityId',
4246
] as const;
4347

4448
const isValid = (value: unknown): boolean => {

src/lib/utilities/query/to-list-workflow-filters.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const DefaultAttributes: SearchAttributes = {
7979
WorkflowId: SEARCH_ATTRIBUTE_TYPE.KEYWORD,
8080
WorkflowType: SEARCH_ATTRIBUTE_TYPE.KEYWORD,
8181
RunId: SEARCH_ATTRIBUTE_TYPE.KEYWORD,
82+
ActivityId: SEARCH_ATTRIBUTE_TYPE.KEYWORD,
8283
};
8384

8485
export const toListWorkflowFilters = (

src/lib/utilities/query/to-list-workflow-parameters.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const defaultParameters = {
1717
workflowId: '',
1818
workflowType: '',
1919
executionStatus: null,
20-
timeRange: null,
20+
timeRange: undefined,
21+
activityId: '',
2122
};
2223

2324
describe('toListWorkflowParameters', () => {

src/lib/utilities/query/to-list-workflow-parameters.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ const isWorkflowTypeStatement = is('WorkflowType');
3232
const isWorkflowIdStatement = is('WorkflowId');
3333
const isStartTimeStatement = is('StartTime');
3434
const isExecutionStatusStatement = is('ExecutionStatus');
35+
const isActivityIdStatement = is('ActivityId');
3536

3637
export const toListWorkflowParameters = (query: string): ParsedParameters => {
3738
const tokens = tokenize(query);
3839
const parameters: ParsedParameters = {
3940
workflowId: '',
4041
workflowType: '',
4142
executionStatus: null,
42-
timeRange: null,
43+
timeRange: undefined,
44+
activityId: '',
4345
};
4446

4547
tokens.forEach((token, index) => {
@@ -66,6 +68,9 @@ export const toListWorkflowParameters = (query: string): ParsedParameters => {
6668
console.error('Error parsing StartTime from query', error);
6769
}
6870
}
71+
72+
if (isActivityIdStatement(token))
73+
parameters.activityId = getTwoAhead(tokens, index);
6974
});
7075

7176
return parameters;

0 commit comments

Comments
 (0)