@biorate/axios 2.2.1 → 3.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.
- package/dist/{index.js → cjs/index.js} +0 -1
- package/dist/cjs/package.json +3 -0
- package/dist/{src → cjs/src}/fake-response.js +0 -1
- package/dist/{src → cjs/src}/index.js +0 -1
- package/dist/{src → cjs/src}/interfaces.js +0 -1
- package/dist/{src → cjs/src}/options.js +0 -1
- package/dist/{src → cjs/src}/stubs.js +0 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/src/fake-response.js +10 -0
- package/dist/esm/src/index.js +111 -0
- package/dist/esm/src/interfaces.js +1 -0
- package/dist/esm/src/options.js +8 -0
- package/dist/esm/src/stubs.js +48 -0
- package/dist/types/src/fake-response.d.ts +10 -0
- package/dist/types/src/index.d.ts +33 -0
- package/dist/types/src/interfaces.d.ts +12 -0
- package/dist/types/src/options.d.ts +4 -0
- package/dist/types/src/stubs.d.ts +14 -0
- package/package.json +33 -8
- package/.nyc_output/84023f98-547c-4ebe-ac26-64a9b2da3563.json +0 -1
- package/.nyc_output/88d6a3b7-d47d-4373-aab3-aa6ff0e2b5b0.json +0 -1
- package/.nyc_output/9b9edde9-e8c1-437a-9e11-4099e5e61dce.json +0 -1
- package/.nyc_output/processinfo/84023f98-547c-4ebe-ac26-64a9b2da3563.json +0 -1
- package/.nyc_output/processinfo/88d6a3b7-d47d-4373-aab3-aa6ff0e2b5b0.json +0 -1
- package/.nyc_output/processinfo/9b9edde9-e8c1-437a-9e11-4099e5e61dce.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/CHANGELOG.md +0 -916
- package/allure-results/024aff4f-434d-462d-b12d-51ad34e0fdd5-result.json +0 -1
- package/allure-results/034efb06-cd77-45cb-becb-73cddf20dc15-container.json +0 -1
- package/allure-results/0f32df6c-5e9b-47f1-89c8-ea600c83ba26-result.json +0 -1
- package/allure-results/122199ab-d667-4cc9-b573-113d8868a8cd-container.json +0 -1
- package/allure-results/13d110d0-109c-4351-89ed-5bc13e0bdb3e-result.json +0 -1
- package/allure-results/1c22f13b-2e46-4968-9705-a3ada037e508-result.json +0 -1
- package/allure-results/1dd4fd35-9f73-44a7-a521-d9f6c88e4dbf-result.json +0 -1
- package/allure-results/23bbf376-c3b5-4d1c-97f5-c7933bd22bed-container.json +0 -1
- package/allure-results/312ebf35-2d28-4c05-8fe3-e3d2dbf6e476-result.json +0 -1
- package/allure-results/337b7e6a-6ad9-4fa3-a228-97c58de356e1-result.json +0 -1
- package/allure-results/3c46512d-2d69-4cf9-a829-1a2ed1e12357-result.json +0 -1
- package/allure-results/3dd2c9c2-e703-49d6-a5bf-020bfbf8983d-result.json +0 -1
- package/allure-results/46595c34-330b-40d4-920b-d9ed72544bd5-result.json +0 -1
- package/allure-results/4ab9592b-3194-4468-b531-6b00b0d21c0b-result.json +0 -1
- package/allure-results/4bbf362f-9228-4d11-97c3-c94296b4814f-result.json +0 -1
- package/allure-results/4cad7c8d-b6c5-406c-9d30-e1c0e79ba37e-result.json +0 -1
- package/allure-results/51ad02af-e7b2-49f6-b7be-52951c85c92c-result.json +0 -1
- package/allure-results/545d7b97-ddce-4b37-9173-d82320af1cf8-result.json +0 -1
- package/allure-results/5ef8c8d3-5162-40a6-af20-534c68d89ab7-result.json +0 -1
- package/allure-results/6333d6c1-d0a9-4010-ac90-559e27d51569-result.json +0 -1
- package/allure-results/640ada6c-e27b-49bb-9538-2f89caf15bec-result.json +0 -1
- package/allure-results/6b24004c-0cf5-4afb-be3d-66bb02b6f940-result.json +0 -1
- package/allure-results/6d405aea-2939-4211-ae8c-d705cd7847a8-result.json +0 -1
- package/allure-results/78193a1c-8fb4-4fa1-ae61-b442b735e6a2-result.json +0 -1
- package/allure-results/7c156a84-fff6-4e38-9fb2-b8559787299d-result.json +0 -1
- package/allure-results/81c881a2-134a-46d1-8fac-6be7f82208b2-result.json +0 -1
- package/allure-results/84dfd493-152d-472e-bd3f-0afe78f6b26f-result.json +0 -1
- package/allure-results/86025fdc-3bf2-4ef9-90ae-3cae234063f0-result.json +0 -1
- package/allure-results/89748530-4e9f-4ad3-a600-67d6ecfb0af5-result.json +0 -1
- package/allure-results/8b3c2df8-404b-470a-9cbd-39e401befa46-result.json +0 -1
- package/allure-results/8ce702b9-7c91-42b9-86f9-57c52121784e-result.json +0 -1
- package/allure-results/9c7b34a3-84b1-449d-bd02-33f1997e27eb-result.json +0 -1
- package/allure-results/a1788657-cd9f-4a87-b639-3e0f52584834-container.json +0 -1
- package/allure-results/a7b917eb-5177-4f4a-aa8b-04a2edf0285d-result.json +0 -1
- package/allure-results/aa87ef6c-02cb-4a22-869e-1e161def29d0-result.json +0 -1
- package/allure-results/b8a8dfaa-d1b6-41cb-bef0-417090bc6154-result.json +0 -1
- package/allure-results/b8c412fe-ac83-4576-81f4-ea4b32270e34-container.json +0 -1
- package/allure-results/be170a39-68d6-48f6-915d-95dbfee194b2-result.json +0 -1
- package/allure-results/e083bcb1-5524-4c6b-a1c0-c59fccf0a4a2-result.json +0 -1
- package/allure-results/ebfb6a2b-8dce-4caa-9871-2a19b23cd7a7-result.json +0 -1
- package/allure-results/ef495d15-cfbc-4904-a5ca-e6fc8d74064c-result.json +0 -1
- package/allure-results/f111080e-f644-4834-8383-45e2f396399f-result.json +0 -1
- package/allure-results/f15db1cd-8051-4a57-b85b-2625a78a68bd-result.json +0 -1
- package/allure-results/f2b8e231-3b72-4e4f-b7d2-385d71427c40-result.json +0 -1
- package/allure-results/f56ffbe5-bd28-4a7f-a575-642848659921-container.json +0 -1
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -109
- package/coverage/coverage-final.json +0 -7
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -131
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/coverage/src/fake-response.ts.html +0 -142
- package/coverage/src/index.html +0 -176
- package/coverage/src/index.ts.html +0 -679
- package/coverage/src/interfaces.ts.html +0 -127
- package/coverage/src/options.ts.html +0 -112
- package/coverage/src/stubs.ts.html +0 -286
- package/coverage/tests/__mocks__/index.html +0 -116
- package/coverage/tests/__mocks__/index.ts.html +0 -199
- package/dist/index.js.map +0 -1
- package/dist/src/fake-response.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/interfaces.js.map +0 -1
- package/dist/src/options.js.map +0 -1
- package/dist/src/stubs.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/index.d.ts +0 -33
- package/src/fake-response.ts +0 -19
- package/src/index.ts +0 -198
- package/src/interfaces.ts +0 -14
- package/src/options.ts +0 -9
- package/src/stubs.ts +0 -67
- package/tsconfig.build.json +0 -5
- package/tsconfig.json +0 -9
- /package/{index.ts → dist/types/index.d.ts} +0 -0
package/src/interfaces.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
|
|
3
|
-
export type IAxiosFetchOptions = AxiosRequestConfig & {
|
|
4
|
-
path?: Record<string, string | number>;
|
|
5
|
-
retry?: boolean;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type IStubParam = {
|
|
9
|
-
data: Record<string, any> | string;
|
|
10
|
-
status?: number;
|
|
11
|
-
statusText?: string;
|
|
12
|
-
headers?: Record<string, any>;
|
|
13
|
-
config?: InternalAxiosRequestConfig<any>;
|
|
14
|
-
};
|
package/src/options.ts
DELETED
package/src/stubs.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { AxiosError, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { status as statuses } from 'http-status';
|
|
3
|
-
import { Axios, IStubParam } from './index';
|
|
4
|
-
import { Options } from './options';
|
|
5
|
-
import { FakeResponse } from './fake-response';
|
|
6
|
-
|
|
7
|
-
export class Stubs {
|
|
8
|
-
static #cache = new WeakMap<typeof Axios, Stubs>();
|
|
9
|
-
|
|
10
|
-
#halt = (
|
|
11
|
-
statusText: string,
|
|
12
|
-
status: number,
|
|
13
|
-
params: IStubParam,
|
|
14
|
-
response: FakeResponse,
|
|
15
|
-
) => {
|
|
16
|
-
throw new AxiosError(
|
|
17
|
-
statusText,
|
|
18
|
-
String(status),
|
|
19
|
-
params.config,
|
|
20
|
-
params.headers,
|
|
21
|
-
response,
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
public static get(Class: typeof Axios) {
|
|
26
|
-
if (!this.#cache.has(Class)) this.#cache.set(Class, new this(Class));
|
|
27
|
-
return this.#cache.get(Class)!;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public readonly options: Options = new Options();
|
|
31
|
-
|
|
32
|
-
protected fetch = new WeakMap<typeof Axios, typeof Axios.fetch>();
|
|
33
|
-
|
|
34
|
-
protected constructor(protected Class: typeof Axios) {}
|
|
35
|
-
|
|
36
|
-
public stub(
|
|
37
|
-
instance: Axios & {
|
|
38
|
-
validateStatus?: (status: number) => boolean;
|
|
39
|
-
},
|
|
40
|
-
params: IStubParam,
|
|
41
|
-
persist = false,
|
|
42
|
-
) {
|
|
43
|
-
const status = params?.status ?? 200;
|
|
44
|
-
const statusText = String(statuses[<keyof typeof statuses>status] ?? statuses[500]);
|
|
45
|
-
const response = new FakeResponse<typeof params.data>(
|
|
46
|
-
params.data,
|
|
47
|
-
status,
|
|
48
|
-
statusText,
|
|
49
|
-
params.headers ?? {},
|
|
50
|
-
params.config ?? <InternalAxiosRequestConfig<any>>{},
|
|
51
|
-
);
|
|
52
|
-
this.fetch.set(this.Class, this.Class.fetch);
|
|
53
|
-
this.Class.fetch = async (options?: any) => {
|
|
54
|
-
this.options.push(options);
|
|
55
|
-
if (!persist) this.unstub();
|
|
56
|
-
if (instance?.validateStatus?.(status)) return response;
|
|
57
|
-
if (['4', '5'].includes(String(status)[0]))
|
|
58
|
-
this.#halt(statusText, status, params, response);
|
|
59
|
-
return response;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public unstub() {
|
|
64
|
-
if (!this.fetch.has(this.Class)) return;
|
|
65
|
-
this.Class.fetch = this.fetch.get(this.Class)!;
|
|
66
|
-
}
|
|
67
|
-
}
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
|
File without changes
|