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.

feat(connected-accounts): bump @composio/client to alpha.71, drop casts, add tests + error mapping

venkat82483af3607084
diff --git a/.changeset/connected-accounts-acl.md b/.changeset/connected-accounts-acl.md
index 83bcaf958..d580488b7 100644
--- a/.changeset/connected-accounts-acl.md
+++ b/.changeset/connected-accounts-acl.md
@@ -29,4 +29,4 @@ New error classes:
No breaking changes. Existing `link()` callers without the new options get a `PRIVATE` connection exactly as today; existing `get()` / `list()` callers see new optional fields.
-Python SDK gets the matching change in the same release train.
+The Python SDK mirror ships in a separate PR — same wire contract, same release train.
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e32ece8f5..f07ba9c18 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -25,8 +25,8 @@ catalogs:
specifier: ^4.20250917.0
version: 4.20260218.0
'@composio/client':
- specifier: 0.1.0-alpha.70
- version: 0.1.0-alpha.70
+ specifier: 0.1.0-alpha.71
+ version: 0.1.0-alpha.71
'@effect/cli':
specifier: ^0.73.2
version: 0.73.2
@@ -1079,7 +1079,7 @@ importers:
version: link:../cli-local-tools
'@composio/client':
specifier: 'catalog:'
- version: 0.1.0-alpha.70
+ version: 0.1.0-alpha.71
'@composio/core':
specifier: workspace:*
version: link:../core
@@ -1249,7 +1249,7 @@ importers:
dependencies:
'@composio/client':
specifier: 'catalog:'
- version: 0.1.0-alpha.70
+ version: 0.1.0-alpha.71
'@composio/json-schema-to-zod':
specifier: workspace:*
version: link:../json-schema-to-zod
@@ -1912,8 +1912,8 @@ packages:
resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==}
engines: {node: '>=0.1.90'}
- '@composio/[email protected]':
- resolution: {integrity: sha512-bANvjHL9aYwvzcrDL9S2W/uTf6EV3slIpYRL3lAv3k74tTgB1TkYzAWgxxz1OpLK86iDB5xq3RFlritVu23Erg==}
+ '@composio/[email protected]':
+ resolution: {integrity: sha512-6h1IPMbXIx5PjaU0T+a1MNnKHL/pPP7+X2nNQaler5XoENANWGm4mYePjR+7Cgtw1j6X2QkCmRLuX5q9c0INvQ==}
'@cspotcode/[email protected]':
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
@@ -7286,7 +7286,7 @@ snapshots:
'@colors/[email protected]':
optional: true
- '@composio/[email protected]': {}
+ '@composio/[email protected]': {}
'@cspotcode/[email protected]':
dependencies:
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 533a17671..5608a88d4 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -22,7 +22,7 @@ catalog:
'@clack/prompts': '^1.0.1'
'@cloudflare/vitest-pool-workers': ^0.9.2
'@cloudflare/workers-types': ^4.20250917.0
- '@composio/client': 0.1.0-alpha.70
+ '@composio/client': 0.1.0-alpha.71
'@effect/cli': ^0.73.2
'@effect/eslint-plugin': ^0.3.2
'@effect/language-service': ^0.74.0
diff --git a/ts/packages/core/src/errors/ConnectedAccountsErrors.ts b/ts/packages/core/src/errors/ConnectedAccountsErrors.ts
index b18786db8..48cd19d78 100644
--- a/ts/packages/core/src/errors/ConnectedAccountsErrors.ts
+++ b/ts/packages/core/src/errors/ConnectedAccountsErrors.ts
@@ -56,19 +56,6 @@ export class ComposioFailedToCreateConnectedAccountLink extends ComposioError {
}
}
-/**
- * Thrown by `composio.connectedAccounts.initiate()` when the legacy
- * `POST /api/v3/connected_accounts` endpoint rejects a Composio-managed
- * OAuth (OAuth1, OAuth2, DCR_OAUTH) auth-config request.
- *
- * The retiring path is being phased out — new orgs from 2026-05-08 and
- * all remaining orgs from 2026-07-03. Migrate the call to
- * `composio.connectedAccounts.link()`, which works for every redirectable
- * scheme regardless of whether the auth config is Composio-managed or
- * custom.
- *
- * See: https://docs.composio.dev/docs/changelog/2026/04/24
- */
/**
* Thrown when a tool execution attempts to use a SHARED connected account
* but the requesting `userId` is not allowed by the connection's ACL.
@@ -146,6 +133,19 @@ export class ComposioSharedConnectionNotAccessibleError extends ComposioError {
}
}
+/**
+ * Thrown by `composio.connectedAccounts.initiate()` when the legacy
+ * `POST /api/v3/connected_accounts` endpoint rejects a Composio-managed
+ * OAuth (OAuth1, OAuth2, DCR_OAUTH) auth-config request.
+ *
+ * The retiring path is being phased out — new orgs from 2026-05-08 and
+ * all remaining orgs from 2026-07-03. Migrate the call to
+ * `composio.connectedAccounts.link()`, which works for every redirectable
+ * scheme regardless of whether the auth config is Composio-managed or
+ * custom.
+ *
+ * See: https://docs.composio.dev/docs/changelog/2026/04/24
+ */
export class ComposioLegacyConnectedAccountsEndpointRetiredError extends ComposioError {
constructor(
message: string = 'POST /api/v3/connected_accounts is no longer supported for Composio-managed OAuth auth configs. Use composio.connectedAccounts.link() instead.',
diff --git a/ts/packages/core/src/models/ConnectedAccounts.ts b/ts/packages/core/src/models/ConnectedAccounts.ts
index 7b50c19d2..3c34fe703 100644
--- a/ts/packages/core/src/models/ConnectedAccounts.ts
+++ b/ts/packages/core/src/models/ConnectedAccounts.ts
@@ -9,6 +9,8 @@ import ComposioClient, { BadRequestError } from '@composio/client';
import {
ConnectedAccountCreateResponse,
ConnectedAccountDeleteResponse,
+ ConnectedAccountPatchParams,
+ ConnectedAccountPatchResponse,
ConnectedAccountRefreshParams,
ConnectedAccountRefreshResponse,
ConnectedAccountUpdateStatusParams,
@@ -16,6 +18,7 @@ import {
ConnectedAccountListParams as ConnectedAccountListParamsRaw,
ConnectedAccountCreateParams as ConnectedAccountCreateParamsRaw,
} from '@composio/client/resources/connected-accounts';
+import { LinkCreateParams } from '@composio/client/resources/link';
import {
CreateConnectedAccountOptions,
ConnectedAccountRetrieveResponse,
@@ -41,6 +44,7 @@ import {
transformConnectedAccountResponse,
} from '../utils/transformers/connectedAccounts';
import {
+ ComposioAclOnlyForSharedError,
ComposioFailedToCreateConnectedAccountLink,
ComposioLegacyConnectedAccountsEndpointRetiredError,
ComposioMultipleConnectedAccountsError,
@@ -52,41 +56,13 @@ import { ConnectionData } from '../types/connectedAccountAuthStates.types';
// warning on every initiate() call.
let _legacyInitiateWarningEmitted = false;
-// Wire-level fields added by Hermes #9860 / #9882 (account_type) and
-// merged #9902 (ACL). 9902 nests ACL under a single `acl_config_for_shared`
-// object (single JSONB column under the hood). Once @composio/client is
-// regenerated against the post-9902 backend spec, this local extension can
-// be removed and we can rely on the generated `LinkCreateParams` directly.
-type AclConfigWireShape = {
- allow_all_users?: boolean;
- allowed_user_ids?: string[];
- not_allowed_user_ids?: string[];
-};
-
-type LinkCreateBodyWithAcl = ConnectedAccountCreateParamsRaw extends never
- ? never
- : Record<string, unknown> & {
- auth_config_id: string;
- user_id: string;
- alias?: string;
- callback_url?: string;
- account_type?: 'PRIVATE' | 'SHARED';
- acl_config_for_shared?: AclConfigWireShape;
- };
-
-// Wire-level body for PATCH /connected_accounts/{id} with ACL.
-type ConnectedAccountPatchBodyWithAcl = {
- alias?: string;
- acl_config_for_shared?: AclConfigWireShape;
-};
-
/**
* Serialise the SDK's `aclConfigForShared` (camelCase, top-level optional)
* to the wire's `acl_config_for_shared` block. Returns `undefined` when the
* caller didn't pass anything (PATCH-style "don't touch ACL"); returns
- * `{}` when the caller passed an explicit empty object (also "no fields to
- * change", but encodes the explicit intent — the backend treats both the
- * same way today).
+ * `{}` when the caller passed an explicit empty object (the backend treats
+ * both the same way today — deny-by-default — but the explicit form is
+ * preserved so the intent is visible in network traces).
*/
function serializeAclConfigForWire(
acl:
@@ -96,7 +72,7 @@ function serializeAclConfigForWire(
notAllowedUserIds?: string[];
}
| undefined
-): AclConfigWireShape | undefined {
+): LinkCreateParams.ACLConfigForShared | undefined {
if (acl === undefined) return undefined;
return {
...(acl.allowAllUsers !== undefined && { allow_all_users: acl.allowAllUsers }),
@@ -423,21 +399,17 @@ export class ConnectedAccounts {
const opts = requestOptions.data;
const aclWire = serializeAclConfigForWire(opts.aclConfigForShared);
- const body: LinkCreateBodyWithAcl = {
+ const body: LinkCreateParams = {
auth_config_id: authConfigId,
user_id: userId,
- ...(opts.callbackUrl && { callback_url: opts.callbackUrl }),
- ...(opts.alias != null && { alias: opts.alias }),
+ ...(opts.callbackUrl !== undefined && { callback_url: opts.callbackUrl }),
+ ...(opts.alias !== undefined && { alias: opts.alias }),
...(opts.accountType !== undefined && { account_type: opts.accountType }),
...(aclWire !== undefined && { acl_config_for_shared: aclWire }),
};
try {
- // Cast retained until @composio/client adds account_type / ACL fields
- // to LinkCreateParams.
- const response = await this.client.link.create(body as unknown as Parameters<
- typeof this.client.link.create
- >[0]);
+ const response = await this.client.link.create(body);
const connectionRequest = createConnectionRequest(
this.client,
@@ -447,6 +419,16 @@ export class ConnectedAccounts {
);
return connectionRequest;
} catch (error) {
+ // Backend rejects ACL fields on PRIVATE connections with a 400 +
+ // `ConnectedAccount_AclOnlyForShared`. Surface it as a typed error so
+ // callers can `instanceof` instead of grepping messages.
+ if (
+ error instanceof BadRequestError &&
+ typeof error.message === 'string' &&
+ error.message.includes('acl_config_for_shared is only valid on SHARED')
+ ) {
+ throw new ComposioAclOnlyForSharedError(error.message, { cause: error });
+ }
throw new ComposioFailedToCreateConnectedAccountLink(
'Failed to create connected account link',
{
@@ -634,7 +616,11 @@ export class ConnectedAccounts {
}
/**
- * Update a connected account's alias and/or credentials.
+ * Enable or disable a connected account (wraps the `/status` endpoint
+ * — accepts only `{ enabled: boolean }` despite the historical JSDoc
+ * mentioning "alias and/or credentials"). For ACL writes on SHARED
+ * connections, see {@link updateAcl}. Alias / credential PATCH isn't
+ * surfaced on the SDK yet.
*
* @param {string} nanoid - The unique identifier of the connected account
* @param {UpdateConnectedAccountParams} params - The update parameters
@@ -696,8 +682,24 @@ export class ConnectedAccounts {
* // Revoke a previously-granted allow list (back to deny-by-default)
* await composio.connectedAccounts.updateAcl('ca_abc', { allowedUserIds: [] });
* ```
+ *
+ * **Empty-array semantics — read carefully.** Passing `[]` for either
+ * list **replaces** the list, it does not extend it:
+ *
+ * - `allowedUserIds: []` → revoke all previously-granted user IDs (state
+ * reverts to deny-by-default unless `allowAllUsers` is true).
+ * - `notAllowedUserIds: []` → **clears the deny list**, which silently
+ * re-grants access to users you previously blocked. Always pair an
+ * empty deny list with a deliberate audit of the allow side.
+ *
+ * @returns The PATCH response (`{ id, status, success }`). To read the
+ * updated `aclConfigForShared` block, call `get(nanoid)` after the
+ * promise resolves.
*/
- async updateAcl(nanoid: string, params: UpdateConnectedAccountAclParams): Promise<void> {
+ async updateAcl(
+ nanoid: string,
+ params: UpdateConnectedAccountAclParams
+ ): Promise<ConnectedAccountPatchResponse> {
const parsedParams = UpdateConnectedAccountAclParamsSchema.safeParse(params);
if (!parsedParams.success) {
throw new ValidationError('Failed to parse connected account ACL update params', {
@@ -705,15 +707,23 @@ export class ConnectedAccounts {
});
}
- const body: ConnectedAccountPatchBodyWithAcl = {
+ const body: ConnectedAccountPatchParams = {
acl_config_for_shared: serializeAclConfigForWire(parsedParams.data),
};
- // Cast retained until @composio/client adds acl_config_for_shared to
- // ConnectedAccountPatchParams.
- await this.client.connectedAccounts.patch(
- nanoid,
- body as unknown as Parameters<typeof this.client.connectedAccounts.patch>[1]
- );
+ try {
+ return await this.client.connectedAccounts.patch(nanoid, body);
+ } catch (error) {
+ // Same `AclOnlyForShared` 400 the create path can hit — backend
+ // rejects ACL writes on a PRIVATE row at PATCH-time too.
+ if (
+ error instanceof BadRequestError &&
+ typeof error.message === 'string' &&
+ error.message.includes('acl_config_for_shared is only valid on SHARED')
+ ) {
+ throw new ComposioAclOnlyForSharedError(error.message, { cause: error });
+ }
+ throw error;
+ }
}
}
diff --git a/ts/packages/core/src/models/ToolRouterSession.ts b/ts/packages/core/src/models/ToolRouterSession.ts
index ee12f5356..bf6e5eb6f 100644
--- a/ts/packages/core/src/models/ToolRouterSession.ts
+++ b/ts/packages/core/src/models/ToolRouterSession.ts
@@ -1,5 +1,5 @@
import { telemetry } from '../telemetry/Telemetry';
-import { Composio as ComposioClient } from '@composio/client';
+import { Composio as ComposioClient, BadRequestError } from '@composio/client';
import { BaseComposioProvider } from '../provider/BaseProvider';
import { ComposioConfig } from '../composio';
import {
@@ -33,7 +33,7 @@ import {
} from '../types/connectedAccounts.types';
import { transform } from '../utils/transform';
import { ToolkitConnectionStateSchema } from '../types/toolRouter.types';
-import { ValidationError } from '../errors';
+import { ComposioAclOnlyForSharedError, ValidationError } from '../errors';
import { Tools } from './Tools';
import { ToolRouterSessionFilesMount } from './ToolRouterSessionFileMount';
import type {
@@ -47,6 +47,7 @@ import type { Tool, ToolExecuteResponse } from '../types/tool.types';
import type { SessionProxyExecuteParams } from '../types/toolRouter.types';
import type {
SessionExecuteParams,
+ SessionLinkParams,
SessionSearchParams,
} from '@composio/client/resources/tool-router/session/session.mjs';
import { SessionProxyExecuteParamsSchema } from '../types/toolRouter.types';
@@ -321,7 +322,7 @@ export class ToolRouterSession<
aclConfigForShared?: ConnectedAccountAclConfig;
}
): Promise<ConnectionRequest> {
- const aclWire =
+ const aclWire: SessionLinkParams.ACLConfigForShared | undefined =
options?.aclConfigForShared === undefined
? undefined
: {
@@ -335,19 +336,30 @@ export class ToolRouterSession<
not_allowed_user_ids: options.aclConfigForShared.notAllowedUserIds,
}),
};
- // Cast retained until @composio/client adds account_type +
- // acl_config_for_shared to SessionLinkParams (Hermes #9860 + #9902).
- const body = {
+ const body: SessionLinkParams = {
toolkit,
- ...(options?.callbackUrl && { callback_url: options.callbackUrl }),
- ...(options?.alias != null && { alias: options.alias }),
+ ...(options?.callbackUrl !== undefined && { callback_url: options.callbackUrl }),
+ ...(options?.alias !== undefined && { alias: options.alias }),
...(options?.accountType !== undefined && { account_type: options.accountType }),
...(aclWire !== undefined && { acl_config_for_shared: aclWire }),
};
- const response = await this.client.toolRouter.session.link(
- this.sessionId,
- body as unknown as Parameters<typeof this.client.toolRouter.session.link>[1]
- );
+
+ let response;
+ try {
+ response = await this.client.toolRouter.session.link(this.sessionId, body);
+ } catch (error) {
+ // Backend rejects ACL fields on PRIVATE connections with a 400 +
+ // `ConnectedAccount_AclOnlyForShared`. Surface it as a typed error
+ // mirroring `composio.connectedAccounts.link()`.
+ if (
+ error instanceof BadRequestError &&
+ typeof error.message === 'string' &&
+ error.message.includes('acl_config_for_shared is only valid on SHARED')
+ ) {
+ throw new ComposioAclOnlyForSharedError(error.message, { cause: error });
+ }
+ throw error;
+ }
return createConnectionRequest(
this.client,
diff --git a/ts/packages/core/src/types/connectedAccounts.types.ts b/ts/packages/core/src/types/connectedAccounts.types.ts
index be5e9d41f..bad43af21 100644
--- a/ts/packages/core/src/types/connectedAccounts.types.ts
+++ b/ts/packages/core/src/types/connectedAccounts.types.ts
@@ -347,6 +347,10 @@ export const UpdateConnectedAccountParamsSchema = z.object({
* Each field is optional, but at least one must be provided — passing an
* empty object is rejected as a no-op.
*/
+// NOTE: `UpdateConnectedAccountAclParamsSchema` is a ZodEffects (because of
+// the `.refine` below) — it does not expose `.shape`. If you need to reuse
+// individual ACL fields elsewhere, pull them from
+// `ConnectedAccountAclConfigSchema.shape` (the unrefined base) instead.
export const UpdateConnectedAccountAclParamsSchema = ConnectedAccountAclConfigSchema.refine(
acl =>
acl.allowAllUsers !== undefined ||
diff --git a/ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts b/ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts
index bb12f8057..45ab3c57f 100644
--- a/ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts
+++ b/ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts
@@ -4,9 +4,11 @@ import { ConnectedAccounts } from '../../src/models/ConnectedAccounts';
import ComposioClient from '@composio/client';
import { ConnectedAccountRetrieveResponse } from '@composio/client/resources/connected-accounts.mjs';
import {
+ ComposioAclOnlyForSharedError,
ComposioConnectedAccountNotFoundError,
ComposioFailedToCreateConnectedAccountLink,
} from '../../src/errors';
+import { BadRequestError } from '@composio/client';
import { ConnectedAccountStatuses } from '../../src/types/connectedAccounts.types';
import { ComposioMultipleConnectedAccountsError } from '../../src/errors';
import { AuthSchemeTypes } from '../../src/types/authConfigs.types';
@@ -22,6 +24,7 @@ const extendedMockClient = {
retrieve: vi.fn(),
delete: vi.fn(),
refresh: vi.fn(),
+ patch: vi.fn(),
updateStatus: vi.fn(),
createConnectedAccountLink: vi.fn(),
},
@@ -1517,4 +1520,177 @@ describe('ConnectedAccounts', () => {
expect(connectionRequest).toHaveProperty('id', 'conn_new');
});
});
+
+ describe('link with accountType + ACL (Hermes #9860, #9902)', () => {
+ beforeEach(() => {
+ extendedMockClient.connectedAccounts.list.mockResolvedValue({
+ items: [],
+ next_cursor: null,
+ total_pages: 0,
+ });
+ extendedMockClient.link.create.mockResolvedValue({
+ connected_account_id: 'conn_shared_abc',
+ redirect_url: 'https://connect.composio.dev/auth?token=xyz',
+ });
+ });
+
+ it('forwards accountType=SHARED + nested aclConfigForShared to client.link.create', async () => {
+ await connectedAccounts.link('user_123', 'auth_config_123', {
+ accountType: 'SHARED',
+ aclConfigForShared: {
+ allowAllUsers: true,
+ notAllowedUserIds: ['user_bob'],
+ },
+ });
+
+ expect(extendedMockClient.link.create).toHaveBeenCalledWith({
+ auth_config_id: 'auth_config_123',
+ user_id: 'user_123',
+ account_type: 'SHARED',
+ acl_config_for_shared: {
+ allow_all_users: true,
+ not_allowed_user_ids: ['user_bob'],
+ },
+ });
+ });
+
+ it('omits acl_config_for_shared when aclConfigForShared is undefined', async () => {
+ await connectedAccounts.link('user_123', 'auth_config_123', { accountType: 'SHARED' });
+
+ const body = extendedMockClient.link.create.mock.calls[0][0];
+ expect(body.account_type).toBe('SHARED');
+ expect('acl_config_for_shared' in body).toBe(false);
+ });
+
+ it('serializes only the fields the caller provided (PATCH-style on inner block)', async () => {
+ await connectedAccounts.link('user_123', 'auth_config_123', {
+ accountType: 'SHARED',
+ aclConfigForShared: { allowedUserIds: ['user_alice'] },
+ });
+
+ expect(extendedMockClient.link.create).toHaveBeenCalledWith({
+ auth_config_id: 'auth_config_123',
+ user_id: 'user_123',
+ account_type: 'SHARED',
+ acl_config_for_shared: { allowed_user_ids: ['user_alice'] },
+ });
+ });
+
+ it('preserves explicit empty arrays in the serialized body', async () => {
+ await connectedAccounts.link('user_123', 'auth_config_123', {
+ accountType: 'SHARED',
+ aclConfigForShared: { allowedUserIds: [], notAllowedUserIds: [] },
+ });
+
+ expect(extendedMockClient.link.create).toHaveBeenCalledWith({
+ auth_config_id: 'auth_config_123',
+ user_id: 'user_123',
+ account_type: 'SHARED',
+ acl_config_for_shared: {
+ allowed_user_ids: [],
+ not_allowed_user_ids: [],
+ },
+ });
+ });
+
+ it('maps 400 AclOnlyForShared to ComposioAclOnlyForSharedError', async () => {
+ extendedMockClient.link.create.mockReset();
+ extendedMockClient.link.create.mockRejectedValueOnce(
+ Object.assign(new BadRequestError(400, undefined, 'acl_config_for_shared is only valid on SHARED connections.', {}), {})
+ );
+
+ await expect(
+ connectedAccounts.link('user_123', 'auth_config_123', {
+ accountType: 'PRIVATE',
+ aclConfigForShared: { allowAllUsers: true },
+ })
+ ).rejects.toBeInstanceOf(ComposioAclOnlyForSharedError);
+ });
+
+ it('falls back to ComposioFailedToCreateConnectedAccountLink on unrelated errors', async () => {
+ extendedMockClient.link.create.mockReset();
+ extendedMockClient.link.create.mockRejectedValueOnce(new Error('network died'));
+
+ await expect(connectedAccounts.link('user_123', 'auth_config_123')).rejects.toBeInstanceOf(
+ ComposioFailedToCreateConnectedAccountLink
+ );
+ });
+ });
+
+ describe('updateAcl', () => {
+ it('serializes PATCH body with nested acl_config_for_shared', async () => {
+ extendedMockClient.connectedAccounts.patch.mockResolvedValueOnce({
+ id: 'ca_abc',
+ status: 'ACTIVE',
+ success: true,
+ });
+
+ const result = await connectedAccounts.updateAcl('ca_abc', {
+ allowAllUsers: true,
+ notAllowedUserIds: ['user_bob'],
+ });
+
+ expect(extendedMockClient.connectedAccounts.patch).toHaveBeenCalledWith('ca_abc', {
+ acl_config_for_shared: {
+ allow_all_users: true,
+ not_allowed_user_ids: ['user_bob'],
+ },
+ });
+ expect(result).toEqual({ id: 'ca_abc', status: 'ACTIVE', success: true });
+ });
+
+ it('omits absent fields from the inner block (PATCH semantics)', async () => {
+ extendedMockClient.connectedAccounts.patch.mockResolvedValueOnce({
+ id: 'ca_abc',
+ status: 'ACTIVE',
+ success: true,
+ });
+
+ await connectedAccounts.updateAcl('ca_abc', { allowedUserIds: ['user_alice'] });
+
+ expect(extendedMockClient.connectedAccounts.patch).toHaveBeenCalledWith('ca_abc', {
+ acl_config_for_shared: { allowed_user_ids: ['user_alice'] },
+ });
+ });
+
+ it('preserves empty array to clear a list', async () => {
+ extendedMockClient.connectedAccounts.patch.mockResolvedValueOnce({
+ id: 'ca_abc',
+ status: 'ACTIVE',
+ success: true,
+ });
+
+ await connectedAccounts.updateAcl('ca_abc', { allowedUserIds: [] });
+
+ expect(extendedMockClient.connectedAccounts.patch).toHaveBeenCalledWith('ca_abc', {
+ acl_config_for_shared: { allowed_user_ids: [] },
+ });
+ });
+
+ it('rejects an empty params object via the refine', async () => {
+ await expect(connectedAccounts.updateAcl('ca_abc', {})).rejects.toMatchObject({
+ name: 'ValidationError',
+ });
+ expect(extendedMockClient.connectedAccounts.patch).not.toHaveBeenCalled();
+ });
+
+ it('maps 400 AclOnlyForShared to ComposioAclOnlyForSharedError', async () => {
+ extendedMockClient.connectedAccounts.patch.mockRejectedValueOnce(
+ new BadRequestError(400, undefined, 'acl_config_for_shared is only valid on SHARED connections.', {})
+ );
+
+ await expect(
+ connectedAccounts.updateAcl('ca_abc', { allowAllUsers: true })
+ ).rejects.toBeInstanceOf(ComposioAclOnlyForSharedError);
+ });
+
+ it('rethrows non-AclOnlyForShared errors unchanged', async () => {
+ const otherError = new Error('connection lost');
+ extendedMockClient.connectedAccounts.patch.mockRejectedValueOnce(otherError);
+
+ await expect(
+ connectedAccounts.updateAcl('ca_abc', { allowAllUsers: true })
+ ).rejects.toBe(otherError);
+ });
+ });
});