Skip to content

Commit 5cb73ae

Browse files
committed
improvement(jira): reuse shared transformUser utility in search_users
1 parent a78027a commit 5cb73ae

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

apps/sim/tools/jira/search_users.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
import type { JiraSearchUsersParams, JiraSearchUsersResponse } from '@/tools/jira/types'
22
import { TIMESTAMP_OUTPUT, USER_OUTPUT_PROPERTIES } from '@/tools/jira/types'
3-
import { getJiraCloudId } from '@/tools/jira/utils'
3+
import { getJiraCloudId, transformUser } from '@/tools/jira/utils'
44
import type { ToolConfig } from '@/tools/types'
55

6-
/**
7-
* Transforms a raw Jira user API object into typed output.
8-
*/
9-
function transformUserOutput(user: any) {
10-
return {
11-
accountId: user.accountId ?? '',
12-
accountType: user.accountType ?? null,
13-
active: user.active ?? false,
14-
displayName: user.displayName ?? '',
15-
emailAddress: user.emailAddress ?? null,
16-
avatarUrl: user.avatarUrls?.['48x48'] ?? null,
17-
timeZone: user.timeZone ?? null,
18-
self: user.self ?? null,
19-
}
20-
}
21-
226
export const jiraSearchUsersTool: ToolConfig<JiraSearchUsersParams, JiraSearchUsersResponse> = {
237
id: 'jira_search_users',
248
name: 'Jira Search Users',
@@ -144,7 +128,10 @@ export const jiraSearchUsersTool: ToolConfig<JiraSearchUsersParams, JiraSearchUs
144128
success: true,
145129
output: {
146130
ts: new Date().toISOString(),
147-
users: users.map(transformUserOutput),
131+
users: users.map((user: any) => ({
132+
...transformUser(user),
133+
self: user.self ?? null,
134+
})),
148135
total: users.length,
149136
},
150137
}

0 commit comments

Comments
 (0)