@biorate/axios 0.28.0 → 0.30.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.
@@ -0,0 +1,63 @@
1
+ TN:
2
+ SF:src/index.ts
3
+ FN:41,(anonymous_6)
4
+ FN:49,(anonymous_7)
5
+ FN:55,(anonymous_8)
6
+ FN:68,(anonymous_9)
7
+ FN:93,(anonymous_10)
8
+ FN:98,(anonymous_11)
9
+ FN:104,(anonymous_12)
10
+ FNF:7
11
+ FNH:7
12
+ FNDA:3,(anonymous_6)
13
+ FNDA:3,(anonymous_7)
14
+ FNDA:3,(anonymous_8)
15
+ FNDA:3,(anonymous_9)
16
+ FNDA:3,(anonymous_10)
17
+ FNDA:1,(anonymous_11)
18
+ FNDA:2,(anonymous_12)
19
+ DA:1,1
20
+ DA:2,1
21
+ DA:3,1
22
+ DA:4,1
23
+ DA:7,1
24
+ DA:9,1
25
+ DA:16,1
26
+ DA:41,1
27
+ DA:45,1
28
+ DA:50,3
29
+ DA:58,3
30
+ DA:59,3
31
+ DA:64,3
32
+ DA:69,3
33
+ DA:70,3
34
+ DA:71,3
35
+ DA:73,3
36
+ DA:74,3
37
+ DA:75,0
38
+ DA:76,3
39
+ DA:77,0
40
+ DA:78,3
41
+ DA:81,3
42
+ DA:82,3
43
+ DA:83,3
44
+ DA:85,2
45
+ DA:87,3
46
+ DA:99,1
47
+ LF:28
48
+ LH:26
49
+ BRDA:58,0,0,3
50
+ BRDA:58,0,1,0
51
+ BRDA:69,1,0,3
52
+ BRDA:69,1,1,0
53
+ BRDA:74,2,0,0
54
+ BRDA:74,2,1,3
55
+ BRDA:74,3,0,3
56
+ BRDA:74,3,1,3
57
+ BRDA:76,4,0,0
58
+ BRDA:76,4,1,3
59
+ BRDA:76,5,0,3
60
+ BRDA:76,5,1,0
61
+ BRF:12
62
+ BRH:7
63
+ end_of_record
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biorate/axios",
3
- "version": "0.28.0",
3
+ "version": "0.30.2",
4
4
  "description": "Axios OOP static interface",
5
5
  "main": "dist",
6
6
  "scripts": {
@@ -29,8 +29,8 @@
29
29
  "path-to-url": "^0.1.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@biorate/config": "0.28.0",
33
- "@biorate/inversion": "0.28.0"
32
+ "@biorate/config": "0.30.2",
33
+ "@biorate/inversion": "0.30.2"
34
34
  },
35
- "gitHead": "4857311a7f3664a01bc1a1142f46b4ed5e632efd"
35
+ "gitHead": "7ab1c4ca350f0464a52b5a5746aad22d8924f1b3"
36
36
  }
package/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './src';
package/src/index.ts DELETED
@@ -1,105 +0,0 @@
1
- import { omit, pick } from 'lodash';
2
- import axios, { AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios';
3
- import retry, { IAxiosRetryConfig } from 'axios-retry';
4
- import * as pathToUrl from 'path-to-url';
5
- import { IAxiosFetchOptions } from './interfaces';
6
-
7
- export * from './interfaces';
8
-
9
- const axiosRetryConfigKeys = [
10
- 'retries',
11
- 'retryDelay',
12
- 'shouldResetTimeout',
13
- 'retryCondition',
14
- ];
15
-
16
- const axiosExcludeKeys = ['path', 'config'];
17
-
18
- /**
19
- * @description
20
- * Axios OOP static interface
21
- *
22
- * ### Features:
23
- * - OOP
24
- * - DI
25
- *
26
- * @example
27
- * ```
28
- * import { Axios } from '@biorate/axios';
29
- *
30
- * class Yandex extends Axios {
31
- * public baseURL = 'https://yandex.ru';
32
- * }
33
- *
34
- * (async () => {
35
- * const response = await Yandex.fetch<string>();
36
- * console.log(response.status); // 200
37
- * console.log(response.data); // <!DOCTYPE html><html ...
38
- * })();
39
- * ```
40
- */
41
- export class Axios {
42
- /**
43
- * @description Axios instance cache
44
- */
45
- protected static cache = new WeakMap<Object, Axios>();
46
- /**
47
- * @description Fetch static method
48
- */
49
- public static fetch(...args: unknown[]) {
50
- return this._fetch(...args);
51
- }
52
- /**
53
- * @description Protected fetch static method
54
- */
55
- protected static _fetch<D = any>(
56
- options?: IAxiosFetchOptions,
57
- ): Promise<AxiosResponse<D>> {
58
- if (!this.cache.has(this)) this.cache.set(this, new this());
59
- return this.cache.get(this).fetch<D>(options);
60
- }
61
- /**
62
- * @description Axios client cache
63
- */
64
- #client: AxiosInstance;
65
- /**
66
- * @description Fetch method
67
- */
68
- protected async fetch<D>(options?: IAxiosFetchOptions): Promise<AxiosResponse<D>> {
69
- if (!this.#client) {
70
- this.#client = axios.create();
71
- retry(this.#client, <IAxiosRetryConfig>pick(this, axiosRetryConfigKeys));
72
- }
73
- const settings = { ...this, ...options };
74
- if (settings.baseURL && settings.path)
75
- settings.baseURL = pathToUrl(settings.baseURL, settings.path);
76
- if (settings.url && settings.path)
77
- settings.url = pathToUrl(settings.url, settings.path);
78
- const params = {
79
- ...omit(settings, axiosRetryConfigKeys.concat(axiosExcludeKeys)),
80
- };
81
- try {
82
- await this.before(params);
83
- return await this.#client(params);
84
- } catch (e) {
85
- await this.catch(e);
86
- } finally {
87
- await this.finally();
88
- }
89
- }
90
- /**
91
- * @description Before hook
92
- */
93
- protected async before(params: IAxiosFetchOptions) {}
94
-
95
- /**
96
- * @description Catch hook
97
- */
98
- protected async catch(e: Error) {
99
- throw e;
100
- }
101
- /**
102
- * @description Finally hook
103
- */
104
- protected async finally() {}
105
- }
package/src/interfaces.ts DELETED
@@ -1,5 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios';
2
-
3
- export type IAxiosFetchOptions = AxiosRequestConfig & {
4
- path?: Record<string, string | number>;
5
- };