@hyper-fetch/axios 5.0.0 → 5.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyper-fetch/axios",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "private": false,
5
5
  "description": "Simple axios adapter for Hyper Fetch",
6
6
  "author": "Kacper Skawina <kacper.skawina@gmail.com>",
@@ -11,7 +11,6 @@
11
11
  "types": "dist/index.d.ts",
12
12
  "source": "src/index.ts",
13
13
  "scripts": {
14
- "prepublishOnly": "yarn build",
15
14
  "clean": "npx rimraf dist",
16
15
  "test": "jest --watchAll --maxWorkers=3",
17
16
  "test-pipeline": "jest --watchAll=false --maxWorkers=1 --no-cache",
@@ -31,7 +30,7 @@
31
30
  "repository": {
32
31
  "type": "git",
33
32
  "url": "git+https://github.com/BetterTyped/hyper-fetch.git",
34
- "directory": "packages/adapter-firebase"
33
+ "directory": "packages/adapter-axios"
35
34
  },
36
35
  "bugs": {
37
36
  "url": "https://github.com/BetterTyped/hyper-fetch/issues"
@@ -1,91 +0,0 @@
1
- import { Client } from "@hyper-fetch/core";
2
-
3
- import { axiosAdapter } from "../../../src/adapter/adapter";
4
- import { createRequestInterceptor, resetInterceptors, startServer, stopServer } from "../../server";
5
-
6
- describe("Fetch Adapter [ Browser ]", () => {
7
- let client = new Client({ url: "shared-base-url" }).setAdapter(axiosAdapter);
8
- let request = client.createRequest()({ endpoint: "/shared-endpoint" });
9
-
10
- beforeAll(() => {
11
- startServer();
12
- });
13
-
14
- beforeEach(() => {
15
- client = new Client({ url: "shared-base-url" }).setAdapter(axiosAdapter);
16
- request = client.createRequest()({ endpoint: "/shared-endpoint" });
17
-
18
- resetInterceptors();
19
- jest.resetAllMocks();
20
- });
21
-
22
- afterAll(() => {
23
- stopServer();
24
- });
25
-
26
- it("should make a request and return success data with status", async () => {
27
- const response = createRequestInterceptor(request);
28
- const { data, status, error, extra } = await request.send();
29
-
30
- expect(data).toStrictEqual(response);
31
- expect(status).toBe(200);
32
- expect(error).toBe(null);
33
- expect({ ...extra.headers }).toStrictEqual({
34
- "content-type": "application/json",
35
- "x-powered-by": "msw",
36
- });
37
- });
38
-
39
- it("should make a request and return error with status", async () => {
40
- createRequestInterceptor(request, { status: 400 });
41
- const { data, error, status, extra } = await request.send();
42
-
43
- expect(error.message).toBe("Request failed with status code 400");
44
- expect(data).toStrictEqual(null);
45
- expect(status).toBe(400);
46
- expect({ ...extra.headers }).toStrictEqual({
47
- "content-type": "application/json",
48
- "x-powered-by": "msw",
49
- });
50
- });
51
-
52
- it("should allow to call the request callbacks", async () => {
53
- createRequestInterceptor(request);
54
-
55
- const spy1 = jest.fn();
56
- const spy2 = jest.fn();
57
- const spy3 = jest.fn();
58
- const spy4 = jest.fn();
59
- const spy5 = jest.fn();
60
- const spy6 = jest.fn();
61
-
62
- await request.send({
63
- onSettle: spy1,
64
- onRequestStart: spy2,
65
- onResponseStart: spy3,
66
- onUploadProgress: spy4,
67
- onDownloadProgress: spy5,
68
- onResponse: spy6,
69
- });
70
-
71
- expect(spy1).toBeCalledTimes(1);
72
- expect(spy2).toBeCalledTimes(1);
73
- expect(spy3).toBeCalledTimes(1);
74
- expect(spy4).toBeCalledTimes(2);
75
- expect(spy5).toBeCalledTimes(3);
76
- expect(spy6).toBeCalledTimes(1);
77
- });
78
-
79
- it("should allow to add upload progress", async () => {
80
- const postRequest = client.createRequest<any, any>()({ endpoint: "/shared-endpoint", method: "POST" });
81
- createRequestInterceptor(postRequest);
82
-
83
- const spy1 = jest.fn();
84
- await postRequest.send({
85
- data: { name: "test" },
86
- onUploadProgress: spy1,
87
- });
88
-
89
- expect(spy1).toBeCalledTimes(1);
90
- });
91
- });
@@ -1 +0,0 @@
1
- import "jest-extended";
@@ -1,5 +0,0 @@
1
- import { AbortController } from "abortcontroller-polyfill/dist/cjs-ponyfill";
2
-
3
- if (!global.AbortController) {
4
- global.AbortController = AbortController as any;
5
- }
@@ -1,2 +0,0 @@
1
- export * from "./server";
2
- export * from "./server.constants";
@@ -1,18 +0,0 @@
1
- export type StatusCodesType = 200 | StatusErrorCodesType;
2
- export type StatusErrorCodesType = 400 | 401 | 404 | 500;
3
- export type ErrorMockType = { message: string };
4
-
5
- export const errorResponses: Record<StatusErrorCodesType, ErrorMockType> = {
6
- 401: {
7
- message: "Unathorized",
8
- },
9
- 400: {
10
- message: "Error",
11
- },
12
- 404: {
13
- message: "Not found",
14
- },
15
- 500: {
16
- message: "Server Error",
17
- },
18
- };
@@ -1,48 +0,0 @@
1
- import { setupServer } from "msw/node";
2
- import { RequestInstance } from "request";
3
- import { ExtractResponseType } from "@hyper-fetch/core";
4
-
5
- import { getInterceptEndpoint, createStubMethod } from "./server.utils";
6
- import { ErrorMockType, errorResponses, StatusCodesType, StatusErrorCodesType } from "./server.constants";
7
-
8
- export const server = setupServer();
9
-
10
- export const startServer = (): void => {
11
- server.listen();
12
- };
13
-
14
- export const resetInterceptors = (): void => {
15
- server.resetHandlers();
16
- };
17
-
18
- export const stopServer = (): void => {
19
- server.close();
20
- };
21
-
22
- export const createRequestInterceptor = <T extends RequestInstance, StatusType extends StatusCodesType>(
23
- request: T,
24
- props?: {
25
- fixture?: ExtractResponseType<T>;
26
- status?: StatusType;
27
- delay?: number;
28
- },
29
- ): StatusType extends StatusErrorCodesType ? ErrorMockType : ExtractResponseType<T> => {
30
- const { fixture, status, delay } = props || {};
31
- const { endpoint, method } = request;
32
- const url = getInterceptEndpoint(endpoint);
33
-
34
- const currentStatus: StatusCodesType = status || 200;
35
-
36
- if (currentStatus !== 200 && currentStatus in errorResponses) {
37
- const errorResponse = errorResponses[currentStatus] as StatusType extends StatusErrorCodesType
38
- ? ErrorMockType
39
- : ExtractResponseType<T>;
40
- server.use(createStubMethod(request, url, method, currentStatus, errorResponse, delay));
41
-
42
- return errorResponse;
43
- }
44
-
45
- const responseData = (fixture || { data: [1, 2, 3] }) as ExtractResponseType<T>;
46
- server.use(createStubMethod(request, url, method, currentStatus, responseData, delay));
47
- return responseData as any;
48
- };
@@ -1,106 +0,0 @@
1
- import {
2
- DefaultBodyType,
3
- MockedResponse,
4
- PathParams,
5
- ResponseComposition,
6
- ResponseTransformer,
7
- rest,
8
- RestContext,
9
- RestHandler,
10
- RestRequest,
11
- } from "msw";
12
- import { RequestInstance } from "request";
13
-
14
- export function sleep(timeMs) {
15
- return new Promise((resolve) => {
16
- setTimeout(resolve, timeMs);
17
- });
18
- }
19
-
20
- const defaultTimeout = 5000;
21
- export const getErrorMessage = (errorCase?: "timeout" | "abort" | "deleted") => {
22
- if (errorCase === "timeout") {
23
- return new Error("Request timeout");
24
- }
25
- if (errorCase === "abort") {
26
- return new Error("Request cancelled");
27
- }
28
- return new Error("Unexpected error");
29
- };
30
- export const getInterceptEndpoint = (endpoint: string): RegExp => {
31
- return new RegExp(`^(?!.*\b${`${endpoint}/`}/\b).*${endpoint}.*`);
32
- };
33
-
34
- const getResponse = (ctx: RestContext, request: RequestInstance, fixture: unknown, status: number, delay = 10) => {
35
- const { requestManager } = request.client;
36
- const controllers = requestManager.abortControllers.get(request.abortKey);
37
- const abortController = Array.from(controllers || [])[controllers.size - 1];
38
-
39
- const timeoutTime = request.options?.timeout || defaultTimeout;
40
- const isTimeout = timeoutTime < delay;
41
-
42
- if (!delay) {
43
- return [ctx.json(fixture), ctx.status(status)];
44
- }
45
-
46
- return [
47
- async (response: MockedResponse<unknown>) => {
48
- await sleep(Math.min(timeoutTime, delay));
49
- if (abortController && abortController?.[1].signal.aborted) {
50
- ctx.status(500)(response);
51
- const error = getErrorMessage("abort");
52
- response.body = request.client.appManager.isBrowser ? error : JSON.stringify({ message: error.message });
53
- return response;
54
- }
55
- if (isTimeout) {
56
- ctx.status(500)(response);
57
- const error = getErrorMessage("timeout");
58
- response.body = request.client.appManager.isBrowser ? error : JSON.stringify({ message: error.message });
59
- return response;
60
- }
61
- ctx.json(fixture)(response);
62
- ctx.status(status)(response);
63
- return response;
64
- },
65
- ];
66
- };
67
-
68
- export const createStubMethod = (
69
- request: RequestInstance,
70
- url: RegExp,
71
- method: string,
72
- status: number,
73
- response: Record<string, any>,
74
- delay?: number,
75
- ): RestHandler => {
76
- function callback(_req: RestRequest<DefaultBodyType, PathParams>, res: ResponseComposition<any>, ctx: RestContext) {
77
- const args: ResponseTransformer<any, any>[] = getResponse(ctx, request, response, status, delay);
78
-
79
- if (delay === 0) {
80
- args.shift();
81
- }
82
-
83
- if (delay === null || delay === undefined) {
84
- args.unshift(ctx.delay());
85
- }
86
-
87
- if (delay) {
88
- args.unshift(ctx.delay(delay));
89
- }
90
-
91
- return res(...args);
92
- }
93
-
94
- switch (method.toUpperCase()) {
95
- case "POST":
96
- return rest.post(url, callback);
97
- case "PUT":
98
- return rest.put(url, callback);
99
- case "PATCH":
100
- return rest.patch(url, callback);
101
- case "DELETE":
102
- return rest.delete(url, callback);
103
- default:
104
- return rest.get(url, callback);
105
- }
106
- };
@@ -1,10 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "noEmit": true,
4
- "baseUrl": "../src",
5
- "moduleResolution": "node",
6
- "esModuleInterop": true,
7
- "allowSyntheticDefaultImports": true
8
- },
9
- "include": ["../jest.config.ts", "./"]
10
- }
@@ -1,73 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <coverage generated="1686218956973" clover="3.2.0">
3
- <project timestamp="1686218956973" name="All files">
4
- <metrics statements="64" coveredstatements="62" conditionals="16" coveredconditionals="16" methods="4" coveredmethods="3" elements="84" coveredelements="81" complexity="0" loc="64" ncloc="64" packages="1" files="1" classes="1"/>
5
- <file name="adapter.ts" path="/Users/maciejpyrc/Praca/better-typed/open-source/hyper-fetch/packages/adapter-axios/src/adapter/adapter.ts">
6
- <metrics statements="64" coveredstatements="62" conditionals="16" coveredconditionals="16" methods="4" coveredmethods="3"/>
7
- <line num="1" count="1" type="stmt"/>
8
- <line num="2" count="1" type="stmt"/>
9
- <line num="3" count="1" type="stmt"/>
10
- <line num="4" count="1" type="stmt"/>
11
- <line num="5" count="1" type="stmt"/>
12
- <line num="6" count="1" type="cond" truecount="3" falsecount="0"/>
13
- <line num="7" count="4" type="stmt"/>
14
- <line num="8" count="4" type="stmt"/>
15
- <line num="9" count="4" type="stmt"/>
16
- <line num="10" count="4" type="stmt"/>
17
- <line num="11" count="4" type="stmt"/>
18
- <line num="12" count="4" type="stmt"/>
19
- <line num="13" count="4" type="stmt"/>
20
- <line num="14" count="4" type="stmt"/>
21
- <line num="15" count="4" type="stmt"/>
22
- <line num="16" count="4" type="stmt"/>
23
- <line num="17" count="4" type="stmt"/>
24
- <line num="18" count="4" type="stmt"/>
25
- <line num="19" count="4" type="stmt"/>
26
- <line num="20" count="4" type="stmt"/>
27
- <line num="21" count="4" type="stmt"/>
28
- <line num="22" count="4" type="stmt"/>
29
- <line num="23" count="4" type="stmt"/>
30
- <line num="24" count="4" type="stmt"/>
31
- <line num="25" count="4" type="stmt"/>
32
- <line num="26" count="4" type="stmt"/>
33
- <line num="27" count="4" type="stmt"/>
34
- <line num="28" count="4" type="stmt"/>
35
- <line num="29" count="4" type="stmt"/>
36
- <line num="30" count="4" type="cond" truecount="1" falsecount="0"/>
37
- <line num="31" count="4" type="stmt"/>
38
- <line num="32" count="4" type="cond" truecount="1" falsecount="0"/>
39
- <line num="33" count="4" type="stmt"/>
40
- <line num="34" count="4" type="stmt"/>
41
- <line num="35" count="4" type="stmt"/>
42
- <line num="36" count="4" type="stmt"/>
43
- <line num="37" count="4" type="stmt"/>
44
- <line num="38" count="4" type="stmt"/>
45
- <line num="39" count="4" type="stmt"/>
46
- <line num="40" count="4" type="stmt"/>
47
- <line num="41" count="4" type="stmt"/>
48
- <line num="42" count="4" type="stmt"/>
49
- <line num="43" count="4" type="cond" truecount="1" falsecount="0"/>
50
- <line num="44" count="0" type="stmt"/>
51
- <line num="45" count="0" type="stmt"/>
52
- <line num="46" count="4" type="cond" truecount="1" falsecount="0"/>
53
- <line num="47" count="4" type="cond" truecount="1" falsecount="0"/>
54
- <line num="48" count="3" type="stmt"/>
55
- <line num="49" count="3" type="stmt"/>
56
- <line num="50" count="3" type="stmt"/>
57
- <line num="51" count="4" type="stmt"/>
58
- <line num="52" count="4" type="stmt"/>
59
- <line num="53" count="4" type="cond" truecount="1" falsecount="0"/>
60
- <line num="54" count="2" type="stmt"/>
61
- <line num="55" count="2" type="stmt"/>
62
- <line num="56" count="4" type="stmt"/>
63
- <line num="57" count="4" type="cond" truecount="1" falsecount="0"/>
64
- <line num="58" count="2" type="cond" truecount="5" falsecount="0"/>
65
- <line num="59" count="4" type="stmt"/>
66
- <line num="60" count="4" type="cond" truecount="1" falsecount="0"/>
67
- <line num="61" count="4" type="stmt"/>
68
- <line num="62" count="4" type="stmt"/>
69
- <line num="63" count="4" type="stmt"/>
70
- <line num="64" count="4" type="stmt"/>
71
- </file>
72
- </project>
73
- </coverage>
@@ -1,2 +0,0 @@
1
- {"/Users/maciejpyrc/Praca/better-typed/open-source/hyper-fetch/packages/adapter-axios/src/adapter/adapter.ts": {"path":"/Users/maciejpyrc/Praca/better-typed/open-source/hyper-fetch/packages/adapter-axios/src/adapter/adapter.ts","all":false,"statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":55}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":68}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":0}},"3":{"start":{"line":4,"column":0},"end":{"line":4,"column":51}},"4":{"start":{"line":5,"column":0},"end":{"line":5,"column":0}},"5":{"start":{"line":6,"column":0},"end":{"line":6,"column":83}},"6":{"start":{"line":7,"column":0},"end":{"line":7,"column":9}},"7":{"start":{"line":8,"column":0},"end":{"line":8,"column":16}},"8":{"start":{"line":9,"column":0},"end":{"line":9,"column":11}},"9":{"start":{"line":10,"column":0},"end":{"line":10,"column":12}},"10":{"start":{"line":11,"column":0},"end":{"line":11,"column":12}},"11":{"start":{"line":12,"column":0},"end":{"line":12,"column":12}},"12":{"start":{"line":13,"column":0},"end":{"line":13,"column":12}},"13":{"start":{"line":14,"column":0},"end":{"line":14,"column":18}},"14":{"start":{"line":15,"column":0},"end":{"line":15,"column":17}},"15":{"start":{"line":16,"column":0},"end":{"line":16,"column":24}},"16":{"start":{"line":17,"column":0},"end":{"line":17,"column":23}},"17":{"start":{"line":18,"column":0},"end":{"line":18,"column":22}},"18":{"start":{"line":19,"column":0},"end":{"line":19,"column":20}},"19":{"start":{"line":20,"column":0},"end":{"line":20,"column":20}},"20":{"start":{"line":21,"column":0},"end":{"line":21,"column":19}},"21":{"start":{"line":22,"column":0},"end":{"line":22,"column":14}},"22":{"start":{"line":23,"column":0},"end":{"line":23,"column":23}},"23":{"start":{"line":24,"column":0},"end":{"line":24,"column":89}},"24":{"start":{"line":25,"column":0},"end":{"line":25,"column":0}},"25":{"start":{"line":26,"column":0},"end":{"line":26,"column":29}},"26":{"start":{"line":27,"column":0},"end":{"line":27,"column":0}},"27":{"start":{"line":28,"column":0},"end":{"line":28,"column":20}},"28":{"start":{"line":29,"column":0},"end":{"line":29,"column":0}},"29":{"start":{"line":30,"column":0},"end":{"line":30,"column":35}},"30":{"start":{"line":31,"column":0},"end":{"line":31,"column":44}},"31":{"start":{"line":32,"column":0},"end":{"line":32,"column":93}},"32":{"start":{"line":33,"column":0},"end":{"line":33,"column":0}},"33":{"start":{"line":34,"column":0},"end":{"line":34,"column":21}},"34":{"start":{"line":35,"column":0},"end":{"line":35,"column":11}},"35":{"start":{"line":36,"column":0},"end":{"line":36,"column":16}},"36":{"start":{"line":37,"column":0},"end":{"line":37,"column":20}},"37":{"start":{"line":38,"column":0},"end":{"line":38,"column":13}},"38":{"start":{"line":39,"column":0},"end":{"line":39,"column":19}},"39":{"start":{"line":40,"column":0},"end":{"line":40,"column":32}},"40":{"start":{"line":41,"column":0},"end":{"line":41,"column":67}},"41":{"start":{"line":42,"column":0},"end":{"line":42,"column":31}},"42":{"start":{"line":43,"column":0},"end":{"line":43,"column":30}},"43":{"start":{"line":44,"column":0},"end":{"line":44,"column":45}},"44":{"start":{"line":45,"column":0},"end":{"line":45,"column":11}},"45":{"start":{"line":46,"column":0},"end":{"line":46,"column":20}},"46":{"start":{"line":47,"column":0},"end":{"line":47,"column":46}},"47":{"start":{"line":48,"column":0},"end":{"line":48,"column":23}},"48":{"start":{"line":49,"column":0},"end":{"line":49,"column":26}},"49":{"start":{"line":50,"column":0},"end":{"line":50,"column":42}},"50":{"start":{"line":51,"column":0},"end":{"line":51,"column":8}},"51":{"start":{"line":52,"column":0},"end":{"line":52,"column":6}},"52":{"start":{"line":53,"column":0},"end":{"line":53,"column":27}},"53":{"start":{"line":54,"column":0},"end":{"line":54,"column":90}},"54":{"start":{"line":55,"column":0},"end":{"line":55,"column":24}},"55":{"start":{"line":56,"column":0},"end":{"line":56,"column":8}},"56":{"start":{"line":57,"column":0},"end":{"line":57,"column":25}},"57":{"start":{"line":58,"column":0},"end":{"line":58,"column":99}},"58":{"start":{"line":59,"column":0},"end":{"line":59,"column":8}},"59":{"start":{"line":60,"column":0},"end":{"line":60,"column":22}},"60":{"start":{"line":61,"column":0},"end":{"line":61,"column":26}},"61":{"start":{"line":62,"column":0},"end":{"line":62,"column":9}},"62":{"start":{"line":63,"column":0},"end":{"line":63,"column":5}},"63":{"start":{"line":64,"column":0},"end":{"line":64,"column":2}}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":4,"7":4,"8":4,"9":4,"10":4,"11":4,"12":4,"13":4,"14":4,"15":4,"16":4,"17":4,"18":4,"19":4,"20":4,"21":4,"22":4,"23":4,"24":4,"25":4,"26":4,"27":4,"28":4,"29":4,"30":4,"31":4,"32":4,"33":4,"34":4,"35":4,"36":4,"37":4,"38":4,"39":4,"40":4,"41":4,"42":4,"43":0,"44":0,"45":4,"46":4,"47":3,"48":3,"49":3,"50":4,"51":4,"52":4,"53":2,"54":2,"55":4,"56":4,"57":2,"58":4,"59":4,"60":4,"61":4,"62":4,"63":4},"branchMap":{"0":{"type":"branch","line":6,"loc":{"start":{"line":6,"column":28},"end":{"line":64,"column":2}},"locations":[{"start":{"line":6,"column":28},"end":{"line":64,"column":2}}]},"1":{"type":"branch","line":6,"loc":{"start":{"line":6,"column":52},"end":{"line":64,"column":2}},"locations":[{"start":{"line":6,"column":52},"end":{"line":64,"column":2}}]},"2":{"type":"branch","line":6,"loc":{"start":{"line":6,"column":81},"end":{"line":64,"column":2}},"locations":[{"start":{"line":6,"column":81},"end":{"line":64,"column":2}}]},"3":{"type":"branch","line":30,"loc":{"start":{"line":30,"column":21},"end":{"line":63,"column":3}},"locations":[{"start":{"line":30,"column":21},"end":{"line":63,"column":3}}]},"4":{"type":"branch","line":43,"loc":{"start":{"line":43,"column":8},"end":{"line":45,"column":11}},"locations":[{"start":{"line":43,"column":8},"end":{"line":45,"column":11}}]},"5":{"type":"branch","line":46,"loc":{"start":{"line":46,"column":8},"end":{"line":46,"column":19}},"locations":[{"start":{"line":46,"column":8},"end":{"line":46,"column":19}}]},"6":{"type":"branch","line":32,"loc":{"start":{"line":32,"column":28},"end":{"line":32,"column":92}},"locations":[{"start":{"line":32,"column":28},"end":{"line":32,"column":92}}]},"7":{"type":"branch","line":47,"loc":{"start":{"line":47,"column":26},"end":{"line":51,"column":7}},"locations":[{"start":{"line":47,"column":26},"end":{"line":51,"column":7}}]},"8":{"type":"branch","line":53,"loc":{"start":{"line":53,"column":12},"end":{"line":56,"column":7}},"locations":[{"start":{"line":53,"column":12},"end":{"line":56,"column":7}}]},"9":{"type":"branch","line":57,"loc":{"start":{"line":57,"column":13},"end":{"line":59,"column":7}},"locations":[{"start":{"line":57,"column":13},"end":{"line":59,"column":7}}]},"10":{"type":"branch","line":58,"loc":{"start":{"line":58,"column":37},"end":{"line":58,"column":39}},"locations":[{"start":{"line":58,"column":37},"end":{"line":58,"column":39}}]},"11":{"type":"branch","line":58,"loc":{"start":{"line":58,"column":37},"end":{"line":58,"column":45}},"locations":[{"start":{"line":58,"column":37},"end":{"line":58,"column":45}}]},"12":{"type":"branch","line":58,"loc":{"start":{"line":58,"column":45},"end":{"line":58,"column":50}},"locations":[{"start":{"line":58,"column":45},"end":{"line":58,"column":50}}]},"13":{"type":"branch","line":58,"loc":{"start":{"line":58,"column":77},"end":{"line":58,"column":79}},"locations":[{"start":{"line":58,"column":77},"end":{"line":58,"column":79}}]},"14":{"type":"branch","line":58,"loc":{"start":{"line":58,"column":77},"end":{"line":58,"column":86}},"locations":[{"start":{"line":58,"column":77},"end":{"line":58,"column":86}}]},"15":{"type":"branch","line":60,"loc":{"start":{"line":60,"column":15},"end":{"line":62,"column":7}},"locations":[{"start":{"line":60,"column":15},"end":{"line":62,"column":7}}]}},"b":{"0":[5],"1":[4],"2":[4],"3":[4],"4":[1],"5":[3],"6":[4],"7":[3],"8":[2],"9":[2],"10":[1],"11":[1],"12":[1],"13":[1],"14":[1],"15":[4]},"fnMap":{"0":{"name":"axiosAdapter","decl":{"start":{"line":6,"column":28},"end":{"line":64,"column":2}},"loc":{"start":{"line":6,"column":28},"end":{"line":64,"column":2}},"line":6},"1":{"name":"unmountListener","decl":{"start":{"line":32,"column":28},"end":{"line":32,"column":92}},"loc":{"start":{"line":32,"column":28},"end":{"line":32,"column":92}},"line":32},"2":{"name":"Object.assign.onUploadProgress","decl":{"start":{"line":43,"column":10},"end":{"line":45,"column":11}},"loc":{"start":{"line":43,"column":10},"end":{"line":45,"column":11}},"line":43},"3":{"name":"onDownloadProgress","decl":{"start":{"line":47,"column":26},"end":{"line":51,"column":7}},"loc":{"start":{"line":47,"column":26},"end":{"line":51,"column":7}},"line":47}},"f":{"0":5,"1":4,"2":0,"3":3}}
2
- }
@@ -1,223 +0,0 @@
1
-
2
- <!doctype html>
3
- <html lang="en">
4
-
5
- <head>
6
- <title>Code coverage report for adapter.server.ts</title>
7
- <meta charset="utf-8" />
8
- <link rel="stylesheet" href="prettify.css" />
9
- <link rel="stylesheet" href="base.css" />
10
- <link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
11
- <meta name="viewport" content="width=device-width, initial-scale=1" />
12
- <style type='text/css'>
13
- .coverage-summary .sorter {
14
- background-image: url(sort-arrow-sprite.png);
15
- }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <div class='wrapper'>
21
- <div class='pad1'>
22
- <h1><a href="index.html">All files</a> adapter.server.ts</h1>
23
- <div class='clearfix'>
24
-
25
- <div class='fl pad1y space-right2'>
26
- <span class="strong">89.13% </span>
27
- <span class="quiet">Statements</span>
28
- <span class='fraction'>41/46</span>
29
- </div>
30
-
31
-
32
- <div class='fl pad1y space-right2'>
33
- <span class="strong">66.66% </span>
34
- <span class="quiet">Branches</span>
35
- <span class='fraction'>4/6</span>
36
- </div>
37
-
38
-
39
- <div class='fl pad1y space-right2'>
40
- <span class="strong">50% </span>
41
- <span class="quiet">Functions</span>
42
- <span class='fraction'>1/2</span>
43
- </div>
44
-
45
-
46
- <div class='fl pad1y space-right2'>
47
- <span class="strong">89.13% </span>
48
- <span class="quiet">Lines</span>
49
- <span class='fraction'>41/46</span>
50
- </div>
51
-
52
-
53
- </div>
54
- <p class="quiet">
55
- Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
56
- </p>
57
- <template id="filterTemplate">
58
- <div class="quiet">
59
- Filter:
60
- <input oninput="onInput()" type="search" id="fileSearch">
61
- </div>
62
- </template>
63
- </div>
64
- <div class='status-line high'></div>
65
- <pre><table class="coverage">
66
- <tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
67
- <a name='L2'></a><a href='#L2'>2</a>
68
- <a name='L3'></a><a href='#L3'>3</a>
69
- <a name='L4'></a><a href='#L4'>4</a>
70
- <a name='L5'></a><a href='#L5'>5</a>
71
- <a name='L6'></a><a href='#L6'>6</a>
72
- <a name='L7'></a><a href='#L7'>7</a>
73
- <a name='L8'></a><a href='#L8'>8</a>
74
- <a name='L9'></a><a href='#L9'>9</a>
75
- <a name='L10'></a><a href='#L10'>10</a>
76
- <a name='L11'></a><a href='#L11'>11</a>
77
- <a name='L12'></a><a href='#L12'>12</a>
78
- <a name='L13'></a><a href='#L13'>13</a>
79
- <a name='L14'></a><a href='#L14'>14</a>
80
- <a name='L15'></a><a href='#L15'>15</a>
81
- <a name='L16'></a><a href='#L16'>16</a>
82
- <a name='L17'></a><a href='#L17'>17</a>
83
- <a name='L18'></a><a href='#L18'>18</a>
84
- <a name='L19'></a><a href='#L19'>19</a>
85
- <a name='L20'></a><a href='#L20'>20</a>
86
- <a name='L21'></a><a href='#L21'>21</a>
87
- <a name='L22'></a><a href='#L22'>22</a>
88
- <a name='L23'></a><a href='#L23'>23</a>
89
- <a name='L24'></a><a href='#L24'>24</a>
90
- <a name='L25'></a><a href='#L25'>25</a>
91
- <a name='L26'></a><a href='#L26'>26</a>
92
- <a name='L27'></a><a href='#L27'>27</a>
93
- <a name='L28'></a><a href='#L28'>28</a>
94
- <a name='L29'></a><a href='#L29'>29</a>
95
- <a name='L30'></a><a href='#L30'>30</a>
96
- <a name='L31'></a><a href='#L31'>31</a>
97
- <a name='L32'></a><a href='#L32'>32</a>
98
- <a name='L33'></a><a href='#L33'>33</a>
99
- <a name='L34'></a><a href='#L34'>34</a>
100
- <a name='L35'></a><a href='#L35'>35</a>
101
- <a name='L36'></a><a href='#L36'>36</a>
102
- <a name='L37'></a><a href='#L37'>37</a>
103
- <a name='L38'></a><a href='#L38'>38</a>
104
- <a name='L39'></a><a href='#L39'>39</a>
105
- <a name='L40'></a><a href='#L40'>40</a>
106
- <a name='L41'></a><a href='#L41'>41</a>
107
- <a name='L42'></a><a href='#L42'>42</a>
108
- <a name='L43'></a><a href='#L43'>43</a>
109
- <a name='L44'></a><a href='#L44'>44</a>
110
- <a name='L45'></a><a href='#L45'>45</a>
111
- <a name='L46'></a><a href='#L46'>46</a>
112
- <a name='L47'></a><a href='#L47'>47</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
113
- <span class="cline-any cline-yes">1x</span>
114
- <span class="cline-any cline-yes">1x</span>
115
- <span class="cline-any cline-yes">1x</span>
116
- <span class="cline-any cline-yes">1x</span>
117
- <span class="cline-any cline-yes">1x</span>
118
- <span class="cline-any cline-yes">1x</span>
119
- <span class="cline-any cline-yes">1x</span>
120
- <span class="cline-any cline-yes">1x</span>
121
- <span class="cline-any cline-yes">1x</span>
122
- <span class="cline-any cline-yes">1x</span>
123
- <span class="cline-any cline-yes">1x</span>
124
- <span class="cline-any cline-yes">1x</span>
125
- <span class="cline-any cline-yes">1x</span>
126
- <span class="cline-any cline-yes">1x</span>
127
- <span class="cline-any cline-yes">1x</span>
128
- <span class="cline-any cline-yes">1x</span>
129
- <span class="cline-any cline-yes">1x</span>
130
- <span class="cline-any cline-yes">1x</span>
131
- <span class="cline-any cline-yes">1x</span>
132
- <span class="cline-any cline-yes">1x</span>
133
- <span class="cline-any cline-yes">1x</span>
134
- <span class="cline-any cline-yes">1x</span>
135
- <span class="cline-any cline-yes">1x</span>
136
- <span class="cline-any cline-yes">1x</span>
137
- <span class="cline-any cline-yes">1x</span>
138
- <span class="cline-any cline-yes">1x</span>
139
- <span class="cline-any cline-yes">1x</span>
140
- <span class="cline-any cline-yes">1x</span>
141
- <span class="cline-any cline-yes">1x</span>
142
- <span class="cline-any cline-yes">1x</span>
143
- <span class="cline-any cline-yes">1x</span>
144
- <span class="cline-any cline-yes">1x</span>
145
- <span class="cline-any cline-no">&nbsp;</span>
146
- <span class="cline-any cline-no">&nbsp;</span>
147
- <span class="cline-any cline-no">&nbsp;</span>
148
- <span class="cline-any cline-yes">1x</span>
149
- <span class="cline-any cline-yes">1x</span>
150
- <span class="cline-any cline-no">&nbsp;</span>
151
- <span class="cline-any cline-no">&nbsp;</span>
152
- <span class="cline-any cline-yes">1x</span>
153
- <span class="cline-any cline-yes">1x</span>
154
- <span class="cline-any cline-yes">1x</span>
155
- <span class="cline-any cline-yes">1x</span>
156
- <span class="cline-any cline-yes">1x</span>
157
- <span class="cline-any cline-yes">1x</span>
158
- <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import { getAdapterBindings } from "@hyper-fetch/core";
159
- import axios from "axios";
160
- &nbsp;
161
- import { AxiosAdapterType } from "./adapter.types";
162
- &nbsp;
163
- export const axiosAdapter: AxiosAdapterType = async (request, requestId) =&gt; {
164
- const {
165
- fullUrl,
166
- makeRequest,
167
- // config,
168
- // headers,
169
- onError,
170
- onResponseEnd,
171
- onRequestEnd,
172
- createAbortListener,
173
- onResponseStart,
174
- onBeforeRequest,
175
- onRequestStart,
176
- onSuccess,
177
- getAbortController,
178
- } = await getAdapterBindings&lt;AxiosAdapterType&gt;(request, requestId, 0, { headers: {} });
179
- &nbsp;
180
- const { method, options } = request;
181
- &nbsp;
182
- onBeforeRequest();
183
- &nbsp;
184
- return makeRequest((resolve) =&gt; {
185
- const controller = getAbortController();
186
- const unmountListener = <span class="fstat-no" title="function not covered" >() =&gt; createAbortListener(0, { headers: {} }, () =&gt; {}, resolve);</span>
187
- &nbsp;
188
- onRequestStart();
189
- axios({ ...options, method, url: fullUrl, signal: controller.signal })
190
- .then((response) =&gt; {
191
- <span class="cstat-no" title="statement not covered" > onRequestEnd();</span>
192
- <span class="cstat-no" title="statement not covered" > onResponseStart();</span>
193
- <span class="cstat-no" title="statement not covered" > onSuccess(response.data, response.status, { headers: response.headers }, resolve);</span>
194
- })
195
- .then(() =&gt; {
196
- <span class="cstat-no" title="statement not covered" > onResponseEnd();</span>
197
- <span class="cstat-no" title="statement not covered" > unmountListener();</span>
198
- })
199
- .catch((error) =&gt; {
200
- onError(error, error.response<span class="branch-0 cbranch-no" title="branch not covered" >?.s</span>tatus, { headers: error.response<span class="branch-0 cbranch-no" title="branch not covered" >?.h</span>eaders }, resolve);
201
- });
202
- });
203
- };
204
- &nbsp;</pre></td></tr></table></pre>
205
-
206
- <div class='push'></div><!-- for sticky footer -->
207
- </div><!-- /wrapper -->
208
- <div class='footer quiet pad2 space-top1 center small'>
209
- Code coverage generated by
210
- <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
211
- at 2023-06-04T10:54:39.932Z
212
- </div>
213
- <script src="prettify.js"></script>
214
- <script>
215
- window.onload = function () {
216
- prettyPrint();
217
- };
218
- </script>
219
- <script src="sorter.js"></script>
220
- <script src="block-navigation.js"></script>
221
- </body>
222
- </html>
223
-