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

@@ -1,13 +0,0 @@
// @ts-check
import { execSync } from 'node:child_process';
import glob from 'fast-glob';
import fs from 'node:fs';
const files = await glob(['packages/*/dist', 'submodules/*/dist'], { onlyDirectories: true });
console.log('files', files);
const clean = 'rimraf dist && mkdir dist';
execSync(clean);
for (let dir of files) {
const rsync = `rsync ${dir}/* ./dist`;
execSync(rsync);
}

View File

@@ -1,8 +1,8 @@
{ {
"name": "@kevisual/query-awesome", "name": "@kevisual/query-awesome",
"version": "0.0.2", "version": "0.0.4",
"description": "", "description": "",
"main": "index.js", "main": "mod.ts",
"scripts": { "scripts": {
"build": "turbo run build", "build": "turbo run build",
"postbuild": "bun bun.copy.config.mjs" "postbuild": "bun bun.copy.config.mjs"
@@ -23,15 +23,9 @@
"@kevisual/router": "^0.0.36", "@kevisual/router": "^0.0.36",
"@kevisual/types": "^0.0.10", "@kevisual/types": "^0.0.10",
"@kevisual/use-config": "^1.0.21", "@kevisual/use-config": "^1.0.21",
"@types/bun": "^1.3.3",
"@types/node": "^24.10.1",
"fast-glob": "^3.3.3", "fast-glob": "^3.3.3",
"tsup": "^8.5.1" "tsup": "^8.5.1"
},
"exports": {
".": {
"import": "./dist/query-login-browser.js"
},
"./*": {
"import": "./dist/*"
}
} }
} }

View File

@@ -1,3 +0,0 @@
//npm.xiongxiao.me/:_authToken=${ME_NPM_TOKEN}
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
ignore-workspace-root-check=true

View File

@@ -1,22 +0,0 @@
{
"$schema": "https://kevisual.xiongxiao.me/root/ai/kevisual/tools/kevisual-sync/schema.json?v=2",
"metadata": {
"share": "public"
},
"checkDir": {
"query": {
"url": "https://kevisual.xiongxiao.me/root/ai/code/registry/query",
"enabled": true
}
},
"syncDirectory": [
{
"files": [
"query/**/*"
],
"ignore": [],
"registry": "https://kevisual.xiongxiao.me/root/ai/code/registry"
}
],
"sync": {}
}

View File

@@ -1,32 +0,0 @@
{
"name": "@kevisual/api",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"build2": "bun bun.config.mjs",
"download": "ev sync download",
"upload": "ev sync upload"
},
"keywords": [],
"files": [
"src",
"query",
"dist"
],
"publishConfig": {
"access": "public"
},
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
"license": "MIT",
"packageManager": "pnpm@10.6.2",
"type": "module",
"dependencies": {
"@kevisual/query": "^0.0.18",
"@kevisual/router": "^0.0.20"
},
"devDependencies": {
"@kevisual/types": "^0.0.10",
"@types/node": "^22.15.27"
}
}

View File

