@stackone/transport 1.7.0 → 1.8.2

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 (34) hide show
  1. package/dist/index.d.mts +753 -0
  2. package/dist/index.d.ts +753 -0
  3. package/dist/index.js +13540 -1
  4. package/dist/index.mjs +13516 -0
  5. package/package.json +28 -10
  6. package/dist/index.es.mjs +0 -1
  7. package/dist/types/authorization/authorizationHeaders.d.ts +0 -4
  8. package/dist/types/authorization/types.d.ts +0 -12
  9. package/dist/types/cacheClient/types.d.ts +0 -31
  10. package/dist/types/customErrors/index.d.ts +0 -3
  11. package/dist/types/customErrors/schemas.d.ts +0 -17
  12. package/dist/types/customErrors/types.d.ts +0 -4
  13. package/dist/types/errors/httpResponseError.d.ts +0 -6
  14. package/dist/types/httpClient/httpClient.d.ts +0 -37
  15. package/dist/types/httpClient/httpClientManager.d.ts +0 -10
  16. package/dist/types/httpClient/types.d.ts +0 -57
  17. package/dist/types/index.d.ts +0 -17
  18. package/dist/types/instanceManager/constants.d.ts +0 -1
  19. package/dist/types/instanceManager/index.d.ts +0 -15
  20. package/dist/types/lockManager/index.d.ts +0 -9
  21. package/dist/types/lockManager/types.d.ts +0 -6
  22. package/dist/types/memoryStore/constants.d.ts +0 -12
  23. package/dist/types/memoryStore/index.d.ts +0 -42
  24. package/dist/types/memoryStore/types.d.ts +0 -19
  25. package/dist/types/parsers/requestParameters.d.ts +0 -3
  26. package/dist/types/parsers/types.d.ts +0 -7
  27. package/dist/types/redisClient/index.d.ts +0 -69
  28. package/dist/types/redisClient/types.d.ts +0 -31
  29. package/dist/types/requestClient/requestClientFactory.d.ts +0 -4
  30. package/dist/types/requestClient/restClient.d.ts +0 -13
  31. package/dist/types/requestClient/types.d.ts +0 -14
  32. package/dist/types/scriptManager/index.d.ts +0 -21
  33. package/dist/types/scriptManager/types.d.ts +0 -8
  34. package/dist/types/validators/statusCodes.d.ts +0 -3
@@ -0,0 +1,753 @@
1
+ import { ILogger } from "@stackone/logger";
2
+ import * as redis from "redis";
3
+ import { AxiosInstance, AxiosInterceptorOptions, AxiosResponse, CreateAxiosDefaults, InternalAxiosRequestConfig } from "axios";
4
+ import { z } from "zod/v4";
5
+ import https from "https";
6
+ import { AgentOptions } from "node:http";
7
+
8
+ //#region src/authorization/types.d.ts
9
+ type BasicAuthorizationParams = {
10
+ type: 'basic';
11
+ username?: string;
12
+ password?: string;
13
+ encoding?: string;
14
+ };
15
+ type BearerAuthorizationParams = {
16
+ type: 'bearer';
17
+ token: string;
18
+ includeBearer?: boolean;
19
+ };
20
+ //#endregion
21
+ //#region src/authorization/authorizationHeaders.d.ts
22
+ declare const createAuthorizationHeaders: (authenticationParams: BasicAuthorizationParams | BearerAuthorizationParams) => {
23
+ authorization: string;
24
+ };
25
+ //#endregion
26
+ //#region src/cacheClient/types.d.ts
27
+ interface ICacheClient<ClientType = unknown> {
28
+ getData<T>(key: string): Promise<T | null>;
29
+ listData<T>({
30
+ partialKey,
31
+ limit,
32
+ cursor
33
+ }: {
34
+ partialKey: string;
35
+ limit?: number;
36
+ cursor?: string;
37
+ }): Promise<{
38
+ items: T[] | null;
39
+ cursor?: string;
40
+ }>;
41
+ setData<T>({
42
+ key,
43
+ value,
44
+ cacheTTL,
45
+ groupKey
46
+ }: {
47
+ key: string;
48
+ value: T;
49
+ cacheTTL: number;
50
+ groupKey?: string;
51
+ }): Promise<boolean>;
52
+ executeScript?<T>({
53
+ sha1,
54
+ keys,
55
+ args
56
+ }: {
57
+ sha1: string;
58
+ keys: string[];
59
+ args: string[];
60
+ }): Promise<T | null>;
61
+ loadScript?(script: string): Promise<string | null>;
62
+ increment?(key: string, cacheTTL: number): Promise<number | null>;
63
+ decrement?(key: string, cacheTTL: number): Promise<number | null>;
64
+ subscribe?<T extends boolean = false>(pattern: string, listener: PubSubListener<T>): Promise<boolean>;
65
+ unsubscribe?(pattern: string): Promise<boolean>;
66
+ publish?(channel: string, message: string): Promise<number | null>;
67
+ getClient?(): ClientType | null;
68
+ deleteData?(key: string): Promise<boolean>;
69
+ }
70
+ type PubSubListener<ReturnsBuffer extends boolean = false> = <T extends (ReturnsBuffer extends true ? Buffer : string)>(message: T, channel: T) => unknown;
71
+ //#endregion
72
+ //#region src/redisClient/index.d.ts
73
+ type RedisClientType = redis.RedisClientType;
74
+ interface RedisClientConfig {
75
+ getRedisClient?: typeof redis.createClient;
76
+ host?: string;
77
+ port?: number;
78
+ tls?: boolean;
79
+ reconnect?: boolean;
80
+ database?: number;
81
+ }
82
+ declare const buildRedisClientInstance: (config: RedisClientConfig, logger?: ILogger) => Promise<ICacheClient<RedisClientType> | undefined>;
83
+ declare class RedisClient implements ICacheClient<RedisClientType> {
84
+ #private;
85
+ static build({
86
+ getRedisClient,
87
+ host,
88
+ port,
89
+ tls,
90
+ reconnect,
91
+ database
92
+ }: RedisClientConfig, logger?: ILogger): Promise<ICacheClient<RedisClientType> | null>;
93
+ getData<T>(key: string): Promise<T | null>;
94
+ setData<T>({
95
+ key,
96
+ value,
97
+ cacheTTL,
98
+ groupKey
99
+ }: {
100
+ key: string;
101
+ value: T;
102
+ cacheTTL: number;
103
+ groupKey?: string;
104
+ }): Promise<boolean>;
105
+ executeScript<T>({
106
+ sha1,
107
+ keys,
108
+ args
109
+ }: {
110
+ sha1: string;
111
+ keys: string[];
112
+ args: string[];
113
+ }): Promise<T | null>;
114
+ loadScript(script: string): Promise<string | null>;
115
+ increment(key: string, cacheTTL: number): Promise<number | null>;
116
+ decrement(key: string, cacheTTL: number): Promise<number | null>;
117
+ subscribe<T extends boolean>(pattern: string, listener: PubSubListener<T>): Promise<boolean>;
118
+ unsubscribe(pattern: string): Promise<boolean>;
119
+ publish(channel: string, message: string): Promise<number | null>;
120
+ getClient(): RedisClientType | null;
121
+ listData<T>({
122
+ partialKey,
123
+ limit,
124
+ cursor
125
+ }: {
126
+ partialKey: string;
127
+ limit: number;
128
+ cursor?: string;
129
+ }): Promise<{
130
+ items: T[] | null;
131
+ cursor?: string;
132
+ }>;
133
+ deleteData(key: string): Promise<boolean>;
134
+ }
135
+ //#endregion
136
+ //#region src/scriptManager/types.d.ts
137
+ type Scripts<T extends string> = Record<T, string>;
138
+ type ScriptManagerOptions<T extends string> = {
139
+ redisClientConfig: RedisClientConfig;
140
+ logger?: ILogger;
141
+ scriptMap?: Map<T, string>;
142
+ };
143
+ //#endregion
144
+ //#region src/scriptManager/index.d.ts
145
+ declare class ScriptManager<T extends string> {
146
+ protected cacheClient: ICacheClient<RedisClientType> | null;
147
+ protected scriptMap: Map<string, string>;
148
+ protected logger?: ILogger;
149
+ protected scripts: Scripts<T>;
150
+ protected redisClientConfig: RedisClientConfig;
151
+ constructor(preLoadScripts: Scripts<T>);
152
+ protected initialize({
153
+ redisClientConfig,
154
+ logger,
155
+ scriptMap
156
+ }: ScriptManagerOptions<T>, ...args: unknown[]): Promise<void>;
157
+ protected additionalInitialization(..._args: unknown[]): Promise<void>;
158
+ protected loadScripts<U extends string>(scripts: Scripts<U>, scriptMap?: Map<U, string>): Promise<void>;
159
+ protected executeScript<X extends string, U>(method: X, keys: string[], args: string[]): Promise<U | null>;
160
+ protected isReady(): Promise<boolean>;
161
+ }
162
+ //#endregion
163
+ //#region src/concurrencyManager/types.d.ts
164
+ type ConcurrencySubPoolConfig = {
165
+ subPoolKey: string;
166
+ urlPattern: RegExp | string;
167
+ maxConcurrency: number;
168
+ };
169
+ type ConcurrencyConfig = {
170
+ mainMaxConcurrency: number;
171
+ subPools?: ConcurrencySubPoolConfig[];
172
+ };
173
+ type RequestMetadata = {
174
+ requestId: string;
175
+ targetConcurrencyKey: string;
176
+ leaseSubscription: boolean;
177
+ setRemovalSubscription: boolean;
178
+ queueKey: string;
179
+ joinCondition?: 'optimistic' | 'attempts' | 'failed';
180
+ failureReason?: string;
181
+ };
182
+ //#endregion
183
+ //#region src/concurrencyManager/utils/index.d.ts
184
+ declare enum ConcurrencyMethods {
185
+ tryConcurrency = "tryConcurrency",
186
+ removeFromSet = "removeFromSet",
187
+ publishNextItem = "publishNextItem",
188
+ }
189
+ //#endregion
190
+ //#region src/concurrencyManager/index.d.ts
191
+ declare class ConcurrencyManager extends ScriptManager<ConcurrencyMethods> {
192
+ private static instance;
193
+ private static asyncInstanceInit;
194
+ private static hasValidRedisConfig;
195
+ private static lastInitFailure;
196
+ private static RETRY_WINDOW_MS;
197
+ private static logger?;
198
+ private static initConfig;
199
+ private subscriptionManager;
200
+ private queueManager;
201
+ private generateUUID;
202
+ static getInstance(config?: RedisClientConfig, logger?: ILogger, scriptMap?: Map<ConcurrencyMethods, string>, generateUUID?: () => string): Promise<ConcurrencyManager>;
203
+ protected additionalInitialization(generateUUID?: () => string): Promise<void>;
204
+ private addTestSubscription;
205
+ private checkRedisEventsEmit;
206
+ isRedisConfigured(): Promise<boolean>;
207
+ private subscribeToLeaseExpiry;
208
+ private subscribeToSetRemoval;
209
+ registerRequest(requestKey: string, config: ConcurrencyConfig, requestId: string, requestUrl: string | undefined): Promise<RequestMetadata>;
210
+ releaseRequest(requestId: string, targetConcurrencyKey: string): Promise<boolean>;
211
+ private readyCheck;
212
+ static isReady(): Promise<boolean>;
213
+ static close(): void;
214
+ }
215
+ //#endregion
216
+ //#region src/customErrors/schemas.d.ts
217
+ declare const CUSTOM_ERROR_CONFIG_SCHEMA: z.ZodObject<{
218
+ receivedStatus: z.ZodNumber;
219
+ targetStatus: z.ZodNumber;
220
+ message: z.ZodOptional<z.ZodString>;
221
+ condition: z.ZodOptional<z.ZodString>;
222
+ }, z.core.$strip>;
223
+ //#endregion
224
+ //#region src/customErrors/types.d.ts
225
+ type CustomErrorConfig = z.infer<typeof CUSTOM_ERROR_CONFIG_SCHEMA>;
226
+ declare const HttpErrorMessages: Record<number, string>;
227
+ //#endregion
228
+ //#region src/httpClient/types.d.ts
229
+ type HttpHeaders = {
230
+ [key: string]: string;
231
+ };
232
+ type HttpQueryParams = {
233
+ [key: string]: string;
234
+ };
235
+ declare const HttpMethods: readonly ["get", "post", "put", "delete", "patch"];
236
+ type HttpMethod = (typeof HttpMethods)[number];
237
+ type HttpResponse<T = any> = {
238
+ data: T;
239
+ status: number;
240
+ headers: HttpHeaders;
241
+ requestUrl: string;
242
+ responseType?: string;
243
+ responseTime?: Date;
244
+ message?: string;
245
+ };
246
+ type HttpParameters = {
247
+ query: HttpQueryParams;
248
+ body: Record<string, unknown>;
249
+ headers: HttpHeaders;
250
+ };
251
+ interface IHttpClient {
252
+ request<P, T>({
253
+ headers,
254
+ url,
255
+ method,
256
+ queryParams,
257
+ maxRedirects,
258
+ responseType,
259
+ cacheTTL,
260
+ context,
261
+ payload,
262
+ httpsAgent
263
+ }: {
264
+ headers?: HttpHeaders;
265
+ url: string;
266
+ method?: HttpMethod;
267
+ queryParams?: HttpQueryParams;
268
+ maxRedirects?: number;
269
+ responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text';
270
+ cacheTTL?: number;
271
+ context?: unknown;
272
+ payload?: P;
273
+ httpsAgent?: https.Agent;
274
+ }): Promise<HttpResponse<T>>;
275
+ get<T>({
276
+ headers,
277
+ url,
278
+ queryParams,
279
+ maxRedirects,
280
+ cacheTTL,
281
+ context
282
+ }: {
283
+ headers?: HttpHeaders;
284
+ url: string;
285
+ queryParams?: HttpQueryParams;
286
+ maxRedirects?: number;
287
+ cacheTTL?: number;
288
+ context?: unknown;
289
+ }): Promise<HttpResponse<T>>;
290
+ post<P, T>({
291
+ headers,
292
+ url,
293
+ maxRedirects,
294
+ cacheTTL,
295
+ context,
296
+ payload
297
+ }: {
298
+ headers?: HttpHeaders;
299
+ url: string;
300
+ maxRedirects?: number;
301
+ cacheTTL?: number;
302
+ context?: unknown;
303
+ payload?: P;
304
+ }): Promise<HttpResponse<T>>;
305
+ }
306
+ interface OperationSetting {
307
+ url?: string;
308
+ query?: Record<string, string>;
309
+ config?: Partial<APIConfig>;
310
+ custom_settings?: Record<string, unknown>;
311
+ }
312
+ type OperationSettings = Record<string, OperationSetting>;
313
+ type AccountSettings = Record<string, string | number | boolean | object>;
314
+ type HttpClientBehaviour = 'CONCURRENCY' | 'RETRY';
315
+ type APIConfig = Record<string, unknown>;
316
+ type RequestContext = {
317
+ accountSecureId?: string;
318
+ projectSecureId?: string;
319
+ organizationId?: number;
320
+ environment?: string;
321
+ authConfigKey?: string;
322
+ provider?: string;
323
+ service?: string;
324
+ resource?: string;
325
+ subResource?: string;
326
+ childResource?: string;
327
+ operation?: string;
328
+ action?: string;
329
+ mode?: string;
330
+ testerUniqueToken?: string;
331
+ externalKey?: string;
332
+ dataKey?: string;
333
+ isDataSync?: boolean;
334
+ operationSettings?: OperationSettings;
335
+ accountSettings?: AccountSettings;
336
+ behaviours?: HttpClientBehaviour[];
337
+ };
338
+ //#endregion
339
+ //#region src/errors/httpResponseError.d.ts
340
+ declare class HttpResponseError extends Error {
341
+ readonly response: HttpResponse;
342
+ constructor(response: HttpResponse, message?: string);
343
+ toString(): string;
344
+ }
345
+ //#endregion
346
+ //#region src/lockManager/index.d.ts
347
+ declare class LockManager {
348
+ private locks;
349
+ constructor();
350
+ withLock<T>(key: string, operation: () => Promise<T>): Promise<T>;
351
+ lock(key: string): Promise<void>;
352
+ unlock(key: string): void;
353
+ queueLength(key: string): number | undefined;
354
+ close(): void;
355
+ }
356
+ //#endregion
357
+ //#region src/memoryStore/types.d.ts
358
+ interface MemoryStoreConfig<T> {
359
+ instantiator?: string;
360
+ logger?: ILogger;
361
+ dataStore?: Map<string, T>;
362
+ lockManager?: LockManager;
363
+ expiryMap?: Map<string, number>;
364
+ evictionFrequency?: number;
365
+ staleDataThreshold?: number;
366
+ truncateThreshold?: number;
367
+ truncationPercentage?: number;
368
+ typeGuard?: (data: unknown) => data is T;
369
+ dispose?: (key: string, value: T) => Promise<void> | void;
370
+ }
371
+ type PruneCount = {
372
+ dataStoreSize: number;
373
+ prunedDataStoreSize: number;
374
+ };
375
+ //#endregion
376
+ //#region src/eventClient/types.d.ts
377
+ type PromiseExecutorMethods<T> = {
378
+ resolve?: (value: T) => void;
379
+ reject?: (reason: unknown) => void;
380
+ };
381
+ type EventClientConfig<T> = {
382
+ instantiator?: string;
383
+ defaultTimeoutMS?: number;
384
+ timeoutResolveValue?: T;
385
+ };
386
+ //#endregion
387
+ //#region src/eventClient/index.d.ts
388
+ declare class EventClient<T> {
389
+ private executorMethodStore;
390
+ private promiseStore;
391
+ private logger;
392
+ private eventClientConfig?;
393
+ private executorMethodStoreConfig?;
394
+ private pendingPromiseStoreConfig?;
395
+ constructor(eventClientConfig?: EventClientConfig<T>, executorMethodStoreConfig?: MemoryStoreConfig<PromiseExecutorMethods<T> | undefined>, pendingPromiseStoreConfig?: MemoryStoreConfig<Promise<T> | undefined>);
396
+ setPendingEvent(eventKey: string, timeoutInMS: number): Promise<void>;
397
+ waitForEvent(eventKey: string, timeoutInMS: number): Promise<T | null>;
398
+ getPendingEvent(eventKey: string): Promise<T | null>;
399
+ deleteEvent(eventKey: string): Promise<boolean>;
400
+ resolveEvent(eventKey: string, value: T): Promise<void>;
401
+ private defaultExecutorMethodDispose;
402
+ private defaultExecutorMethodTypeGuard;
403
+ private defaultPendingPromiseDispose;
404
+ private defaultPendingPromiseTypeGuard;
405
+ }
406
+ //#endregion
407
+ //#region src/getTransportInstance/index.d.ts
408
+ declare const getTransportInstance: (logger: ILogger, context?: RequestContext) => Promise<AxiosInstance>;
409
+ //#endregion
410
+ //#region src/httpClient/httpClient.d.ts
411
+ declare class HttpClient implements IHttpClient {
412
+ #private;
413
+ constructor({
414
+ transportInstance
415
+ }?: {
416
+ transportInstance?: AxiosInstance;
417
+ });
418
+ request<P, T>({
419
+ headers,
420
+ url,
421
+ method,
422
+ queryParams,
423
+ maxRedirects,
424
+ responseType,
425
+ cacheTTL,
426
+ context,
427
+ payload,
428
+ httpsAgent
429
+ }: {
430
+ headers?: HttpHeaders;
431
+ url: string;
432
+ method?: HttpMethod;
433
+ queryParams?: HttpQueryParams;
434
+ maxRedirects?: number;
435
+ responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text';
436
+ cacheTTL?: number;
437
+ context?: unknown;
438
+ payload?: P;
439
+ httpsAgent?: https.Agent;
440
+ }): Promise<HttpResponse<T>>;
441
+ get<T>({
442
+ headers,
443
+ url,
444
+ queryParams,
445
+ maxRedirects,
446
+ cacheTTL,
447
+ context
448
+ }: {
449
+ headers?: HttpHeaders;
450
+ url: string;
451
+ queryParams?: HttpQueryParams;
452
+ maxRedirects?: number;
453
+ cacheTTL?: number;
454
+ context?: unknown;
455
+ }): Promise<HttpResponse<T>>;
456
+ post<P, T>({
457
+ headers,
458
+ url,
459
+ maxRedirects,
460
+ cacheTTL,
461
+ context,
462
+ payload
463
+ }: {
464
+ headers?: HttpHeaders;
465
+ url: string;
466
+ maxRedirects?: number;
467
+ cacheTTL?: number;
468
+ context?: unknown;
469
+ payload?: P;
470
+ }): Promise<HttpResponse<T>>;
471
+ }
472
+ //#endregion
473
+ //#region src/httpClient/httpClientManager.d.ts
474
+ declare const buildHttpClientInstance: () => IHttpClient;
475
+ declare class HttpClientManager {
476
+ private static httpClientInstance;
477
+ static getInstance({
478
+ getHttpClient
479
+ }?: {
480
+ getHttpClient?: typeof buildHttpClientInstance;
481
+ }): Promise<IHttpClient>;
482
+ static resetInstance(): void;
483
+ }
484
+ //#endregion
485
+ //#region src/rateLimitManager/types.d.ts
486
+ type RateLimitSubPoolConfig = {
487
+ subPoolKey: string;
488
+ urlPattern: RegExp | string;
489
+ rateLimit: number;
490
+ };
491
+ type RetryUnit = 'seconds' | 'milliseconds' | 'date';
492
+ type MappedRateLimitErrorConfig = {
493
+ errorStatus: number;
494
+ errorMessage: string | RegExp;
495
+ errorMessagePath?: string;
496
+ retryAfterPath?: string;
497
+ retryAfterUnit?: RetryUnit;
498
+ retryAfterValue?: number;
499
+ };
500
+ type RateLimitConfig = {
501
+ mainRatelimit: number;
502
+ subPools?: RateLimitSubPoolConfig[];
503
+ mappedRateLimitErrors?: MappedRateLimitErrorConfig[];
504
+ };
505
+ //#endregion
506
+ //#region src/interceptors/types.d.ts
507
+ type RequestInterceptor = (value: InternalAxiosRequestConfig<unknown>) => InternalAxiosRequestConfig<unknown> | Promise<InternalAxiosRequestConfig<unknown>>;
508
+ type ResponseInterceptor = (value: AxiosResponse<unknown, unknown>) => AxiosResponse<unknown, unknown> | Promise<AxiosResponse<unknown, unknown>>;
509
+ type ErrorInterceptor = (error: unknown) => unknown;
510
+ type Interceptor = RequestInterceptor | ResponseInterceptor | ErrorInterceptor | null;
511
+ interface InterceptorDependencies {
512
+ axiosInstance?: AxiosInstance;
513
+ logger?: ILogger;
514
+ context?: RequestContext;
515
+ requestConfig?: RequestConfig;
516
+ [key: string]: unknown;
517
+ }
518
+ type RequestConfig = {
519
+ rateLimits?: RateLimitConfig;
520
+ concurrency?: ConcurrencyConfig;
521
+ };
522
+ //#endregion
523
+ //#region src/httpTransportFactory/types.d.ts
524
+ type InterceptorDependencyInjector<T extends Interceptor> = (dependencies: InterceptorDependencies) => T;
525
+ type RequestInterceptorConfig = {
526
+ onFulfilled: InterceptorDependencyInjector<RequestInterceptor> | RequestInterceptor | null;
527
+ onRejected: InterceptorDependencyInjector<ErrorInterceptor> | ErrorInterceptor | null;
528
+ options: AxiosInterceptorOptions | undefined;
529
+ };
530
+ type ResponseInterceptorConfig = {
531
+ onFulfilled: InterceptorDependencyInjector<ResponseInterceptor> | ResponseInterceptor | null;
532
+ onRejected: InterceptorDependencyInjector<ErrorInterceptor> | ErrorInterceptor | null;
533
+ };
534
+ type InterceptorConfigs = {
535
+ requestConfigs?: RequestInterceptorConfig[];
536
+ responseConfigs?: ResponseInterceptorConfig[];
537
+ };
538
+ type HttpTransportInstanceConfig = {
539
+ interceptors?: InterceptorConfigs;
540
+ instanceConfig?: CreateAxiosDefaults;
541
+ httpAgentConfig?: AgentOptions;
542
+ logger: ILogger;
543
+ context?: RequestContext;
544
+ };
545
+ //#endregion
546
+ //#region src/httpTransportFactory/index.d.ts
547
+ declare class HttpTransportFactory {
548
+ static createInstance({
549
+ interceptors,
550
+ instanceConfig,
551
+ httpAgentConfig,
552
+ logger,
553
+ context
554
+ }: HttpTransportInstanceConfig): AxiosInstance;
555
+ private static applyInterceptors;
556
+ private static resolveInterceptorInstance;
557
+ }
558
+ //#endregion
559
+ //#region src/instanceManager/index.d.ts
560
+ declare class InstanceManager {
561
+ private static instance;
562
+ private static logger;
563
+ private dataStore;
564
+ private constructor();
565
+ static getInstance(logger?: ILogger): InstanceManager;
566
+ private initialize;
567
+ get<T>(key: string): Promise<T | null>;
568
+ set<T>(key: string, value: T, cacheTTL?: number): Promise<boolean>;
569
+ private ensureReady;
570
+ isReady(): boolean;
571
+ close(): void;
572
+ }
573
+ //#endregion
574
+ //#region src/memoryStore/index.d.ts
575
+ declare class MemoryStore<T> implements ICacheClient {
576
+ private config;
577
+ private instantiator;
578
+ private dataStore;
579
+ private lockManager;
580
+ private expiryMap;
581
+ private evictionFrequency;
582
+ private staleDataThreshold;
583
+ private truncateThreshold;
584
+ private truncationPercentage;
585
+ private logger?;
586
+ private typeGuard?;
587
+ private dispose?;
588
+ private evictionInterval?;
589
+ private lastAccessedAt;
590
+ constructor(config?: MemoryStoreConfig<T>);
591
+ private initialize;
592
+ getData<U = T>(key: string): Promise<U | null>;
593
+ setData<U = T>({
594
+ key,
595
+ value,
596
+ cacheTTL
597
+ }: {
598
+ key: string;
599
+ value: U;
600
+ cacheTTL?: number;
601
+ }): Promise<boolean>;
602
+ private typeGuardBypass;
603
+ delete(key: string): Promise<boolean>;
604
+ pruneExpiredKeys(): Promise<PruneCount | undefined>;
605
+ private startEvictionTask;
606
+ private stopEvictionTask;
607
+ private updateLastAccessedAt;
608
+ isReady(): boolean;
609
+ close(): void;
610
+ listData<T>({
611
+ partialKey,
612
+ cursor,
613
+ limit
614
+ }: {
615
+ partialKey: string;
616
+ cursor?: string;
617
+ limit: number;
618
+ }): Promise<{
619
+ items: T[] | null;
620
+ cursor?: string;
621
+ }>;
622
+ }
623
+ //#endregion
624
+ //#region src/parsers/types.d.ts
625
+ declare const RequestParameterLocations: readonly ["query", "body", "headers"];
626
+ type RequestParameterLocation = (typeof RequestParameterLocations)[number];
627
+ type RequestParameter = {
628
+ name: string;
629
+ in: RequestParameterLocation;
630
+ value?: unknown;
631
+ };
632
+ //#endregion
633
+ //#region src/parsers/requestParameters.d.ts
634
+ declare const parseRequestParameters: (parameters: RequestParameter[]) => HttpParameters;
635
+ //#endregion
636
+ //#region src/queueManager/utils/enums.d.ts
637
+ declare enum QueueMethods {
638
+ rPush = "rPush",
639
+ lPush = "lPush",
640
+ lPop = "lPop",
641
+ llen = "llen",
642
+ }
643
+ //#endregion
644
+ //#region src/queueManager/types.d.ts
645
+ type OnTurnFunction<T> = (queueName: string, value: string) => T | Promise<T>;
646
+ //#endregion
647
+ //#region src/queueManager/index.d.ts
648
+ declare class QueueManager extends ScriptManager<QueueMethods> {
649
+ private static instance;
650
+ private static asyncInstanceInit;
651
+ private static logger?;
652
+ private static config?;
653
+ protected logger?: ILogger;
654
+ private subscriptionManager;
655
+ private eventClient;
656
+ static getInstance(config?: RedisClientConfig, logger?: ILogger, scriptMap?: Map<QueueMethods, string>): Promise<QueueManager>;
657
+ protected additionalInitialization(): Promise<void>;
658
+ joinAndWaitTurn<T>(queueName: string, value: string, hasPriority: boolean, onTurn: OnTurnFunction<T>, coldStartEnabled?: boolean): Promise<T | null>;
659
+ pop<T>(queueName: string): Promise<T | null>;
660
+ length(queueName: string): Promise<number | null>;
661
+ private readyCheck;
662
+ isReady(): Promise<boolean>;
663
+ close(): void;
664
+ }
665
+ //#endregion
666
+ //#region src/rateLimitManager/constants.d.ts
667
+ declare enum RateLimitMethods {
668
+ incr = "incr",
669
+ }
670
+ //#endregion
671
+ //#region src/rateLimitManager/index.d.ts
672
+ declare class RateLimitManager extends ScriptManager<RateLimitMethods> {
673
+ private static instance;
674
+ private static asyncInstanceInit;
675
+ private static logger?;
676
+ private static initConfig;
677
+ static getInstance(config?: RedisClientConfig, logger?: ILogger, scriptMap?: Map<RateLimitMethods, string>): Promise<RateLimitManager>;
678
+ getDynamicMaxWaitTime(ratelimitConfig: RateLimitConfig, concurrencyConfig: ConcurrencyConfig, requestUrl?: string, cutoffTime?: number, fudgeFactor?: number, ballparkResponseTime?: number): Promise<number>;
679
+ getWaitTime(requestKey: any, config: RateLimitConfig, requestUrl?: string): Promise<number | null>;
680
+ private readyCheck;
681
+ static isReady(): Promise<boolean>;
682
+ static close(): void;
683
+ }
684
+ //#endregion
685
+ //#region src/requestClient/types.d.ts
686
+ interface IRequestClient {
687
+ performRequest: ({
688
+ httpClient,
689
+ url,
690
+ method,
691
+ headers,
692
+ body,
693
+ customErrorConfigs
694
+ }: {
695
+ httpClient: IHttpClient;
696
+ url: string;
697
+ method: HttpMethod;
698
+ headers: HttpHeaders;
699
+ queryParams?: HttpQueryParams;
700
+ body: unknown;
701
+ customErrorConfigs?: CustomErrorConfig[];
702
+ }) => Promise<HttpResponse>;
703
+ }
704
+ type RequestClientType = 'rest' | 'soap';
705
+ //#endregion
706
+ //#region src/requestClient/requestClientFactory.d.ts
707
+ declare class RequestClientFactory {
708
+ static build(type?: RequestClientType): IRequestClient;
709
+ }
710
+ //#endregion
711
+ //#region src/redisClient/types.d.ts
712
+ type GetRedisClient = typeof buildRedisClientInstance;
713
+ //#endregion
714
+ //#region src/subscriptionManager/types.d.ts
715
+ type SubscriptionManagerOptions = {
716
+ config?: RedisClientConfig;
717
+ getCacheClient?: GetRedisClient;
718
+ logger?: ILogger;
719
+ instantiator?: string;
720
+ subscriptionTTL?: number;
721
+ staleSubscriptionsThreshold?: number;
722
+ truncateThreshold?: number;
723
+ truncationPercentage?: number;
724
+ };
725
+ //#endregion
726
+ //#region src/subscriptionManager/index.d.ts
727
+ declare class SubscriptionManager {
728
+ private options;
729
+ private subscriptionMap;
730
+ private subscriptionClient;
731
+ private logger?;
732
+ constructor(options: SubscriptionManagerOptions);
733
+ initialize(options?: SubscriptionManagerOptions): Promise<void>;
734
+ subscribe<T extends boolean = false>(key: string, listener: PubSubListener<T>): Promise<boolean>;
735
+ unsubscribe(key: string): Promise<boolean>;
736
+ isReady(): boolean;
737
+ close(): void;
738
+ }
739
+ //#endregion
740
+ //#region src/validators/statusCodes.d.ts
741
+ declare const isSuccessStatusCode: (status: number | undefined) => boolean;
742
+ declare const isFailedStatusCode: (status: number | undefined) => boolean;
743
+ declare const isInfoStatusCode: (status: number | undefined) => boolean;
744
+ //#endregion
745
+ //#region src/lockManager/types.d.ts
746
+ type Lock = Promise<void>;
747
+ type Unlock = () => void;
748
+ type LockEntry = {
749
+ lock: Lock;
750
+ unlock: Unlock;
751
+ };
752
+ //#endregion
753
+ export { CUSTOM_ERROR_CONFIG_SCHEMA, ConcurrencyManager, CustomErrorConfig, EventClient, HttpClient, HttpClientManager, HttpErrorMessages, HttpHeaders, HttpMethod, HttpMethods, HttpParameters, HttpQueryParams, HttpResponse, HttpResponseError, HttpTransportFactory, ICacheClient, IHttpClient, InstanceManager, Lock, LockEntry, LockManager, MemoryStore, MemoryStoreConfig, PruneCount, PubSubListener, QueueManager, RateLimitManager, RedisClient, RequestClientFactory, RequestParameter, RequestParameterLocations, ScriptManager, SubscriptionManager, Unlock, createAuthorizationHeaders, getTransportInstance, isFailedStatusCode, isInfoStatusCode, isSuccessStatusCode, parseRequestParameters };