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

fix: Actions parity in TS SDK #991

Merged
merged 27 commits into from
Dec 12, 2024
Merged
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
46072fb
added 10mb max buffer size
plxity Dec 11, 2024
3b3fec1
ran prettier
plxity Dec 11, 2024
3872ed9
fixed action cli in TS
plxity Dec 11, 2024
b3804c9
fixed action cli in TS
plxity Dec 11, 2024
e899b48
Merge branch 'master' of https://github.com/ComposioHQ/composio into …
plxity Dec 11, 2024
afb4e26
fixed action cli in TS
plxity Dec 11, 2024
bde0b4a
Merge branch 'master' into fix-cli-parity-3
plxity Dec 11, 2024
9e0b2fd
fixed action cli in TS
plxity Dec 11, 2024
f88ccd6
Merge branch 'fix-cli-parity-3' of https://github.com/ComposioHQ/comp…
plxity Dec 11, 2024
1ccdf0d
fixed action cli in TS
plxity Dec 11, 2024
1196135
fixed action cli in TS
plxity Dec 11, 2024
8d890c9
fixed action cli in TS
plxity Dec 11, 2024
5e81f83
Merge branch 'master' into fix-cli-parity-3
plxity Dec 12, 2024
cd42f57
Merge branch 'master' into fix-cli-parity-3
plxity Dec 12, 2024
a0adee3
Merge branch 'master' into fix-cli-parity-3
plxity Dec 12, 2024
7ac89f3
Merge branch 'master' into fix-cli-parity-3
plxity Dec 12, 2024
854f095
Merge branch 'master' into fix-cli-parity-3
plxity Dec 12, 2024
4002cc7
fixed action cli in TS
plxity Dec 11, 2024
0145807
Merge branch 'master' into fix-cli-parity-3
plxity Dec 12, 2024
c94337b
fixed actions cli
plxity Dec 12, 2024
a25004e
fixed actions cli
plxity Dec 12, 2024
2aa2d18
Merge branch 'master' into fix-cli-parity-3
plxity Dec 12, 2024
4f575b3
changed max warning
plxity Dec 12, 2024
02dd841
Merge branch 'fix-cli-parity-3' of https://github.com/ComposioHQ/comp…
plxity Dec 12, 2024
02c31ec
changed max warning
plxity Dec 12, 2024
1c6cb24
fixed prettier
plxity Dec 12, 2024
0a30bf7
changed workflow
plxity Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions js/src/cli/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import chalk from "chalk";
import { Command } from "commander";
import client from "../sdk/client/client";
import { getOpenAPIClient } from "../sdk/utils/config";
import { ListActionsV2Data } from "../sdk/client";

export default class ActionCommand {
private program: Command;

constructor(program: Command) {
this.program = program;
this.program
.command("actions")
.description("Composio Actions")
.option(
"-a, --apps <appName>",
"List all actions for the given apps",
(value, previous: string[]) => previous.concat([value]),
[]
)
.option(
"--tags <tagName>",
"List all actions for the given tags",
(value, previous: string[]) => previous.concat([value]),
[]
)
.option(
"--use-case <useCase>",
"Search for actions based on the given use case"
)
.option("--limit <limit>", "Limit the number of actions to display")
.option("--enabled", "Only show enabled actions")
.action(this.handleAction.bind(this));
}

private async handleAction(options: {
apps?: string[];
tags?: string[];
useCase?: string;
limit?: number;
enabled?: boolean;
}): Promise<void> {
getOpenAPIClient();
const { apps = [], tags = [], useCase, limit, enabled } = options;
if (apps.length === 0) {
console.log(chalk.red("Please provide at least one app name"));

Check warning on line 46 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement

Check warning on line 46 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement
return;
}
const data: ListActionsV2Data = {
query: {},
};
if (data?.query) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The if (data?.query) check is redundant since query is initialized on line 50. Consider removing this check as it will always be true.

if (tags) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The if (tags) check is redundant since tags is defaulted to an empty array in the destructuring. Consider removing this check and simplifying the logic.

data.query.tags = tags.join(",");
}
if (limit) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider adding validation for the limit parameter to ensure it's a positive number. This would prevent potential API errors from invalid input.

data.query.limit = limit;
}
if (enabled) {
data.query.showEnabledOnly = enabled;
}
if (useCase) {
data.query.useCase = useCase;
}
data.query.apps = apps.join(",");
}

try {
const response = await client.actionsV2.listActionsV2(data);
if (response.data?.items.length === 0) {
console.log(chalk.yellow("No actions found"));

Check warning on line 71 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement

Check warning on line 71 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement
return;
}
console.log(chalk.green("Here are the actions for the app:"));

Check warning on line 74 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement

Check warning on line 74 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement
console.log("");

Check warning on line 75 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement

Check warning on line 75 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement
// render list
const actions = response.data?.items || [];
actions.forEach((action) => console.log(action.name));

Check warning on line 78 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement

Check warning on line 78 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider enhancing the action list output to include more useful information like displayName and enabled status. Current output only shows the action name.

} catch (error: any) {

Check warning on line 79 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected any. Specify a different type

Check warning on line 79 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected any. Specify a different type
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider using a more specific type than any for the error. You could create a custom error type or use unknown if the error structure is not known.

console.log(chalk.red(error?.message));

Check warning on line 80 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement

Check warning on line 80 in js/src/cli/actions.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

Unexpected console statement
return;
}
}
}
Loading