Files
tkmind_go/ui/desktop/src/api/config.ts
T
2025-02-13 13:50:02 -05:00

60 lines
1.2 KiB
TypeScript

import {
readAllConfig,
readConfig,
removeConfig,
upsertConfig,
addExtension,
removeExtension,
} from './generated';
import { client } from './generated/client.gen';
// Initialize client configuration
client.setConfig({
baseUrl: window.appConfig.get('GOOSE_API_HOST') + ':' + window.appConfig.get('GOOSE_PORT'),
headers: {
'Content-Type': 'application/json',
'X-Secret-Key': window.appConfig.get('secretKey'),
},
});
export class Config {
static async upsert(key: string, value: any, isSecret?: boolean) {
return await upsertConfig({
body: {
key,
value,
is_secret: isSecret,
},
});
}
static async read(key: string) {
return await readConfig({
body: { key },
});
}
static async remove(key: string) {
return await removeConfig({
body: { key },
});
}
static async readAll() {
const response = await readAllConfig();
return response.data.config;
}
static async addExtension(name: string, config: any) {
return await addExtension({
body: { name, config },
});
}
static async removeExtension(name: string) {
return await removeExtension({
body: { key: name },
});
}
}