Files
query/test/examples.ts

55 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { createQueryApi } from '@kevisual/query/api';
const api = {
"app_domain_manager": {
/**
* 获取域名信息可以通过id或者domain进行查询
*
* @param data - Request parameters
* @param data.data - {object}
*/
"get": {
"path": "app_domain_manager",
"key": "get",
"description": "获取域名信息可以通过id或者domain进行查询",
"metadata": {
"args": {
"data": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"domain": {
"type": "string"
}
},
"additionalProperties": false,
"required": ["id", "domain"]
}
},
"viewItem": {
"api": {
"url": "/api/router"
},
"type": "api",
"title": "路由"
},
"url": "/api/router",
"source": "query-proxy-api"
}
}
}
} as const;
const queryApi = createQueryApi({ api });
export { queryApi };
const result = await queryApi.app_domain_manager.get<{ id: number }>({
data: {
id: '123',
domain: 'example.com'
}
});
result.data.id; // TypeScript 正确推断为 number