diff --git a/client/ts/package.json b/client/ts/package.json index 1410fcd8d..dd24a257d 100644 --- a/client/ts/package.json +++ b/client/ts/package.json @@ -1,8 +1,11 @@ { - "name": "monitor_client", + "name": "@monitor/client", "version": "1.0.0", - "main": "index.js", + "main": "dist/lib.js", "license": "MIT", + "scripts": { + "build": "tsc" + }, "dependencies": { "@tanstack/react-query": "^4.29.19", "axios": "^1.4.0" diff --git a/client/ts/src/lib.ts b/client/ts/src/lib.ts index faecea820..b9da7c6bc 100644 --- a/client/ts/src/lib.ts +++ b/client/ts/src/lib.ts @@ -19,8 +19,8 @@ export type LoginOptions = { secret?: string; }; -export async function MonitorClient(base_url: string) { - let jwt = ""; +export function MonitorClient(base_url: string, token?: string) { + let jwt = token ?? ""; const auth = async ( request: R @@ -40,12 +40,14 @@ export async function MonitorClient(base_url: string) { params: { username: options.username, password: options.password }, }); jwt = res.jwt; + return res.jwt; } else if (options.secret) { const res = await auth({ type: "LoginWithSecret", params: { username: options.username, secret: options.secret }, }); jwt = res.jwt; + return res.jwt; } } }; diff --git a/client/ts/tsconfig.json b/client/ts/tsconfig.json index d15dbffa1..b2162f14e 100644 --- a/client/ts/tsconfig.json +++ b/client/ts/tsconfig.json @@ -2,11 +2,12 @@ "compilerOptions": { "strict": true, "target": "ESNext", - "module": "CommonJS", + "module": "ESNext", "moduleResolution": "node", "allowSyntheticDefaultImports": true, "esModuleInterop": true, "isolatedModules": true, - "outDir": "build" + "outDir": "dist", + "declaration": true } } \ No newline at end of file