@composio/core 0.1.4-alpha.0 → 0.1.8-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +285 -121
- package/dist/index.d.cts +309 -36
- package/dist/index.d.ts +309 -36
- package/dist/index.js +283 -121
- package/package.json +3 -5
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var ToolListParamsSchema = z.object({
|
|
|
35
35
|
important: z.string().optional(),
|
|
36
36
|
limit: z.string().optional(),
|
|
37
37
|
search: z.string().optional(),
|
|
38
|
-
toolkits: z.string().optional(),
|
|
38
|
+
toolkits: z.array(z.string()).optional(),
|
|
39
39
|
tools: z.array(z.string()).optional()
|
|
40
40
|
});
|
|
41
41
|
var CustomAuthParamsSchema = z.object({
|
|
@@ -400,7 +400,7 @@ var Tools = class {
|
|
|
400
400
|
important: queryParams.data.important,
|
|
401
401
|
limit: queryParams.data.limit,
|
|
402
402
|
search: queryParams.data.search,
|
|
403
|
-
toolkit_slug: queryParams.data.toolkits,
|
|
403
|
+
toolkit_slug: queryParams.data.toolkits?.join(","),
|
|
404
404
|
tool_slugs: queryParams.data.tools?.join(",")
|
|
405
405
|
});
|
|
406
406
|
if (!tools) {
|
|
@@ -977,30 +977,174 @@ var Triggers = class {
|
|
|
977
977
|
}
|
|
978
978
|
};
|
|
979
979
|
|
|
980
|
+
// src/types/authConfigs.types.ts
|
|
981
|
+
import { z as z3 } from "zod";
|
|
982
|
+
var AuthConfigTypes = {
|
|
983
|
+
CUSTOM: "use_custom_auth",
|
|
984
|
+
COMPOSIO_MANAGED: "use_composio_managed_auth"
|
|
985
|
+
};
|
|
986
|
+
var AuthSchemeTypes = {
|
|
987
|
+
OAUTH2: "OAUTH2",
|
|
988
|
+
OAUTH1: "OAUTH1",
|
|
989
|
+
OAUTH1A: "OAUTH1A",
|
|
990
|
+
API_KEY: "API_KEY",
|
|
991
|
+
BASIC: "BASIC",
|
|
992
|
+
BILLCOM_AUTH: "BILLCOM_AUTH",
|
|
993
|
+
BEARER_TOKEN: "BEARER_TOKEN",
|
|
994
|
+
GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
|
|
995
|
+
NO_AUTH: "NO_AUTH",
|
|
996
|
+
BASIC_WITH_JWT: "BASIC_WITH_JWT",
|
|
997
|
+
COMPOSIO_LINK: "COMPOSIO_LINK",
|
|
998
|
+
CALCOM_AUTH: "CALCOM_AUTH",
|
|
999
|
+
SNOWFLAKE: "SNOWFLAKE"
|
|
1000
|
+
};
|
|
1001
|
+
var AuthSchemeEnum = z3.enum([
|
|
1002
|
+
"OAUTH2",
|
|
1003
|
+
"OAUTH1",
|
|
1004
|
+
"OAUTH1A",
|
|
1005
|
+
"API_KEY",
|
|
1006
|
+
"BASIC",
|
|
1007
|
+
"BILLCOM_AUTH",
|
|
1008
|
+
"BEARER_TOKEN",
|
|
1009
|
+
"GOOGLE_SERVICE_ACCOUNT",
|
|
1010
|
+
"NO_AUTH",
|
|
1011
|
+
"BASIC_WITH_JWT",
|
|
1012
|
+
"COMPOSIO_LINK",
|
|
1013
|
+
"CALCOM_AUTH",
|
|
1014
|
+
"SNOWFLAKE"
|
|
1015
|
+
]);
|
|
1016
|
+
var CreateCustomAuthConfigParamsSchema = z3.object({
|
|
1017
|
+
type: z3.literal("use_custom_auth"),
|
|
1018
|
+
name: z3.string().optional(),
|
|
1019
|
+
credentials: z3.record(z3.string(), z3.union([z3.string(), z3.number(), z3.boolean()])),
|
|
1020
|
+
authScheme: AuthSchemeEnum
|
|
1021
|
+
});
|
|
1022
|
+
var CreateComposioManagedAuthConfigParamsSchema = z3.object({
|
|
1023
|
+
type: z3.literal("use_composio_managed_auth"),
|
|
1024
|
+
name: z3.string().optional(),
|
|
1025
|
+
credentials: z3.record(z3.string(), z3.union([z3.string(), z3.number(), z3.boolean()])).optional()
|
|
1026
|
+
});
|
|
1027
|
+
var CreateAuthConfigParamsSchema = z3.discriminatedUnion("type", [
|
|
1028
|
+
CreateCustomAuthConfigParamsSchema,
|
|
1029
|
+
CreateComposioManagedAuthConfigParamsSchema
|
|
1030
|
+
]);
|
|
1031
|
+
var CreateAuthConfigResponseSchema = z3.object({
|
|
1032
|
+
id: z3.string(),
|
|
1033
|
+
authScheme: z3.string(),
|
|
1034
|
+
isComposioManaged: z3.boolean(),
|
|
1035
|
+
toolkit: z3.string()
|
|
1036
|
+
});
|
|
1037
|
+
var AuthConfigRetrieveResponseSchema = z3.object({
|
|
1038
|
+
id: z3.string(),
|
|
1039
|
+
name: z3.string(),
|
|
1040
|
+
toolkit: z3.object({
|
|
1041
|
+
logo: z3.string(),
|
|
1042
|
+
slug: z3.string()
|
|
1043
|
+
}),
|
|
1044
|
+
noOfConnections: z3.number(),
|
|
1045
|
+
status: z3.enum(["ENABLED", "DISABLED"]),
|
|
1046
|
+
uuid: z3.string(),
|
|
1047
|
+
authScheme: AuthSchemeEnum.optional(),
|
|
1048
|
+
credentials: z3.record(z3.string(), z3.union([z3.string(), z3.number(), z3.boolean()])),
|
|
1049
|
+
expectedInputFields: z3.array(z3.unknown()).optional(),
|
|
1050
|
+
isComposioManaged: z3.boolean().optional(),
|
|
1051
|
+
createdBy: z3.string().optional(),
|
|
1052
|
+
createdAt: z3.string().optional(),
|
|
1053
|
+
lastUpdatedAt: z3.string().optional()
|
|
1054
|
+
});
|
|
1055
|
+
var AuthConfigListParamsSchema = z3.object({
|
|
1056
|
+
cursor: z3.string().optional(),
|
|
1057
|
+
isComposioManaged: z3.boolean().optional(),
|
|
1058
|
+
limit: z3.number().optional(),
|
|
1059
|
+
toolkitSlug: z3.string().optional()
|
|
1060
|
+
});
|
|
1061
|
+
var AuthConfigListResponseSchema = z3.object({
|
|
1062
|
+
items: z3.array(AuthConfigRetrieveResponseSchema),
|
|
1063
|
+
nextCursor: z3.string().optional(),
|
|
1064
|
+
totalPages: z3.number()
|
|
1065
|
+
});
|
|
1066
|
+
var AuthConfigUpdateParamsSchema = z3.object({
|
|
1067
|
+
credentials: z3.record(z3.string(), z3.union([z3.string(), z3.number(), z3.boolean()]))
|
|
1068
|
+
});
|
|
1069
|
+
|
|
980
1070
|
// src/models/AuthConfigs.ts
|
|
981
1071
|
var AuthConfigs = class {
|
|
982
|
-
FILE_NAME = "core/models/AuthConfigs.ts";
|
|
983
1072
|
client;
|
|
984
1073
|
constructor(client) {
|
|
985
1074
|
this.client = client;
|
|
986
1075
|
}
|
|
1076
|
+
parseAuthConfigRetrieveResponse(authConfig) {
|
|
1077
|
+
return AuthConfigRetrieveResponseSchema.parse({
|
|
1078
|
+
id: authConfig.id,
|
|
1079
|
+
name: authConfig.name,
|
|
1080
|
+
noOfConnections: authConfig.no_of_connections,
|
|
1081
|
+
status: authConfig.status,
|
|
1082
|
+
toolkit: {
|
|
1083
|
+
logo: authConfig.toolkit.logo,
|
|
1084
|
+
slug: authConfig.toolkit.slug
|
|
1085
|
+
},
|
|
1086
|
+
uuid: authConfig.uuid,
|
|
1087
|
+
authScheme: authConfig.auth_scheme,
|
|
1088
|
+
credentials: authConfig.credentials,
|
|
1089
|
+
expectedInputFields: authConfig.expected_input_fields,
|
|
1090
|
+
isComposioManaged: authConfig.is_composio_managed,
|
|
1091
|
+
createdBy: authConfig.created_by,
|
|
1092
|
+
createdAt: authConfig.created_at,
|
|
1093
|
+
lastUpdatedAt: authConfig.last_updated_at
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
987
1096
|
/**
|
|
988
1097
|
* List all auth configs
|
|
989
1098
|
* @param {AuthConfigListParams} query - Query parameters for filtering auth configs
|
|
990
1099
|
* @param {RequestOptions} options - Request options
|
|
991
1100
|
* @returns {Promise<AuthConfigListResponse>} List of auth configs
|
|
992
1101
|
*/
|
|
993
|
-
async list(query
|
|
994
|
-
|
|
1102
|
+
async list(query) {
|
|
1103
|
+
const parsedQuery = query ? AuthConfigListParamsSchema.parse(query) : void 0;
|
|
1104
|
+
const result = await this.client.authConfigs.list({
|
|
1105
|
+
cursor: parsedQuery?.cursor,
|
|
1106
|
+
is_composio_managed: parsedQuery?.isComposioManaged,
|
|
1107
|
+
limit: parsedQuery?.limit?.toString(),
|
|
1108
|
+
toolkit_slug: parsedQuery?.toolkitSlug
|
|
1109
|
+
});
|
|
1110
|
+
return AuthConfigListResponseSchema.parse({
|
|
1111
|
+
items: result.items.map((item) => this.parseAuthConfigRetrieveResponse(item)),
|
|
1112
|
+
nextCursor: result.next_cursor,
|
|
1113
|
+
totalPages: result.total_pages
|
|
1114
|
+
});
|
|
995
1115
|
}
|
|
996
1116
|
/**
|
|
997
1117
|
* Create a new auth config
|
|
998
|
-
* @param {
|
|
999
|
-
* @param {
|
|
1000
|
-
* @returns {Promise<
|
|
1118
|
+
* @param {string} toolkit - Unique identifier of the toolkit
|
|
1119
|
+
* @param {CreateAuthConfigParams} options - Options for creating a new auth config
|
|
1120
|
+
* @returns {Promise<CreateAuthConfigResponse>} Created auth config
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* const authConfig = await authConfigs.create('my-toolkit', {
|
|
1124
|
+
* type: AuthConfigTypes.CUSTOM,
|
|
1125
|
+
* name: 'My Custom Auth Config',
|
|
1126
|
+
* authScheme: AuthSchemeTypes.API_KEY,
|
|
1127
|
+
* credentials: {
|
|
1128
|
+
* apiKey: '1234567890',
|
|
1129
|
+
* },
|
|
1130
|
+
* });
|
|
1131
|
+
*
|
|
1132
|
+
* @link https://docs.composio.dev/reference/auth-configs/create-auth-config
|
|
1001
1133
|
*/
|
|
1002
|
-
async create(
|
|
1003
|
-
|
|
1134
|
+
async create(toolkit, options) {
|
|
1135
|
+
const parsedOptions = CreateAuthConfigParamsSchema.parse(options);
|
|
1136
|
+
const result = await this.client.authConfigs.create({
|
|
1137
|
+
toolkit: {
|
|
1138
|
+
slug: toolkit
|
|
1139
|
+
},
|
|
1140
|
+
auth_config: parsedOptions
|
|
1141
|
+
});
|
|
1142
|
+
return CreateAuthConfigResponseSchema.parse({
|
|
1143
|
+
id: result.auth_config.id,
|
|
1144
|
+
authScheme: result.auth_config.auth_scheme,
|
|
1145
|
+
isComposioManaged: result.auth_config.is_composio_managed,
|
|
1146
|
+
toolkit: result.toolkit.slug
|
|
1147
|
+
});
|
|
1004
1148
|
}
|
|
1005
1149
|
/**
|
|
1006
1150
|
* Get an auth config by nanoid
|
|
@@ -1008,8 +1152,9 @@ var AuthConfigs = class {
|
|
|
1008
1152
|
* @param {RequestOptions} options - Request options
|
|
1009
1153
|
* @returns {Promise<AuthConfigRetrieveResponse>} Auth config details
|
|
1010
1154
|
*/
|
|
1011
|
-
async get(nanoid
|
|
1012
|
-
|
|
1155
|
+
async get(nanoid) {
|
|
1156
|
+
const result = await this.client.authConfigs.retrieve(nanoid);
|
|
1157
|
+
return this.parseAuthConfigRetrieveResponse(result);
|
|
1013
1158
|
}
|
|
1014
1159
|
/**
|
|
1015
1160
|
* Update an auth config
|
|
@@ -1018,8 +1163,12 @@ var AuthConfigs = class {
|
|
|
1018
1163
|
* @param {RequestOptions} options - Request options
|
|
1019
1164
|
* @returns {Promise<AuthConfigUpdateResponse>} Updated auth config
|
|
1020
1165
|
*/
|
|
1021
|
-
async update(nanoid, data
|
|
1022
|
-
return this.client.authConfigs.update(nanoid,
|
|
1166
|
+
async update(nanoid, data) {
|
|
1167
|
+
return this.client.authConfigs.update(nanoid, {
|
|
1168
|
+
auth_config: {
|
|
1169
|
+
credentials: data.credentials
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1023
1172
|
}
|
|
1024
1173
|
/**
|
|
1025
1174
|
* Delete an auth config
|
|
@@ -1027,8 +1176,8 @@ var AuthConfigs = class {
|
|
|
1027
1176
|
* @param {RequestOptions} options - Request options
|
|
1028
1177
|
* @returns {Promise<AuthConfigDeleteResponse>} Response from deletion
|
|
1029
1178
|
*/
|
|
1030
|
-
async delete(nanoid
|
|
1031
|
-
return this.client.authConfigs.delete(nanoid
|
|
1179
|
+
async delete(nanoid) {
|
|
1180
|
+
return this.client.authConfigs.delete(nanoid);
|
|
1032
1181
|
}
|
|
1033
1182
|
/**
|
|
1034
1183
|
* Update the status of an auth config
|
|
@@ -1037,8 +1186,8 @@ var AuthConfigs = class {
|
|
|
1037
1186
|
* @param {RequestOptions} options - Request options
|
|
1038
1187
|
* @returns {Promise<AuthConfigUpdateStatusResponse>} Updated auth config details
|
|
1039
1188
|
*/
|
|
1040
|
-
async updateStatus(status, nanoid
|
|
1041
|
-
return this.client.authConfigs.updateStatus(status, { nanoid }
|
|
1189
|
+
async updateStatus(status, nanoid) {
|
|
1190
|
+
return this.client.authConfigs.updateStatus(status, { nanoid });
|
|
1042
1191
|
}
|
|
1043
1192
|
/**
|
|
1044
1193
|
* Enable an auth config
|
|
@@ -1046,8 +1195,8 @@ var AuthConfigs = class {
|
|
|
1046
1195
|
* @param {RequestOptions} options - Request options
|
|
1047
1196
|
* @returns {Promise<AuthConfigUpdateStatusResponse>} Updated auth config details
|
|
1048
1197
|
*/
|
|
1049
|
-
async enable(nanoid
|
|
1050
|
-
return this.client.authConfigs.updateStatus("ENABLED", { nanoid }
|
|
1198
|
+
async enable(nanoid) {
|
|
1199
|
+
return this.client.authConfigs.updateStatus("ENABLED", { nanoid });
|
|
1051
1200
|
}
|
|
1052
1201
|
/**
|
|
1053
1202
|
* Disable an auth config
|
|
@@ -1055,13 +1204,13 @@ var AuthConfigs = class {
|
|
|
1055
1204
|
* @param {RequestOptions} options - Request options
|
|
1056
1205
|
* @returns {Promise<AuthConfigUpdateStatusResponse>} Updated auth config details
|
|
1057
1206
|
*/
|
|
1058
|
-
async disable(nanoid
|
|
1059
|
-
return this.client.authConfigs.updateStatus("DISABLED", { nanoid }
|
|
1207
|
+
async disable(nanoid) {
|
|
1208
|
+
return this.client.authConfigs.updateStatus("DISABLED", { nanoid });
|
|
1060
1209
|
}
|
|
1061
1210
|
};
|
|
1062
1211
|
|
|
1063
1212
|
// src/types/connectedAccounts.types.ts
|
|
1064
|
-
import { z as
|
|
1213
|
+
import { z as z4 } from "zod";
|
|
1065
1214
|
var ConnectedAccountStatuses = {
|
|
1066
1215
|
ACTIVE: "ACTIVE",
|
|
1067
1216
|
INACTIVE: "INACTIVE",
|
|
@@ -1070,7 +1219,7 @@ var ConnectedAccountStatuses = {
|
|
|
1070
1219
|
EXPIRED: "EXPIRED",
|
|
1071
1220
|
FAILED: "FAILED"
|
|
1072
1221
|
};
|
|
1073
|
-
var ConnectedAccountStatusSchema =
|
|
1222
|
+
var ConnectedAccountStatusSchema = z4.enum([
|
|
1074
1223
|
ConnectedAccountStatuses.ACTIVE,
|
|
1075
1224
|
ConnectedAccountStatuses.INACTIVE,
|
|
1076
1225
|
ConnectedAccountStatuses.PENDING,
|
|
@@ -1078,34 +1227,34 @@ var ConnectedAccountStatusSchema = z3.enum([
|
|
|
1078
1227
|
ConnectedAccountStatuses.EXPIRED,
|
|
1079
1228
|
ConnectedAccountStatuses.FAILED
|
|
1080
1229
|
]);
|
|
1081
|
-
var CreateConnectedAccountParamsSchema =
|
|
1082
|
-
authConfig:
|
|
1083
|
-
id:
|
|
1230
|
+
var CreateConnectedAccountParamsSchema = z4.object({
|
|
1231
|
+
authConfig: z4.object({
|
|
1232
|
+
id: z4.string()
|
|
1084
1233
|
}),
|
|
1085
|
-
connection:
|
|
1086
|
-
data:
|
|
1087
|
-
redirectUrl:
|
|
1088
|
-
userId:
|
|
1234
|
+
connection: z4.object({
|
|
1235
|
+
data: z4.record(z4.string(), z4.unknown()).optional(),
|
|
1236
|
+
redirectUrl: z4.string().optional(),
|
|
1237
|
+
userId: z4.string().optional()
|
|
1089
1238
|
})
|
|
1090
1239
|
});
|
|
1091
|
-
var DefaultCreateConnectedAccountParamsSchema =
|
|
1092
|
-
auth_config:
|
|
1093
|
-
id:
|
|
1240
|
+
var DefaultCreateConnectedAccountParamsSchema = z4.object({
|
|
1241
|
+
auth_config: z4.object({
|
|
1242
|
+
id: z4.string()
|
|
1094
1243
|
}),
|
|
1095
|
-
connection:
|
|
1096
|
-
data:
|
|
1097
|
-
redirect_uri:
|
|
1098
|
-
user_id:
|
|
1244
|
+
connection: z4.object({
|
|
1245
|
+
data: z4.record(z4.string(), z4.unknown()).optional(),
|
|
1246
|
+
redirect_uri: z4.string().optional(),
|
|
1247
|
+
user_id: z4.string().optional()
|
|
1099
1248
|
})
|
|
1100
1249
|
});
|
|
1101
|
-
var CreateConnectedAccountOptionsSchema =
|
|
1102
|
-
redirectUrl:
|
|
1103
|
-
data:
|
|
1250
|
+
var CreateConnectedAccountOptionsSchema = z4.object({
|
|
1251
|
+
redirectUrl: z4.string().optional(),
|
|
1252
|
+
data: z4.record(z4.string(), z4.unknown()).optional()
|
|
1104
1253
|
});
|
|
1105
|
-
var CreateConnectedAccountResponseSchema =
|
|
1106
|
-
id:
|
|
1254
|
+
var CreateConnectedAccountResponseSchema = z4.object({
|
|
1255
|
+
id: z4.string(),
|
|
1107
1256
|
status: ConnectedAccountStatusSchema,
|
|
1108
|
-
redirectUrl:
|
|
1257
|
+
redirectUrl: z4.string().nullable()
|
|
1109
1258
|
});
|
|
1110
1259
|
var ConnectedAccountAuthSchemes = {
|
|
1111
1260
|
OAUTH2: "OAUTH2",
|
|
@@ -1122,7 +1271,7 @@ var ConnectedAccountAuthSchemes = {
|
|
|
1122
1271
|
CALCOM_AUTH: "CALCOM_AUTH",
|
|
1123
1272
|
SNOWFLAKE: "SNOWFLAKE"
|
|
1124
1273
|
};
|
|
1125
|
-
var ConnectedAccountAuthSchemesSchema =
|
|
1274
|
+
var ConnectedAccountAuthSchemesSchema = z4.enum([
|
|
1126
1275
|
ConnectedAccountAuthSchemes.OAUTH2,
|
|
1127
1276
|
ConnectedAccountAuthSchemes.OAUTH1,
|
|
1128
1277
|
ConnectedAccountAuthSchemes.OAUTH1A,
|
|
@@ -1137,33 +1286,32 @@ var ConnectedAccountAuthSchemesSchema = z3.enum([
|
|
|
1137
1286
|
ConnectedAccountAuthSchemes.CALCOM_AUTH,
|
|
1138
1287
|
ConnectedAccountAuthSchemes.SNOWFLAKE
|
|
1139
1288
|
]);
|
|
1140
|
-
var ConnectedAccountAuthConfigSchema =
|
|
1141
|
-
id:
|
|
1289
|
+
var ConnectedAccountAuthConfigSchema = z4.object({
|
|
1290
|
+
id: z4.string(),
|
|
1142
1291
|
authScheme: ConnectedAccountAuthSchemesSchema,
|
|
1143
|
-
isComposioManaged:
|
|
1144
|
-
isDisabled:
|
|
1292
|
+
isComposioManaged: z4.boolean(),
|
|
1293
|
+
isDisabled: z4.boolean()
|
|
1145
1294
|
});
|
|
1146
|
-
var ConnectedAccountRetrieveResponseSchema =
|
|
1147
|
-
id:
|
|
1148
|
-
uuid: z3.string(),
|
|
1295
|
+
var ConnectedAccountRetrieveResponseSchema = z4.object({
|
|
1296
|
+
id: z4.string(),
|
|
1149
1297
|
authConfig: ConnectedAccountAuthConfigSchema,
|
|
1150
|
-
userId:
|
|
1151
|
-
data:
|
|
1152
|
-
params:
|
|
1298
|
+
userId: z4.string(),
|
|
1299
|
+
data: z4.record(z4.string(), z4.unknown()),
|
|
1300
|
+
params: z4.record(z4.string(), z4.unknown()),
|
|
1153
1301
|
status: ConnectedAccountStatusSchema,
|
|
1154
|
-
statusReason:
|
|
1155
|
-
toolkit:
|
|
1156
|
-
slug:
|
|
1302
|
+
statusReason: z4.string().nullable(),
|
|
1303
|
+
toolkit: z4.object({
|
|
1304
|
+
slug: z4.string()
|
|
1157
1305
|
}),
|
|
1158
|
-
testRequestEndpoint:
|
|
1159
|
-
isDisabled:
|
|
1160
|
-
createdAt:
|
|
1161
|
-
updatedAt:
|
|
1306
|
+
testRequestEndpoint: z4.string().optional(),
|
|
1307
|
+
isDisabled: z4.boolean(),
|
|
1308
|
+
createdAt: z4.string(),
|
|
1309
|
+
updatedAt: z4.string()
|
|
1162
1310
|
});
|
|
1163
1311
|
|
|
1164
1312
|
// src/models/ConnectionRequest.ts
|
|
1313
|
+
import { ZodError } from "zod";
|
|
1165
1314
|
var ConnectionRequest = class {
|
|
1166
|
-
FILE_NAME = "core/models/ConnectionRequest.ts";
|
|
1167
1315
|
client;
|
|
1168
1316
|
connectedAccountId;
|
|
1169
1317
|
connectedAccountStatus;
|
|
@@ -1178,23 +1326,31 @@ var ConnectionRequest = class {
|
|
|
1178
1326
|
* @returns
|
|
1179
1327
|
*/
|
|
1180
1328
|
async transformResponse(response) {
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1329
|
+
try {
|
|
1330
|
+
const parsedResponse = ConnectedAccountRetrieveResponseSchema.parse({
|
|
1331
|
+
...response,
|
|
1332
|
+
userId: response.user_id,
|
|
1333
|
+
// Add the missing userId property
|
|
1334
|
+
authConfig: {
|
|
1335
|
+
...response.auth_config,
|
|
1336
|
+
authScheme: response.auth_config.auth_scheme,
|
|
1337
|
+
isComposioManaged: response.auth_config.is_composio_managed,
|
|
1338
|
+
isDisabled: response.auth_config.is_disabled
|
|
1339
|
+
},
|
|
1340
|
+
statusReason: response.status_reason,
|
|
1341
|
+
isDisabled: response.is_disabled,
|
|
1342
|
+
createdAt: response.created_at,
|
|
1343
|
+
updatedAt: response.updated_at,
|
|
1344
|
+
testRequestEndpoint: response.test_request_endpoint
|
|
1345
|
+
});
|
|
1346
|
+
return parsedResponse;
|
|
1347
|
+
} catch (error) {
|
|
1348
|
+
logger_default.error("Error transforming response", error);
|
|
1349
|
+
if (error instanceof ZodError) {
|
|
1350
|
+
logger_default.error(JSON.stringify(error.errors, null, 2));
|
|
1351
|
+
}
|
|
1352
|
+
throw error;
|
|
1353
|
+
}
|
|
1198
1354
|
}
|
|
1199
1355
|
/**
|
|
1200
1356
|
* Wait for the connection to be established.
|
|
@@ -1244,13 +1400,35 @@ var ConnectedAccounts = class {
|
|
|
1244
1400
|
return this.client.connectedAccounts.list(query);
|
|
1245
1401
|
}
|
|
1246
1402
|
/**
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
1250
|
-
* @
|
|
1403
|
+
* Compound function to create a new connected account.
|
|
1404
|
+
* This function creates a new connected account and returns a connection request.
|
|
1405
|
+
* Users can then wait for the connection to be established using the `waitForConnection` method.
|
|
1406
|
+
* @param {string} userId - User ID of the connected account
|
|
1407
|
+
* @param {string} authConfigId - Auth config ID of the connected account
|
|
1408
|
+
* @param {CreateConnectedAccountOptions} data - Data for creating a new connected account
|
|
1409
|
+
* @returns {Promise<ConnectionRequest>} Connection request object
|
|
1410
|
+
*
|
|
1411
|
+
* @example
|
|
1412
|
+
* const connectionRequest = await composio.createConnectedAccount('user_123', 'auth_config_123', {
|
|
1413
|
+
* data: {
|
|
1414
|
+
* name: 'My Connected Account',
|
|
1415
|
+
* },
|
|
1416
|
+
* });
|
|
1417
|
+
*
|
|
1418
|
+
* @link https://docs.composio.dev/reference/connected-accounts/create-connected-account
|
|
1251
1419
|
*/
|
|
1252
|
-
async create(
|
|
1253
|
-
|
|
1420
|
+
async create(userId, authConfigId, options) {
|
|
1421
|
+
const response = await this.client.connectedAccounts.create({
|
|
1422
|
+
auth_config: {
|
|
1423
|
+
id: authConfigId
|
|
1424
|
+
},
|
|
1425
|
+
connection: {
|
|
1426
|
+
data: options?.data,
|
|
1427
|
+
redirect_uri: options?.redirectUrl,
|
|
1428
|
+
user_id: userId
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
return new ConnectionRequest(this.client, response.id, response.status);
|
|
1254
1432
|
}
|
|
1255
1433
|
/**
|
|
1256
1434
|
* Get a connected account by nanoid
|
|
@@ -1307,27 +1485,6 @@ var ConnectedAccounts = class {
|
|
|
1307
1485
|
async disable(nanoid) {
|
|
1308
1486
|
return this.client.connectedAccounts.updateStatus(nanoid, { enabled: false });
|
|
1309
1487
|
}
|
|
1310
|
-
/**
|
|
1311
|
-
* Compound function to create a new connected account.
|
|
1312
|
-
* This function creates a new connected account and returns a connection request.
|
|
1313
|
-
* Users can then wait for the connection to be established using the `waitForConnection` method.
|
|
1314
|
-
* @param {CreateConnectedAccountParams} data - Data for creating a new connected account
|
|
1315
|
-
* @returns {Promise<ConnectionRequest>} Connection request object
|
|
1316
|
-
*/
|
|
1317
|
-
async createConnectedAccount(userId, authConfigId, options) {
|
|
1318
|
-
const { redirectUrl, data } = options;
|
|
1319
|
-
const response = await this.create({
|
|
1320
|
-
auth_config: {
|
|
1321
|
-
id: authConfigId
|
|
1322
|
-
},
|
|
1323
|
-
connection: {
|
|
1324
|
-
data,
|
|
1325
|
-
redirect_uri: redirectUrl,
|
|
1326
|
-
user_id: userId
|
|
1327
|
-
}
|
|
1328
|
-
});
|
|
1329
|
-
return new ConnectionRequest(this.client, response.id, response.status);
|
|
1330
|
-
}
|
|
1331
1488
|
};
|
|
1332
1489
|
|
|
1333
1490
|
// src/types/telemetry.types.ts
|
|
@@ -1814,7 +1971,7 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
|
|
|
1814
1971
|
};
|
|
1815
1972
|
|
|
1816
1973
|
// package.json
|
|
1817
|
-
var version = "0.1.
|
|
1974
|
+
var version = "0.1.8-alpha.0";
|
|
1818
1975
|
|
|
1819
1976
|
// src/utils/uuid.ts
|
|
1820
1977
|
import { v4 as uuidv4 } from "uuid";
|
|
@@ -1842,7 +1999,9 @@ var Composio = class {
|
|
|
1842
1999
|
toolkits;
|
|
1843
2000
|
triggers;
|
|
1844
2001
|
toolset;
|
|
2002
|
+
// auth configs
|
|
1845
2003
|
authConfigs;
|
|
2004
|
+
createAuthConfig;
|
|
1846
2005
|
// connected accounts
|
|
1847
2006
|
connectedAccounts;
|
|
1848
2007
|
createConnectedAccount;
|
|
@@ -1877,8 +2036,9 @@ var Composio = class {
|
|
|
1877
2036
|
this.toolkits = new Toolkits(this.client);
|
|
1878
2037
|
this.triggers = new Triggers(this.client);
|
|
1879
2038
|
this.authConfigs = new AuthConfigs(this.client);
|
|
2039
|
+
this.createAuthConfig = this.authConfigs.create.bind(this.authConfigs);
|
|
1880
2040
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
1881
|
-
this.createConnectedAccount = this.connectedAccounts.
|
|
2041
|
+
this.createConnectedAccount = this.connectedAccounts.create.bind(this.connectedAccounts);
|
|
1882
2042
|
if (this.config.allowTracking ?? true) {
|
|
1883
2043
|
this.initializeTelemetry(
|
|
1884
2044
|
{
|
|
@@ -1958,39 +2118,39 @@ var BaseTelemetryTransport = class {
|
|
|
1958
2118
|
};
|
|
1959
2119
|
|
|
1960
2120
|
// src/utils/jsonSchema.ts
|
|
1961
|
-
import { z as
|
|
2121
|
+
import { z as z5 } from "zod";
|
|
1962
2122
|
function jsonSchemaPropertiesToTSTypes(value) {
|
|
1963
2123
|
if (!value.type) {
|
|
1964
|
-
return
|
|
2124
|
+
return z5.object({});
|
|
1965
2125
|
}
|
|
1966
2126
|
let zodType;
|
|
1967
2127
|
switch (value.type) {
|
|
1968
2128
|
case "string":
|
|
1969
|
-
zodType =
|
|
2129
|
+
zodType = z5.string().describe(
|
|
1970
2130
|
(value.description || "") + (value.examples ? `
|
|
1971
2131
|
Examples: ${value.examples.join(", ")}` : "")
|
|
1972
2132
|
);
|
|
1973
2133
|
break;
|
|
1974
2134
|
case "number":
|
|
1975
|
-
zodType =
|
|
2135
|
+
zodType = z5.number().describe(
|
|
1976
2136
|
(value.description || "") + (value.examples ? `
|
|
1977
2137
|
Examples: ${value.examples.join(", ")}` : "")
|
|
1978
2138
|
);
|
|
1979
2139
|
break;
|
|
1980
2140
|
case "integer":
|
|
1981
|
-
zodType =
|
|
2141
|
+
zodType = z5.number().int().describe(
|
|
1982
2142
|
(value.description || "") + (value.examples ? `
|
|
1983
2143
|
Examples: ${value.examples.join(", ")}` : "")
|
|
1984
2144
|
);
|
|
1985
2145
|
break;
|
|
1986
2146
|
case "boolean":
|
|
1987
|
-
zodType =
|
|
2147
|
+
zodType = z5.boolean().describe(
|
|
1988
2148
|
(value.description || "") + (value.examples ? `
|
|
1989
2149
|
Examples: ${value.examples.join(", ")}` : "")
|
|
1990
2150
|
);
|
|
1991
2151
|
break;
|
|
1992
2152
|
case "array":
|
|
1993
|
-
zodType =
|
|
2153
|
+
zodType = z5.array(
|
|
1994
2154
|
jsonSchemaPropertiesToTSTypes(
|
|
1995
2155
|
value.items
|
|
1996
2156
|
)
|
|
@@ -2006,7 +2166,7 @@ Examples: ${value.examples.join(", ")}` : "")
|
|
|
2006
2166
|
);
|
|
2007
2167
|
break;
|
|
2008
2168
|
case "null":
|
|
2009
|
-
zodType =
|
|
2169
|
+
zodType = z5.null().describe(value.description || "");
|
|
2010
2170
|
break;
|
|
2011
2171
|
default:
|
|
2012
2172
|
throw new Error(`Unsupported JSON schema type: ${value.type}`);
|
|
@@ -2017,7 +2177,7 @@ function jsonSchemaToModel(jsonSchema) {
|
|
|
2017
2177
|
const properties = jsonSchema.properties;
|
|
2018
2178
|
const requiredFields = jsonSchema.required || [];
|
|
2019
2179
|
if (!properties) {
|
|
2020
|
-
return
|
|
2180
|
+
return z5.object({});
|
|
2021
2181
|
}
|
|
2022
2182
|
const zodSchema = {};
|
|
2023
2183
|
for (const [key, _] of Object.entries(properties)) {
|
|
@@ -2029,7 +2189,7 @@ function jsonSchemaToModel(jsonSchema) {
|
|
|
2029
2189
|
schema
|
|
2030
2190
|
)
|
|
2031
2191
|
);
|
|
2032
|
-
zodType =
|
|
2192
|
+
zodType = z5.union(anyOfTypes).describe(
|
|
2033
2193
|
(value.description || "") + (value.examples ? `
|
|
2034
2194
|
Examples: ${value.examples.join(", ")}` : "")
|
|
2035
2195
|
);
|
|
@@ -2039,7 +2199,7 @@ Examples: ${value.examples.join(", ")}` : "")
|
|
|
2039
2199
|
schema
|
|
2040
2200
|
)
|
|
2041
2201
|
);
|
|
2042
|
-
zodType =
|
|
2202
|
+
zodType = z5.intersection(
|
|
2043
2203
|
allOfTypes[0],
|
|
2044
2204
|
allOfTypes.slice(1).reduce((acc, schema) => acc.and(schema), allOfTypes[0])
|
|
2045
2205
|
).describe(
|
|
@@ -2063,9 +2223,11 @@ Examples: ${value.examples.join(", ")}` : "")
|
|
|
2063
2223
|
zodSchema[key] = zodType.optional();
|
|
2064
2224
|
}
|
|
2065
2225
|
}
|
|
2066
|
-
return
|
|
2226
|
+
return z5.object(zodSchema);
|
|
2067
2227
|
}
|
|
2068
2228
|
export {
|
|
2229
|
+
AuthConfigTypes,
|
|
2230
|
+
AuthSchemeTypes,
|
|
2069
2231
|
BaseAgenticToolset,
|
|
2070
2232
|
BaseNonAgenticToolset,
|
|
2071
2233
|
BaseTelemetryTransport,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -28,9 +28,6 @@
|
|
|
28
28
|
"author": "",
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"packageManager": "pnpm@10.8.0",
|
|
31
|
-
"peerDependencies": {
|
|
32
|
-
"openai": "^4.94.0"
|
|
33
|
-
},
|
|
34
31
|
"devDependencies": {
|
|
35
32
|
"tsup": "^8.4.0",
|
|
36
33
|
"tsx": "^4.19.3",
|
|
@@ -38,10 +35,11 @@
|
|
|
38
35
|
},
|
|
39
36
|
"dependencies": {
|
|
40
37
|
"@composio/client": "0.1.0-alpha.9",
|
|
38
|
+
"openai": "^4.94.0",
|
|
41
39
|
"pusher-js": "^8.4.0",
|
|
42
40
|
"uuid": "^11.1.0",
|
|
43
41
|
"zod": "^3.24.2",
|
|
44
42
|
"zod-to-json-schema": "^3.24.5"
|
|
45
43
|
},
|
|
46
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "5d9df8854dde996024639b4fbe5940c00167baf0"
|
|
47
45
|
}
|