web-core-tcm 0.0.24 → 0.0.25

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.
Files changed (126) hide show
  1. package/.editorconfig +7 -0
  2. package/.github/workflows/test.yml +29 -0
  3. package/.prettierrc.json +5 -0
  4. package/.vscode/extensions.json +15 -0
  5. package/.vscode/settings.json +9 -0
  6. package/eslint.config.js +83 -0
  7. package/index.html +24 -0
  8. package/package.json +1 -4
  9. package/postcss.config.js +29 -0
  10. package/public/favicon.ico +0 -0
  11. package/public/icons/favicon-128x128.png +0 -0
  12. package/public/icons/favicon-16x16.png +0 -0
  13. package/public/icons/favicon-32x32.png +0 -0
  14. package/public/icons/favicon-96x96.png +0 -0
  15. package/quasar.config.ts +233 -0
  16. package/src/App.vue +7 -0
  17. package/src/api/algorithm/comprehensiveAlgorithm.ts +20 -0
  18. package/src/api/algorithm/index.ts +50 -0
  19. package/src/api/algorithm/inquiriesAlgorithm.ts +16 -0
  20. package/src/api/algorithm/inspectionsAlgorithm.ts +11 -0
  21. package/src/api/algorithm/lisemsAlgorithm.ts +16 -0
  22. package/src/api/algorithm/pulsationsAlgorithm.ts +8 -0
  23. package/src/api/authorization/alova/apiDefinitions.ts +23 -0
  24. package/src/api/authorization/alova/createApis.ts +114 -0
  25. package/src/api/authorization/alova/globals.d.ts +394 -0
  26. package/src/api/authorization/alova/implement/authorization.ts +14 -0
  27. package/src/api/authorization/alova/implement/index.ts +1 -0
  28. package/src/api/authorization/alova/index.ts +22 -0
  29. package/src/api/authorization/authorization.ts +16 -0
  30. package/src/api/authorization/index.ts +2 -0
  31. package/src/api/check/alova/apiDefinitions.ts +30 -0
  32. package/src/api/check/alova/createApis.ts +114 -0
  33. package/src/api/check/alova/globals.d.ts +1257 -0
  34. package/src/api/check/alova/implement/check.ts +165 -0
  35. package/src/api/check/alova/implement/index.ts +1 -0
  36. package/src/api/check/alova/index.ts +22 -0
  37. package/src/api/check/check.ts +217 -0
  38. package/src/api/check/index.ts +2 -0
  39. package/src/api/config/alova/index.ts +71 -0
  40. package/src/api/config/index.ts +132 -0
  41. package/src/api/device/device.js +58 -0
  42. package/src/api/doctor/alova/apiDefinitions.ts +28 -0
  43. package/src/api/doctor/alova/createApis.ts +114 -0
  44. package/src/api/doctor/alova/globals.d.ts +559 -0
  45. package/src/api/doctor/alova/implement/doctor.ts +51 -0
  46. package/src/api/doctor/alova/implement/index.ts +1 -0
  47. package/src/api/doctor/alova/index.ts +23 -0
  48. package/src/api/doctor/doctor.ts +53 -0
  49. package/src/api/doctor/index.ts +2 -0
  50. package/src/api/index.ts +12 -0
  51. package/src/api/metric/implement/index.ts +1 -0
  52. package/src/api/metric/implement/metric.ts +108 -0
  53. package/src/api/metric/index.ts +2 -0
  54. package/src/api/metric/metric.ts +114 -0
  55. package/src/api/oauth/alova/apiDefinitions.ts +26 -0
  56. package/src/api/oauth/alova/createApis.ts +114 -0
  57. package/src/api/oauth/alova/globals.d.ts +460 -0
  58. package/src/api/oauth/alova/implement/index.ts +1 -0
  59. package/src/api/oauth/alova/implement/oauth.ts +24 -0
  60. package/src/api/oauth/alova/index.ts +21 -0
  61. package/src/api/oauth/index.ts +2 -0
  62. package/src/api/oauth/oauth.ts +19 -0
  63. package/src/api/outpatient/alova/apiDefinitions.ts +27 -0
  64. package/src/api/outpatient/alova/createApis.ts +114 -0
  65. package/src/api/outpatient/alova/globals.d.ts +685 -0
  66. package/src/api/outpatient/alova/implement/index.ts +1 -0
  67. package/src/api/outpatient/alova/implement/outpatient.ts +91 -0
  68. package/src/api/outpatient/alova/index.ts +22 -0
  69. package/src/api/outpatient/index.ts +2 -0
  70. package/src/api/outpatient/outpatient.ts +67 -0
  71. package/src/api/patient/alova/apiDefinitions.ts +41 -0
  72. package/src/api/patient/alova/createApis.ts +114 -0
  73. package/src/api/patient/alova/globals.d.ts +1690 -0
  74. package/src/api/patient/alova/implement/index.ts +2 -0
  75. package/src/api/patient/alova/implement/meta.ts +517 -0
  76. package/src/api/patient/alova/implement/patient.ts +99 -0
  77. package/src/api/patient/alova/index.ts +22 -0
  78. package/src/api/patient/core.ts +133 -0
  79. package/src/api/patient/index.ts +4 -0
  80. package/src/api/patient/meta.ts +570 -0
  81. package/src/api/patient/patient.ts +98 -0
  82. package/src/api/prescription/alova/apiDefinitions.ts +29 -0
  83. package/src/api/prescription/alova/createApis.ts +114 -0
  84. package/src/api/prescription/alova/globals.d.ts +968 -0
  85. package/src/api/prescription/alova/implement/herbal.ts +68 -0
  86. package/src/api/prescription/alova/implement/index.ts +2 -0
  87. package/src/api/prescription/alova/implement/prescription.ts +62 -0
  88. package/src/api/prescription/alova/index.ts +22 -0
  89. package/src/api/prescription/herbal.ts +51 -0
  90. package/src/api/prescription/index.ts +3 -0
  91. package/src/api/prescription/prescription.ts +76 -0
  92. package/src/api/scientist/alova/apiDefinitions.ts +27 -0
  93. package/src/api/scientist/alova/createApis.ts +114 -0
  94. package/src/api/scientist/alova/globals.d.ts +447 -0
  95. package/src/api/scientist/alova/implement/index.ts +1 -0
  96. package/src/api/scientist/alova/implement/scientist.ts +40 -0
  97. package/src/api/scientist/alova/index.ts +24 -0
  98. package/src/api/scientist/index.ts +2 -0
  99. package/src/api/scientist/scientist.ts +49 -0
  100. package/src/assets/quasar-logo-vertical.svg +15 -0
  101. package/src/boot/.gitkeep +0 -0
  102. package/src/components/ExampleComponent.vue +37 -0
  103. package/src/components/models.ts +8 -0
  104. package/src/css/app.scss +1 -0
  105. package/src/css/quasar.variables.scss +25 -0
  106. package/src/env.d.ts +7 -0
  107. package/src/index.ts +3 -0
  108. package/src/layouts/UserLayout.vue +108 -0
  109. package/src/pages/LoginPage.vue +29 -0
  110. package/src/proto/Images.proto +7 -0
  111. package/src/proto/WaveMap.proto +10 -0
  112. package/src/proto/index.ts +2 -0
  113. package/src/proto/types/Images_pb.ts +48 -0
  114. package/src/proto/types/WaveMap_pb.ts +59 -0
  115. package/src/router/index.ts +37 -0
  116. package/src/router/routes.ts +14 -0
  117. package/src/util/RichTextUtil.ts +5 -0
  118. package/src/util/datetime.ts +43 -0
  119. package/src/util/export.ts +46 -0
  120. package/src/util/helper.ts +159 -0
  121. package/src/util/image.ts +28 -0
  122. package/src/util/number.ts +146 -0
  123. package/src/util/s256.js +27 -0
  124. package/src/util/secret.ts +60 -0
  125. package/src/util/string.ts +121 -0
  126. package/tsconfig.json +7 -0
