axios-annotations 1.3.4 → 2.0.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 (98) hide show
  1. package/README.md +248 -105
  2. package/index.d.ts +1 -0
  3. package/index.js +121 -0
  4. package/lib/core/cancel.d.ts +30 -0
  5. package/lib/core/cancel.js +56 -0
  6. package/lib/core/common.d.ts +6 -0
  7. package/lib/core/common.js +166 -1
  8. package/lib/core/config.d.ts +60 -29
  9. package/lib/core/config.js +332 -1
  10. package/lib/core/parser.d.ts +19 -15
  11. package/lib/core/parser.js +79 -1
  12. package/lib/core/provider.d.ts +6 -0
  13. package/lib/core/provider.js +172 -0
  14. package/lib/core/service.d.ts +153 -33
  15. package/lib/core/service.js +562 -1
  16. package/lib/decorator/abort-source.d.ts +3 -9
  17. package/lib/decorator/abort-source.js +25 -1
  18. package/lib/decorator/delete-mapping.d.ts +1 -3
  19. package/lib/decorator/delete-mapping.js +13 -1
  20. package/lib/decorator/get-mapping.d.ts +1 -3
  21. package/lib/decorator/get-mapping.js +13 -1
  22. package/lib/decorator/ignore-residual-params.d.ts +1 -3
  23. package/lib/decorator/ignore-residual-params.js +24 -1
  24. package/lib/decorator/patch-mapping.d.ts +1 -3
  25. package/lib/decorator/patch-mapping.js +13 -1
  26. package/lib/decorator/post-mapping.d.ts +1 -3
  27. package/lib/decorator/post-mapping.js +13 -1
  28. package/lib/decorator/put-mapping.d.ts +1 -3
  29. package/lib/decorator/put-mapping.js +13 -1
  30. package/lib/decorator/request-body.d.ts +1 -3
  31. package/lib/decorator/request-body.js +28 -1
  32. package/lib/decorator/request-config.d.ts +5 -7
  33. package/lib/decorator/request-config.js +23 -1
  34. package/lib/decorator/request-header.d.ts +2 -5
  35. package/lib/decorator/request-header.js +21 -1
  36. package/lib/decorator/request-mapping.d.ts +3 -6
  37. package/lib/decorator/request-mapping.js +58 -1
  38. package/lib/decorator/request-param.d.ts +1 -3
  39. package/lib/decorator/request-param.js +27 -1
  40. package/lib/decorator/request-with.d.ts +1 -3
  41. package/lib/decorator/request-with.js +20 -1
  42. package/lib/index.d.ts +19 -0
  43. package/lib/index.js +139 -0
  44. package/lib/plugins/auth/authorizer.d.ts +23 -49
  45. package/lib/plugins/auth/authorizer.js +271 -1
  46. package/lib/plugins/auth/history.d.ts +14 -15
  47. package/lib/plugins/auth/history.js +96 -1
  48. package/lib/plugins/auth/index.d.ts +9 -4
  49. package/lib/plugins/auth/index.js +368 -1
  50. package/lib/plugins/auth/queue.d.ts +28 -16
  51. package/lib/plugins/auth/queue.js +270 -1
  52. package/lib/plugins/auth/storage.d.ts +6 -7
  53. package/lib/plugins/auth/storage.js +207 -1
  54. package/package.json +16 -16
  55. package/plugins/auth/index.d.ts +4 -4
  56. package/plugins/auth/index.js +26 -1
  57. package/core/config.d.ts +0 -29
  58. package/core/config.js +0 -1
  59. package/core/parser.d.ts +0 -15
  60. package/core/parser.js +0 -1
  61. package/core/service.d.ts +0 -33
  62. package/core/service.js +0 -1
  63. package/decorator/abort-source.d.ts +0 -9
  64. package/decorator/abort-source.js +0 -1
  65. package/decorator/delete-mapping.d.ts +0 -1
  66. package/decorator/delete-mapping.js +0 -1
  67. package/decorator/get-mapping.d.ts +0 -1
  68. package/decorator/get-mapping.js +0 -1
  69. package/decorator/ignore-residual-params.d.ts +0 -1
  70. package/decorator/ignore-residual-params.js +0 -1
  71. package/decorator/patch-mapping.d.ts +0 -1
  72. package/decorator/patch-mapping.js +0 -1
  73. package/decorator/post-mapping.d.ts +0 -1
  74. package/decorator/post-mapping.js +0 -1
  75. package/decorator/put-mapping.d.ts +0 -3
  76. package/decorator/put-mapping.js +0 -1
  77. package/decorator/request-body.d.ts +0 -3
  78. package/decorator/request-body.js +0 -1
  79. package/decorator/request-config.d.ts +0 -29
  80. package/decorator/request-config.js +0 -1
  81. package/decorator/request-header.d.ts +0 -1
  82. package/decorator/request-header.js +0 -1
  83. package/decorator/request-mapping.d.ts +0 -1
  84. package/decorator/request-mapping.js +0 -1
  85. package/decorator/request-param.d.ts +0 -1
  86. package/decorator/request-param.js +0 -1
  87. package/decorator/request-with.d.ts +0 -1
  88. package/decorator/request-with.js +0 -1
  89. package/lib/plugins/cache/index.js +0 -1
  90. package/plugins/auth/authorizer.d.ts +0 -49
  91. package/plugins/auth/authorizer.js +0 -1
  92. package/plugins/auth/history.d.ts +0 -15
  93. package/plugins/auth/history.js +0 -1
  94. package/plugins/auth/queue.d.ts +0 -16
  95. package/plugins/auth/queue.js +0 -1
  96. package/plugins/auth/storage.d.ts +0 -7
  97. package/plugins/auth/storage.js +0 -1
  98. package/plugins/cache/index.js +0 -1
