@kevisual/api 0.0.49 → 0.0.51
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.
- package/dist/query-proxy.d.ts +14 -10
- package/dist/query-proxy.js +15 -1
- package/dist/utils-node.d.ts +36 -0
- package/dist/utils-node.js +1871 -0
- package/dist/utils.d.ts +4 -1
- package/dist/utils.js +1807 -4
- package/package.json +4 -2
- package/query/query-proxy/proxy.ts +25 -9
- package/query/query-proxy/router-api-proxy.ts +1 -0
- package/query/utils/random.ts +5 -2
package/dist/query-proxy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QueryClient
|
|
1
|
+
import { QueryClient } from '@kevisual/query';
|
|
2
2
|
import { QueryRouterServer, Route } from '@kevisual/router/browser';
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { QueryRouterServer as QueryRouterServer$1, App } from '@kevisual/router';
|
|
@@ -60,7 +60,7 @@ type RouterViewWorker = {
|
|
|
60
60
|
};
|
|
61
61
|
} & RouteViewBase;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* 去掉不需要保存的服务器的数据
|
|
64
64
|
* @param item
|
|
65
65
|
* @returns
|
|
66
66
|
*/
|
|
@@ -113,7 +113,7 @@ declare const pickRouterViewData: (item: RouterViewItem) => {
|
|
|
113
113
|
enabled?: boolean;
|
|
114
114
|
};
|
|
115
115
|
/**
|
|
116
|
-
* 注入 js 的url地址,使用importScripts加载
|
|
116
|
+
* 注入 js 的url地址,使用 importScripts 加载
|
|
117
117
|
*/
|
|
118
118
|
type RouteViewPage = {
|
|
119
119
|
type: 'page';
|
|
@@ -126,6 +126,9 @@ type RouterViewQuery = {
|
|
|
126
126
|
query: string;
|
|
127
127
|
title: string;
|
|
128
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* 后端存储结构
|
|
131
|
+
*/
|
|
129
132
|
type RouterViewData = {
|
|
130
133
|
data: {
|
|
131
134
|
items: RouterViewItem[];
|
|
@@ -145,9 +148,9 @@ declare class QueryProxy {
|
|
|
145
148
|
token?: string;
|
|
146
149
|
routerViewData?: RouterViewData;
|
|
147
150
|
});
|
|
148
|
-
getDefulatToken
|
|
151
|
+
private getDefulatToken;
|
|
149
152
|
initRouterViewQuery(): void;
|
|
150
|
-
initRouterView
|
|
153
|
+
private initRouterView;
|
|
151
154
|
/**
|
|
152
155
|
* 初始化路由
|
|
153
156
|
* main
|
|
@@ -162,10 +165,10 @@ declare class QueryProxy {
|
|
|
162
165
|
initApi(item?: RouterViewApi): Promise<void>;
|
|
163
166
|
initContext(item?: RouterViewContext): Promise<void>;
|
|
164
167
|
generateId(): string;
|
|
165
|
-
callWorker
|
|
166
|
-
initWorker
|
|
167
|
-
initPage
|
|
168
|
-
getQueryByViewId
|
|
168
|
+
private callWorker;
|
|
169
|
+
private initWorker;
|
|
170
|
+
private initPage;
|
|
171
|
+
private getQueryByViewId;
|
|
169
172
|
/**
|
|
170
173
|
* 列出路由
|
|
171
174
|
* @param filter
|
|
@@ -197,6 +200,7 @@ type RouterItem = {
|
|
|
197
200
|
middleware?: string[];
|
|
198
201
|
metadata?: Record<string, any>;
|
|
199
202
|
};
|
|
203
|
+
declare const createViewData: (routerViewData: RouterViewItem | RouterViewItem[], data?: RouterViewData) => RouterViewData;
|
|
200
204
|
|
|
201
205
|
declare const initApi: (opts: {
|
|
202
206
|
item?: RouterViewApi;
|
|
@@ -211,5 +215,5 @@ declare const initApi: (opts: {
|
|
|
211
215
|
message: string;
|
|
212
216
|
}>;
|
|
213
217
|
|
|
214
|
-
export { QueryProxy, RouteTypeList, initApi, pickRouterViewData };
|
|
218
|
+
export { QueryProxy, RouteTypeList, createViewData, initApi, pickRouterViewData };
|
|
215
219
|
export type { RouteViewPage, RouterItem, RouterViewApi, RouterViewContext, RouterViewData, RouterViewItem, RouterViewItemInfo, RouterViewQuery, RouterViewWorker };
|
package/dist/query-proxy.js
CHANGED
|
@@ -8839,6 +8839,7 @@ var initApi = async (opts) => {
|
|
|
8839
8839
|
let metadata = r.metadata || {};
|
|
8840
8840
|
metadata.viewItem = item;
|
|
8841
8841
|
metadata.url = query.url;
|
|
8842
|
+
metadata.source = "query-proxy-api";
|
|
8842
8843
|
router.route({
|
|
8843
8844
|
path: r.path,
|
|
8844
8845
|
key: r.key || "",
|
|
@@ -10307,6 +10308,7 @@ class QueryProxy {
|
|
|
10307
10308
|
console.debug(`注册路由: [${r.path}] ${r?.key}`, "Context");
|
|
10308
10309
|
let metadata = r.metadata || {};
|
|
10309
10310
|
metadata.viewItem = item;
|
|
10311
|
+
metadata.source = "query-proxy-context";
|
|
10310
10312
|
this.router.route({
|
|
10311
10313
|
path: r.path,
|
|
10312
10314
|
key: r.key || "",
|
|
@@ -10399,6 +10401,7 @@ class QueryProxy {
|
|
|
10399
10401
|
console.debug(`注册路由: [${r.path}] ${r?.key}`, "API");
|
|
10400
10402
|
let metadata = r.metadata || {};
|
|
10401
10403
|
metadata.viewItem = item;
|
|
10404
|
+
metadata.source = "query-proxy-worker";
|
|
10402
10405
|
this.router.route({
|
|
10403
10406
|
path: r.path,
|
|
10404
10407
|
key: r.key || "",
|
|
@@ -10504,13 +10507,24 @@ class QueryProxy {
|
|
|
10504
10507
|
item.response = res;
|
|
10505
10508
|
return item;
|
|
10506
10509
|
}
|
|
10507
|
-
item.response = { code: 500, message: "无法处理的路由类型" };
|
|
10510
|
+
item.response = { code: 500, message: "无法处理的路由类型", data: item };
|
|
10508
10511
|
return item;
|
|
10509
10512
|
}
|
|
10510
10513
|
}
|
|
10514
|
+
var createViewData = (routerViewData, data) => {
|
|
10515
|
+
return {
|
|
10516
|
+
views: [],
|
|
10517
|
+
viewId: undefined,
|
|
10518
|
+
data: {
|
|
10519
|
+
items: Array.isArray(routerViewData) ? routerViewData : [routerViewData]
|
|
10520
|
+
},
|
|
10521
|
+
...data
|
|
10522
|
+
};
|
|
10523
|
+
};
|
|
10511
10524
|
export {
|
|
10512
10525
|
pickRouterViewData,
|
|
10513
10526
|
initApi,
|
|
10527
|
+
createViewData,
|
|
10514
10528
|
RouteTypeList,
|
|
10515
10529
|
QueryProxy
|
|
10516
10530
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createId } from '@paralleldrive/cuid2';
|
|
2
|
+
|
|
3
|
+
declare const letter = "abcdefghijklmnopqrstuvwxyz";
|
|
4
|
+
declare const number = "0123456789";
|
|
5
|
+
declare const alphanumericWithDash = "abcdefghijklmnopqrstuvwxyz0123456789-";
|
|
6
|
+
declare const cuid2: typeof createId;
|
|
7
|
+
/**
|
|
8
|
+
* 创建一个随机的字母字符串
|
|
9
|
+
*/
|
|
10
|
+
declare const uuid: (size?: number) => string;
|
|
11
|
+
/**
|
|
12
|
+
* 创建一个随机的 id,包含字母和数字
|
|
13
|
+
*/
|
|
14
|
+
declare const nanoid: (size?: number) => string;
|
|
15
|
+
/**
|
|
16
|
+
* 创建一个随机的 id,包含字母、数字和短横线
|
|
17
|
+
*/
|
|
18
|
+
declare const nanoidWithDash: (size?: number) => string;
|
|
19
|
+
/**
|
|
20
|
+
* 创建一个随机的 id,以字母开头的字符串
|
|
21
|
+
* @param number
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
declare const randomId: (number: number) => string;
|
|
25
|
+
/**
|
|
26
|
+
* 创建一个随机的字母字符串
|
|
27
|
+
* @param number
|
|
28
|
+
* @param opts
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
declare const randomLetter: (number?: number, opts?: {
|
|
32
|
+
before?: string;
|
|
33
|
+
after?: string;
|
|
34
|
+
}) => string;
|
|
35
|
+
|
|
36
|
+
export { alphanumericWithDash, cuid2, letter, nanoid, nanoidWithDash, number, randomId, randomLetter, uuid };
|