Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-dixit authored Jan 14, 2025
2 parents 8050d19 + 6ac3758 commit 62d1de9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
3 changes: 2 additions & 1 deletion js/src/sdk/utils/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { sendBrowserReq, sendProcessReq } from "../../../utils/external";
import logger from "../../../utils/logger";
import { getEnvVariable } from "../../../utils/shared";
import ComposioSDKContext from "../composioContext";
import { TELEMETRY_URL } from "../constants";
Expand Down Expand Up @@ -39,7 +40,7 @@ export async function logError(payload: ErrorPayload) {
}
} catch (error) {
// eslint-disable-next-line no-console
console.error("Error sending error to telemetry", error);
logger.debug("Error sending error to telemetry", error);
// DO NOTHING
}
}
Expand Down
4 changes: 2 additions & 2 deletions js/src/utils/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function sendProcessReq(info: {
// // Close the stdin stream
child.stdin.end();
} catch (error) {
logger.error("Error sending error to telemetry", error);
logger.debug("Error sending error to telemetry", error);
// DO NOTHING
}
}
Expand Down Expand Up @@ -120,7 +120,7 @@ export function sendBrowserReq(info: {
// Send the reporting payload as a JSON string
xhr.send(JSON.stringify(info.data));
} catch (error) {
logger.error("Error sending error to telemetry", error);
logger.debug("Error sending error to telemetry", error);
// DO NOTHING
}
}
38 changes: 35 additions & 3 deletions python/composio/client/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1491,21 +1491,53 @@ def remove(self, id: str) -> None:
self.client.http.delete(url=str(self.endpoint / id))

@t.overload # type: ignore
def get(self) -> t.List[IntegrationModel]: ...
def get(
self,
*,
page_size: t.Optional[int] = None,
page: t.Optional[int] = None,
app_id: t.Optional[str] = None,
app_name: t.Optional[str] = None,
show_disabled: t.Optional[bool] = None,
) -> t.List[IntegrationModel]: ...

@t.overload
def get(self, id: t.Optional[str] = None) -> IntegrationModel: ...

def get(
self, id: t.Optional[str] = None
self,
id: t.Optional[str] = None,
*,
page_size: t.Optional[int] = None,
page: t.Optional[int] = None,
app_id: t.Optional[str] = None,
app_name: t.Optional[str] = None,
show_disabled: t.Optional[bool] = None,
) -> t.Union[t.List[IntegrationModel], IntegrationModel]:
if id is not None:
return IntegrationModel(
**self._raise_if_required(
self.client.http.get(url=str(self.endpoint / id))
).json()
)
return super().get({})

quries = {}
if page_size is not None:
quries["pageSize"] = json.dumps(page_size)

if page is not None:
quries["page"] = json.dumps(page)

if app_id is not None:
quries["appId"] = app_id

if app_name is not None:
quries["appName"] = app_name

if show_disabled is not None:
quries["showDisabled"] = json.dumps(show_disabled)

return super().get(queries=quries)

@te.deprecated("`get_id` is deprecated, use `get(id=id)`")
def get_by_id(
Expand Down
10 changes: 7 additions & 3 deletions python/composio/tools/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1341,16 +1341,20 @@ def get_integrations(
self,
app: t.Optional[AppType] = None,
auth_scheme: t.Optional[AuthSchemeType] = None,
fetch_disabled: bool = False,
) -> t.List[IntegrationModel]:
integrations = self.client.integrations.get()
integrations = self.client.integrations.get(
show_disabled=fetch_disabled,
page_size=999,
)
if app is not None:
app = str(app).lower()
integrations = [i for i in integrations if i.appName.lower() == app]

if auth_scheme is not None:
integrations = [i for i in integrations if i.authScheme == auth_scheme]

return integrations
return sorted(integrations, key=lambda x: x.createdAt)

def get_connected_account(self, id: str) -> ConnectedAccountModel:
return self.client.connected_accounts.get(connection_id=id)
Expand Down Expand Up @@ -1405,7 +1409,7 @@ def _get_integration_for_app(
app: AppType,
auth_scheme: t.Optional[str] = None,
) -> IntegrationModel:
for integration in sorted(self.get_integrations(), key=lambda x: x.createdAt):
for integration in reversed(self.get_integrations(app=app)):
if integration.appName.lower() == str(app).lower():
if (
auth_scheme is not None
Expand Down

0 comments on commit 62d1de9

Please sign in to comment.