@pushwoosh/http-client 2.7.2 → 2.8.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.
@@ -1,231 +0,0 @@
1
- import type { RequestDetails } from './http-client.types';
2
- /**
3
- * Class describes an error related to HttpClient.
4
- * Should be used to describe all other errors related to HttpClient, but never used as a separate instance.
5
- */
6
- export declare class HttpClientError extends Error {
7
- /**
8
- * Error code.
9
- */
10
- readonly code: number;
11
- /**
12
- * Create an error instance.
13
- *
14
- * @param message - error message.
15
- * @param code - error code.
16
- */
17
- protected constructor(message: string, code: number);
18
- }
19
- /**
20
- * Class describes a logic error in HttpClient.
21
- */
22
- export declare class LogicError extends HttpClientError {
23
- /**
24
- * Create an error instance.
25
- *
26
- * @param message - error message.
27
- */
28
- constructor(message: string);
29
- }
30
- /**
31
- * Class describes categorized errors.
32
- * Should be used to describe all other categorized errors, but never used as a separate instance.
33
- *
34
- * @extends HttpClientError
35
- */
36
- export declare class ClassifiedError extends HttpClientError {
37
- /**
38
- * Request details.
39
- */
40
- readonly details: RequestDetails | null;
41
- /**
42
- * Create an error instance.
43
- *
44
- * @param message - error message.
45
- * @param code - error code.
46
- * @param details - request details.
47
- */
48
- protected constructor(message: string, code: number, details: RequestDetails | null);
49
- }
50
- /**
51
- * Error that doesn't fit into any category.
52
- */
53
- export declare class UntiledError extends ClassifiedError {
54
- /**
55
- * Create an error instance.
56
- *
57
- * @param message - error message.
58
- * @param code - error code.
59
- * @param details - request details.
60
- */
61
- constructor(message: string, code: number, details: RequestDetails | null);
62
- }
63
- /**
64
- * Class describes "Bad Request" error.
65
- */
66
- export declare class BadRequestError extends ClassifiedError {
67
- /**
68
- * Create an error instance.
69
- *
70
- * @param message - error message.
71
- * @param details - request details.
72
- */
73
- constructor(message?: string, details?: RequestDetails | null);
74
- }
75
- /**
76
- * Class describes "Unauthorized" error.
77
- */
78
- export declare class UnauthorizedError extends ClassifiedError {
79
- /**
80
- * Create an error instance.
81
- *
82
- * @param message - error message.
83
- * @param details - request details.
84
- */
85
- constructor(message?: string, details?: RequestDetails | null);
86
- }
87
- /**
88
- * Class describes "Forbidden" error.
89
- */
90
- export declare class ForbiddenError extends ClassifiedError {
91
- /**
92
- * Create an error instance.
93
- *
94
- * @param message - error message.
95
- * @param details - request details.
96
- */
97
- constructor(message?: string, details?: RequestDetails | null);
98
- }
99
- /**
100
- * Class describes "Not Found" error.
101
- */
102
- export declare class NotFoundError extends ClassifiedError {
103
- /**
104
- * Create an error instance.
105
- *
106
- * @param message - error message.
107
- * @param details - request details.
108
- */
109
- constructor(message?: string, details?: RequestDetails | null);
110
- }
111
- /**
112
- * Class describes "Method Not Allowed" error.
113
- */
114
- export declare class MethodNotAllowedError extends ClassifiedError {
115
- /**
116
- * Create an error instance.
117
- *
118
- * @param message - error message.
119
- * @param details - request details.
120
- */
121
- constructor(message?: string, details?: RequestDetails | null);
122
- }
123
- /**
124
- * Class describes "Payload Too Large" error.
125
- */
126
- export declare class PayloadTooLargeError extends ClassifiedError {
127
- /**
128
- * Create an error instance.
129
- *
130
- * @param message - error message.
131
- * @param details - request details.
132
- */
133
- constructor(message?: string, details?: RequestDetails | null);
134
- }
135
- /**
136
- * Class describes "Unsupported Media Type" error.
137
- */
138
- export declare class UnsupportedMediaTypeError extends ClassifiedError {
139
- /**
140
- * Create an error instance.
141
- *
142
- * @param message - error message.
143
- * @param details - request details.
144
- */
145
- constructor(message?: string, details?: RequestDetails | null);
146
- }
147
- /**
148
- * Class describes "Unprocessable Entity" error.
149
- */
150
- export declare class UnprocessableEntityError extends ClassifiedError {
151
- /**
152
- * Create an error instance.
153
- *
154
- * @param message - error message.
155
- * @param details - request details.
156
- */
157
- constructor(message?: string, details?: RequestDetails | null);
158
- }
159
- /**
160
- * Class describes "Too Many Requests" error.
161
- */
162
- export declare class TooManyRequestsError extends ClassifiedError {
163
- /**
164
- * Create an error instance.
165
- *
166
- * @param message - error message.
167
- * @param details - request details.
168
- */
169
- constructor(message?: string, details?: RequestDetails | null);
170
- }
171
- /**
172
- * Class describes "Internal Server Error" error.
173
- */
174
- export declare class InternalServerError extends ClassifiedError {
175
- /**
176
- * Create an error instance.
177
- *
178
- * @param message - error message.
179
- * @param details - request details.
180
- */
181
- constructor(message?: string, details?: RequestDetails | null);
182
- }
183
- /**
184
- * Class describes "Not Implemented" error.
185
- */
186
- export declare class NotImplementedError extends ClassifiedError {
187
- /**
188
- * Create an error instance.
189
- *
190
- * @param message - error message.
191
- * @param details - request details.
192
- */
193
- constructor(message?: string, details?: RequestDetails | null);
194
- }
195
- /**
196
- * Class describes "Bad Gateway" error.
197
- */
198
- export declare class BadGatewayError extends ClassifiedError {
199
- /**
200
- * Create an error instance.
201
- *
202
- * @param message - error message.
203
- * @param details - request details.
204
- */
205
- constructor(message?: string, details?: RequestDetails | null);
206
- }
207
- /**
208
- * Class describes "Service Unavailable" error.
209
- */
210
- export declare class ServiceUnavailableError extends ClassifiedError {
211
- /**
212
- * Create an error instance.
213
- *
214
- * @param message - error message.
215
- * @param details - request details.
216
- */
217
- constructor(message?: string, details?: RequestDetails | null);
218
- }
219
- /**
220
- * Class describes "Gateway Timeout" error.
221
- */
222
- export declare class GatewayTimeoutError extends ClassifiedError {
223
- /**
224
- * Create an error instance.
225
- *
226
- * @param message - error message.
227
- * @param details - request details.
228
- */
229
- constructor(message?: string, details?: RequestDetails | null);
230
- }
231
- //# sourceMappingURL=http-client.errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-client.errors.d.ts","sourceRoot":"","sources":["../src/http-client.errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACH,SAAS,aAAa,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAMpD;AAED;;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AE,cAAc,GAAG,IAAW;CAKjG;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,eAAe;IAC5D;;;;;OAKG;gBACgB,OAAO,GAAE,MAAkC,EAAE,OAAO,GAAE,cAAc,GAAG,IAAW;CAKtG;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,eAAe;IAC3D;;;;;OAKG;gBACgB,OAAO,GAAE,MAAgC,EAAE,OAAO,GAAE,cAAc,GAAG,IAAW;CAKpG;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,eAAe;IACvD;;;;;OAKG;gBACgB,OAAO,GAAE,MAA6B,EAAE,OAAO,GAAE,cAAc,GAAG,IAAW;CAKjG;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,eAAe;IACtD;;;;;OAKG;gBACgB,OAAO,GAAE,MAAiC,EAAE,OAAO,GAAE,cAAc,GAAG,IAAW;CAKrG;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,eAAe;IACtD;;;;;OAKG;gBACgB,OAAO,GAAE,MAA2B,EAAE,OAAO,GAAE,cAAc,GAAG,IAAW;CAK/F;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,eAAe;IAClD;;;;;OAKG;gBACgB,OAAO,GAAE,MAAuB,EAAE,OAAO,GAAE,cAAc,GAAG,IAAW;CAK3F;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D;;;;;OAKG;gBACgB,OAAO,GAAE,MAA+B,EAAE,OAAO,GAAE,cAAc,GAAG,IAAW;CAKnG;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,eAAe;IACtD;;;;;OAKG;gBACgB,OAAO,GAAE,MAA2B,EAAE,OAAO,GAAE,cAAc,GAAG,IAAW;CAK/F"}
@@ -1,3 +0,0 @@
1
- import { Params } from './http-client.types';
2
- export declare function updatePath(url: string, params: Params): string;
3
- //# sourceMappingURL=http-client.helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-client.helpers.d.ts","sourceRoot":"","sources":["../src/http-client.helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAQ7C,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAU9D"}
@@ -1,180 +0,0 @@
1
- import type { History } from 'history';
2
- import { AccessToken, Body, CodeAuthorization, Config, DeleteOptions, GetOptions, Introspect, Method, Params, PatchOptions, PostOptions, PutOptions, Query, RequestDetails, RequestOptions, Result, StreamOptions } from './http-client.types';
3
- export declare class HttpClient {
4
- /**
5
- * Cookie name used to save the authorization state
6
- * For more information see https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.1
7
- */
8
- static AUTHORIZATION_STATE_COOKIE_NAME: string;
9
- private static readonly AUTHORIZATION_STATE_SESSION_KEY;
10
- private static readonly URL_BEFORE_AUTHORIZATION_SESSION_KEY;
11
- /**
12
- * Cookie name used to save the page address before authorization
13
- */
14
- static URL_BEFORE_AUTHORIZATION_COOKIE_NAME: string;
15
- /**
16
- * Base URL for requests
17
- */
18
- private readonly baseURL?;
19
- /**
20
- * API for working with navigation
21
- */
22
- private readonly history;
23
- /**
24
- * Http Client configuration
25
- */
26
- private readonly config;
27
- /**
28
- * Access token used to access protected resources
29
- * For more information see https://www.rfc-editor.org/rfc/rfc6749.html#section-1.4
30
- */
31
- private accessToken;
32
- /**
33
- * Refresh token used to refresh the access token.
34
- * For more information see https://www.rfc-editor.org/rfc/rfc6749.html#section-1.5
35
- */
36
- private refreshToken;
37
- /**
38
- * Is token refresh in progress
39
- */
40
- private isRefreshing;
41
- /**
42
- * Email or username of the logged in user.
43
- * Taken from jwt (claims).
44
- */
45
- private userName;
46
- /**
47
- * Account ID under which the user is logged in.
48
- * Taken from jwt (claims).
49
- */
50
- private accountID;
51
- /**
52
- * Create an instance of the class
53
- *
54
- * @param history - API for working with navigation
55
- * @param config - Http Client configuration
56
- */
57
- constructor(history: History, config: Config);
58
- /**
59
- * Check for authorization
60
- *
61
- * @param details - request details to protected resources
62
- */
63
- private checkAuthorization;
64
- /**
65
- * Update access token
66
- * For more information see:
67
- * https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.3
68
- * https://www.rfc-editor.org/rfc/rfc6749.html#section-6
69
- *
70
- * @param query - query parameters involved in the update
71
- */
72
- private updateToken;
73
- /**
74
- * Update access token using authorization code
75
- * For more information see: https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.3
76
- *
77
- * @param authorizationCode - authorization code received from the authorization server
78
- */
79
- updateTokenByAuthorizationCode: (authorizationCode: string) => Promise<void>;
80
- /**
81
- * Update access token using refresh token
82
- * For more information see: https://www.rfc-editor.org/rfc/rfc6749.html#section-6
83
- *
84
- * @param details - request details to protected resources
85
- */
86
- updateTokenByRefreshToken: (details: RequestDetails | null) => Promise<void>;
87
- /**
88
- * Process response from fetch request
89
- *
90
- * @param response - fetch response
91
- * @param details - request details
92
- * @param responseMiddleware - middleware to process response
93
- */
94
- private processFetchResponse;
95
- /**
96
- * Build fetch request URL, headers, and options from the given parameters.
97
- * Shared by both `request()` and `stream()`.
98
- */
99
- private buildFetchRequest;
100
- /**
101
- * Make a request
102
- *
103
- * @param url - request address
104
- * @param method - request method
105
- * @param options - request configuration
106
- */
107
- request: <M extends Method, R extends Result, P extends Params | never, Q extends Query | never, B extends Body | never>(url: string, method: M, options: RequestOptions<M, R, P, Q, B>) => Promise<R>;
108
- /**
109
- * Make a streaming request that returns the raw Response.
110
- * Use this for NDJSON, SSE, or other streaming protocols where
111
- * you need access to response.body (ReadableStream).
112
- *
113
- * @param url - request address
114
- * @param method - request method
115
- * @param options - stream request configuration
116
- */
117
- stream: (url: string, method: Method, options: StreamOptions) => Promise<globalThis.Response>;
118
- /**
119
- * Perform GET request
120
- *
121
- * @param url - request address
122
- * @param options - GET request configuration
123
- */
124
- get: <R extends Result, P extends Params | never, Q extends Query | never>(url: string, options: GetOptions<R, P, Q>) => Promise<R>;
125
- /**
126
- * Perform POST request
127
- *
128
- * @param url - request address
129
- * @param options - POST request configuration
130
- */
131
- post: <R extends Result, P extends Params | never, Q extends Query | never, B extends Body>(url: string, options: PostOptions<R, P, Q, B>) => Promise<R>;
132
- /**
133
- * Perform PUT request
134
- *
135
- * @param url - request address
136
- * @param options - PUT request configuration
137
- */
138
- put: <R extends Result, P extends Params | never, Q extends Query | never, B extends Body>(url: string, options: PutOptions<R, P, Q, B>) => Promise<R>;
139
- /**
140
- * Perform PATCH request
141
- *
142
- * @param url - request address
143
- * @param options - PATCH request configuration
144
- */
145
- patch: <R extends Result, P extends Params | never, Q extends Query | never, B extends Body>(url: string, options: PatchOptions<R, P, Q, B>) => Promise<R>;
146
- /**
147
- * Perform DELETE request
148
- *
149
- * @param url - request address
150
- * @param options - DELETE request configuration
151
- */
152
- delete: <R extends Result, P extends Params | never, Q extends Query | never, B extends Body>(url: string, options: DeleteOptions<R, P, Q, B>) => Promise<R>;
153
- /**
154
- * Perform the first step of client authorization
155
- * For more information see https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.1
156
- */
157
- login: () => Promise<void>;
158
- /**
159
- * Perform the second step of client authorization
160
- * For more information see https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.3
161
- *
162
- * @param authorization - client authorization data on the server
163
- */
164
- authorize: <I extends Introspect>(authorization: CodeAuthorization) => Promise<I>;
165
- /**
166
- * End the session
167
- */
168
- logout: () => Promise<void>;
169
- /**
170
- * Get access token
171
- */
172
- getAccessToken: () => Promise<AccessToken>;
173
- /**
174
- * Manually set the access token
175
- *
176
- * @param accessToken - access token
177
- */
178
- setAccessToken: (accessToken: string) => void;
179
- }
180
- //# sourceMappingURL=http-client.main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-client.main.d.ts","sourceRoot":"","sources":["../src/http-client.main.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAUvC,OAAO,EACL,WA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C,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAAC,CAE1J;IAEF;;;;;OAKG;IACI,KAAK,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,KAAK,EAAE,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,CAAC,SAAS,IAAI,EAAE,KAAK,MAAM,EAAE,SAAS,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAAC,CAE9J;IAEF;;;;;OAKG;IACI,MAAM,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,KAAK,EAAE,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,CAAC,SAAS,IAAI,EAAE,KAAK,MAAM,EAAE,SAAS,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAAC,CAEhK;IAEF;;;OAGG;IACI,KAAK,QAAa,OAAO,CAAC,IAAI,CAAC,CAoBpC;IAEF;;;;;OAKG;IACI,SAAS,GAAU,CAAC,SAAS,UAAU,EAAE,eAAe,iBAAiB,KAAG,OAAO,CAAC,CAAC,CAAC,CAsC3F;IAEF;;OAEG;IACI,MAAM,QAAa,OAAO,CAAC,IAAI,CAAC,CAWrC;IAEF;;OAEG;IACI,cAAc,QAAa,OAAO,CAAC,WAAW,CAAC,CAOpD;IAEF;;;;OAIG;IACI,cAAc,GAAI,aAAa,MAAM,KAAG,IAAI,CAEjD;CACH"}
@@ -1,99 +0,0 @@
1
- import type { CookieAttributes } from 'js-cookie';
2
- export type AccessToken = string;
3
- export type RefreshToken = string;
4
- export declare enum Method {
5
- GET = "GET",
6
- POST = "POST",
7
- PUT = "PUT",
8
- PATCH = "PATCH",
9
- DELETE = "DELETE"
10
- }
11
- export type Headers = Record<string, string | number | boolean>;
12
- export type Params = Record<string, string | number>;
13
- export type Query = Record<string, string> | URLSearchParams | string;
14
- export type Body = Record<string, unknown> | FormData;
15
- export type Result = unknown;
16
- export type RequestDetails = {
17
- readonly url: string;
18
- readonly method: Method;
19
- readonly params: Params;
20
- readonly query: Query;
21
- readonly body: Body;
22
- readonly withCredentials?: boolean;
23
- readonly withAuthorization: boolean;
24
- };
25
- export type Response = {
26
- readonly result: any;
27
- readonly status: number;
28
- readonly message?: string;
29
- readonly details: RequestDetails;
30
- };
31
- export type CommonRequestOptions<R extends Result> = {
32
- readonly headers?: Headers;
33
- readonly withAuthorization: boolean;
34
- readonly withCredentials?: boolean;
35
- readonly responseMiddleware?: (response: Response) => Promise<R> | R;
36
- readonly errorMiddleware?: (error: unknown) => Promise<never> | never;
37
- };
38
- export type RequestOptions<M extends Method, R extends Result, P extends Params | never, Q extends Query | never, B extends Body | never> = M extends Method.GET ? [P] extends [never] ? [Q] extends [never] ? CommonRequestOptions<R> : CommonRequestOptions<R> & {
39
- readonly query: Q;
40
- } : [Q] extends [never] ? CommonRequestOptions<R> & {
41
- readonly params: P;
42
- } : CommonRequestOptions<R> & {
43
- readonly query: Q;
44
- readonly params: P;
45
- } : [P] extends [never] ? [Q] extends [never] ? [B] extends [never] ? CommonRequestOptions<R> : CommonRequestOptions<R> & {
46
- readonly body: B;
47
- } : [B] extends [never] ? CommonRequestOptions<R> & {
48
- readonly query: Q;
49
- } : CommonRequestOptions<R> & {
50
- readonly query: Q;
51
- readonly body: B;
52
- } : [Q] extends [never] ? [B] extends [never] ? CommonRequestOptions<R> & {
53
- readonly params: P;
54
- } : CommonRequestOptions<R> & {
55
- readonly params: P;
56
- readonly body: B;
57
- } : [B] extends [never] ? CommonRequestOptions<R> & {
58
- readonly params: P;
59
- readonly query: Q;
60
- } : CommonRequestOptions<R> & {
61
- readonly params: P;
62
- readonly query: Q;
63
- readonly body: B;
64
- };
65
- export type GetOptions<R extends Result, P extends Params | never, Q extends Query | never> = Omit<RequestOptions<Method.GET, R, P, Q, never>, 'method'>;
66
- export type PostOptions<R extends Result, P extends Params | never, Q extends Query | never, B extends Body> = Omit<RequestOptions<Method.POST, R, P, Q, B>, 'method'>;
67
- export type PutOptions<R extends Result, P extends Params | never, Q extends Query | never, B extends Body> = Omit<RequestOptions<Method.PUT, R, P, Q, B>, 'method'>;
68
- export type PatchOptions<R extends Result, P extends Params | never, Q extends Query | never, B extends Body> = Omit<RequestOptions<Method.PATCH, R, P, Q, B>, 'method'>;
69
- export type DeleteOptions<R extends Result, P extends Params | never, Q extends Query | never, B extends Body> = Omit<RequestOptions<Method.DELETE, R, P, Q, B>, 'method'>;
70
- export type Config = {
71
- readonly urls: {
72
- readonly authorize: string;
73
- readonly token: string;
74
- readonly logout: string;
75
- };
76
- readonly baseURL?: string;
77
- readonly clientId: string;
78
- readonly cookie: Omit<CookieAttributes, 'domain'> & {
79
- readonly domain: string;
80
- };
81
- readonly basicResponseMiddleware: <R extends Result>(response: Response) => Promise<R> | R;
82
- readonly basicErrorMiddleware: (error: unknown) => Promise<never> | never;
83
- };
84
- export type CodeAuthorization = {
85
- readonly state: string;
86
- readonly code: string;
87
- };
88
- export type Introspect = Record<string, unknown>;
89
- export type StreamOptions = {
90
- readonly headers?: Headers;
91
- readonly withAuthorization: boolean;
92
- readonly withCredentials?: boolean;
93
- readonly signal?: AbortSignal;
94
- readonly errorMiddleware?: (error: unknown) => Promise<never> | never;
95
- readonly params?: Params;
96
- readonly query?: Query;
97
- readonly body?: Body;
98
- };
99
- //# sourceMappingURL=http-client.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-client.types.d.ts","sourceRoot":"","sources":["../src/http-client.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,oBAAY,MAAM;IAChB,GAAG,QAAQ;IACX,IAAI,SA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
2
- /**
3
- * Check if the request was successful.
4
- *
5
- * @param response - response from the server.
6
- */
7
- export declare function checkIsResponseSuccess(response: Response): boolean;
8
- /**
9
- * Default server response handler.
10
- *
11
- * @param response - response from the server.
12
- */
13
- export declare function defaultResponseMiddleware<R extends Result>(response: Response): R;
14
- /**
15
- * Default error handler.
16
- *
17
- * @param error - error.
18
- */
19
- export declare function defaultErrorMiddleware(error: unknown): never;
20
- //# sourceMappingURL=http-client.utilities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-client.utilities.d.ts","sourceRoot":"","sources":["../src/http-client.utilities.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,QAAQ,EACR,MAAM,EACP,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAElE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,CAAC,CAyCjF;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAE5D"}
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './http-client.errors';
2
- export * from './http-client.main';
3
- export * from './http-client.types';
4
- export * from './http-client.utilities';
5
- export * from './rpc-client';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC"}