Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enhance type and errors #812

Merged
merged 11 commits into from
Nov 6, 2024
Merged

feat: enhance type and errors #812

merged 11 commits into from
Nov 6, 2024

Conversation

himanshu-dixit
Copy link
Collaborator

@himanshu-dixit himanshu-dixit commented Nov 2, 2024

Important

Enhances error handling and type definitions across the SDK, introducing ComposioError and CEG for standardized error management.

  • Error Handling:
    • Introduces ComposioError and CEG classes in error.ts for standardized error handling.
    • Updates error handling in apps.ts, integrations.ts, triggers.ts, and connectedAccounts.ts to use CEG.handleError().
  • Type Enhancements:
    • Updates function signatures in activeTriggers.ts, apps.ts, connectedAccounts.ts, and integrations.ts to use specific types from types.gen.
    • Adds type annotations to various functions in Entity.ts and Composio.ts.
  • Function Modifications:
    • Replaces getActions with getTools in actionRegistry.spec.ts and base.toolset.ts.
    • Changes client configuration in services.gen.ts to throwOnError: true.

This description was created by Ellipsis for d26f824. It will automatically update as commits are pushed.

Copy link

vercel bot commented Nov 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
composio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 6, 2024 8:03am

Copy link

sweep-ai bot commented Nov 2, 2024

Hey @himanshu-dixit, here is an example of how you can ask me to improve this pull request:

@Sweep Add unit tests for the new `CEG` (Composio Error Generator) class in `error.ts` to verify:
1. Correct error handling for different HTTP status codes
2. Proper error message generation
3. Handling of custom error scenarios
4. Verification of error details like message, description, and possible fix

📖 For more information on how to use Sweep, please read our documentation.

Copy link

github-actions bot commented Nov 2, 2024

This comment was generated by github-actions[bot]!

JS SDK Coverage Report

📊 Coverage report for JS SDK can be found at the following URL:
https://pub-92e668239ab84bfd80ee07d61e9d2f40.r2.dev/coverage-11699472779/coverage/index.html

📁 Test report folder can be found at the following URL:
https://pub-92e668239ab84bfd80ee07d61e9d2f40.r2.dev/html-report-11699472779/html-report/report.html

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on e0b02ca in 18 seconds

More details
  • Looked at 16 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. js/src/index.ts:8
  • Draft comment:
    Consider using import instead of require for consistency with other import statements.
import { APPS, ACTIONS } from "./constants";
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_0DwoLWjlaSzG5CAI


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to febe169 in 1 minute and 17 seconds

More details
  • Looked at 659 lines of code in 14 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. js/src/sdk/actionRegistry.spec.ts:131
  • Draft comment:
    The method getTools is used but not defined in the ActionRegistry class. Ensure that this method is implemented or correct the method name if it's a typo.
  • Reason this comment was not posted:
    Marked as duplicate.
2. js/src/sdk/base.toolset.ts:209
  • Draft comment:
    The method getTools is used but not defined in the ComposioToolSet class. Ensure that this method is implemented or correct the method name if it's a typo.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is incorrect because the getTools method is defined in the class. The comment suggests a missing method, but the method is present, so no code change is required.
    I might be missing some context about how the method is used elsewhere, but based on the file content, the method is defined, so the comment is not valid.
    The presence of the method definition in the file is sufficient evidence to conclude that the comment is incorrect.
    Delete the comment because it incorrectly states that the getTools method is not defined, while it is actually defined in the file.

Workflow ID: wflow_REnxkLGTGo7u8d5F


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -122,13 +122,13 @@ describe("ActionRegistry", () => {

await actionRegistry.createAction(options);

const actions = await actionRegistry.getActions({actions: ["testAction"]});
const actions = await actionRegistry.getTools({actions: ["testAction"]});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method getTools is used but not defined in the ActionRegistry class. Ensure that this method is implemented or correct the method name if it's a typo.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on 632ddba in 58 seconds

More details
  • Looked at 287 lines of code in 9 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. js/src/sdk/models/activeTriggers.ts:47
  • Draft comment:
    Consider validating the response structure before casting it to TActiveTrigger to avoid potential runtime errors.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_uRiNLVDvJrtHUhIt


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

try {
const {data: response} = await apiClient.triggers.getActiveTriggers({ query: data })

const newResponse = response as TActiveTriggersListResponse;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider validating the response structure before casting it to TActiveTriggersListResponse to avoid potential runtime errors.

async create(data: InitiateConnectionPayloadDto) {
try {
const {data: res} = await apiClient.connections.initiateConnection({ body: data });
//@ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using @ts-ignore. Address the TypeScript error directly to ensure type safety.

Suggested change
//@ts-ignore

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on bb215eb in 17 seconds

More details
  • Looked at 132 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. js/src/sdk/models/Entity.ts:135
  • Draft comment:
    Consider using ComposioError for more informative error messages instead of Error. This applies to other instances in this file as well.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The error handling is consistent across methods, but the error messages could be more informative.

Workflow ID: wflow_eZXMqR2uqeMl2CSi


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

createdAt: string;
updatedAt: string;
disabledAt: string | null;
disabledReason: string | null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not important, can we fix the spacing here?

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on d26f824 in 34 seconds

More details
  • Looked at 20 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. js/src/sdk/utils/error.ts:113
  • Draft comment:
    The 401 status code should map to ERROR.BACKEND.UNAUTHORIZED instead of ERROR.COMMON.API_KEY_UNAVAILABLE. This ensures consistency with the error definitions.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_jU3gheOL7YbY5MtW


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@himanshu-dixit himanshu-dixit merged commit 9bf1f25 into master Nov 6, 2024
9 checks passed
@himanshu-dixit himanshu-dixit deleted the ft-type-and-errors branch November 6, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants