@stackone/transport 2.3.0 → 2.4.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.cjs +190 -0
- package/dist/{index.d.ts → index.d.cts} +32 -24
- package/dist/index.d.mts +32 -24
- package/dist/index.mjs +17 -23
- package/package.json +7 -10
- package/dist/index.js +0 -195
|
@@ -154,6 +154,7 @@ interface ICacheClient<ClientType = unknown> {
|
|
|
154
154
|
publish?(channel: string, message: string): Promise<number | null>;
|
|
155
155
|
getClient?(): ClientType | null;
|
|
156
156
|
deleteData?(key: string): Promise<boolean>;
|
|
157
|
+
close?(): Promise<void> | void;
|
|
157
158
|
}
|
|
158
159
|
type PubSubListener<ReturnsBuffer extends boolean = false> = <T extends (ReturnsBuffer extends true ? Buffer : string)>(message: T, channel: T) => unknown;
|
|
159
160
|
//#endregion
|
|
@@ -365,22 +366,38 @@ interface InterceptorDependencies {
|
|
|
365
366
|
axiosInstance?: AxiosInstance;
|
|
366
367
|
logger?: ILogger;
|
|
367
368
|
context?: RequestContext;
|
|
368
|
-
requestConfig?: RequestConfig
|
|
369
|
+
requestConfig?: RequestConfig;
|
|
369
370
|
concurrencyManager?: ConcurrencyManager;
|
|
370
371
|
rateLimitManager?: RateLimitManager;
|
|
371
372
|
[key: string]: unknown;
|
|
372
373
|
}
|
|
373
|
-
type RequestConfig
|
|
374
|
+
type RequestConfig = {
|
|
374
375
|
rateLimits?: RateLimitConfig;
|
|
375
376
|
concurrency?: ConcurrencyConfig;
|
|
376
377
|
};
|
|
377
378
|
//#endregion
|
|
379
|
+
//#region src/parsers/types.d.ts
|
|
380
|
+
declare const RequestParameterLocations: readonly ["query", "body", "headers"];
|
|
381
|
+
type RequestParameterLocation = (typeof RequestParameterLocations)[number];
|
|
382
|
+
declare const QueryArrayFormats: readonly ["repeat", "brackets", "comma"];
|
|
383
|
+
type QueryArrayFormat = (typeof QueryArrayFormats)[number];
|
|
384
|
+
type RequestParameter = {
|
|
385
|
+
name: string;
|
|
386
|
+
in: RequestParameterLocation;
|
|
387
|
+
value?: unknown;
|
|
388
|
+
arrayFormat?: QueryArrayFormat;
|
|
389
|
+
};
|
|
390
|
+
//#endregion
|
|
378
391
|
//#region src/httpClient/types.d.ts
|
|
379
392
|
type HttpHeaders = {
|
|
380
393
|
[key: string]: string;
|
|
381
394
|
};
|
|
395
|
+
type HttpQueryParamValue = {
|
|
396
|
+
value: string | string[];
|
|
397
|
+
arrayFormat?: QueryArrayFormat;
|
|
398
|
+
};
|
|
382
399
|
type HttpQueryParams = {
|
|
383
|
-
[key: string]: string;
|
|
400
|
+
[key: string]: string | string[] | HttpQueryParamValue;
|
|
384
401
|
};
|
|
385
402
|
declare const HttpMethods: readonly ["get", "post", "put", "delete", "patch"];
|
|
386
403
|
type HttpMethod = (typeof HttpMethods)[number];
|
|
@@ -425,7 +442,7 @@ interface IHttpClient {
|
|
|
425
442
|
payload?: P;
|
|
426
443
|
httpsAgent?: https.Agent;
|
|
427
444
|
httpAgent?: http.Agent;
|
|
428
|
-
requestConfig?: RequestConfig
|
|
445
|
+
requestConfig?: RequestConfig;
|
|
429
446
|
httpsAgentConfig?: https.AgentOptions;
|
|
430
447
|
}): Promise<HttpResponse<T>>;
|
|
431
448
|
get<T>({
|
|
@@ -443,7 +460,7 @@ interface IHttpClient {
|
|
|
443
460
|
maxRedirects?: number;
|
|
444
461
|
cacheTTL?: number;
|
|
445
462
|
context?: RequestContext;
|
|
446
|
-
requestConfig?: RequestConfig
|
|
463
|
+
requestConfig?: RequestConfig;
|
|
447
464
|
}): Promise<HttpResponse<T>>;
|
|
448
465
|
post<P, T>({
|
|
449
466
|
headers,
|
|
@@ -460,7 +477,7 @@ interface IHttpClient {
|
|
|
460
477
|
cacheTTL?: number;
|
|
461
478
|
context?: RequestContext;
|
|
462
479
|
payload?: P;
|
|
463
|
-
requestConfig?: RequestConfig
|
|
480
|
+
requestConfig?: RequestConfig;
|
|
464
481
|
}): Promise<HttpResponse<T>>;
|
|
465
482
|
}
|
|
466
483
|
interface OperationSetting {
|
|
@@ -506,7 +523,7 @@ type TransportFactory = ({
|
|
|
506
523
|
logger?: ILogger;
|
|
507
524
|
redisClientConfig?: RedisClientConfig;
|
|
508
525
|
context?: RequestContext;
|
|
509
|
-
requestConfig?: RequestConfig
|
|
526
|
+
requestConfig?: RequestConfig;
|
|
510
527
|
httpsAgentConfig?: https.AgentOptions;
|
|
511
528
|
}) => Promise<AxiosInstance>;
|
|
512
529
|
//#endregion
|
|
@@ -592,7 +609,7 @@ declare const getTransportInstance: ({
|
|
|
592
609
|
logger?: ILogger;
|
|
593
610
|
redisClientConfig?: RedisClientConfig;
|
|
594
611
|
context?: RequestContext;
|
|
595
|
-
requestConfig?: RequestConfig
|
|
612
|
+
requestConfig?: RequestConfig;
|
|
596
613
|
httpsAgentConfig?: https.AgentOptions;
|
|
597
614
|
}) => Promise<AxiosInstance>;
|
|
598
615
|
//#endregion
|
|
@@ -641,7 +658,7 @@ declare class HttpClient<TError extends Error = Error> implements IHttpClient {
|
|
|
641
658
|
payload?: P;
|
|
642
659
|
httpsAgent?: https.Agent;
|
|
643
660
|
httpAgent?: http.Agent;
|
|
644
|
-
requestConfig?: RequestConfig
|
|
661
|
+
requestConfig?: RequestConfig;
|
|
645
662
|
httpsAgentConfig?: https.AgentOptions;
|
|
646
663
|
}): Promise<HttpResponse<T>>;
|
|
647
664
|
get<T>({
|
|
@@ -661,7 +678,7 @@ declare class HttpClient<TError extends Error = Error> implements IHttpClient {
|
|
|
661
678
|
cacheTTL?: number;
|
|
662
679
|
context?: RequestContext;
|
|
663
680
|
traceId?: string;
|
|
664
|
-
requestConfig?: RequestConfig
|
|
681
|
+
requestConfig?: RequestConfig;
|
|
665
682
|
}): Promise<HttpResponse<T>>;
|
|
666
683
|
post<P, T>({
|
|
667
684
|
headers,
|
|
@@ -680,7 +697,7 @@ declare class HttpClient<TError extends Error = Error> implements IHttpClient {
|
|
|
680
697
|
context?: RequestContext;
|
|
681
698
|
traceId?: string;
|
|
682
699
|
payload?: P;
|
|
683
|
-
requestConfig?: RequestConfig
|
|
700
|
+
requestConfig?: RequestConfig;
|
|
684
701
|
}): Promise<HttpResponse<T>>;
|
|
685
702
|
}
|
|
686
703
|
//#endregion
|
|
@@ -723,7 +740,7 @@ type HttpTransportInstanceConfig = {
|
|
|
723
740
|
httpsAgentConfig?: AgentOptions;
|
|
724
741
|
logger?: ILogger;
|
|
725
742
|
context?: RequestContext;
|
|
726
|
-
requestConfig?: RequestConfig
|
|
743
|
+
requestConfig?: RequestConfig;
|
|
727
744
|
concurrencyManager?: ConcurrencyManager;
|
|
728
745
|
rateLimitManager?: RateLimitManager;
|
|
729
746
|
};
|
|
@@ -849,20 +866,11 @@ declare class MemoryStore<T> implements ICacheClient {
|
|
|
849
866
|
}>;
|
|
850
867
|
}
|
|
851
868
|
//#endregion
|
|
852
|
-
//#region src/parsers/types.d.ts
|
|
853
|
-
declare const RequestParameterLocations: readonly ["query", "body", "headers"];
|
|
854
|
-
type RequestParameterLocation = (typeof RequestParameterLocations)[number];
|
|
855
|
-
type RequestParameter = {
|
|
856
|
-
name: string;
|
|
857
|
-
in: RequestParameterLocation;
|
|
858
|
-
value?: unknown;
|
|
859
|
-
};
|
|
860
|
-
//#endregion
|
|
861
869
|
//#region src/parsers/requestParameters.d.ts
|
|
862
870
|
declare const parseRequestParameters: (parameters: RequestParameter[]) => HttpParameters;
|
|
863
871
|
//#endregion
|
|
864
872
|
//#region src/requestClient/types.d.ts
|
|
865
|
-
interface IRequestClient<RequestConfig = RequestConfig
|
|
873
|
+
interface IRequestClient<RequestConfig$1 = RequestConfig> {
|
|
866
874
|
performRequest: ({
|
|
867
875
|
httpClient,
|
|
868
876
|
url,
|
|
@@ -880,7 +888,7 @@ interface IRequestClient<RequestConfig = RequestConfig$1> {
|
|
|
880
888
|
queryParams?: HttpQueryParams;
|
|
881
889
|
body: unknown;
|
|
882
890
|
customErrorConfigs?: CustomErrorConfig[];
|
|
883
|
-
requestConfig?: RequestConfig;
|
|
891
|
+
requestConfig?: RequestConfig$1;
|
|
884
892
|
}) => Promise<HttpResponse>;
|
|
885
893
|
}
|
|
886
894
|
type RequestClientType = 'rest' | 'soap';
|
|
@@ -930,4 +938,4 @@ type LockEntry = {
|
|
|
930
938
|
unlock: Unlock;
|
|
931
939
|
};
|
|
932
940
|
//#endregion
|
|
933
|
-
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 IRequestClient, 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
|
|
941
|
+
export { CUSTOM_ERROR_CONFIG_SCHEMA, type ConcurrencyConfig, ConcurrencyManager, type CustomErrorConfig, type ErrorMappingFn, EventClient, HttpClient, HttpClientManager, HttpErrorMessages, type HttpHeaders, type HttpMethod, HttpMethods, type HttpParameters, type HttpQueryParamValue, type HttpQueryParams, type HttpResponse, HttpResponseError, HttpTransportFactory, type ICacheClient, type IHttpClient, type IRequestClient, type InitializedTransportManagers, InstanceManager, type Lock, type LockEntry, LockManager, MemoryStore, type MemoryStoreConfig, type PruneCount, type PubSubListener, type QueryArrayFormat, QueryArrayFormats, 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.mts
CHANGED
|
@@ -154,6 +154,7 @@ interface ICacheClient<ClientType = unknown> {
|
|
|
154
154
|
publish?(channel: string, message: string): Promise<number | null>;
|
|
155
155
|
getClient?(): ClientType | null;
|
|
156
156
|
deleteData?(key: string): Promise<boolean>;
|
|
157
|
+
close?(): Promise<void> | void;
|
|
157
158
|
}
|
|
158
159
|
type PubSubListener<ReturnsBuffer extends boolean = false> = <T extends (ReturnsBuffer extends true ? Buffer : string)>(message: T, channel: T) => unknown;
|
|
159
160
|
//#endregion
|
|
@@ -365,22 +366,38 @@ interface InterceptorDependencies {
|
|
|
365
366
|
axiosInstance?: AxiosInstance;
|
|
366
367
|
logger?: ILogger;
|
|
367
368
|
context?: RequestContext;
|
|
368
|
-
requestConfig?: RequestConfig
|
|
369
|
+
requestConfig?: RequestConfig;
|
|
369
370
|
concurrencyManager?: ConcurrencyManager;
|
|
370
371
|
rateLimitManager?: RateLimitManager;
|
|
371
372
|
[key: string]: unknown;
|
|
372
373
|
}
|
|
373
|
-
type RequestConfig
|
|
374
|
+
type RequestConfig = {
|
|
374
375
|
rateLimits?: RateLimitConfig;
|
|
375
376
|
concurrency?: ConcurrencyConfig;
|
|
376
377
|
};
|
|
377
378
|
//#endregion
|
|
379
|
+
//#region src/parsers/types.d.ts
|
|
380
|
+
declare const RequestParameterLocations: readonly ["query", "body", "headers"];
|
|
381
|
+
type RequestParameterLocation = (typeof RequestParameterLocations)[number];
|
|
382
|
+
declare const QueryArrayFormats: readonly ["repeat", "brackets", "comma"];
|
|
383
|
+
type QueryArrayFormat = (typeof QueryArrayFormats)[number];
|
|
384
|
+
type RequestParameter = {
|
|
385
|
+
name: string;
|
|
386
|
+
in: RequestParameterLocation;
|
|
387
|
+
value?: unknown;
|
|
388
|
+
arrayFormat?: QueryArrayFormat;
|
|
389
|
+
};
|
|
390
|
+
//#endregion
|
|
378
391
|
//#region src/httpClient/types.d.ts
|
|
379
392
|
type HttpHeaders = {
|
|
380
393
|
[key: string]: string;
|
|
381
394
|
};
|
|
395
|
+
type HttpQueryParamValue = {
|
|
396
|
+
value: string | string[];
|
|
397
|
+
arrayFormat?: QueryArrayFormat;
|
|
398
|
+
};
|
|
382
399
|
type HttpQueryParams = {
|
|
383
|
-
[key: string]: string;
|
|
400
|
+
[key: string]: string | string[] | HttpQueryParamValue;
|
|
384
401
|
};
|
|
385
402
|
declare const HttpMethods: readonly ["get", "post", "put", "delete", "patch"];
|
|
386
403
|
type HttpMethod = (typeof HttpMethods)[number];
|
|
@@ -425,7 +442,7 @@ interface IHttpClient {
|
|
|
425
442
|
payload?: P;
|
|
426
443
|
httpsAgent?: https.Agent;
|
|
427
444
|
httpAgent?: http.Agent;
|
|
428
|
-
requestConfig?: RequestConfig
|
|
445
|
+
requestConfig?: RequestConfig;
|
|
429
446
|
httpsAgentConfig?: https.AgentOptions;
|
|
430
447
|
}): Promise<HttpResponse<T>>;
|
|
431
448
|
get<T>({
|
|
@@ -443,7 +460,7 @@ interface IHttpClient {
|
|
|
443
460
|
maxRedirects?: number;
|
|
444
461
|
cacheTTL?: number;
|
|
445
462
|
context?: RequestContext;
|
|
446
|
-
requestConfig?: RequestConfig
|
|
463
|
+
requestConfig?: RequestConfig;
|
|
447
464
|
}): Promise<HttpResponse<T>>;
|
|
448
465
|
post<P, T>({
|
|
449
466
|
headers,
|
|
@@ -460,7 +477,7 @@ interface IHttpClient {
|
|
|
460
477
|
cacheTTL?: number;
|
|
461
478
|
context?: RequestContext;
|
|
462
479
|
payload?: P;
|
|
463
|
-
requestConfig?: RequestConfig
|
|
480
|
+
requestConfig?: RequestConfig;
|
|
464
481
|
}): Promise<HttpResponse<T>>;
|
|
465
482
|
}
|
|
466
483
|
interface OperationSetting {
|
|
@@ -506,7 +523,7 @@ type TransportFactory = ({
|
|
|
506
523
|
logger?: ILogger;
|
|
507
524
|
redisClientConfig?: RedisClientConfig;
|
|
508
525
|
context?: RequestContext;
|
|
509
|
-
requestConfig?: RequestConfig
|
|
526
|
+
requestConfig?: RequestConfig;
|
|
510
527
|
httpsAgentConfig?: https.AgentOptions;
|
|
511
528
|
}) => Promise<AxiosInstance>;
|
|
512
529
|
//#endregion
|
|
@@ -592,7 +609,7 @@ declare const getTransportInstance: ({
|
|
|
592
609
|
logger?: ILogger;
|
|
593
610
|
redisClientConfig?: RedisClientConfig;
|
|
594
611
|
context?: RequestContext;
|
|
595
|
-
requestConfig?: RequestConfig
|
|
612
|
+
requestConfig?: RequestConfig;
|
|
596
613
|
httpsAgentConfig?: https.AgentOptions;
|
|
597
614
|
}) => Promise<AxiosInstance>;
|
|
598
615
|
//#endregion
|
|
@@ -641,7 +658,7 @@ declare class HttpClient<TError extends Error = Error> implements IHttpClient {
|
|
|
641
658
|
payload?: P;
|
|
642
659
|
httpsAgent?: https.Agent;
|
|
643
660
|
httpAgent?: http.Agent;
|
|
644
|
-
requestConfig?: RequestConfig
|
|
661
|
+
requestConfig?: RequestConfig;
|
|
645
662
|
httpsAgentConfig?: https.AgentOptions;
|
|
646
663
|
}): Promise<HttpResponse<T>>;
|
|
647
664
|
get<T>({
|
|
@@ -661,7 +678,7 @@ declare class HttpClient<TError extends Error = Error> implements IHttpClient {
|
|
|
661
678
|
cacheTTL?: number;
|
|
662
679
|
context?: RequestContext;
|
|
663
680
|
traceId?: string;
|
|
664
|
-
requestConfig?: RequestConfig
|
|
681
|
+
requestConfig?: RequestConfig;
|
|
665
682
|
}): Promise<HttpResponse<T>>;
|
|
666
683
|
post<P, T>({
|
|
667
684
|
headers,
|
|
@@ -680,7 +697,7 @@ declare class HttpClient<TError extends Error = Error> implements IHttpClient {
|
|
|
680
697
|
context?: RequestContext;
|
|
681
698
|
traceId?: string;
|
|
682
699
|
payload?: P;
|
|
683
|
-
requestConfig?: RequestConfig
|
|
700
|
+
requestConfig?: RequestConfig;
|
|
684
701
|
}): Promise<HttpResponse<T>>;
|
|
685
702
|
}
|
|
686
703
|
//#endregion
|
|
@@ -723,7 +740,7 @@ type HttpTransportInstanceConfig = {
|
|
|
723
740
|
httpsAgentConfig?: AgentOptions;
|
|
724
741
|
logger?: ILogger;
|
|
725
742
|
context?: RequestContext;
|
|
726
|
-
requestConfig?: RequestConfig
|
|
743
|
+
requestConfig?: RequestConfig;
|
|
727
744
|
concurrencyManager?: ConcurrencyManager;
|
|
728
745
|
rateLimitManager?: RateLimitManager;
|
|
729
746
|
};
|
|
@@ -849,20 +866,11 @@ declare class MemoryStore<T> implements ICacheClient {
|
|
|
849
866
|
}>;
|
|
850
867
|
}
|
|
851
868
|
//#endregion
|
|
852
|
-
//#region src/parsers/types.d.ts
|
|
853
|
-
declare const RequestParameterLocations: readonly ["query", "body", "headers"];
|
|
854
|
-
type RequestParameterLocation = (typeof RequestParameterLocations)[number];
|
|
855
|
-
type RequestParameter = {
|
|
856
|
-
name: string;
|
|
857
|
-
in: RequestParameterLocation;
|
|
858
|
-
value?: unknown;
|
|
859
|
-
};
|
|
860
|
-
//#endregion
|
|
861
869
|
//#region src/parsers/requestParameters.d.ts
|
|
862
870
|
declare const parseRequestParameters: (parameters: RequestParameter[]) => HttpParameters;
|
|
863
871
|
//#endregion
|
|
864
872
|
//#region src/requestClient/types.d.ts
|
|
865
|
-
interface IRequestClient<RequestConfig = RequestConfig
|
|
873
|
+
interface IRequestClient<RequestConfig$1 = RequestConfig> {
|
|
866
874
|
performRequest: ({
|
|
867
875
|
httpClient,
|
|
868
876
|
url,
|
|
@@ -880,7 +888,7 @@ interface IRequestClient<RequestConfig = RequestConfig$1> {
|
|
|
880
888
|
queryParams?: HttpQueryParams;
|
|
881
889
|
body: unknown;
|
|
882
890
|
customErrorConfigs?: CustomErrorConfig[];
|
|
883
|
-
requestConfig?: RequestConfig;
|
|
891
|
+
requestConfig?: RequestConfig$1;
|
|
884
892
|
}) => Promise<HttpResponse>;
|
|
885
893
|
}
|
|
886
894
|
type RequestClientType = 'rest' | 'soap';
|
|
@@ -930,4 +938,4 @@ type LockEntry = {
|
|
|
930
938
|
unlock: Unlock;
|
|
931
939
|
};
|
|
932
940
|
//#endregion
|
|
933
|
-
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 IRequestClient, 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
|
|
941
|
+
export { CUSTOM_ERROR_CONFIG_SCHEMA, type ConcurrencyConfig, ConcurrencyManager, type CustomErrorConfig, type ErrorMappingFn, EventClient, HttpClient, HttpClientManager, HttpErrorMessages, type HttpHeaders, type HttpMethod, HttpMethods, type HttpParameters, type HttpQueryParamValue, type HttpQueryParams, type HttpResponse, HttpResponseError, HttpTransportFactory, type ICacheClient, type IHttpClient, type IRequestClient, type InitializedTransportManagers, InstanceManager, type Lock, type LockEntry, LockManager, MemoryStore, type MemoryStoreConfig, type PruneCount, type PubSubListener, type QueryArrayFormat, QueryArrayFormats, 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 };
|