web-core-tcm 0.0.2 → 0.0.7
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/package.json +15 -2
- package/src/coreApi/api/algorithm/comprehensiveAlgorithm.ts +20 -0
- package/src/coreApi/api/algorithm/index.ts +44 -0
- package/src/coreApi/api/algorithm/inquiriesAlgorithm.ts +19 -0
- package/src/coreApi/api/algorithm/inspectionsAlgorithm.ts +11 -0
- package/src/coreApi/api/algorithm/lisemsAlgorithm.ts +16 -0
- package/src/coreApi/api/algorithm/pulsationsAlgorithm.ts +9 -0
- package/src/coreApi/api/authorization/alova/apiDefinitions.ts +23 -0
- package/src/coreApi/api/authorization/alova/createApis.ts +99 -0
- package/src/coreApi/api/authorization/alova/globals.d.ts +373 -0
- package/src/coreApi/api/authorization/alova/implement/authorization.ts +12 -0
- package/src/coreApi/api/authorization/alova/index.ts +21 -0
- package/src/coreApi/api/authorization/authorization.ts +16 -0
- package/src/coreApi/api/check/alova/apiDefinitions.ts +30 -0
- package/src/coreApi/api/check/alova/createApis.ts +99 -0
- package/src/coreApi/api/check/alova/globals.d.ts +1248 -0
- package/src/coreApi/api/check/alova/implement/check.ts +119 -0
- package/src/coreApi/api/check/alova/index.ts +21 -0
- package/src/coreApi/api/check/check.ts +164 -0
- package/src/coreApi/api/config/alova/index.ts +72 -0
- package/src/coreApi/api/config/index.ts +128 -0
- package/src/coreApi/api/device/device.js +58 -0
- package/src/coreApi/api/doctor/alova/apiDefinitions.ts +28 -0
- package/src/coreApi/api/doctor/alova/createApis.ts +99 -0
- package/src/coreApi/api/doctor/alova/globals.d.ts +550 -0
- package/src/coreApi/api/doctor/alova/implement/doctor.ts +37 -0
- package/src/coreApi/api/doctor/alova/index.ts +21 -0
- package/src/coreApi/api/doctor/doctor.ts +53 -0
- package/src/coreApi/api/metric/implement/metric.ts +98 -0
- package/src/coreApi/api/metric/metric.ts +114 -0
- package/src/coreApi/api/oauth/alova/apiDefinitions.ts +26 -0
- package/src/coreApi/api/oauth/alova/createApis.ts +99 -0
- package/src/coreApi/api/oauth/alova/globals.d.ts +451 -0
- package/src/coreApi/api/oauth/alova/implement/oauth.ts +19 -0
- package/src/coreApi/api/oauth/alova/index.ts +20 -0
- package/src/coreApi/api/oauth/oauth.ts +15 -0
- package/src/coreApi/api/outpatient/alova/apiDefinitions.ts +27 -0
- package/src/coreApi/api/outpatient/alova/createApis.ts +99 -0
- package/src/coreApi/api/outpatient/alova/globals.d.ts +676 -0
- package/src/coreApi/api/outpatient/alova/implement/outpatient.ts +66 -0
- package/src/coreApi/api/outpatient/alova/index.ts +21 -0
- package/src/coreApi/api/outpatient/outpatient.ts +62 -0
- package/src/coreApi/api/patient/alova/apiDefinitions.ts +41 -0
- package/src/coreApi/api/patient/alova/createApis.ts +99 -0
- package/src/coreApi/api/patient/alova/globals.d.ts +1677 -0
- package/src/coreApi/api/patient/alova/implement/meta.ts +488 -0
- package/src/coreApi/api/patient/alova/implement/patient.ts +77 -0
- package/src/coreApi/api/patient/alova/index.ts +21 -0
- package/src/coreApi/api/patient/core.ts +131 -0
- package/src/coreApi/api/patient/meta.ts +466 -0
- package/src/coreApi/api/patient/patient.ts +98 -0
- package/src/coreApi/api/prescription/alova/apiDefinitions.ts +29 -0
- package/src/coreApi/api/prescription/alova/createApis.ts +99 -0
- package/src/coreApi/api/prescription/alova/globals.d.ts +959 -0
- package/src/coreApi/api/prescription/alova/implement/herbal.ts +48 -0
- package/src/coreApi/api/prescription/alova/implement/prescription.ts +45 -0
- package/src/coreApi/api/prescription/alova/index.ts +21 -0
- package/src/coreApi/api/prescription/herbal.ts +44 -0
- package/src/coreApi/api/prescription/prescription.ts +68 -0
- package/src/coreApi/api/scientist/alova/apiDefinitions.ts +27 -0
- package/src/coreApi/api/scientist/alova/createApis.ts +99 -0
- package/src/coreApi/api/scientist/alova/globals.d.ts +438 -0
- package/src/coreApi/api/scientist/alova/implement/scientist.ts +29 -0
- package/src/coreApi/api/scientist/alova/index.ts +21 -0
- package/src/coreApi/api/scientist/scientist.ts +49 -0
- package/src/api/test/test.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-core-tcm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Core",
|
|
5
5
|
"productName": "Core",
|
|
6
6
|
"author": "wywywywywywywywywy <qa123456_0714@qq.com>",
|
|
@@ -40,5 +40,18 @@
|
|
|
40
40
|
"node": "^28 || ^26 || ^24 || ^22 || ^20",
|
|
41
41
|
"npm": ">= 6.13.4",
|
|
42
42
|
"yarn": ">= 1.21.1"
|
|
43
|
-
}
|
|
43
|
+
},
|
|
44
|
+
"main": "eslint.config.js",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/NUC-TCM/web.core.tcm.git"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"前端核心工具包"
|
|
51
|
+
],
|
|
52
|
+
"license": "ISC",
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/NUC-TCM/web.core.tcm/issues"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://github.com/NUC-TCM/web.core.tcm#readme"
|
|
44
57
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/api/comprehensiveAlgorithm.ts
|
|
2
|
+
import { comprehensiveAlgorithmService } from 'src/api/algorithm';
|
|
3
|
+
|
|
4
|
+
export const comprehensiveQwenAlgorithm = (data: object) =>
|
|
5
|
+
comprehensiveAlgorithmService.Post<Response>('/千问大模型分析', data, {
|
|
6
|
+
timeout: 30000,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const comprehensiveDeepSeekV3Algorithm = (data: object) =>
|
|
10
|
+
comprehensiveAlgorithmService.Post<Response>('/DeepSeekV3大模型分析', data, {
|
|
11
|
+
timeout: 30000,
|
|
12
|
+
});
|
|
13
|
+
export const comprehensiveDeepSeekR1Algorithm = (data: object) =>
|
|
14
|
+
comprehensiveAlgorithmService.Post<Response>('/DeepSeekR1大模型分析', data, {
|
|
15
|
+
timeout: 300000,
|
|
16
|
+
});
|
|
17
|
+
export const doctorSceneTextAnalysis = (data: object) =>
|
|
18
|
+
comprehensiveAlgorithmService.Post<Response>('/医生场景文本', data, {
|
|
19
|
+
timeout: 300000,
|
|
20
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createAlova } from 'alova';
|
|
2
|
+
import adapterFetch from 'alova/fetch';
|
|
3
|
+
import { responded } from 'src/api/config/alova';
|
|
4
|
+
import { getServiceEndpoint, ServiceType } from 'src/api/config';
|
|
5
|
+
|
|
6
|
+
export const inspectionAlgorithmService = createAlova({
|
|
7
|
+
baseURL: getServiceEndpoint(ServiceType.InspectionsAlgorithm),
|
|
8
|
+
timeout: 30000,
|
|
9
|
+
cacheFor: null,
|
|
10
|
+
requestAdapter: adapterFetch(),
|
|
11
|
+
responded: responded
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const inquiriesAlgorithmService = createAlova({
|
|
15
|
+
baseURL: getServiceEndpoint(ServiceType.InquiriesAlgorithm),
|
|
16
|
+
timeout: 30000,
|
|
17
|
+
cacheFor: null,
|
|
18
|
+
requestAdapter: adapterFetch(),
|
|
19
|
+
responded: responded
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const lisemsAlgorithmService = createAlova({
|
|
23
|
+
baseURL: getServiceEndpoint(ServiceType.LisemsAlgorithm),
|
|
24
|
+
timeout: 30000,
|
|
25
|
+
cacheFor: null,
|
|
26
|
+
requestAdapter: adapterFetch(),
|
|
27
|
+
responded: responded
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const pulsationsAlgorithmService = createAlova({
|
|
31
|
+
baseURL: getServiceEndpoint(ServiceType.PulsationsAlgorithm),
|
|
32
|
+
timeout: 30000,
|
|
33
|
+
cacheFor: null,
|
|
34
|
+
requestAdapter: adapterFetch(),
|
|
35
|
+
responded: responded
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const comprehensiveAlgorithmService = createAlova({
|
|
39
|
+
baseURL: getServiceEndpoint(ServiceType.ComprehensiveAlgorithm),
|
|
40
|
+
timeout: 30000,
|
|
41
|
+
cacheFor: null,
|
|
42
|
+
requestAdapter: adapterFetch(),
|
|
43
|
+
responded: responded
|
|
44
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { inquiriesAlgorithmService } from 'src/api/algorithm';
|
|
2
|
+
|
|
3
|
+
export const complaintsRecognition = (symptomDescription: string) =>
|
|
4
|
+
inquiriesAlgorithmService.Post<string[]>(
|
|
5
|
+
'/主诉/识别',
|
|
6
|
+
{ symptomDescription },
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export const complaintsDialog = (body: object) =>
|
|
10
|
+
inquiriesAlgorithmService.Post<{ reply: string; positive_symptom: string[] }>('/主诉/对话', body);
|
|
11
|
+
|
|
12
|
+
export const complaintsView = (params: string) =>
|
|
13
|
+
inquiriesAlgorithmService.Post<{ symptoms: string[] }>('/主诉/视图', {params});
|
|
14
|
+
|
|
15
|
+
export const complaintsSearch = (data: string) =>
|
|
16
|
+
inquiriesAlgorithmService.Post<string[]>('/主诉/搜索', {data});
|
|
17
|
+
|
|
18
|
+
export const complaintsChoose = (body: object) =>
|
|
19
|
+
inquiriesAlgorithmService.Post<{ status: string; data: [] }>('/主诉/选择', body);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { inspectionAlgorithmService } from 'src/api/algorithm';
|
|
2
|
+
|
|
3
|
+
export const tongueAnalyze = (images: FormData) =>
|
|
4
|
+
inspectionAlgorithmService.Post<JSON>('/舌象', images, {
|
|
5
|
+
timeout: 30000,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const faceAnalyze = (images: FormData) =>
|
|
9
|
+
inspectionAlgorithmService.Post<JSON>('/面象', images, {
|
|
10
|
+
timeout: 30000,
|
|
11
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { lisemsAlgorithmService } from 'src/api/algorithm';
|
|
2
|
+
|
|
3
|
+
export const analysisLisems = (body: object) =>
|
|
4
|
+
lisemsAlgorithmService.Post<JSON,Response>('/特征参数', body, {
|
|
5
|
+
transform(data) {
|
|
6
|
+
return data.json() as Promise<JSON>;
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const getFrequencyDomainDiagram = (body: number[]) =>
|
|
11
|
+
lisemsAlgorithmService.Post<string,Response>('/频域图', JSON.stringify(body), {
|
|
12
|
+
async transform(res) {
|
|
13
|
+
const blob = await res.blob();
|
|
14
|
+
return URL.createObjectURL(blob);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { pulsationsAlgorithmService } from 'src/api/algorithm';
|
|
2
|
+
|
|
3
|
+
export const pulsationPreprocessing = (pulsation: object) =>
|
|
4
|
+
pulsationsAlgorithmService.Post<{ [key: string]: number[] }>('/预处理', pulsation, {
|
|
5
|
+
});
|
|
6
|
+
export const pulsationAnalysis = (pulsation: object) =>
|
|
7
|
+
pulsationsAlgorithmService.Post<JSON>('/特征参数', pulsation, {
|
|
8
|
+
timeout: 30000,
|
|
9
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types='./globals.d.ts' />
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* OpenAPI definition - version v0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* OpenAPI version: 3.1.0
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* NOTE: This file is auto generated by the alova's vscode plugin.
|
|
13
|
+
*
|
|
14
|
+
* https://alova.js.org/devtools/vscode
|
|
15
|
+
*
|
|
16
|
+
* **Do not edit the file manually.**
|
|
17
|
+
*/
|
|
18
|
+
export default {
|
|
19
|
+
'oAuthRestful.getToken': ['POST', '/授权/服务/令牌'],
|
|
20
|
+
'resourceAuthorizationRestful.getResourceAuthorizationState': ['GET', '/授权/服务/资源/{id}'],
|
|
21
|
+
'roleAuthorizationRestful.getRoleAuthorizationState': ['GET', '/授权/服务/角色/{role}'],
|
|
22
|
+
'userAuthorizationRestful.getUserAuthorizationState': ['GET', '/授权/服务/用户/{userId}']
|
|
23
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* OpenAPI definition - version v0
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* OpenAPI version: 3.1.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This file is auto generated by the alova's vscode plugin.
|
|
12
|
+
*
|
|
13
|
+
* https://alova.js.org/devtools/vscode
|
|
14
|
+
*
|
|
15
|
+
* **Do not edit the file manually.**
|
|
16
|
+
*/
|
|
17
|
+
import type { Alova, MethodType, AlovaGenerics, AlovaMethodCreateConfig } from 'alova';
|
|
18
|
+
import { Method } from 'alova';
|
|
19
|
+
import apiDefinitions from './apiDefinitions';
|
|
20
|
+
|
|
21
|
+
const cache = Object.create(null);
|
|
22
|
+
const createFunctionalProxy = (array: (string | symbol)[], alovaInstance: Alova<AlovaGenerics>, configMap: any) => {
|
|
23
|
+
const apiPathKey = array.join('.') as keyof typeof apiDefinitions;
|
|
24
|
+
if (cache[apiPathKey]) {
|
|
25
|
+
return cache[apiPathKey];
|
|
26
|
+
}
|
|
27
|
+
// create a new proxy instance
|
|
28
|
+
const proxy = new Proxy(function () {}, {
|
|
29
|
+
get(_, property) {
|
|
30
|
+
// record the target property, so that it can get the completed accessing paths
|
|
31
|
+
const newArray = [...array, property];
|
|
32
|
+
// always return a new proxy to continue recording accessing paths.
|
|
33
|
+
return createFunctionalProxy(newArray, alovaInstance, configMap);
|
|
34
|
+
},
|
|
35
|
+
apply(_, __, [config]) {
|
|
36
|
+
const apiItem = apiDefinitions[apiPathKey];
|
|
37
|
+
if (!apiItem) {
|
|
38
|
+
throw new Error(`the api path of \`${apiPathKey}\` is not found`);
|
|
39
|
+
}
|
|
40
|
+
const mergedConfig = {
|
|
41
|
+
...configMap[apiPathKey],
|
|
42
|
+
...config
|
|
43
|
+
};
|
|
44
|
+
const [method, url] = apiItem;
|
|
45
|
+
const pathParams = mergedConfig.pathParams;
|
|
46
|
+
const urlReplaced = url!.replace(/\{([^}]+)\}/g, (_, key) => {
|
|
47
|
+
const pathParam = pathParams[key];
|
|
48
|
+
return pathParam;
|
|
49
|
+
});
|
|
50
|
+
delete mergedConfig.pathParams;
|
|
51
|
+
let data = mergedConfig.data;
|
|
52
|
+
if (Object.prototype.toString.call(data) === '[object Object]' && typeof FormData !== 'undefined') {
|
|
53
|
+
let hasBlobData = false;
|
|
54
|
+
const formData = new FormData();
|
|
55
|
+
for (const key in data) {
|
|
56
|
+
formData.append(key, data[key]);
|
|
57
|
+
if (data[key] instanceof Blob) {
|
|
58
|
+
hasBlobData = true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
data = hasBlobData ? formData : data;
|
|
62
|
+
}
|
|
63
|
+
return new Method(method!.toUpperCase() as MethodType, alovaInstance, urlReplaced, mergedConfig, data);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
cache[apiPathKey] = proxy;
|
|
67
|
+
return proxy;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const createApis = (alovaInstance: Alova<AlovaGenerics>, configMap: any) => {
|
|
71
|
+
const Apis = new Proxy({} as authorizeApi, {
|
|
72
|
+
get(_, property) {
|
|
73
|
+
return createFunctionalProxy([property], alovaInstance, configMap);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return Apis;
|
|
77
|
+
};
|
|
78
|
+
export const mountApis = (Apis: authorizeApi) => {
|
|
79
|
+
// define global variable `Apis`
|
|
80
|
+
(globalThis as any).authorizeApi = Apis;
|
|
81
|
+
};
|
|
82
|
+
type MethodConfig<T> = AlovaMethodCreateConfig<
|
|
83
|
+
(typeof import('./index'))['alovaInstance'] extends Alova<infer AG> ? AG : any,
|
|
84
|
+
any,
|
|
85
|
+
T
|
|
86
|
+
>;
|
|
87
|
+
type APISofParameters<Tag extends string, Url extends string> = Tag extends keyof authorizeApi
|
|
88
|
+
? Url extends keyof authorizeApi[Tag]
|
|
89
|
+
? authorizeApi[Tag][Url] extends (...args: any) => any
|
|
90
|
+
? Parameters<authorizeApi[Tag][Url]>
|
|
91
|
+
: any
|
|
92
|
+
: any
|
|
93
|
+
: any;
|
|
94
|
+
type MethodsConfigMap = {
|
|
95
|
+
[P in keyof typeof import('./apiDefinitions').default]?: MethodConfig<
|
|
96
|
+
P extends `${infer Tag}.${infer Url}` ? Parameters<NonNullable<APISofParameters<Tag, Url>[0]>['transform']>[0] : any
|
|
97
|
+
>;
|
|
98
|
+
};
|
|
99
|
+
export const withConfigType = <Config extends MethodsConfigMap>(config: Config) => config;
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* OpenAPI definition - version v0
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* OpenAPI version: 3.1.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This file is auto generated by the alova's vscode plugin.
|
|
12
|
+
*
|
|
13
|
+
* https://alova.js.org/devtools/vscode
|
|
14
|
+
*
|
|
15
|
+
* **Do not edit the file manually.**
|
|
16
|
+
*/
|
|
17
|
+
import type { Alova, AlovaMethodCreateConfig, AlovaGenerics, Method } from 'alova';
|
|
18
|
+
import type { $$userConfigMap, alovaInstance } from './index';
|
|
19
|
+
import type apiDefinitions from './apiDefinitions';
|
|
20
|
+
|
|
21
|
+
type CollapsedAlova = typeof alovaInstance;
|
|
22
|
+
type UserMethodConfigMap = typeof $$userConfigMap;
|
|
23
|
+
|
|
24
|
+
type Alova2MethodConfig<Responded> =
|
|
25
|
+
CollapsedAlova extends Alova<
|
|
26
|
+
AlovaGenerics<
|
|
27
|
+
any,
|
|
28
|
+
any,
|
|
29
|
+
infer RequestConfig,
|
|
30
|
+
infer Response,
|
|
31
|
+
infer ResponseHeader,
|
|
32
|
+
infer L1Cache,
|
|
33
|
+
infer L2Cache,
|
|
34
|
+
infer SE
|
|
35
|
+
>
|
|
36
|
+
>
|
|
37
|
+
? Omit<
|
|
38
|
+
AlovaMethodCreateConfig<
|
|
39
|
+
AlovaGenerics<Responded, any, RequestConfig, Response, ResponseHeader, L1Cache, L2Cache, SE>,
|
|
40
|
+
any,
|
|
41
|
+
Responded
|
|
42
|
+
>,
|
|
43
|
+
'params'
|
|
44
|
+
>
|
|
45
|
+
: never;
|
|
46
|
+
|
|
47
|
+
// Extract the return type of transform function that define in $$userConfigMap, if it not exists, use the default type.
|
|
48
|
+
type ExtractUserDefinedTransformed<
|
|
49
|
+
DefinitionKey extends keyof typeof apiDefinitions,
|
|
50
|
+
Default
|
|
51
|
+
> = DefinitionKey extends keyof UserMethodConfigMap
|
|
52
|
+
? UserMethodConfigMap[DefinitionKey]['transform'] extends (...args: any[]) => any
|
|
53
|
+
? Awaited<ReturnType<UserMethodConfigMap[DefinitionKey]['transform']>>
|
|
54
|
+
: Default
|
|
55
|
+
: Default;
|
|
56
|
+
type Alova2Method<
|
|
57
|
+
Responded,
|
|
58
|
+
DefinitionKey extends keyof typeof apiDefinitions,
|
|
59
|
+
CurrentConfig extends Alova2MethodConfig<any>
|
|
60
|
+
> =
|
|
61
|
+
CollapsedAlova extends Alova<
|
|
62
|
+
AlovaGenerics<
|
|
63
|
+
any,
|
|
64
|
+
any,
|
|
65
|
+
infer RequestConfig,
|
|
66
|
+
infer Response,
|
|
67
|
+
infer ResponseHeader,
|
|
68
|
+
infer L1Cache,
|
|
69
|
+
infer L2Cache,
|
|
70
|
+
infer SE
|
|
71
|
+
>
|
|
72
|
+
>
|
|
73
|
+
? Method<
|
|
74
|
+
AlovaGenerics<
|
|
75
|
+
CurrentConfig extends undefined
|
|
76
|
+
? ExtractUserDefinedTransformed<DefinitionKey, Responded>
|
|
77
|
+
: CurrentConfig['transform'] extends (...args: any[]) => any
|
|
78
|
+
? Awaited<ReturnType<CurrentConfig['transform']>>
|
|
79
|
+
: ExtractUserDefinedTransformed<DefinitionKey, Responded>,
|
|
80
|
+
any,
|
|
81
|
+
RequestConfig,
|
|
82
|
+
Response,
|
|
83
|
+
ResponseHeader,
|
|
84
|
+
L1Cache,
|
|
85
|
+
L2Cache,
|
|
86
|
+
SE
|
|
87
|
+
>
|
|
88
|
+
>
|
|
89
|
+
: never;
|
|
90
|
+
|
|
91
|
+
export interface GetTokenRequest {
|
|
92
|
+
type?: string;
|
|
93
|
+
uid?: string;
|
|
94
|
+
token?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface DoctorState {
|
|
97
|
+
id?: string;
|
|
98
|
+
name?: string;
|
|
99
|
+
createdTimestamp?: number;
|
|
100
|
+
updatedTimestamp?: number;
|
|
101
|
+
gender?: string;
|
|
102
|
+
identityNumber?: string;
|
|
103
|
+
phoneNumber?: string;
|
|
104
|
+
birthdate?: string;
|
|
105
|
+
}
|
|
106
|
+
export interface PatientState {
|
|
107
|
+
id?: string;
|
|
108
|
+
doctorId?: string;
|
|
109
|
+
name?: string;
|
|
110
|
+
createdTimestamp?: number;
|
|
111
|
+
updatedTimestamp?: number;
|
|
112
|
+
identity?: string;
|
|
113
|
+
gender?: string;
|
|
114
|
+
phoneNumber?: string;
|
|
115
|
+
birthdate?: string;
|
|
116
|
+
tags?: string;
|
|
117
|
+
mainSymptom?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface ScientistState {
|
|
120
|
+
id?: string;
|
|
121
|
+
name?: string;
|
|
122
|
+
createdTimestamp?: number;
|
|
123
|
+
updatedTimestamp?: number;
|
|
124
|
+
identityNumber?: string;
|
|
125
|
+
gender?: string;
|
|
126
|
+
phoneNumber?: string;
|
|
127
|
+
birthdate?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface GetTokenResponse {
|
|
130
|
+
status?: number;
|
|
131
|
+
token?: string;
|
|
132
|
+
doctors?: DoctorState[];
|
|
133
|
+
patients?: PatientState[];
|
|
134
|
+
scientist?: ScientistState[];
|
|
135
|
+
}
|
|
136
|
+
export interface AuthorizationState {
|
|
137
|
+
requestDefinition?: string;
|
|
138
|
+
policyDefinition?: string;
|
|
139
|
+
policyEffect?: string;
|
|
140
|
+
matchers?: string;
|
|
141
|
+
policies?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface ResourceAuthorizationState {
|
|
144
|
+
resourceId?: string;
|
|
145
|
+
authorizationStates?: AuthorizationState[];
|
|
146
|
+
ownerId?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface RoleAuthorizationState {
|
|
149
|
+
role?: string;
|
|
150
|
+
authorizationStates?: AuthorizationState[];
|
|
151
|
+
}
|
|
152
|
+
export interface UserAuthorizationState {
|
|
153
|
+
userId?: string;
|
|
154
|
+
authorizationStates?: AuthorizationState[];
|
|
155
|
+
}
|
|
156
|
+
declare global {
|
|
157
|
+
interface authorizeApi {
|
|
158
|
+
oAuthRestful: {
|
|
159
|
+
/**
|
|
160
|
+
* ---
|
|
161
|
+
*
|
|
162
|
+
* [POST]
|
|
163
|
+
*
|
|
164
|
+
* **path:** /授权/服务/令牌
|
|
165
|
+
*
|
|
166
|
+
* ---
|
|
167
|
+
*
|
|
168
|
+
* **RequestBody**
|
|
169
|
+
* ```ts
|
|
170
|
+
* type RequestBody = {
|
|
171
|
+
* type?: string
|
|
172
|
+
* uid?: string
|
|
173
|
+
* token?: string
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* ---
|
|
178
|
+
*
|
|
179
|
+
* **Response**
|
|
180
|
+
* ```ts
|
|
181
|
+
* type Response = {
|
|
182
|
+
* status?: number
|
|
183
|
+
* token?: string
|
|
184
|
+
* // [items] start
|
|
185
|
+
* // [items] end
|
|
186
|
+
* doctors?: Array<{
|
|
187
|
+
* id?: string
|
|
188
|
+
* name?: string
|
|
189
|
+
* createdTimestamp?: number
|
|
190
|
+
* updatedTimestamp?: number
|
|
191
|
+
* gender?: string
|
|
192
|
+
* identityNumber?: string
|
|
193
|
+
* phoneNumber?: string
|
|
194
|
+
* birthdate?: string
|
|
195
|
+
* }>
|
|
196
|
+
* // [items] start
|
|
197
|
+
* // [items] end
|
|
198
|
+
* patients?: Array<{
|
|
199
|
+
* id?: string
|
|
200
|
+
* doctorId?: string
|
|
201
|
+
* name?: string
|
|
202
|
+
* createdTimestamp?: number
|
|
203
|
+
* updatedTimestamp?: number
|
|
204
|
+
* identity?: string
|
|
205
|
+
* gender?: string
|
|
206
|
+
* phoneNumber?: string
|
|
207
|
+
* birthdate?: string
|
|
208
|
+
* tags?: string
|
|
209
|
+
* mainSymptom?: string
|
|
210
|
+
* }>
|
|
211
|
+
* // [items] start
|
|
212
|
+
* // [items] end
|
|
213
|
+
* scientist?: Array<{
|
|
214
|
+
* id?: string
|
|
215
|
+
* name?: string
|
|
216
|
+
* createdTimestamp?: number
|
|
217
|
+
* updatedTimestamp?: number
|
|
218
|
+
* identityNumber?: string
|
|
219
|
+
* gender?: string
|
|
220
|
+
* phoneNumber?: string
|
|
221
|
+
* birthdate?: string
|
|
222
|
+
* }>
|
|
223
|
+
* }
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
getToken<
|
|
227
|
+
Config extends Alova2MethodConfig<GetTokenResponse> & {
|
|
228
|
+
data: GetTokenRequest;
|
|
229
|
+
}
|
|
230
|
+
>(
|
|
231
|
+
config: Config
|
|
232
|
+
): Alova2Method<GetTokenResponse, 'oAuthRestful.getToken', Config>;
|
|
233
|
+
};
|
|
234
|
+
resourceAuthorizationRestful: {
|
|
235
|
+
/**
|
|
236
|
+
* ---
|
|
237
|
+
*
|
|
238
|
+
* [GET]
|
|
239
|
+
*
|
|
240
|
+
* **path:** /授权/服务/资源/{id}
|
|
241
|
+
*
|
|
242
|
+
* ---
|
|
243
|
+
*
|
|
244
|
+
* **Path Parameters**
|
|
245
|
+
* ```ts
|
|
246
|
+
* type PathParameters = {
|
|
247
|
+
* id: string
|
|
248
|
+
* }
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* ---
|
|
252
|
+
*
|
|
253
|
+
* **Response**
|
|
254
|
+
* ```ts
|
|
255
|
+
* type Response = {
|
|
256
|
+
* resourceId?: string
|
|
257
|
+
* // [items] start
|
|
258
|
+
* // [items] end
|
|
259
|
+
* authorizationStates?: Array<{
|
|
260
|
+
* requestDefinition?: string
|
|
261
|
+
* policyDefinition?: string
|
|
262
|
+
* policyEffect?: string
|
|
263
|
+
* matchers?: string
|
|
264
|
+
* policies?: string
|
|
265
|
+
* }>
|
|
266
|
+
* ownerId?: string
|
|
267
|
+
* }
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
getResourceAuthorizationState<
|
|
271
|
+
Config extends Alova2MethodConfig<ResourceAuthorizationState> & {
|
|
272
|
+
pathParams: {
|
|
273
|
+
id: string;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
>(
|
|
277
|
+
config: Config
|
|
278
|
+
): Alova2Method<ResourceAuthorizationState, 'resourceAuthorizationRestful.getResourceAuthorizationState', Config>;
|
|
279
|
+
};
|
|
280
|
+
roleAuthorizationRestful: {
|
|
281
|
+
/**
|
|
282
|
+
* ---
|
|
283
|
+
*
|
|
284
|
+
* [GET]
|
|
285
|
+
*
|
|
286
|
+
* **path:** /授权/服务/角色/{role}
|
|
287
|
+
*
|
|
288
|
+
* ---
|
|
289
|
+
*
|
|
290
|
+
* **Path Parameters**
|
|
291
|
+
* ```ts
|
|
292
|
+
* type PathParameters = {
|
|
293
|
+
* role: string
|
|
294
|
+
* }
|
|
295
|
+
* ```
|
|
296
|
+
*
|
|
297
|
+
* ---
|
|
298
|
+
*
|
|
299
|
+
* **Response**
|
|
300
|
+
* ```ts
|
|
301
|
+
* type Response = {
|
|
302
|
+
* role?: string
|
|
303
|
+
* // [items] start
|
|
304
|
+
* // [items] end
|
|
305
|
+
* authorizationStates?: Array<{
|
|
306
|
+
* requestDefinition?: string
|
|
307
|
+
* policyDefinition?: string
|
|
308
|
+
* policyEffect?: string
|
|
309
|
+
* matchers?: string
|
|
310
|
+
* policies?: string
|
|
311
|
+
* }>
|
|
312
|
+
* }
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
getRoleAuthorizationState<
|
|
316
|
+
Config extends Alova2MethodConfig<RoleAuthorizationState> & {
|
|
317
|
+
pathParams: {
|
|
318
|
+
role: string;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
>(
|
|
322
|
+
config: Config
|
|
323
|
+
): Alova2Method<RoleAuthorizationState, 'roleAuthorizationRestful.getRoleAuthorizationState', Config>;
|
|
324
|
+
};
|
|
325
|
+
userAuthorizationRestful: {
|
|
326
|
+
/**
|
|
327
|
+
* ---
|
|
328
|
+
*
|
|
329
|
+
* [GET]
|
|
330
|
+
*
|
|
331
|
+
* **path:** /授权/服务/用户/{userId}
|
|
332
|
+
*
|
|
333
|
+
* ---
|
|
334
|
+
*
|
|
335
|
+
* **Path Parameters**
|
|
336
|
+
* ```ts
|
|
337
|
+
* type PathParameters = {
|
|
338
|
+
* userId: string
|
|
339
|
+
* }
|
|
340
|
+
* ```
|
|
341
|
+
*
|
|
342
|
+
* ---
|
|
343
|
+
*
|
|
344
|
+
* **Response**
|
|
345
|
+
* ```ts
|
|
346
|
+
* type Response = {
|
|
347
|
+
* userId?: string
|
|
348
|
+
* // [items] start
|
|
349
|
+
* // [items] end
|
|
350
|
+
* authorizationStates?: Array<{
|
|
351
|
+
* requestDefinition?: string
|
|
352
|
+
* policyDefinition?: string
|
|
353
|
+
* policyEffect?: string
|
|
354
|
+
* matchers?: string
|
|
355
|
+
* policies?: string
|
|
356
|
+
* }>
|
|
357
|
+
* }
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
getUserAuthorizationState<
|
|
361
|
+
Config extends Alova2MethodConfig<UserAuthorizationState> & {
|
|
362
|
+
pathParams: {
|
|
363
|
+
userId: string;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
>(
|
|
367
|
+
config: Config
|
|
368
|
+
): Alova2Method<UserAuthorizationState, 'userAuthorizationRestful.getUserAuthorizationState', Config>;
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
var authorizeApi: authorizeApi;
|
|
373
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Authorization } from 'src/api/authorization/authorization';
|
|
2
|
+
export class AlovaAuthorization extends Authorization{
|
|
3
|
+
static override getToken(type?: string, uid?: string, token?: string) {
|
|
4
|
+
return authorizeApi.oAuthRestful.getToken({
|
|
5
|
+
data: {
|
|
6
|
+
... {... type && {type}},
|
|
7
|
+
... {... uid && {uid}},
|
|
8
|
+
... {... token && {token}}
|
|
9
|
+
}
|
|
10
|
+
}).send()
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createAlova } from 'alova';
|
|
2
|
+
import fetchAdapter from 'alova/fetch';
|
|
3
|
+
import { createApis, withConfigType, mountApis } from './createApis';
|
|
4
|
+
import { onAuthRequired, responded } from 'src/api/config/alova';
|
|
5
|
+
import { getServiceEndpoint, ServiceType } from 'src/api/config';
|
|
6
|
+
|
|
7
|
+
export const alovaInstance = createAlova({
|
|
8
|
+
baseURL: getServiceEndpoint(ServiceType.Authorization),
|
|
9
|
+
requestAdapter: fetchAdapter(),
|
|
10
|
+
beforeRequest: onAuthRequired(),
|
|
11
|
+
cacheFor: null,
|
|
12
|
+
responded: responded
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const $$userConfigMap = withConfigType({});
|
|
16
|
+
|
|
17
|
+
const Apis = createApis(alovaInstance, $$userConfigMap);
|
|
18
|
+
|
|
19
|
+
mountApis(Apis);
|
|
20
|
+
|
|
21
|
+
export default Apis;
|