package/core/service.d.ts DELETED
@@ -1,33 +0,0 @@
1
- import Config from "./config";
2
- import {AxiosPromise, AxiosRequestConfig} from "axios";
3
- import {AbortControllerAdapter} from "../decorator/abort-source";
4
-
5
- export interface RequestController {
6
- ignoreResidualParams: (ignore?: boolean) => RequestController;
7
-
8
- param: (key: string, required?: boolean) => RequestController;
9
-
10
- header: (header: string, value: string | ((...args: any[]) => string)) => RequestController;
11
-
12
- body: (key: string) => RequestController;
13
-
14
- config: (config: Partial<AxiosRequestConfig>) => RequestController;
15
-
16
- send: (data?: Record<string, any>) => AxiosPromise<any>;
17
-
18
- with: (registration: string) => RequestController;
19
-
20
- abort: (abortController: (AbortController | AbortControllerAdapter) | ((...args: any[]) => (AbortControllerAdapter | AbortController))) => RequestController;
21
- }
22
-
23
- export default class Service {
24
- constructor(path?: string);
25
-
26
- config: Config;
27
-
28
- path: string;
29
-
30
- request(method: string, path: string, data?: any, config?: Partial<AxiosRequestConfig>): AxiosPromise<any>;
31
-
32
- requestWith(method: string, path?: string): RequestController;
33
- }
package/core/service.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require("../lib/core/service");
@@ -1,9 +0,0 @@
1
- import {CancelToken} from "axios";
2
-
3
- export class AbortControllerAdapter {
4
- constructor(CancelToken: CancelToken);
5
-
6
- abort(reason?: string): void;
7
- }
8
-
9
- export default function AbortSource(abortController: (AbortController | AbortControllerAdapter) | ((...args: any[]) => (AbortController | AbortControllerAdapter))): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/abort-source");
@@ -1 +0,0 @@
1
- export default function DeleteMapping(path?: string): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/delete-mapping");
@@ -1 +0,0 @@
1
- export default function GetMapping(path?: string): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/get-mapping");
@@ -1 +0,0 @@
1
- export default function IgnoreResidualParams(ignore?: boolean): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/ignore-residual-params");
@@ -1 +0,0 @@
1
- export default function PatchMapping(path?: string): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/patch-mapping");
@@ -1 +0,0 @@
1
- export default function PostMapping(path?: string): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/post-mapping");
@@ -1,3 +0,0 @@
1
- import {AxiosPromise} from "axios";
2
-
3
- export default function PutMapping(path?: string): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/put-mapping");
@@ -1,3 +0,0 @@
1
- import {AxiosPromise} from "axios";
2
-
3
- export default function RequestBody(name?: string): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/request-body");
@@ -1,29 +0,0 @@
1
- import {AxiosInstance, AxiosRequestConfig} from "axios";
2
-
3
- declare class Config {
4
- constructor(protocol?: string, host?: string, port?: number, prefix?: string, plugins?: ((config: Config) => void)[]);
5
-
6
- static forName(name: string): Config;
7
-
8
- host: string;
9
-
10
- port: number | null | string;
11
-
12
- protocol: string;
13
-
14
- prefix: string;
15
-
16
- origin: string;
17
-
18
- baseURL: string;
19
-
20
- axios: AxiosInstance;
21
-
22
- plugins: ((config: Config) => void)[];
23
-
24
- register(name: string): Config;
25
-
26
- unregister(): Config;
27
- }
28
-
29
- export default function RequestConfig(config: Config | ((...args: any[]) => Partial<AxiosRequestConfig>) | Partial<AxiosRequestConfig>): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/request-config");
@@ -1 +0,0 @@
1
- export default function RequestHeader(header: string, value: string | ((...args: any[]) => string)): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/request-header");
@@ -1 +0,0 @@
1
- export default function RequestMapping(path: string, method?: string): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/request-mapping");
@@ -1 +0,0 @@
1
- export default function RequestParam(name: string, required?: boolean): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/request-param");
@@ -1 +0,0 @@
1
- export default function RequestWith(registration: string): ((target: any) => any);
@@ -1 +0,0 @@
1
- module.exports = require("../lib/decorator/request-with");
@@ -1 +0,0 @@
1
- function CachePlugin(){return function(e){var t=e.axios.defaults.adapter;e.axios.defaults.adapter=function(e){return t(e)}}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=CachePlugin;
@@ -1,49 +0,0 @@
1
- import {AxiosError, AxiosPromise, AxiosRequestConfig} from "axios";
2
- import SessionStorage from "./storage";
3
- import SessionHistory from "./history";
4
-
5
- export interface Session {
6
- access_token?: string;
7
-
8
- refresh_token?: string;
9
-
10
- token?: string;
11
-
12
- accessToken?: string;
13
-
14
- refreshToken?: string;
15
-
16
- expires_in?: number;
17
-
18
- expiresIn?: number;
19
-
20
- scope?: string;
21
-
22
- token_type?: string;
23
- }
24
-
25
- export default class Authorizer {
26
- sessionKey: string;
27
-
28
- sessionStorage: SessionStorage;
29
-
30
- sessionHistory: SessionHistory;
31
-
32
- getSession(): Promise<Partial<Session>>;
33
-
34
- storageSession(session: Session): Promise<void>;
35
-
36
- refreshSession(session: Session): Promise<Partial<Session>> | Promise<Record<string, any>> | Promise<any>;
37
-
38
- withAuthentication(request: AxiosRequestConfig, session: Partial<Session>): void;
39
-
40
- checkSession(request: AxiosRequestConfig, session: Partial<Session>): boolean;
41
-
42
- checkResponse(response: Response): boolean;
43
-
44
- onAuthorizedDenied(error: AxiosError): Promise<void>;
45
-
46
- onSessionInvalidated(): void;
47
-
48
- invalidateSession(): Promise<void>;
49
- }
@@ -1 +0,0 @@
1
- module.exports = require("../../lib/plugins/auth/authorizer");
@@ -1,15 +0,0 @@
1
- import {Session} from "./authorizer";
2
-
3
- export default class SessionHistory {
4
- add(session: Session): void;
5
-
6
- check(jwt: string): boolean;
7
-
8
- deprecate(session: Session): void;
9
-
10
- clean(): void;
11
-
12
- isDeprecated(session: Session): boolean;
13
-
14
- size: number;
15
- }
@@ -1 +0,0 @@
1
- module.exports = require("../../lib/plugins/auth/history");
@@ -1,16 +0,0 @@
1
- import {AxiosError, AxiosPromise} from "axios";
2
- import Authorizer from "./authorizer";
3
-
4
- export default class PendingQueue {
5
- constructor(authorizer: Authorizer);
6
-
7
- resend(error: AxiosError, retries?: number): AxiosPromise<any>;
8
-
9
- push(error: AxiosError): AxiosPromise<any>;
10
-
11
- pop(): void;
12
-
13
- clear(): void;
14
-
15
- size: number;
16
- }
@@ -1 +0,0 @@
1
- module.exports = require("../../lib/plugins/auth/queue");
@@ -1,7 +0,0 @@
1
- export default class SessionStorage {
2
- set(key: string, value: any): Promise<void>;
3
-
4
- get(key: string): Promise<any>;
5
-
6
- remove(key: string): Promise<void>;
7
- }
@@ -1 +0,0 @@
1
- module.exports = require("../../lib/plugins/auth/storage");
@@ -1 +0,0 @@
1
- module.exports = require("../../lib/plugins/cache/index");