@@ -1,154 +0,0 @@
import { Query } from '@kevisual/query';
import type { Result, DataOpts } from '@kevisual/query/query';
export type SimpleObject = Record<string, any>;
export const markType = ['simple', 'md', 'mdx', 'wallnote', 'excalidraw', 'chat'] as const;
export type MarkType = (typeof markType)[number];
export type MarkData = {
nodes?: any[];
edges?: any[];
elements?: any[];
permission?: any;
[key: string]: any;
};
export type Mark = {
id: string;
title: string;
description: string;
markType: MarkType;
link: string;
data?: MarkData;
uid: string;
puid: string;
summary: string;
thumbnail?: string;
tags: string[];
createdAt: string;
updatedAt: string;
version: number;
};
export type ShowMarkPick = Pick<Mark, 'id' | 'title' | 'description' | 'summary' | 'link' | 'tags' | 'thumbnail' | 'updatedAt'>;
export type SearchOpts = {
page?: number;
pageSize?: number;
search?: string;
sort?: string; // DESC, ASC
markType?: MarkType; // 类型
[key: string]: any;
};
export type QueryMarkOpts<T extends SimpleObject = SimpleObject> = {
query?: Query;
isBrowser?: boolean;
onLoad?: () => void;
} & T;
export type ResultMarkList = {
list: Mark[];
pagination: {
pageSize: number;
current: number;
total: number;
};
};
export type QueryMarkData = {
id?: string;
title?: string;
description?: string;
[key: string]: any;
};
export type QueryMarkResult = {
accessToken: string;
refreshToken: string;
};
export class QueryMarkBase<T extends SimpleObject = SimpleObject> {
query: Query;
isBrowser: boolean;
load?: boolean;
storage?: Storage;
onLoad?: () => void;
constructor(opts?: QueryMarkOpts<T>) {
this.query = opts?.query || new Query();
this.isBrowser = opts?.isBrowser ?? true;
this.init();
this.onLoad = opts?.onLoad;
}
setQuery(query: Query) {
this.query = query;
}
private async init() {
this.load = true;
this.onLoad?.();
}
async post<T = Result<any>>(data: any, opts?: DataOpts): Promise<T> {
try {
return this.query.post({ path: 'mark', ...data }, opts) as Promise<T>;
} catch (error) {
console.log('error', error);
return {
code: 400,
} as any;
}
}
async getMarkList(search: SearchOpts, opts?: DataOpts) {
return this.post<Result<ResultMarkList>>({ key: 'list', ...search }, opts);
}
async getMark(id: string, opts?: DataOpts) {
return this.post<Result<Mark>>({ key: 'get', id }, opts);
}
async getVersion(id: string, opts?: DataOpts) {
return this.post<Result<{ version: number; id: string }>>({ key: 'getVersion', id }, opts);
}
/**
* 检查版本
* 当需要更新时返回true
* @param id
* @param version
* @param opts
* @returns
*/
async checkVersion(id: string, version?: number, opts?: DataOpts) {
if (!version) {
return true;
}
const res = await this.getVersion(id, opts);
if (res.code === 200) {
if (res.data!.version > version) {
return true;
}
return false;
}
return true;
}
async updateMark(data: any, opts?: DataOpts) {
return this.post<Result<Mark>>({ key: 'update', data }, opts);
}
async deleteMark(id: string, opts?: DataOpts) {
return this.post<Result<Mark>>({ key: 'delete', id }, opts);
}
}
export class QueryMark extends QueryMarkBase<SimpleObject> {
markType: string;
constructor(opts?: QueryMarkOpts & { markType?: MarkType }) {
super(opts);
this.markType = opts?.markType || 'simple';
}
async getMarkList(search?: SearchOpts, opts?: DataOpts) {
return this.post<Result<ResultMarkList>>({ key: 'list', ...search, markType: this.markType }, opts);
}
async updateMark(data: any, opts?: DataOpts) {
if (!data.id) {
data.markType = this.markType || 'simple';
}
return super.updateMark(data, opts);
}
}

View File

@@ -1,19 +0,0 @@
{
"extends": "@kevisual/types/json/frontend.json",
"compilerOptions": {
"baseUrl": ".",
"typeRoots": [
"./node_modules/@types",
"./node_modules/@kevisual"
],
"paths": {
"@/*": [
"src/*"
]
},
},
"include": [
"src/**/*",
"query/**/*",
],
}

View File

@@ -1,30 +0,0 @@
// @ts-check
import { resolvePath, getDevInputs } from '@kevisual/use-config/env';
import { execSync } from 'node:child_process';
import glob from 'fast-glob';
const files = await glob(['src/defines/*.ts', 'src/query/*.ts', 'src/router/*.ts']);
const inputs = getDevInputs(files);
const external = ['@kevisual/router'];
for (let input of inputs) {
const entry = input.path;
const naming = input.naming;
/**
* @type {import('bun').BuildConfig}
*/
await Bun.build({
target: 'node',
format: 'esm',
entrypoints: [resolvePath(entry, { meta: import.meta })],
outdir: resolvePath('./dist', { meta: import.meta }),
naming: {
entry: naming + '.js',
},
external: external,
env: 'KEVISUAL_*',
});
const cmd = `dts -i ${entry} -o ${naming}.d.ts`;
execSync(cmd, { stdio: 'inherit' });
}

