@kevisual/api 0.0.47 → 0.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import { QueryUtil } from '@kevisual/router/define';
1
2
  import { Query, BaseQuery, DataOpts } from '@kevisual/query/query';
2
3
 
3
4
  type Message = {
@@ -31,7 +32,13 @@ type ChatOpts = {
31
32
  */
32
33
  options?: any;
33
34
  };
34
- declare const appDefine: any;
35
+ declare const appDefine: QueryUtil<{
36
+ chat: {
37
+ path: string;
38
+ key: string;
39
+ description: string;
40
+ };
41
+ }>;
35
42
 
36
43
  declare class QueryApp<T extends Query = Query> extends BaseQuery<T, typeof appDefine> {
37
44
  constructor(opts?: {
@@ -43,7 +50,13 @@ declare class QueryApp<T extends Query = Query> extends BaseQuery<T, typeof appD
43
50
  * @param opts
44
51
  * @returns
45
52
  */
46
- postChat(data: PostChat, opts?: DataOpts): any;
53
+ postChat(data: PostChat, opts?: DataOpts): Promise<{
54
+ code: number;
55
+ data?: {
56
+ [x: string]: any;
57
+ } | undefined;
58
+ message?: string;
59
+ }>;
47
60
  /**
48
61
  * 获取模型列表
49
62
  * @param opts
@@ -51,7 +64,11 @@ declare class QueryApp<T extends Query = Query> extends BaseQuery<T, typeof appD
51
64
  */
52
65
  getModelList(data?: {
53
66
  usernames?: string[];
54
- }, opts?: DataOpts): any;
67
+ }, opts?: DataOpts): Promise<{
68
+ code: number;
69
+ data?: any;
70
+ message?: string;
71
+ }>;
55
72
  /**
56
73
  * 聊天对话模型
57
74
  * @param data
@@ -59,20 +76,36 @@ declare class QueryApp<T extends Query = Query> extends BaseQuery<T, typeof appD
59
76
  * @param opts
60
77
  * @returns
61
78
  */
62
- chat(data: ChatDataOpts, chatOpts: ChatOpts, opts?: DataOpts): any;
63
- clearConfigCache(opts?: DataOpts): any;
79
+ chat(data: ChatDataOpts, chatOpts: ChatOpts, opts?: DataOpts): Promise<{
80
+ code: number;
81
+ data?: any;
82
+ message?: string;
83
+ }>;
84
+ clearConfigCache(opts?: DataOpts): Promise<{
85
+ code: number;
86
+ data?: any;
87
+ message?: string;
88
+ }>;
64
89
  /**
65
90
  * 获取聊天使用情况
66
91
  * @param opts
67
92
  * @returns
68
93
  */
69
- getChatUsage(opts?: DataOpts): any;
94
+ getChatUsage(opts?: DataOpts): Promise<{
95
+ code: number;
96
+ data?: any;
97
+ message?: string;
98
+ }>;
70
99
  /**
71
100
  * 清除当前用户模型自己的统计
72
101
  * @param opts
73
102
  * @returns
74
103
  */
75
- clearSelfUsage(opts?: DataOpts): any;
104
+ clearSelfUsage(opts?: DataOpts): Promise<{
105
+ code: number;
106
+ data?: any;
107
+ message?: string;
108
+ }>;
76
109
  }
77
110
 
78
111
  export { QueryApp, appDefine };
package/dist/query-ai.js CHANGED
@@ -1,4 +1,4 @@
1
- // node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query-browser.js
1
+ // node_modules/.pnpm/@kevisual+query@0.0.40/node_modules/@kevisual/query/dist/query-browser.js
2
2
  var isTextForContentType = (contentType) => {
3
3
  if (!contentType)
4
4
  return false;
@@ -27,12 +27,12 @@ var adapter = async (opts = {}, overloadOpts) => {
27
27
  url = new URL(opts.url);
28
28
  } else {
29
29
  origin = window?.location?.origin || "http://localhost:51515";
30
- url = new URL(opts.url, origin);
30
+ url = new URL(opts?.url || "", origin);
31
31
  }
32
32
  const isGet = method === "GET";
33
33
  const oldSearchParams = url.searchParams;
34
34
  if (isGet) {
35
- let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts.body });
35
+ let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts?.params, ...opts?.body });
36
36
  url.search = searchParams.toString();
