elseware-nodejs 1.11.6 → 1.11.8

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.cts CHANGED
@@ -1926,7 +1926,19 @@ interface ParsedQuery {
1926
1926
  populate: string[];
1927
1927
  }
1928
1928
 
1929
+ interface ApiFeaturesConfig {
1930
+ defaultPage: number;
1931
+ defaultLimit: number;
1932
+ maxLimit: number;
1933
+ reservedFields: string[];
1934
+ supportedOperators: string[];
1935
+ }
1936
+ declare const DefaultApiFeaturesConfig: ApiFeaturesConfig;
1937
+
1929
1938
  declare class ApiFeatures {
1939
+ private static config;
1940
+ static configure(config: Partial<ApiFeaturesConfig>): void;
1941
+ static getConfig(): ApiFeaturesConfig;
1930
1942
  static parse(query: Record<string, unknown>): ParsedQuery;
1931
1943
  private static parseFilters;
1932
1944
  private static parseSort;
@@ -1935,12 +1947,6 @@ declare class ApiFeatures {
1935
1947
  private static parsePagination;
1936
1948
  }
1937
1949
 
1938
- declare const QUERY_RESERVED_FIELDS: readonly ["page", "limit", "sort", "fields", "populate"];
1939
- declare const DEFAULT_PAGE = 1;
1940
- declare const DEFAULT_LIMIT = 100;
1941
- declare const DEFAULT_SORT_DIRECTION = "asc";
1942
- declare const SUPPORTED_OPERATORS: readonly ["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin", "contains", "startsWith", "endsWith"];
1943
-
1944
1950
  interface ApiResponseOptions<T = unknown> {
1945
1951
  statusCode?: number;
1946
1952
  success?: boolean;
@@ -2136,6 +2142,7 @@ declare class HttpClient {
2136
2142
  protected patch<T>(path: string, body?: unknown): Promise<T>;
2137
2143
  protected delete<T>(path: string): Promise<T>;
2138
2144
  private request;
2145
+ private parseResponseBody;
2139
2146
  private sleep;
2140
2147
  }
2141
2148
 
@@ -2339,4 +2346,4 @@ declare function toMinutes(ms: number): number;
2339
2346
  declare function toHours(ms: number): number;
2340
2347
  declare function sleep(ms: number): Promise<void>;
2341
2348
 
2342
- export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, type AppErrorOptions, AsyncHandler, type AsyncRequestHandler, type AuthStrategy, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CorrelationId, type CorsOptionsConfig, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, type DatabaseConnectionOptions, DatabaseManager, type DatabaseProvider, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, type ErrorMeta, ErrorMiddleware, type ExponentialBackoffOptions, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, type Filter, FixedRetryPolicy, type FixedRetryPolicyOptions, Graph, HashMap, HashSet, HttpClient, type HttpClientOptions, HyperLogLog, type IValidator, type InferSchema, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, type LoadEnvOptions, Logger, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, type MongoDatabaseConfig, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, type PaginationMeta, type PaginationQuery, PairingHeap, PairingNode, type ParsedQuery, type PickOptions, type Point, type Point2D, PriorityQueue, type ProgressCallback, QUERY_RESERVED_FIELDS, QuadTree, type QueryFilter, type QueryOperator, type QueryOptions, type QuerySort, Queue, RadixTree, type Rect, RedBlackTree, type Repository, RequestContext, type RequestContextData, type RequestContextOptions, type RetryPolicy, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, type Select, type SendEmailOptions, ServiceClient, type ServiceResponse, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, type TokenProvider, TracingHeaders, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isAllowedOrigin, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
2349
+ export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, ApiFeatures, type ApiFeaturesConfig, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, type AppErrorOptions, AsyncHandler, type AsyncRequestHandler, type AuthStrategy, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CorrelationId, type CorsOptionsConfig, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, type DatabaseConnectionOptions, DatabaseManager, type DatabaseProvider, DefaultApiFeaturesConfig, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, type ErrorMeta, ErrorMiddleware, type ExponentialBackoffOptions, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, type Filter, FixedRetryPolicy, type FixedRetryPolicyOptions, Graph, HashMap, HashSet, HttpClient, type HttpClientOptions, HyperLogLog, type IValidator, type InferSchema, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, type LoadEnvOptions, Logger, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, type MongoDatabaseConfig, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, type PaginationMeta, type PaginationQuery, PairingHeap, PairingNode, type ParsedQuery, type PickOptions, type Point, type Point2D, PriorityQueue, type ProgressCallback, QuadTree, type QueryFilter, type QueryOperator, type QueryOptions, type QuerySort, Queue, RadixTree, type Rect, RedBlackTree, type Repository, RequestContext, type RequestContextData, type RequestContextOptions, type RetryPolicy, SMTPProvider, SegmentTree, type Select, type SendEmailOptions, ServiceClient, type ServiceResponse, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, type TokenProvider, TracingHeaders, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isAllowedOrigin, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
package/dist/index.d.ts CHANGED
@@ -1926,7 +1926,19 @@ interface ParsedQuery {
1926
1926
  populate: string[];
1927
1927
  }
1928
1928
 
1929
+ interface ApiFeaturesConfig {
1930
+ defaultPage: number;
1931
+ defaultLimit: number;
1932
+ maxLimit: number;
1933
+ reservedFields: string[];
1934
+ supportedOperators: string[];
1935
+ }
1936
+ declare const DefaultApiFeaturesConfig: ApiFeaturesConfig;
1937
+
1929
1938
  declare class ApiFeatures {
1939
+ private static config;
1940
+ static configure(config: Partial<ApiFeaturesConfig>): void;
1941
+ static getConfig(): ApiFeaturesConfig;
1930
1942
  static parse(query: Record<string, unknown>): ParsedQuery;
1931
1943
  private static parseFilters;
1932
1944
  private static parseSort;
@@ -1935,12 +1947,6 @@ declare class ApiFeatures {
1935
1947
  private static parsePagination;
1936
1948
  }
1937
1949
 
1938
- declare const QUERY_RESERVED_FIELDS: readonly ["page", "limit", "sort", "fields", "populate"];
1939
- declare const DEFAULT_PAGE = 1;
1940
- declare const DEFAULT_LIMIT = 100;
1941
- declare const DEFAULT_SORT_DIRECTION = "asc";
1942
- declare const SUPPORTED_OPERATORS: readonly ["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin", "contains", "startsWith", "endsWith"];
1943
-
1944
1950
  interface ApiResponseOptions<T = unknown> {
1945
1951
  statusCode?: number;
1946
1952
  success?: boolean;
@@ -2136,6 +2142,7 @@ declare class HttpClient {
2136
2142
  protected patch<T>(path: string, body?: unknown): Promise<T>;
2137
2143
  protected delete<T>(path: string): Promise<T>;
2138
2144
  private request;
2145
+ private parseResponseBody;
2139
2146
  private sleep;
2140
2147
  }
2141
2148
 
@@ -2339,4 +2346,4 @@ declare function toMinutes(ms: number): number;
2339
2346
  declare function toHours(ms: number): number;
2340
2347
  declare function sleep(ms: number): Promise<void>;
2341
2348
 
2342
- export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, type AppErrorOptions, AsyncHandler, type AsyncRequestHandler, type AuthStrategy, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CorrelationId, type CorsOptionsConfig, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, type DatabaseConnectionOptions, DatabaseManager, type DatabaseProvider, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, type ErrorMeta, ErrorMiddleware, type ExponentialBackoffOptions, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, type Filter, FixedRetryPolicy, type FixedRetryPolicyOptions, Graph, HashMap, HashSet, HttpClient, type HttpClientOptions, HyperLogLog, type IValidator, type InferSchema, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, type LoadEnvOptions, Logger, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, type MongoDatabaseConfig, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, type PaginationMeta, type PaginationQuery, PairingHeap, PairingNode, type ParsedQuery, type PickOptions, type Point, type Point2D, PriorityQueue, type ProgressCallback, QUERY_RESERVED_FIELDS, QuadTree, type QueryFilter, type QueryOperator, type QueryOptions, type QuerySort, Queue, RadixTree, type Rect, RedBlackTree, type Repository, RequestContext, type RequestContextData, type RequestContextOptions, type RetryPolicy, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, type Select, type SendEmailOptions, ServiceClient, type ServiceResponse, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, type TokenProvider, TracingHeaders, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isAllowedOrigin, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
2349
+ export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, ApiFeatures, type ApiFeaturesConfig, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, type AppErrorOptions, AsyncHandler, type AsyncRequestHandler, type AuthStrategy, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CorrelationId, type CorsOptionsConfig, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, type DatabaseConnectionOptions, DatabaseManager, type DatabaseProvider, DefaultApiFeaturesConfig, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, type ErrorMeta, ErrorMiddleware, type ExponentialBackoffOptions, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, type Filter, FixedRetryPolicy, type FixedRetryPolicyOptions, Graph, HashMap, HashSet, HttpClient, type HttpClientOptions, HyperLogLog, type IValidator, type InferSchema, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, type LoadEnvOptions, Logger, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, type MongoDatabaseConfig, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, type PaginationMeta, type PaginationQuery, PairingHeap, PairingNode, type ParsedQuery, type PickOptions, type Point, type Point2D, PriorityQueue, type ProgressCallback, QuadTree, type QueryFilter, type QueryOperator, type QueryOptions, type QuerySort, Queue, RadixTree, type Rect, RedBlackTree, type Repository, RequestContext, type RequestContextData, type RequestContextOptions, type RetryPolicy, SMTPProvider, SegmentTree, type Select, type SendEmailOptions, ServiceClient, type ServiceResponse, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, type TokenProvider, TracingHeaders, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isAllowedOrigin, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
package/dist/index.js CHANGED
@@ -1927,6 +1927,7 @@ var CircularQueue = class {
1927
1927
  }
1928
1928
  this.data = new Array(capacity);
1929
1929
  }
1930
+ capacity;
1930
1931
  data;
1931
1932
  head = 0;
1932
1933
  tail = 0;
@@ -4904,6 +4905,8 @@ var DatabaseManager = class {
4904
4905
  this.provider = provider;
4905
4906
  this.options = options;
4906
4907
  }
4908
+ provider;
4909
+ options;
4907
4910
  async connect() {
4908
4911
  try {
4909
4912
  await this.provider.connect();
@@ -4954,6 +4957,7 @@ var MongoDatabaseProvider = class {
4954
4957
  constructor(config) {
4955
4958
  this.config = config;
4956
4959
  }
4960
+ config;
4957
4961
  async connect() {
4958
4962
  mongoose.set("strictQuery", this.config.strictQuery ?? true);
4959
4963
  await mongoose.connect(this.config.uri);
@@ -4985,33 +4989,41 @@ var AsyncHandler = (fn) => (req, res, next) => {
4985
4989
  Promise.resolve(fn(req, res, next)).catch(next);
4986
4990
  };
4987
4991
 
4988
- // src/infrastructure/http/query/QueryConstants.ts
4989
- var QUERY_RESERVED_FIELDS = [
4990
- "page",
4991
- "limit",
4992
- "sort",
4993
- "fields",
4994
- "populate"
4995
- ];
4996
- var DEFAULT_PAGE = 1;
4997
- var DEFAULT_LIMIT = 100;
4998
- var DEFAULT_SORT_DIRECTION = "asc";
4999
- var SUPPORTED_OPERATORS = [
5000
- "eq",
5001
- "ne",
5002
- "gt",
5003
- "gte",
5004
- "lt",
5005
- "lte",
5006
- "in",
5007
- "nin",
5008
- "contains",
5009
- "startsWith",
5010
- "endsWith"
5011
- ];
4992
+ // src/infrastructure/http/query/ApiFeaturesConfig.ts
4993
+ var DefaultApiFeaturesConfig = {
4994
+ defaultPage: 1,
4995
+ defaultLimit: 100,
4996
+ maxLimit: 1e3,
4997
+ reservedFields: ["page", "limit", "sort", "fields", "populate"],
4998
+ supportedOperators: [
4999
+ "eq",
5000
+ "ne",
5001
+ "gt",
5002
+ "gte",
5003
+ "lt",
5004
+ "lte",
5005
+ "in",
5006
+ "nin",
5007
+ "contains",
5008
+ "startsWith",
5009
+ "endsWith"
5010
+ ]
5011
+ };
5012
5012
 
5013
5013
  // src/infrastructure/http/query/ApiFeatures.ts
5014
5014
  var ApiFeatures = class {
5015
+ static config = {
5016
+ ...DefaultApiFeaturesConfig
5017
+ };
5018
+ static configure(config) {
5019
+ this.config = {
5020
+ ...this.config,
5021
+ ...config
5022
+ };
5023
+ }
5024
+ static getConfig() {
5025
+ return this.config;
5026
+ }
5015
5027
  static parse(query) {
5016
5028
  return {
5017
5029
  filters: this.parseFilters(query),
@@ -5024,12 +5036,11 @@ var ApiFeatures = class {
5024
5036
  static parseFilters(query) {
5025
5037
  const filters = [];
5026
5038
  Object.entries(query).forEach(([key, value]) => {
5027
- if (QUERY_RESERVED_FIELDS.includes(key)) {
5039
+ if (this.config.reservedFields.includes(key)) {
5028
5040
  return;
5029
5041
  }
5030
- const match = key.match(
5031
- /^(.+)\[(eq|ne|gt|gte|lt|lte|in|nin|contains|startsWith|endsWith)\]$/
5032
- );
5042
+ const operatorsPattern = this.config.supportedOperators.join("|");
5043
+ const match = key.match(new RegExp(`^(.+)\\[(${operatorsPattern})\\]$`));
5033
5044
  if (match) {
5034
5045
  filters.push({
5035
5046
  field: match[1],
@@ -5079,8 +5090,9 @@ var ApiFeatures = class {
5079
5090
  return populate.split(",").map((field) => field.trim()).filter(Boolean);
5080
5091
  }
5081
5092
  static parsePagination(query) {
5082
- const page = Number(query.page) || DEFAULT_PAGE;
5083
- const limit = Number(query.limit) || DEFAULT_LIMIT;
5093
+ const page = Math.max(1, Number(query.page) || this.config.defaultPage);
5094
+ const requestedLimit = Number(query.limit) || this.config.defaultLimit;
5095
+ const limit = Math.min(Math.max(1, requestedLimit), this.config.maxLimit);
5084
5096
  return {
5085
5097
  page,
5086
5098
  limit
@@ -5368,6 +5380,7 @@ var JoiValidator = class {
5368
5380
  constructor(schema) {
5369
5381
  this.schema = schema;
5370
5382
  }
5383
+ schema;
5371
5384
  validate(data) {
5372
5385
  const result = this.schema.validate(data, {
5373
5386
  abortEarly: false,
@@ -5396,6 +5409,7 @@ var ZodValidator = class {
5396
5409
  constructor(schema) {
5397
5410
  this.schema = schema;
5398
5411
  }
5412
+ schema;
5399
5413
  validate(data) {
5400
5414
  const result = this.schema.safeParse(data);
5401
5415
  if (!result.success) {
@@ -5584,6 +5598,7 @@ var BearerTokenStrategy = class {
5584
5598
  constructor(tokenProvider) {
5585
5599
  this.tokenProvider = tokenProvider;
5586
5600
  }
5601
+ tokenProvider;
5587
5602
  async getHeaders() {
5588
5603
  const token = await this.tokenProvider.getToken();
5589
5604
  return {
@@ -5597,6 +5612,7 @@ var StaticTokenProvider = class {
5597
5612
  constructor(token) {
5598
5613
  this.token = token;
5599
5614
  }
5615
+ token;
5600
5616
  getToken() {
5601
5617
  return this.token;
5602
5618
  }
@@ -5640,9 +5656,9 @@ var HttpClient = class {
5640
5656
  let attempt = 0;
5641
5657
  let lastError;
5642
5658
  while (true) {
5659
+ const controller = new AbortController();
5660
+ const timeout = setTimeout(() => controller.abort(), this.timeout);
5643
5661
  try {
5644
- const controller = new AbortController();
5645
- const timeout = setTimeout(() => controller.abort(), this.timeout);
5646
5662
  const authHeaders = await this.authStrategy?.getHeaders();
5647
5663
  const response = await fetch(`${this.baseUrl}${path2}`, {
5648
5664
  method,
@@ -5656,17 +5672,19 @@ var HttpClient = class {
5656
5672
  body: body !== void 0 ? JSON.stringify(body) : void 0
5657
5673
  });
5658
5674
  clearTimeout(timeout);
5659
- const json = await response.json();
5675
+ const parsedBody = await this.parseResponseBody(response);
5660
5676
  if (!response.ok) {
5677
+ const payload = parsedBody;
5661
5678
  throw new AppError(
5662
- json?.message ?? "HTTP request failed",
5679
+ payload?.message ?? response.statusText ?? "HTTP request failed",
5663
5680
  response.status,
5664
5681
  {
5665
- code: json?.code ?? "HTTP_REQUEST_FAILED",
5682
+ code: payload?.code ?? "HTTP_REQUEST_FAILED",
5666
5683
  details: {
5667
5684
  service: this.serviceName,
5668
5685
  method,
5669
- path: path2
5686
+ path: path2,
5687
+ status: response.status
5670
5688
  }
5671
5689
  }
5672
5690
  );
@@ -5675,8 +5693,9 @@ var HttpClient = class {
5675
5693
  logger.info(
5676
5694
  `[${this.serviceName}]` + (correlationId2 ? ` [${correlationId2}]` : "") + ` ${method} ${path2}`
5677
5695
  );
5678
- return json;
5696
+ return parsedBody;
5679
5697
  } catch (error) {
5698
+ clearTimeout(timeout);
5680
5699
  lastError = error;
5681
5700
  if (this.retryPolicy.shouldRetry(attempt, error)) {
5682
5701
  const delay = this.retryPolicy.getDelay(attempt, error);
@@ -5697,6 +5716,31 @@ var HttpClient = class {
5697
5716
  );
5698
5717
  throw lastError;
5699
5718
  }
5719
+ async parseResponseBody(response) {
5720
+ if (response.status === 204) {
5721
+ return null;
5722
+ }
5723
+ const responseLike = response;
5724
+ const contentType = response.headers?.get?.("content-type") ?? "";
5725
+ if (contentType.includes("application/json") && typeof responseLike.json === "function") {
5726
+ return responseLike.json();
5727
+ }
5728
+ if (typeof responseLike.json === "function") {
5729
+ try {
5730
+ return await responseLike.json();
5731
+ } catch {
5732
+ }
5733
+ }
5734
+ if (typeof responseLike.text === "function") {
5735
+ const text = await responseLike.text();
5736
+ return {
5737
+ message: text || response.statusText || "HTTP request failed"
5738
+ };
5739
+ }
5740
+ return {
5741
+ message: response.statusText || "HTTP request failed"
5742
+ };
5743
+ }
5700
5744
  sleep(ms) {
5701
5745
  return new Promise((resolve) => setTimeout(resolve, ms));
5702
5746
  }
@@ -6330,6 +6374,6 @@ function sleep(ms) {
6330
6374
  return new Promise((resolve) => setTimeout(resolve, ms));
6331
6375
  }
6332
6376
 
6333
- export { AVLTree, AdjacencyList, AdjacencyMatrix, ApiFeatures, ApiResponse, AppError, AsyncHandler, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, CloudinaryService, ConsistentHash, CorrelationId, CountMinSketch, CrudControllerFactory, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, DatabaseManager, Deque, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, EmailService, ErrorMiddleware, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, FixedRetryPolicy, Graph, HashMap, HashSet, HttpClient, HyperLogLog, InternalServiceClient, IntervalTree, JWTService, JoiValidator, KDTree, LFUCache, LRUCache, Logger, MaxHeap, MaxStack, MinHeap, MinStack, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, PriorityQueue, QUERY_RESERVED_FIELDS, QuadTree, Queue, RadixTree, RedBlackTree, RequestContext, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, ServiceClient, Set2 as Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TracingHeaders, TreeNode, Trie, ZodValidator, authMiddleware, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isAllowedOrigin, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
6377
+ export { AVLTree, AdjacencyList, AdjacencyMatrix, ApiFeatures, ApiResponse, AppError, AsyncHandler, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, CloudinaryService, ConsistentHash, CorrelationId, CountMinSketch, CrudControllerFactory, DatabaseManager, DefaultApiFeaturesConfig, Deque, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, EmailService, ErrorMiddleware, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, FixedRetryPolicy, Graph, HashMap, HashSet, HttpClient, HyperLogLog, InternalServiceClient, IntervalTree, JWTService, JoiValidator, KDTree, LFUCache, LRUCache, Logger, MaxHeap, MaxStack, MinHeap, MinStack, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, PriorityQueue, QuadTree, Queue, RadixTree, RedBlackTree, RequestContext, SMTPProvider, SegmentTree, ServiceClient, Set2 as Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TracingHeaders, TreeNode, Trie, ZodValidator, authMiddleware, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isAllowedOrigin, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
6334
6378
  //# sourceMappingURL=index.js.map
6335
6379
  //# sourceMappingURL=index.js.map