@vroskus/library-api 1.0.0 → 1.0.1
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.d.ts +2 -1
- package/dist/index.js +4 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -17,17 +17,18 @@ type $SetUnauthenticatedHandlerParams = {
|
|
|
17
17
|
handler: $UnauthenticatedHandler;
|
|
18
18
|
};
|
|
19
19
|
type $SetUnauthenticatedHandlerResponse = void;
|
|
20
|
-
export declare const getMock: () => AxiosMockAdapter;
|
|
21
20
|
declare class ApiService<C extends $Config> {
|
|
22
21
|
connection: AxiosInstance;
|
|
23
22
|
unauthenticatedHandler: $UnauthenticatedHandler;
|
|
24
23
|
requestContextListener: $RequestContextListener;
|
|
25
24
|
responseContextListener: $ResponseContextListener;
|
|
25
|
+
mock: AxiosMockAdapter | null;
|
|
26
26
|
constructor({ apiUrl, timeout, }: C);
|
|
27
27
|
setUnauthenticatedHandler({ handler, }: $SetUnauthenticatedHandlerParams): $SetUnauthenticatedHandlerResponse;
|
|
28
28
|
setRequestContextListener({ listener, }: $SetRequestContextListenerParams): $SetRequestContextListenerResponse;
|
|
29
29
|
setResponseContextListener({ listener, }: $SetResponseContextListenerParams): $SetResponseContextListenerResponse;
|
|
30
30
|
pushRequestContext(config: AxiosRequestConfig<unknown>, requestId: string): void;
|
|
31
31
|
pushResponseContext(response: AxiosResponse<unknown>): void;
|
|
32
|
+
initMock(): void;
|
|
32
33
|
}
|
|
33
34
|
export default ApiService;
|
package/dist/index.js
CHANGED
|
@@ -17,14 +17,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.getMock = void 0;
|
|
21
20
|
const axios_1 = __importDefault(require("axios"));
|
|
22
21
|
const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));
|
|
23
22
|
const lodash_1 = __importDefault(require("lodash"));
|
|
24
23
|
const uuid_1 = require("uuid");
|
|
25
24
|
__exportStar(require("./types"), exports);
|
|
26
|
-
const getMock = () => new axios_mock_adapter_1.default(axios_1.default);
|
|
27
|
-
exports.getMock = getMock;
|
|
28
25
|
class ApiService {
|
|
29
26
|
constructor({ apiUrl, timeout, }) {
|
|
30
27
|
const connectionConfig = {
|
|
@@ -81,6 +78,7 @@ class ApiService {
|
|
|
81
78
|
this.pushRequestContext(config, requestId);
|
|
82
79
|
return config;
|
|
83
80
|
});
|
|
81
|
+
this.mock = null;
|
|
84
82
|
}
|
|
85
83
|
setUnauthenticatedHandler({ handler, }) {
|
|
86
84
|
this.unauthenticatedHandler = handler;
|
|
@@ -123,5 +121,8 @@ class ApiService {
|
|
|
123
121
|
const cleanResponseContext = lodash_1.default.omitBy(responseContext, lodash_1.default.isUndefined);
|
|
124
122
|
this.responseContextListener(cleanResponseContext);
|
|
125
123
|
}
|
|
124
|
+
initMock() {
|
|
125
|
+
this.mock = new axios_mock_adapter_1.default(this.connection);
|
|
126
|
+
}
|
|
126
127
|
}
|
|
127
128
|
exports.default = ApiService;
|