@hyper-fetch/core 3.2.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 (60) hide show
  1. package/.eslintrc.json +1 -2
  2. package/dist/index.d.ts +1273 -11
  3. package/package.json +2 -2
  4. package/tsconfig.json +1 -0
  5. package/dist/adapter/adapter.bindings.d.ts +0 -25
  6. package/dist/adapter/adapter.browser.d.ts +0 -2
  7. package/dist/adapter/adapter.constants.d.ts +0 -1
  8. package/dist/adapter/adapter.d.ts +0 -2
  9. package/dist/adapter/adapter.server.d.ts +0 -2
  10. package/dist/adapter/adapter.types.d.ts +0 -57
  11. package/dist/adapter/adapter.utils.d.ts +0 -8
  12. package/dist/adapter/index.d.ts +0 -7
  13. package/dist/cache/cache.d.ts +0 -76
  14. package/dist/cache/cache.events.d.ts +0 -28
  15. package/dist/cache/cache.types.d.ts +0 -50
  16. package/dist/cache/cache.utils.d.ts +0 -6
  17. package/dist/cache/index.d.ts +0 -4
  18. package/dist/client/client.constants.d.ts +0 -9
  19. package/dist/client/client.d.ts +0 -142
  20. package/dist/client/client.types.d.ts +0 -41
  21. package/dist/client/client.utils.d.ts +0 -10
  22. package/dist/client/index.d.ts +0 -4
  23. package/dist/constants/http.constants.d.ts +0 -7
  24. package/dist/constants/time.constants.d.ts +0 -11
  25. package/dist/dispatcher/dispatcher.constants.d.ts +0 -6
  26. package/dist/dispatcher/dispatcher.d.ts +0 -155
  27. package/dist/dispatcher/dispatcher.events.d.ts +0 -11
  28. package/dist/dispatcher/dispatcher.types.d.ts +0 -31
  29. package/dist/dispatcher/dispatcher.utils.d.ts +0 -10
  30. package/dist/dispatcher/index.d.ts +0 -5
  31. package/dist/effect/index.d.ts +0 -2
  32. package/dist/effect/request.effect.d.ts +0 -14
  33. package/dist/effect/request.effect.types.d.ts +0 -32
  34. package/dist/managers/app/app.manager.constants.d.ts +0 -9
  35. package/dist/managers/app/app.manager.d.ts +0 -34
  36. package/dist/managers/app/app.manager.events.d.ts +0 -11
  37. package/dist/managers/app/app.manager.types.d.ts +0 -6
  38. package/dist/managers/app/app.manager.utils.d.ts +0 -4
  39. package/dist/managers/app/index.d.ts +0 -5
  40. package/dist/managers/index.d.ts +0 -3
  41. package/dist/managers/logger/index.d.ts +0 -4
  42. package/dist/managers/logger/logger.manager.constants.d.ts +0 -4
  43. package/dist/managers/logger/logger.manager.d.ts +0 -19
  44. package/dist/managers/logger/logger.manager.types.d.ts +0 -30
  45. package/dist/managers/logger/logger.manager.utils.d.ts +0 -3
  46. package/dist/managers/request/index.d.ts +0 -4
  47. package/dist/managers/request/request.manager.d.ts +0 -43
  48. package/dist/managers/request/request.manager.events.d.ts +0 -36
  49. package/dist/managers/request/request.manager.types.d.ts +0 -23
  50. package/dist/managers/request/request.manager.utils.d.ts +0 -16
  51. package/dist/request/index.d.ts +0 -3
  52. package/dist/request/request.d.ts +0 -98
  53. package/dist/request/request.types.d.ts +0 -202
  54. package/dist/request/request.utils.d.ts +0 -22
  55. package/dist/types/fetch.types.d.ts +0 -16
  56. package/dist/types/helpers.types.d.ts +0 -11
  57. package/dist/types/http.types.d.ts +0 -1
  58. package/dist/types/index.d.ts +0 -3
  59. package/dist/utils/index.d.ts +0 -1
  60. package/dist/utils/uuid.utils.d.ts +0 -1
