elseware-nodejs 1.11.0 → 1.11.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.
package/dist/index.d.cts CHANGED
@@ -8,36 +8,60 @@ import { Schema } from 'joi';
8
8
  import { Model, UpdateQuery } from 'mongoose';
9
9
  import { SignOptions, JwtPayload } from 'jsonwebtoken';
10
10
 
11
- declare function loadEnv<TSchema extends ZodTypeAny, TTransform = undefined>(options: {
11
+ declare const DEFAULT_ALLOWED_ORIGINS: string[];
12
+
13
+ interface LoadEnvOptions<TSchema extends ZodTypeAny, TTransform = undefined> {
12
14
  schema: TSchema;
13
15
  transform?: (env: infer<TSchema>) => TTransform;
14
- }): TTransform extends undefined ? infer<TSchema> : TTransform;
16
+ }
17
+
18
+ declare function loadEnv<TSchema extends ZodTypeAny, TTransform = undefined>(options: LoadEnvOptions<TSchema, TTransform>): TTransform extends undefined ? infer<TSchema> : TTransform;
19
+
20
+ interface AppErrorOptions {
21
+ code?: string;
22
+ details?: Record<string, unknown>;
23
+ isOperational?: boolean;
24
+ }
25
+ declare class AppError extends Error {
26
+ readonly statusCode: number;
27
+ readonly status: string;
28
+ readonly isOperational: boolean;
29
+ readonly code?: string;
30
+ readonly details?: Record<string, unknown>;
31
+ constructor(message: string, statusCode?: number, options?: AppErrorOptions);
32
+ }
33
+
34
+ declare enum LoggerLevel {
35
+ DEBUG = "DEBUG",
36
+ INFO = "INFO",
37
+ WARN = "WARN",
38
+ ERROR = "ERROR"
39
+ }
15
40
 
16
41
  interface LoggerOptions {
17
- timestamp?: boolean;
18
42
  enabled?: boolean;
43
+ timestamp?: boolean;
44
+ colors?: boolean;
45
+ level?: LoggerLevel;
19
46
  }
47
+
20
48
  declare class Logger {
21
- private timestamp;
22
49
  private enabled;
50
+ private timestamp;
51
+ private colorsEnabled;
52
+ private minimumLevel;
23
53
  configure(options?: LoggerOptions): void;
24
- private format;
25
- private output;
26
- success(msg: string): void;
27
- info(msg: string): void;
28
- warning(msg: string): void;
29
- danger(message: string, error?: unknown): void;
30
- log(msg: string): void;
54
+ private levelWeight;
55
+ private shouldLog;
56
+ private formatLevel;
57
+ private write;
58
+ debug(message: string): void;
59
+ info(message: string): void;
60
+ warn(message: string): void;
61
+ error(message: string, error?: unknown): void;
31
62
  }
32
- declare const logger: Logger;
33
63
 
34
- interface AllowedOriginsOptions {
35
- origins?: string | string[];
36
- defaults?: string[];
37
- }
38
- declare function createAllowedOrigins(options?: AllowedOriginsOptions): string[];
39
-
40
- declare function createCorsOptions(allowedOrigins: string[]): CorsOptions;
64
+ declare const logger: Logger;
41
65
 