View File

@@ -1,18 +0,0 @@
{
"name": "@kevisual/query-list",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"build": "bun bun.config.mjs"
},
"keywords": [],
"files": [
"src",
"dist"
],
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
"license": "MIT",
"packageManager": "pnpm@10.6.2",
"type": "module"
}

View File

@@ -1,27 +0,0 @@
import { QueryUtil } from '@kevisual/router/define';
export const shopDefine = QueryUtil.create({
getRegistry: {
path: 'shop',
key: 'get-registry',
description: '获取应用商店注册表信息',
},
listInstalled: {
path: 'shop',
key: 'list-installed',
description: '列出当前已安装的所有应用',
},
install: {
path: 'shop',
key: 'install',
description: '安装指定的应用,可以指定 id、type、force 和 yes 参数',
},
uninstall: {
path: 'shop',
key: 'uninstall',
description: '卸载指定的应用,可以指定 id 和 type 参数',
},
});

View File

@@ -1,19 +0,0 @@
import { shopDefine } from '../defines/query-shop-define.ts';
import { BaseQuery, DataOpts, Query } from '@kevisual/query/query';
export { shopDefine };
export class QueryApp extends BaseQuery {
appDefine = shopDefine;
constructor(opts?: { query: Query }) {
super(opts!);
this.appDefine.query = this.query;
}
get chain() {
return this.appDefine.queryChain;
}
getInstall(data: any, opts?: DataOpts) {
return this.appDefine.queryChain('install').post(data, opts);
}
}

View File

@@ -1,18 +0,0 @@
{
"extends": "@kevisual/types/json/frontend.json",
"compilerOptions": {
"baseUrl": ".",
"typeRoots": [
"./node_modules/@types",
"./node_modules/@kevisual"
],
"paths": {
"@/*": [
"src/*"
]
},
},
"include": [
"src/**/*",
],
}

View File

@@ -1,30 +0,0 @@
// @ts-check
import { resolvePath, getDevInputs } from '@kevisual/use-config/env';
import { execSync } from 'node:child_process';
import glob from 'fast-glob';
const files = await glob('src/*.ts');
const inputs = getDevInputs(files);
const external = ['@kevisual/router'];
for (let input of inputs) {
const entry = input.path;
const naming = input.naming;
/**
* @type {import('bun').BuildConfig}
*/
await Bun.build({
target: 'node',
format: 'esm',
entrypoints: [resolvePath(entry, { meta: import.meta })],
outdir: resolvePath('./dist', { meta: import.meta }),
naming: {
entry: naming + '.js',
},
external: external,
env: 'KEVISUAL_*',
});
const cmd = `dts -i ${entry} -o ${naming}.d.ts`;
execSync(cmd, { stdio: 'inherit' });
}

View File

@@ -1,18 +0,0 @@
{
"name": "@kevisual/query-app",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"build": "bun bun.config.mjs"
},
"keywords": [],
"files": [
"src",
"dist"
],
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
"license": "MIT",
"packageManager": "pnpm@10.6.2",
"type": "module"
}

View File

@@ -1,62 +0,0 @@
import { QueryUtil } from './common.ts';
export const appDefine = QueryUtil.create({
getApp: {
path: 'app',
key: 'get',
description: '获取应用信息',
},
updateApp: {
path: 'app',
key: 'update',
description: '更新应用信息',
},
deleteApp: {
path: 'app',
key: 'delete',
description: '删除应用信息',
},
listApps: {
path: 'app',
key: 'list',
description: '列出所有应用信息',
},
canUploadFiles: {
path: 'app',
key: 'canUploadFiles',
description: '检查是否可以上传文件',
},
uploadFiles: {
path: 'app',
key: 'uploadFiles',
description: '上传文件',
},
publishApp: {
path: 'app',
key: 'publish',
description: '发布应用',
},
getMinioList: {
path: 'app',
key: 'get-minio-list',
description: '获取 MinIO 文件列表',
},
detectVersionList: {
path: 'app',
key: 'detectVersionList',
description: '检测版本列表并同步 MinIO 数据',
},
publicList: {
path: 'app',
key: 'public-list',
description: '获取公开应用列表',
},
});

