axios-annotations 1.3.0 → 1.3.2
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/core/config.d.ts +29 -0
- package/core/parser.d.ts +15 -0
- package/core/service.d.ts +33 -0
- package/decorator/abort-source.d.ts +9 -0
- package/decorator/delete-mapping.d.ts +1 -0
- package/decorator/get-mapping.d.ts +1 -0
- package/decorator/ignore-residual-params.d.ts +1 -0
- package/decorator/patch-mapping.d.ts +1 -0
- package/decorator/post-mapping.d.ts +1 -0
- package/decorator/put-mapping.d.ts +3 -0
- package/decorator/request-body.d.ts +3 -0
- package/decorator/request-config.d.ts +29 -0
- package/decorator/request-header.d.ts +1 -0
- package/decorator/request-mapping.d.ts +1 -0
- package/decorator/request-param.d.ts +1 -0
- package/decorator/request-with.d.ts +1 -0
- package/lib/plugins/cache/index.js +1 -0
- package/package.json +1 -1
- package/plugins/auth/authorizer.d.ts +49 -0
- package/plugins/auth/history.d.ts +15 -0
- package/plugins/auth/index.d.ts +4 -0
- package/plugins/auth/queue.d.ts +16 -0
- package/plugins/auth/storage.d.ts +7 -0
- package/plugins/cache/index.js +1 -0
package/core/config.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {AxiosInstance} from "axios";
|
|
2
|
+
|
|
3
|
+
export default 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 const config: Config;
|
package/core/parser.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const URLSearchParamsParser: {
|
|
2
|
+
encode: (encoder: object) => string;
|
|
3
|
+
|
|
4
|
+
decode: (data: object) => object;
|
|
5
|
+
|
|
6
|
+
has: (encoder: object, key: string) => boolean;
|
|
7
|
+
|
|
8
|
+
delete: (encoder: object, key: string) => void;
|
|
9
|
+
|
|
10
|
+
get: (encoder: object, key: string) => any;
|
|
11
|
+
|
|
12
|
+
append: (encoder: object, key: string, value: any) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default URLSearchParamsParser;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function DeleteMapping(path?: string): ((target: any) => any);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function GetMapping(path?: string): ((target: any) => any);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function IgnoreResidualParams(ignore?: boolean): ((target: any) => any);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PatchMapping(path?: string): ((target: any) => any);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PostMapping(path?: string): ((target: any) => any);
|
|
@@ -0,0 +1,29 @@
|
|
|
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);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function RequestHeader(header: string, value: string | ((...args: any[]) => string)): ((target: any) => any);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function RequestMapping(path: string, method?: string): ((target: any) => any);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function RequestParam(name: string, required?: boolean): ((target: any) => any);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function RequestWith(registration: string): ((target: any) => any);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";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;
|
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("../../lib/plugins/cache/index");
|