feat: hook extensions up in settings-v2 (#1447)
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
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 },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
|
||||
import type { ReadAllConfigData, ReadAllConfigResponse, RemoveExtensionData, RemoveExtensionResponse, AddExtensionData, AddExtensionResponse, ReadConfigData, RemoveConfigData, RemoveConfigResponse, UpsertConfigData, UpsertConfigResponse } from './types.gen';
|
||||
import type { ReadAllConfigData, ReadAllConfigResponse, RemoveExtensionData, RemoveExtensionResponse, AddExtensionData, AddExtensionResponse, UpdateExtensionData, UpdateExtensionResponse, ReadConfigData, RemoveConfigData, RemoveConfigResponse, UpsertConfigData, UpsertConfigResponse } from './types.gen';
|
||||
import { client as _heyApiClient } from './client.gen';
|
||||
|
||||
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
||||
@@ -47,6 +47,17 @@ export const addExtension = <ThrowOnError extends boolean = false>(options: Opti
|
||||
});
|
||||
};
|
||||
|
||||
export const updateExtension = <ThrowOnError extends boolean = false>(options: Options<UpdateExtensionData, ThrowOnError>) => {
|
||||
return (options.client ?? _heyApiClient).put<UpdateExtensionResponse, unknown, ThrowOnError>({
|
||||
url: '/config/extension',
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options?.headers
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const readConfig = <ThrowOnError extends boolean = false>(options: Options<ReadConfigData, ThrowOnError>) => {
|
||||
return (options.client ?? _heyApiClient).get<unknown, unknown, ThrowOnError>({
|
||||
url: '/config/read',
|
||||
@@ -89,6 +89,33 @@ export type AddExtensionResponses = {
|
||||
|
||||
export type AddExtensionResponse = AddExtensionResponses[keyof AddExtensionResponses];
|
||||
|
||||
export type UpdateExtensionData = {
|
||||
body: ExtensionQuery;
|
||||
path?: never;
|
||||
query?: never;
|
||||
url: '/config/extension';
|
||||
};
|
||||
|
||||
export type UpdateExtensionErrors = {
|
||||
/**
|
||||
* Extension not found
|
||||
*/
|
||||
404: unknown;
|
||||
/**
|
||||
* Internal server error
|
||||
*/
|
||||
500: unknown;
|
||||
};
|
||||
|
||||
export type UpdateExtensionResponses = {
|
||||
/**
|
||||
* Extension configuration updated successfully
|
||||
*/
|
||||
200: string;
|
||||
};
|
||||
|
||||
export type UpdateExtensionResponse = UpdateExtensionResponses[keyof UpdateExtensionResponses];
|
||||
|
||||
export type ReadConfigData = {
|
||||
body: ConfigKeyQuery;
|
||||
path?: never;
|
||||
Reference in New Issue
Block a user