axios-annotations 2.3.0 → 3.1.0

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 (140) hide show
  1. package/README.md +774 -741
  2. package/es/core/builder.d.ts +33 -0
  3. package/es/core/builder.js +515 -0
  4. package/es/core/common.d.ts +36 -0
  5. package/es/core/common.js +148 -0
  6. package/es/core/config.d.ts +60 -0
  7. package/es/core/config.js +357 -0
  8. package/es/core/core-expect.js +3 -0
  9. package/es/core/expect.d.ts +2 -0
  10. package/es/core/expect.js +2 -0
  11. package/es/core/provider.d.ts +6 -0
  12. package/es/core/provider.js +172 -0
  13. package/es/core/service.d.ts +5 -0
  14. package/es/core/service.js +57 -0
  15. package/es/decorator/path-variables.d.ts +7 -0
  16. package/es/decorator/path-variables.js +32 -0
  17. package/es/decorator/request-body.d.ts +7 -0
  18. package/es/decorator/request-body.js +31 -0
  19. package/es/decorator/request-config.d.ts +7 -0
  20. package/es/decorator/request-config.js +25 -0
  21. package/es/decorator/request-header.d.ts +4 -0
  22. package/es/decorator/request-header.js +14 -0
  23. package/es/decorator/request-mapping.d.ts +6 -0
  24. package/es/decorator/request-mapping.js +56 -0
  25. package/es/decorator/request-param.d.ts +4 -0
  26. package/es/decorator/request-param.js +15 -0
  27. package/es/decorator/request-with.d.ts +3 -0
  28. package/es/decorator/request-with.js +8 -0
  29. package/es/index.d.ts +13 -0
  30. package/es/index.js +14 -0
  31. package/es/plugins/auth/authorizer.d.ts +24 -0
  32. package/es/plugins/auth/authorizer.js +268 -0
  33. package/es/plugins/auth/history.d.ts +15 -0
  34. package/es/plugins/auth/history.js +94 -0
  35. package/es/plugins/auth/index.d.ts +16 -0
  36. package/es/plugins/auth/index.js +358 -0
  37. package/es/plugins/auth/queue.d.ts +29 -0
  38. package/es/plugins/auth/queue.js +281 -0
  39. package/es/plugins/auth/storage.d.ts +6 -0
  40. package/es/plugins/auth/storage.js +203 -0
  41. package/lib/core/builder.d.ts +33 -0
  42. package/lib/core/builder.js +520 -0
  43. package/lib/core/common.d.ts +34 -4
  44. package/lib/core/common.js +139 -147
  45. package/lib/core/config.d.ts +15 -15
  46. package/lib/core/config.js +44 -14
  47. package/lib/core/core-expect.js +8 -0
  48. package/lib/core/expect.d.ts +2 -4
  49. package/lib/core/expect.js +6 -15
  50. package/lib/core/provider.d.ts +5 -5
  51. package/lib/core/provider.js +2 -2
  52. package/lib/core/service.d.ts +3 -151
  53. package/lib/core/service.js +43 -544
  54. package/lib/decorator/path-variables.d.ts +7 -0
  55. package/lib/decorator/path-variables.js +37 -0
  56. package/lib/decorator/request-body.d.ts +7 -1
  57. package/lib/decorator/request-body.js +28 -20
  58. package/lib/decorator/request-config.d.ts +6 -4
  59. package/lib/decorator/request-config.js +23 -16
  60. package/lib/decorator/request-header.d.ts +4 -2
  61. package/lib/decorator/request-header.js +11 -13
  62. package/lib/decorator/request-mapping.d.ts +6 -3
  63. package/lib/decorator/request-mapping.js +46 -43
  64. package/lib/decorator/request-param.d.ts +4 -1
  65. package/lib/decorator/request-param.js +12 -19
  66. package/lib/decorator/request-with.d.ts +3 -1
  67. package/lib/decorator/request-with.js +6 -13
  68. package/lib/index.d.ts +4 -11
  69. package/lib/index.js +19 -68
  70. package/lib/plugins/auth/authorizer.d.ts +6 -5
  71. package/lib/plugins/auth/authorizer.js +3 -2
  72. package/lib/plugins/auth/history.d.ts +5 -4
  73. package/lib/plugins/auth/history.js +2 -0
  74. package/lib/plugins/auth/index.d.ts +7 -0
  75. package/lib/plugins/auth/index.js +11 -3
  76. package/lib/plugins/auth/queue.d.ts +3 -2
  77. package/lib/plugins/auth/queue.js +31 -24
  78. package/lib/plugins/auth/storage.js +2 -2
  79. package/package.json +42 -7
  80. package/wechat-mp/core/builder.d.ts +33 -0
  81. package/wechat-mp/core/builder.js +520 -0
  82. package/wechat-mp/core/common.d.ts +36 -0
  83. package/wechat-mp/core/common.js +158 -0
  84. package/wechat-mp/core/config.d.ts +60 -0
  85. package/wechat-mp/core/config.js +362 -0
  86. package/wechat-mp/core/core-expect.js +8 -0
  87. package/wechat-mp/core/expect.d.ts +2 -0
  88. package/wechat-mp/core/expect.js +6 -0
  89. package/wechat-mp/core/provider.d.ts +6 -0
  90. package/wechat-mp/core/provider.js +178 -0
  91. package/wechat-mp/core/service.d.ts +5 -0
  92. package/wechat-mp/core/service.js +61 -0
  93. package/wechat-mp/decorator/path-variables.d.ts +7 -0
  94. package/wechat-mp/decorator/path-variables.js +37 -0
  95. package/wechat-mp/decorator/request-body.d.ts +7 -0
  96. package/wechat-mp/decorator/request-body.js +36 -0
  97. package/wechat-mp/decorator/request-config.d.ts +7 -0
  98. package/wechat-mp/decorator/request-config.js +30 -0
  99. package/wechat-mp/decorator/request-header.d.ts +4 -0
  100. package/wechat-mp/decorator/request-header.js +19 -0
  101. package/wechat-mp/decorator/request-mapping.d.ts +6 -0
  102. package/wechat-mp/decorator/request-mapping.js +61 -0
  103. package/wechat-mp/decorator/request-param.d.ts +4 -0
  104. package/wechat-mp/decorator/request-param.js +20 -0
  105. package/wechat-mp/decorator/request-with.d.ts +3 -0
  106. package/wechat-mp/decorator/request-with.js +13 -0
  107. package/wechat-mp/index.d.ts +13 -0
  108. package/wechat-mp/index.js +97 -0
  109. package/wechat-mp/plugins/auth/authorizer.d.ts +24 -0
  110. package/wechat-mp/plugins/auth/authorizer.js +272 -0
  111. package/wechat-mp/plugins/auth/history.d.ts +15 -0
  112. package/wechat-mp/plugins/auth/history.js +98 -0
  113. package/wechat-mp/plugins/auth/index.d.ts +16 -0
  114. package/wechat-mp/plugins/auth/index.js +376 -0
  115. package/wechat-mp/plugins/auth/queue.d.ts +29 -0
  116. package/wechat-mp/plugins/auth/queue.js +285 -0
  117. package/wechat-mp/plugins/auth/storage.d.ts +6 -0
  118. package/wechat-mp/plugins/auth/storage.js +207 -0
  119. package/index.d.ts +0 -1
  120. package/index.js +0 -127
  121. package/lib/core/cancel.d.ts +0 -30
  122. package/lib/core/cancel.js +0 -56
  123. package/lib/core/parser.d.ts +0 -19
  124. package/lib/core/parser.js +0 -79
  125. package/lib/decorator/abort-source.d.ts +0 -3
  126. package/lib/decorator/abort-source.js +0 -25
  127. package/lib/decorator/delete-mapping.d.ts +0 -1
  128. package/lib/decorator/delete-mapping.js +0 -13
  129. package/lib/decorator/get-mapping.d.ts +0 -1
  130. package/lib/decorator/get-mapping.js +0 -13
  131. package/lib/decorator/ignore-residual-params.d.ts +0 -1
  132. package/lib/decorator/ignore-residual-params.js +0 -24
  133. package/lib/decorator/patch-mapping.d.ts +0 -1
  134. package/lib/decorator/patch-mapping.js +0 -13
  135. package/lib/decorator/post-mapping.d.ts +0 -1
  136. package/lib/decorator/post-mapping.js +0 -13
  137. package/lib/decorator/put-mapping.d.ts +0 -1
  138. package/lib/decorator/put-mapping.js +0 -13
  139. package/plugins/auth/index.d.ts +0 -4
  140. package/plugins/auth/index.js +0 -26