42
66
  /**
43
67
  * CircularArray (Ring Buffer)
@@ -1731,6 +1755,15 @@ declare class SegmentTree<T> {
1731
1755
  private updatePoint;
1732
1756
  }
1733
1757
 
1758
+ interface AllowedOriginsOptions {
1759
+ origins?: string | string[];
1760
+ defaults?: string[];
1761
+ }
1762
+
1763
+ declare function createAllowedOrigins(options?: AllowedOriginsOptions): string[];
1764
+
1765
+ declare function createCorsOptions(allowedOrigins: string[]): CorsOptions;
1766
+
1734
1767
  interface DatabaseProvider {
1735
1768
  connect(): Promise<void>;
1736
1769
  disconnect(): Promise<void>;
@@ -1766,18 +1799,6 @@ declare class MongoDatabaseProvider implements DatabaseProvider {
1766
1799
  getConnectionState(): string;
1767
1800
  }
1768
1801
 
1769
- declare class AppError extends Error {
1770
- statusCode: number;
1771
- status: string;
1772
- isOperational: boolean;
1773
- code?: string;
1774
- details?: Record<string, unknown>;
1775
- constructor(message: string, statusCode?: number, options?: {
1776
- code?: string;
1777
- details?: Record<string, unknown>;
1778
- });
1779
- }
1780
-
1781
1802
  type Filter<T> = Partial<Record<keyof T, unknown>>;
1782
1803
  type Field<T> = Extract<keyof T, string>;
1783
1804
  type PrefixedField<T> = `+${Field<T>}` | `-${Field<T>}`;
@@ -2315,4 +2336,4 @@ declare function toMinutes(ms: number): number;
2315
2336
  declare function toHours(ms: number): number;
2316
2337
  declare function sleep(ms: number): Promise<void>;
2317
2338
 
2318
- 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 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 };
2339
+ 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, 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 };
package/dist/index.d.ts CHANGED
@@ -8,36 +8,60 @@ import { Schema } from 'joi';
8
8
  import { Model, UpdateQuery } from 'mongoose';
9
9
  import { SignOptions, JwtPayload } from 'jsonwebtoken';
10
10
 
11
- declare function loadEnv<TSchema extends ZodTypeAny, TTransform = undefined>(options: {
11
+ declare const DEFAULT_ALLOWED_ORIGINS: string[];
12
+
13
+ interface LoadEnvOptions<TSchema extends ZodTypeAny, TTransform = undefined> {
12
14
  schema: TSchema;
13
15
  transform?: (env: infer<TSchema>) => TTransform;
14
- }): TTransform extends undefined ? infer<TSchema> : TTransform;
16
+ }
17
+
18
+ declare function loadEnv<TSchema extends ZodTypeAny, TTransform = undefined>(options: LoadEnvOptions<TSchema, TTransform>): TTransform extends undefined ? infer<TSchema> : TTransform;
19
+
20
+ interface AppErrorOptions {
21
+ code?: string;
22
+ details?: Record<string, unknown>;
23
+ isOperational?: boolean;
24
+ }
25
+ declare class AppError extends Error {
26
+ readonly statusCode: number;
27
+ readonly status: string;
28
+ readonly isOperational: boolean;
29
+ readonly code?: string;
30
+ readonly details?: Record<string, unknown>;
31
+ constructor(message: string, statusCode?: number, options?: AppErrorOptions);
32
+ }
33
+
34
+ declare enum LoggerLevel {
35
+ DEBUG = "DEBUG",
36
+ INFO = "INFO",
37
+ WARN = "WARN",
38
+ ERROR = "ERROR"
39
+ }
15
40
 
16
41
  interface LoggerOptions {
17
- timestamp?: boolean;
18
42
  enabled?: boolean;
43
+ timestamp?: boolean;
44
+ colors?: boolean;
45
+ level?: LoggerLevel;
19
46
  }
47
+
20
48
  declare class Logger {
21
- private timestamp;
22
49
  private enabled;
50
+ private timestamp;
51
+ private colorsEnabled;
52
+ private minimumLevel;
23
53
  configure(options?: LoggerOptions): void;
24
- private format;
25
- private output;
26
- success(msg: string): void;
27
- info(msg: string): void;
28
- warning(msg: string): void;
29
- danger(message: string, error?: unknown): void;
30
- log(msg: string): void;
54
+ private levelWeight;
55
+ private shouldLog;
56
+ private formatLevel;
57
+ private write;
58
+ debug(message: string): void;
59
+ info(message: string): void;
60
+ warn(message: string): void;
61
+ error(message: string, error?: unknown): void;
31
62
  }
32
- declare const logger: Logger;
33
63
 
34
- interface AllowedOriginsOptions {
35
- origins?: string | string[];
36
- defaults?: string[];
37
- }
38
- declare function createAllowedOrigins(options?: AllowedOriginsOptions): string[];
39
-
40
- declare function createCorsOptions(allowedOrigins: string[]): CorsOptions;
64
+ declare const logger: Logger;
41
65
 
42
66
  /**
43
67
  * CircularArray (Ring Buffer)
@@ -1731,6 +1755,15 @@ declare class SegmentTree<T> {
1731
1755
  private updatePoint;
1732
1756
  }
1733
1757
 
1758
+ interface AllowedOriginsOptions {
1759
+ origins?: string | string[];
1760
+ defaults?: string[];
1761
+ }
1762
+
1763
+ declare function createAllowedOrigins(options?: AllowedOriginsOptions): string[];
1764
+
1765
+ declare function createCorsOptions(allowedOrigins: string[]): CorsOptions;
1766
+
1734
1767
  interface DatabaseProvider {
1735
1768
  connect(): Promise<void>;
1736
1769
  disconnect(): Promise<void>;
@@ -1766,18 +1799,6 @@ declare class MongoDatabaseProvider implements DatabaseProvider {
1766
1799
  getConnectionState(): string;
1767
1800
  }
1768
1801
 
1769
- declare class AppError extends Error {
1770
- statusCode: number;
1771
- status: string;
1772
- isOperational: boolean;
1773
- code?: string;
1774
- details?: Record<string, unknown>;
1775
- constructor(message: string, statusCode?: number, options?: {
1776
- code?: string;
1777
- details?: Record<string, unknown>;
1778
- });
1779
- }
1780
-
1781
1802
  type Filter<T> = Partial<Record<keyof T, unknown>>;
1782
1803
  type Field<T> = Extract<keyof T, string>;
1783
1804
  type PrefixedField<T> = `+${Field<T>}` | `-${Field<T>}`;
@@ -2315,4 +2336,4 @@ declare function toMinutes(ms: number): number;
2315
2336
  declare function toHours(ms: number): number;
2316
2337
  declare function sleep(ms: number): Promise<void>;
2317
2338
 
2318
- 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 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 };
2339
+ 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, 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 };