37
37
  } else {
38
38
  const params = {
@@ -57,11 +57,13 @@ var adapter = async (opts = {}, overloadOpts) => {
57
57
  } else if (isPostFile) {
58
58
  body = opts.body;
59
59
  } else {
60
- headers = {
61
- "Content-Type": "application/json",
62
- ...headers
63
- };
64
- body = JSON.stringify(opts.body);
60
+ if (opts.body && typeof opts.body === "object" && !(opts.body instanceof FormData)) {
61
+ headers = {
62
+ "Content-Type": "application/json",
63
+ ...headers
64
+ };
65
+ body = JSON.stringify(opts.body);
66
+ }
65
67
  }
66
68
  return fetch(url, {
67
69
  method: method.toUpperCase(),
@@ -131,7 +133,7 @@ class Query {
131
133
  "Content-Type": "application/json"
132
134
  };
133
135
  this.timeout = opts?.timeout || 60000 * 3;
134
- if (opts.beforeRequest) {
136
+ if (opts?.beforeRequest) {
135
137
  this.beforeRequest = opts.beforeRequest;
136
138
  } else {
137
139
  this.beforeRequest = async (opts2) => {
@@ -389,7 +391,7 @@ var appDefine = QueryUtil.create({
389
391
  }
390
392
  });
391
393
 
392
- // node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query.js
394
+ // node_modules/.pnpm/@kevisual+query@0.0.40/node_modules/@kevisual/query/dist/query.js
393
395
  class BaseQuery {
394
396
  query;
395
397
  queryDefine;
@@ -1,17 +1,183 @@
1
+ import * as _kevisual_router_define from '@kevisual/router/define';
2
+ import { QueryUtil } from '@kevisual/router/define';
1
3
  import { BaseQuery, Query, DataOpts } from '@kevisual/query/query';
2
4
 
3
- declare const appDefine: any;
5
+ declare const appDefine: QueryUtil<{
6
+ getApp: {
7
+ path: string;
8
+ key: string;
9
+ description: string;
10
+ };
11
+ updateApp: {
12
+ path: string;
13
+ key: string;
14
+ description: string;
15
+ };
16
+ deleteApp: {
17
+ path: string;
18
+ key: string;
19
+ description: string;
20
+ };
21
+ listApps: {
22
+ path: string;
23
+ key: string;
24
+ description: string;
25
+ };
26
+ canUploadFiles: {
27
+ path: string;
28
+ key: string;
29
+ description: string;
30
+ };
31
+ uploadFiles: {
32
+ path: string;
33
+ key: string;
34
+ description: string;
35
+ };
36
+ publishApp: {
37
+ path: string;
38
+ key: string;
39
+ description: string;
40
+ };
41
+ getMinioList: {
42
+ path: string;
43
+ key: string;
44
+ description: string;
45
+ };
46
+ detectVersionList: {
47
+ path: string;
48
+ key: string;
49
+ description: string;
50
+ };
51
+ publicList: {
52
+ path: string;
53
+ key: string;
54
+ description: string;
55
+ };
56
+ }>;
4
57
 
5
- declare const userAppDefine: any;
58
+ declare const userAppDefine: QueryUtil<{
59
+ listUserApps: {
60
+ path: string;
61
+ key: string;
62
+ description: string;
63
+ };
64
+ getUserApp: {
65
+ path: string;
66
+ key: string;
67
+ description: string;
68
+ };
69
+ updateUserApp: {
70
+ path: string;
71
+ key: string;
72
+ description: string;
73
+ };
74
+ deleteUserApp: {
75
+ path: string;
76
+ key: string;
77
+ description: string;
78
+ };
79
+ testUserApp: {
80
+ path: string;
81
+ key: string;
82
+ description: string;
83
+ };
84
+ }>;
6
85
 
7
86
  declare class QueryApp extends BaseQuery {
8
- appDefine: any;
9
- userAppDefine: any;
87
+ appDefine: _kevisual_router_define.QueryUtil<{
88
+ getApp: {
89
+ path: string;
90
+ key: string;
91
+ description: string;
92
+ };
93
+ updateApp: {
94
+ path: string;
95
+ key: string;
96
+ description: string;
97
+ };
98
+ deleteApp: {
99
+ path: string;
100
+ key: string;
101
+ description: string;
102
+ };
103
+ listApps: {
104
+ path: string;
105
+ key: string;
106
+ description: string;
107
+ };
108
+ canUploadFiles: {
109
+ path: string;
110
+ key: string;
111
+ description: string;
112
+ };
113
+ uploadFiles: {
114
+ path: string;
115
+ key: string;
116
+ description: string;
117
+ };
118
+ publishApp: {
119
+ path: string;
120
+ key: string;
121
+ description: string;
122
+ };
123
+ getMinioList: {
124
+ path: string;
125
+ key: string;
126
+ description: string;
127
+ };
128
+ detectVersionList: {
129
+ path: string;
130
+ key: string;
131
+ description: string;
132
+ };
133
+ publicList: {
134
+ path: string;
135
+ key: string;
136
+ description: string;
137
+ };
138
+ }>;
139
+ userAppDefine: _kevisual_router_define.QueryUtil<{
140
+ listUserApps: {
141
+ path: string;
142
+ key: string;
143
+ description: string;
144
+ };
145
+ getUserApp: {
146
+ path: string;
147
+ key: string;
148
+ description: string;
149
+ };
150
+ updateUserApp: {
151
+ path: string;
152
+ key: string;
153
+ description: string;
154
+ };
155
+ deleteUserApp: {
156
+ path: string;
157
+ key: string;
158
+ description: string;
159
+ };
160
+ testUserApp: {
161
+ path: string;
162
+ key: string;
163
+ description: string;
164
+ };
165
+ }>;
10
166
  constructor(opts?: {
11
167
  query: Query;
12
168
  });
13
- getList(data: any, opts?: DataOpts): any;
14
- getPublicApp(data: any, opts?: DataOpts): any;
169
+ getList(data: any, opts?: DataOpts): Promise<{
170
+ code: number;
171
+ data?: {
172
+ [x: string]: any;
173
+ } | undefined;
174
+ message?: string;
175
+ }>;
176
+ getPublicApp(data: any, opts?: DataOpts): Promise<{
177
+ code: number;
178
+ data?: any;
179
+ message?: string;
180
+ }>;
15
181
  getApp(data: {
16
182
  key?: string;
17
183
  version?: string;
@@ -20,7 +186,11 @@ declare class QueryApp extends BaseQuery {
20
186
  * 之后上传文件就好了,会执行检测任务
21
187
  */
22
188
  create?: boolean;
23
- }, opts?: DataOpts): any;
189
+ }, opts?: DataOpts): Promise<{
190
+ code: number;
191
+ data?: any;
192
+ message?: string;
193
+ }>;
24
194
  /**
25
195
  * 发布应用
26
196
  * @param data
@@ -33,7 +203,11 @@ declare class QueryApp extends BaseQuery {
33
203
  detect?: boolean;
34
204
  appKey?: string;
35
205
  version?: string;
36
- }, opts?: DataOpts): any;
206
+ }, opts?: DataOpts): Promise<{
207
+ code: number;
208
+ data?: any;
209
+ message?: string;
210
+ }>;
37
211
  }
38
212
 
39
213
  export { QueryApp, appDefine, userAppDefine };
package/dist/query-app.js CHANGED
@@ -1,4 +1,4 @@
1
- // node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query-browser.js
1
+ // node_modules/.pnpm/@kevisual+query@0.0.40/node_modules/@kevisual/query/dist/query-browser.js
2
2
  var isTextForContentType = (contentType) => {
3
3
  if (!contentType)
4
4
  return false;
@@ -27,12 +27,12 @@ var adapter = async (opts = {}, overloadOpts) => {
27
27
  url = new URL(opts.url);
28
28
  } else {
29
29
  origin = window?.location?.origin || "http://localhost:51515";
30
- url = new URL(opts.url, origin);
30
+ url = new URL(opts?.url || "", origin);
31
31
  }
32
32
  const isGet = method === "GET";
33
33
  const oldSearchParams = url.searchParams;
34
34
  if (isGet) {
35
- let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts.body });
35
+ let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts?.params, ...opts?.body });
36
36
  url.search = searchParams.toString();
37
37
  } else {
38
38
  const params = {
@@ -57,11 +57,13 @@ var adapter = async (opts = {}, overloadOpts) => {
57
57
  } else if (isPostFile) {
58
58
  body = opts.body;
59
59
  } else {
60
- headers = {
61
- "Content-Type": "application/json",
62
- ...headers
63
- };
64
- body = JSON.stringify(opts.body);
60
+ if (opts.body && typeof opts.body === "object" && !(opts.body instanceof FormData)) {
61
+ headers = {
62
+ "Content-Type": "application/json",
63
+ ...headers
64
+ };
65
+ body = JSON.stringify(opts.body);
66
+ }
65
67
  }
66
68
  return fetch(url, {
67
69
  method: method.toUpperCase(),
@@ -131,7 +133,7 @@ class Query {
131
133
  "Content-Type": "application/json"
132
134
  };
133
135
  this.timeout = opts?.timeout || 60000 * 3;
134
- if (opts.beforeRequest) {
136
+ if (opts?.beforeRequest) {
135
137
  this.beforeRequest = opts.beforeRequest;
136
138
  } else {
137
139
  this.beforeRequest = async (opts2) => {
@@ -463,7 +465,7 @@ var userAppDefine = QueryUtil.create({
463
465
  }
464
466
  });
465
467
 
466
- // node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query.js
468
+ // node_modules/.pnpm/@kevisual+query@0.0.40/node_modules/@kevisual/query/dist/query.js
467
469
  class BaseQuery {
468
470
  query;
469
471
  queryDefine;
@@ -30,41 +30,101 @@ type DefaultConfigKey = (typeof defaultConfigKeys)[number];
30
30
  declare class QueryConfig {
31
31
  query: Query;
32
32
  constructor(opts?: QueryConfigOpts);
33
- post<T = Config>(data: any): Promise<any>;
33
+ post<T = Config>(data: any): Promise<{
34
+ code: number;
35
+ data?: T | undefined;
36
+ message?: string;
37
+ }>;
34
38
  getConfig({ id, key }: {
35
39
  id?: string;
36
40
  key?: string;
37
- }, opts?: PostOpts): Promise<any>;
38
- updateConfig(data: Config, opts?: PostOpts): Promise<any>;
41
+ }, opts?: PostOpts): Promise<{
42
+ code: number;
43
+ data?: Config<any> | undefined;
44
+ message?: string;
45
+ }>;
46
+ updateConfig(data: Config, opts?: PostOpts): Promise<{
47
+ code: number;
48
+ data?: Config<any> | undefined;
49
+ message?: string;
50
+ }>;
39
51
  deleteConfig(data: {
40
52
  id?: string;
41
53
  key?: string;
42
- }, opts?: PostOpts): Promise<any>;
43
- listConfig(opts?: PostOpts): Promise<any>;
54
+ }, opts?: PostOpts): Promise<{
55
+ code: number;
56
+ data?: Config<any> | undefined;
57
+ message?: string;
58
+ }>;
59
+ listConfig(opts?: PostOpts): Promise<{
60
+ code: number;
61
+ data?: {
62
+ list: Config[];
63
+ } | undefined;
64
+ message?: string;
65
+ }>;
44
66
  /**
45
67
  * 获取上传配置
46
68
  * @returns
47
69
  */
48
- getUploadConfig(opts?: PostOpts): Promise<any>;
70
+ getUploadConfig(opts?: PostOpts): Promise<{
71
+ code: number;
72
+ data?: {
73
+ code: number;
74
+ data?: Config<UploadConfig> | undefined;
75
+ message?: string;
76
+ } | undefined;
77
+ message?: string;
78
+ }>;
49
79
  /**
50
80
  * 更新上传配置
51
81
  * @param data
52
82
  * @returns
53
83
  */
54
- updateUploadConfig(data: Config, opts?: PostOpts): Promise<any>;
84
+ updateUploadConfig(data: Config, opts?: PostOpts): Promise<{
85
+ code: number;
86
+ data?: {
87
+ code: number;
88
+ data?: Config<UploadConfig> | undefined;
89
+ message?: string;
90
+ } | undefined;
91
+ message?: string;
92
+ }>;
55
93
  /**
56
94
  * 检测配置是否存在
57
95
  * @param id
58
96
  * @returns
59
97
  */
60
- detectConfig(opts?: PostOpts): Promise<any>;
98
+ detectConfig(opts?: PostOpts): Promise<{
99
+ code: number;
100
+ data?: {
101
+ updateList: Config[];
102
+ } | undefined;
103
+ message?: string;
104
+ }>;
61
105
  /**
62
106
  * 获取配置, 获取默认的配置项
63
107
  * @param key
64
108
  * @returns
65
109
  */
66
- getConfigByKey(key: DefaultConfigKey, opts?: PostOpts): Promise<any>;
67
- getByKey<T = any>(key: string, opts?: PostOpts): Promise<any>;
110
+ getConfigByKey(key: DefaultConfigKey, opts?: PostOpts): Promise<{
111
+ code: number;
112
+ data?: {
113
+ code: number;
114
+ data?: Config<any> | undefined;
115
+ message?: string;
116
+ } | undefined;
117
+ message?: string;
118
+ }>;
119
+ getByKey<T = any>(key: string, opts?: PostOpts): Promise<{
120
+ code: number;
121
+ data?: {
122
+ code: number;
123
+ data?: Config<T> | undefined;
124
+ message?: string;
125
+ } | undefined;
126
+ message?: string;
127
+ }>;
68
128
  }
69
129
 
70
130
  export { QueryConfig, defaultConfigKeys };
@@ -1,4 +1,4 @@
1
- // node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query-browser.js
1
+ // node_modules/.pnpm/@kevisual+query@0.0.40/node_modules/@kevisual/query/dist/query-browser.js
2
2
  var isTextForContentType = (contentType) => {
3
3
  if (!contentType)
4
4
  return false;
@@ -27,12 +27,12 @@ var adapter = async (opts = {}, overloadOpts) => {
27
27
  url = new URL(opts.url);
28
28
  } else {
29
29
  origin = window?.location?.origin || "http://localhost:51515";
30
- url = new URL(opts.url, origin);
30
+ url = new URL(opts?.url || "", origin);
31
31
  }
32
32
  const isGet = method === "GET";
33
33
  const oldSearchParams = url.searchParams;
34
34
  if (isGet) {
35
- let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts.body });
35
+ let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts?.params, ...opts?.body });
36
36
  url.search = searchParams.toString();
37
37
  } else {
38
38
  const params = {
@@ -57,11 +57,13 @@ var adapter = async (opts = {}, overloadOpts) => {
57
57
  } else if (isPostFile) {
58
58
  body = opts.body;
59
59
  } else {
60
- headers = {
61
- "Content-Type": "application/json",
62
- ...headers
63
- };
64
- body = JSON.stringify(opts.body);
60
+ if (opts.body && typeof opts.body === "object" && !(opts.body instanceof FormData)) {
61
+ headers = {
62
+ "Content-Type": "application/json",
63
+ ...headers
64
+ };
65
+ body = JSON.stringify(opts.body);
66
+ }
65
67
  }
66
68
  return fetch(url, {
67
69
  method: method.toUpperCase(),
@@ -131,7 +133,7 @@ class Query {
131
133
  "Content-Type": "application/json"
132
134
  };
133
135
  this.timeout = opts?.timeout || 60000 * 3;
134
- if (opts.beforeRequest) {
136
+ if (opts?.beforeRequest) {
135
137
  this.beforeRequest = opts.beforeRequest;
136
138
  } else {
137
139
  this.beforeRequest = async (opts2) => {
@@ -33,6 +33,8 @@ type CacheLoginUser = {
33
33
  id?: string;
34
34
  accessToken?: string;
35
35
  refreshToken?: string;
36
+ accessTokenExpiresIn?: number;
37
+ createdAt?: number;
36
38
  };
37
39
  type CacheLogin = {
38
40
  loginUsers: CacheLoginUser[];
@@ -133,6 +135,7 @@ declare class QueryLogin extends BaseQuery {
133
135
  setLoginToken(token: {
134
136
  accessToken: string;
135
137
  refreshToken: string;
138
+ accessTokenExpiresIn?: number;
136
139
  }): Promise<void>;
137
140
  loginByWechat(data: {
138
141
  code: string;
@@ -149,7 +152,8 @@ declare class QueryLogin extends BaseQuery {
149
152
  * 登陆成功,需要获取用户信息进行缓存
150
153
  * @param param0
151
154
  */
152
- beforeSetLoginUser({ accessToken, refreshToken, check401 }: {
155
+ beforeSetLoginUser({ accessToken, refreshToken, check401, accessTokenExpiresIn }: {
156
+ accessTokenExpiresIn?: number;
153
157
  accessToken?: string;
154
158
  refreshToken?: string;
155
159
  check401?: boolean;
@@ -218,7 +222,7 @@ declare class QueryLogin extends BaseQuery {
218
222
  orgs?: string[];
219
223
  type?: string;
220
224
  username?: string;
221
- }>;
225
+ } | null>;
222
226
  /**
223
227
  * 检查本地token是否存在,简单的判断是否已经属于登陆状态
224
228
  * @returns
@@ -264,7 +268,7 @@ declare class QueryLogin extends BaseQuery {
264
268
  *
265
269
  *
266
270
 
267
- import MD5 from 'crypto-js/md5.js';
271
+ // import MD5 from 'crypto-js/md5.js';
268
272
  import jsonwebtoken from 'jsonwebtoken';
269
273
 
270
274
  */