@@ -1,153 +1,5 @@
1
- import type { AxiosRequestConfig, AxiosResponse, CancelTokenSource } from "axios";
2
- import AbortControllerAdapter from "./cancel";
3
- import Config from "./config";
4
- export type HeaderMappingValueType = string | ((...args: any[]) => string);
5
- export type AxiosConfigOptionMappingType = keyof AxiosRequestConfig | ((...args: any[]) => (keyof AxiosRequestConfig));
6
- export type AbortControllerGenerator = ((...args: any[]) => (AbortController | AbortControllerAdapter));
7
- export type QueryStringEncodeFeatures = {
8
- ignoreResidualParams?: boolean;
9
- abortController?: (AbortController | AbortControllerAdapter) | AbortControllerGenerator;
10
- };
11
- export type RequestParamEncodeRule = {
12
- body?: boolean;
13
- required?: boolean;
14
- };
15
- export type NextAbortVersionAxiosRequestConfig = AxiosRequestConfig & {
16
- signal: AbortSignal;
17
- };
18
- export declare const ConfigMapping: {
19
- requestHeaders(rules: Record<string, HeaderMappingValueType>, args?: any[]): Record<string, string>;
20
- axiosConfig<D = any>(options: AxiosConfigOptionMappingType[], args: any[]): AxiosRequestConfig<D>;
21
- querystring(features: QueryStringEncodeFeatures | null, rules: Record<string, RequestParamEncodeRule>, data: Record<string, any>): string;
22
- /**
23
- * 从参数对象中提取 body 所属字段
24
- * @param rules
25
- * @param data
26
- */
27
- body(rules: Record<string, RequestParamEncodeRule>, data: Record<string, any>): any;
28
- };
29
1
  export default class Service {
30
- _path: string;
31
- _config: Config;
32
- _headers: Record<string, Record<string, HeaderMappingValueType>>;
33
- _params: Record<string, Record<string, RequestParamEncodeRule>>;
34
- _configs: Record<string, AxiosConfigOptionMappingType[]>;
35
- _for: Record<string, string>;
36
- _features: Record<string, QueryStringEncodeFeatures>;
37
- constructor(path?: any);
38
- get config(): Config;
39
- set config(value: Config);
40
- get path(): string;
41
- set path(value: string);
42
- params(id: string, name: string, config?: RequestParamEncodeRule): void;
43
- headers(id: string, header: string, value: HeaderMappingValueType): void;
44
- for(id: string, registrationName?: string): string;
45
- abort(id: string, abortController: (AbortController | AbortControllerAdapter | AbortControllerGenerator)): void;
46
- features(id: string, options?: QueryStringEncodeFeatures): QueryStringEncodeFeatures;
47
- configs(id: string, options: AxiosConfigOptionMappingType): void;
48
- /**
49
- * 填充路径占位符 <br/>
50
- * override this method to custom placeholder replacement <br>
51
- * default implement: data = { id: 111 }; <br/>
52
- * "/path/{id}" -> return "/path/111"
53
- * @param path
54
- * @param data
55
- */
56
- pathVariable(path: string, data: Record<string, any>): string;
57
- createRequestConfig(id: string, path: string, data: Record<string, any>, headerArgs?: any[], configArgs?: AxiosConfigOptionMappingType[]): {
58
- path: string;
59
- body: any;
60
- config: AxiosRequestConfig<any>;
61
- query: string;
62
- };
63
- request<T = any, R = AxiosResponse<T>, D = any>(method: string, path: string, data?: Record<string, any>, config?: AxiosRequestConfig<D>): Promise<R>;
64
- requestWith<T = any, R = AxiosResponse<T>, D = any>(method: string, path?: string): {
65
- with(registration: string): {
66
- with(registration: string): any;
67
- param: (key: string, required?: boolean) => any;
68
- abort(abortController: ((AbortController & {
69
- source: CancelTokenSource;
70
- }) | AbortControllerGenerator)): any;
71
- ignoreResidualParams(ignore?: boolean): any;
72
- header: (header: string, value: HeaderMappingValueType) => any;
73
- body: (key: string) => any;
74
- config: (cfg: AxiosConfigOptionMappingType) => any;
75
- send: (data?: Record<string, any>) => (Promise<R>);
76
- };
77
- param: (key: string, required?: boolean) => {
78
- with(registration: string): any;
79
- param: (key: string, required?: boolean) => any;
80
- abort(abortController: ((AbortController & {
81
- source: CancelTokenSource;
82
- }) | AbortControllerGenerator)): any;
83
- ignoreResidualParams(ignore?: boolean): any;
84
- header: (header: string, value: HeaderMappingValueType) => any;
85
- body: (key: string) => any;
86
- config: (cfg: AxiosConfigOptionMappingType) => any;
87
- send: (data?: Record<string, any>) => (Promise<R>);
88
- };
89
- abort(abortController: ((AbortController & {
90
- source: CancelTokenSource;
91
- }) | AbortControllerGenerator)): {
92
- with(registration: string): any;
93
- param: (key: string, required?: boolean) => any;
94
- abort(abortController: ((AbortController & {
95
- source: CancelTokenSource;
96
- }) | AbortControllerGenerator)): any;
97
- ignoreResidualParams(ignore?: boolean): any;
98
- header: (header: string, value: HeaderMappingValueType) => any;
99
- body: (key: string) => any;
100
- config: (cfg: AxiosConfigOptionMappingType) => any;
101
- send: (data?: Record<string, any>) => (Promise<R>);
102
- };
103
- ignoreResidualParams(ignore?: boolean): {
104
- with(registration: string): any;
105
- param: (key: string, required?: boolean) => any;
106
- abort(abortController: ((AbortController & {
107
- source: CancelTokenSource;
108
- }) | AbortControllerGenerator)): any;
109
- ignoreResidualParams(ignore?: boolean): any;
110
- header: (header: string, value: HeaderMappingValueType) => any;
111
- body: (key: string) => any;
112
- config: (cfg: AxiosConfigOptionMappingType) => any;
113
- send: (data?: Record<string, any>) => (Promise<R>);
114
- };
115
- header: (header: string, value: HeaderMappingValueType) => {
116
- with(registration: string): any;
117
- param: (key: string, required?: boolean) => any;
118
- abort(abortController: ((AbortController & {
119
- source: CancelTokenSource;
120
- }) | AbortControllerGenerator)): any;
121
- ignoreResidualParams(ignore?: boolean): any;
122
- header: (header: string, value: HeaderMappingValueType) => any;
123
- body: (key: string) => any;
124
- config: (cfg: AxiosConfigOptionMappingType) => any;
125
- send: (data?: Record<string, any>) => (Promise<R>);
126
- };
127
- body: (key: string) => {
128
- with(registration: string): any;
129
- param: (key: string, required?: boolean) => any;
130
- abort(abortController: ((AbortController & {
131
- source: CancelTokenSource;
132
- }) | AbortControllerGenerator)): any;
133
- ignoreResidualParams(ignore?: boolean): any;
134
- header: (header: string, value: HeaderMappingValueType) => any;
135
- body: (key: string) => any;
136
- config: (cfg: AxiosConfigOptionMappingType) => any;
137
- send: (data?: Record<string, any>) => (Promise<R>);
138
- };
139
- config: (cfg: AxiosConfigOptionMappingType) => {
140
- with(registration: string): any;
141
- param: (key: string, required?: boolean) => any;
142
- abort(abortController: ((AbortController & {
143
- source: CancelTokenSource;
144
- }) | AbortControllerGenerator)): any;
145
- ignoreResidualParams(ignore?: boolean): any;
146
- header: (header: string, value: HeaderMappingValueType) => any;
147
- body: (key: string) => any;
148
- config: (cfg: AxiosConfigOptionMappingType) => any;
149
- send: (data?: Record<string, any>) => (Promise<R>);
150
- };
151
- send: (data?: Record<string, any>) => (Promise<R>);
152
- };
2
+ config: import("./config").default;
3
+ path: string;
4
+ constructor();
153
5
  }