This commit is contained in:
2025-12-08 01:56:17 +08:00
parent 04a21d7178
commit 7793764baa
54 changed files with 762 additions and 1091 deletions

View File

@@ -0,0 +1,65 @@
/**
* 配置查询
* @updatedAt 2025-12-03 10:33:00
*/
import { Query } from '@kevisual/query';
import type { Result } from '@kevisual/query/query';
type QueryConfigOpts = {
query?: Query;
};
export type Config<T = any> = {
id?: string;
title?: string;
key?: string;
description?: string;
data?: T;
createdAt?: string;
updatedAt?: string;
};
export type UploadConfig = {
key?: string;
version?: string;
};
type PostOpts = {
token?: string;
payload?: Record<string, any>;
};
export class QueryConfig {
query: Query;
constructor(opts?: QueryConfigOpts) {
this.query = opts?.query || new Query();
}
async post<T = Config>(data: any) {
return this.query.post<T>({ path: 'secret', ...data });
}
async getItem({ id, key }: { id?: string; key?: string }, opts?: PostOpts) {
return this.post({
key: 'get',
data: {
id,
key,
},
...opts,
});
}
async updateItem(data: Config, opts?: PostOpts) {
return this.post({
key: 'update',
data,
...opts,
});
}
async deleteItem(data: { id?: string, key?: string }, opts?: PostOpts) {
return this.post({
key: 'delete',
data,
});
}
async listItems(opts?: PostOpts) {
return this.post<{ list: Config[] }>({
key: 'list',
...opts,
});
}
}