@devries-cameron20 / composio Mirror · read-only / commits / 58196802b
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 00:45 UTC

refactor: replace conditional spreads with plain if-checks in ConnectedAccounts

Clean up initiate() and link() to build params objects with simple if-statements instead of ...(condition && { key: value }) spreads. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Zen Agent <zen@composio.dev>

abir committed Apr 9, 2026 at 06:22 UTC 58196802b20086240a133d137b0bd27d43826f85
1 file changed +20 -8
ts/packages/core/src/models/ConnectedAccounts.ts
+20 -8
@@ -193,7 +193,7 @@ export class ConnectedAccounts {
193 // state = connectionDataParsed.data;
194 // }
195
196 - const response = await this.client.connectedAccounts.create({
196 + const createParams: ConnectedAccountCreateParamsRaw = {
197 auth_config: {
198 id: authConfigId,
199 },
@@ -202,9 +202,13 @@ export class ConnectedAccounts {
202 user_id: userId,
203 state,
204 },
205 - ...(options?.alias != null && { alias: options.alias }),
206 - // @TODO: This is a temporary fix to allow api_key to be optional, in future ideally we should fix this from API side
207 - } as ConnectedAccountCreateParamsRaw);
205 + };
206 +
207 + if (options?.alias != null) {
208 + createParams.alias = options.alias;
209 + }
210 +
211 + const response = await this.client.connectedAccounts.create(createParams);
212
213 const redirectUrl =
214 typeof response.connectionData?.val?.redirectUrl === 'string'
@@ -267,12 +271,20 @@ export class ConnectedAccounts {
271 }
272
273 try {
270 - const response = await this.client.link.create({
274 + const linkParams: Record<string, string> = {
275 auth_config_id: authConfigId,
276 user_id: userId,
273 - ...(requestOptions?.data.callbackUrl && { callback_url: requestOptions.data.callbackUrl }),
274 - ...(requestOptions?.data.alias != null && { alias: requestOptions.data.alias }),
275 - });
277 + };
278 +
279 + if (requestOptions?.data.callbackUrl) {
280 + linkParams.callback_url = requestOptions.data.callbackUrl;
281 + }
282 +
283 + if (requestOptions?.data.alias != null) {
284 + linkParams.alias = requestOptions.data.alias;
285 + }
286 +
287 + const response = await this.client.link.create(linkParams);
288
289 const connectionRequest = createConnectionRequest(
290 this.client,