"重构模块依赖并添加查询应用功能"
This commit is contained in:
		
							
								
								
									
										30
									
								
								packages/query-app/bun.config.mjs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								packages/query-app/bun.config.mjs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
// @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' });
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								packages/query-app/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								packages/query-app/package.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
{
 | 
			
		||||
  "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"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										57
									
								
								packages/query-app/src/defines/app.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								packages/query-app/src/defines/app.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,57 @@
 | 
			
		||||
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 数据',
 | 
			
		||||
  },
 | 
			
		||||
});
 | 
			
		||||
							
								
								
									
										1
									
								
								packages/query-app/src/defines/common.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								packages/query-app/src/defines/common.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
export { QueryUtil } from '@kevisual/router/define';
 | 
			
		||||
							
								
								
									
										3
									
								
								packages/query-app/src/defines/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								packages/query-app/src/defines/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
import { appDefine } from './app';
 | 
			
		||||
import { userAppDefine } from './user-app';
 | 
			
		||||
export { appDefine, userAppDefine };
 | 
			
		||||
							
								
								
									
										33
									
								
								packages/query-app/src/defines/user-app.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								packages/query-app/src/defines/user-app.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
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 的数据进行测试,获取版本信息',
 | 
			
		||||
  },
 | 
			
		||||
});
 | 
			
		||||
							
								
								
									
										1
									
								
								packages/query-app/src/query-app-define.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								packages/query-app/src/query-app-define.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
export * from './defines/index.ts';
 | 
			
		||||
							
								
								
									
										18
									
								
								packages/query-app/src/query-app.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								packages/query-app/src/query-app.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
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);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										6
									
								
								packages/query-app/src/test/query-app.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								packages/query-app/src/test/query-app.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
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({});
 | 
			
		||||
							
								
								
									
										18
									
								
								packages/query-app/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								packages/query-app/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
{
 | 
			
		||||
  "extends": "@kevisual/types/json/frontend.json",
 | 
			
		||||
  "compilerOptions": {
 | 
			
		||||
    "baseUrl": ".",
 | 
			
		||||
    "typeRoots": [
 | 
			
		||||
      "./node_modules/@types",
 | 
			
		||||
      "./node_modules/@kevisual"
 | 
			
		||||
    ],
 | 
			
		||||
    "paths": {
 | 
			
		||||
      "@/*": [
 | 
			
		||||
        "src/*"
 | 
			
		||||
      ]
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  "include": [
 | 
			
		||||
    "src/**/*",
 | 
			
		||||
  ],
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user