diff --git a/.github/workflows/run_js_test.yml b/.github/workflows/run_js_test.yml index 3df1053029c..98c93a32cb6 100644 --- a/.github/workflows/run_js_test.yml +++ b/.github/workflows/run_js_test.yml @@ -30,4 +30,4 @@ jobs: - name: pnpm build run: cd js && pnpm build - name: run test - run: cd js && pnpm test \ No newline at end of file + run: cd js && pnpm test diff --git a/js/config/getTestConfig.ts b/js/config/getTestConfig.ts new file mode 100644 index 00000000000..45b5fa41b1c --- /dev/null +++ b/js/config/getTestConfig.ts @@ -0,0 +1,4 @@ +export const env = process.env.TEST_ENV || "prod" +export const getTestConfig = ():Record => { + return require(`./test.config.${env}.json`); +} \ No newline at end of file diff --git a/js/config/test.config.prod.json b/js/config/test.config.prod.json new file mode 100644 index 00000000000..489feb5be83 --- /dev/null +++ b/js/config/test.config.prod.json @@ -0,0 +1,4 @@ +{ + "COMPOSIO_API_KEY": "cq5ke4zt8e7a1lmen823", + "BACKEND_HERMES_URL": "https://backend.composio.dev" +} \ No newline at end of file diff --git a/js/src/sdk/baseClient.ts b/js/src/sdk/baseClient.ts deleted file mode 100644 index faff84ee4ca..00000000000 --- a/js/src/sdk/baseClient.ts +++ /dev/null @@ -1,33 +0,0 @@ -// import { Composio } from "." -// import { OpenAIToolSet } from "../frameworks/openai"; - -// // //const composioSDK = new Composio("tmam8qoxvuiinbsaikgh", "http://localhost:9900"); -// // const composioSDK = new Composio("cc0fu8lookgq1ov8z4xx9n", "https://backend.composio.dev"); - -// (async()=>{ -// // const entity = await composioSDK.getEntity("himanshu") -// // const toolset = new OpenAIToolSet({ -// // apiKey: "tmam8qoxvuiinbsaikgh", -// // baseUrl: "http://localhost:9900" -// // }) - -// // const tools = await toolset.getActions({ -// // actions: ["GITHUB_GITHUB_API_ROOT"] -// // }) - -// // console.log("ds") - -// // const data = await entity.initiateConnection('github'); -// // console.log(data) -// // const list = await composioSDK.connectedAccounts.list({ -// // user_uuid: '1' -// // }) - -// // console.log(list) - -// // const items = await OpenAIToolSet({ -// // apiKey?: Optional, -// // baseUrl? -// // }) - -// })() \ No newline at end of file diff --git a/js/src/sdk/index.spec.ts b/js/src/sdk/index.spec.ts new file mode 100644 index 00000000000..c767a6bcf0e --- /dev/null +++ b/js/src/sdk/index.spec.ts @@ -0,0 +1,30 @@ +import { describe, it, expect } from "@jest/globals"; +import {Composio} from "./index" + +//@ts-ignore +import { getTestConfig } from "../../config/getTestConfig"; + +const COMPOSIO_API_KEY = getTestConfig()["COMPOSIO_API_KEY"] +const BACKEND_HERMES_URL = getTestConfig()["BACKEND_HERMES_URL"] + +describe("Basic SDK spec suite", () => { + it("create basic client", () => { + new Composio(COMPOSIO_API_KEY) + }); + + it("without apiKey, error should be thrown", () => { + expect(() => { + new Composio(); + }).toThrow('API key is missing'); + }); + + it("get entity",async()=>{ + const app = "github" + const composio = new Composio(COMPOSIO_API_KEY, BACKEND_HERMES_URL); + const entity = composio.getEntity("default") + + expect(entity.id).toBe("default") + const connection = await entity.getConnection(app); + expect(connection.appUniqueId).toBe(app); + }) +}); diff --git a/js/src/sdk/models/Entity.ts b/js/src/sdk/models/Entity.ts index 593d2938bb0..3dbe9367b7d 100644 --- a/js/src/sdk/models/Entity.ts +++ b/js/src/sdk/models/Entity.ts @@ -163,8 +163,6 @@ export class Entity { }); } - - console.log("hi") // Initiate the connection process return ConnectedAccounts.initiate({ integrationId: integration!.id!, diff --git a/js/tsconfig.json b/js/tsconfig.json index fa915a8d547..32f5337b1d7 100644 --- a/js/tsconfig.json +++ b/js/tsconfig.json @@ -8,7 +8,7 @@ "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "outDir": "./dist", - "rootDir": "./src", + "rootDir": "./", "sourceMap": true, }, "include": ["src/**/*"],