elseware-nodejs 1.11.5 → 1.11.7

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
@@ -8,8 +8,6 @@ import { Schema } from 'joi';
8
8
  import { Model, UpdateQuery } from 'mongoose';
9
9
  import { SignOptions, JwtPayload } from 'jsonwebtoken';
10
10
 
11
- declare const DEFAULT_ALLOWED_ORIGINS: string[];
12
-
13
11
  type InferSchema<TSchema extends ZodTypeAny> = z.infer<TSchema>;
14
12
  interface LoadEnvOptions<TSchema extends ZodTypeAny, TOutput = InferSchema<TSchema>> {
15
13
  schema: TSchema;
@@ -1756,14 +1754,18 @@ declare class SegmentTree<T> {
1756
1754
  private updatePoint;
1757
1755
  }
1758
1756
 
1759
- interface AllowedOriginsOptions {
1760
- origins?: string | string[];
1761
- defaults?: string[];
1757
+ interface CorsOptionsConfig {
1758
+ allowedOrigins: string[];
1759
+ allowCredentials?: boolean;
1760
+ allowedMethods?: string[];
1761
+ allowedHeaders?: string[];
1762
+ exposedHeaders?: string[];
1763
+ optionsSuccessStatus?: number;
1762
1764
  }
1763
1765
 
1764
- declare function createAllowedOrigins(options?: AllowedOriginsOptions): string[];
1766
+ declare function createCorsOptions(config: CorsOptionsConfig): CorsOptions;
1765
1767
 
1766
- declare function createCorsOptions(allowedOrigins: string[]): CorsOptions;
1768
+ declare function isAllowedOrigin(origin: string, allowedOrigins: string[]): boolean;
1767
1769
 
1768
1770
  interface DatabaseProvider {
1769
1771
  connect(): Promise<void>;
@@ -2134,6 +2136,7 @@ declare class HttpClient {
2134
2136
  protected patch<T>(path: string, body?: unknown): Promise<T>;
2135
2137
  protected delete<T>(path: string): Promise<T>;
2136
2138
  private request;
2139
+ private parseResponseBody;
2137
2140
  private sleep;
2138
2141
  }
2139
2142
 
@@ -2337,4 +2340,4 @@ declare function toMinutes(ms: number): number;
2337
2340
  declare function toHours(ms: number): number;
2338
2341
  declare function sleep(ms: number): Promise<void>;
2339
2342
 
2340
- export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, 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, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, DEFAULT_ALLOWED_ORIGINS, 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, createAllowedOrigins, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
2343
+ 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 };
package/dist/index.d.ts CHANGED
@@ -8,8 +8,6 @@ import { Schema } from 'joi';
8
8
  import { Model, UpdateQuery } from 'mongoose';
9
9
  import { SignOptions, JwtPayload } from 'jsonwebtoken';
10
10
 
11
- declare const DEFAULT_ALLOWED_ORIGINS: string[];
12
-
13
11
  type InferSchema<TSchema extends ZodTypeAny> = z.infer<TSchema>;
14
12
  interface LoadEnvOptions<TSchema extends ZodTypeAny, TOutput = InferSchema<TSchema>> {
15
13
  schema: TSchema;
@@ -1756,14 +1754,18 @@ declare class SegmentTree<T> {
1756
1754
  private updatePoint;
1757
1755
  }
1758
1756
 
1759
- interface AllowedOriginsOptions {
1760
- origins?: string | string[];
1761
- defaults?: string[];
1757
+ interface CorsOptionsConfig {
1758
+ allowedOrigins: string[];
1759
+ allowCredentials?: boolean;
1760
+ allowedMethods?: string[];
1761
+ allowedHeaders?: string[];
1762
+ exposedHeaders?: string[];
1763
+ optionsSuccessStatus?: number;
1762
1764
  }
1763
1765
 
1764
- declare function createAllowedOrigins(options?: AllowedOriginsOptions): string[];
1766
+ declare function createCorsOptions(config: CorsOptionsConfig): CorsOptions;
1765
1767
 
1766
- declare function createCorsOptions(allowedOrigins: string[]): CorsOptions;
1768
+ declare function isAllowedOrigin(origin: string, allowedOrigins: string[]): boolean;
1767
1769
 
1768
1770
  interface DatabaseProvider {
1769
1771
  connect(): Promise<void>;
@@ -2134,6 +2136,7 @@ declare class HttpClient {
2134
2136
  protected patch<T>(path: string, body?: unknown): Promise<T>;
2135
2137
  protected delete<T>(path: string): Promise<T>;
2136
2138
  private request;
2139
+ private parseResponseBody;
2137
2140
  private sleep;
2138
2141
  }
2139
2142
 
@@ -2337,4 +2340,4 @@ declare function toMinutes(ms: number): number;
2337
2340
  declare function toHours(ms: number): number;
2338
2341
  declare function sleep(ms: number): Promise<void>;
2339
2342
 
2340
- export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, 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, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, DEFAULT_ALLOWED_ORIGINS, 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, createAllowedOrigins, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
2343
+ 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 };
package/dist/index.js CHANGED
@@ -12,8 +12,7 @@ import juice from 'juice';
12
12
  import jwt from 'jsonwebtoken';
13
13
  import multer from 'multer';
14
14
 
15
- // src/core/constants/defaultOrigins.ts
16
- var DEFAULT_ALLOWED_ORIGINS = ["http://localhost:3000"];
15
+ // src/core/environment/loadEnv.ts
17
16
 
18
17
  // src/utils/errorToString.ts
19
18
  function errorToString(error) {
@@ -1928,6 +1927,7 @@ var CircularQueue = class {
1928
1927
  }
1929
1928
  this.data = new Array(capacity);
1930
1929
  }
1930
+ capacity;
1931
1931
  data;
1932
1932
  head = 0;
1933
1933
  tail = 0;
@@ -4848,41 +4848,52 @@ var SegmentTree = class {
4848
4848
  }
4849
4849
  };
4850
4850
 
4851
- // src/infrastructure/cors/createAllowedOrigins.ts
4852
- function createAllowedOrigins(options = {}) {
4853
- const { origins, defaults = DEFAULT_ALLOWED_ORIGINS } = options;
4854
- let allowedOrigins = [];
4855
- if (typeof origins === "string") {
4856
- allowedOrigins = origins.split(",").map((origin) => origin.trim()).filter(Boolean);
4857
- }
4858
- if (Array.isArray(origins)) {
4859
- allowedOrigins = origins.map((origin) => origin.trim()).filter(Boolean);
4860
- }
4861
- if (allowedOrigins.length === 0) {
4862
- allowedOrigins = [...defaults];
4863
- }
4864
- return allowedOrigins;
4851
+ // src/infrastructure/cors/isAllowedOrigin.ts
4852
+ function isAllowedOrigin(origin, allowedOrigins) {
4853
+ return allowedOrigins.some((allowedOrigin) => {
4854
+ if (allowedOrigin === "*") {
4855
+ return true;
4856
+ }
4857
+ if (allowedOrigin === origin) {
4858
+ return true;
4859
+ }
4860
+ if (allowedOrigin.startsWith("*.") && origin.endsWith(allowedOrigin.slice(1))) {
4861
+ return true;
4862
+ }
4863
+ return false;
4864
+ });
4865
4865
  }
4866
4866
 
4867
4867
  // src/infrastructure/cors/createCorsOptions.ts
4868
- function createCorsOptions(allowedOrigins) {
4868
+ function createCorsOptions(config) {
4869
+ const {
4870
+ allowedOrigins,
4871
+ allowCredentials = true,
4872
+ allowedMethods = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
4873
+ allowedHeaders = [
4874
+ "Content-Type",
4875
+ "Authorization",
4876
+ "X-Requested-With",
4877
+ "Accept"
4878
+ ],
4879
+ exposedHeaders = ["Set-Cookie"],
4880
+ optionsSuccessStatus = 204
4881
+ } = config;
4869
4882
  return {
4870
4883
  origin(origin, callback) {
4871
- if (!origin || allowedOrigins.includes(origin)) {
4884
+ if (!origin) {
4885
+ return callback(null, true);
4886
+ }
4887
+ if (isAllowedOrigin(origin, allowedOrigins)) {
4872
4888
  return callback(null, true);
4873
4889
  }
4874
4890
  return callback(new Error(`CORS blocked: ${origin} is not allowed`));
4875
4891
  },
4876
- credentials: true,
4877
- methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
4878
- allowedHeaders: [
4879
- "Content-Type",
4880
- "Authorization",
4881
- "X-Requested-With",
4882
- "Accept"
4883
- ],
4884
- exposedHeaders: ["Set-Cookie"],
4885
- optionsSuccessStatus: 204
4892
+ credentials: allowCredentials,
4893
+ methods: allowedMethods,
4894
+ allowedHeaders,
4895
+ exposedHeaders,
4896
+ optionsSuccessStatus
4886
4897
  };
4887
4898
  }
4888
4899
 
@@ -4894,6 +4905,8 @@ var DatabaseManager = class {
4894
4905
  this.provider = provider;
4895
4906
  this.options = options;
4896
4907
  }
4908
+ provider;
4909
+ options;
4897
4910
  async connect() {
4898
4911
  try {
4899
4912
  await this.provider.connect();
@@ -4944,6 +4957,7 @@ var MongoDatabaseProvider = class {
4944
4957
  constructor(config) {
4945
4958
  this.config = config;
4946
4959
  }
4960
+ config;
4947
4961
  async connect() {
4948
4962
  mongoose.set("strictQuery", this.config.strictQuery ?? true);
4949
4963
  await mongoose.connect(this.config.uri);
@@ -5358,6 +5372,7 @@ var JoiValidator = class {
5358
5372
  constructor(schema) {
5359
5373
  this.schema = schema;
5360
5374
  }
5375
+ schema;
5361
5376
  validate(data) {
5362
5377
  const result = this.schema.validate(data, {
5363
5378
  abortEarly: false,
@@ -5386,6 +5401,7 @@ var ZodValidator = class {
5386
5401
  constructor(schema) {
5387
5402
  this.schema = schema;
5388
5403
  }
5404
+ schema;
5389
5405
  validate(data) {
5390
5406
  const result = this.schema.safeParse(data);
5391
5407
  if (!result.success) {
@@ -5574,6 +5590,7 @@ var BearerTokenStrategy = class {
5574
5590
  constructor(tokenProvider) {
5575
5591
  this.tokenProvider = tokenProvider;
5576
5592
  }
5593
+ tokenProvider;
5577
5594
  async getHeaders() {
5578
5595
  const token = await this.tokenProvider.getToken();
5579
5596
  return {
@@ -5587,6 +5604,7 @@ var StaticTokenProvider = class {
5587
5604
  constructor(token) {
5588
5605
  this.token = token;
5589
5606
  }
5607
+ token;
5590
5608
  getToken() {
5591
5609
  return this.token;
5592
5610
  }
@@ -5630,9 +5648,9 @@ var HttpClient = class {
5630
5648
  let attempt = 0;
5631
5649
  let lastError;
5632
5650
  while (true) {
5651
+ const controller = new AbortController();
5652
+ const timeout = setTimeout(() => controller.abort(), this.timeout);
5633
5653
  try {
5634
- const controller = new AbortController();
5635
- const timeout = setTimeout(() => controller.abort(), this.timeout);
5636
5654
  const authHeaders = await this.authStrategy?.getHeaders();
5637
5655
  const response = await fetch(`${this.baseUrl}${path2}`, {
5638
5656
  method,
@@ -5646,17 +5664,19 @@ var HttpClient = class {
5646
5664
  body: body !== void 0 ? JSON.stringify(body) : void 0
5647
5665
  });
5648
5666
  clearTimeout(timeout);
5649
- const json = await response.json();
5667
+ const parsedBody = await this.parseResponseBody(response);
5650
5668
  if (!response.ok) {
5669
+ const payload = parsedBody;
5651
5670
  throw new AppError(
5652
- json?.message ?? "HTTP request failed",
5671
+ payload?.message ?? response.statusText ?? "HTTP request failed",
5653
5672
  response.status,
5654
5673
  {
5655
- code: json?.code ?? "HTTP_REQUEST_FAILED",
5674
+ code: payload?.code ?? "HTTP_REQUEST_FAILED",
5656
5675
  details: {
5657
5676
  service: this.serviceName,
5658
5677
  method,
5659
- path: path2
5678
+ path: path2,
5679
+ status: response.status
5660
5680
  }
5661
5681
  }
5662
5682
  );
@@ -5665,8 +5685,9 @@ var HttpClient = class {
5665
5685
  logger.info(
5666
5686
  `[${this.serviceName}]` + (correlationId2 ? ` [${correlationId2}]` : "") + ` ${method} ${path2}`
5667
5687
  );
5668
- return json;
5688
+ return parsedBody;
5669
5689
  } catch (error) {
5690
+ clearTimeout(timeout);
5670
5691
  lastError = error;
5671
5692
  if (this.retryPolicy.shouldRetry(attempt, error)) {
5672
5693
  const delay = this.retryPolicy.getDelay(attempt, error);
@@ -5687,6 +5708,31 @@ var HttpClient = class {
5687
5708
  );
5688
5709
  throw lastError;
5689
5710
  }
5711
+ async parseResponseBody(response) {
5712
+ if (response.status === 204) {
5713
+ return null;
5714
+ }
5715
+ const responseLike = response;
5716
+ const contentType = response.headers?.get?.("content-type") ?? "";
5717
+ if (contentType.includes("application/json") && typeof responseLike.json === "function") {
5718
+ return responseLike.json();
5719
+ }
5720
+ if (typeof responseLike.json === "function") {
5721
+ try {
5722
+ return await responseLike.json();
5723
+ } catch {
5724
+ }
5725
+ }
5726
+ if (typeof responseLike.text === "function") {
5727
+ const text = await responseLike.text();
5728
+ return {
5729
+ message: text || response.statusText || "HTTP request failed"
5730
+ };
5731
+ }
5732
+ return {
5733
+ message: response.statusText || "HTTP request failed"
5734
+ };
5735
+ }
5690
5736
  sleep(ms) {
5691
5737
  return new Promise((resolve) => setTimeout(resolve, ms));
5692
5738
  }
@@ -6320,6 +6366,6 @@ function sleep(ms) {
6320
6366
  return new Promise((resolve) => setTimeout(resolve, ms));
6321
6367
  }
6322
6368
 
6323
- 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_ALLOWED_ORIGINS, 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, createAllowedOrigins, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
6369
+ 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 };
6324
6370
  //# sourceMappingURL=index.js.map
6325
6371
  //# sourceMappingURL=index.js.map