elseware-nodejs 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1994,12 +1994,132 @@ declare class ZodValidator implements IValidator {
1994
1994
  validate<T = unknown>(data: unknown): ValidationResult<T>;
1995
1995
  }
1996
1996
 
1997
+ declare class CorrelationId {
1998
+ static generate(): string;
1999
+ }
2000
+
2001
+ interface RequestContextData {
2002
+ correlationId: string;
2003
+ requestId?: string;
2004
+ userId?: string;
2005
+ tenantId?: string;
2006
+ }
2007
+ declare class RequestContext {
2008
+ private static readonly storage;
2009
+ static run<T>(context: RequestContextData, callback: () => T): T;
2010
+ static get(): RequestContextData | undefined;
2011
+ static getCorrelationId(): string | undefined;
2012
+ static getRequestId(): string | undefined;
2013
+ static getUserId(): string | undefined;
2014
+ static getTenantId(): string | undefined;
2015
+ }
2016
+
2017
+ declare class TracingHeaders {
2018
+ static build(): Record<string, string>;
2019
+ }
2020
+
2021
+ interface RetryPolicy {
2022
+ shouldRetry(attempt: number, error?: unknown): boolean;
2023
+ getDelay(attempt: number, error?: unknown): number;
2024
+ }
2025
+
2026
+ interface ExponentialBackoffOptions {
2027
+ retries?: number;
2028
+ baseDelay?: number;
2029
+ maxDelay?: number;
2030
+ }
2031
+ declare class ExponentialBackoffRetryPolicy implements RetryPolicy {
2032
+ private readonly retries;
2033
+ private readonly baseDelay;
2034
+ private readonly maxDelay;
2035
+ constructor(options?: ExponentialBackoffOptions);
2036
+ shouldRetry(attempt: number): boolean;
2037
+ getDelay(attempt: number): number;
2038
+ }
2039
+
2040
+ interface FixedRetryPolicyOptions {
2041
+ retries?: number;
2042
+ delay?: number;
2043
+ }
2044
+ declare class FixedRetryPolicy implements RetryPolicy {
2045
+ private readonly retries;
2046
+ private readonly delay;
2047
+ constructor(options?: FixedRetryPolicyOptions);
2048
+ shouldRetry(attempt: number): boolean;
2049
+ getDelay(_attempt: number, _error?: unknown): number;
2050
+ }
2051
+
2052
+ interface AuthStrategy {
2053
+ getHeaders(): Promise<Record<string, string>>;
2054
+ }
2055
+
2056
+ interface TokenProvider {
2057
+ getToken(): Promise<string> | string;
2058
+ }
2059
+
2060
+ declare class BearerTokenStrategy implements AuthStrategy {
2061
+ private readonly tokenProvider;
2062
+ constructor(tokenProvider: TokenProvider);
2063
+ getHeaders(): Promise<Record<string, string>>;
2064
+ }
2065
+
2066
+ declare class StaticTokenProvider implements TokenProvider {
2067
+ private readonly token;
2068
+ constructor(token: string);
2069
+ getToken(): string;
2070
+ }
2071
+
2072
+ interface HttpClientOptions {
2073
+ timeout?: number;
2074
+ headers?: Record<string, string>;
2075
+ serviceName?: string;
2076
+ retryPolicy?: RetryPolicy;
2077
+ }
2078
+
2079
+ declare class HttpClient {
2080
+ protected readonly baseUrl: string;
2081
+ protected readonly timeout: number;
2082
+ protected readonly headers: Record<string, string>;
2083
+ protected readonly serviceName: string;
2084
+ protected readonly authStrategy?: AuthStrategy;
2085
+ protected readonly retryPolicy: RetryPolicy;
2086
+ constructor(baseUrl: string, options?: HttpClientOptions & {
2087
+ authStrategy?: AuthStrategy;
2088
+ });
2089
+ protected get<T>(path: string): Promise<T>;
2090
+ protected post<T>(path: string, body?: unknown): Promise<T>;
2091
+ protected put<T>(path: string, body?: unknown): Promise<T>;
2092
+ protected patch<T>(path: string, body?: unknown): Promise<T>;
2093
+ protected delete<T>(path: string): Promise<T>;
2094
+ private request;
2095
+ private sleep;
2096
+ }
2097
+
2098
+ declare abstract class ServiceClient extends HttpClient {
2099
+ protected getData<T>(path: string): Promise<T>;
2100
+ protected postData<T>(path: string, body?: unknown): Promise<T>;
2101
+ protected putData<T>(path: string, body?: unknown): Promise<T>;
2102
+ protected patchData<T>(path: string, body?: unknown): Promise<T>;
2103
+ protected deleteData<T>(path: string): Promise<T>;
2104
+ }
2105
+
2106
+ declare abstract class InternalServiceClient extends ServiceClient {
2107
+ constructor(baseUrl: string, serviceToken: string, serviceName?: string);
2108
+ }
2109
+
2110
+ interface ServiceResponse<T> {
2111
+ status: string;
2112
+ message?: string;
2113
+ data: T;
2114
+ }
2115
+
1997
2116
  declare class MongoRepository<T> implements Repository<T> {
1998
2117
  protected model: Model<T>;
1999
2118
  constructor(model: Model<T>);
2000
2119
  private buildSelect;
2001
2120
  private applyQueryOptions;
2002
2121
  private toPlain;
2122
+ private toPlainArray;
2003
2123
  /**
2004
2124
  * Create
2005
2125
  */
@@ -2175,4 +2295,4 @@ declare function toMinutes(ms: number): number;
2175
2295
  declare function toHours(ms: number): number;
2176
2296
  declare function sleep(ms: number): Promise<void>;
2177
2297
 
2178
- export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, AsyncHandler, type AsyncRequestHandler, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, 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, FenwickTree, FibNode, FibonacciHeap, type Filter, Graph, HashMap, HashSet, HyperLogLog, type IValidator, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, 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, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, type Select, type SendEmailOptions, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createAllowedOrigins, createCorsOptions, days, errorToString, hours, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
2298
+ export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, 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_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, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, 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 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, days, errorToString, hours, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
package/dist/index.d.ts CHANGED
@@ -1994,12 +1994,132 @@ declare class ZodValidator implements IValidator {
1994
1994
  validate<T = unknown>(data: unknown): ValidationResult<T>;
1995
1995
  }
1996
1996
 
1997
+ declare class CorrelationId {
1998
+ static generate(): string;
1999
+ }
2000
+
2001
+ interface RequestContextData {
2002
+ correlationId: string;
2003
+ requestId?: string;
2004
+ userId?: string;
2005
+ tenantId?: string;
2006
+ }
2007
+ declare class RequestContext {
2008
+ private static readonly storage;
2009
+ static run<T>(context: RequestContextData, callback: () => T): T;
2010
+ static get(): RequestContextData | undefined;
2011
+ static getCorrelationId(): string | undefined;
2012
+ static getRequestId(): string | undefined;
2013
+ static getUserId(): string | undefined;
2014
+ static getTenantId(): string | undefined;
2015
+ }
2016
+
2017
+ declare class TracingHeaders {
2018
+ static build(): Record<string, string>;
2019
+ }
2020
+
2021
+ interface RetryPolicy {
2022
+ shouldRetry(attempt: number, error?: unknown): boolean;
2023
+ getDelay(attempt: number, error?: unknown): number;
2024
+ }
2025
+
2026
+ interface ExponentialBackoffOptions {
2027
+ retries?: number;
2028
+ baseDelay?: number;
2029
+ maxDelay?: number;
2030
+ }
2031
+ declare class ExponentialBackoffRetryPolicy implements RetryPolicy {
2032
+ private readonly retries;
2033
+ private readonly baseDelay;
2034
+ private readonly maxDelay;
2035
+ constructor(options?: ExponentialBackoffOptions);
2036
+ shouldRetry(attempt: number): boolean;
2037
+ getDelay(attempt: number): number;
2038
+ }
2039
+
2040
+ interface FixedRetryPolicyOptions {
2041
+ retries?: number;
2042
+ delay?: number;
2043
+ }
2044
+ declare class FixedRetryPolicy implements RetryPolicy {
2045
+ private readonly retries;
2046
+ private readonly delay;
2047
+ constructor(options?: FixedRetryPolicyOptions);
2048
+ shouldRetry(attempt: number): boolean;
2049
+ getDelay(_attempt: number, _error?: unknown): number;
2050
+ }
2051
+
2052
+ interface AuthStrategy {
2053
+ getHeaders(): Promise<Record<string, string>>;
2054
+ }
2055
+
2056
+ interface TokenProvider {
2057
+ getToken(): Promise<string> | string;
2058
+ }
2059
+
2060
+ declare class BearerTokenStrategy implements AuthStrategy {
2061
+ private readonly tokenProvider;
2062
+ constructor(tokenProvider: TokenProvider);
2063
+ getHeaders(): Promise<Record<string, string>>;
2064
+ }
2065
+
2066
+ declare class StaticTokenProvider implements TokenProvider {
2067
+ private readonly token;
2068
+ constructor(token: string);
2069
+ getToken(): string;
2070
+ }
2071
+
2072
+ interface HttpClientOptions {
2073
+ timeout?: number;
2074
+ headers?: Record<string, string>;
2075
+ serviceName?: string;
2076
+ retryPolicy?: RetryPolicy;
2077
+ }
2078
+
2079
+ declare class HttpClient {
2080
+ protected readonly baseUrl: string;
2081
+ protected readonly timeout: number;
2082
+ protected readonly headers: Record<string, string>;
2083
+ protected readonly serviceName: string;
2084
+ protected readonly authStrategy?: AuthStrategy;
2085
+ protected readonly retryPolicy: RetryPolicy;
2086
+ constructor(baseUrl: string, options?: HttpClientOptions & {
2087
+ authStrategy?: AuthStrategy;
2088
+ });
2089
+ protected get<T>(path: string): Promise<T>;
2090
+ protected post<T>(path: string, body?: unknown): Promise<T>;
2091
+ protected put<T>(path: string, body?: unknown): Promise<T>;
2092
+ protected patch<T>(path: string, body?: unknown): Promise<T>;
2093
+ protected delete<T>(path: string): Promise<T>;
2094
+ private request;
2095
+ private sleep;
2096
+ }
2097
+
2098
+ declare abstract class ServiceClient extends HttpClient {
2099
+ protected getData<T>(path: string): Promise<T>;
2100
+ protected postData<T>(path: string, body?: unknown): Promise<T>;
2101
+ protected putData<T>(path: string, body?: unknown): Promise<T>;
2102
+ protected patchData<T>(path: string, body?: unknown): Promise<T>;
2103
+ protected deleteData<T>(path: string): Promise<T>;
2104
+ }
2105
+
2106
+ declare abstract class InternalServiceClient extends ServiceClient {
2107
+ constructor(baseUrl: string, serviceToken: string, serviceName?: string);
2108
+ }
2109
+
2110
+ interface ServiceResponse<T> {
2111
+ status: string;
2112
+ message?: string;
2113
+ data: T;
2114
+ }
2115
+
1997
2116
  declare class MongoRepository<T> implements Repository<T> {
1998
2117
  protected model: Model<T>;
1999
2118
  constructor(model: Model<T>);
2000
2119
  private buildSelect;
2001
2120
  private applyQueryOptions;
2002
2121
  private toPlain;
2122
+ private toPlainArray;
2003
2123
  /**
2004
2124
  * Create
2005
2125
  */
@@ -2175,4 +2295,4 @@ declare function toMinutes(ms: number): number;
2175
2295
  declare function toHours(ms: number): number;
2176
2296
  declare function sleep(ms: number): Promise<void>;
2177
2297
 
2178
- export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, AsyncHandler, type AsyncRequestHandler, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, 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, FenwickTree, FibNode, FibonacciHeap, type Filter, Graph, HashMap, HashSet, HyperLogLog, type IValidator, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, 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, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, type Select, type SendEmailOptions, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createAllowedOrigins, createCorsOptions, days, errorToString, hours, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
2298
+ export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, 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_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, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, 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 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, days, errorToString, hours, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };