web-core-tcm 0.0.23 → 0.0.24

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/package.json +41 -21
  2. package/.editorconfig +0 -7
  3. package/.github/workflows/test.yml +0 -29
  4. package/.prettierrc.json +0 -5
  5. package/.vscode/extensions.json +0 -15
  6. package/.vscode/settings.json +0 -9
  7. package/eslint.config.js +0 -83
  8. package/index.html +0 -24
  9. package/postcss.config.js +0 -29
  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 +0 -220
  16. package/src/App.vue +0 -7
  17. package/src/api/algorithm/comprehensiveAlgorithm.ts +0 -20
  18. package/src/api/algorithm/index.ts +0 -50
  19. package/src/api/algorithm/inquiriesAlgorithm.ts +0 -19
  20. package/src/api/algorithm/inspectionsAlgorithm.ts +0 -11
  21. package/src/api/algorithm/lisemsAlgorithm.ts +0 -16
  22. package/src/api/algorithm/pulsationsAlgorithm.ts +0 -9
  23. package/src/api/authorization/alova/apiDefinitions.ts +0 -23
  24. package/src/api/authorization/alova/createApis.ts +0 -99
  25. package/src/api/authorization/alova/globals.d.ts +0 -373
  26. package/src/api/authorization/alova/implement/authorization.ts +0 -12
  27. package/src/api/authorization/alova/implement/index.ts +0 -1
  28. package/src/api/authorization/alova/index.ts +0 -23
  29. package/src/api/authorization/authorization.ts +0 -16
  30. package/src/api/authorization/index.ts +0 -2
  31. package/src/api/check/alova/apiDefinitions.ts +0 -30
  32. package/src/api/check/alova/createApis.ts +0 -99
  33. package/src/api/check/alova/globals.d.ts +0 -1248
  34. package/src/api/check/alova/implement/check.ts +0 -119
  35. package/src/api/check/alova/implement/index.ts +0 -1
  36. package/src/api/check/alova/index.ts +0 -23
  37. package/src/api/check/check.ts +0 -164
  38. package/src/api/check/index.ts +0 -2
  39. package/src/api/config/alova/index.ts +0 -72
  40. package/src/api/config/index.ts +0 -130
  41. package/src/api/device/device.js +0 -58
  42. package/src/api/doctor/alova/apiDefinitions.ts +0 -28
  43. package/src/api/doctor/alova/createApis.ts +0 -99
  44. package/src/api/doctor/alova/globals.d.ts +0 -550
  45. package/src/api/doctor/alova/implement/doctor.ts +0 -37
  46. package/src/api/doctor/alova/implement/index.ts +0 -1
  47. package/src/api/doctor/alova/index.ts +0 -23
  48. package/src/api/doctor/doctor.ts +0 -53
  49. package/src/api/doctor/index.ts +0 -2
  50. package/src/api/index.ts +0 -15
  51. package/src/api/metric/implement/index.ts +0 -1
  52. package/src/api/metric/implement/metric.ts +0 -98
  53. package/src/api/metric/index.ts +0 -2
  54. package/src/api/metric/metric.ts +0 -114
  55. package/src/api/oauth/alova/apiDefinitions.ts +0 -26
  56. package/src/api/oauth/alova/createApis.ts +0 -99
  57. package/src/api/oauth/alova/globals.d.ts +0 -451
  58. package/src/api/oauth/alova/implement/index.ts +0 -1
  59. package/src/api/oauth/alova/implement/oauth.ts +0 -19
  60. package/src/api/oauth/alova/index.ts +0 -22
  61. package/src/api/oauth/index.ts +0 -2
  62. package/src/api/oauth/oauth.ts +0 -15
  63. package/src/api/outpatient/alova/apiDefinitions.ts +0 -27
  64. package/src/api/outpatient/alova/createApis.ts +0 -99
  65. package/src/api/outpatient/alova/globals.d.ts +0 -676
  66. package/src/api/outpatient/alova/implement/index.ts +0 -1
  67. package/src/api/outpatient/alova/implement/outpatient.ts +0 -66
  68. package/src/api/outpatient/alova/index.ts +0 -23
  69. package/src/api/outpatient/index.ts +0 -2
  70. package/src/api/outpatient/outpatient.ts +0 -62
  71. package/src/api/patient/alova/apiDefinitions.ts +0 -41
  72. package/src/api/patient/alova/createApis.ts +0 -99
  73. package/src/api/patient/alova/globals.d.ts +0 -1677
  74. package/src/api/patient/alova/implement/index.ts +0 -2
  75. package/src/api/patient/alova/implement/meta.ts +0 -488
  76. package/src/api/patient/alova/implement/patient.ts +0 -77
  77. package/src/api/patient/alova/index.ts +0 -24
  78. package/src/api/patient/core.ts +0 -131
  79. package/src/api/patient/index.ts +0 -4
  80. package/src/api/patient/meta.ts +0 -466
  81. package/src/api/patient/patient.ts +0 -98
  82. package/src/api/prescription/alova/apiDefinitions.ts +0 -29
  83. package/src/api/prescription/alova/createApis.ts +0 -99
  84. package/src/api/prescription/alova/globals.d.ts +0 -959
  85. package/src/api/prescription/alova/implement/herbal.ts +0 -48
  86. package/src/api/prescription/alova/implement/index.ts +0 -2
  87. package/src/api/prescription/alova/implement/prescription.ts +0 -45
  88. package/src/api/prescription/alova/index.ts +0 -23
  89. package/src/api/prescription/herbal.ts +0 -44
  90. package/src/api/prescription/index.ts +0 -3
  91. package/src/api/prescription/prescription.ts +0 -68
  92. package/src/api/scientist/alova/apiDefinitions.ts +0 -27
  93. package/src/api/scientist/alova/createApis.ts +0 -99
  94. package/src/api/scientist/alova/globals.d.ts +0 -438
  95. package/src/api/scientist/alova/implement/index.ts +0 -1
  96. package/src/api/scientist/alova/implement/scientist.ts +0 -29
  97. package/src/api/scientist/alova/index.ts +0 -23
  98. package/src/api/scientist/index.ts +0 -2
  99. package/src/api/scientist/scientist.ts +0 -49
  100. package/src/assets/quasar-logo-vertical.svg +0 -15
  101. package/src/boot/.gitkeep +0 -0
  102. package/src/components/ExampleComponent.vue +0 -37
  103. package/src/components/models.ts +0 -8
  104. package/src/css/app.scss +0 -1
  105. package/src/css/quasar.variables.scss +0 -25
  106. package/src/env.d.ts +0 -7
  107. package/src/index.ts +0 -4
  108. package/src/layouts/UserLayout.vue +0 -106
  109. package/src/pages/LoginPage.vue +0 -32
  110. package/src/proto/Images.proto +0 -7
  111. package/src/proto/WaveMap.proto +0 -10
  112. package/src/proto/index.ts +0 -2
  113. package/src/proto/types/Images_pb.ts +0 -48
  114. package/src/proto/types/WaveMap_pb.ts +0 -59
  115. package/src/router/index.ts +0 -37
  116. package/src/router/routes.ts +0 -14
  117. package/src/util/RichTextUtil.ts +0 -5
  118. package/src/util/datetime.ts +0 -43
  119. package/src/util/export.ts +0 -46
  120. package/src/util/helper.ts +0 -159
  121. package/src/util/image.ts +0 -28
  122. package/src/util/number.ts +0 -146
  123. package/src/util/s256.js +0 -30
  124. package/src/util/secret.ts +0 -60
  125. package/src/util/string.ts +0 -121
  126. package/tsconfig.json +0 -3
