@hyper-fetch/core 3.1.0 → 3.2.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.
Files changed (61) hide show
  1. package/.eslintrc.json +1 -2
  2. package/README.md +13 -13
  3. package/dist/index.d.ts +1273 -11
  4. package/package.json +2 -2
  5. package/tsconfig.json +1 -0
  6. package/dist/adapter/adapter.bindings.d.ts +0 -25
  7. package/dist/adapter/adapter.browser.d.ts +0 -2
  8. package/dist/adapter/adapter.constants.d.ts +0 -1
  9. package/dist/adapter/adapter.d.ts +0 -2
  10. package/dist/adapter/adapter.server.d.ts +0 -2
  11. package/dist/adapter/adapter.types.d.ts +0 -57
  12. package/dist/adapter/adapter.utils.d.ts +0 -8
  13. package/dist/adapter/index.d.ts +0 -7
  14. package/dist/cache/cache.d.ts +0 -76
  15. package/dist/cache/cache.events.d.ts +0 -28
  16. package/dist/cache/cache.types.d.ts +0 -50
  17. package/dist/cache/cache.utils.d.ts +0 -6
  18. package/dist/cache/index.d.ts +0 -4
  19. package/dist/client/client.constants.d.ts +0 -9
  20. package/dist/client/client.d.ts +0 -142
  21. package/dist/client/client.types.d.ts +0 -41
  22. package/dist/client/client.utils.d.ts +0 -10
  23. package/dist/client/index.d.ts +0 -4
  24. package/dist/constants/http.constants.d.ts +0 -7
  25. package/dist/constants/time.constants.d.ts +0 -11
  26. package/dist/dispatcher/dispatcher.constants.d.ts +0 -6
  27. package/dist/dispatcher/dispatcher.d.ts +0 -155
  28. package/dist/dispatcher/dispatcher.events.d.ts +0 -11
  29. package/dist/dispatcher/dispatcher.types.d.ts +0 -31
  30. package/dist/dispatcher/dispatcher.utils.d.ts +0 -10
  31. package/dist/dispatcher/index.d.ts +0 -5
  32. package/dist/effect/index.d.ts +0 -2
  33. package/dist/effect/request.effect.d.ts +0 -14
  34. package/dist/effect/request.effect.types.d.ts +0 -32
  35. package/dist/managers/app/app.manager.constants.d.ts +0 -9
  36. package/dist/managers/app/app.manager.d.ts +0 -34
  37. package/dist/managers/app/app.manager.events.d.ts +0 -11
  38. package/dist/managers/app/app.manager.types.d.ts +0 -6
  39. package/dist/managers/app/app.manager.utils.d.ts +0 -4
  40. package/dist/managers/app/index.d.ts +0 -5
  41. package/dist/managers/index.d.ts +0 -3
  42. package/dist/managers/logger/index.d.ts +0 -4
  43. package/dist/managers/logger/logger.manager.constants.d.ts +0 -4
  44. package/dist/managers/logger/logger.manager.d.ts +0 -19
  45. package/dist/managers/logger/logger.manager.types.d.ts +0 -30
  46. package/dist/managers/logger/logger.manager.utils.d.ts +0 -3
  47. package/dist/managers/request/index.d.ts +0 -4
  48. package/dist/managers/request/request.manager.d.ts +0 -43
  49. package/dist/managers/request/request.manager.events.d.ts +0 -36
  50. package/dist/managers/request/request.manager.types.d.ts +0 -23
  51. package/dist/managers/request/request.manager.utils.d.ts +0 -16
  52. package/dist/request/index.d.ts +0 -3
  53. package/dist/request/request.d.ts +0 -98
  54. package/dist/request/request.types.d.ts +0 -202
  55. package/dist/request/request.utils.d.ts +0 -22
  56. package/dist/types/fetch.types.d.ts +0 -16
  57. package/dist/types/helpers.types.d.ts +0 -11
  58. package/dist/types/http.types.d.ts +0 -1
  59. package/dist/types/index.d.ts +0 -3
  60. package/dist/utils/index.d.ts +0 -1
  61. package/dist/utils/uuid.utils.d.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyper-fetch/core",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "private": false,