@@ -1,155 +0,0 @@
1
- /// <reference types="node" />
2
- import EventEmitter from "events";
3
- import { QueueDataType, DispatcherOptionsType, DispatcherStorageType, DispatcherStorageValueType, RunningRequestValueType } from "dispatcher";
4
- import { ClientInstance } from "client";
5
- import { RequestInstance } from "request";
6
- /**
7
- * Dispatcher class was made to store controlled request Fetches, and firing them all-at-once or one-by-one in request queue.
8
- * Generally requests should be flushed at the same time, the queue provide mechanism to fire them in the order.
9
- */
10
- export declare class Dispatcher {
11
- client: ClientInstance;
12
- options?: DispatcherOptionsType;
13
- emitter: EventEmitter;
14
- events: {
15
- setDrained: <Request_1 extends RequestInstance>(queueKey: string, values: QueueDataType<Request_1>) => void;
16
- setQueueStatus: <Request_2 extends RequestInstance>(queueKey: string, values: QueueDataType<Request_2>) => void;
17
- setQueueChanged: <Request_3 extends RequestInstance>(queueKey: string, values: QueueDataType<Request_3>) => void;
18
- onDrained: <Request_4 extends RequestInstance>(queueKey: string, callback: (values: QueueDataType<Request_4>) => void) => VoidFunction;
19
- onQueueStatus: <Request_5 extends RequestInstance>(queueKey: string, callback: (values: QueueDataType<Request_5>) => void) => VoidFunction;
20
- onQueueChange: <Request_6 extends RequestInstance>(queueKey: string, callback: (values: QueueDataType<Request_6>) => void) => VoidFunction;
21
- };
22
- storage: DispatcherStorageType;
23
- private requestCount;
24
- private runningRequests;
25
- private logger;
26
- constructor(client: ClientInstance, options?: DispatcherOptionsType);
27
- /**
28
- * Start request handling by queueKey
29
- */
30
- start: (queueKey: string) => void;
31
- /**
32
- * Pause request queue, but not cancel already started requests
33
- */
34
- pause: (queueKey: string) => void;
35
- /**
36
- * Stop request queue and cancel all started requests - those will be treated like not started
37
- */
38
- stop: (queueKey: string) => void;
39
- /**
40
- * Return all
41
- */
42
- getQueuesKeys: () => string[];
43
- /**
44
- * Return queue state object
45
- */
46
- getQueue: <Request_1 extends RequestInstance = RequestInstance>(queueKey: string) => QueueDataType<Request_1>;
47
- /**
48
- * Return request from queue state
49
- */
50
- getRequest: <Request_1 extends RequestInstance = RequestInstance>(queueKey: string, requestId: string) => DispatcherStorageValueType<Request_1>;
51
- /**
52
- * Get value of the active queue status based on the stopped status
53
- */
54
- getIsActiveQueue: (queueKey: string) => boolean;
55
- /**
56
- * Add new element to storage
57
- */
58
- addQueueElement: <Request_1 extends RequestInstance = RequestInstance>(queueKey: string, dispatcherDump: DispatcherStorageValueType<Request_1>) => void;
59
- /**
60
- * Set new queue storage value
61
- */
62
- setQueue: <Request_1 extends RequestInstance = RequestInstance>(queueKey: string, queue: QueueDataType<Request_1>) => QueueDataType<Request_1>;
63
- /**
64
- * Clear requests from queue cache
65
- */
66
- clearQueue: (queueKey: string) => {
67
- requests: any[];
68
- stopped: boolean;
69
- };
70
- /**
71
- * Method used to flush the queue requests
72
- */
73
- flushQueue: (queueKey: string) => Promise<void>;
74
- /**
75
- * Flush all available requests from all queues
76
- */
77
- flush: () => Promise<void>;
78
- /**
79
- * Clear all running requests and storage
80
- */
81
- clear: () => void;
82
- /**
83
- * Start particular request
84
- */
85
- startRequest: (queueKey: string, requestId: string) => void;
86
- /**
87
- * Stop particular request
88
- */
89
- stopRequest: (queueKey: string, requestId: string) => void;
90
- /**
91
- * Get currently running requests from all queueKeys
92
- */
93
- getAllRunningRequest: () => RunningRequestValueType[];
94
- /**
95
- * Get currently running requests
96
- */
97
- getRunningRequests: (queueKey: string) => RunningRequestValueType[];
98
- /**
99
- * Get running request by id
100
- */
101
- getRunningRequest: (queueKey: string, requestId: string) => RunningRequestValueType;
102
- /**
103
- * Add request to the running requests list
104
- */
105
- addRunningRequest: (queueKey: string, requestId: string, request: RequestInstance) => void;
106
- /**
107
- * Get the value based on the currently running requests
108
- */
109
- hasRunningRequests: (queueKey: string) => boolean;
110
- /**
111
- * Check if request is currently processing
112
- */
113
- hasRunningRequest: (queueKey: string, requestId: string) => boolean;
114
- /**
115
- * Cancel all started requests, but do NOT remove it from main storage
116
- */
117
- cancelRunningRequests: (queueKey: string) => void;
118
- /**
119
- * Cancel started request, but do NOT remove it from main storage
120
- */
121
- cancelRunningRequest: (queueKey: string, requestId: string) => void;
122
- /**
123
- * Delete all started requests, but do NOT clear it from queue and do NOT cancel them
124
- */
125
- deleteRunningRequests: (queueKey: string) => void;
126
- /**
127
- * Delete request by id, but do NOT clear it from queue and do NOT cancel them
128
- */
129
- deleteRunningRequest: (queueKey: string, requestId: string) => void;
130
- /**
131
- * Get count of requests from the same queueKey
132
- */
133
- getQueueRequestCount: (queueKey: string) => number;
134
- /**
135
- * Add request count to the queueKey
136
- */
137
- incrementQueueRequestCount: (queueKey: string) => void;
138
- /**
139
- * Create storage element from request
140
- */
141
- createStorageElement: <Request_1 extends RequestInstance>(request: Request_1) => DispatcherStorageValueType<Request_1>;
142
- /**
143
- * Add request to the dispatcher handler
144
- */
145
- add: (request: RequestInstance) => string;
146
- /**
147
- * Delete from the storage and cancel request
148
- */
149
- delete: (queueKey: string, requestId: string, abortKey: string) => QueueDataType<RequestInstance>;
150
- /**
151
- * Request can run for some time, once it's done, we have to check if it's successful or if it was aborted
152
- * It can be different once the previous call was set as cancelled and removed from queue before this request got resolved
153
- */
154
- performRequest: (storageElement: DispatcherStorageValueType) => Promise<void | QueueDataType<RequestInstance>>;
155
- }
@@ -1,11 +0,0 @@
1
- import EventEmitter from "events";
2
- import { QueueDataType } from "dispatcher";
3
- import { RequestInstance } from "request";
4
- export declare const getDispatcherEvents: (emitter: EventEmitter) => {
5
- setDrained: <Request_1 extends RequestInstance>(queueKey: string, values: QueueDataType<Request_1>) => void;
6
- setQueueStatus: <Request_2 extends RequestInstance>(queueKey: string, values: QueueDataType<Request_2>) => void;
7
- setQueueChanged: <Request_3 extends RequestInstance>(queueKey: string, values: QueueDataType<Request_3>) => void;
8
- onDrained: <Request_4 extends RequestInstance>(queueKey: string, callback: (values: QueueDataType<Request_4>) => void) => VoidFunction;
9
- onQueueStatus: <Request_5 extends RequestInstance>(queueKey: string, callback: (values: QueueDataType<Request_5>) => void) => VoidFunction;
10
- onQueueChange: <Request_6 extends RequestInstance>(queueKey: string, callback: (values: QueueDataType<Request_6>) => void) => VoidFunction;
11
- };
@@ -1,31 +0,0 @@
1
- import { Dispatcher } from "dispatcher";
2
- import { RequestDump, RequestInstance } from "request";
3
- export type DispatcherOptionsType = {
4
- storage?: DispatcherStorageType;
5
- onInitialization?: (dispatcherInstance: Dispatcher) => void;
6
- onUpdateStorage?: <Request extends RequestInstance>(queueKey: string, data: QueueDataType<Request>) => void;
7
- onDeleteFromStorage?: <Request extends RequestInstance>(queueKey: string, data: QueueDataType<Request>) => void;
8
- onClearStorage?: (dispatcherInstance: Dispatcher) => void;
9
- };
10
- export type DispatcherStorageValueType<Request extends RequestInstance = RequestInstance> = {
11
- requestId: string;
12
- requestDump: RequestDump<Request>;
13
- retries: number;
14
- timestamp: number;
15
- stopped: boolean;
16
- };
17
- export type QueueDataType<Request extends RequestInstance = RequestInstance> = {
18
- requests: DispatcherStorageValueType<Request>[];
19
- stopped: boolean;
20
- };
21
- export type DispatcherStorageType = {
22
- set: <Request extends RequestInstance = RequestInstance>(key: string, data: QueueDataType<Request>) => void;
23
- get: <Request extends RequestInstance = RequestInstance>(key: string) => QueueDataType<Request> | undefined;
24
- keys: () => string[] | IterableIterator<string>;
25
- delete: (key: string) => void;
26
- clear: () => void;
27
- };
28
- export type RunningRequestValueType = {
29
- requestId: string;
30
- request: RequestInstance;
31
- };
@@ -1,10 +0,0 @@
1
- import { RequestInstance } from "request";
2
- import { ResponseType } from "adapter";
3
- import { DispatcherRequestType, DispatcherStorageValueType } from "dispatcher";
4
- export declare const getDispatcherDrainedEventKey: (key: string) => string;
5
- export declare const getDispatcherStatusEventKey: (key: string) => string;
6
- export declare const getDispatcherChangeEventKey: (key: string) => string;
7
- export declare const getIsEqualTimestamp: (currentTimestamp: number, threshold: number, queueTimestamp?: number) => boolean;
8
- export declare const canRetryRequest: (currentRetries: number, retry: number | undefined) => boolean;
9
- export declare const getRequestType: (request: RequestInstance, latestRequest: DispatcherStorageValueType | undefined) => DispatcherRequestType;
10
- export declare const isFailedRequest: (data: ResponseType<unknown, unknown>) => boolean;
@@ -1,5 +0,0 @@
1
- export * from "./dispatcher.constants";
2
- export * from "./dispatcher.events";
3
- export * from "./dispatcher";
4
- export * from "./dispatcher.types";
5
- export * from "./dispatcher.utils";
@@ -1,2 +0,0 @@
1
- export * from "./request.effect";
2
- export * from "./request.effect.types";
@@ -1,14 +0,0 @@
1
- import { ExtractErrorType, ExtractResponseType } from "types";
2
- import { RequestEffectOptionsType } from "effect";
3
- import { RequestInstance } from "request";
4
- import { ResponseErrorType, ResponseType, ResponseSuccessType } from "adapter";
5
- export declare class RequestEffect<T extends RequestInstance> {
6
- config: RequestEffectOptionsType<T>;
7
- constructor(config: RequestEffectOptionsType<T>);
8
- getEffectKey: () => string;
9
- onTrigger: (request: T) => void;
10
- onStart: (request: T) => void;
11
- onSuccess: (response: ResponseSuccessType<ExtractResponseType<T>>, request: T) => void;
12
- onError: (response: ResponseErrorType<ExtractErrorType<T>>, request: T) => void;
13
- onFinished: (response: ResponseType<ExtractResponseType<T>, ExtractErrorType<T>>, request: T) => void;
14
- }
@@ -1,32 +0,0 @@
1
- import { RequestInstance } from "request";
2
- import { ResponseErrorType, ResponseType, ResponseSuccessType } from "adapter";
3
- import { RequestEffect } from "effect";
4
- import { ExtractErrorType, ExtractResponseType } from "types";
5
- export type RequestEffectLifecycle = "trigger" | "start" | "success" | "error" | "finished";
6
- export type RequestEffectInstance = RequestEffect<RequestInstance>;
7
- export type RequestEffectOptionsType<T extends RequestInstance> = {
8
- /**
9
- * It should match effectKey on the request for which given effect should be triggered.
10
- */
11
- effectKey: string;
12
- /**
13
- * Callback that will be executed when request gets triggered
14
- */
15
- onTrigger?: (request: RequestInstance) => void;
16
- /**
17
- * Callback that will be executed when request starts
18
- */
19
- onStart?: (request: RequestInstance) => void;
20
- /**
21
- * Callback that will be executed when response is successful
22
- */
23
- onSuccess?: (response: ResponseSuccessType<ExtractResponseType<T>>, request: RequestInstance) => void;
24
- /**
25
- * Callback that will be executed when response is failed
26
- */
27
- onError?: (response: ResponseErrorType<ExtractErrorType<T>>, request: RequestInstance) => void;
28
- /**
29
- * Callback that will be executed when response is finished
30
- */
31
- onFinished?: (response: ResponseType<ExtractResponseType<T>, ExtractErrorType<T>>, request: RequestInstance) => void;
32
- };
@@ -1,9 +0,0 @@
1
- import { RequiredKeys } from "types";
2
- import { AppManagerOptionsType } from "managers";
3
- export declare enum AppEvents {
4
- focus = "focus",
5
- blur = "blur",
6
- online = "online",
7
- offline = "offline"
8
- }
9
- export declare const appManagerInitialOptions: RequiredKeys<AppManagerOptionsType>;
@@ -1,34 +0,0 @@
1
- /// <reference types="node" />
2
- import EventEmitter from "events";
3
- import { AppManagerOptionsType } from "managers";
4
- /**
5
- * App manager handles main application states - focus and online. Those two values can answer questions:
6
- * - Is the tab or current view instance focused and visible for user?
7
- * - Is our application online or offline?
8
- * With the app manager it is not a problem to get the valid answer for this question.
9
- *
10
- * @caution
11
- * Make sure to apply valid focus/online handlers for different environments like for example for native mobile applications.
12
- */
13
- export declare class AppManager {
14
- options?: AppManagerOptionsType;
15
- emitter: EventEmitter;
16
- events: {
17
- emitFocus: () => void;
18
- emitBlur: () => void;
19
- emitOnline: () => void;
20
- emitOffline: () => void;
21
- onFocus: (callback: () => void) => VoidFunction;
22
- onBlur: (callback: () => void) => VoidFunction;
23
- onOnline: (callback: () => void) => VoidFunction;
24
- onOffline: (callback: () => void) => VoidFunction;
25
- };
26
- isBrowser: boolean;
27
- isOnline: boolean;
28
- isFocused: boolean;
29
- constructor(options?: AppManagerOptionsType);
30
- private setInitialFocus;
31
- private setInitialOnline;
32
- setFocused: (isFocused: boolean) => void;
33
- setOnline: (isOnline: boolean) => void;
34
- }
@@ -1,11 +0,0 @@
1
- import EventEmitter from "events";
2
- export declare const getAppManagerEvents: (emitter: EventEmitter) => {
3
- emitFocus: () => void;
4
- emitBlur: () => void;
5
- emitOnline: () => void;
6
- emitOffline: () => void;
7
- onFocus: (callback: () => void) => VoidFunction;
8
- onBlur: (callback: () => void) => VoidFunction;
9
- onOnline: (callback: () => void) => VoidFunction;
10
- onOffline: (callback: () => void) => VoidFunction;
11
- };
@@ -1,6 +0,0 @@
1
- export type AppManagerOptionsType = {
2
- initiallyFocused?: boolean | (() => boolean | Promise<boolean>);
3
- initiallyOnline?: boolean | (() => boolean | Promise<boolean>);
4
- focusEvent?: (setFocused: (isFocused: boolean) => void) => void;
5
- onlineEvent?: (setOnline: (isOnline: boolean) => void) => void;
6
- };
@@ -1,4 +0,0 @@
1
- export declare const hasWindow: () => boolean;
2
- export declare const hasDocument: () => boolean;
3
- export declare const onWindowEvent: <K extends keyof WindowEventMap>(key: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined) => void;
4
- export declare const onDocumentEvent: <K extends keyof DocumentEventMap>(key: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined) => void;
@@ -1,5 +0,0 @@
1
- export * from "./app.manager";
2
- export * from "./app.manager.types";
3
- export * from "./app.manager.utils";
4
- export * from "./app.manager.events";
5
- export * from "./app.manager.constants";
@@ -1,3 +0,0 @@
1
- export * from "./app";
2
- export * from "./request";
3
- export * from "./logger";
@@ -1,4 +0,0 @@
1
- export * from "./logger.manager";
2
- export * from "./logger.manager.utils";
3
- export * from "./logger.manager.types";
4
- export * from "./logger.manager.constants";
@@ -1,4 +0,0 @@
1
- import { LoggerLevelType } from "./logger.manager.types";
2
- export declare const loggerStyles: Record<LoggerLevelType, string>;
3
- export declare const loggerIconLevels: Record<LoggerLevelType, string>;
4
- export declare const severity: Record<LoggerLevelType, number>;
@@ -1,19 +0,0 @@
1
- /// <reference types="node" />
2
- import EventEmitter from "events";
3
- import { ClientInstance } from "client";
4
- import { LoggerType, SeverityType, LoggerOptionsType, LoggerFunctionType } from "managers";
5
- /**
6
- * This class is used across the Hyper Fetch library to provide unified logging system with necessary setup per each client.
7
- * We can set up the logging level based on available values. This manager enable to initialize the logging instance per individual module
8
- * like Client, Request etc. Which can give you better feedback on the logging itself.
9
- */
10
- export declare class LoggerManager {
11
- private client;
12
- private options?;
13
- logger: LoggerFunctionType;
14
- severity: SeverityType;
15
- emitter: EventEmitter;
16
- constructor(client: Pick<ClientInstance, "debug">, options?: LoggerOptionsType);
17
- setSeverity: (severity: SeverityType) => void;
18
- init: (module: string) => LoggerType;
19
- }
@@ -1,30 +0,0 @@
1
- import { ResponseType } from "adapter";
2
- import { RequestInstance } from "request";
3
- import { ResponseDetailsType } from "managers/request";
4
- export type SeverityType = 0 | 1 | 2 | 3;
5
- export type LoggerType = Record<LoggerLevelType, (message: LoggerMessageType, ...additionalData: LoggerMessageType[]) => void>;
6
- export type LoggerFunctionType = (log: LogType) => void;
7
- export type LoggerOptionsType = {
8
- logger?: LoggerFunctionType;
9
- severity?: SeverityType;
10
- };
11
- export type LogType = {
12
- module: string;
13
- level: LoggerLevelType;
14
- message: LoggerMessageType;
15
- additionalData?: LoggerMessageType[];
16
- enabled: boolean;
17
- severity: SeverityType;
18
- };
19
- export type LoggerLevelType = "error" | "warning" | "info" | "debug";
20
- export type LoggerMessageType = string | Record<string, unknown> | Array<unknown>;
21
- export type LoggerRequestEventData = {
22
- requestId: string;
23
- request: RequestInstance;
24
- };
25
- export type LoggerResponseEventData = {
26
- requestId: string;
27
- request: RequestInstance;
28
- response: ResponseType<unknown, unknown>;
29
- details: ResponseDetailsType;
30
- };
@@ -1,3 +0,0 @@
1
- import { LoggerFunctionType } from "managers";
2
- export declare const getTime: () => string;
3
- export declare const logger: LoggerFunctionType;
@@ -1,4 +0,0 @@
1
- export * from "./request.manager";
2
- export * from "./request.manager.utils";
3
- export * from "./request.manager.events";
4
- export * from "./request.manager.types";
@@ -1,43 +0,0 @@
1
- /// <reference types="node" />
2
- import EventEmitter from "events";
3
- /**
4
- * **Request Manager** is used to emit `request lifecycle events` like - request start, request end, upload and download progress.
5
- * It is also the place of `request aborting` system, here we store all the keys and controllers that are isolated for each client instance.
6
- */
7
- export declare class RequestManager {
8
- emitter: EventEmitter;
9
- events: {
10
- emitLoading: (queueKey: string, requestId: string, values: import("managers").RequestLoadingEventType) => void;
11
- emitRequestStart: (queueKey: string, requestId: string, details: import("managers").RequestEventType<import("../..").RequestInstance>) => void;
12
- emitResponseStart: (queueKey: string, requestId: string, details: import("managers").RequestEventType<import("../..").RequestInstance>) => void;
13
- emitUploadProgress: (queueKey: string, requestId: string, values: import("../..").ProgressType, details: import("managers").RequestEventType<import("../..").RequestInstance>) => void;
14
- emitDownloadProgress: (queueKey: string, requestId: string, values: import("../..").ProgressType, details: import("managers").RequestEventType<import("../..").RequestInstance>) => void;
15
- emitResponse: (cacheKey: string, requestId: string, response: import("../..").ResponseType<unknown, unknown>, details: import("managers").ResponseDetailsType) => void;
16
- emitAbort: (abortKey: string, requestId: string, request: import("../..").RequestInstance) => void;
17
- emitRemove: <T extends import("../..").RequestInstance>(queueKey: string, requestId: string, details: import("managers").RequestEventType<T>) => void;
18
- onLoading: (queueKey: string, callback: (values: import("managers").RequestLoadingEventType) => void) => VoidFunction;
19
- onLoadingById: (requestId: string, callback: (values: import("managers").RequestLoadingEventType) => void) => VoidFunction;
20
- onRequestStart: <T_1 extends import("../..").RequestInstance>(queueKey: string, callback: (details: import("managers").RequestEventType<T_1>) => void) => VoidFunction;
21
- onRequestStartById: <T_2 extends import("../..").RequestInstance>(requestId: string, callback: (details: import("managers").RequestEventType<T_2>) => void) => VoidFunction;
22
- onResponseStart: <T_3 extends import("../..").RequestInstance>(queueKey: string, callback: (details: import("managers").RequestEventType<T_3>) => void) => VoidFunction;
23
- onResponseStartById: <T_4 extends import("../..").RequestInstance>(requestId: string, callback: (details: import("managers").RequestEventType<T_4>) => void) => VoidFunction;
24
- onUploadProgress: <T_5 extends import("../..").RequestInstance = import("../..").RequestInstance>(queueKey: string, callback: (values: import("../..").ProgressType, details: import("managers").RequestEventType<T_5>) => void) => VoidFunction;
25
- onUploadProgressById: <T_6 extends import("../..").RequestInstance = import("../..").RequestInstance>(requestId: string, callback: (values: import("../..").ProgressType, details: import("managers").RequestEventType<T_6>) => void) => VoidFunction;
26
- onDownloadProgress: <T_7 extends import("../..").RequestInstance = import("../..").RequestInstance>(queueKey: string, callback: (values: import("../..").ProgressType, details: import("managers").RequestEventType<T_7>) => void) => VoidFunction;
27
- onDownloadProgressById: <T_8 extends import("../..").RequestInstance = import("../..").RequestInstance>(requestId: string, callback: (values: import("../..").ProgressType, details: import("managers").RequestEventType<T_8>) => void) => VoidFunction;
28
- onResponse: <Response_1, ErrorType>(cacheKey: string, callback: (response: import("../..").ResponseType<Response_1, ErrorType>, details: import("managers").ResponseDetailsType) => void) => VoidFunction;
29
- onResponseById: <Response_2, ErrorType_1>(requestId: string, callback: (response: import("../..").ResponseType<Response_2, ErrorType_1>, details: import("managers").ResponseDetailsType) => void) => VoidFunction;
30
- onAbort: (abortKey: string, callback: (request: import("../..").RequestInstance) => void) => VoidFunction;
31
- onAbortById: (requestId: string, callback: (request: import("../..").RequestInstance) => void) => VoidFunction;
32
- onRemove: <T_9 extends import("../..").RequestInstance = import("../..").RequestInstance>(queueKey: string, callback: (details: import("managers").RequestEventType<T_9>) => void) => VoidFunction;
33
- onRemoveById: <T_10 extends import("../..").RequestInstance = import("../..").RequestInstance>(requestId: string, callback: (details: import("managers").RequestEventType<T_10>) => void) => VoidFunction;
34
- };
35
- abortControllers: Map<string, Map<string, AbortController>>;
36
- addAbortController: (abortKey: string, requestId: string) => void;
37
- getAbortController: (abortKey: string, requestId: string) => AbortController;
38
- removeAbortController: (abortKey: string, requestId: string) => void;
39
- useAbortController: (abortKey: string, requestId: string) => void;
40
- abortByKey: (abortKey: string) => void;
41
- abortByRequestId: (abortKey: string, requestId: string) => void;
42
- abortAll: () => void;
43
- }
@@ -1,36 +0,0 @@
1
- import EventEmitter from "events";
2
- import { RequestEventType, ResponseDetailsType, RequestLoadingEventType } from "managers";
3
- import { ProgressType, ResponseType } from "adapter";
4
- import { RequestInstance } from "request";
5
- export declare const getRequestManagerEvents: (emitter: EventEmitter) => {
6
- /**
7
- * Emiter
8
- */
9
- emitLoading: (queueKey: string, requestId: string, values: RequestLoadingEventType) => void;
10
- emitRequestStart: (queueKey: string, requestId: string, details: RequestEventType<RequestInstance>) => void;
11
- emitResponseStart: (queueKey: string, requestId: string, details: RequestEventType<RequestInstance>) => void;
12
- emitUploadProgress: (queueKey: string, requestId: string, values: ProgressType, details: RequestEventType<RequestInstance>) => void;
13
- emitDownloadProgress: (queueKey: string, requestId: string, values: ProgressType, details: RequestEventType<RequestInstance>) => void;
14
- emitResponse: (cacheKey: string, requestId: string, response: ResponseType<unknown, unknown>, details: ResponseDetailsType) => void;
15
- emitAbort: (abortKey: string, requestId: string, request: RequestInstance) => void;
16
- emitRemove: <T extends RequestInstance>(queueKey: string, requestId: string, details: RequestEventType<T>) => void;
17
- /**
18
- * Listeners
19
- */
20
- onLoading: (queueKey: string, callback: (values: RequestLoadingEventType) => void) => VoidFunction;
21
- onLoadingById: (requestId: string, callback: (values: RequestLoadingEventType) => void) => VoidFunction;
22
- onRequestStart: <T_1 extends RequestInstance>(queueKey: string, callback: (details: RequestEventType<T_1>) => void) => VoidFunction;
23
- onRequestStartById: <T_2 extends RequestInstance>(requestId: string, callback: (details: RequestEventType<T_2>) => void) => VoidFunction;
24
- onResponseStart: <T_3 extends RequestInstance>(queueKey: string, callback: (details: RequestEventType<T_3>) => void) => VoidFunction;
25
- onResponseStartById: <T_4 extends RequestInstance>(requestId: string, callback: (details: RequestEventType<T_4>) => void) => VoidFunction;
26
- onUploadProgress: <T_5 extends RequestInstance = RequestInstance>(queueKey: string, callback: (values: ProgressType, details: RequestEventType<T_5>) => void) => VoidFunction;
27
- onUploadProgressById: <T_6 extends RequestInstance = RequestInstance>(requestId: string, callback: (values: ProgressType, details: RequestEventType<T_6>) => void) => VoidFunction;
28
- onDownloadProgress: <T_7 extends RequestInstance = RequestInstance>(queueKey: string, callback: (values: ProgressType, details: RequestEventType<T_7>) => void) => VoidFunction;
29
- onDownloadProgressById: <T_8 extends RequestInstance = RequestInstance>(requestId: string, callback: (values: ProgressType, details: RequestEventType<T_8>) => void) => VoidFunction;
30
- onResponse: <Response_1, ErrorType>(cacheKey: string, callback: (response: ResponseType<Response_1, ErrorType>, details: ResponseDetailsType) => void) => VoidFunction;
31
- onResponseById: <Response_2, ErrorType_1>(requestId: string, callback: (response: ResponseType<Response_2, ErrorType_1>, details: ResponseDetailsType) => void) => VoidFunction;
32
- onAbort: (abortKey: string, callback: (request: RequestInstance) => void) => VoidFunction;
33
- onAbortById: (requestId: string, callback: (request: RequestInstance) => void) => VoidFunction;
34
- onRemove: <T_9 extends RequestInstance = RequestInstance>(queueKey: string, callback: (details: RequestEventType<T_9>) => void) => VoidFunction;
35
- onRemoveById: <T_10 extends RequestInstance = RequestInstance>(requestId: string, callback: (details: RequestEventType<T_10>) => void) => VoidFunction;
36
- };
@@ -1,23 +0,0 @@
1
- import { RequestInstance } from "request";
2
- export type RequestLoadingEventType = {
3
- queueKey: string;
4
- requestId: string;
5
- loading: boolean;
6
- isRetry: boolean;
7
- isOffline: boolean;
8
- };
9
- export type RequestEventType<T extends RequestInstance> = {
10
- requestId: string;
11
- request: T;
12
- };
13
- export type ResponseDetailsType = {
14
- retries: number;
15
- timestamp: number;
16
- isFailed: boolean;
17
- isCanceled: boolean;
18
- isOffline: boolean;
19
- };
20
- export type RequestRemoveDataType = {
21
- queueKey: string;
22
- requestId: string;
23
- };
@@ -1,16 +0,0 @@
1
- export declare const getLoadingEventKey: (key: string) => string;
2
- export declare const getLoadingIdEventKey: (key: string) => string;
3
- export declare const getRemoveEventKey: (key: string) => string;
4
- export declare const getRemoveIdEventKey: (key: string) => string;
5
- export declare const getAbortEventKey: (key: string) => string;
6
- export declare const getAbortByIdEventKey: (key: string) => string;
7
- export declare const getResponseEventKey: (key: string) => string;
8
- export declare const getResponseIdEventKey: (key: string) => string;
9
- export declare const getRequestStartEventKey: (key: string) => string;
10
- export declare const getRequestStartIdEventKey: (key: string) => string;
11
- export declare const getResponseStartEventKey: (key: string) => string;
12
- export declare const getResponseStartIdEventKey: (key: string) => string;
13
- export declare const getUploadProgressEventKey: (key: string) => string;
14
- export declare const getUploadProgressIdEventKey: (key: string) => string;
15
- export declare const getDownloadProgressEventKey: (key: string) => string;
16
- export declare const getDownloadProgressIdEventKey: (key: string) => string;
@@ -1,3 +0,0 @@
1
- export * from "./request";
2
- export * from "./request.types";
3
- export * from "./request.utils";