View File

@@ -1 +0,0 @@
export { QueryUtil } from '@kevisual/router/define';

View File

@@ -1,3 +0,0 @@
import { appDefine } from './app';
import { userAppDefine } from './user-app';
export { appDefine, userAppDefine };

View File

@@ -1,33 +0,0 @@
import { QueryUtil } from './common.ts';
export const userAppDefine = QueryUtil.create({
listUserApps: {
path: 'user-app',
key: 'list',
description: '列出当前用户的所有应用(不包含 data 字段)',
},
getUserApp: {
path: 'user-app',
key: 'get',
description: '获取用户应用信息,可以指定 id 或 key',
},
updateUserApp: {
path: 'user-app',
key: 'update',
description: '更新或创建用户应用',
},
deleteUserApp: {
path: 'user-app',
key: 'delete',
description: '删除用户应用及关联数据',
},
testUserApp: {
path: 'user-app',
key: 'test',
description: '对 user-app 的数据进行测试,获取版本信息',
},
});

View File

@@ -1 +0,0 @@
export * from './defines/index.ts';

View File

@@ -1,18 +0,0 @@
import { appDefine, userAppDefine } from './defines/index.ts';
import { BaseQuery, DataOpts, Query } from '@kevisual/query/query';
export { appDefine, userAppDefine };
export class QueryApp extends BaseQuery {
appDefine = appDefine;
userAppDefine = userAppDefine;
constructor(opts?: { query: Query }) {
super(opts!);
this.appDefine.query = this.query;
this.userAppDefine.query = this.query;
}
getList(data: any, opts?: DataOpts) {
return this.appDefine.queryChain('listApps').post(data, opts);
}
}

View File

@@ -1,6 +0,0 @@
import { QueryApp } from '../query-app.ts';
import { Query } from '@kevisual/query/query';
const query = new Query();
const qa = new QueryApp({ query: query });
qa.appDefine.queryChain('getApp').post({});

View File

@@ -1,18 +0,0 @@
{
"extends": "@kevisual/types/json/frontend.json",
"compilerOptions": {
"baseUrl": ".",
"typeRoots": [
"./node_modules/@types",
"./node_modules/@kevisual"
],
"paths": {
"@/*": [
"src/*"
]
},
},
"include": [
"src/**/*",
],
}

1053
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +0,0 @@
packages:
- 'submodules/*'
- 'packages/*'
- 'apps/*'
- 'libs/*'

View File

