@akanjs/devkit 2.1.1-rc.1 → 2.1.1

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/auth.ts DELETED
@@ -1,41 +0,0 @@
1
- import { mkdir } from "node:fs/promises";
2
-
3
- import {
4
- type AkanGlobalConfig,
5
- akanCloudHost,
6
- akanCloudUrl,
7
- basePath,
8
- configPath,
9
- defaultAkanGlobalConfig,
10
- defaultHostConfig,
11
- type HostConfig,
12
- } from "./constants";
13
- import { FileSys } from "./fileSys";
14
-
15
- export const getAkanGlobalConfig = async () => {
16
- const exists = await FileSys.fileExists(configPath);
17
- const akanConfig = exists ? await FileSys.readJson<AkanGlobalConfig>(configPath) : defaultAkanGlobalConfig;
18
- return akanConfig;
19
- };
20
- export const setAkanGlobalConfig = async (akanConfig: AkanGlobalConfig) => {
21
- await mkdir(basePath, { recursive: true });
22
- await Bun.write(configPath, JSON.stringify(akanConfig, null, 2));
23
- };
24
- export const getHostConfig = async (host = akanCloudHost) => {
25
- const akanConfig = await getAkanGlobalConfig();
26
- return akanConfig.cloudHost[host] ?? defaultHostConfig;
27
- };
28
- export const setHostConfig = async (host = akanCloudHost, config: HostConfig = {}) => {
29
- const akanConfig = await getAkanGlobalConfig();
30
- akanConfig.cloudHost[host] = config;
31
- await setAkanGlobalConfig(akanConfig);
32
- };
33
- export const getSelf = async (token: string) => {
34
- try {
35
- const res = await fetch(`${akanCloudUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
36
- const user = (await res.json()) as { id: string; nickname: string };
37
- return user;
38
- } catch (e) {
39
- return null;
40
- }
41
- };
package/constants.ts DELETED
@@ -1,32 +0,0 @@
1
- import type { SupportedLlmModel } from "./aiEditor";
2
-
3
- export const basePath = `${Bun.env.HOME ?? Bun.env.USERPROFILE}/.akan`;
4
- export const configPath = `${basePath}/config.json`;
5
- export const akanCloudHost =
6
- process.env.AKAN_PUBLIC_OPERATION_MODE === "local"
7
- ? "http://localhost"
8
- : "https://cloud.akanjs.com";
9
- export const akanCloudUrl = `${akanCloudHost}${
10
- process.env.AKAN_PUBLIC_OPERATION_MODE === "local" ? ":8282" : ""
11
- }/api`;
12
-
13
- export interface HostConfig {
14
- auth?: {
15
- token: string;
16
- self: { id: string; nickname: string };
17
- };
18
- }
19
- export const defaultHostConfig: HostConfig = {};
20
- export interface AkanGlobalConfig {
21
- cloudHost: {
22
- [key: string]: HostConfig;
23
- };
24
- llm: {
25
- model: SupportedLlmModel;
26
- apiKey: string;
27
- } | null;
28
- }
29
- export const defaultAkanGlobalConfig: AkanGlobalConfig = {
30
- cloudHost: {},
31
- llm: null,
32
- };