5
5
  "description": "Cache, Queue and Persist your requests no matter if you are online or offline!",
6
6
  "author": "Maciej Pyrc <m.pyrc@interia.pl>",
@@ -17,7 +17,7 @@
17
17
  "test-pipeline": "jest --watchAll=false --maxWorkers=1 --no-cache",
18
18
  "start": "yarn build && npx run-when-changed --watch 'src/**/*.ts' --exec 'yarn build'",
19
19
  "build": "yarn clean && node ../../scripts/build.js",
20
- "postbuild": "ttsc --project tsconfig.json --outDir dist",
20
+ "postbuild": "rollup -c '../../rollup.config.js'",
21
21
  "lint": "eslint . --ext .js,.jsx,.tsx,.ts --fix",
22
22
  "format": "prettier --write .",
23
23
  "typecheck": "tsc --noEmit --emitDeclarationOnly false",
package/tsconfig.json CHANGED
@@ -4,5 +4,6 @@
4
4
  "rootDir": "./src",
5
5
  "baseUrl": "./src"
6
6
  },
7
+ "include": ["./src/index.ts"],
7
8
  "exclude": ["dist", "__tests__", "jest.config.ts"]
8
9
  }
@@ -1,25 +0,0 @@
1
- import { ResponseSuccessType, ResponseErrorType, ProgressDataType } from "adapter";
2
- import { RequestInstance } from "request";
3
- import { ExtractResponseType, ExtractErrorType } from "types";
4
- export declare const getAdapterBindings: <ConfigType = any>(cmd: RequestInstance, requestId: string) => Promise<{
5
- fullUrl: string;
6
- headers: HeadersInit;
7
- payload: string | FormData;
8
- config: ConfigType;
9
- getAbortController: () => AbortController;
10
- getRequestStartTimestamp: () => number;
11
- getResponseStartTimestamp: () => number;
12
- createAbortListener: <T extends RequestInstance>(callback: () => void, resolve: (value: ResponseErrorType<ExtractErrorType<T>>) => void) => () => void;
13
- onBeforeRequest: () => void;
14
- onRequestStart: (progress?: ProgressDataType) => number;
15
- onRequestProgress: (progress: ProgressDataType) => number;
16
- onRequestEnd: () => number;
17
- onResponseStart: (progress?: ProgressDataType) => number;
18
- onResponseProgress: (progress: ProgressDataType) => number;
19
- onResponseEnd: () => number;
20
- onSuccess: <T_1 extends RequestInstance>(responseData: unknown, status: number, resolve: (value: ResponseErrorType<ExtractErrorType<T_1>>) => void) => Promise<ResponseSuccessType<ExtractResponseType<T_1>>>;
21
- onAbortError: <T_2 extends RequestInstance>(resolve: (value: ResponseErrorType<ExtractErrorType<T_2>>) => void) => Promise<ResponseErrorType<ExtractErrorType<T_2>>>;
22
- onTimeoutError: <T_3 extends RequestInstance>(resolve: (value: ResponseErrorType<ExtractErrorType<T_3>>) => void) => Promise<ResponseErrorType<ExtractErrorType<T_3>>>;
23
- onUnexpectedError: <T_4 extends RequestInstance>(resolve: (value: ResponseErrorType<ExtractErrorType<T_4>>) => void) => Promise<ResponseErrorType<ExtractErrorType<T_4>>>;
24
- onError: <T_5 extends RequestInstance>(error: Error | ExtractErrorType<T_5>, status: number, resolve: (value: ResponseErrorType<ExtractErrorType<T_5>>) => void) => Promise<ResponseErrorType<ExtractErrorType<T_5>>>;
25
- }>;
@@ -1,2 +0,0 @@
1
- import { AdapterType } from "adapter";
2
- export declare const browserAdapter: AdapterType;
@@ -1 +0,0 @@
1
- export declare const defaultTimeout: number;
@@ -1,2 +0,0 @@
1
- import { AdapterType } from "adapter";
2
- export declare const adapter: AdapterType;
@@ -1,2 +0,0 @@
1
- import { AdapterType } from "adapter";
2
- export declare const serverAdapter: AdapterType;
@@ -1,57 +0,0 @@
1
- import { RequestInstance } from "request";
2
- export type AdapterType = (request: RequestInstance, requestId: string) => Promise<ResponseType<any, any>>;
3
- export type AdapterOptionsType = Partial<XMLHttpRequest>;
4
- export type AdapterPayloadMappingType = (data: unknown) => string | FormData;
5
- export type ResponseType<GenericDataType, GenericErrorType> = [
6
- GenericDataType | null,
7
- GenericErrorType | null,
8
- number | null
9
- ];
10
- export type ResponseSuccessType<GenericDataType> = [GenericDataType, null, number | null];
11
- export type ResponseErrorType<GenericErrorType> = [null, GenericErrorType, number | null];
12
- export type QueryParamValuesType = number | string | boolean | null | undefined;
13
- export type QueryParamType = QueryParamValuesType | Array<QueryParamValuesType> | Record<string, QueryParamValuesType>;
14
- export type QueryParamsType = Record<string, QueryParamType>;
15
- export type HeaderMappingType = <T extends RequestInstance>(request: T) => HeadersInit;
16
- export type AdapterHeadersProps = {
17
- isFormData: boolean;
18
- headers: HeadersInit | undefined;
19
- };
20
- export type QueryStringifyOptionsType = {
21
- /**
22
- * Strict URI encoding
23
- */
24
- strict?: boolean;
25
- /**
26
- * Encode keys and values
27
- */
28
- encode?: boolean;
29
- /**
30
- * Array encoding type
31
- */
32
- arrayFormat?: "bracket" | "index" | "comma" | "separator" | "bracket-separator" | "none";
33
- /**
34
- * Array format separator
35
- */
36
- arraySeparator?: string;
37
- /**
38
- * Skip keys with null values
39
- */
40
- skipNull?: boolean;
41
- /**
42
- * Skip keys with empty string
43
- */
44
- skipEmptyString?: boolean;
45
- };
46
- export type ProgressDataType = {
47
- total?: number;
48
- loaded?: number;
49
- };
50
- export type ProgressType = {
51
- progress: number;
52
- timeLeft: number | null;
53
- sizeLeft: number;
54
- total: number;
55
- loaded: number;
56
- startTimestamp: number;
57
- };
@@ -1,8 +0,0 @@
1
- import { RequestInstance } from "request";
2
- import { ExtractErrorType } from "types";
3
- export declare const getErrorMessage: (errorCase?: "timeout" | "abort" | "deleted") => Error;
4
- export declare const parseResponse: (response: string | unknown) => any;
5
- export declare const parseErrorResponse: <T extends RequestInstance>(response: unknown) => ExtractErrorType<T>;
6
- export declare const getUploadSize: (payload: FormData | string) => number;
7
- export declare const fileToBuffer: (file: File | Blob) => Promise<Uint8Array>;
8
- export declare const getStreamPayload: (payload: FormData | string | null) => string | Promise<(string | Uint8Array)[]>;
@@ -1,7 +0,0 @@
1
- export * from "./adapter";
2
- export * from "./adapter.types";
3
- export * from "./adapter.utils";
4
- export * from "./adapter.server";
5
- export * from "./adapter.browser";
6
- export * from "./adapter.bindings";
7
- export * from "./adapter.constants";
@@ -1,76 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import EventEmitter from "events";
4
- import { ResponseType } from "adapter";
5
- import { ClientInstance } from "client";
6
- import { ResponseDetailsType } from "managers";
7
- import { CacheOptionsType, CacheAsyncStorageType, CacheStorageType, getCacheEvents, CacheValueType } from "cache";
8
- import { RequestDump, RequestInstance } from "request";
9
- /**
10
- * Cache class handles the data exchange with the dispatchers.
11
- *
12
- * @note
13
- * Keys used to save the values are created dynamically on the Request class
14
- *
15
- */
16
- export declare class Cache {
17
- client: ClientInstance;
18
- options?: CacheOptionsType;
19
- emitter: EventEmitter;
20
- events: ReturnType<typeof getCacheEvents>;
21
- storage: CacheStorageType;
22
- lazyStorage?: CacheAsyncStorageType;
23
- clearKey: string;
24
- garbageCollectors: Map<string, NodeJS.Timeout>;
25
- private logger;
26
- constructor(client: ClientInstance, options?: CacheOptionsType);
27
- /**
28
- * Set the cache data to the storage
29
- * @param request
30
- * @param response
31
- * @param details
32
- * @returns
33
- */
34
- set: <Response_1, Error_1>(request: RequestInstance | RequestDump<RequestInstance>, response: ResponseType<Response_1, Error_1>, details: ResponseDetailsType) => void;
35
- /**
36
- * Get particular record from storage by cacheKey. It will trigger lazyStorage to emit lazy load event for reading it's data.
37
- * @param cacheKey
38
- * @returns
39
- */
40
- get: <Response_1, Error_1>(cacheKey: string) => CacheValueType<Response_1, Error_1>;
41
- /**
42
- * Get sync storage keys, lazyStorage keys will not be included
43
- * @returns
44
- */
45
- keys: () => string[];
46
- /**
47
- * Delete record from storages and trigger revalidation
48
- * @param cacheKey
49
- */
50
- delete: (cacheKey: string) => void;
51
- /**
52
- * Revalidate cache by cacheKey or partial matching with RegExp
53
- * @param cacheKey
54
- */
55
- revalidate: (cacheKey: string | RegExp) => Promise<void>;
56
- /**
57
- * Used to receive data from lazy storage
58
- * @param cacheKey
59
- */
60
- getLazyResource: <Response_1, Error_1>(cacheKey: string) => Promise<CacheValueType<Response_1, Error_1>>;
61
- /**
62
- * Used to receive keys from sync storage and lazy storage
63
- * @param cacheKey
64
- */
65
- getLazyKeys: () => Promise<string[]>;
66
- /**
67
- * Schedule garbage collection for given key
68
- * @param cacheKey
69
- * @returns
70
- */
71
- scheduleGarbageCollector: (cacheKey: string) => Promise<void>;
72
- /**
73
- * Clear cache storages
74
- */
75
- clear: () => Promise<void>;
76
- }
@@ -1,28 +0,0 @@
1
- import EventEmitter from "events";
2
- import { CacheValueType } from "cache";
3
- export declare const getCacheEvents: (emitter: EventEmitter) => {
4
- /**
5
- * Set cache data
6
- * @param cacheKey
7
- * @param data
8
- */
9
- emitCacheData: <Response_1, Error_1>(cacheKey: string, data: CacheValueType<Response_1, Error_1>) => void;
10
- /**
11
- * Revalidate cache values event
12
- */
13
- emitRevalidation: (cacheKey: string) => void;
14
- /**
15
- * Cache data listener
16
- * @param cacheKey
17
- * @param callback
18
- * @returns
19
- */
20
- onData: <Response_2, Error_2>(cacheKey: string, callback: (data: CacheValueType<Response_2, Error_2>) => void) => VoidFunction;
21
- /**
22
- * Cache invalidation listener
23
- * @param cacheKey
24
- * @param callback
25
- * @returns
26
- */
27
- onRevalidate: (cacheKey: string, callback: () => void) => VoidFunction;
28
- };
@@ -1,50 +0,0 @@
1
- import { Cache } from "cache";
2
- import { ResponseType } from "adapter";
3
- import { ResponseDetailsType } from "managers";
4
- export type CacheOptionsType = {
5
- /**
6
- * Assign your custom sync storage
7
- */
8
- storage?: CacheStorageType;
9
- /**
10
- * Lazy loading from remote resources - possibly persistent
11
- */
12
- lazyStorage?: CacheAsyncStorageType;
13
- /**
14
- * Key to clear lazy storage data
15
- */
16
- clearKey?: string;
17
- /**
18
- * Initialization callback
19
- */
20
- onInitialization?: (cache: Cache) => void;
21
- /**
22
- * Callback for every change in the storage
23
- */
24
- onChange?: <Response = any, Error = any>(key: string, data: CacheValueType<Response, Error>) => void;
25
- /**
26
- * Callback for every delete in the storage
27
- */
28
- onDelete?: (key: string) => void;
29
- };
30
- export type CacheValueType<Response = any, Error = any> = {
31
- data: ResponseType<Response, Error>;
32
- details: ResponseDetailsType;
33
- cacheTime: number;
34
- clearKey: string;
35
- garbageCollection: number;
36
- };
37
- export type CacheAsyncStorageType = {
38
- set: <Response, Error>(key: string, data: CacheValueType<Response, Error>) => Promise<void>;
39
- get: <Response, Error>(key: string) => Promise<CacheValueType<Response, Error> | undefined>;
40
- keys: () => Promise<string[] | IterableIterator<string> | string[]>;
41
- delete: (key: string) => Promise<void>;
42
- };
43
- export type CacheStorageType = {
44
- set: <Response, Error>(key: string, data: CacheValueType<Response, Error>) => void;
45
- get: <Response, Error>(key: string) => CacheValueType<Response, Error> | undefined;
46
- keys: () => string[] | IterableIterator<string> | string[];
47
- delete: (key: string) => void;
48
- clear: () => void;
49
- };
50
- export type CacheInitialData = Record<string, CacheValueType>;
@@ -1,6 +0,0 @@
1
- import { RequestInstance } from "request";
2
- import { ExtractAdapterReturnType } from "types";
3
- export declare const getCacheData: <T extends RequestInstance>(previousResponse: ExtractAdapterReturnType<T>, response: ExtractAdapterReturnType<T>) => ExtractAdapterReturnType<T>;
4
- export declare const getRevalidateEventKey: (key: string) => string;
5
- export declare const getCacheKey: (key: string) => string;
6
- export declare const getCacheIdKey: (key: string) => string;
@@ -1,4 +0,0 @@
1
- export * from "./cache";
2
- export * from "./cache.types";
3
- export * from "./cache.utils";
4
- export * from "./cache.events";
@@ -1,9 +0,0 @@
1
- export declare const stringifyDefaultOptions: {
2
- readonly strict: true;
3
- readonly encode: true;
4
- readonly arrayFormat: "bracket";
5
- readonly arraySeparator: "";
6
- readonly sort: false;
7
- readonly skipNull: true;
8
- readonly skipEmptyString: true;
9
- };
@@ -1,142 +0,0 @@
1
- import { AdapterType, AdapterOptionsType, ResponseType, QueryParamsType, QueryStringifyOptionsType, HeaderMappingType, AdapterPayloadMappingType } from "adapter";
2
- import { ClientOptionsType, ClientInstance, ClientErrorType, StringifyCallbackType, RequestInterceptorType, ResponseInterceptorType } from "client";
3
- import { Cache } from "cache";
4
- import { Dispatcher } from "dispatcher";
5
- import { RequestEffectInstance } from "effect";
6
- import { Request, RequestOptionsType, RequestInstance } from "request";
7
- import { AppManager, RequestManager, LoggerManager, SeverityType } from "managers";
8
- /**
9
- * **Client** is a class that allows you to configure the connection with the server and then use it to create
10
- * requests which, when called using the appropriate method, will cause the server to be queried for the endpoint and
11
- * method specified in the request.
12
- * @position 1
13
- */
14
- export declare class Client<GlobalErrorType extends ClientErrorType = Error, AdapterOptions = AdapterOptionsType> {
15
- options: ClientOptionsType;
16
- readonly url: string;
17
- debug: boolean;
18
- __onErrorCallbacks: ResponseInterceptorType[];
19
- __onSuccessCallbacks: ResponseInterceptorType[];
20
- __onResponseCallbacks: ResponseInterceptorType[];
21
- __onAuthCallbacks: RequestInterceptorType[];
22
- __onRequestCallbacks: RequestInterceptorType[];
23
- requestManager: RequestManager;
24
- appManager: AppManager;
25
- loggerManager: LoggerManager;
26
- adapter: AdapterType;
27
- cache: Cache;
28
- fetchDispatcher: Dispatcher;
29
- submitDispatcher: Dispatcher;
30
- effects: RequestEffectInstance[];
31
- queryParamsConfig?: QueryStringifyOptionsType;
32
- adapterDefaultOptions?: (request: RequestInstance) => AdapterOptions;
33
- requestDefaultOptions?: (options: RequestOptionsType<string, AdapterOptions>) => Partial<RequestOptionsType<string, AdapterOptions>>;
34
- /**
35
- * Method to stringify query params from objects.
36
- */
37
- stringifyQueryParams: StringifyCallbackType;
38
- /**
39
- * Method to get default headers and to map them based on the data format exchange, by default it handles FormData / JSON formats.
40
- */
41
- headerMapper: HeaderMappingType;
42
- /**
43
- * Method to get request data and transform them to the required format. It handles FormData and JSON by default.
44
- */
45
- payloadMapper: AdapterPayloadMappingType;
46
- logger: import("managers").LoggerType;
47
- constructor(options: ClientOptionsType);
48
- /**
49
- * This method allows to configure global defaults for the request configuration like method, auth, deduplication etc.
50
- */
51
- setRequestDefaultOptions: (callback: (request: RequestInstance) => Partial<RequestOptionsType<string, AdapterOptions>>) => Client<GlobalErrorType, AdapterOptions>;
52
- setAdapterDefaultOptions: (callback: (request: RequestInstance) => AdapterOptions) => Client<GlobalErrorType, AdapterOptions>;
53
- /**
54
- * This method enables the logger usage and display the logs in console
55
- */
56
- setDebug: (debug: boolean) => Client<GlobalErrorType, AdapterOptions>;
57
- /**
58
- * Set the logger severity of the messages displayed to the console
59
- */
60
- setLoggerSeverity: (severity: SeverityType) => Client<GlobalErrorType, AdapterOptions>;
61
- /**
62
- * Set the new logger instance to the Client
63
- */
64
- setLogger: (callback: (Client: ClientInstance) => LoggerManager) => Client<GlobalErrorType, AdapterOptions>;
65
- /**
66
- * Set config for the query params stringify method, we can set here, among others, arrayFormat, skipNull, encode, skipEmptyString and more
67
- */
68
- setQueryParamsConfig: (queryParamsConfig: QueryStringifyOptionsType) => Client<GlobalErrorType, AdapterOptions>;
69
- /**
70
- * Set the custom query params stringify method to the Client
71
- * @param stringifyFn Custom callback handling query params stringify
72
- */
73
- setStringifyQueryParams: (stringifyFn: StringifyCallbackType) => Client<GlobalErrorType, AdapterOptions>;
74
- /**
75
- * Set the custom header mapping function
76
- */
77
- setHeaderMapper: (headerMapper: HeaderMappingType) => Client<GlobalErrorType, AdapterOptions>;
78
- /**
79
- * Set the request payload mapping function which get triggered before request get send
80
- */
81
- setPayloadMapper: (payloadMapper: AdapterPayloadMappingType) => Client<GlobalErrorType, AdapterOptions>;
82
- /**
83
- * Set custom http adapter to handle graphql, rest, firebase or other
84
- */
85
- setAdapter: (callback: (Client: ClientInstance) => AdapterType) => Client<GlobalErrorType, AdapterOptions>;
86
- /**
87
- * Method of manipulating requests before sending the request. We can for example add custom header with token to the request which request had the auth set to true.
88
- */
89
- onAuth: (callback: RequestInterceptorType) => Client<GlobalErrorType, AdapterOptions>;
90
- /**
91
- * Method for intercepting error responses. It can be used for example to refresh tokens.
92
- */
93
- onError: <ErrorType = null>(callback: ResponseInterceptorType<any, GlobalErrorType | ErrorType>) => Client<GlobalErrorType, AdapterOptions>;
94
- /**
95
- * Method for intercepting success responses.
96
- */
97
- onSuccess: <ErrorType = null>(callback: ResponseInterceptorType<any, GlobalErrorType | ErrorType>) => Client<GlobalErrorType, AdapterOptions>;
98
- /**
99
- * Method of manipulating requests before sending the request.
100
- */
101
- onRequest: (callback: RequestInterceptorType) => Client<GlobalErrorType, AdapterOptions>;
102
- /**
103
- * Method for intercepting any responses.
104
- */
105
- onResponse: <ErrorType = null>(callback: ResponseInterceptorType<any, GlobalErrorType | ErrorType>) => Client<GlobalErrorType, AdapterOptions>;
106
- /**
107
- * Add persistent effects which trigger on the request lifecycle
108
- */
109
- addEffect: (effect: RequestEffectInstance | RequestEffectInstance[]) => this;
110
- /**
111
- * Remove effects from Client
112
- */
113
- removeEffect: (effect: RequestEffectInstance | string) => this;
114
- /**
115
- * Helper used by http adapter to apply the modifications on response error
116
- */
117
- __modifyAuth: (request: RequestInstance) => Promise<RequestInstance>;
118
- /**
119
- * Private helper to run async pre-request processing
120
- */
121
- __modifyRequest: (request: RequestInstance) => Promise<RequestInstance>;
122
- /**
123
- * Private helper to run async on-error response processing
124
- */
125
- __modifyErrorResponse: (response: ResponseType<any, GlobalErrorType>, request: RequestInstance) => Promise<ResponseType<any, GlobalErrorType>>;
126
- /**
127
- * Private helper to run async on-success response processing
128
- */
129
- __modifySuccessResponse: (response: ResponseType<any, GlobalErrorType>, request: RequestInstance) => Promise<ResponseType<any, GlobalErrorType>>;
130
- /**
131
- * Private helper to run async response processing
132
- */
133
- __modifyResponse: (response: ResponseType<any, GlobalErrorType>, request: RequestInstance) => Promise<ResponseType<any, GlobalErrorType>>;
134
- /**
135
- * Clears the Client instance and remove all listeners on it's dependencies
136
- */
137
- clear: () => void;
138
- /**
139
- * Create requests based on the Client setup
140
- */
141
- createRequest: <Response_1, Payload = undefined, LocalError extends ClientErrorType = undefined, QueryParams extends string | QueryParamsType = string | QueryParamsType>() => <EndpointType extends string>(params: RequestOptionsType<EndpointType, AdapterOptions>) => Request<Response_1, Payload, QueryParams, GlobalErrorType, LocalError, EndpointType, AdapterOptions, false, false, false, undefined>;
142
- }
@@ -1,41 +0,0 @@
1
- import { Cache } from "cache";
2
- import { RequestInstance } from "request";
3
- import { Dispatcher } from "dispatcher";
4
- import { ResponseType, AdapterType, QueryParamsType } from "adapter";
5
- import { Client } from "client";
6
- import { AppManager } from "managers";
7
- import { NegativeTypes } from "types";
8
- export type ClientErrorType = Record<string, any> | string;
9
- export type ClientInstance = Client<any, any>;
10
- /**
11
- * Configuration setup for the client
12
- */
13
- export type ClientOptionsType = {
14
- /**
15
- * Url to your server
16
- */
17
- url: string;
18
- /**
19
- * Custom adapter initialization prop
20
- */
21
- adapter?: AdapterType;
22
- /**
23
- * Custom cache initialization prop
24
- */
25
- cache?: <B extends ClientInstance, C extends Cache>(client: B) => C;
26
- /**
27
- * Custom app manager initialization prop
28
- */
29
- appManager?: <B extends ClientInstance, A extends AppManager>(client: B) => A;
30
- /**
31
- * Custom fetch dispatcher initialization prop
32
- */
33
- fetchDispatcher?: <B extends ClientInstance, D extends Dispatcher>(client: B) => D;
34
- /**
35
- * Custom submit dispatcher initialization prop
36
- */
37
- submitDispatcher?: <B extends ClientInstance, D extends Dispatcher>(client: B) => D;
38
- };
39
- export type RequestInterceptorType = (request: RequestInstance) => Promise<RequestInstance> | RequestInstance;
40
- export type ResponseInterceptorType<Response = any, Error = any> = (response: ResponseType<Response, Error>, request: RequestInstance) => Promise<ResponseType<any, any>> | ResponseType<any, any>;
41
- export type StringifyCallbackType = (queryParams: QueryParamsType | string | NegativeTypes) => string;
@@ -1,10 +0,0 @@
1
- import { QueryParamsType, ResponseType, QueryStringifyOptionsType } from "adapter";
2
- import { RequestInstance } from "request";
3
- import { NegativeTypes } from "types";
4
- import { RequestInterceptorType, ResponseInterceptorType } from "./client.types";
5
- export declare const stringifyValue: (response: string | unknown) => string;
6
- export declare const interceptRequest: (interceptors: RequestInterceptorType[], request: RequestInstance) => Promise<RequestInstance>;
7
- export declare const interceptResponse: <GlobalErrorType>(interceptors: ResponseInterceptorType[], response: ResponseType<any, GlobalErrorType>, request: RequestInstance) => Promise<ResponseType<any, GlobalErrorType>>;
8
- export declare const getAdapterHeaders: (request: RequestInstance) => HeadersInit;
9
- export declare const getAdapterPayload: (data: unknown) => string | FormData;
10
- export declare const stringifyQueryParams: (queryParams: QueryParamsType | string | NegativeTypes, options?: QueryStringifyOptionsType) => string;
@@ -1,4 +0,0 @@
1
- export * from "./client";
2
- export * from "./client.utils";
3
- export * from "./client.types";
4
- export * from "./client.constants";
@@ -1,7 +0,0 @@
1
- export declare enum HttpMethodsEnum {
2
- get = "GET",
3
- post = "POST",
4
- put = "PUT",
5
- patch = "PATCH",
6
- delete = "DELETE"
7
- }
@@ -1,11 +0,0 @@
1
- export declare enum DateInterval {
2
- second = 1000,
3
- minute = 60000,
4
- hour = 3600000,
5
- day = 86400000,
6
- week = 604800000,
7
- month30 = 2592000000,
8
- month31 = 2678400000,
9
- year = 31536000000,
10
- yearLeap = 31622400000
11
- }
@@ -1,6 +0,0 @@
1
- export declare enum DispatcherRequestType {
2
- oneByOne = "one-by-one",
3
- allAtOnce = "all-at-once",
4
- previousCanceled = "previous-canceled",
5
- deduplicated = "deduplicated"
6
- }