@kevisual/query 0.0.52 → 0.0.54
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-api.d.ts +2 -0
- package/dist/query-api.js +19183 -363
- package/dist/query-browser.js +1 -1
- package/dist/query-ws.js +1 -1
- package/package.json +5 -5
- package/src/create-query/index.ts +14 -0
package/dist/query-browser.js
CHANGED
|
@@ -109,7 +109,7 @@ var adapter = async (opts = {}, overloadOpts) => {
|
|
|
109
109
|
});
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
// node_modules/.pnpm/zustand@5.0.
|
|
112
|
+
// ../../node_modules/.pnpm/zustand@5.0.12_@types+react@19.2.14_react@19.2.4_use-sync-external-store@1.6.0_react@19.2.4_/node_modules/zustand/esm/vanilla.mjs
|
|
113
113
|
var createStoreImpl = (createState) => {
|
|
114
114
|
let state;
|
|
115
115
|
const listeners = /* @__PURE__ */ new Set;
|
package/dist/query-ws.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/zustand@5.0.
|
|
1
|
+
// ../../node_modules/.pnpm/zustand@5.0.12_@types+react@19.2.14_react@19.2.4_use-sync-external-store@1.6.0_react@19.2.4_/node_modules/zustand/esm/vanilla.mjs
|
|
2
2
|
var createStoreImpl = (createState) => {
|
|
3
3
|
let state;
|
|
4
4
|
const listeners = /* @__PURE__ */ new Set;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/query",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.54",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run clean && bun run bun.config.ts",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"description": "",
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@kevisual/code-builder": "^0.0.6",
|
|
22
|
-
"@kevisual/router": "^0.
|
|
23
|
-
"@types/node": "^25.
|
|
22
|
+
"@kevisual/router": "^0.1.6",
|
|
23
|
+
"@types/node": "^25.5.0",
|
|
24
24
|
"typescript": "^5.9.3",
|
|
25
|
-
"es-toolkit": "^1.
|
|
25
|
+
"es-toolkit": "^1.45.1",
|
|
26
26
|
"zod": "^4.3.6",
|
|
27
|
-
"zustand": "^5.0.
|
|
27
|
+
"zustand": "^5.0.12"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
@@ -8,6 +8,7 @@ type RouteInfo = {
|
|
|
8
8
|
metadata?: {
|
|
9
9
|
summary?: string;
|
|
10
10
|
args?: Record<string, any>;
|
|
11
|
+
returns?: Record<string, any>;
|
|
11
12
|
viewItem?: {
|
|
12
13
|
type?: string;
|
|
13
14
|
api?: {
|
|
@@ -46,12 +47,17 @@ const removeViewItemCotnextFromRoutes = (list: RouteInfo[], options?: CreateQuer
|
|
|
46
47
|
}
|
|
47
48
|
type CreateQueryOptions = {
|
|
48
49
|
removeViewItem?: boolean,
|
|
50
|
+
removeId?: boolean,
|
|
49
51
|
before?: string,
|
|
50
52
|
after?: string,
|
|
51
53
|
}
|
|
52
54
|
export const createQueryByRoutes = (list: RouteInfo[], options?: CreateQueryOptions) => {
|
|
53
55
|
const obj: any = {};
|
|
54
56
|
list = removeViewItemCotnextFromRoutes(list, options);
|
|
57
|
+
list = options?.removeId ? list.map(route => {
|
|
58
|
+
const { id, ...rest } = route;
|
|
59
|
+
return rest as RouteInfo;
|
|
60
|
+
}) : list;
|
|
55
61
|
for (const route of list) {
|
|
56
62
|
if (!obj[route.path]) {
|
|
57
63
|
obj[route.path] = {};
|
|
@@ -64,6 +70,14 @@ export const createQueryByRoutes = (list: RouteInfo[], options?: CreateQueryOpti
|
|
|
64
70
|
route.metadata.args = toJSONSchema(jsonSchema);
|
|
65
71
|
}
|
|
66
72
|
}
|
|
73
|
+
if (route.metadata?.returns) {
|
|
74
|
+
const returns = route.metadata.returns;
|
|
75
|
+
if (returns?.$schema) {
|
|
76
|
+
// 将 returns 转换为 JSON Schema
|
|
77
|
+
const jsonSchema = fromJSONSchema(returns);
|
|
78
|
+
route.metadata.returns = toJSONSchema(jsonSchema);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
67
81
|
obj[route.path][route.key] = route;
|
|
68
82
|
}
|
|
69
83
|
const before = options?.before || `import { createQueryApi } from '@kevisual/query/api';`;
|