@devries-cameron20 / composio Mirror · read-only / commits / 9e9a5ecae
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 20:45 UTC

feat(cli): add "--type-tools" support to "ts generate" command; implement optional input/output type generation for tools

jkomyno committed Aug 26, 2025 at 03:42 UTC 9e9a5ecae5512e9888ffb919566df67296722ec4
25 files changed +1359 -950
ts/packages/cli/src/commands/generate.cmd.ts
+10 -3
@@ -11,17 +11,24 @@ export const outputOpt = Options.optional(
11 })
12 ).pipe(Options.withAlias('o'), Options.withDescription('Output directory for type stubs'));
13
14 +export const typeTools = Options.boolean('type-tools').pipe(
15 + Options.withDefault(false),
16 + Options.withDescription(
17 + 'Whether to emit type stubs for tools. This only applies to TypeScript projects.'
18 + )
19 +);
20 +
21 /**
22 * @example
23 * ```bash
24 * composio generate <command>
25 * ```
26 */
20 -export const generateCmd = Command.make('generate', { outputOpt }).pipe(
27 +export const generateCmd = Command.make('generate', { outputOpt, typeTools }).pipe(
28 Command.withDescription(
29 'Updates the local type stubs with the latest app data, automatically detecting the language of the project in the current working directory (TypeScript | Python).'
30 ),
24 - Command.withHandler(({ outputOpt }) =>
31 + Command.withHandler(({ outputOpt, typeTools }) =>
32 Effect.gen(function* () {
33 const process = yield* NodeProcess;
34 const cwd = process.cwd;
@@ -34,7 +41,7 @@ export const generateCmd = Command.make('generate', { outputOpt }).pipe(
41 // Redirect to either `ts generate` or `py generate` commands
42 yield* Match.value(envLang).pipe(
43 Match.when('TypeScript', () =>
37 - generateTypescriptTypeStubs({ outputOpt, compact: false, transpiled: false })
44 + generateTypescriptTypeStubs({ outputOpt, compact: false, transpiled: false, typeTools })
45 ),
46 Match.when('Python', () => generatePythonTypeStubs({ outputOpt })),
47 Match.exhaustive
ts/packages/cli/src/commands/login.cmd.ts
+1 -1
@@ -1,4 +1,4 @@
1 -import { Command, Options, Prompt } from '@effect/cli';
1 +import { Command, Options } from '@effect/cli';
2 import { Effect, Console, Schedule } from 'effect';
3 import { green } from 'ansis';
4 import open, { apps } from 'open';
ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts
+4 -2
@@ -55,7 +55,7 @@ export function generatePythonTypeStubs({ outputOpt }: GetCmdParams<typeof _pyCm
55 const [toolkits, tools, triggerTypes] = yield* Effect.all(
56 [
57 Effect.logDebug('Fetching toolkits...').pipe(Effect.flatMap(() => client.getToolkits())),
58 - Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getTools())),
58 + Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getToolsAsEnums())),
59 Effect.logDebug('Fetching trigger types payloads...').pipe(
60 Effect.flatMap(() => client.getTriggerTypes(triggerTypesAsEnums.length))
61 ),
@@ -63,7 +63,9 @@ export function generatePythonTypeStubs({ outputOpt }: GetCmdParams<typeof _pyCm
63 { concurrency: 'unbounded' }
64 );
65
66 - const index = createToolkitIndex({ toolkits, tools, triggerTypes });
66 + const typeableTools = { withTypes: false as const, tools };
67 +
68 + const index = createToolkitIndex({ toolkits, typeableTools, triggerTypes });
69
70 // Generate Python sources
71 const sources = generatePythonSources({
ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
+36 -6
@@ -17,6 +17,7 @@
17 import path from 'node:path';
18 import { Command, Options } from '@effect/cli';
19 import { Console, Effect, Option, pipe } from 'effect';
20 +import { Match } from 'effect';
21 import { FileSystem } from '@effect/platform';
22 import { ComposioToolkitsRepository } from 'src/services/composio-clients';
23 import { NodeProcess } from 'src/services/node-process';
@@ -46,10 +47,16 @@ export const transpiled = Options.boolean('transpiled').pipe(
47 Options.withDescription('Whether to emit transpiled JavaScript alongside TypeScript files')
48 );
49
50 +export const typeTools = Options.boolean('type-tools').pipe(
51 + Options.withDefault(false),
52 + Options.withDescription('Whether to emit type stubs for tools')
53 +);
54 +
55 const _tsCmd$Generate = Command.make('generate', {
56 outputOpt,
57 compact,
58 transpiled: transpiled,
59 + typeTools,
60 }).pipe(Command.withDescription('Updates the local type stubs with the latest app data.'));
61
62 /**
@@ -89,6 +96,7 @@ export const tsCmd$Generate = _tsCmd$Generate.pipe(
96 export function generateTypescriptTypeStubs({
97 outputOpt,
98 compact,
99 + typeTools,
100 transpiled = false,
101 }: GetCmdParams<typeof _tsCmd$Generate> & { transpiled?: boolean }) {
102 return Effect.gen(function* () {
@@ -116,14 +124,16 @@ export function generateTypescriptTypeStubs({
124 // Fetch data from Composio API
125 yield* Console.log('Fetching latest data from Composio API...');
126
119 - const triggerTypesAsEnums = yield* Effect.logDebug('Fetching trigger types...').pipe(
120 - Effect.flatMap(() => client.getTriggerTypesAsEnums())
121 - );
127 + const [triggerTypesAsEnums, toolsAsEnums] = yield* Effect.all([
128 + Effect.logDebug('Fetching trigger types...').pipe(
129 + Effect.flatMap(() => client.getTriggerTypesAsEnums())
130 + ),
131 + Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getToolsAsEnums())),
132 + ]);
133
123 - const [toolkits, tools, triggerTypes] = yield* Effect.all(
134 + const [toolkits, triggerTypes] = yield* Effect.all(
135 [
136 Effect.logDebug('Fetching toolkits...').pipe(Effect.flatMap(() => client.getToolkits())),
126 - Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getTools())),
137 Effect.logDebug('Fetching trigger types payloads...').pipe(
138 Effect.flatMap(() => client.getTriggerTypes(triggerTypesAsEnums.length))
139 ),
@@ -131,7 +141,27 @@ export function generateTypescriptTypeStubs({
141 { concurrency: 'unbounded' }
142 );
143
134 - const index = createToolkitIndex({ toolkits, tools, triggerTypes });
144 + // Only fetch tools if `--type-tools` was specified
145 + const typeableTools = yield* Match.value(typeTools).pipe(
146 + Match.when(true, typePredicate =>
147 + Effect.logDebug('Fetching tools...').pipe(
148 + Effect.flatMap(() => client.getTools(toolsAsEnums.length)),
149 + Effect.map(tools => ({
150 + withTypes: typePredicate,
151 + tools,
152 + }))
153 + )
154 + ),
155 + Match.when(false, typePredicate =>
156 + Effect.succeed({
157 + withTypes: typePredicate,
158 + tools: toolsAsEnums,
159 + })
160 + ),
161 + Match.exhaustive
162 + );
163 +
164 + const index = createToolkitIndex({ toolkits, typeableTools, triggerTypes });
165
166 // Generate TypeScript sources
167 const sources = yield* generateTypeScriptSources({
ts/packages/cli/src/effects/force-config.ts
+1 -1
@@ -1,4 +1,4 @@
1 -import { Config, Option } from 'effect';
1 +import { Config } from 'effect';
2
3 type FORCE_CONFIG = Config.Config.Wrap<{
4 USE_CACHE: boolean;
ts/packages/cli/src/generation/create-toolkit-index.ts
+47 -9
@@ -1,7 +1,7 @@
1 -import { pipe, String, Record } from 'effect';
1 +import { pipe, String, Record, Match } from 'effect';
2 import type { Simplify } from 'effect/Types';
3 import { Toolkit, Toolkits, ToolkitName } from 'src/models/toolkits';
4 -import { Tools } from 'src/models/tools';
4 +import { ToolsAsEnums, Tools, ToolAsEnum, Tool } from 'src/models/tools';
5 import { TriggerType, TriggerTypes } from 'src/models/trigger-types';
6
7 const startsWith =
@@ -11,13 +11,15 @@ const startsWith =
11
12 interface CreateToolkitIndexInput {
13 toolkits: Toolkits; // e.g., [ { slug: 'gmail', ... }]
14 - tools: Tools; // e.g., [ 'GMAIL_SEND_EMAIL' ]
14 + typeableTools: { withTypes: false; tools: ToolsAsEnums } | { withTypes: true; tools: Tools }; // e.g., [ 'GMAIL_SEND_EMAIL' ] | [ { slug: 'GMAIL_SEND_EMAIL', ... } ]
15 triggerTypes: TriggerTypes; // e.g., [ { slug: 'GMAIL_NEW_EMAIL', ... } ]
16 }
17
18 export type ToolkitIndexData = Simplify<{
19 slug: string;
20 - tools: Record<`${ToolkitName}_${string}`, string>;
20 + typeableTools:
21 + | { withTypes: false; value: Record<`${ToolkitName}_${string}`, ToolAsEnum> }
22 + | { withTypes: true; value: Record<`${ToolkitName}_${string}`, Tool> };
23 triggerTypes: Record<`${ToolkitName}_${string}`, TriggerType>;
24 }>;
25
@@ -37,14 +39,34 @@ export function createToolkitIndex(input: CreateToolkitIndexInput): Simplify<Too
39 const stripPrefix = String.slice(key.length + 1);
40
41 const { slug } = value.toolkit;
40 - const tools = value.tools.map(tool => [stripPrefix(tool), tool] as const);
42 +
43 + const typeableTools = Match.value(value.typeableTools).pipe(
44 + Match.when({ withTypes: true }, ({ withTypes, tools }) => {
45 + return {
46 + withTypes,
47 + value: Record.fromEntries(tools.map(tool => [stripPrefix(tool.slug), tool] as const)),
48 + };
49 + }),
50 + Match.when({ withTypes: false }, ({ withTypes, tools }) => {
51 + return {
52 + withTypes,
53 + value: Record.fromEntries(tools.map(tool => [stripPrefix(tool), tool] as const)),
54 + };
55 + }),
56 + Match.exhaustive
57 + );
58 +
59 const triggerTypes = value.triggerTypes.map(
60 triggerType => [stripPrefix(triggerType.slug), triggerType] as const
61 );
62
63 return [
64 key,
47 - { slug, tools: Record.fromEntries(tools), triggerTypes: Record.fromEntries(triggerTypes) },
65 + {
66 + slug,
67 + typeableTools,
68 + triggerTypes: Record.fromEntries(triggerTypes),
69 + },
70 ] as const;
71 })
72 );
@@ -58,7 +80,9 @@ type GroupByToolkitOutput<T extends ToolkitName> = [
80 Uppercase<T>,
81 {
82 toolkit: Toolkit;
61 - tools: Array<`${Uppercase<T>}_${string}`>;
83 + typeableTools:
84 + | { withTypes: false; tools: Array<`${Uppercase<T>}_${string}`> }
85 + | { withTypes: true; tools: Array<Tool & { slug: `${Uppercase<T>}_${string}` }> };
86 triggerTypes: Array<TriggerTypeWithUppercaseSlug<T>>;
87 },
88 ];
@@ -66,18 +90,32 @@ type GroupByToolkitOutput<T extends ToolkitName> = [
90 const groupByToolkit =
91 <const T extends string>(toolkit: Omit<Toolkit, 'name'> & { name: T }) =>
92 ({
69 - tools,
93 + typeableTools,
94 triggerTypes,
95 }: Omit<CreateToolkitIndexInput, 'toolkits'>): GroupByToolkitOutput<T & ToolkitName> => {
96 const toolkitName = pipe(toolkit.slug, String.toUpperCase, ToolkitName) as Uppercase<
97 T & ToolkitName
98 >;
99
100 + const filteredTypeableTools = Match.value(typeableTools).pipe(
101 + Match.when({ withTypes: true }, ({ withTypes, tools }) => ({
102 + withTypes,
103 + tools: tools.filter(tool => startsWith(`${toolkitName}_`)(tool.slug)) as Array<
104 + Tool & { slug: `${typeof toolkitName}_${string}` }
105 + >,
106 + })),
107 + Match.when({ withTypes: false }, ({ withTypes, tools }) => ({
108 + withTypes,
109 + tools: tools.filter(startsWith(`${toolkitName}_`)),
110 + })),
111 + Match.exhaustive
112 + );
113 +
114 return [
115 toolkitName,
116 {
117 toolkit,
80 - tools: tools.filter(startsWith(`${toolkitName}_`)),
118 + typeableTools: filteredTypeableTools,
119 triggerTypes: triggerTypes.filter(triggerType =>
120 startsWith(`${toolkitName}_`)(triggerType.slug)
121 ) as Array<TriggerTypeWithUppercaseSlug<T & ToolkitName>>,
ts/packages/cli/src/generation/python/generate-toolkit-sources.ts
+13 -3
@@ -31,7 +31,7 @@
31 * ```
32 */
33
34 -import { pipe, Record } from 'effect';
34 +import { Match, pipe, Record } from 'effect';
35 import type { ToolkitName } from 'src/models/toolkits';
36 import type { ToolkitIndex, ToolkitIndexData } from 'src/generation/create-toolkit-index';
37 import type { SourceFile } from 'src/generation/types';
@@ -120,8 +120,18 @@ function generatePythonToolkitSource(banner: string) {
120 const toolsEntries = (spacing: number) => {
121 const spacePad = ' '.repeat(spacing);
122
123 - if (Record.size(toolkit.tools) > 0) {
124 - return Object.entries(toolkit.tools)
123 + if (Object.keys(toolkit.typeableTools.value).length > 0) {
124 + const tools = Match.value(toolkit.typeableTools).pipe(
125 + Match.when({ withTypes: true }, ({ value }) =>
126 + Record.mapEntries(value, (toolValue, toolName) => [toolName, toolValue.slug])
127 + ),
128 + Match.when({ withTypes: false }, ({ value }) =>
129 + Record.mapEntries(value, (toolValue, toolName) => [toolName, toolValue])
130 + ),
131 + Match.exhaustive
132 + );
133 +
134 + return Object.entries(tools)
135 .map(([toolName, toolValue]) => `${spacePad}${toolName} = "${toolValue}"`)
136 .join('\n');
137 }
ts/packages/cli/src/generation/typescript/generate-toolkit-sources.ts
+110 -3
@@ -116,7 +116,7 @@ export function generateTypeScriptToolkitSources(banner: string) {
116 function generateTypeScriptToolkitSource(_banner: string) {
117 return (
118 toolkitName: ToolkitName,
119 - { slug, tools, triggerTypes }: ToolkitIndexData
119 + { slug, typeableTools, triggerTypes }: ToolkitIndexData
120 ): Effect.Effect<SourceFile, GenerateTypeFromJsonSchemaError, never> => {
121 return Effect.gen(function* () {
122 const filename = `${slug}.ts`;
@@ -129,6 +129,107 @@ function generateTypeScriptToolkitSource(_banner: string) {
129 );
130 }
131
132 + if (typeableTools.withTypes) {
133 + file.add(
134 + ts.docSectionComment(
135 + `// --------------- //
136 + // Tool types //
137 + // --------------- //
138 + `
139 + )
140 + );
141 +
142 + // write type declarations for each tool, without exporting them
143 + for (const [toolName, tool] of Record.toEntries(typeableTools.value)) {
144 + // e.g., `type GMAIL_SEND_EMAIL_INPUT = { .. }`
145 + const toolInputType = yield* generateTypeFromJsonSchema(
146 + `${toolkitName}_${toolName}_INPUT`,
147 + tool.input_parameters
148 + );
149 +
150 + // e.g., `type GMAIL_SEND_EMAIL_OUTPUT = { .. }`
151 + const toolOutputType = yield* generateTypeFromJsonSchema(
152 + `${toolkitName}_${toolName}_OUTPUT`,
153 + tool.output_parameters
154 + );
155 +
156 + file.add(
157 + ts
158 + .typeDeclaration(tool.slug, toolInputType)
159 + .setDocComment(ts.docComment(`Type of ${toolkitName}'s ${tool.slug} tool input.`))
160 + );
161 +
162 + file.add(
163 + ts
164 + .typeDeclaration(tool.slug, toolOutputType)
165 + .setDocComment(ts.docComment(`Type of ${toolkitName}'s ${tool.slug} tool output.`))
166 + );
167 + }
168 +
169 + // write the map of input tool types
170 + {
171 + const toolInputTypeEntries = pipe(
172 + typeableTools.value,
173 + Record.map((_, toolName) =>
174 + ts.property(toolName, ts.namedType(`${toolkitName}_${toolName}_INPUT`))
175 + ),
176 + Record.toEntries,
177 + Arr.map(([_, value]) => value)
178 + );
179 +
180 + const doc = ts.docComment(
181 + `Type map of all available tool input types for toolkit "${toolkitName}".`
182 + );
183 +
184 + file.add(
185 + ts
186 + .moduleExport(
187 + ts.typeDeclaration(
188 + `${toolkitName}_TOOL_INPUTS`,
189 + ts.objectType().addMultiple(toolInputTypeEntries)
190 + )
191 + )
192 + .setDocComment(doc)
193 + );
194 + }
195 +
196 + // write the map of output tool types
197 + {
198 + const toolOutputTypeEntries = pipe(
199 + typeableTools.value,
200 + Record.map((_, toolName) =>
201 + ts.property(toolName, ts.namedType(`${toolkitName}_${toolName}_OUTPUT`))
202 + ),
203 + Record.toEntries,
204 + Arr.map(([_, value]) => value)
205 + );
206 +
207 + const doc = ts.docComment(
208 + `Type map of all available tool input types for toolkit "${toolkitName}".`
209 + );
210 +
211 + file.add(
212 + ts
213 + .moduleExport(
214 + ts.typeDeclaration(
215 + `${toolkitName}_TOOL_OUTPUTS`,
216 + ts.objectType().addMultiple(toolOutputTypeEntries)
217 + )
218 + )
219 + .setDocComment(doc)
220 + );
221 + }
222 + }
223 +
224 + file.add(
225 + ts.docSectionComment(
226 + `// ------------------- //
227 + // Trigger types //
228 + // ------------------- //
229 + `
230 + )
231 + );
232 +
233 // write type declarations for each trigger payload, without exporting them
234 for (const [triggerTypeSlug, triggerType] of Record.toEntries(triggerTypes)) {
235 // e.g., `type GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD = { .. }`
@@ -136,7 +237,13 @@ function generateTypeScriptToolkitSource(_banner: string) {
237 `${toolkitName}_${triggerTypeSlug}_PAYLOAD`,
238 triggerType.payload
239 );
139 - file.add(ts.typeDeclaration(triggerTypeSlug, triggerPayloadType));
240 + file.add(
241 + ts
242 + .typeDeclaration(triggerTypeSlug, triggerPayloadType)
243 + .setDocComment(
244 + ts.docComment(`Type of ${toolkitName}'s ${triggerTypeSlug} trigger payload.`)
245 + )
246 + );
247 }
248
249 // write the toolkit const object declaration
@@ -151,7 +258,7 @@ function generateTypeScriptToolkitSource(_banner: string) {
258 ts
259 .objectValue()
260 .addMultiple(
154 - Object.entries(tools).map(([toolName, tool]) =>
261 + Object.entries(typeableTools.value).map(([toolName, tool]) =>
262 ts.propertyValue(toolName, ts.stringLiteral(tool).asValue())
263 )
264 )
ts/packages/cli/src/generation/typescript/generate.ts
+3 -3
@@ -20,21 +20,21 @@ export function generateTypeScriptSources(params: GenerateTypeScriptSourcesParam
20 index: ToolkitIndex
21 ): Effect.Effect<Array<SourceFile>, GenerateTypeFromJsonSchemaError, never> =>
22 Effect.gen(function* () {
23 - const toolkiteSources = yield* generateTypeScriptToolkitSources(params.banner)(index);
23 + const toolkitSources = yield* generateTypeScriptToolkitSources(params.banner)(index);
24
25 const indexSource = generateIndexSource(params)(index);
26 const indexFilename = path.join(params.outputDir, 'index.ts');
27
28 if (!params.emitSingleFile) {
29 return [
30 - ...toolkiteSources.map(
30 + ...toolkitSources.map(
31 ([filename, content]) => [path.join(params.outputDir, filename), content] as const
32 ),
33 [indexFilename, indexSource] as const,
34 ] as const;
35 }
36
37 - const localToolkitsSources = toolkiteSources.map(([_, content]) => content).join('\n');
37 + const localToolkitsSources = toolkitSources.map(([_, content]) => content).join('\n');
38
39 const indexSourceSingleFile = `${ts.stringify(ts.docComment(params.banner))}
40 ${localToolkitsSources}
ts/packages/cli/src/models/tools.ts
+50 -8
@@ -2,21 +2,21 @@ import { Brand, Schema } from 'effect';
2 import { JSONTransformSchema } from './utils/json-transform-schema';
3 import { extractActual } from './utils/extract-actual';
4
5 -export const Tool = Schema.String.annotations({ identifier: 'Tool' });
6 -export type Tool = Schema.Schema.Type<typeof Tool>;
5 +export const ToolAsEnum = Schema.String.annotations({ identifier: 'ToolAsEnum' });
6 +export type ToolAsEnum = Schema.Schema.Type<typeof ToolAsEnum>;
7
8 -export const Tools = Schema.Array(Tool).annotations({
9 - identifier: 'Array<Tool>',
8 +export const ToolsAsEnums = Schema.Array(ToolAsEnum).annotations({
9 + identifier: 'Array<ToolAsEnum>',
10 message: issue => ({
11 message: `Expected an array of strings, got ${extractActual(issue)}`,
12 override: true,
13 }),
14 });
15 -export type Tools = Schema.Schema.Type<typeof Tools>;
15 +export type ToolsAsEnums = Schema.Schema.Type<typeof ToolsAsEnums>;
16
17 -export const ToolsJSON = JSONTransformSchema(Tools);
18 -export const toolsFromJSON = Schema.decode(ToolsJSON);
19 -export const toolsToJSON = Schema.encode(ToolsJSON);
17 +export const ToolsAsEnumsJSON = JSONTransformSchema(ToolsAsEnums);
18 +export const toolsAsEnumsFromJSON = Schema.decode(ToolsAsEnumsJSON);
19 +export const toolsAsEnumsToJSON = Schema.encode(ToolsAsEnumsJSON);
20
21 // E.g., `SEND_EMAIL`
22 export type ToolName = string & Brand.Brand<'ToolName'>;
@@ -25,3 +25,45 @@ export const ToolName = Brand.nominal<ToolName>();
25 // E.g., `GMAIL_SEND_EMAIL`
26 export type ToolNameWithToolkitPrefix = string & Brand.Brand<'ToolNameWithToolkitPrefix'>;
27 export const ToolNameWithToolkitPrefix = Brand.nominal<ToolNameWithToolkitPrefix>();
28 +
29 +/**
30 + * Tool with payload
31 + */
32 +export const Tool = Schema.Struct({
33 + /**
34 + * List of available versions of this tool
35 + */
36 + available_versions: Schema.Array(Schema.String),
37 + /**
38 + * Human-readable display name of the tool
39 + */
40 + name: Schema.String,
41 + /**
42 + * Unique identifier for the tool
43 + */
44 + slug: ToolAsEnum,
45 + /**
46 + * Schema definition of required input parameters for the tool
47 + */
48 + input_parameters: Schema.Record({ key: Schema.String, value: Schema.Unknown }),
49 + /**
50 + * Schema definition of required output parameters for the tool
51 + */
52 + output_parameters: Schema.Record({ key: Schema.String, value: Schema.Unknown }),
53 + /**
54 + * Detailed explanation of the tool's functionality and purpose.
55 + */
56 + description: Schema.String,
57 + /**
58 + * List of tags associated with the tool for categorization and filtering.
59 + */
60 + tags: Schema.Array(Schema.String),
61 +}).annotations({ identifier: 'Tool' });
62 +export type Tool = Schema.Schema.Type<typeof Tool>;
63 +
64 +export const Tools = Schema.Array(Tool).annotations({ identifier: 'Array<Tool>' });
65 +export type Tools = Schema.Schema.Type<typeof Tools>;
66 +
67 +export const ToolsJSON = JSONTransformSchema(Tools);
68 +export const ToolsFromJSON = Schema.decode(ToolsJSON);
69 +export const ToolsToJSON = Schema.encode(ToolsJSON);
ts/packages/cli/src/models/trigger-types.ts
-1
@@ -1,7 +1,6 @@
1 import { Brand, Schema } from 'effect';
2 import { JSONTransformSchema } from './utils/json-transform-schema';
3 import { extractActual } from './utils/extract-actual';
4 -import { Toolkit } from './toolkits';
4
5 /**
6 * TriggerType as Enums
ts/packages/cli/src/services/composio-clients-cached.ts
+22 -6
@@ -7,7 +7,12 @@ import { FORCE_CONFIG } from 'src/effects/force-config';
7 import { ComposioToolkitsRepository } from './composio-clients';
8 import { NodeOs } from './node-os';
9 import { toolkitsFromJSON, toolkitsToJSON } from 'src/models/toolkits';
10 -import { toolsFromJSON, toolsToJSON } from 'src/models/tools';
10 +import {
11 + toolsAsEnumsFromJSON,
12 + toolsAsEnumsToJSON,
13 + ToolsFromJSON,
14 + ToolsToJSON,
15 +} from 'src/models/tools';
16 import {
17 TriggerTypesAsEnumsFromJSON,
18 TriggerTypesAsEnumsToJSON,
@@ -22,6 +27,7 @@ import { ConfigLive } from './config';
27 export const CACHE_FILES = {
28 toolkits: 'toolkits.json',
29 tools: 'tools.json',
30 + toolsAsEnums: 'tools-as-enums.json',
31 triggerTypesAsEnums: 'trigger-types-as-enums.json',
32 triggerTypes: 'trigger-types.json',
33 } as const;
@@ -118,12 +124,12 @@ export const ComposioToolkitsRepositoryCached = Layer.effect(
124 );
125 },
126
121 - getTools: () => {
127 + getToolsAsEnums: () => {
128 return createCachedEffect(
123 - CACHE_FILES.tools,
124 - toolsFromJSON,
125 - toolsToJSON,
126 - underlyingRepository.getTools()
129 + CACHE_FILES.toolsAsEnums,
130 + toolsAsEnumsFromJSON,
131 + toolsAsEnumsToJSON,
132 + underlyingRepository.getToolsAsEnums()
133 );
134 },
135
@@ -145,6 +151,16 @@ export const ComposioToolkitsRepositoryCached = Layer.effect(
151 underlyingRepository.getTriggerTypes(limit)
152 );
153 },
154 +
155 + getTools: (limit: number) => {
156 + return createCachedEffect(
157 + // We don't care about the limit in the cache file name
158 + CACHE_FILES.tools,
159 + ToolsFromJSON,
160 + ToolsToJSON,
161 + underlyingRepository.getTools(limit)
162 + );
163 + },
164 });
165 })
166 ).pipe(
ts/packages/cli/src/services/composio-clients.ts
+34 -8
@@ -1,7 +1,7 @@
1 import { pipe, Data, Effect, Option, Schema, Array, Order, ParseResult } from 'effect';
2 import { Composio as _RawComposioClient } from '@composio/client';
3 import { Toolkit, Toolkits } from 'src/models/toolkits';
4 -import { Tools } from 'src/models/tools';
4 +import { ToolsAsEnums, Tools, Tool } from 'src/models/tools';
5 import { Session, RetrievedSession } from 'src/models/session';
6 import { TriggerType, TriggerTypes, TriggerTypesAsEnums } from 'src/models/trigger-types';
7 import { ComposioUserContext, ComposioUserContextLive } from './user-context';
@@ -45,7 +45,14 @@ export const ToolkitsResponse = Schema.Struct({
45 }).annotations({ identifier: 'ToolkitsResponse' });
46 export type ToolkitsResponse = Schema.Schema.Type<typeof ToolkitsResponse>;
47
48 -export const ToolsResponse = Tools;
48 +export const ToolsAsEnumsResponse = ToolsAsEnums;
49 +export type ToolsAsEnumsResponse = Schema.Schema.Type<typeof ToolsAsEnumsResponse>;
50 +
51 +export const ToolsResponse = Schema.Struct({
52 + items: Tools,
53 + total_pages: Schema.Int,
54 + next_cursor: Schema.NullOr(Schema.Int),
55 +}).annotations({ identifier: 'ToolsResponse' });
56 export type ToolsResponse = Schema.Schema.Type<typeof ToolsResponse>;
57
58 export const TriggerTypesAsEnumsResponse = TriggerTypesAsEnums;
@@ -182,7 +189,17 @@ export class ComposioClientLive extends Effect.Service<ComposioClientLive>()(
189 * Retrieve a list of all available tool enumeration values (tool slugs) for the project.
190 */
191 retrieveEnum: () =>
185 - callClient(clientSingleton, client => client.tools.retrieveEnum(), ToolsResponse),
192 + callClient(
193 + clientSingleton,
194 + client => client.tools.retrieveEnum(),
195 + ToolsAsEnumsResponse
196 + ),
197 + /**
198 + * Retrieve a list of $limit trigger types, containing their payload.
199 + * Usually, you would call this with a limit matching the length of the list returned by `retrieveEnum`.
200 + */
201 + list: (params: { limit: number }) =>
202 + callClient(clientSingleton, client => client.tools.list(params), ToolsResponse),
203 },
204 triggersTypes: {
205 /**
@@ -242,7 +259,6 @@ export class ComposioToolkitsRepository extends Effect.Service<ComposioToolkitsR
259 getToolkits: () =>
260 client.toolkits.list().pipe(
261 Effect.map(response => response.items),
245 - Effect.tap(Effect.logDebug),
262 Effect.flatMap(
263 Effect.fn(function* (toolkits) {
264 // Sort apps by slug.
@@ -252,13 +268,23 @@ export class ComposioToolkitsRepository extends Effect.Service<ComposioToolkitsR
268 })
269 )
270 ),
255 - getTools: () => client.tools.retrieveEnum().pipe(Effect.tap(Effect.logDebug)),
256 - getTriggerTypesAsEnums: () =>
257 - client.triggersTypes.retrieveEnum().pipe(Effect.tap(Effect.logDebug)),
271 + getToolsAsEnums: () => client.tools.retrieveEnum(),
272 + getTools: (limit: number) =>
273 + client.tools.list({ limit }).pipe(
274 + Effect.map(response => response.items),
275 + Effect.flatMap(
276 + Effect.fn(function* (tools) {
277 + // Sort apps by slug.
278 + // TODO: make sure this happens on the server-side.
279 + const orderBySlug = Order.mapInput(Order.string, (app: Tool) => app.slug);
280 + return Array.sort(tools, orderBySlug) as ReadonlyArray<Tool>;
281 + })
282 + )
283 + ),
284 + getTriggerTypesAsEnums: () => client.triggersTypes.retrieveEnum(),
285 getTriggerTypes: (limit: number) =>
286 client.triggersTypes.list({ limit }).pipe(
287 Effect.map(response => response.items),
261 - Effect.tap(Effect.logDebug),
288 Effect.flatMap(
289 Effect.fn(function* (triggerTypes) {
290 // Sort apps by slug.
ts/packages/cli/src/services/config.ts
+1 -1
@@ -1,4 +1,4 @@
1 -import { Option, Effect, ConfigProvider, Layer, Logger, LogLevel } from 'effect';
1 +import { Option, Effect, ConfigProvider, Layer, Logger } from 'effect';
2 import * as constants from 'src/constants';
3 import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
4 import { APP_CONFIG } from 'src/effects/app-config';
ts/packages/cli/test/__utils__/services/test-layer.ts
+4 -3
@@ -24,7 +24,7 @@ import {
24 } from 'src/services/composio-clients';
25 import { EnvLangDetector } from 'src/services/env-lang-detector';
26 import { JsPackageManagerDetector } from 'src/services/js-package-manager-detector';
27 -import type { Tools } from 'src/models/tools';
27 +import type { ToolsAsEnums } from 'src/models/tools';
28 import type { TriggerTypes, TriggerTypesAsEnums } from 'src/models/trigger-types';
29 import { ComposioUserContextLive } from 'src/services/user-context';
30 import { UpgradeBinary } from 'src/services/upgrade-binary';
@@ -48,7 +48,7 @@ export interface TestLiveInput {
48 */
49 toolkitsData?: {
50 toolkits?: Toolkits;
51 - tools?: Tools;
51 + tools?: ToolsAsEnums;
52 triggerTypesAsEnums?: TriggerTypesAsEnums;
53 triggerTypes?: TriggerTypes;
54 };
@@ -90,9 +90,10 @@ export const TestLayer = (input?: TestLiveInput) =>
90 ComposioToolkitsRepository,
91 new ComposioToolkitsRepository({
92 getToolkits: () => Effect.succeed(toolkitsData.toolkits),
93 - getTools: () => Effect.succeed(toolkitsData.tools),
93 + getToolsAsEnums: () => Effect.succeed(toolkitsData.tools),
94 getTriggerTypesAsEnums: () => Effect.succeed(toolkitsData.triggerTypesAsEnums),
95 getTriggerTypes: limit => Effect.succeed(toolkitsData.triggerTypes.slice(0, limit)),
96 + getTools: limit => Effect.succeed(toolkitsData.tools.slice(0, limit)),
97 })
98 );
99
ts/packages/cli/test/src/commands/$default.cmd.test.ts
+10 -10
@@ -58,25 +58,25 @@ describe('CLI: composio', () => {
58
59 COMMANDS
60
61 - - version Display your account information.
61 + - version Display your account information.
62
63 - - upgrade Upgrade your Composio CLI to the latest available version.
63 + - upgrade Upgrade your Composio CLI to the latest available version.
64
65 - - whoami Display your account information.
65 + - whoami Display your account information.
66
67 - - login [--no-browser] Log in to the Composio SDK.
67 + - login [--no-browser] Log in to the Composio SDK.
68
69 - - logout Log out from the Composio SDK.
69 + - logout Log out from the Composio SDK.
70
71 - - generate [(-o, --output-dir directory)] Updates the local type stubs with the latest app data, automatically detecting the language of the project in the current working directory (TypeScript | Python).
71 + - generate [(-o, --output-dir directory)] [--type-tools] Updates the local type stubs with the latest app data, automatically detecting the language of the project in the current working directory (TypeScript | Python).
72
73 - - py Handle Python projects.
73 + - py Handle Python projects.
74
75 - - py generate [(-o, --output-dir directory)] Updates the local type stubs with the latest app data.
75 + - py generate [(-o, --output-dir directory)] Updates the local type stubs with the latest app data.
76
77 - - ts Handle TypeScript projects.
77 + - ts Handle TypeScript projects.
78
79 - - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] Updates the local type stubs with the latest app data.
79 + - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] Updates the local type stubs with the latest app data.
80 "
81 `);
82 })
ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
+32 -2
@@ -64,6 +64,15 @@ describe('CLI: composio ts generate', () => {
64 expect(gmailSourceCode).toMatchInlineSnapshot(`
65 "import { type TriggerEvent } from "@composio/core"
66
67 + // ------------------- //
68 + // Trigger types //
69 + // ------------------- //
70 +
71 +
72 +
73 + /**
74 + * Type of GMAIL's NEW_GMAIL_MESSAGE trigger payload.
75 + */
76 type GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD = {
77 /**
78 * Attachment List
@@ -288,7 +297,13 @@ describe('CLI: composio ts generate', () => {
297 "
298 `);
299 expect(slackSourceCode).toMatchInlineSnapshot(`
291 - "/**
300 + "// ------------------- //
301 + // Trigger types //
302 + // ------------------- //
303 +
304 +
305 +
306 + /**
307 * Map of Composio's SLACK toolkit.
308 */
309 export const SLACK = {
@@ -392,6 +407,15 @@ describe('CLI: composio ts generate', () => {
407 expect(gmailSourceCode).toMatchInlineSnapshot(`
408 "import { type TriggerEvent } from "@composio/core"
409
410 + // ------------------- //
411 + // Trigger types //
412 + // ------------------- //
413 +
414 +
415 +
416 + /**
417 + * Type of GMAIL's NEW_GMAIL_MESSAGE trigger payload.
418 + */
419 type GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD = {
420 /**
421 * Attachment List
@@ -616,7 +640,13 @@ describe('CLI: composio ts generate', () => {
640 "
641 `);
642 expect(slackSourceCode).toMatchInlineSnapshot(`
619 - "/**
643 + "// ------------------- //
644 + // Trigger types //
645 + // ------------------- //
646 +
647 +
648 +
649 + /**
650 * Map of Composio's SLACK toolkit.
651 */
652 export const SLACK = {
ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts
+3 -3
@@ -11,7 +11,7 @@ describe('generatePythonToolkitSources', () => {
11 it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty array', () => {
12 const index = createToolkitIndex({
13 toolkits: [],
14 - tools: [],
14 + typeableTools: { withTypes: false, tools: [] },
15 triggerTypes: [],
16 });
17
@@ -30,7 +30,7 @@ describe('generatePythonToolkitSources', () => {
30
31 const index = createToolkitIndex({
32 toolkits,
33 - tools: [],
33 + typeableTools: { withTypes: false, tools: [] },
34 triggerTypes: [],
35 });
36
@@ -71,7 +71,7 @@ describe('generatePythonToolkitSources', () => {
71
72 const index = createToolkitIndex({
73 toolkits,
74 - tools: [...TOOLS_GMAIL.slice(0, 3)],
74 + typeableTools: { withTypes: false, tools: [...TOOLS_GMAIL.slice(0, 3)] },
75 triggerTypes: [...TRIGGER_TYPES_GMAIL],
76 });
77
ts/packages/cli/test/src/generation/toolkit-index.test.ts
+13 -10
@@ -7,7 +7,7 @@ describe('createToolkitIndex', () => {
7 it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty index', () => {
8 const index = createToolkitIndex({
9 toolkits: [],
10 - tools: [],
10 + typeableTools: { withTypes: false, tools: [] },
11 triggerTypes: [],
12 });
13
@@ -28,19 +28,19 @@ describe('createToolkitIndex', () => {
28
29 const index = createToolkitIndex({
30 toolkits,
31 - tools: [],
31 + typeableTools: { withTypes: false, tools: [] },
32 triggerTypes: [],
33 });
34
35 expect(index).toEqual({
36 GMAIL: {
37 slug: 'gmail',
38 - tools: {},
38 + typeableTools: { withTypes: false, value: {} },
39 triggerTypes: {},
40 },
41 SLACK: {
42 slug: 'slack',
43 - tools: {},
43 + typeableTools: { withTypes: false, value: {} },
44 triggerTypes: {},
45 },
46 });
@@ -67,17 +67,20 @@ describe('createToolkitIndex', () => {
67
68 const index = createToolkitIndex({
69 toolkits,
70 - tools,
70 + typeableTools: { withTypes: false, tools },
71 triggerTypes,
72 });
73
74 expect(index).toEqual({
75 GMAIL: {
76 slug: 'gmail',
77 - tools: {
78 - CREATE_EMAIL_DRAFT: 'GMAIL_CREATE_EMAIL_DRAFT',
79 - DELETE_MESSAGE: 'GMAIL_DELETE_MESSAGE',
80 - FETCH_EMAILS: 'GMAIL_FETCH_EMAILS',
77 + typeableTools: {
78 + withTypes: false,
79 + value: {
80 + CREATE_EMAIL_DRAFT: 'GMAIL_CREATE_EMAIL_DRAFT',
81 + DELETE_MESSAGE: 'GMAIL_DELETE_MESSAGE',
82 + FETCH_EMAILS: 'GMAIL_FETCH_EMAILS',
83 + },
84 },
85 triggerTypes: {
86 NEW_GMAIL_MESSAGE: GMAIL_NEW_GMAIL_MESSAGE,
@@ -85,7 +88,7 @@ describe('createToolkitIndex', () => {
88 },
89 SLACK: {
90 slug: 'slack',
88 - tools: {},
91 + typeableTools: { withTypes: false, value: {} },
92 triggerTypes: {},
93 },
94 });
ts/packages/cli/test/src/generation/typescript/generate-index-source.test.ts
+12 -6
@@ -28,7 +28,7 @@ describe('generateTypeScriptToolkitSources', () => {
28 it('[Given] empty toolkits, tools, triggerTypes [Then] it creates a valid but empty index map', () => {
29 const index = createToolkitIndex({
30 toolkits: [],
31 - tools: [],
31 + typeableTools: { withTypes: false, tools: [] },
32 triggerTypes: [],
33 });
34
@@ -71,7 +71,7 @@ describe('generateTypeScriptToolkitSources', () => {
71
72 const index = createToolkitIndex({
73 toolkits,
74 - tools: [],
74 + typeableTools: { withTypes: false, tools: [] },
75 triggerTypes: [],
76 });
77
@@ -119,7 +119,10 @@ describe('generateTypeScriptToolkitSources', () => {
119
120 const index = createToolkitIndex({
121 toolkits,
122 - tools: [...TOOLS_GMAIL.slice(0, 3), ...TOOLS_GITHUB.slice(0, 3)],
122 + typeableTools: {
123 + withTypes: false,
124 + tools: [...TOOLS_GMAIL.slice(0, 3), ...TOOLS_GITHUB.slice(0, 3)],
125 + },
126 triggerTypes: [...TRIGGER_TYPES_GITHUB, ...TRIGGER_TYPES_GMAIL],
127 });
128
@@ -173,7 +176,7 @@ describe('generateTypeScriptToolkitSources', () => {
176 it('[Given] empty toolkits, tools, triggerTypes [Then] it creates a valid but empty index map', () => {
177 const index = createToolkitIndex({
178 toolkits: [],
176 - tools: [],
179 + typeableTools: { withTypes: false, tools: [] },
180 triggerTypes: [],
181 });
182
@@ -220,7 +223,7 @@ describe('generateTypeScriptToolkitSources', () => {
223
224 const index = createToolkitIndex({
225 toolkits,
223 - tools: [],
226 + typeableTools: { withTypes: false, tools: [] },
227 triggerTypes: [],
228 });
229
@@ -274,7 +277,10 @@ describe('generateTypeScriptToolkitSources', () => {
277
278 const index = createToolkitIndex({
279 toolkits,
277 - tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
280 + typeableTools: {
281 + withTypes: false,
282 + tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
283 + },
284 triggerTypes: [...TRIGGER_TYPES_GMAIL],
285 });
286
ts/packages/cli/test/src/generation/typescript/generate-toolkit-source.test.ts
+874 -817
@@ -20,7 +20,7 @@ describe('generateTypeScriptToolkitSources', () => {
20 Effect.fn(function* () {
21 const index = createToolkitIndex({
22 toolkits: [],
23 - tools: [],
23 + typeableTools: { withTypes: false, tools: [] },
24 triggerTypes: [],
25 });
26
@@ -42,7 +42,7 @@ describe('generateTypeScriptToolkitSources', () => {
42
43 const index = createToolkitIndex({
44 toolkits,
45 - tools: [],
45 + typeableTools: { withTypes: false, tools: [] },
46 triggerTypes: [],
47 });
48
@@ -51,26 +51,32 @@ describe('generateTypeScriptToolkitSources', () => {
51 expect(sources[0]).toHaveLength(2);
52 expect(sources[0][0]).toBe('slack.ts');
53 expect(sources[0][1]).toMatchInlineSnapshot(`
54 - "/**
55 - * Map of Composio's SLACK toolkit.
56 - */
57 - export const SLACK = {
58 - slug: "slack",
59 - tools: {},
60 - triggerTypes: {},
61 - }
54 + "// ------------------- //
55 + // Trigger types //
56 + // ------------------- //
57
63 - /**
64 - * Type map of all available trigger payloads for toolkit "SLACK".
65 - */
66 - export type SLACK_TRIGGER_PAYLOADS = {}
58
68 - /**
69 - * Type map of all available trigger events for toolkit "SLACK".
70 - */
71 - export type SLACK_TRIGGER_EVENTS = {}
72 - "
73 - `);
59 +
60 + /**
61 + * Map of Composio's SLACK toolkit.
62 + */
63 + export const SLACK = {
64 + slug: "slack",
65 + tools: {},
66 + triggerTypes: {},
67 + }
68 +
69 + /**
70 + * Type map of all available trigger payloads for toolkit "SLACK".
71 + */
72 + export type SLACK_TRIGGER_PAYLOADS = {}
73 +
74 + /**
75 + * Type map of all available trigger events for toolkit "SLACK".
76 + */
77 + export type SLACK_TRIGGER_EVENTS = {}
78 + "
79 + `);
80 })
81 );
82
@@ -98,11 +104,14 @@ describe('generateTypeScriptToolkitSources', () => {
104
105 const index = createToolkitIndex({
106 toolkits,
101 - tools: [
102 - ...TOOLS_GITHUB.slice(0, 3),
103 - ...TOOLS_GMAIL.slice(0, 3),
104 - ...TOOLS_GOOGLEDRIVE.slice(0, 3),
105 - ],
107 + typeableTools: {
108 + withTypes: false,
109 + tools: [
110 + ...TOOLS_GITHUB.slice(0, 3),
111 + ...TOOLS_GMAIL.slice(0, 3),
112 + ...TOOLS_GOOGLEDRIVE.slice(0, 3),
113 + ],
114 + },
115 triggerTypes: [
116 ...TRIGGER_TYPES_GITHUB,
117 ...TRIGGER_TYPES_GMAIL,
@@ -116,882 +125,930 @@ describe('generateTypeScriptToolkitSources', () => {
125 expect(sources[0]).toHaveLength(2);
126 expect(sources[0][0]).toBe('gmail.ts');
127 expect(sources[0][1]).toMatchInlineSnapshot(`
119 - "import { type TriggerEvent } from "@composio/core"
128 + "import { type TriggerEvent } from "@composio/core"
129 +
130 + // ------------------- //
131 + // Trigger types //
132 + // ------------------- //
133 +
134 +
135
121 - type GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD = {
122 - /**
123 - * Attachment List
124 - * @description The list of attachments in the message
125 - * @default null
126 - */
127 - attachment_list: unknown[] | null;
128 - /**
129 - * Message ID
130 - * @description The message ID of the message
131 - * @default null
132 - */
133 - message_id: string | null;
134 - /**
135 - * Message Text
136 - * @description The text of the message
137 - * @default null
138 - */
139 - message_text: string | null;
140 - /**
141 - * Message Timestamp
142 - * @description The timestamp of the message
143 - * @default null
144 - */
145 - message_timestamp: string | null;
146 - /**
147 - * Payload
148 - * @description The payload of the message
149 - * @default null
150 - */
151 - payload: Record<string, never> | null;
152 - /**
153 - * Sender
154 - * @description The sender of the message
155 - * @default null
156 - */
157 - sender: string | null;
158 - /**
159 - * Subject
160 - * @description The subject of the message
161 - * @default null
162 - */
163 - subject: string | null;
136 /**
165 - * Thread ID
166 - * @description The thread ID of the message
167 - * @default null
137 + * Type of GMAIL's NEW_GMAIL_MESSAGE trigger payload.
138 */
169 - thread_id: string | null;
139 + type GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD = {
140 + /**
141 + * Attachment List
142 + * @description The list of attachments in the message
143 + * @default null
144 + */
145 + attachment_list: unknown[] | null;
146 + /**
147 + * Message ID
148 + * @description The message ID of the message
149 + * @default null
150 + */
151 + message_id: string | null;
152 + /**
153 + * Message Text
154 + * @description The text of the message
155 + * @default null
156 + */
157 + message_text: string | null;
158 + /**
159 + * Message Timestamp
160 + * @description The timestamp of the message
161 + * @default null
162 + */
163 + message_timestamp: string | null;
164 + /**
165 + * Payload
166 + * @description The payload of the message
167 + * @default null
168 + */
169 + payload: Record<string, never> | null;
170 + /**
171 + * Sender
172 + * @description The sender of the message
173 + * @default null
174 + */
175 + sender: string | null;
176 + /**
177 + * Subject
178 + * @description The subject of the message
179 + * @default null
180 + */
181 + subject: string | null;
182 + /**
183 + * Thread ID
184 + * @description The thread ID of the message
185 + * @default null
186 + */
187 + thread_id: string | null;
188 + /**
189 + * To
190 + * @description The recipient of the message
191 + * @default null
192 + */
193 + to: string | null;
194 + };
195 +
196 /**
171 - * To
172 - * @description The recipient of the message
173 - * @default null
197 + * Map of Composio's GMAIL toolkit.
198 */
175 - to: string | null;
176 - };
177 -
178 - /**
179 - * Map of Composio's GMAIL toolkit.
180 - */
181 - export const GMAIL = {
182 - slug: "gmail",
183 - tools: {
184 - ADD_LABEL_TO_EMAIL: "GMAIL_ADD_LABEL_TO_EMAIL",
185 - CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
186 - CREATE_LABEL: "GMAIL_CREATE_LABEL",
187 - },
188 - triggerTypes: {
189 - NEW_GMAIL_MESSAGE: {
190 - slug: "GMAIL_NEW_GMAIL_MESSAGE",
191 - name: "New Gmail Message Received Trigger",
192 - description: "Triggers when a new message is received in Gmail.",
193 - instructions: "\\n **Instructions for Setting Up the Trigger:**\\n\\n - Ensure that the Gmail API is enabled for your Google account.\\n - Provide the user ID (usually 'me' for the authenticated user).\\n - Optionally, provide label IDs to filter messages.\\n ",
194 - config: {
195 - properties: {
196 - interval: {
197 - default: 1,
198 - description: "Periodic Interval to Check for Updates & Send a Trigger in Minutes",
199 - title: "Interval",
200 - type: "number",
201 - },
202 - labelIds: {
203 - default: "INBOX",
204 - description: "Filter messages by a single label ID. Labels identify the status or category of messages. Supported labels include 'INBOX', 'SPAM', 'TRASH', 'UNREAD', 'STARRED', 'IMPORTANT', 'CATEGORY_PERSONAL', 'CATEGORY_SOCIAL', 'CATEGORY_PROMOTIONS', 'CATEGORY_UPDATES', and 'CATEGORY_FORUMS'. For complex label filtering, use the 'query' parameter instead.",
205 - examples: ["INBOX", "UNREAD", "STARRED"],
206 - title: "Labelids",
207 - type: "string",
208 - },
209 - query: {
210 - default: "",
211 - description: "Advanced Gmail search using the same syntax as Gmail's search box. Use 'AND' for messages that match all conditions, 'OR' for any condition. Search by sender (from:email@domain.com), labels (label:inbox), status (is:unread), attachments (has:attachment), dates (after:2023/1/1), and more. If specified, this takes precedence over labelIds.",
212 - examples: ["label:inbox OR label:sent", "from:example@gmail.com is:unread", "has:attachment after:2023/1/1", "is:important is:unread"],
213 - title: "Query",
214 - type: "string",
215 - },
216 - userId: {
217 - default: "me",
218 - description: "The user's email address or 'me' for the authenticated user.",
219 - examples: ["me"],
220 - title: "Userid",
221 - type: "string",
222 - },
223 - },
224 - title: "NewMessageConfig",
225 - type: "object",
226 - },
227 - payload: {
228 - properties: {
229 - attachment_list: {
230 - anyOf: [{
231 - items: {},
232 - type: "array",
233 - }, {
234 - type: "null",
235 - }],
236 - default: null,
237 - description: "The list of attachments in the message",
238 - title: "Attachment List",
239 - },
240 - message_id: {
241 - anyOf: [{
242 - type: "string",
243 - }, {
244 - type: "null",
245 - }],
246 - default: null,
247 - description: "The message ID of the message",
248 - title: "Message ID",
249 - },
250 - message_text: {
251 - anyOf: [{
252 - type: "string",
253 - }, {
254 - type: "null",
255 - }],
256 - default: null,
257 - description: "The text of the message",
258 - title: "Message Text",
259 - },
260 - message_timestamp: {
261 - anyOf: [{
262 - type: "string",
263 - }, {
264 - type: "null",
265 - }],
266 - default: null,
267 - description: "The timestamp of the message",
268 - title: "Message Timestamp",
269 - },
270 - payload: {
271 - anyOf: [{
272 - type: "object",
273 - }, {
274 - type: "null",
275 - }],
276 - default: null,
277 - description: "The payload of the message",
278 - title: "Payload",
279 - },
280 - sender: {
281 - anyOf: [{
199 + export const GMAIL = {
200 + slug: "gmail",
201 + tools: {
202 + ADD_LABEL_TO_EMAIL: "GMAIL_ADD_LABEL_TO_EMAIL",
203 + CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
204 + CREATE_LABEL: "GMAIL_CREATE_LABEL",
205 + },
206 + triggerTypes: {
207 + NEW_GMAIL_MESSAGE: {
208 + slug: "GMAIL_NEW_GMAIL_MESSAGE",
209 + name: "New Gmail Message Received Trigger",
210 + description: "Triggers when a new message is received in Gmail.",
211 + instructions: "\\n **Instructions for Setting Up the Trigger:**\\n\\n - Ensure that the Gmail API is enabled for your Google account.\\n - Provide the user ID (usually 'me' for the authenticated user).\\n - Optionally, provide label IDs to filter messages.\\n ",
212 + config: {
213 + properties: {
214 + interval: {
215 + default: 1,
216 + description: "Periodic Interval to Check for Updates & Send a Trigger in Minutes",
217 + title: "Interval",
218 + type: "number",
219 + },
220 + labelIds: {
221 + default: "INBOX",
222 + description: "Filter messages by a single label ID. Labels identify the status or category of messages. Supported labels include 'INBOX', 'SPAM', 'TRASH', 'UNREAD', 'STARRED', 'IMPORTANT', 'CATEGORY_PERSONAL', 'CATEGORY_SOCIAL', 'CATEGORY_PROMOTIONS', 'CATEGORY_UPDATES', and 'CATEGORY_FORUMS'. For complex label filtering, use the 'query' parameter instead.",
223 + examples: ["INBOX", "UNREAD", "STARRED"],
224 + title: "Labelids",
225 type: "string",
283 - }, {
284 - type: "null",
285 - }],
286 - default: null,
287 - description: "The sender of the message",
288 - title: "Sender",
289 - },
290 - subject: {
291 - anyOf: [{
226 + },
227 + query: {
228 + default: "",
229 + description: "Advanced Gmail search using the same syntax as Gmail's search box. Use 'AND' for messages that match all conditions, 'OR' for any condition. Search by sender (from:email@domain.com), labels (label:inbox), status (is:unread), attachments (has:attachment), dates (after:2023/1/1), and more. If specified, this takes precedence over labelIds.",
230 + examples: ["label:inbox OR label:sent", "from:example@gmail.com is:unread", "has:attachment after:2023/1/1", "is:important is:unread"],
231 + title: "Query",
232 type: "string",
293 - }, {
294 - type: "null",
295 - }],
296 - default: null,
297 - description: "The subject of the message",
298 - title: "Subject",
299 - },
300 - thread_id: {
301 - anyOf: [{
233 + },
234 + userId: {
235 + default: "me",
236 + description: "The user's email address or 'me' for the authenticated user.",
237 + examples: ["me"],
238 + title: "Userid",
239 type: "string",
303 - }, {
304 - type: "null",
305 - }],
306 - default: null,
307 - description: "The thread ID of the message",
308 - title: "Thread ID",
240 + },
241 },
310 - to: {
311 - anyOf: [{
312 - type: "string",
313 - }, {
314 - type: "null",
315 - }],
316 - default: null,
317 - description: "The recipient of the message",
318 - title: "To",
242 + title: "NewMessageConfig",
243 + type: "object",
244 + },
245 + payload: {
246 + properties: {
247 + attachment_list: {
248 + anyOf: [{
249 + items: {},
250 + type: "array",
251 + }, {
252 + type: "null",
253 + }],
254 + default: null,
255 + description: "The list of attachments in the message",
256 + title: "Attachment List",
257 + },
258 + message_id: {
259 + anyOf: [{
260 + type: "string",
261 + }, {
262 + type: "null",
263 + }],
264 + default: null,
265 + description: "The message ID of the message",
266 + title: "Message ID",
267 + },
268 + message_text: {
269 + anyOf: [{
270 + type: "string",
271 + }, {
272 + type: "null",
273 + }],
274 + default: null,
275 + description: "The text of the message",
276 + title: "Message Text",
277 + },
278 + message_timestamp: {
279 + anyOf: [{
280 + type: "string",
281 + }, {
282 + type: "null",
283 + }],
284 + default: null,
285 + description: "The timestamp of the message",
286 + title: "Message Timestamp",
287 + },
288 + payload: {
289 + anyOf: [{
290 + type: "object",
291 + }, {
292 + type: "null",
293 + }],
294 + default: null,
295 + description: "The payload of the message",
296 + title: "Payload",
297 + },
298 + sender: {
299 + anyOf: [{
300 + type: "string",
301 + }, {
302 + type: "null",
303 + }],
304 + default: null,
305 + description: "The sender of the message",
306 + title: "Sender",
307 + },
308 + subject: {
309 + anyOf: [{
310 + type: "string",
311 + }, {
312 + type: "null",
313 + }],
314 + default: null,
315 + description: "The subject of the message",
316 + title: "Subject",
317 + },
318 + thread_id: {
319 + anyOf: [{
320 + type: "string",
321 + }, {
322 + type: "null",
323 + }],
324 + default: null,
325 + description: "The thread ID of the message",
326 + title: "Thread ID",
327 + },
328 + to: {
329 + anyOf: [{
330 + type: "string",
331 + }, {
332 + type: "null",
333 + }],
334 + default: null,
335 + description: "The recipient of the message",
336 + title: "To",
337 + },
338 },
339 + title: "NewMessagePayload",
340 + type: "object",
341 },
321 - title: "NewMessagePayload",
322 - type: "object",
342 + type: "poll",
343 },
324 - type: "poll",
344 },
326 - },
327 - }
345 + }
346
329 - /**
330 - * Type map of all available trigger payloads for toolkit "GMAIL".
331 - */
332 - export type GMAIL_TRIGGER_PAYLOADS = {
333 - NEW_GMAIL_MESSAGE: GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD
334 - }
347 + /**
348 + * Type map of all available trigger payloads for toolkit "GMAIL".
349 + */
350 + export type GMAIL_TRIGGER_PAYLOADS = {
351 + NEW_GMAIL_MESSAGE: GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD
352 + }
353
336 - /**
337 - * Type map of all available trigger events for toolkit "GMAIL".
338 - */
339 - export type GMAIL_TRIGGER_EVENTS = {
340 - NEW_GMAIL_MESSAGE: TriggerEvent<GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD>
341 - }
342 - "
343 - `);
354 + /**
355 + * Type map of all available trigger events for toolkit "GMAIL".
356 + */
357 + export type GMAIL_TRIGGER_EVENTS = {
358 + NEW_GMAIL_MESSAGE: TriggerEvent<GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD>
359 + }
360 + "
361 + `);
362
363 expect(sources[1]).toHaveLength(2);
364 expect(sources[1][0]).toBe('github.ts');
365 expect(sources[1][1]).toMatchInlineSnapshot(`
348 - "import { type TriggerEvent } from "@composio/core"
366 + "import { type TriggerEvent } from "@composio/core"
367
350 - type GITHUB_COMMIT_EVENT_PAYLOAD = {
351 - /**
352 - * Author
353 - * @description The GitHub username of the commit author
354 - */
355 - author?: string;
356 - /**
357 - * Id
358 - * @description The SHA of the commit
359 - */
360 - id?: string;
361 - /**
362 - * Message
363 - * @description The commit message
364 - */
365 - message?: string;
366 - /**
367 - * Timestamp
368 - * @description The timestamp of the commit
369 - */
370 - timestamp?: string;
371 - /**
372 - * Url
373 - * @description The GitHub URL of the commit
374 - */
375 - url?: string;
376 - };
368 + // ------------------- //
369 + // Trigger types //
370 + // ------------------- //
371
378 - type GITHUB_FOLLOWER_EVENT_PAYLOAD = {
379 - /**
380 - * Username
381 - * @description Username of the github follower
382 - */
383 - username?: string;
384 - };
372
386 - type GITHUB_ISSUE_ADDED_EVENT_PAYLOAD = {
387 - /**
388 - * Action
389 - * @description The action that was performed on the issue
390 - */
391 - action?: string;
392 - /**
393 - * Createdat
394 - * @description The timestamp when the issue was created
395 - */
396 - createdAt?: string;
397 - /**
398 - * Createdby
399 - * @description The GitHub username of the user who created the issue
400 - */
401 - createdBy?: string;
402 - /**
403 - * Description
404 - * @description A detailed description of the issue
405 - * @default
406 - */
407 - description: string;
408 - /**
409 - * Issue Id
410 - * @description The unique ID assigned to the issue
411 - */
412 - issue_id?: number;
413 - /**
414 - * Number
415 - * @description The unique number assigned to the issue
416 - */
417 - number?: number;
418 - /**
419 - * Title
420 - * @description The title of the issue
421 - */
422 - title?: string;
423 - /**
424 - * Url
425 - * @description The GitHub URL of the issue
426 - */
427 - url?: string;
428 - };
373
430 - type GITHUB_LABEL_ADDED_EVENT_PAYLOAD = {
431 - /**
432 - * Action
433 - * @description The action that was performed on the label
434 - */
435 - action?: string;
374 /**
437 - * Label
438 - * @description The name of the label that was added
375 + * Type of GITHUB's COMMIT_EVENT trigger payload.
376 */
440 - label?: string;
441 - /**
442 - * Labeled At
443 - * @description The timestamp when the label was added
444 - */
445 - labeled_at?: string;
446 - /**
447 - * Labeled By
448 - * @description The GitHub username of the user who added the label
449 - */
450 - labeled_by?: string;
451 - /**
452 - * Pull Request Number
453 - * @description The unique number assigned to the pull request
454 - */
455 - pull_request_number?: number;
456 - /**
457 - * Pull Request Title
458 - * @description The title of the pull request
459 - */
460 - pull_request_title?: string;
461 - /**
462 - * Pull Request Url
463 - * @description The GitHub URL of the pull request
464 - */
465 - pull_request_url?: string;
466 - };
377 + type GITHUB_COMMIT_EVENT_PAYLOAD = {
378 + /**
379 + * Author
380 + * @description The GitHub username of the commit author
381 + */
382 + author?: string;
383 + /**
384 + * Id
385 + * @description The SHA of the commit
386 + */
387 + id?: string;
388 + /**
389 + * Message
390 + * @description The commit message
391 + */
392 + message?: string;
393 + /**
394 + * Timestamp
395 + * @description The timestamp of the commit
396 + */
397 + timestamp?: string;
398 + /**
399 + * Url
400 + * @description The GitHub URL of the commit
401 + */
402 + url?: string;
403 + };
404
468 - type GITHUB_PULL_REQUEST_EVENT_PAYLOAD = {
469 - /**
470 - * Action
471 - * @description The action that was performed on the pull request
472 - */
473 - action?: string;
474 - /**
475 - * Createdat
476 - * @description The timestamp when the pull request was created
477 - */
478 - createdAt?: string;
479 - /**
480 - * Createdby
481 - * @description The GitHub username of the user who created the pull request
482 - */
483 - createdBy?: string;
405 /**
485 - * Description
486 - * @description A detailed description of the pull request
487 - * @default
406 + * Type of GITHUB's FOLLOWER_EVENT trigger payload.
407 */
489 - description: string;
490 - /**
491 - * Number
492 - * @description The unique number assigned to the pull request
493 - */
494 - number?: number;
495 - /**
496 - * Title
497 - * @description The title of the pull request
498 - */
499 - title?: string;
500 - /**
501 - * Url
502 - * @description The GitHub URL of the pull request
503 - */
504 - url?: string;
505 - };
408 + type GITHUB_FOLLOWER_EVENT_PAYLOAD = {
409 + /**
410 + * Username
411 + * @description Username of the github follower
412 + */
413 + username?: string;
414 + };
415
507 - type GITHUB_STAR_ADDED_EVENT_PAYLOAD = {
508 - /**
509 - * Action
510 - * @description The action that was performed on the star
511 - */
512 - action?: string;
416 /**
514 - * Repository Id
515 - * @description The unique ID assigned to the repository
417 + * Type of GITHUB's ISSUE_ADDED_EVENT trigger payload.
418 */
517 - repository_id?: number;
419 + type GITHUB_ISSUE_ADDED_EVENT_PAYLOAD = {
420 + /**
421 + * Action
422 + * @description The action that was performed on the issue
423 + */
424 + action?: string;
425 + /**
426 + * Createdat
427 + * @description The timestamp when the issue was created
428 + */
429 + createdAt?: string;
430 + /**
431 + * Createdby
432 + * @description The GitHub username of the user who created the issue
433 + */
434 + createdBy?: string;
435 + /**
436 + * Description
437 + * @description A detailed description of the issue
438 + * @default
439 + */
440 + description: string;
441 + /**
442 + * Issue Id
443 + * @description The unique ID assigned to the issue
444 + */
445 + issue_id?: number;
446 + /**
447 + * Number
448 + * @description The unique number assigned to the issue
449 + */
450 + number?: number;
451 + /**
452 + * Title
453 + * @description The title of the issue
454 + */
455 + title?: string;
456 + /**
457 + * Url
458 + * @description The GitHub URL of the issue
459 + */
460 + url?: string;
461 + };
462 +
463 /**
519 - * Repository Name
520 - * @description The name of the repository
464 + * Type of GITHUB's LABEL_ADDED_EVENT trigger payload.
465 */
522 - repository_name?: string;
466 + type GITHUB_LABEL_ADDED_EVENT_PAYLOAD = {
467 + /**
468 + * Action
469 + * @description The action that was performed on the label
470 + */
471 + action?: string;
472 + /**
473 + * Label
474 + * @description The name of the label that was added
475 + */
476 + label?: string;
477 + /**
478 + * Labeled At
479 + * @description The timestamp when the label was added
480 + */
481 + labeled_at?: string;
482 + /**
483 + * Labeled By
484 + * @description The GitHub username of the user who added the label
485 + */
486 + labeled_by?: string;
487 + /**
488 + * Pull Request Number
489 + * @description The unique number assigned to the pull request
490 + */
491 + pull_request_number?: number;
492 + /**
493 + * Pull Request Title
494 + * @description The title of the pull request
495 + */
496 + pull_request_title?: string;
497 + /**
498 + * Pull Request Url
499 + * @description The GitHub URL of the pull request
500 + */
501 + pull_request_url?: string;
502 + };
503 +
504 /**
524 - * Repository Url
525 - * @description The GitHub URL of the repository
505 + * Type of GITHUB's PULL_REQUEST_EVENT trigger payload.
506 */
527 - repository_url?: string;
507 + type GITHUB_PULL_REQUEST_EVENT_PAYLOAD = {
508 + /**
509 + * Action
510 + * @description The action that was performed on the pull request
511 + */
512 + action?: string;
513 + /**
514 + * Createdat
515 + * @description The timestamp when the pull request was created
516 + */
517 + createdAt?: string;
518 + /**
519 + * Createdby
520 + * @description The GitHub username of the user who created the pull request
521 + */
522 + createdBy?: string;
523 + /**
524 + * Description
525 + * @description A detailed description of the pull request
526 + * @default
527 + */
528 + description: string;
529 + /**
530 + * Number
531 + * @description The unique number assigned to the pull request
532 + */
533 + number?: number;
534 + /**
535 + * Title
536 + * @description The title of the pull request
537 + */
538 + title?: string;
539 + /**
540 + * Url
541 + * @description The GitHub URL of the pull request
542 + */
543 + url?: string;
544 + };
545 +
546 /**
529 - * Starred At
530 - * @description The timestamp when the star was added
547 + * Type of GITHUB's STAR_ADDED_EVENT trigger payload.
548 */
532 - starred_at?: string;
549 + type GITHUB_STAR_ADDED_EVENT_PAYLOAD = {
550 + /**
551 + * Action
552 + * @description The action that was performed on the star
553 + */
554 + action?: string;
555 + /**
556 + * Repository Id
557 + * @description The unique ID assigned to the repository
558 + */
559 + repository_id?: number;
560 + /**
561 + * Repository Name
562 + * @description The name of the repository
563 + */
564 + repository_name?: string;
565 + /**
566 + * Repository Url
567 + * @description The GitHub URL of the repository
568 + */
569 + repository_url?: string;
570 + /**
571 + * Starred At
572 + * @description The timestamp when the star was added
573 + */
574 + starred_at?: string;
575 + /**
576 + * Starred By
577 + * @description The GitHub username of the user who added the star
578 + */
579 + starred_by?: string;
580 + };
581 +
582 /**
534 - * Starred By
535 - * @description The GitHub username of the user who added the star
583 + * Map of Composio's GITHUB toolkit.
584 */
537 - starred_by?: string;
538 - };
539 -
540 - /**
541 - * Map of Composio's GITHUB toolkit.
542 - */
543 - export const GITHUB = {
544 - slug: "github",
545 - tools: {
546 - ACCEPT_A_REPOSITORY_INVITATION: "GITHUB_ACCEPT_A_REPOSITORY_INVITATION",
547 - ACTIVITY_LIST_REPO_S_STARRED_BY_AUTHENTICATED_USER: "GITHUB_ACTIVITY_LIST_REPO_S_STARRED_BY_AUTHENTICATED_USER",
548 - ACTIVITY_LIST_STARGAZERS_FOR_REPO: "GITHUB_ACTIVITY_LIST_STARGAZERS_FOR_REPO",
549 - },
550 - triggerTypes: {
551 - COMMIT_EVENT: {
552 - slug: "GITHUB_COMMIT_EVENT",
553 - name: "Commit Event",
554 - description: "Triggered when a new commit is pushed to a repository.",
555 - instructions: "This trigger fires every time a new commit is pushed to the repository.",
556 - config: {
557 - properties: {
558 - owner: {
559 - description: "Owner of the repository",
560 - title: "Owner",
561 - type: "string",
562 - },
563 - repo: {
564 - description: "Repository name",
565 - title: "Repo",
566 - type: "string",
585 + export const GITHUB = {
586 + slug: "github",
587 + tools: {
588 + ACCEPT_A_REPOSITORY_INVITATION: "GITHUB_ACCEPT_A_REPOSITORY_INVITATION",
589 + ACTIVITY_LIST_REPO_S_STARRED_BY_AUTHENTICATED_USER: "GITHUB_ACTIVITY_LIST_REPO_S_STARRED_BY_AUTHENTICATED_USER",
590 + ACTIVITY_LIST_STARGAZERS_FOR_REPO: "GITHUB_ACTIVITY_LIST_STARGAZERS_FOR_REPO",
591 + },
592 + triggerTypes: {
593 + COMMIT_EVENT: {
594 + slug: "GITHUB_COMMIT_EVENT",
595 + name: "Commit Event",
596 + description: "Triggered when a new commit is pushed to a repository.",
597 + instructions: "This trigger fires every time a new commit is pushed to the repository.",
598 + config: {
599 + properties: {
600 + owner: {
601 + description: "Owner of the repository",
602 + title: "Owner",
603 + type: "string",
604 + },
605 + repo: {
606 + description: "Repository name",
607 + title: "Repo",
608 + type: "string",
609 + },
610 },
611 + required: ["owner", "repo"],
612 + title: "WebhookConfigSchema",
613 + type: "object",
614 },
569 - required: ["owner", "repo"],
570 - title: "WebhookConfigSchema",
571 - type: "object",
572 - },
573 - payload: {
574 - properties: {
575 - author: {
576 - description: "The GitHub username of the commit author",
577 - examples: ["octocat"],
578 - title: "Author",
579 - type: "string",
580 - },
581 - id: {
582 - description: "The SHA of the commit",
583 - examples: ["7638417db6d59f3c431d3e1f261cc637155684cd"],
584 - title: "Id",
585 - type: "string",
586 - },
587 - message: {
588 - description: "The commit message",
589 - examples: ["Fix typo in README"],
590 - title: "Message",
591 - type: "string",
592 - },
593 - timestamp: {
594 - description: "The timestamp of the commit",
595 - examples: ["2021-04-14T02:15:15Z"],
596 - title: "Timestamp",
597 - type: "string",
598 - },
599 - url: {
600 - description: "The GitHub URL of the commit",
601 - examples: ["https://github.com/octocat/Hello-World/commit/7638417db6d59f3c431d3e1f261cc637155684cd"],
602 - title: "Url",
603 - type: "string",
615 + payload: {
616 + properties: {
617 + author: {
618 + description: "The GitHub username of the commit author",
619 + examples: ["octocat"],
620 + title: "Author",
621 + type: "string",
622 + },
623 + id: {
624 + description: "The SHA of the commit",
625 + examples: ["7638417db6d59f3c431d3e1f261cc637155684cd"],
626 + title: "Id",
627 + type: "string",
628 + },
629 + message: {
630 + description: "The commit message",
631 + examples: ["Fix typo in README"],
632 + title: "Message",
633 + type: "string",
634 + },
635 + timestamp: {
636 + description: "The timestamp of the commit",
637 + examples: ["2021-04-14T02:15:15Z"],
638 + title: "Timestamp",
639 + type: "string",
640 + },
641 + url: {
642 + description: "The GitHub URL of the commit",
643 + examples: ["https://github.com/octocat/Hello-World/commit/7638417db6d59f3c431d3e1f261cc637155684cd"],
644 + title: "Url",
645 + type: "string",
646 + },
647 },
648 + required: ["id", "message", "timestamp", "author", "url"],
649 + title: "CommitPayloadSchema",
650 + type: "object",
651 },
606 - required: ["id", "message", "timestamp", "author", "url"],
607 - title: "CommitPayloadSchema",
608 - type: "object",
652 + type: "webhook",
653 },
610 - type: "webhook",
611 - },
612 - FOLLOWER_EVENT: {
613 - slug: "GITHUB_FOLLOWER_EVENT",
614 - name: "Follower Changes",
615 - description: "Triggers when there are changes in GitHub followers.",
616 - instructions: "**Instructions for Setting Up the Trigger:**\\n\\n This trigger fires when there are changes in your GitHub followers.\\n It detects new followers and unfollowers.\\n ",
617 - config: {
618 - properties: {
619 - interval: {
620 - default: 1,
621 - description: "Periodic Interval to Check for Updates & Send a Trigger in Minutes",
622 - title: "Interval",
623 - type: "number",
654 + FOLLOWER_EVENT: {
655 + slug: "GITHUB_FOLLOWER_EVENT",
656 + name: "Follower Changes",
657 + description: "Triggers when there are changes in GitHub followers.",
658 + instructions: "**Instructions for Setting Up the Trigger:**\\n\\n This trigger fires when there are changes in your GitHub followers.\\n It detects new followers and unfollowers.\\n ",
659 + config: {
660 + properties: {
661 + interval: {
662 + default: 1,
663 + description: "Periodic Interval to Check for Updates & Send a Trigger in Minutes",
664 + title: "Interval",
665 + type: "number",
666 + },
667 },
668 + title: "GithubFollowerConfig",
669 + type: "object",
670 },
626 - title: "GithubFollowerConfig",
627 - type: "object",
628 - },
629 - payload: {
630 - properties: {
631 - username: {
632 - description: "Username of the github follower",
633 - title: "Username",
634 - type: "string",
671 + payload: {
672 + properties: {
673 + username: {
674 + description: "Username of the github follower",
675 + title: "Username",
676 + type: "string",
677 + },
678 },
679 + required: ["username"],
680 + title: "GithubFollowerPayload",
681 + type: "object",
682 },
637 - required: ["username"],
638 - title: "GithubFollowerPayload",
639 - type: "object",
683 + type: "poll",
684 },
641 - type: "poll",
642 - },
643 - ISSUE_ADDED_EVENT: {
644 - slug: "GITHUB_ISSUE_ADDED_EVENT",
645 - name: "Issue Added Event",
646 - description: "Triggered when a new issue is added to the repository.",
647 - instructions: "This trigger fires every time a new issue is added to the repository.",
648 - config: {
649 - properties: {
650 - owner: {
651 - description: "Owner of the repository",
652 - title: "Owner",
653 - type: "string",
654 - },
655 - repo: {
656 - description: "Repository name",
657 - title: "Repo",
658 - type: "string",
685 + ISSUE_ADDED_EVENT: {
686 + slug: "GITHUB_ISSUE_ADDED_EVENT",
687 + name: "Issue Added Event",
688 + description: "Triggered when a new issue is added to the repository.",
689 + instructions: "This trigger fires every time a new issue is added to the repository.",
690 + config: {
691 + properties: {
692 + owner: {
693 + description: "Owner of the repository",
694 + title: "Owner",
695 + type: "string",
696 + },
697 + repo: {
698 + description: "Repository name",
699 + title: "Repo",
700 + type: "string",
701 + },
702 },
703 + required: ["owner", "repo"],
704 + title: "WebhookConfigSchema",
705 + type: "object",
706 },
661 - required: ["owner", "repo"],
662 - title: "WebhookConfigSchema",
663 - type: "object",
664 - },
665 - payload: {
666 - properties: {
667 - action: {
668 - description: "The action that was performed on the issue",
669 - examples: ["opened"],
670 - title: "Action",
671 - type: "string",
672 - },
673 - createdAt: {
674 - description: "The timestamp when the issue was created",
675 - examples: ["2021-04-14T02:15:15Z"],
676 - title: "Createdat",
677 - type: "string",
678 - },
679 - createdBy: {
680 - description: "The GitHub username of the user who created the issue",
681 - examples: ["octocat"],
682 - title: "Createdby",
683 - type: "string",
684 - },
685 - description: {
686 - default: "",
687 - description: "A detailed description of the issue",
688 - examples: ["There is a bug in the code that needs to be fixed."],
689 - title: "Description",
690 - type: "string",
691 - },
692 - issue_id: {
693 - description: "The unique ID assigned to the issue",
694 - examples: [101],
695 - title: "Issue Id",
696 - type: "integer",
697 - },
698 - number: {
699 - description: "The unique number assigned to the issue",
700 - examples: [42],
701 - title: "Number",
702 - type: "integer",
703 - },
704 - title: {
705 - description: "The title of the issue",
706 - examples: ["Bug in code"],
707 - title: "Title",
708 - type: "string",
709 - },
710 - url: {
711 - description: "The GitHub URL of the issue",
712 - examples: ["https://github.com/octocat/Hello-World/issues/42"],
713 - title: "Url",
714 - type: "string",
707 + payload: {
708 + properties: {
709 + action: {
710 + description: "The action that was performed on the issue",
711 + examples: ["opened"],
712 + title: "Action",
713 + type: "string",
714 + },
715 + createdAt: {
716 + description: "The timestamp when the issue was created",
717 + examples: ["2021-04-14T02:15:15Z"],
718 + title: "Createdat",
719 + type: "string",
720 + },
721 + createdBy: {
722 + description: "The GitHub username of the user who created the issue",
723 + examples: ["octocat"],
724 + title: "Createdby",
725 + type: "string",
726 + },
727 + description: {
728 + default: "",
729 + description: "A detailed description of the issue",
730 + examples: ["There is a bug in the code that needs to be fixed."],
731 + title: "Description",
732 + type: "string",
733 + },
734 + issue_id: {
735 + description: "The unique ID assigned to the issue",
736 + examples: [101],
737 + title: "Issue Id",
738 + type: "integer",
739 + },
740 + number: {
741 + description: "The unique number assigned to the issue",
742 + examples: [42],
743 + title: "Number",
744 + type: "integer",
745 + },
746 + title: {
747 + description: "The title of the issue",
748 + examples: ["Bug in code"],
749 + title: "Title",
750 + type: "string",
751 + },
752 + url: {
753 + description: "The GitHub URL of the issue",
754 + examples: ["https://github.com/octocat/Hello-World/issues/42"],
755 + title: "Url",
756 + type: "string",
757 + },
758 },
759 + required: ["action", "issue_id", "number", "title", "createdBy", "createdAt", "url"],
760 + title: "IssueAddedPayloadSchema",
761 + type: "object",
762 },
717 - required: ["action", "issue_id", "number", "title", "createdBy", "createdAt", "url"],
718 - title: "IssueAddedPayloadSchema",
719 - type: "object",
763 + type: "webhook",
764 },
721 - type: "webhook",
722 - },
723 - LABEL_ADDED_EVENT: {
724 - slug: "GITHUB_LABEL_ADDED_EVENT",
725 - name: "Label Added Event",
726 - description: "Triggered when a new label is added to a pull request.",
727 - instructions: "This trigger fires every time a new label is added to a pull request on the repository.",
728 - config: {
729 - properties: {
730 - owner: {
731 - description: "Owner of the repository",
732 - title: "Owner",
733 - type: "string",
734 - },
735 - repo: {
736 - description: "Repository name",
737 - title: "Repo",
738 - type: "string",
765 + LABEL_ADDED_EVENT: {
766 + slug: "GITHUB_LABEL_ADDED_EVENT",
767 + name: "Label Added Event",
768 + description: "Triggered when a new label is added to a pull request.",
769 + instructions: "This trigger fires every time a new label is added to a pull request on the repository.",
770 + config: {
771 + properties: {
772 + owner: {
773 + description: "Owner of the repository",
774 + title: "Owner",
775 + type: "string",
776 + },
777 + repo: {
778 + description: "Repository name",
779 + title: "Repo",
780 + type: "string",
781 + },
782 },
783 + required: ["owner", "repo"],
784 + title: "WebhookConfigSchema",
785 + type: "object",
786 },
741 - required: ["owner", "repo"],
742 - title: "WebhookConfigSchema",
743 - type: "object",
744 - },
745 - payload: {
746 - properties: {
747 - action: {
748 - description: "The action that was performed on the label",
749 - examples: ["labeled"],
750 - title: "Action",
751 - type: "string",
752 - },
753 - label: {
754 - description: "The name of the label that was added",
755 - examples: ["bug", "enhancement"],
756 - title: "Label",
757 - type: "string",
758 - },
759 - labeled_at: {
760 - description: "The timestamp when the label was added",
761 - examples: ["2021-04-14T02:15:15Z"],
762 - title: "Labeled At",
763 - type: "string",
764 - },
765 - labeled_by: {
766 - description: "The GitHub username of the user who added the label",
767 - examples: ["octocat"],
768 - title: "Labeled By",
769 - type: "string",
770 - },
771 - pull_request_number: {
772 - description: "The unique number assigned to the pull request",
773 - examples: [42],
774 - title: "Pull Request Number",
775 - type: "integer",
776 - },
777 - pull_request_title: {
778 - description: "The title of the pull request",
779 - examples: ["Fix typo in README"],
780 - title: "Pull Request Title",
781 - type: "string",
782 - },
783 - pull_request_url: {
784 - description: "The GitHub URL of the pull request",
785 - examples: ["https://github.com/octocat/Hello-World/pull/42"],
786 - title: "Pull Request Url",
787 - type: "string",
787 + payload: {
788 + properties: {
789 + action: {
790 + description: "The action that was performed on the label",
791 + examples: ["labeled"],
792 + title: "Action",
793 + type: "string",
794 + },
795 + label: {
796 + description: "The name of the label that was added",
797 + examples: ["bug", "enhancement"],
798 + title: "Label",
799 + type: "string",
800 + },
801 + labeled_at: {
802 + description: "The timestamp when the label was added",
803 + examples: ["2021-04-14T02:15:15Z"],
804 + title: "Labeled At",
805 + type: "string",
806 + },
807 + labeled_by: {
808 + description: "The GitHub username of the user who added the label",
809 + examples: ["octocat"],
810 + title: "Labeled By",
811 + type: "string",
812 + },
813 + pull_request_number: {
814 + description: "The unique number assigned to the pull request",
815 + examples: [42],
816 + title: "Pull Request Number",
817 + type: "integer",
818 + },
819 + pull_request_title: {
820 + description: "The title of the pull request",
821 + examples: ["Fix typo in README"],
822 + title: "Pull Request Title",
823 + type: "string",
824 + },
825 + pull_request_url: {
826 + description: "The GitHub URL of the pull request",
827 + examples: ["https://github.com/octocat/Hello-World/pull/42"],
828 + title: "Pull Request Url",
829 + type: "string",
830 + },
831 },
832 + required: ["action", "label", "pull_request_number", "pull_request_title", "pull_request_url", "labeled_by", "labeled_at"],
833 + title: "LabelAddedPayloadSchema",
834 + type: "object",
835 },
790 - required: ["action", "label", "pull_request_number", "pull_request_title", "pull_request_url", "labeled_by", "labeled_at"],
791 - title: "LabelAddedPayloadSchema",
792 - type: "object",
836 + type: "webhook",
837 },
794 - type: "webhook",
795 - },
796 - PULL_REQUEST_EVENT: {
797 - slug: "GITHUB_PULL_REQUEST_EVENT",
798 - name: "Pull Request Event",
799 - description: "Triggered when a pull request is opened, closed, or synchronized.",
800 - instructions: "This trigger fires every time a pull request is opened, closed, or synchronized on the repository.",
801 - config: {
802 - properties: {
803 - owner: {
804 - description: "Owner of the repository",
805 - title: "Owner",
806 - type: "string",
807 - },
808 - repo: {
809 - description: "Repository name",
810 - title: "Repo",
811 - type: "string",
838 + PULL_REQUEST_EVENT: {
839 + slug: "GITHUB_PULL_REQUEST_EVENT",
840 + name: "Pull Request Event",
841 + description: "Triggered when a pull request is opened, closed, or synchronized.",
842 + instructions: "This trigger fires every time a pull request is opened, closed, or synchronized on the repository.",
843 + config: {
844 + properties: {
845 + owner: {
846 + description: "Owner of the repository",
847 + title: "Owner",
848 + type: "string",
849 + },
850 + repo: {
851 + description: "Repository name",
852 + title: "Repo",
853 + type: "string",
854 + },
855 },
856 + required: ["owner", "repo"],
857 + title: "WebhookConfigSchema",
858 + type: "object",
859 },
814 - required: ["owner", "repo"],
815 - title: "WebhookConfigSchema",
816 - type: "object",
817 - },
818 - payload: {
819 - properties: {
820 - action: {
821 - description: "The action that was performed on the pull request",
822 - examples: ["opened", "closed", "synchronize"],
823 - title: "Action",
824 - type: "string",
825 - },
826 - createdAt: {
827 - description: "The timestamp when the pull request was created",
828 - examples: ["2021-04-14T02:15:15Z"],
829 - title: "Createdat",
830 - type: "string",
831 - },
832 - createdBy: {
833 - description: "The GitHub username of the user who created the pull request",
834 - examples: ["octocat"],
835 - title: "Createdby",
836 - type: "string",
837 - },
838 - description: {
839 - default: "",
840 - description: "A detailed description of the pull request",
841 - examples: ["This pull request fixes a typo found in the README file under the 'Installation' section."],
842 - title: "Description",
843 - type: "string",
844 - },
845 - number: {
846 - description: "The unique number assigned to the pull request",
847 - examples: [42],
848 - title: "Number",
849 - type: "integer",
850 - },
851 - title: {
852 - description: "The title of the pull request",
853 - examples: ["Fix typo in README"],
854 - title: "Title",
855 - type: "string",
856 - },
857 - url: {
858 - description: "The GitHub URL of the pull request",
859 - examples: ["https://github.com/octocat/Hello-World/pull/42"],
860 - title: "Url",
861 - type: "string",
860 + payload: {
861 + properties: {
862 + action: {
863 + description: "The action that was performed on the pull request",
864 + examples: ["opened", "closed", "synchronize"],
865 + title: "Action",
866 + type: "string",
867 + },
868 + createdAt: {
869 + description: "The timestamp when the pull request was created",
870 + examples: ["2021-04-14T02:15:15Z"],
871 + title: "Createdat",
872 + type: "string",
873 + },
874 + createdBy: {
875 + description: "The GitHub username of the user who created the pull request",
876 + examples: ["octocat"],
877 + title: "Createdby",
878 + type: "string",
879 + },
880 + description: {
881 + default: "",
882 + description: "A detailed description of the pull request",
883 + examples: ["This pull request fixes a typo found in the README file under the 'Installation' section."],
884 + title: "Description",
885 + type: "string",
886 + },
887 + number: {
888 + description: "The unique number assigned to the pull request",
889 + examples: [42],
890 + title: "Number",
891 + type: "integer",
892 + },
893 + title: {
894 + description: "The title of the pull request",
895 + examples: ["Fix typo in README"],
896 + title: "Title",
897 + type: "string",
898 + },
899 + url: {
900 + description: "The GitHub URL of the pull request",
901 + examples: ["https://github.com/octocat/Hello-World/pull/42"],
902 + title: "Url",
903 + type: "string",
904 + },
905 },
906 + required: ["action", "number", "title", "createdBy", "createdAt", "url"],
907 + title: "PullRequestPayloadSchema",
908 + type: "object",
909 },
864 - required: ["action", "number", "title", "createdBy", "createdAt", "url"],
865 - title: "PullRequestPayloadSchema",
866 - type: "object",
910 + type: "webhook",
911 },
868 - type: "webhook",
869 - },
870 - STAR_ADDED_EVENT: {
871 - slug: "GITHUB_STAR_ADDED_EVENT",
872 - name: "Star Added Event",
873 - description: "Triggered when a new star is added to the repository.",
874 - instructions: "This trigger fires every time a new star is added to the repository.",
875 - config: {
876 - properties: {
877 - owner: {
878 - description: "Owner of the repository",
879 - title: "Owner",
880 - type: "string",
881 - },
882 - repo: {
883 - description: "Repository name",
884 - title: "Repo",
885 - type: "string",
912 + STAR_ADDED_EVENT: {
913 + slug: "GITHUB_STAR_ADDED_EVENT",
914 + name: "Star Added Event",
915 + description: "Triggered when a new star is added to the repository.",
916 + instructions: "This trigger fires every time a new star is added to the repository.",
917 + config: {
918 + properties: {
919 + owner: {
920 + description: "Owner of the repository",
921 + title: "Owner",
922 + type: "string",
923 + },
924 + repo: {
925 + description: "Repository name",
926 + title: "Repo",
927 + type: "string",
928 + },
929 },
930 + required: ["owner", "repo"],
931 + title: "WebhookConfigSchema",
932 + type: "object",
933 },
888 - required: ["owner", "repo"],
889 - title: "WebhookConfigSchema",
890 - type: "object",
891 - },
892 - payload: {
893 - properties: {
894 - action: {
895 - description: "The action that was performed on the star",
896 - examples: ["created"],
897 - title: "Action",
898 - type: "string",
899 - },
900 - repository_id: {
901 - description: "The unique ID assigned to the repository",
902 - examples: [101],
903 - title: "Repository Id",
904 - type: "integer",
905 - },
906 - repository_name: {
907 - description: "The name of the repository",
908 - examples: ["Hello-World"],
909 - title: "Repository Name",
910 - type: "string",
911 - },
912 - repository_url: {
913 - description: "The GitHub URL of the repository",
914 - examples: ["https://github.com/octocat/Hello-World"],
915 - title: "Repository Url",
916 - type: "string",
917 - },
918 - starred_at: {
919 - description: "The timestamp when the star was added",
920 - examples: ["2021-04-14T02:15:15Z"],
921 - title: "Starred At",
922 - type: "string",
923 - },
924 - starred_by: {
925 - description: "The GitHub username of the user who added the star",
926 - examples: ["octocat"],
927 - title: "Starred By",
928 - type: "string",
934 + payload: {
935 + properties: {
936 + action: {
937 + description: "The action that was performed on the star",
938 + examples: ["created"],
939 + title: "Action",
940 + type: "string",
941 + },
942 + repository_id: {
943 + description: "The unique ID assigned to the repository",
944 + examples: [101],
945 + title: "Repository Id",
946 + type: "integer",
947 + },
948 + repository_name: {
949 + description: "The name of the repository",
950 + examples: ["Hello-World"],
951 + title: "Repository Name",
952 + type: "string",
953 + },
954 + repository_url: {
955 + description: "The GitHub URL of the repository",
956 + examples: ["https://github.com/octocat/Hello-World"],
957 + title: "Repository Url",
958 + type: "string",
959 + },
960 + starred_at: {
961 + description: "The timestamp when the star was added",
962 + examples: ["2021-04-14T02:15:15Z"],
963 + title: "Starred At",
964 + type: "string",
965 + },
966 + starred_by: {
967 + description: "The GitHub username of the user who added the star",
968 + examples: ["octocat"],
969 + title: "Starred By",
970 + type: "string",
971 + },
972 },
973 + required: ["action", "starred_at", "repository_id", "repository_name", "repository_url", "starred_by"],
974 + title: "StarAddedPayloadSchema",
975 + type: "object",
976 },
931 - required: ["action", "starred_at", "repository_id", "repository_name", "repository_url", "starred_by"],
932 - title: "StarAddedPayloadSchema",
933 - type: "object",
977 + type: "webhook",
978 },
935 - type: "webhook",
979 },
937 - },
938 - }
980 + }
981
940 - /**
941 - * Type map of all available trigger payloads for toolkit "GITHUB".
942 - */
943 - export type GITHUB_TRIGGER_PAYLOADS = {
944 - COMMIT_EVENT: GITHUB_COMMIT_EVENT_PAYLOAD
945 - FOLLOWER_EVENT: GITHUB_FOLLOWER_EVENT_PAYLOAD
946 - ISSUE_ADDED_EVENT: GITHUB_ISSUE_ADDED_EVENT_PAYLOAD
947 - LABEL_ADDED_EVENT: GITHUB_LABEL_ADDED_EVENT_PAYLOAD
948 - PULL_REQUEST_EVENT: GITHUB_PULL_REQUEST_EVENT_PAYLOAD
949 - STAR_ADDED_EVENT: GITHUB_STAR_ADDED_EVENT_PAYLOAD
950 - }
982 + /**
983 + * Type map of all available trigger payloads for toolkit "GITHUB".
984 + */
985 + export type GITHUB_TRIGGER_PAYLOADS = {
986 + COMMIT_EVENT: GITHUB_COMMIT_EVENT_PAYLOAD
987 + FOLLOWER_EVENT: GITHUB_FOLLOWER_EVENT_PAYLOAD
988 + ISSUE_ADDED_EVENT: GITHUB_ISSUE_ADDED_EVENT_PAYLOAD
989 + LABEL_ADDED_EVENT: GITHUB_LABEL_ADDED_EVENT_PAYLOAD
990 + PULL_REQUEST_EVENT: GITHUB_PULL_REQUEST_EVENT_PAYLOAD
991 + STAR_ADDED_EVENT: GITHUB_STAR_ADDED_EVENT_PAYLOAD
992 + }
993
952 - /**
953 - * Type map of all available trigger events for toolkit "GITHUB".
954 - */
955 - export type GITHUB_TRIGGER_EVENTS = {
956 - COMMIT_EVENT: TriggerEvent<GITHUB_COMMIT_EVENT_PAYLOAD>
957 - FOLLOWER_EVENT: TriggerEvent<GITHUB_FOLLOWER_EVENT_PAYLOAD>
958 - ISSUE_ADDED_EVENT: TriggerEvent<GITHUB_ISSUE_ADDED_EVENT_PAYLOAD>
959 - LABEL_ADDED_EVENT: TriggerEvent<GITHUB_LABEL_ADDED_EVENT_PAYLOAD>
960 - PULL_REQUEST_EVENT: TriggerEvent<GITHUB_PULL_REQUEST_EVENT_PAYLOAD>
961 - STAR_ADDED_EVENT: TriggerEvent<GITHUB_STAR_ADDED_EVENT_PAYLOAD>
962 - }
963 - "
964 - `);
994 + /**
995 + * Type map of all available trigger events for toolkit "GITHUB".
996 + */
997 + export type GITHUB_TRIGGER_EVENTS = {
998 + COMMIT_EVENT: TriggerEvent<GITHUB_COMMIT_EVENT_PAYLOAD>
999 + FOLLOWER_EVENT: TriggerEvent<GITHUB_FOLLOWER_EVENT_PAYLOAD>
1000 + ISSUE_ADDED_EVENT: TriggerEvent<GITHUB_ISSUE_ADDED_EVENT_PAYLOAD>
1001 + LABEL_ADDED_EVENT: TriggerEvent<GITHUB_LABEL_ADDED_EVENT_PAYLOAD>
1002 + PULL_REQUEST_EVENT: TriggerEvent<GITHUB_PULL_REQUEST_EVENT_PAYLOAD>
1003 + STAR_ADDED_EVENT: TriggerEvent<GITHUB_STAR_ADDED_EVENT_PAYLOAD>
1004 + }
1005 + "
1006 + `);
1007
1008 expect(sources[2]).toHaveLength(2);
1009 expect(sources[2][0]).toBe('slack.ts');
1010 expect(sources[2][1]).toMatchInlineSnapshot(`
969 - "/**
970 - * Map of Composio's SLACK toolkit.
971 - */
972 - export const SLACK = {
973 - slug: "slack",
974 - tools: {},
975 - triggerTypes: {},
976 - }
1011 + "// ------------------- //
1012 + // Trigger types //
1013 + // ------------------- //
1014
978 - /**
979 - * Type map of all available trigger payloads for toolkit "SLACK".
980 - */
981 - export type SLACK_TRIGGER_PAYLOADS = {}
1015
983 - /**
984 - * Type map of all available trigger events for toolkit "SLACK".
985 - */
986 - export type SLACK_TRIGGER_EVENTS = {}
987 - "
988 - `);
1016 +
1017 + /**
1018 + * Map of Composio's SLACK toolkit.
1019 + */
1020 + export const SLACK = {
1021 + slug: "slack",
1022 + tools: {},
1023 + triggerTypes: {},
1024 + }
1025 +
1026 + /**
1027 + * Type map of all available trigger payloads for toolkit "SLACK".
1028 + */
1029 + export type SLACK_TRIGGER_PAYLOADS = {}
1030 +
1031 + /**
1032 + * Type map of all available trigger events for toolkit "SLACK".
1033 + */
1034 + export type SLACK_TRIGGER_EVENTS = {}
1035 + "
1036 + `);
1037
1038 expect(sources[3]).toHaveLength(2);
1039 expect(sources[3][0]).toBe('googledrive.ts');
1040 expect(sources[3][1]).toMatchInlineSnapshot(`
1041 "import { type TriggerEvent } from "@composio/core"
1042
1043 + // ------------------- //
1044 + // Trigger types //
1045 + // ------------------- //
1046 +
1047 +
1048 +
1049 + /**
1050 + * Type of GOOGLEDRIVE's GOOGLE_DRIVE_CHANGES trigger payload.
1051 + */
1052 type GOOGLEDRIVE_GOOGLE_DRIVE_CHANGES_PAYLOAD = object;
1053
1054 /**
ts/packages/cli/test/src/generation/typescript/generate.test.ts
+58 -43
@@ -29,7 +29,7 @@ describe('generateTypeScriptSources', () => {
29 Effect.fn(function* () {
30 const index = createToolkitIndex({
31 toolkits: [],
32 - tools: [],
32 + typeableTools: { withTypes: false, tools: [] },
33 triggerTypes: [],
34 });
35
@@ -82,7 +82,7 @@ describe('generateTypeScriptSources', () => {
82
83 const index = createToolkitIndex({
84 toolkits,
85 - tools: [],
85 + typeableTools: { withTypes: false, tools: [] },
86 triggerTypes: [],
87 });
88
@@ -91,26 +91,32 @@ describe('generateTypeScriptSources', () => {
91 expect(sources[0]).toHaveLength(2);
92 expect(sources[0][0]).toBe(path.join(params.outputDir, 'slack.ts'));
93 expect(sources[0][1]).toMatchInlineSnapshot(`
94 - "/**
95 - * Map of Composio's SLACK toolkit.
96 - */
97 - export const SLACK = {
98 - slug: "slack",
99 - tools: {},
100 - triggerTypes: {},
101 - }
102 -
103 - /**
104 - * Type map of all available trigger payloads for toolkit "SLACK".
105 - */
106 - export type SLACK_TRIGGER_PAYLOADS = {}
107 -
108 - /**
109 - * Type map of all available trigger events for toolkit "SLACK".
110 - */
111 - export type SLACK_TRIGGER_EVENTS = {}
112 - "
113 - `);
94 + "// ------------------- //
95 + // Trigger types //
96 + // ------------------- //
97 +
98 +
99 +
100 + /**
101 + * Map of Composio's SLACK toolkit.
102 + */
103 + export const SLACK = {
104 + slug: "slack",
105 + tools: {},
106 + triggerTypes: {},
107 + }
108 +
109 + /**
110 + * Type map of all available trigger payloads for toolkit "SLACK".
111 + */
112 + export type SLACK_TRIGGER_PAYLOADS = {}
113 +
114 + /**
115 + * Type map of all available trigger events for toolkit "SLACK".
116 + */
117 + export type SLACK_TRIGGER_EVENTS = {}
118 + "
119 + `);
120 assertTypeScriptIsValid({ files: { './slack.ts': sources[0][1] } });
121
122 expect(sources[1]).toHaveLength(2);
@@ -165,7 +171,10 @@ describe('generateTypeScriptSources', () => {
171
172 const index = createToolkitIndex({
173 toolkits,
168 - tools: [...TOOLS_GMAIL.slice(0, 3), ...TOOLS_GITHUB.slice(0, 3)],
174 + typeableTools: {
175 + withTypes: false,
176 + tools: [...TOOLS_GMAIL.slice(0, 3), ...TOOLS_GITHUB.slice(0, 3)],
177 + },
178 triggerTypes: [...TRIGGER_TYPES_GMAIL, ...TRIGGER_TYPES_GITHUB],
179 });
180
@@ -174,26 +183,32 @@ describe('generateTypeScriptSources', () => {
183 expect(sources[0]).toHaveLength(2);
184 expect(sources[0][0]).toBe(path.join(params.outputDir, './slack.ts'));
185 expect(sources[0][1]).toMatchInlineSnapshot(`
177 - "/**
178 - * Map of Composio's SLACK toolkit.
179 - */
180 - export const SLACK = {
181 - slug: "slack",
182 - tools: {},
183 - triggerTypes: {},
184 - }
185 -
186 - /**
187 - * Type map of all available trigger payloads for toolkit "SLACK".
188 - */
189 - export type SLACK_TRIGGER_PAYLOADS = {}
190 -
191 - /**
192 - * Type map of all available trigger events for toolkit "SLACK".
193 - */
194 - export type SLACK_TRIGGER_EVENTS = {}
195 - "
196 - `);
186 + "// ------------------- //
187 + // Trigger types //
188 + // ------------------- //
189 +
190 +
191 +
192 + /**
193 + * Map of Composio's SLACK toolkit.
194 + */
195 + export const SLACK = {
196 + slug: "slack",
197 + tools: {},
198 + triggerTypes: {},
199 + }
200 +
201 + /**
202 + * Type map of all available trigger payloads for toolkit "SLACK".
203 + */
204 + export type SLACK_TRIGGER_PAYLOADS = {}
205 +
206 + /**
207 + * Type map of all available trigger events for toolkit "SLACK".
208 + */
209 + export type SLACK_TRIGGER_EVENTS = {}
210 + "
211 + `);
212 assertTypeScriptIsValid({ files: { './slack.ts': sources[0][1] } });
213
214 expect(sources[1]).toHaveLength(2);
ts/packages/ts-builders/src/DocSectionComment.ts new
+18
@@ -0,0 +1,18 @@
1 +import type { BasicBuilder } from './BasicBuilder';
2 +import { Writer } from './Writer';
3 +
4 +export class DocSectionComment implements BasicBuilder {
5 + constructor(private startingText: string) {}
6 +
7 + write(writer: Writer): void {
8 + const lines = this.startingText.split('\n');
9 +
10 + for (const line of lines) {
11 + writer.writeLine(line.trimStart());
12 + }
13 + }
14 +}
15 +
16 +export function docSectionComment(startingText: string) {
17 + return new DocSectionComment(startingText);
18 +}
ts/packages/ts-builders/src/File.ts
+2 -1
@@ -1,12 +1,13 @@
1 import type { AnyDeclarationBuilder } from './AnyDeclarationBuilder';
2 import type { BasicBuilder } from './BasicBuilder';
3 +import type { DocSectionComment } from './DocSectionComment';
4 import { Export } from './Export';
5 import type { ExportFrom } from './ExportFrom';
6 import type { Import } from './Import';
7 import { Writer } from './Writer';
8
9 // eslint-disable-next-line @typescript-eslint/no-explicit-any
9 -export type FileItem = AnyDeclarationBuilder | Export<any> | ExportFrom;
10 +export type FileItem = AnyDeclarationBuilder | Export<any> | ExportFrom | DocSectionComment;
11 export class File implements BasicBuilder {
12 private imports: Import[] = [];
13 private declarations: FileItem[] = [];
ts/packages/ts-builders/src/index.ts
+1
@@ -6,6 +6,7 @@ export * from './BasicBuilder';
6 export * from './Class';
7 export * from './ConstDeclaration';
8 export * from './DocComment';
9 +export * from './DocSectionComment';
10 export * from './Export';
11 export * from './ExportFrom';
12 export * from './File';