Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: add types #842

Merged
merged 14 commits into from
Nov 14, 2024

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api-reference/actions-controller-v-1/execute-action.mdx

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api-reference/actions-controller-v-1/get-action.mdx

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api-reference/actions-controller-v-1/list-actions.mdx

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api-reference/actions-controller-v-2/execute-action.mdx

This file was deleted.

3 changes: 3 additions & 0 deletions docs/api-reference/admin/clear-cache.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

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

The new API documentation files are missing descriptions and details about the endpoints. Consider adding information such as parameters, request body, responses, and examples to improve clarity and usability. This applies to clear-cache.mdx, get-user-info.mdx, and update-connection-data.mdx.

openapi: post /api/v1/clear-cache
---
3 changes: 3 additions & 0 deletions docs/api-reference/auth/get-user-info.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
openapi: get /api/v1/client/auth/client_info
---
3 changes: 3 additions & 0 deletions docs/api-reference/connections/update-connection-data.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
openapi: patch /api/v1/connectedAccounts/{connectedAccountId}/data
---
2 changes: 1 addition & 1 deletion docs/composio_openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "composio-core",
"version": "0.2.9-3",
"version": "0.2.9-6",
"description": "",
"main": "lib/src/index.js",
"scripts": {
Expand Down
20 changes: 16 additions & 4 deletions js/src/sdk/client/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ export const $ExpectedInputFieldsDTO = {
type: 'string',
description: 'Description of the field'
},
displayName: {
display_name: {
type: 'string',
description: 'Display name of the field'
},
Expand All @@ -809,17 +809,17 @@ export const $ExpectedInputFieldsDTO = {
type: 'boolean',
description: 'Whether the field is required'
},
expectedFromCustomer: {
expected_from_customer: {
type: 'boolean',
description: 'Whether the field is expected from customer'
},
isSecret: {
is_secret: {
type: 'boolean',
description: 'Whether the field is a secret'
}
},
type: 'object',
required: ['name', 'type', 'description', 'displayName', 'default', 'required', 'expectedFromCustomer', 'isSecret']
required: ['name', 'type', 'description', 'display_name', 'default', 'required', 'expected_from_customer', 'is_secret']
} as const;

export const $GetConnectorInfoResDTO = {
Expand Down Expand Up @@ -1161,6 +1161,12 @@ export const $ConnectionWithAppData = {
'$ref': '#/components/schemas/MemberInfoResDTO'
},
type: 'object'
},
labels: {
items: {
type: 'string'
},
type: 'array'
}
},
type: 'object',
Expand Down Expand Up @@ -1316,6 +1322,12 @@ export const $ConnectionParams = {
'$ref': '#/components/schemas/MemberInfoResDTO'
},
type: 'object'
},
labels: {
items: {
type: 'string'
},
type: 'array'
}
},
type: 'object',
Expand Down
10 changes: 6 additions & 4 deletions js/src/sdk/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export type AppQueryDTO = {
*/
additionalFields?: string;
/**
* Whether to include local tools or not
* Enter 'true' or 'false'
*/
includeLocal?: string;
};
Expand Down Expand Up @@ -571,7 +571,7 @@ export type ExpectedInputFieldsDTO = {
/**
* Display name of the field
*/
displayName: string;
display_name: string;
/**
* Default value of the field
*/
Expand All @@ -585,11 +585,11 @@ export type ExpectedInputFieldsDTO = {
/**
* Whether the field is expected from customer
*/
expectedFromCustomer: boolean;
expected_from_customer: boolean;
/**
* Whether the field is a secret
*/
isSecret: boolean;
is_secret: boolean;
};

export type GetConnectorInfoResDTO = {
Expand Down Expand Up @@ -810,6 +810,7 @@ export type ConnectionWithAppData = {
member: {
[key: string]: unknown;
};
labels?: Array<(string)>;
};

export type GetConnectionsResult = {
Expand Down Expand Up @@ -877,6 +878,7 @@ export type ConnectionParams = {
member: {
[key: string]: unknown;
};
labels?: Array<(string)>;
};

export type ToggleConnectedAccountResponseDTO = {
Expand Down
16 changes: 16 additions & 0 deletions js/src/sdk/models/Entity.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
import { describe, it, expect } from "@jest/globals";
import { getBackendClient } from "../testUtils/getBackendClient";
import { Entity } from "./Entity";
import { ConnectedAccounts } from "./connectedAccounts";

describe("Entity class tests", () => {
let backendClient = getBackendClient();
let entity: Entity;
let triggerId: string;
let connectedAccounts: ConnectedAccounts;

beforeAll(() => {
entity = new Entity(backendClient, "default");
connectedAccounts = new ConnectedAccounts(backendClient);

});

it("should create an Entity instance with 'default' id", () => {
expect(entity).toBeInstanceOf(Entity);
expect(entity.id).toBe("default");
});


it("should create for different entities", async () => {
const entityId = "test-entity";
const entity2 = new Entity(backendClient, entityId);
const connection = await entity2.initiateConnection("github");
expect(connection.connectionStatus).toBe("INITIATED");

const connection2 = await connectedAccounts.get({connectedAccountId: connection.connectedAccountId});
if(!connection2) throw new Error("Connection not found");
expect(connection2.entityId).toBe(entityId);
});

it("get connection for github", async () => {
const app = "github";
Expand Down
2 changes: 1 addition & 1 deletion js/src/sdk/models/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class Entity {
// Initiate the connection process
return this.connectedAccounts.initiate({
integrationId: integration!.id!,
userUuid: this.id,
entityId: this.id,
redirectUri: redirectUrl,
//@ts-ignore
data: connectionData,
Expand Down
5 changes: 3 additions & 2 deletions js/src/sdk/models/connectedAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ type ConnectedAccountsListData = GetConnectionsData['query'] & {appNames?: strin

type InitiateConnectionDataReq = InitiateConnectionPayloadDto & {
data?: Record<string, unknown> | unknown;
userUuid?: string;
entityId?: string;
labels?: string[];
integrationId: string;
redirectUri?: string;
}

export class ConnectedAccounts {
Expand Down Expand Up @@ -70,12 +70,13 @@ export class ConnectedAccounts {

async initiate(payload: InitiateConnectionDataReq): Promise<ConnectionRequest> {
try {
const {integrationId, entityId = 'default', labels,data={}} = payload;
const {integrationId, entityId = 'default', labels,data={}, redirectUri} = payload;

const res = await client.connections.initiateConnection({ body: {
integrationId,
entityId,
labels,
redirectUri,
data,
} }).then(res => res.data);

Expand Down
8 changes: 6 additions & 2 deletions js/src/sdk/utils/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ export class CEG {

let axiosDataMessage = axiosError.response?.data?.message || axiosError.message;
const status = axiosError.response?.status || axiosError.status || axiosError.code || 'unknown';
const urlAndStatus = axiosError.config?.url ? `in (URL: ${axiosError.config.url}, Status: ${status})` : '';
axiosDataMessage = `${axiosDataMessage || errorDetails.description || "No additional information available."} ${urlAndStatus}`;
const urlAndStatus = axiosError.config?.url ? `🔗 in URL: ${axiosError.config.url}, 📊 Status: ${status}` : '';
axiosDataMessage = `❌ ${ifObjectStringify(axiosDataMessage) || errorDetails.description || "No additional information available."} ${urlAndStatus}`;
throw new ComposioError(
errorKey as string,
errorDetails.message,
Expand Down Expand Up @@ -151,4 +151,8 @@ export class CEG {

throw new ComposioError(messageCode, message || errorDetails.message, description || errorDetails.description, possibleFix || errorDetails.possibleFix);
}
}

export const ifObjectStringify = (obj: any) => {
return typeof obj === 'object' ? JSON.stringify(obj) : obj;
}
Loading