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
fix(core): use Stainless-generated types for update() instead of hardcoded strings
Re-export ConnectedAccountPatchParams from @composio/client as UpdateConnectedAccountParams. Remove redundant Zod schema and runtime validation — Stainless client handles this. Add test for credential update via connection param.
Dhawal Upadhyay committed
Apr 10, 2026 at 10:51 UTC
43c1b5025e368f6d26853c7f14461c4cd9da72a7
3 files changed
+23
-42
ts/packages/core/src/models/ConnectedAccounts.ts
+2
-13
@@ -28,7 +28,6 @@ import {
28
ConnectedAccountRefreshOptions,
29
ConnectedAccountRefreshOptionsSchema,
30
UpdateConnectedAccountParams,
31
- UpdateConnectedAccountParamsSchema,
31
} from '../types/connectedAccounts.types';
32
import { ConnectionRequest } from '../types/connectionRequest.types';
33
import { createConnectionRequest } from './ConnectionRequest';
@@ -491,18 +490,8 @@ export class ConnectedAccounts {
490
*/
491
async update(
492
nanoid: string,
494
- params: UpdateConnectedAccountParams
493
+ params: UpdateConnectedAccountParams,
494
): Promise<ConnectedAccountPatchResponse> {
496
- const parsedParams = UpdateConnectedAccountParamsSchema.safeParse(params);
497
- if (!parsedParams.success) {
498
- throw new ValidationError('Failed to parse connected account update params', {
499
- cause: parsedParams.error,
500
- });
501
- }
502
-
503
- return this.client.connectedAccounts.patch(nanoid, {
504
- alias: parsedParams.data.alias,
505
- connection: parsedParams.data.connection,
506
- });
495
+ return this.client.connectedAccounts.patch(nanoid, params);
496
}
497
}
ts/packages/core/src/types/connectedAccounts.types.ts
+3
-25
@@ -213,30 +213,8 @@ export const ConnectedAccountRefreshOptionsSchema = z.object({
213
});
214
export type ConnectedAccountRefreshOptions = z.infer<typeof ConnectedAccountRefreshOptionsSchema>;
215
216
-export const UpdateConnectedAccountParamsSchema = z.object({
217
- alias: z
218
- .string()
219
- .optional()
220
- .describe(
221
- 'Human-readable alias for the account. Must be unique per userId and toolkit within the project. Pass an empty string to clear the alias.'
222
- ),
223
- connection: z
224
- .object({
225
- state: z.object({
226
- authScheme: z.enum([
227
- 'BEARER_TOKEN',
228
- 'API_KEY',
229
- 'BASIC',
230
- 'BASIC_WITH_JWT',
231
- 'GOOGLE_SERVICE_ACCOUNT',
232
- 'SERVICE_ACCOUNT',
233
- ]),
234
- val: z.record(z.unknown()),
235
- }),
236
- })
237
- .optional()
238
- .describe('Credential fields to update. Only provided fields are changed — omitted fields are preserved. Set a field to null to remove it.'),
239
-});
240
-export type UpdateConnectedAccountParams = z.infer<typeof UpdateConnectedAccountParamsSchema>;
216
+// Re-export the Stainless-generated type directly so it stays in sync
217
+// with the API contract without hardcoding auth scheme strings.
218
+export type { ConnectedAccountPatchParams as UpdateConnectedAccountParams } from '@composio/client/resources/connected-accounts';
219
220
// UpdateConnectedAccountResponse is now ConnectedAccountPatchResponse from @composio/client
ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts
+18
-4
@@ -965,10 +965,24 @@ describe('ConnectedAccounts', () => {
965
expect(result).toEqual({ success: true });
966
});
967
968
- it('should throw ValidationError for invalid params', async () => {
969
- await expect(connectedAccounts.update('conn_abc123', { alias: 123 } as any)).rejects.toThrow(
970
- 'Failed to parse connected account update params'
971
- );
968
+ it('should update credentials via connection param', async () => {
969
+ const nanoid = 'conn_abc123';
970
+ const mockResponse = { success: true, id: nanoid, status: 'ACTIVE' };
971
+ const params = {
972
+ connection: {
973
+ state: {
974
+ authScheme: 'BEARER_TOKEN' as const,
975
+ val: { token: 'new-access-token' },
976
+ },
977
+ },
978
+ };
979
+
980
+ extendedMockClient.connectedAccounts.patch.mockResolvedValueOnce(mockResponse);
981
+
982
+ const result = await connectedAccounts.update(nanoid, params);
983
+
984
+ expect(extendedMockClient.connectedAccounts.patch).toHaveBeenCalledWith(nanoid, params);
985
+ expect(result).toEqual({ success: true, id: nanoid, status: 'ACTIVE' });
986
});
987
});
988