@stackone/transport 1.17.1 → 2.1.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.
- package/dist/index.d.mts +111 -79
- package/dist/index.d.ts +111 -79
- package/dist/index.js +51 -76
- package/dist/index.mjs +49 -74
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -91,6 +91,26 @@ type LogError = Error & {
|
|
|
91
91
|
url?: string;
|
|
92
92
|
};
|
|
93
93
|
//#endregion
|
|
94
|
+
//#region src/asyncSingleton/index.d.ts
|
|
95
|
+
declare abstract class AsyncSingleton<T, O> {
|
|
96
|
+
private instance;
|
|
97
|
+
private initPromise;
|
|
98
|
+
private retryTimeout;
|
|
99
|
+
private status;
|
|
100
|
+
private initOptions;
|
|
101
|
+
private initArgs;
|
|
102
|
+
protected abstract initInstance(options: O | null, ...args: unknown[]): Promise<T>;
|
|
103
|
+
protected abstract name: string;
|
|
104
|
+
protected getRetryDelay(): number;
|
|
105
|
+
protected getSingleton<U>(ctor: new (...args: unknown[]) => AsyncSingleton<U, unknown>): U;
|
|
106
|
+
getInstance(options?: O | null, ...args: unknown[]): Promise<T>;
|
|
107
|
+
getInstanceIfReady(): T | null;
|
|
108
|
+
isReady(): boolean;
|
|
109
|
+
hasInitFailed(): boolean;
|
|
110
|
+
private init;
|
|
111
|
+
reset(): void;
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
94
114
|
//#region src/cacheClient/types.d.ts
|
|
95
115
|
interface ICacheClient<ClientType = unknown> {
|
|
96
116
|
getData<T>(key: string): Promise<T | null>;
|
|
@@ -208,27 +228,33 @@ declare class RedisClient implements ICacheClient<RedisClientType> {
|
|
|
208
228
|
type Scripts<T extends string> = Record<T, string>;
|
|
209
229
|
type ScriptManagerOptions<T extends string> = {
|
|
210
230
|
redisClientConfig: RedisClientConfig;
|
|
211
|
-
|
|
231
|
+
cacheClient?: ICacheClient<RedisClientType>;
|
|
232
|
+
scripts: Scripts<T>;
|
|
212
233
|
scriptMap?: Map<T, string>;
|
|
234
|
+
logger?: ILogger;
|
|
235
|
+
additionalArgs?: unknown[];
|
|
213
236
|
};
|
|
214
237
|
//#endregion
|
|
215
238
|
//#region src/scriptManager/index.d.ts
|
|
216
|
-
declare class ScriptManager<T extends string
|
|
217
|
-
protected cacheClient: ICacheClient<RedisClientType> | null;
|
|
218
|
-
protected scriptMap: Map<string, string>;
|
|
219
|
-
protected logger?: ILogger;
|
|
220
|
-
protected scripts: Scripts<T>;
|
|
239
|
+
declare abstract class ScriptManager<T extends string, S extends ScriptManager<T, S>> extends AsyncSingleton<S, ScriptManagerOptions<T>> {
|
|
221
240
|
protected redisClientConfig: RedisClientConfig;
|
|
222
|
-
|
|
223
|
-
protected
|
|
241
|
+
protected scripts: Scripts<T>;
|
|
242
|
+
protected scriptMap: Map<T, string>;
|
|
243
|
+
protected cacheClient: ICacheClient<RedisClientType>;
|
|
244
|
+
protected logger: ILogger;
|
|
245
|
+
protected additionalArgs: unknown[];
|
|
246
|
+
protected initInstance({
|
|
224
247
|
redisClientConfig,
|
|
248
|
+
cacheClient,
|
|
249
|
+
scripts,
|
|
250
|
+
scriptMap,
|
|
225
251
|
logger,
|
|
226
|
-
|
|
227
|
-
}: ScriptManagerOptions<T
|
|
228
|
-
protected additionalInitialization(...
|
|
229
|
-
protected loadScripts
|
|
230
|
-
protected executeScript<
|
|
231
|
-
protected
|
|
252
|
+
additionalArgs
|
|
253
|
+
}: ScriptManagerOptions<T>): Promise<S>;
|
|
254
|
+
protected abstract additionalInitialization(...args: unknown[]): Promise<void>;
|
|
255
|
+
protected loadScripts(scripts: Scripts<T>, scriptMap?: Map<T, string>): Promise<void>;
|
|
256
|
+
protected executeScript<U>(method: T, keys: string[], args: string[]): Promise<U | null>;
|
|
257
|
+
protected isRedisReady(): boolean;
|
|
232
258
|
}
|
|
233
259
|
//#endregion
|
|
234
260
|
//#region src/concurrencyManager/types.d.ts
|
|
@@ -259,29 +285,22 @@ declare enum ConcurrencyMethods {
|
|
|
259
285
|
}
|
|
260
286
|
//#endregion
|
|
261
287
|
//#region src/concurrencyManager/index.d.ts
|
|
262
|
-
declare class ConcurrencyManager extends ScriptManager<ConcurrencyMethods> {
|
|
263
|
-
private
|
|
264
|
-
private static asyncInstanceInit;
|
|
265
|
-
private static hasValidRedisConfig;
|
|
266
|
-
private static lastInitFailure;
|
|
267
|
-
private static RETRY_WINDOW_MS;
|
|
268
|
-
private static logger?;
|
|
269
|
-
private static initConfig;
|
|
288
|
+
declare class ConcurrencyManager extends ScriptManager<ConcurrencyMethods, ConcurrencyManager> {
|
|
289
|
+
private hasValidRedisConfig;
|
|
270
290
|
private subscriptionManager;
|
|
271
291
|
private queueManager;
|
|
272
292
|
private generateUUID;
|
|
273
|
-
|
|
293
|
+
name: string;
|
|
274
294
|
protected additionalInitialization(generateUUID?: () => string): Promise<void>;
|
|
275
295
|
private addTestSubscription;
|
|
276
296
|
private checkRedisEventsEmit;
|
|
277
|
-
isRedisConfigured():
|
|
297
|
+
isRedisConfigured(): boolean;
|
|
278
298
|
private subscribeToLeaseExpiry;
|
|
279
299
|
private subscribeToSetRemoval;
|
|
280
300
|
registerRequest(requestKey: string, config: ConcurrencyConfig, requestId: string, requestUrl: string | undefined): Promise<RequestMetadata>;
|
|
281
301
|
releaseRequest(requestId: string, targetConcurrencyKey: string): Promise<boolean>;
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
static close(): void;
|
|
302
|
+
isReady(): boolean;
|
|
303
|
+
close(): void;
|
|
285
304
|
}
|
|
286
305
|
//#endregion
|
|
287
306
|
//#region src/customErrors/schemas.d.ts
|
|
@@ -290,7 +309,7 @@ declare const CUSTOM_ERROR_CONFIG_SCHEMA: z.ZodObject<{
|
|
|
290
309
|
targetStatus: z.ZodNumber;
|
|
291
310
|
message: z.ZodOptional<z.ZodString>;
|
|
292
311
|
condition: z.ZodOptional<z.ZodString>;
|
|
293
|
-
}, z.core.$
|
|
312
|
+
}, z.core.$strict>;
|
|
294
313
|
//#endregion
|
|
295
314
|
//#region src/customErrors/types.d.ts
|
|
296
315
|
type CustomErrorConfig = z.infer<typeof CUSTOM_ERROR_CONFIG_SCHEMA>;
|
|
@@ -317,6 +336,22 @@ type RateLimitConfig = {
|
|
|
317
336
|
mappedRateLimitErrors?: MappedRateLimitErrorConfig[];
|
|
318
337
|
};
|
|
319
338
|
//#endregion
|
|
339
|
+
//#region src/rateLimitManager/constants.d.ts
|
|
340
|
+
declare enum RateLimitMethods {
|
|
341
|
+
incr = "incr",
|
|
342
|
+
}
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/rateLimitManager/index.d.ts
|
|
345
|
+
declare class RateLimitManager extends ScriptManager<RateLimitMethods, RateLimitManager> {
|
|
346
|
+
name: string;
|
|
347
|
+
protected additionalInitialization(): Promise<void>;
|
|
348
|
+
getDynamicMaxWaitTime(ratelimitConfig: RateLimitConfig, concurrencyConfig: ConcurrencyConfig, requestUrl?: string, cutoffTime?: number, fudgeFactor?: number, ballparkResponseTime?: number): number;
|
|
349
|
+
getWaitTime(requestKey: string, config: RateLimitConfig, requestUrl?: string): Promise<number | null>;
|
|
350
|
+
private readyCheck;
|
|
351
|
+
isReady(): boolean;
|
|
352
|
+
close(): void;
|
|
353
|
+
}
|
|
354
|
+
//#endregion
|
|
320
355
|
//#region src/interceptors/types.d.ts
|
|
321
356
|
type RequestInterceptor = (value: InternalAxiosRequestConfig<unknown>) => InternalAxiosRequestConfig<unknown> | Promise<InternalAxiosRequestConfig<unknown>>;
|
|
322
357
|
type ResponseInterceptor = (value: AxiosResponse<unknown, unknown>) => AxiosResponse<unknown, unknown> | Promise<AxiosResponse<unknown, unknown>>;
|
|
@@ -327,6 +362,8 @@ interface InterceptorDependencies {
|
|
|
327
362
|
logger?: ILogger;
|
|
328
363
|
context?: RequestContext;
|
|
329
364
|
requestConfig?: RequestConfig;
|
|
365
|
+
concurrencyManager?: ConcurrencyManager;
|
|
366
|
+
rateLimitManager?: RateLimitManager;
|
|
330
367
|
[key: string]: unknown;
|
|
331
368
|
}
|
|
332
369
|
type RequestConfig = {
|
|
@@ -682,6 +719,8 @@ type HttpTransportInstanceConfig = {
|
|
|
682
719
|
logger?: ILogger;
|
|
683
720
|
context?: RequestContext;
|
|
684
721
|
requestConfig?: RequestConfig;
|
|
722
|
+
concurrencyManager?: ConcurrencyManager;
|
|
723
|
+
rateLimitManager?: RateLimitManager;
|
|
685
724
|
};
|
|
686
725
|
//#endregion
|
|
687
726
|
//#region src/httpTransportFactory/index.d.ts
|
|
@@ -692,12 +731,54 @@ declare class HttpTransportFactory {
|
|
|
692
731
|
httpsAgentConfig,
|
|
693
732
|
logger,
|
|
694
733
|
context,
|
|
695
|
-
requestConfig
|
|
734
|
+
requestConfig,
|
|
735
|
+
concurrencyManager,
|
|
736
|
+
rateLimitManager
|
|
696
737
|
}: HttpTransportInstanceConfig): AxiosInstance;
|
|
697
738
|
private static applyInterceptors;
|
|
698
739
|
private static resolveInterceptorInstance;
|
|
699
740
|
}
|
|
700
741
|
//#endregion
|
|
742
|
+
//#region src/queueManager/utils/enums.d.ts
|
|
743
|
+
declare enum QueueMethods {
|
|
744
|
+
rPush = "rPush",
|
|
745
|
+
lPush = "lPush",
|
|
746
|
+
lPop = "lPop",
|
|
747
|
+
llen = "llen",
|
|
748
|
+
}
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region src/queueManager/types.d.ts
|
|
751
|
+
type OnTurnFunction<T> = (queueName: string, value: string) => T | Promise<T>;
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region src/queueManager/index.d.ts
|
|
754
|
+
declare class QueueManager extends ScriptManager<QueueMethods, QueueManager> {
|
|
755
|
+
private subscriptionManager;
|
|
756
|
+
private eventClient;
|
|
757
|
+
name: string;
|
|
758
|
+
protected additionalInitialization(): Promise<void>;
|
|
759
|
+
joinAndWaitTurn<T>(queueName: string, value: string, hasPriority: boolean, onTurn: OnTurnFunction<T>, coldStartEnabled?: boolean): Promise<T | null>;
|
|
760
|
+
pop<T>(queueName: string): Promise<T | null>;
|
|
761
|
+
length(queueName: string): Promise<number | null>;
|
|
762
|
+
isReady(): boolean;
|
|
763
|
+
close(): void;
|
|
764
|
+
}
|
|
765
|
+
//#endregion
|
|
766
|
+
//#region src/initialization/index.d.ts
|
|
767
|
+
interface TransportInitializationOptions {
|
|
768
|
+
redisClientConfig: RedisClientConfig;
|
|
769
|
+
logger?: ILogger;
|
|
770
|
+
generateUUID?: () => string;
|
|
771
|
+
}
|
|
772
|
+
interface InitializedTransportManagers {
|
|
773
|
+
concurrencyManager: ConcurrencyManager;
|
|
774
|
+
queueManager: QueueManager;
|
|
775
|
+
rateLimitManager: RateLimitManager;
|
|
776
|
+
}
|
|
777
|
+
declare const initializeTransportSystem: (options: TransportInitializationOptions) => Promise<InitializedTransportManagers>;
|
|
778
|
+
declare const shutdownTransportSystem: (logger?: ILogger) => void;
|
|
779
|
+
declare const isTransportSystemReady: () => boolean;
|
|
780
|
+
declare const getTransportManagers: () => InitializedTransportManagers | null;
|
|
781
|
+
//#endregion
|
|
701
782
|
//#region src/instanceManager/index.d.ts
|
|
702
783
|
declare class InstanceManager {
|
|
703
784
|
private static instance;
|
|
@@ -775,55 +856,6 @@ type RequestParameter = {
|
|
|
775
856
|
//#region src/parsers/requestParameters.d.ts
|
|
776
857
|
declare const parseRequestParameters: (parameters: RequestParameter[]) => HttpParameters;
|
|
777
858
|
//#endregion
|
|
778
|
-
//#region src/queueManager/utils/enums.d.ts
|
|
779
|
-
declare enum QueueMethods {
|
|
780
|
-
rPush = "rPush",
|
|
781
|
-
lPush = "lPush",
|
|
782
|
-
lPop = "lPop",
|
|
783
|
-
llen = "llen",
|
|
784
|
-
}
|
|
785
|
-
//#endregion
|
|
786
|
-
//#region src/queueManager/types.d.ts
|
|
787
|
-
type OnTurnFunction<T> = (queueName: string, value: string) => T | Promise<T>;
|
|
788
|
-
//#endregion
|
|
789
|
-
//#region src/queueManager/index.d.ts
|
|
790
|
-
declare class QueueManager extends ScriptManager<QueueMethods> {
|
|
791
|
-
private static instance;
|
|
792
|
-
private static asyncInstanceInit;
|
|
793
|
-
private static logger?;
|
|
794
|
-
private static config?;
|
|
795
|
-
protected logger?: ILogger;
|
|
796
|
-
private subscriptionManager;
|
|
797
|
-
private eventClient;
|
|
798
|
-
static getInstance(config?: RedisClientConfig, logger?: ILogger, scriptMap?: Map<QueueMethods, string>): Promise<QueueManager>;
|
|
799
|
-
protected additionalInitialization(): Promise<void>;
|
|
800
|
-
joinAndWaitTurn<T>(queueName: string, value: string, hasPriority: boolean, onTurn: OnTurnFunction<T>, coldStartEnabled?: boolean): Promise<T | null>;
|
|
801
|
-
pop<T>(queueName: string): Promise<T | null>;
|
|
802
|
-
length(queueName: string): Promise<number | null>;
|
|
803
|
-
private readyCheck;
|
|
804
|
-
isReady(): Promise<boolean>;
|
|
805
|
-
close(): void;
|
|
806
|
-
}
|
|
807
|
-
//#endregion
|
|
808
|
-
//#region src/rateLimitManager/constants.d.ts
|
|
809
|
-
declare enum RateLimitMethods {
|
|
810
|
-
incr = "incr",
|
|
811
|
-
}
|
|
812
|
-
//#endregion
|
|
813
|
-
//#region src/rateLimitManager/index.d.ts
|
|
814
|
-
declare class RateLimitManager extends ScriptManager<RateLimitMethods> {
|
|
815
|
-
private static instance;
|
|
816
|
-
private static asyncInstanceInit;
|
|
817
|
-
private static logger?;
|
|
818
|
-
private static initConfig;
|
|
819
|
-
static getInstance(config?: RedisClientConfig, logger?: ILogger, scriptMap?: Map<RateLimitMethods, string>): Promise<RateLimitManager>;
|
|
820
|
-
getDynamicMaxWaitTime(ratelimitConfig: RateLimitConfig, concurrencyConfig: ConcurrencyConfig, requestUrl?: string, cutoffTime?: number, fudgeFactor?: number, ballparkResponseTime?: number): Promise<number>;
|
|
821
|
-
getWaitTime(requestKey: any, config: RateLimitConfig, requestUrl?: string): Promise<number | null>;
|
|
822
|
-
private readyCheck;
|
|
823
|
-
static isReady(): Promise<boolean>;
|
|
824
|
-
static close(): void;
|
|
825
|
-
}
|
|
826
|
-
//#endregion
|
|
827
859
|
//#region src/requestClient/types.d.ts
|
|
828
860
|
interface IRequestClient {
|
|
829
861
|
performRequest: ({
|
|
@@ -892,4 +924,4 @@ type LockEntry = {
|
|
|
892
924
|
unlock: Unlock;
|
|
893
925
|
};
|
|
894
926
|
//#endregion
|
|
895
|
-
export { CUSTOM_ERROR_CONFIG_SCHEMA, type ConcurrencyConfig, ConcurrencyManager, type CustomErrorConfig, type ErrorMappingFn, EventClient, HttpClient, HttpClientManager, HttpErrorMessages, type HttpHeaders, type HttpMethod, HttpMethods, type HttpParameters, type HttpQueryParams, type HttpResponse, HttpResponseError, HttpTransportFactory, type ICacheClient, type IHttpClient, InstanceManager, type Lock, type LockEntry, LockManager, MemoryStore, type MemoryStoreConfig, type PruneCount, type PubSubListener, QueueManager, type RateLimitConfig, RateLimitManager, RedisClient, type RedisClientConfig, type RedisClientType, RequestClientFactory, type RequestConfig, type RequestContext, type RequestParameter, RequestParameterLocations, ScriptManager, SubscriptionManager, type Unlock, buildHttpClientInstance, createAuthorizationHeaders, getTransportInstance, isFailedStatusCode, isInfoStatusCode, isSuccessStatusCode, parseRequestParameters, serializeHttpResponseError };
|
|
927
|
+
export { CUSTOM_ERROR_CONFIG_SCHEMA, type ConcurrencyConfig, ConcurrencyManager, type CustomErrorConfig, type ErrorMappingFn, EventClient, HttpClient, HttpClientManager, HttpErrorMessages, type HttpHeaders, type HttpMethod, HttpMethods, type HttpParameters, type HttpQueryParams, type HttpResponse, HttpResponseError, HttpTransportFactory, type ICacheClient, type IHttpClient, type InitializedTransportManagers, InstanceManager, type Lock, type LockEntry, LockManager, MemoryStore, type MemoryStoreConfig, type PruneCount, type PubSubListener, QueueManager, type RateLimitConfig, RateLimitManager, RedisClient, type RedisClientConfig, type RedisClientType, RequestClientFactory, type RequestConfig, type RequestContext, type RequestParameter, RequestParameterLocations, ScriptManager, SubscriptionManager, type TransportInitializationOptions, type Unlock, buildHttpClientInstance, createAuthorizationHeaders, getTransportInstance, getTransportManagers, initializeTransportSystem, isFailedStatusCode, isInfoStatusCode, isSuccessStatusCode, isTransportSystemReady, parseRequestParameters, serializeHttpResponseError, shutdownTransportSystem };
|
package/dist/index.d.ts
CHANGED
|
@@ -91,6 +91,26 @@ type LogError = Error & {
|
|
|
91
91
|
url?: string;
|
|
92
92
|
};
|
|
93
93
|
//#endregion
|
|
94
|
+
//#region src/asyncSingleton/index.d.ts
|
|
95
|
+
declare abstract class AsyncSingleton<T, O> {
|
|
96
|
+
private instance;
|
|
97
|
+
private initPromise;
|
|
98
|
+
private retryTimeout;
|
|
99
|
+
private status;
|
|
100
|
+
private initOptions;
|
|
101
|
+
private initArgs;
|
|
102
|
+
protected abstract initInstance(options: O | null, ...args: unknown[]): Promise<T>;
|
|
103
|
+
protected abstract name: string;
|
|
104
|
+
protected getRetryDelay(): number;
|
|
105
|
+
protected getSingleton<U>(ctor: new (...args: unknown[]) => AsyncSingleton<U, unknown>): U;
|
|
106
|
+
getInstance(options?: O | null, ...args: unknown[]): Promise<T>;
|
|
107
|
+
getInstanceIfReady(): T | null;
|
|
108
|
+
isReady(): boolean;
|
|
109
|
+
hasInitFailed(): boolean;
|
|
110
|
+
private init;
|
|
111
|
+
reset(): void;
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
94
114
|
//#region src/cacheClient/types.d.ts
|
|
95
115
|
interface ICacheClient<ClientType = unknown> {
|
|
96
116
|
getData<T>(key: string): Promise<T | null>;
|
|
@@ -208,27 +228,33 @@ declare class RedisClient implements ICacheClient<RedisClientType> {
|
|
|
208
228
|
type Scripts<T extends string> = Record<T, string>;
|
|
209
229
|
type ScriptManagerOptions<T extends string> = {
|
|
210
230
|
redisClientConfig: RedisClientConfig;
|
|
211
|
-
|
|
231
|
+
cacheClient?: ICacheClient<RedisClientType>;
|
|
232
|
+
scripts: Scripts<T>;
|
|
212
233
|
scriptMap?: Map<T, string>;
|
|
234
|
+
logger?: ILogger;
|
|
235
|
+
additionalArgs?: unknown[];
|
|
213
236
|
};
|
|
214
237
|
//#endregion
|
|
215
238
|
//#region src/scriptManager/index.d.ts
|
|
216
|
-
declare class ScriptManager<T extends string
|
|
217
|
-
protected cacheClient: ICacheClient<RedisClientType> | null;
|
|
218
|
-
protected scriptMap: Map<string, string>;
|
|
219
|
-
protected logger?: ILogger;
|
|
220
|
-
protected scripts: Scripts<T>;
|
|
239
|
+
declare abstract class ScriptManager<T extends string, S extends ScriptManager<T, S>> extends AsyncSingleton<S, ScriptManagerOptions<T>> {
|
|
221
240
|
protected redisClientConfig: RedisClientConfig;
|
|
222
|
-
|
|
223
|
-
protected
|
|
241
|
+
protected scripts: Scripts<T>;
|
|
242
|
+
protected scriptMap: Map<T, string>;
|
|
243
|
+
protected cacheClient: ICacheClient<RedisClientType>;
|
|
244
|
+
protected logger: ILogger;
|
|
245
|
+
protected additionalArgs: unknown[];
|
|
246
|
+
protected initInstance({
|
|
224
247
|
redisClientConfig,
|
|
248
|
+
cacheClient,
|
|
249
|
+
scripts,
|
|
250
|
+
scriptMap,
|
|
225
251
|
logger,
|
|
226
|
-
|
|
227
|
-
}: ScriptManagerOptions<T
|
|
228
|
-
protected additionalInitialization(...
|
|
229
|
-
protected loadScripts
|
|
230
|
-
protected executeScript<
|
|
231
|
-
protected
|
|
252
|
+
additionalArgs
|
|
253
|
+
}: ScriptManagerOptions<T>): Promise<S>;
|
|
254
|
+
protected abstract additionalInitialization(...args: unknown[]): Promise<void>;
|
|
255
|
+
protected loadScripts(scripts: Scripts<T>, scriptMap?: Map<T, string>): Promise<void>;
|
|
256
|
+
protected executeScript<U>(method: T, keys: string[], args: string[]): Promise<U | null>;
|
|
257
|
+
protected isRedisReady(): boolean;
|
|
232
258
|
}
|
|
233
259
|
//#endregion
|
|
234
260
|
//#region src/concurrencyManager/types.d.ts
|
|
@@ -259,29 +285,22 @@ declare enum ConcurrencyMethods {
|
|
|
259
285
|
}
|
|
260
286
|
//#endregion
|
|
261
287
|
//#region src/concurrencyManager/index.d.ts
|
|
262
|
-
declare class ConcurrencyManager extends ScriptManager<ConcurrencyMethods> {
|
|
263
|
-
private
|
|
264
|
-
private static asyncInstanceInit;
|
|
265
|
-
private static hasValidRedisConfig;
|
|
266
|
-
private static lastInitFailure;
|
|
267
|
-
private static RETRY_WINDOW_MS;
|
|
268
|
-
private static logger?;
|
|
269
|
-
private static initConfig;
|
|
288
|
+
declare class ConcurrencyManager extends ScriptManager<ConcurrencyMethods, ConcurrencyManager> {
|
|
289
|
+
private hasValidRedisConfig;
|
|
270
290
|
private subscriptionManager;
|
|
271
291
|
private queueManager;
|
|
272
292
|
private generateUUID;
|
|
273
|
-
|
|
293
|
+
name: string;
|
|
274
294
|
protected additionalInitialization(generateUUID?: () => string): Promise<void>;
|
|
275
295
|
private addTestSubscription;
|
|
276
296
|
private checkRedisEventsEmit;
|
|
277
|
-
isRedisConfigured():
|
|
297
|
+
isRedisConfigured(): boolean;
|
|
278
298
|
private subscribeToLeaseExpiry;
|
|
279
299
|
private subscribeToSetRemoval;
|
|
280
300
|
registerRequest(requestKey: string, config: ConcurrencyConfig, requestId: string, requestUrl: string | undefined): Promise<RequestMetadata>;
|
|
281
301
|
releaseRequest(requestId: string, targetConcurrencyKey: string): Promise<boolean>;
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
static close(): void;
|
|
302
|
+
isReady(): boolean;
|
|
303
|
+
close(): void;
|
|
285
304
|
}
|
|
286
305
|
//#endregion
|
|
287
306
|
//#region src/customErrors/schemas.d.ts
|
|
@@ -290,7 +309,7 @@ declare const CUSTOM_ERROR_CONFIG_SCHEMA: z.ZodObject<{
|
|
|
290
309
|
targetStatus: z.ZodNumber;
|
|
291
310
|
message: z.ZodOptional<z.ZodString>;
|
|
292
311
|
condition: z.ZodOptional<z.ZodString>;
|
|
293
|
-
}, z.core.$
|
|
312
|
+
}, z.core.$strict>;
|
|
294
313
|
//#endregion
|
|
295
314
|
//#region src/customErrors/types.d.ts
|
|
296
315
|
type CustomErrorConfig = z.infer<typeof CUSTOM_ERROR_CONFIG_SCHEMA>;
|
|
@@ -317,6 +336,22 @@ type RateLimitConfig = {
|
|
|
317
336
|
mappedRateLimitErrors?: MappedRateLimitErrorConfig[];
|
|
318
337
|
};
|
|
319
338
|
//#endregion
|
|
339
|
+
//#region src/rateLimitManager/constants.d.ts
|
|
340
|
+
declare enum RateLimitMethods {
|
|
341
|
+
incr = "incr",
|
|
342
|
+
}
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/rateLimitManager/index.d.ts
|
|
345
|
+
declare class RateLimitManager extends ScriptManager<RateLimitMethods, RateLimitManager> {
|
|
346
|
+
name: string;
|
|
347
|
+
protected additionalInitialization(): Promise<void>;
|
|
348
|
+
getDynamicMaxWaitTime(ratelimitConfig: RateLimitConfig, concurrencyConfig: ConcurrencyConfig, requestUrl?: string, cutoffTime?: number, fudgeFactor?: number, ballparkResponseTime?: number): number;
|
|
349
|
+
getWaitTime(requestKey: string, config: RateLimitConfig, requestUrl?: string): Promise<number | null>;
|
|
350
|
+
private readyCheck;
|
|
351
|
+
isReady(): boolean;
|
|
352
|
+
close(): void;
|
|
353
|
+
}
|
|
354
|
+
//#endregion
|
|
320
355
|
//#region src/interceptors/types.d.ts
|
|
321
356
|
type RequestInterceptor = (value: InternalAxiosRequestConfig<unknown>) => InternalAxiosRequestConfig<unknown> | Promise<InternalAxiosRequestConfig<unknown>>;
|
|
322
357
|
type ResponseInterceptor = (value: AxiosResponse<unknown, unknown>) => AxiosResponse<unknown, unknown> | Promise<AxiosResponse<unknown, unknown>>;
|
|
@@ -327,6 +362,8 @@ interface InterceptorDependencies {
|
|
|
327
362
|
logger?: ILogger;
|
|
328
363
|
context?: RequestContext;
|
|
329
364
|
requestConfig?: RequestConfig;
|
|
365
|
+
concurrencyManager?: ConcurrencyManager;
|
|
366
|
+
rateLimitManager?: RateLimitManager;
|
|
330
367
|
[key: string]: unknown;
|
|
331
368
|
}
|
|
332
369
|
type RequestConfig = {
|
|
@@ -682,6 +719,8 @@ type HttpTransportInstanceConfig = {
|
|
|
682
719
|
logger?: ILogger;
|
|
683
720
|
context?: RequestContext;
|
|
684
721
|
requestConfig?: RequestConfig;
|
|
722
|
+
concurrencyManager?: ConcurrencyManager;
|
|
723
|
+
rateLimitManager?: RateLimitManager;
|
|
685
724
|
};
|
|
686
725
|
//#endregion
|
|
687
726
|
//#region src/httpTransportFactory/index.d.ts
|
|
@@ -692,12 +731,54 @@ declare class HttpTransportFactory {
|
|
|
692
731
|
httpsAgentConfig,
|
|
693
732
|
logger,
|
|
694
733
|
context,
|
|
695
|
-
requestConfig
|
|
734
|
+
requestConfig,
|
|
735
|
+
concurrencyManager,
|
|
736
|
+
rateLimitManager
|
|
696
737
|
}: HttpTransportInstanceConfig): AxiosInstance;
|
|
697
738
|
private static applyInterceptors;
|
|
698
739
|
private static resolveInterceptorInstance;
|
|
699
740
|
}
|
|
700
741
|
//#endregion
|
|
742
|
+
//#region src/queueManager/utils/enums.d.ts
|
|
743
|
+
declare enum QueueMethods {
|
|
744
|
+
rPush = "rPush",
|
|
745
|
+
lPush = "lPush",
|
|
746
|
+
lPop = "lPop",
|
|
747
|
+
llen = "llen",
|
|
748
|
+
}
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region src/queueManager/types.d.ts
|
|
751
|
+
type OnTurnFunction<T> = (queueName: string, value: string) => T | Promise<T>;
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region src/queueManager/index.d.ts
|
|
754
|
+
declare class QueueManager extends ScriptManager<QueueMethods, QueueManager> {
|
|
755
|
+
private subscriptionManager;
|
|
756
|
+
private eventClient;
|
|
757
|
+
name: string;
|
|
758
|
+
protected additionalInitialization(): Promise<void>;
|
|
759
|
+
joinAndWaitTurn<T>(queueName: string, value: string, hasPriority: boolean, onTurn: OnTurnFunction<T>, coldStartEnabled?: boolean): Promise<T | null>;
|
|
760
|
+
pop<T>(queueName: string): Promise<T | null>;
|
|
761
|
+
length(queueName: string): Promise<number | null>;
|
|
762
|
+
isReady(): boolean;
|
|
763
|
+
close(): void;
|
|
764
|
+
}
|
|
765
|
+
//#endregion
|
|
766
|
+
//#region src/initialization/index.d.ts
|
|
767
|
+
interface TransportInitializationOptions {
|
|
768
|
+
redisClientConfig: RedisClientConfig;
|
|
769
|
+
logger?: ILogger;
|
|
770
|
+
generateUUID?: () => string;
|
|
771
|
+
}
|
|
772
|
+
interface InitializedTransportManagers {
|
|
773
|
+
concurrencyManager: ConcurrencyManager;
|
|
774
|
+
queueManager: QueueManager;
|
|
775
|
+
rateLimitManager: RateLimitManager;
|
|
776
|
+
}
|
|
777
|
+
declare const initializeTransportSystem: (options: TransportInitializationOptions) => Promise<InitializedTransportManagers>;
|
|
778
|
+
declare const shutdownTransportSystem: (logger?: ILogger) => void;
|
|
779
|
+
declare const isTransportSystemReady: () => boolean;
|
|
780
|
+
declare const getTransportManagers: () => InitializedTransportManagers | null;
|
|
781
|
+
//#endregion
|
|
701
782
|
//#region src/instanceManager/index.d.ts
|
|
702
783
|
declare class InstanceManager {
|
|
703
784
|
private static instance;
|
|
@@ -775,55 +856,6 @@ type RequestParameter = {
|
|
|
775
856
|
//#region src/parsers/requestParameters.d.ts
|
|
776
857
|
declare const parseRequestParameters: (parameters: RequestParameter[]) => HttpParameters;
|
|
777
858
|
//#endregion
|
|
778
|
-
//#region src/queueManager/utils/enums.d.ts
|
|
779
|
-
declare enum QueueMethods {
|
|
780
|
-
rPush = "rPush",
|
|
781
|
-
lPush = "lPush",
|
|
782
|
-
lPop = "lPop",
|
|
783
|
-
llen = "llen",
|
|
784
|
-
}
|
|
785
|
-
//#endregion
|
|
786
|
-
//#region src/queueManager/types.d.ts
|
|
787
|
-
type OnTurnFunction<T> = (queueName: string, value: string) => T | Promise<T>;
|
|
788
|
-
//#endregion
|
|
789
|
-
//#region src/queueManager/index.d.ts
|
|
790
|
-
declare class QueueManager extends ScriptManager<QueueMethods> {
|
|
791
|
-
private static instance;
|
|
792
|
-
private static asyncInstanceInit;
|
|
793
|
-
private static logger?;
|
|
794
|
-
private static config?;
|
|
795
|
-
protected logger?: ILogger;
|
|
796
|
-
private subscriptionManager;
|
|
797
|
-
private eventClient;
|
|
798
|
-
static getInstance(config?: RedisClientConfig, logger?: ILogger, scriptMap?: Map<QueueMethods, string>): Promise<QueueManager>;
|
|
799
|
-
protected additionalInitialization(): Promise<void>;
|
|
800
|
-
joinAndWaitTurn<T>(queueName: string, value: string, hasPriority: boolean, onTurn: OnTurnFunction<T>, coldStartEnabled?: boolean): Promise<T | null>;
|
|
801
|
-
pop<T>(queueName: string): Promise<T | null>;
|
|
802
|
-
length(queueName: string): Promise<number | null>;
|
|
803
|
-
private readyCheck;
|
|
804
|
-
isReady(): Promise<boolean>;
|
|
805
|
-
close(): void;
|
|
806
|
-
}
|
|
807
|
-
//#endregion
|
|
808
|
-
//#region src/rateLimitManager/constants.d.ts
|
|
809
|
-
declare enum RateLimitMethods {
|
|
810
|
-
incr = "incr",
|
|
811
|
-
}
|
|
812
|
-
//#endregion
|
|
813
|
-
//#region src/rateLimitManager/index.d.ts
|
|
814
|
-
declare class RateLimitManager extends ScriptManager<RateLimitMethods> {
|
|
815
|
-
private static instance;
|
|
816
|
-
private static asyncInstanceInit;
|
|
817
|
-
private static logger?;
|
|
818
|
-
private static initConfig;
|
|
819
|
-
static getInstance(config?: RedisClientConfig, logger?: ILogger, scriptMap?: Map<RateLimitMethods, string>): Promise<RateLimitManager>;
|
|
820
|
-
getDynamicMaxWaitTime(ratelimitConfig: RateLimitConfig, concurrencyConfig: ConcurrencyConfig, requestUrl?: string, cutoffTime?: number, fudgeFactor?: number, ballparkResponseTime?: number): Promise<number>;
|
|
821
|
-
getWaitTime(requestKey: any, config: RateLimitConfig, requestUrl?: string): Promise<number | null>;
|
|
822
|
-
private readyCheck;
|
|
823
|
-
static isReady(): Promise<boolean>;
|
|
824
|
-
static close(): void;
|
|
825
|
-
}
|
|
826
|
-
//#endregion
|
|
827
859
|
//#region src/requestClient/types.d.ts
|
|
828
860
|
interface IRequestClient {
|
|
829
861
|
performRequest: ({
|
|
@@ -892,4 +924,4 @@ type LockEntry = {
|
|
|
892
924
|
unlock: Unlock;
|
|
893
925
|
};
|
|
894
926
|
//#endregion
|
|
895
|
-
export { CUSTOM_ERROR_CONFIG_SCHEMA, type ConcurrencyConfig, ConcurrencyManager, type CustomErrorConfig, type ErrorMappingFn, EventClient, HttpClient, HttpClientManager, HttpErrorMessages, type HttpHeaders, type HttpMethod, HttpMethods, type HttpParameters, type HttpQueryParams, type HttpResponse, HttpResponseError, HttpTransportFactory, type ICacheClient, type IHttpClient, InstanceManager, type Lock, type LockEntry, LockManager, MemoryStore, type MemoryStoreConfig, type PruneCount, type PubSubListener, QueueManager, type RateLimitConfig, RateLimitManager, RedisClient, type RedisClientConfig, type RedisClientType, RequestClientFactory, type RequestConfig, type RequestContext, type RequestParameter, RequestParameterLocations, ScriptManager, SubscriptionManager, type Unlock, buildHttpClientInstance, createAuthorizationHeaders, getTransportInstance, isFailedStatusCode, isInfoStatusCode, isSuccessStatusCode, parseRequestParameters, serializeHttpResponseError };
|
|
927
|
+
export { CUSTOM_ERROR_CONFIG_SCHEMA, type ConcurrencyConfig, ConcurrencyManager, type CustomErrorConfig, type ErrorMappingFn, EventClient, HttpClient, HttpClientManager, HttpErrorMessages, type HttpHeaders, type HttpMethod, HttpMethods, type HttpParameters, type HttpQueryParams, type HttpResponse, HttpResponseError, HttpTransportFactory, type ICacheClient, type IHttpClient, type InitializedTransportManagers, InstanceManager, type Lock, type LockEntry, LockManager, MemoryStore, type MemoryStoreConfig, type PruneCount, type PubSubListener, QueueManager, type RateLimitConfig, RateLimitManager, RedisClient, type RedisClientConfig, type RedisClientType, RequestClientFactory, type RequestConfig, type RequestContext, type RequestParameter, RequestParameterLocations, ScriptManager, SubscriptionManager, type TransportInitializationOptions, type Unlock, buildHttpClientInstance, createAuthorizationHeaders, getTransportInstance, getTransportManagers, initializeTransportSystem, isFailedStatusCode, isInfoStatusCode, isSuccessStatusCode, isTransportSystemReady, parseRequestParameters, serializeHttpResponseError, shutdownTransportSystem };
|