wsp-ms-core 1.0.7 → 1.0.8-7.5

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 DELETED
@@ -1,301 +0,0 @@
1
- import { RowDataPacket, PoolConnection, Pool } from 'mysql2/promise';
2
- import { RequestHandler, ErrorRequestHandler } from 'express';
3
-
4
- declare abstract class ValueObject<TPrimitive = unknown> {
5
- protected readonly _value: TPrimitive;
6
- protected constructor(value: TPrimitive);
7
- protected abstract validate(value: TPrimitive): void;
8
- get value(): TPrimitive;
9
- toString(): string;
10
- equals(vo?: ValueObject<TPrimitive> | null): boolean;
11
- }
12
-
13
- declare class UUID extends ValueObject<string> {
14
- private constructor();
15
- protected validate(uuid: string): void;
16
- static create(uuid?: string): UUID;
17
- static isValid(uuid: string): boolean;
18
- }
19
-
20
- declare class DateTime extends ValueObject<string> {
21
- static readonly DEFAULT_FORMAT: string;
22
- private readonly _dt;
23
- private static fromLuxon;
24
- private static toUtcFormat;
25
- private constructor();
26
- protected validate(value: string): void;
27
- plusYears(years: number): DateTime;
28
- plusMonths(months: number): DateTime;
29
- plusDays(days: number): DateTime;
30
- plusHours(hours: number): DateTime;
31
- plusMinutes(minutes: number): DateTime;
32
- plusSeconds(seconds: number): DateTime;
33
- minusYears(years: number): DateTime;
34
- minusMonths(months: number): DateTime;
35
- minusDays(days: number): DateTime;
36
- minusHours(hours: number): DateTime;
37
- minusMinutes(minutes: number): DateTime;
38
- minusSeconds(seconds: number): DateTime;
39
- get year(): number;
40
- get month(): number;
41
- get day(): number;
42
- get hour(): number;
43
- get minute(): number;
44
- get second(): number;
45
- getMonthName(locale?: string): string;
46
- getWeekdayName(locale?: string): string;
47
- static create(input?: string | number): DateTime;
48
- }
49
-
50
- declare abstract class DomainEntity<T extends Record<string, string | number | boolean>> {
51
- readonly uuid: UUID;
52
- private readonly _createdAt;
53
- private _updatedAt;
54
- private _deletedAt?;
55
- protected readonly props: T;
56
- protected constructor(uuid: UUID, props: T, audit?: {
57
- createdAt?: DateTime;
58
- updatedAt?: DateTime;
59
- deletedAt?: DateTime;
60
- });
61
- protected touch(): void;
62
- get createdAt(): DateTime;
63
- get updatedAt(): DateTime;
64
- get deletedAt(): DateTime | undefined;
65
- get isDeleted(): boolean;
66
- abstract equals(entity?: DomainEntity<T>): boolean;
67
- softDelete(): void;
68
- abstract toPrimitives(): Record<string, unknown>;
69
- }
70
-
71
- declare abstract class DomainError extends Error {
72
- readonly type: string;
73
- protected constructor(type: string, message?: string);
74
- }
75
-
76
- declare abstract class DomainEvent<T = unknown> {
77
- readonly type: string;
78
- private readonly _occurredAt;
79
- private readonly _payload;
80
- protected constructor(payload: T);
81
- get payload(): T;
82
- get occurredAt(): DateTime;
83
- }
84
-
85
- declare class FatalError extends DomainError {
86
- constructor(type: string, message?: string);
87
- }
88
-
89
- declare class InternalError extends DomainError {
90
- constructor(type: string, message?: string);
91
- }
92
-
93
- declare class UsageError extends DomainError {
94
- readonly vars: Record<string, any>;
95
- constructor(type: string, vars?: Record<string, any>);
96
- }
97
-
98
- declare class Currency extends ValueObject<string> {
99
- static readonly ALPHA_REGEX: RegExp;
100
- static readonly NUM_REGEX: RegExp;
101
- private static readonly ALPHA_TO_NUM;
102
- private static readonly NUM_TO_ALPHA;
103
- static readonly USD: Currency;
104
- static readonly EUR: Currency;
105
- static readonly UYU: Currency;
106
- static readonly ARS: Currency;
107
- static readonly BRL: Currency;
108
- readonly numeric: number;
109
- private constructor();
110
- protected validate(alpha: string): void;
111
- static create(raw: string | number): Currency;
112
- static isValid(raw: string | number): boolean;
113
- }
114
-
115
- declare class Email extends ValueObject<string> {
116
- static readonly REGEX: RegExp;
117
- private constructor();
118
- protected validate(value: string): void;
119
- static create(raw: string): Email;
120
- static isValid(raw: string): boolean;
121
- }
122
-
123
- declare class Language extends ValueObject<string> {
124
- static readonly SUPPORTED: readonly string[];
125
- static readonly DEFAULT: Language;
126
- static readonly ENGLISH: Language;
127
- static readonly ENGLISH_UNITED_STATES: Language;
128
- static readonly ENGLISH_UNITED_KINGDOM: Language;
129
- static readonly ENGLISH_AUSTRALIA: Language;
130
- static readonly ENGLISH_CANADA: Language;
131
- static readonly ENGLISH_NEW_ZEALAND: Language;
132
- static readonly ENGLISH_IRELAND: Language;
133
- static readonly ENGLISH_SOUTH_AFRICA: Language;
134
- static readonly ENGLISH_JAMAICA: Language;
135
- static readonly ENGLISH_BELIZE: Language;
136
- static readonly ENGLISH_TRINIDAD: Language;
137
- static readonly PORTUGUESE_BRAZIL: Language;
138
- static readonly PORTUGUESE_PORTUGAL: Language;
139
- static readonly SPANISH: Language;
140
- static readonly SPANISH_ARGENTINA: Language;
141
- static readonly SPANISH_GUATEMALA: Language;
142
- static readonly SPANISH_COSTA_RICA: Language;
143
- static readonly SPANISH_PANAMA: Language;
144
- static readonly SPANISH_REPUBLICA_DOMINICANA: Language;
145
- static readonly SPANISH_MEXICO: Language;
146
- static readonly SPANISH_VENEZUELA: Language;
147
- static readonly SPANISH_COLOMBIA: Language;
148
- static readonly SPANISH_PERU: Language;
149
- static readonly SPANISH_ECUADOR: Language;
150
- static readonly SPANISH_CHILE: Language;
151
- static readonly SPANISH_URUGUAY: Language;
152
- static readonly SPANISH_PARAGUAY: Language;
153
- static readonly SPANISH_BOLIVIA: Language;
154
- static readonly SPANISH_EL_SALVADOR: Language;
155
- static readonly SPANISH_HONDURAS: Language;
156
- static readonly SPANISH_NICARAGUA: Language;
157
- static readonly SPANISH_PUERTO_RICO: Language;
158
- private constructor();
159
- protected validate(value: string): void;
160
- base(): string;
161
- static create(raw: string): Language;
162
- }
163
-
164
- declare class Price extends ValueObject<{
165
- amount: number;
166
- currency: Currency;
167
- }> {
168
- static readonly MIN_AMOUNT: number;
169
- readonly amount: number;
170
- readonly currency: Currency;
171
- private constructor();
172
- protected validate(props: {
173
- amount: number;
174
- currency: Currency;
175
- }): void;
176
- equals(other?: Price | null): boolean;
177
- private assertSameCurrency;
178
- add(other: Price): Price;
179
- subtract(other: Price): Price;
180
- static create(amount: number, currency: Currency | string | number): Price;
181
- }
182
-
183
- interface EventBus {
184
- publish(event: DomainEvent): Promise<void>;
185
- }
186
-
187
- interface EventBusRepository {
188
- save(event: DomainEvent): Promise<void>;
189
- listPending(limit: number): Promise<DomainEvent[]>;
190
- markProcessed(id: number): Promise<void>;
191
- incrementRetries(id: number): Promise<void>;
192
- }
193
-
194
- interface DatabaseConnection<Q = string, Params = unknown[], Row = Record<string, unknown>> {
195
- query<T = Row>(statement: Q, params?: Params): Promise<T[]>;
196
- begin(): Promise<void>;
197
- commit(): Promise<void>;
198
- rollback(toSavepoint?: string): Promise<void>;
199
- transaction<T>(fn: (conn: this) => Promise<T>): Promise<T>;
200
- close(): Promise<void>;
201
- }
202
-
203
- interface DatabaseConnector<C extends DatabaseConnection = DatabaseConnection> {
204
- getConnection(options?: {
205
- readonly?: boolean;
206
- }): Promise<C>;
207
- closePool(): Promise<void>;
208
- }
209
-
210
- interface Logger {
211
- debug(type: string, message: string, meta?: Record<string, any>): void;
212
- info(type: string, message: string, meta?: Record<string, any>): void;
213
- warn(type: string, message: string, meta?: Record<string, any>): void;
214
- error(type: string, message: string, meta?: Record<string, any>): void;
215
- fatal(type: string, message: string, meta?: Record<string, any>): void;
216
- }
217
-
218
- interface HttpRequest {
219
- readonly headers: Record<string, string>;
220
- readonly params: Record<string, string>;
221
- readonly query: Record<string, string>;
222
- readonly lang: string;
223
- readonly body: any;
224
- readonly files?: Record<string, UploadedFile | UploadedFile[]>;
225
- }
226
- interface HttpResponse {
227
- statusCode: number;
228
- body: any;
229
- }
230
- interface UploadedFile {
231
- fieldName: string;
232
- originalName: string;
233
- encoding: string;
234
- mimetype: string;
235
- buffer: Buffer;
236
- size: number;
237
- }
238
- interface HttpController {
239
- handle(request: HttpRequest): Promise<HttpResponse>;
240
- }
241
-
242
- interface ErrorTemplate {
243
- type: string;
244
- languages: Record<string, string>;
245
- }
246
- type ErrorManagerHandleResult = {
247
- status: number | string;
248
- message: string;
249
- };
250
- declare class ErrorManager {
251
- private readonly logger;
252
- private static readonly DEFAULT_MESSAGES;
253
- static readonly APP_ERRORS: {
254
- readonly UNDEFINED: "UNDEFINED_ERROR";
255
- readonly PROCESS: "PROCESS_ERROR";
256
- readonly DATABASE: "DATABASE_ERROR";
257
- };
258
- private static readonly TEMPLATES;
259
- constructor(logger?: Logger | null);
260
- private getDefaultMessage;
261
- private onFatal;
262
- private onInternal;
263
- private onUsage;
264
- private onUnknown;
265
- handle(err: Error, lang: Language): ErrorManagerHandleResult;
266
- static addTemplate(template: ErrorTemplate): void;
267
- }
268
-
269
- declare class MysqlConnection implements DatabaseConnection<string, any[], RowDataPacket> {
270
- private readonly _conn;
271
- constructor(conn: PoolConnection);
272
- query<R = RowDataPacket>(statement: string, params?: any[]): Promise<R[]>;
273
- begin(): Promise<void>;
274
- commit(): Promise<void>;
275
- rollback(): Promise<void>;
276
- transaction<T>(fn: (conn: this) => Promise<T>): Promise<T>;
277
- close(): Promise<void>;
278
- }
279
-
280
- declare class MysqlConnector implements DatabaseConnector<MysqlConnection> {
281
- static readonly DEFAULT_POOL_SIZE: number;
282
- private readonly _pool;
283
- constructor(pool?: Pool);
284
- private wrap;
285
- getConnection(): Promise<MysqlConnection>;
286
- closePool(): Promise<void>;
287
- static ping(): Promise<boolean>;
288
- }
289
-
290
- declare function adaptExpressRoute(Controller: new () => HttpController): RequestHandler;
291
- declare function adaptExpressErrorHandler(errorManager: ErrorManager): ErrorRequestHandler;
292
-
293
- declare class HttpNotFoundController implements HttpController {
294
- handle(request: HttpRequest): Promise<HttpResponse>;
295
- }
296
-
297
- declare class HttpHealthCheckController implements HttpController {
298
- handle(request: HttpRequest): Promise<HttpResponse>;
299
- }
300
-
301
- export { Currency, DatabaseConnection, DatabaseConnector, DateTime, DomainEntity, DomainError, DomainEvent, Email, ErrorManager, ErrorManagerHandleResult, ErrorTemplate, EventBus, EventBusRepository, FatalError, HttpController, HttpHealthCheckController, HttpNotFoundController, HttpRequest, HttpResponse, InternalError, Language, Logger, MysqlConnection, MysqlConnector, Price, UUID, UploadedFile, UsageError, ValueObject, adaptExpressErrorHandler, adaptExpressRoute };