@@ -1,451 +0,0 @@
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 UserState {
92
- id?: string;
93
- name?: string;
94
- phoneNumber?: string;
95
- identityNumber?: string;
96
- gender?: string;
97
- createdTimestamp?: string;
98
- updatedTimestamp?: string;
99
- }
100
- export interface PhoneVerifyRequest {
101
- phoneNumber?: string;
102
- code?: string;
103
- id?: string;
104
- }
105
- export interface UserGetResponse {
106
- status?: number;
107
- user?: UserState;
108
- }
109
- export interface UserPutResponse {
110
- status?: number;
111
- user?: UserState;
112
- }
113
- export interface PhoneVerifyResponse {
114
- status?: number;
115
- token?: string;
116
- users?: UserState[];
117
- message?: string;
118
- }
119
- export interface Model {
120
- bizId?: string;
121
- outId?: string;
122
- requestId?: string;
123
- verifyCode?: string;
124
- }
125
- export interface SendSmsVerifyCodeResponseBody {
126
- accessDeniedDetail?: string;
127
- code?: string;
128
- message?: string;
129
- model?: Model;
130
- success?: boolean;
131
- }
132
- export interface SendSmsVerifyCodeResponse {
133
- headers?: Record<string, string>;
134
- statusCode?: number;
135
- body?: SendSmsVerifyCodeResponseBody;
136
- }
137
- export interface TokenInfo {
138
- accessToken?: string;
139
- jwtToken?: string;
140
- }
141
- export interface GetAuthTokenResponseBody {
142
- code?: string;
143
- message?: string;
144
- requestId?: string;
145
- tokenInfo?: TokenInfo;
146
- }
147
- export interface GetAuthTokenResponse {
148
- headers?: Record<string, string>;
149
- statusCode?: number;
150
- body?: GetAuthTokenResponseBody;
151
- }
152
- export interface GetClientResponse {
153
- status?: number;
154
- clientDescription?: string;
155
- }
156
- declare global {
157
- interface oauthApi {
158
- userStateRestful: {
159
- /**
160
- * ---
161
- *
162
- * [GET]
163
- *
164
- * **path:** /互联/服务/用户
165
- *
166
- * ---
167
- *
168
- * **Response**
169
- * ```ts
170
- * type Response = {
171
- * status?: number
172
- * user?: {
173
- * id?: string
174
- * name?: string
175
- * phoneNumber?: string
176
- * identityNumber?: string
177
- * gender?: string
178
- * createdTimestamp?: string
179
- * updatedTimestamp?: string
180
- * }
181
- * }
182
- * ```
183
- */
184
- getUserState<Config extends Alova2MethodConfig<UserGetResponse>>(
185
- config?: Config
186
- ): Alova2Method<UserGetResponse, 'userStateRestful.getUserState', Config>;
187
- /**
188
- * ---
189
- *
190
- * [PUT]
191
- *
192
- * **path:** /互联/服务/用户
193
- *
194
- * ---
195
- *
196
- * **RequestBody**
197
- * ```ts
198
- * type RequestBody = {
199
- * id?: string
200
- * name?: string
201
- * phoneNumber?: string
202
- * identityNumber?: string
203
- * gender?: string
204
- * createdTimestamp?: string
205
- * updatedTimestamp?: string
206
- * }
207
- * ```
208
- *
209
- * ---
210
- *
211
- * **Response**
212
- * ```ts
213
- * type Response = {
214
- * status?: number
215
- * user?: {
216
- * id?: string
217
- * name?: string
218
- * phoneNumber?: string
219
- * identityNumber?: string
220
- * gender?: string
221
- * createdTimestamp?: string
222
- * updatedTimestamp?: string
223
- * }
224
- * }
225
- * ```
226
- */
227
- putUserState<
228
- Config extends Alova2MethodConfig<UserPutResponse> & {
229
- data: UserState;
230
- }
231
- >(
232
- config: Config
233
- ): Alova2Method<UserPutResponse, 'userStateRestful.putUserState', Config>;
234
- };
235
- phoneVerifyRestful: {
236
- /**
237
- * ---
238
- *
239
- * [POST]
240
- *
241
- * **path:** /互联/服务/电话/验证短信
242
- *
243
- * ---
244
- *
245
- * **RequestBody**
246
- * ```ts
247
- * type RequestBody = {
248
- * phoneNumber?: string
249
- * code?: string
250
- * id?: string
251
- * }
252
- * ```
253
- *
254
- * ---
255
- *
256
- * **Response**
257
- * ```ts
258
- * type Response = {
259
- * status?: number
260
- * token?: string
261
- * // [items] start
262
- * // [items] end
263
- * users?: Array<{
264
- * id?: string
265
- * name?: string
266
- * phoneNumber?: string
267
- * identityNumber?: string
268
- * gender?: string
269
- * createdTimestamp?: string
270
- * updatedTimestamp?: string
271
- * }>
272
- * message?: string
273
- * }
274
- * ```
275
- */
276
- verifySMSCode<
277
- Config extends Alova2MethodConfig<PhoneVerifyResponse> & {
278
- data: PhoneVerifyRequest;
279
- }
280
- >(
281
- config: Config
282
- ): Alova2Method<PhoneVerifyResponse, 'phoneVerifyRestful.verifySMSCode', Config>;
283
- /**
284
- * ---
285
- *
286
- * [GET]
287
- *
288
- * **path:** /互联/服务/电话/发送短信
289
- *
290
- * ---
291
- *
292
- * **Query Parameters**
293
- * ```ts
294
- * type QueryParameters = {
295
- * phoneNumber: string
296
- * }
297
- * ```
298
- *
299
- * ---
300
- *
301
- * **Response**
302
- * ```ts
303
- * type Response = {
304
- * headers?: Record<string, string>
305
- * statusCode?: number
306
- * body?: {
307
- * accessDeniedDetail?: string
308
- * code?: string
309
- * message?: string
310
- * model?: {
311
- * bizId?: string
312
- * outId?: string
313
- * requestId?: string
314
- * verifyCode?: string
315
- * }
316
- * success?: boolean
317
- * }
318
- * }
319
- * ```
320
- */
321
- sendSMSCode<
322
- Config extends Alova2MethodConfig<SendSmsVerifyCodeResponse> & {
323
- params: {
324
- phoneNumber: string;
325
- };
326
- }
327
- >(
328
- config: Config
329
- ): Alova2Method<SendSmsVerifyCodeResponse, 'phoneVerifyRestful.sendSMSCode', Config>;
330
- /**
331
- * ---
332
- *
333
- * [GET]
334
- *
335
- * **path:** /互联/服务/电话/令牌认证
336
- *
337
- * ---
338
- *
339
- * **Query Parameters**
340
- * ```ts
341
- * type QueryParameters = {
342
- * bizType: number
343
- * }
344
- * ```
345
- *
346
- * ---
347
- *
348
- * **Response**
349
- * ```ts
350
- * type Response = {
351
- * headers?: Record<string, string>
352
- * statusCode?: number
353
- * body?: {
354
- * code?: string
355
- * message?: string
356
- * requestId?: string
357
- * tokenInfo?: {
358
- * accessToken?: string
359
- * jwtToken?: string
360
- * }
361
- * }
362
- * }
363
- * ```
364
- */
365
- authToken<
366
- Config extends Alova2MethodConfig<GetAuthTokenResponse> & {
367
- params: {
368
- bizType: number;
369
- };
370
- }
371
- >(
372
- config: Config
373
- ): Alova2Method<GetAuthTokenResponse, 'phoneVerifyRestful.authToken', Config>;
374
- };
375
- authorizationRestful: {
376
- /**
377
- * ---
378
- *
379
- * [GET]
380
- *
381
- * **path:** /互联/服务/授权/许可
382
- *
383
- * ---
384
- *
385
- * **Query Parameters**
386
- * ```ts
387
- * type QueryParameters = {
388
- * client_id: string
389
- * scope: string
390
- * state: string
391
- * }
392
- * ```
393
- *
394
- * ---
395
- *
396
- * **Response**
397
- * ```ts
398
- * type Response = string
399
- * ```
400
- */
401
- consent<
402
- Config extends Alova2MethodConfig<string> & {
403
- params: {
404
- client_id: string;
405
- scope: string;
406
- state: string;
407
- };
408
- }
409
- >(
410
- config: Config
411
- ): Alova2Method<string, 'authorizationRestful.consent', Config>;
412
- /**
413
- * ---
414
- *
415
- * [GET]
416
- *
417
- * **path:** /互联/服务/授权/客户端介绍
418
- *
419
- * ---
420
- *
421
- * **Query Parameters**
422
- * ```ts
423
- * type QueryParameters = {
424
- * client_id: string
425
- * }
426
- * ```
427
- *
428
- * ---
429
- *
430
- * **Response**
431
- * ```ts
432
- * type Response = {
433
- * status?: number
434
- * clientDescription?: string
435
- * }
436
- * ```
437
- */
438
- getClientDescription<
439
- Config extends Alova2MethodConfig<GetClientResponse> & {
440
- params: {
441
- client_id: string;
442
- };
443
- }
444
- >(
445
- config: Config
446
- ): Alova2Method<GetClientResponse, 'authorizationRestful.getClientDescription', Config>;
447
- };
448
- }
449
-
450
- var oauthApi: oauthApi;
451
- }
@@ -1 +0,0 @@
1
- export * from './oauth';
@@ -1,19 +0,0 @@
1
- import { OAuth } from '@core/api/oauth/oauth';
2
- import { alovaInstance } from '@core/api/oauth/alova';
3
-
4
- export class AlovaOAuth extends OAuth{
5
- static override async getYincToken(code: string, redirect_uri: string,client_id: string,code_verifier: string) {
6
- const formData = new FormData();
7
- formData.append('code', code)
8
- formData.append('grant_type', 'authorization_code')
9
- formData.append('redirect_uri', redirect_uri)
10
- formData.append('client_id', client_id)
11
- formData.append('code_verifier', code_verifier)
12
- const method = alovaInstance.Post<string>('/互联/服务/互联/令牌',formData,{
13
- transform(data){
14
- return (data as { access_token: string }).access_token
15
- }
16
- })
17
- return method.send()
18
- }
19
- }
@@ -1,22 +0,0 @@
1
- import { createAlova } from 'alova';
2
- import fetchAdapter from 'alova/fetch';
3
- import { createApis, withConfigType, mountApis } from './createApis';
4
- import { responded } from '@core/api/config/alova';
5
- import { getServiceEndpoint, ServiceType } from '@core/api/config';
6
-
7
- export const alovaInstance = createAlova({
8
- baseURL: getServiceEndpoint(ServiceType.OAuth),
9
- requestAdapter: fetchAdapter(),
10
- cacheFor: null,
11
- responded: responded
12
- });
13
-
14
- export const $$userConfigMap = withConfigType({});
15
-
16
- const Apis = createApis(alovaInstance, $$userConfigMap);
17
-
18
- mountApis(Apis);
19
-
20
- export default Apis;
21
-
22
-
@@ -1,2 +0,0 @@
1
- export * from './oauth';
2
- export * from './alova/index';
@@ -1,15 +0,0 @@
1
- import type { IBuilder } from 'builder-pattern';
2
- import { Builder } from 'builder-pattern';
3
- export abstract class OAuth {
4
- static _default: typeof OAuth
5
- static builder(): IBuilder<OAuth>{
6
- return Builder(this._default) as unknown as IBuilder<OAuth>;
7
- }
8
- static default(): typeof OAuth {
9
- return this._default as unknown as typeof OAuth;
10
- }
11
- static getYincToken(code: string, redirect_uri: string,client_id: string,code_verifier: string): Promise<string>{
12
- return OAuth.default().getYincToken(code, redirect_uri,client_id,code_verifier)
13
- }
14
- }
15
-
@@ -1,27 +0,0 @@
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
- 'queuerRestful.getQueuerState': ['GET', '/门诊/服务/排队/{id}'],
20
- 'queuerRestful.putQueuerState': ['PUT', '/门诊/服务/排队/{id}'],
21
- 'queuerRestful.deleteQueuerState': ['DELETE', '/门诊/服务/排队/{id}'],
22
- 'queuerRestful.queryQueuerState': ['GET', '/门诊/服务/排队'],
23
- 'queuerRestful.postQueuerState': ['POST', '/门诊/服务/排队'],
24
- 'metricRestful.datesOfQueuerState': ['GET', '/门诊/服务/统计/排队/日期'],
25
- 'metricRestful.totalOfQueuerState': ['GET', '/门诊/服务/统计/排队/总数'],
26
- 'metricRestful.totalOfQueuerTodayState': ['GET', '/门诊/服务/统计/排队/今日']
27
- };
@@ -1,99 +0,0 @@
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 outpatientApi, {
72
- get(_, property) {
73
- return createFunctionalProxy([property], alovaInstance, configMap);
74
- }
75
- });
76
- return Apis;
77
- };
78
- export const mountApis = (Apis: outpatientApi) => {
79
- // define global variable `Apis`
80
- (globalThis as any).outpatientApi = 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 outpatientApi
88
- ? Url extends keyof outpatientApi[Tag]
89
- ? outpatientApi[Tag][Url] extends (...args: any) => any
90
- ? Parameters<outpatientApi[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;