@@ -1,4 +1,4 @@
import { QueryUtil } from '@/query/index.ts'; import { QueryUtil } from '../../../query/index.ts';
type Message = { type Message = {
role?: 'user' | 'assistant' | 'system' | 'tool'; role?: 'user' | 'assistant' | 'system' | 'tool';

View File

@@ -1,4 +1,4 @@
import { QueryUtil } from '@/query/index.ts'; import { QueryUtil } from '../../../query/index.ts';
export const appDefine = QueryUtil.create({ export const appDefine = QueryUtil.create({
getApp: { getApp: {

View File

@@ -15,4 +15,18 @@ export class QueryApp extends BaseQuery {
getList(data: any, opts?: DataOpts) { getList(data: any, opts?: DataOpts) {
return this.appDefine.queryChain('listApps').post(data, opts); return this.appDefine.queryChain('listApps').post(data, opts);
} }
getPublicApp(data: any, opts?: DataOpts) {
return this.query.post({
path: 'app',
key: 'getApp',
data: data,
}, opts);
}
getApp(data: any, opts?: DataOpts) {
return this.query.post({
path: 'app',
key: 'get',
data: data,
}, opts);
}
} }

View File

@@ -0,0 +1,121 @@
/**
* 配置查询
* @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 const defaultConfigKeys = ['upload.json', 'workspace.json', 'ai.json', 'user.json', 'life.json'] as const;
type DefaultConfigKey = (typeof defaultConfigKeys)[number];
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: 'config', ...data });
}
async getConfig({ id, key }: { id?: string; key?: string }, opts?: PostOpts) {
return this.post({
key: 'get',
data: {
id,
key,
},
...opts,
});
}
async updateConfig(data: Config, opts?: PostOpts) {
return this.post({
key: 'update',
data,
...opts,
});
}
async deleteConfig(data: { id?: string, key?: string }, opts?: PostOpts) {
console.log('Delete Config Params:', data);
return this.post({
key: 'delete',
data,
});
}
async listConfig(opts?: PostOpts) {
return this.post<{ list: Config[] }>({
key: 'list',
...opts,
});
}
/**
* 获取上传配置
* @returns
*/
async getUploadConfig(opts?: PostOpts) {
return this.post<Result<Config<UploadConfig>>>({
key: 'getUploadConfig',
...opts,
});
}
/**
* 更新上传配置
* @param data
* @returns
*/
async updateUploadConfig(data: Config, opts?: PostOpts) {
return this.post<Result<Config<UploadConfig>>>({
key: 'updateUploadConfig',
data,
...opts,
});
}
/**
* 检测配置是否存在
* @param id
* @returns
*/
async detectConfig(opts?: PostOpts) {
return this.post<{ updateList: Config[] }>({
key: 'detect',
...opts,
});
}
/**
* 获取配置, 获取默认的配置项
* @param key
* @returns
*/
async getConfigByKey(key: DefaultConfigKey, opts?: PostOpts) {
return this.post<Result<Config>>({
key: 'defaultConfig',
configKey: key,
...opts,
});
}
async getByKey<T = any>(key: string, opts?: PostOpts) {
return this.post<Result<Config<T>>>({
key: 'get',
...opts,
data: { key },
});
}
}

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,
});
}
}

View File

@@ -1,4 +1,4 @@
import { QueryUtil } from '@/query/index.ts'; import { QueryUtil } from '../../../query/index.ts';
export const shopDefine = QueryUtil.create({ export const shopDefine = QueryUtil.create({
getRegistry: { getRegistry: {

View File

@@ -4,14 +4,13 @@ import { BaseQuery, DataOpts, Query } from '@kevisual/query/query';
export { shopDefine }; export { shopDefine };
export class QueryShop<T extends Query = Query> extends BaseQuery<T, typeof shopDefine> { export class QueryShop<T extends Query = Query> extends BaseQuery<T> {
constructor(opts?: { query: T }) { constructor(opts?: { query: T }) {
super({ super({
query: opts?.query!, query: opts?.query!,
queryDefine: shopDefine,
}); });
} }
getInstall(data: any, opts?: DataOpts) { getInstall(data: any, opts?: DataOpts) {
return this.queryDefine.queryChain('install').post(data, opts); return this.query.post(data, opts);
} }
} }

View File

@@ -5,7 +5,8 @@ import { UploadProgress } from './core/upload-progress.ts';
export { uploadFiles, uploadFileChunked, UploadProgress }; export { uploadFiles, uploadFileChunked, UploadProgress };
export * from './utils/to-file.ts'; export { toTextFile, toFile, getDirectoryAndName } from './utils/to-file.ts';
export { randomId } from './utils/random-id.ts'; export { randomId } from './utils/random-id.ts';
export { filterFiles } from './utils/filter-files.ts'; export { filterFiles } from './utils/filter-files.ts';

View File

@@ -1,22 +0,0 @@
{
"$schema": "https://turbo.build/schema.json",
"tasks": {
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**"
]
},
"dev:lib": {
"persistent": true,
"cache": true
},
"build:lib": {
"dependsOn": [
"^build:lib"
]
}
}
}