@@ -0,0 +1,51 @@
1
+ import { Doctor } from 'src/api/doctor/doctor';
2
+
3
+ export class AlovaDoctor extends Doctor {
4
+ override async get() {
5
+ return this.of(
6
+ await doctorApi.doctorStateRestful
7
+ .getDoctorState({
8
+ pathParams: {
9
+ id: this.id,
10
+ },
11
+ async transform(res) {
12
+ return new AlovaDoctor().of(res);
13
+ },
14
+ })
15
+ .send(),
16
+ );
17
+ }
18
+
19
+ override async put() {
20
+ return this.of(
21
+ await doctorApi.doctorStateRestful
22
+ .putDoctorState({
23
+ pathParams: {
24
+ id: this.id,
25
+ },
26
+ data: this.state(),
27
+ })
28
+ .send(),
29
+ );
30
+ }
31
+
32
+ override async post() {
33
+ return this.of(
34
+ await doctorApi.doctorStateRestful
35
+ .postDoctorState({
36
+ data: this.state(),
37
+ })
38
+ .send(),
39
+ );
40
+ }
41
+ override async delete() {
42
+ await doctorApi.doctorStateRestful
43
+ .deleteDoctorState({
44
+ pathParams: {
45
+ id: this.id,
46
+ },
47
+ })
48
+ .send();
49
+ return Promise.resolve();
50
+ }
51
+ }
@@ -0,0 +1 @@
1
+ export * from './doctor';
@@ -0,0 +1,23 @@
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.Doctor),
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;
22
+
23
+ export * from './implement';
@@ -0,0 +1,53 @@
1
+ import { NetworkObject } from 'src/api/patient/core';
2
+ import type { DoctorState } from 'src/api/doctor/alova/globals';
3
+ import type { IBuilder } from 'builder-pattern';
4
+ import { Builder } from 'builder-pattern';
5
+
6
+ export abstract class Doctor extends NetworkObject {
7
+ static override builder(): IBuilder<Doctor> {
8
+ return Builder(this._default) as unknown as IBuilder<Doctor>;
9
+ }
10
+ static override default(): typeof Doctor {
11
+ return this._default as unknown as typeof Doctor;
12
+ }
13
+ id: string = '';
14
+ name: string = '';
15
+ createdTimestamp: string = '';
16
+ updatedTimestamp: string = '';
17
+ gender: string = '';
18
+ identityNumber: string = '';
19
+ phoneNumber: string = '';
20
+ birthdate: string = '';
21
+ custom: string = '标准模式';
22
+ override of(json: DoctorState) {
23
+ if (json.id != undefined) this.id = json.id;
24
+ if (json.name != undefined) this.name = json.name;
25
+ if (json.createdTimestamp != undefined) this.createdTimestamp = json.createdTimestamp;
26
+ if (json.updatedTimestamp != undefined) this.updatedTimestamp = json.updatedTimestamp;
27
+ if (json.gender != undefined) this.gender = json.gender;
28
+ if (json.identityNumber != undefined) this.identityNumber = json.identityNumber;
29
+ if (json.phoneNumber != undefined) this.phoneNumber = json.phoneNumber;
30
+ if (json.birthdate != undefined) this.birthdate = json.birthdate;
31
+ return Promise.resolve(this);
32
+ }
33
+ override state() {
34
+ const state = {} as DoctorState;
35
+ if (this.id) state.id = this.id;
36
+ if (this.name) state.name = this.name;
37
+ if (this.createdTimestamp) state.createdTimestamp = this.createdTimestamp;
38
+ if (this.updatedTimestamp) state.updatedTimestamp = this.updatedTimestamp;
39
+ if (this.gender) state.gender = this.gender;
40
+ if (this.identityNumber) state.identityNumber = this.identityNumber;
41
+ if (this.phoneNumber) state.phoneNumber = this.phoneNumber;
42
+ if (this.birthdate) state.birthdate = this.birthdate;
43
+ return state;
44
+ }
45
+
46
+ abstract get(): Promise<Doctor>;
47
+
48
+ abstract put(): Promise<Doctor>;
49
+
50
+ abstract post(): Promise<Doctor>;
51
+
52
+ abstract delete(): Promise<void>;
53
+ }
@@ -0,0 +1,2 @@
1
+ export * from './doctor';
2
+ export * from './alova';
@@ -0,0 +1,12 @@
1
+ export * as AlgorithmApi from './algorithm/index';
2
+ export * as AuthorizationApi from './authorization/index';
3
+ export * as CheckApi from './check/index';
4
+ export * as ConfigApi from './config/index';
5
+ export * as DoctorApi from './doctor/index';
6
+ export * as MetricApi from './metric/index';
7
+ export * as OAuthApi from './oauth/index';
8
+ export * as OutPatientApi from './outpatient/index';
9
+ export * as PatientApi from './patient/index';
10
+ export * as PrescriptionApi from './prescription/index';
11
+ export * as ScientistApi from './scientist/index';
12
+ export * as DeviceApi from './device/device';
@@ -0,0 +1 @@
1
+ export * from './metric';
@@ -0,0 +1,108 @@
1
+ import type { MetaType } from 'src/api/patient/meta';
2
+ import { Metric } from 'src/api/metric/metric';
3
+ import type {
4
+ AgeDistribute,
5
+ DateDistribute,
6
+ GenderDistribute,
7
+ } from 'src/api/patient/alova/globals';
8
+
9
+ export class AlovaMetric extends Metric {
10
+ // 科研相关统计
11
+ static override getPatientTodayCount(): Promise<number> {
12
+ return patientApi.metricRestful.totalOfPatientByToday().send();
13
+ }
14
+
15
+ static override getPatientTotalCount(): Promise<number> {
16
+ return patientApi.metricRestful.totalOfPatient().send();
17
+ }
18
+
19
+ static override getPatientDateDistribute(): Promise<DateDistribute[]> {
20
+ return patientApi.metricRestful.dateDistributeOfPatient().send();
21
+ }
22
+
23
+ static override getPatientAgeDistribute(): Promise<AgeDistribute[]> {
24
+ return patientApi.metricRestful.ageDistributeOfPatient().send();
25
+ }
26
+
27
+ static override getPatientGenderDistribute(): Promise<GenderDistribute[]> {
28
+ return patientApi.metricRestful.genderDistributeOfPatient().send();
29
+ }
30
+
31
+ // 面象相关统计
32
+ static override getMetaTodayCount(type: MetaType): Promise<number> {
33
+ return patientApi.metricRestful
34
+ .totalOfMetaByToday({
35
+ params: {
36
+ type: type,
37
+ },
38
+ })
39
+ .send();
40
+ }
41
+
42
+ static override getMetaTotalCount(type: MetaType): Promise<number> {
43
+ return patientApi.metricRestful
44
+ .totalOfMeta({
45
+ params: {
46
+ type: type,
47
+ },
48
+ })
49
+ .send();
50
+ }
51
+
52
+ static override getMetaDateDistribute(type: MetaType): Promise<DateDistribute[]> {
53
+ return patientApi.metricRestful
54
+ .datesOfMeta({
55
+ params: {
56
+ type: type,
57
+ },
58
+ })
59
+ .send();
60
+ }
61
+
62
+ // 病例相关统计
63
+ static override getCheckGenderDistribute(): Promise<GenderDistribute[]> {
64
+ return checkApi.checkStateRestful.genderDistributeOfCheckState().send();
65
+ }
66
+
67
+ static override getCheckAgeDistribute(): Promise<AgeDistribute[]> {
68
+ return checkApi.checkStateRestful.ageDistributeOfCheckState().send();
69
+ }
70
+
71
+ static override getCheckTotalCount(): Promise<number> {
72
+ return checkApi.checkStateRestful.totalOfCheckState().send();
73
+ }
74
+
75
+ static override getCheckDateDistribute(): Promise<DateDistribute[]> {
76
+ return checkApi.checkStateRestful.datesOfCheckState().send();
77
+ }
78
+
79
+ static override getCheckTodayCount(): Promise<number> {
80
+ return checkApi.checkStateRestful.totalOfCheckByTodayState().send();
81
+ }
82
+
83
+ // 医生相关统计
84
+ static override getDoctorTotalCount(): Promise<number> {
85
+ return doctorApi.doctorStateRestful.totalOfDoctor().send();
86
+ }
87
+
88
+ static override getDoctorDateDistribute(): Promise<DateDistribute[]> {
89
+ return doctorApi.doctorStateRestful.datesOfDoctor().send();
90
+ }
91
+
92
+ static override getDoctorTodayCount(): Promise<number> {
93
+ return doctorApi.doctorStateRestful.totalOfDoctorByToday().send();
94
+ }
95
+
96
+ // 排队相关统计
97
+ static override getQueuerTotalCount(): Promise<number> {
98
+ return outpatientApi.metricRestful.totalOfQueuerState().send();
99
+ }
100
+
101
+ static override getQueuerDateDistribute(): Promise<DateDistribute[]> {
102
+ return outpatientApi.metricRestful.datesOfQueuerState().send();
103
+ }
104
+
105
+ static override getQueuerTodayCount(): Promise<number> {
106
+ return outpatientApi.metricRestful.totalOfQueuerTodayState().send();
107
+ }
108
+ }
@@ -0,0 +1,2 @@
1
+ export * from './implement';
2
+ export * from './metric';
@@ -0,0 +1,114 @@
1
+ import type { MetaType } from 'src/api/patient/meta';
2
+ import type { IBuilder } from 'builder-pattern';
3
+ import { Builder } from 'builder-pattern';
4
+ import type { DateDistribute } from 'src/api/patient/alova/globals';
5
+ import type { AgeDistribute, GenderDistribute } from 'src/api/check/alova/globals';
6
+
7
+ export class Metric {
8
+ static _default: typeof Metric;
9
+ static builder(): IBuilder<unknown> {
10
+ return Builder(this._default) as unknown as IBuilder<Metric>;
11
+ }
12
+ static default(): typeof Metric {
13
+ return this._default as unknown as typeof Metric;
14
+ }
15
+ // 科研相关统计
16
+ static getPatientTodayCount(): Promise<number> {
17
+ //表单格式的body,不是Json格式的
18
+ return Metric.default().getPatientTodayCount();
19
+ }
20
+
21
+ static getPatientTotalCount(): Promise<number> {
22
+ //表单格式的body,不是Json格式的
23
+ return Metric.default().getPatientTotalCount();
24
+ }
25
+
26
+ static getPatientDateDistribute(): Promise<DateDistribute[]> {
27
+ //表单格式的body,不是Json格式的
28
+ return Metric.default().getPatientDateDistribute();
29
+ }
30
+
31
+ static getPatientAgeDistribute(): Promise<AgeDistribute[]> {
32
+ //表单格式的body,不是Json格式的
33
+ return Metric.default().getPatientAgeDistribute();
34
+ }
35
+
36
+ static getPatientGenderDistribute(): Promise<GenderDistribute[]> {
37
+ //表单格式的body,不是Json格式的
38
+ return Metric.default().getPatientGenderDistribute();
39
+ }
40
+
41
+ // 面象相关统计
42
+ static getMetaTodayCount(type: MetaType): Promise<number> {
43
+ //表单格式的body,不是Json格式的
44
+ return Metric.default().getMetaTodayCount(type);
45
+ }
46
+
47
+ static getMetaTotalCount(type: MetaType): Promise<number> {
48
+ //表单格式的body,不是Json格式的
49
+ return Metric.default().getMetaTotalCount(type);
50
+ }
51
+
52
+ static getMetaDateDistribute(type: MetaType): Promise<DateDistribute[]> {
53
+ //表单格式的body,不是Json格式的
54
+ return Metric.default().getMetaDateDistribute(type);
55
+ }
56
+
57
+ // 病例相关统计
58
+ static getCheckGenderDistribute(): Promise<GenderDistribute[]> {
59
+ //表单格式的body,不是Json格式的
60
+ return Metric.default().getCheckGenderDistribute();
61
+ }
62
+
63
+ static getCheckAgeDistribute(): Promise<AgeDistribute[]> {
64
+ //表单格式的body,不是Json格式的
65
+ return Metric.default().getCheckAgeDistribute();
66
+ }
67
+
68
+ static getCheckTotalCount(): Promise<number> {
69
+ //表单格式的body,不是Json格式的
70
+ return Metric.default().getCheckTotalCount();
71
+ }
72
+
73
+ static getCheckDateDistribute(): Promise<DateDistribute[]> {
74
+ //表单格式的body,不是Json格式的
75
+ return Metric.default().getCheckDateDistribute();
76
+ }
77
+
78
+ static getCheckTodayCount(): Promise<number> {
79
+ //表单格式的body,不是Json格式的
80
+ return Metric.default().getCheckTodayCount();
81
+ }
82
+
83
+ // 医生相关统计
84
+ static getDoctorTotalCount(): Promise<number> {
85
+ //表单格式的body,不是Json格式的
86
+ return Metric.default().getDoctorTotalCount();
87
+ }
88
+
89
+ static getDoctorDateDistribute(): Promise<DateDistribute[]> {
90
+ //表单格式的body,不是Json格式的
91
+ return Metric.default().getDoctorDateDistribute();
92
+ }
93
+
94
+ static getDoctorTodayCount(): Promise<number> {
95
+ //表单格式的body,不是Json格式的
96
+ return Metric.default().getDoctorTodayCount();
97
+ }
98
+
99
+ // 排队相关统计
100
+ static getQueuerTotalCount(): Promise<number> {
101
+ //表单格式的body,不是Json格式的
102
+ return Metric.default().getQueuerTotalCount();
103
+ }
104
+
105
+ static getQueuerDateDistribute(): Promise<DateDistribute[]> {
106
+ //表单格式的body,不是Json格式的
107
+ return Metric.default().getQueuerDateDistribute();
108
+ }
109
+
110
+ static getQueuerTodayCount(): Promise<number> {
111
+ //表单格式的body,不是Json格式的
112
+ return Metric.default().getQueuerTodayCount();
113
+ }
114
+ }
@@ -0,0 +1,26 @@
1
+ /// <reference types='./globals.d.ts' />
2
+ /* tslint:disable */
3
+
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
+ 'userStateRestful.getUserState': ['GET', '/互联/服务/用户'],
20
+ 'userStateRestful.putUserState': ['PUT', '/互联/服务/用户'],
21
+ 'phoneVerifyRestful.verifySMSCode': ['POST', '/互联/服务/电话/验证短信'],
22
+ 'phoneVerifyRestful.sendSMSCode': ['GET', '/互联/服务/电话/发送短信'],
23
+ 'phoneVerifyRestful.authToken': ['GET', '/互联/服务/电话/令牌认证'],
24
+ 'authorizationRestful.consent': ['GET', '/互联/服务/授权/许可'],
25
+ 'authorizationRestful.getClientDescription': ['GET', '/互联/服务/授权/客户端介绍'],
26
+ };
@@ -0,0 +1,114 @@
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 = (
23
+ array: (string | symbol)[],
24
+ alovaInstance: Alova<AlovaGenerics>,
25
+ configMap: any,
26
+ ) => {
27
+ const apiPathKey = array.join('.') as keyof typeof apiDefinitions;
28
+ if (cache[apiPathKey]) {
29
+ return cache[apiPathKey];
30
+ }
31
+ // create a new proxy instance
32
+ const proxy = new Proxy(function () {}, {
33
+ get(_, property) {
34
+ // record the target property, so that it can get the completed accessing paths
35
+ const newArray = [...array, property];
36
+ // always return a new proxy to continue recording accessing paths.
37
+ return createFunctionalProxy(newArray, alovaInstance, configMap);
38
+ },
39
+ apply(_, __, [config]) {
40
+ const apiItem = apiDefinitions[apiPathKey];
41
+ if (!apiItem) {
42
+ throw new Error(`the api path of \`${apiPathKey}\` is not found`);
43
+ }
44
+ const mergedConfig = {
45
+ ...configMap[apiPathKey],
46
+ ...config,
47
+ };
48
+ const [method, url] = apiItem;
49
+ const pathParams = mergedConfig.pathParams;
50
+ const urlReplaced = url!.replace(/\{([^}]+)\}/g, (_, key) => {
51
+ const pathParam = pathParams[key];
52
+ return pathParam;
53
+ });
54
+ delete mergedConfig.pathParams;
55
+ let data = mergedConfig.data;
56
+ if (
57
+ Object.prototype.toString.call(data) === '[object Object]' &&
58
+ typeof FormData !== 'undefined'
59
+ ) {
60
+ let hasBlobData = false;
61
+ const formData = new FormData();
62
+ for (const key in data) {
63
+ formData.append(key, data[key]);
64
+ if (data[key] instanceof Blob) {
65
+ hasBlobData = true;
66
+ }
67
+ }
68
+ data = hasBlobData ? formData : data;
69
+ }
70
+ return new Method(
71
+ method!.toUpperCase() as MethodType,
72
+ alovaInstance,
73
+ urlReplaced,
74
+ mergedConfig,
75
+ data,
76
+ );
77
+ },
78
+ });
79
+ cache[apiPathKey] = proxy;
80
+ return proxy;
81
+ };
82
+
83
+ export const createApis = (alovaInstance: Alova<AlovaGenerics>, configMap: any) => {
84
+ const Apis = new Proxy({} as oauthApi, {
85
+ get(_, property) {
86
+ return createFunctionalProxy([property], alovaInstance, configMap);
87
+ },
88
+ });
89
+ return Apis;
90
+ };
91
+ export const mountApis = (Apis: oauthApi) => {
92
+ // define global variable `Apis`
93
+ (globalThis as any).oauthApi = Apis;
94
+ };
95
+ type MethodConfig<T> = AlovaMethodCreateConfig<
96
+ (typeof import('./index'))['alovaInstance'] extends Alova<infer AG> ? AG : any,
97
+ any,
98
+ T
99
+ >;
100
+ type APISofParameters<Tag extends string, Url extends string> = Tag extends keyof oauthApi
101
+ ? Url extends keyof oauthApi[Tag]
102
+ ? oauthApi[Tag][Url] extends (...args: any) => any
103
+ ? Parameters<oauthApi[Tag][Url]>
104
+ : any
105
+ : any
106
+ : any;
107
+ type MethodsConfigMap = {
108
+ [P in keyof typeof import('./apiDefinitions').default]?: MethodConfig<
109
+ P extends `${infer Tag}.${infer Url}`
110
+ ? Parameters<NonNullable<APISofParameters<Tag, Url>[0]>['transform']>[0]
111
+ : any
112
+ >;
113
+ };
114
+ export const withConfigType = <Config extends MethodsConfigMap>(config: Config) => config;