Skip to content

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

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

abir58196802b200
diff --git a/ts/packages/core/src/models/ConnectedAccounts.ts b/ts/packages/core/src/models/ConnectedAccounts.ts
index 915e72b50..fbb445d1c 100644
--- a/ts/packages/core/src/models/ConnectedAccounts.ts
+++ b/ts/packages/core/src/models/ConnectedAccounts.ts
@@ -193,7 +193,7 @@ export class ConnectedAccounts {
// state = connectionDataParsed.data;
// }
- const response = await this.client.connectedAccounts.create({
+ const createParams: ConnectedAccountCreateParamsRaw = {
auth_config: {
id: authConfigId,
},
@@ -202,9 +202,13 @@ export class ConnectedAccounts {
user_id: userId,
state,
},
- ...(options?.alias != null && { alias: options.alias }),
- // @TODO: This is a temporary fix to allow api_key to be optional, in future ideally we should fix this from API side
- } as ConnectedAccountCreateParamsRaw);
+ };
+
+ if (options?.alias != null) {
+ createParams.alias = options.alias;
+ }
+
+ const response = await this.client.connectedAccounts.create(createParams);
const redirectUrl =
typeof response.connectionData?.val?.redirectUrl === 'string'
@@ -267,12 +271,20 @@ export class ConnectedAccounts {
}
try {
- const response = await this.client.link.create({
+ const linkParams: Record<string, string> = {
auth_config_id: authConfigId,
user_id: userId,
- ...(requestOptions?.data.callbackUrl && { callback_url: requestOptions.data.callbackUrl }),
- ...(requestOptions?.data.alias != null && { alias: requestOptions.data.alias }),
- });
+ };
+
+ if (requestOptions?.data.callbackUrl) {
+ linkParams.callback_url = requestOptions.data.callbackUrl;
+ }
+
+ if (requestOptions?.data.alias != null) {
+ linkParams.alias = requestOptions.data.alias;
+ }
+
+ const response = await this.client.link.create(linkParams);
const connectionRequest = createConnectionRequest(
this.client,