-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Changes from 5 commits
46072fb
3b3fec1
3872ed9
b3804c9
e899b48
afb4e26
bde0b4a
9e0b2fd
f88ccd6
1ccdf0d
1196135
8d890c9
5e81f83
cd42f57
a0adee3
7ac89f3
854f095
4002cc7
0145807
c94337b
a25004e
2aa2d18
4f575b3
02dd841
02c31ec
1c6cb24
0a30bf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
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", "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; | ||
copy?: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
}): Promise<void> { | ||
getOpenAPIClient(); | ||
const { apps = [], tags = [], useCase, limit, enabled } = options; | ||
if (apps) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check |
||
const data: ListActionsV2Data = { | ||
query: {}, | ||
}; | ||
if (data?.query) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
if (tags) { | ||
data.query.tags = tags.join(","); | ||
} | ||
if (limit) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding validation for the |
||
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")); | ||
return; | ||
} | ||
console.log(chalk.green("Here are the actions for the app:")); | ||
console.log(""); | ||
// render list | ||
const actions = response.data?.items || []; | ||
actions.forEach((action) => console.log(action.name)); | ||
} catch (error) { | ||
console.log(chalk.red((error as any).message)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error type casting to |
||
return; | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
--use-case
option is defined but not used in the command options. Consider adding<useCase>
to the option definition to accept a value.