wsp-ms-core 1.0.76 → 1.0.78-beta
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.cjs +782 -481
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +223 -142
- package/dist/index.d.ts +223 -142
- package/dist/index.js +776 -480
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Pool, RowDataPacket, PoolConnection } from 'mysql2/promise';
|
|
2
1
|
import { RequestHandler, ErrorRequestHandler } from 'express';
|
|
2
|
+
import { Pool, RowDataPacket, PoolConnection } from 'mysql2/promise';
|
|
3
3
|
|
|
4
4
|
declare abstract class ValueObject<TPrimitive = unknown> {
|
|
5
5
|
protected readonly _value: TPrimitive;
|
|
@@ -12,27 +12,14 @@ declare abstract class ValueObject<TPrimitive = unknown> {
|
|
|
12
12
|
equals(vo?: ValueObject<TPrimitive> | null): boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
type UUIDVersion = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
16
|
-
interface UUIDValidationOptions {
|
|
17
|
-
/** Versiones permitidas (por defecto: 1–8) */
|
|
18
|
-
allowedVersions?: UUIDVersion[];
|
|
19
|
-
/** Permitir el NIL UUID "00000000-0000-0000-0000-000000000000" (por defecto: false) */
|
|
20
|
-
allowNil?: boolean;
|
|
21
|
-
}
|
|
22
|
-
declare class UUID extends ValueObject<string> {
|
|
23
|
-
static readonly NIL = "00000000-0000-0000-0000-000000000000";
|
|
24
|
-
private constructor();
|
|
25
|
-
protected validate(uuid: string): void;
|
|
26
|
-
toPrimitives(): Record<string, unknown>;
|
|
27
|
-
static create(uuid?: string): UUID;
|
|
28
|
-
static version(uuid: string): UUIDVersion | undefined;
|
|
29
|
-
static isNil(uuid: string): boolean;
|
|
30
|
-
static isRFCStyle(uuid: string): boolean;
|
|
31
|
-
static isValid(uuid: string, opts?: UUIDValidationOptions): boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
15
|
declare class DateTime extends ValueObject<string> {
|
|
35
16
|
static readonly DEFAULT_FORMAT: string;
|
|
17
|
+
static readonly FORMAT: string;
|
|
18
|
+
static readonly FORMAT_Y_M = "Y-M";
|
|
19
|
+
static readonly FORMAT_Y_M_D = "Y-M-D";
|
|
20
|
+
static readonly FORMAT_Y_M_D_H_m_s = "Y-M-D H:M:S";
|
|
21
|
+
static readonly FORMAT_D_M_Y = "D-M-Y";
|
|
22
|
+
private static readonly FORMATS;
|
|
36
23
|
private readonly _dt;
|
|
37
24
|
private static fromLuxon;
|
|
38
25
|
private static toUtcFormat;
|
|
@@ -58,25 +45,57 @@ declare class DateTime extends ValueObject<string> {
|
|
|
58
45
|
get second(): number;
|
|
59
46
|
getMonthName(locale?: string): string;
|
|
60
47
|
getWeekdayName(locale?: string): string;
|
|
48
|
+
format(format: string): string;
|
|
61
49
|
toPrimitives(): Record<string, unknown>;
|
|
62
50
|
static create(input?: string | number): DateTime;
|
|
63
51
|
static now(): DateTime;
|
|
64
52
|
}
|
|
65
53
|
|
|
66
|
-
declare class
|
|
54
|
+
declare abstract class BaseEvent {
|
|
55
|
+
private readonly _version;
|
|
56
|
+
private readonly _type;
|
|
57
|
+
private readonly _payload;
|
|
58
|
+
private readonly _occurredAt;
|
|
59
|
+
protected constructor(version: string, type: string, payload: Record<string, unknown>);
|
|
60
|
+
get version(): string;
|
|
61
|
+
get type(): string;
|
|
62
|
+
get payload(): Record<string, unknown>;
|
|
63
|
+
get ocurredAt(): DateTime;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type UUIDVersion = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
67
|
+
interface UUIDValidationOptions {
|
|
68
|
+
/** Versiones permitidas (por defecto: 1–8) */
|
|
69
|
+
allowedVersions?: UUIDVersion[];
|
|
70
|
+
/** Permitir el NIL UUID "00000000-0000-0000-0000-000000000000" (por defecto: false) */
|
|
71
|
+
allowNil?: boolean;
|
|
72
|
+
}
|
|
73
|
+
declare class UUID extends ValueObject<string> {
|
|
74
|
+
static readonly NIL = "00000000-0000-0000-0000-000000000000";
|
|
75
|
+
private constructor();
|
|
76
|
+
protected validate(uuid: string): void;
|
|
77
|
+
toPrimitives(): Record<string, unknown>;
|
|
78
|
+
static create(uuid?: string): UUID;
|
|
79
|
+
static version(uuid: string): UUIDVersion | undefined;
|
|
80
|
+
static isNil(uuid: string): boolean;
|
|
81
|
+
static isRFCStyle(uuid: string): boolean;
|
|
82
|
+
static isValid(uuid: string, opts?: UUIDValidationOptions): boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare class ProcessStatus extends ValueObject<string> {
|
|
67
86
|
static readonly SUPPORTED: readonly string[];
|
|
68
|
-
static readonly PENDING:
|
|
69
|
-
static readonly PROCESSING:
|
|
70
|
-
static readonly PROCESSED:
|
|
71
|
-
static readonly FAILED:
|
|
72
|
-
static readonly DEAD:
|
|
87
|
+
static readonly PENDING: ProcessStatus;
|
|
88
|
+
static readonly PROCESSING: ProcessStatus;
|
|
89
|
+
static readonly PROCESSED: ProcessStatus;
|
|
90
|
+
static readonly FAILED: ProcessStatus;
|
|
91
|
+
static readonly DEAD: ProcessStatus;
|
|
73
92
|
private constructor();
|
|
74
93
|
protected validate(value: string): void;
|
|
75
94
|
toPrimitives(): Record<string, unknown>;
|
|
76
|
-
static create(status: string):
|
|
95
|
+
static create(status: string): ProcessStatus;
|
|
77
96
|
}
|
|
78
97
|
|
|
79
|
-
declare class
|
|
98
|
+
declare class OutboxRecord {
|
|
80
99
|
private readonly _eventUuid;
|
|
81
100
|
private readonly _eventType;
|
|
82
101
|
private readonly _tenantUuid;
|
|
@@ -90,7 +109,7 @@ declare class DomainEvent {
|
|
|
90
109
|
private _publishedAt;
|
|
91
110
|
private _lastAttempt;
|
|
92
111
|
private readonly _createdAt;
|
|
93
|
-
protected constructor(eventUuid: UUID, eventType: string, tenantUuid: UUID, aggregateUuid: UUID, aggregateType: string, topic: string, payload: string, status:
|
|
112
|
+
protected constructor(eventUuid: UUID, eventType: string, tenantUuid: UUID, aggregateUuid: UUID, aggregateType: string, topic: string, payload: string, status: ProcessStatus, attempts: number, errorMessage: string | undefined, publishedAt: DateTime | undefined, lastAttempt: DateTime | undefined, createdAt: DateTime);
|
|
94
113
|
get eventUuid(): UUID;
|
|
95
114
|
get tenantUuid(): UUID;
|
|
96
115
|
get aggregateUuid(): UUID;
|
|
@@ -98,7 +117,7 @@ declare class DomainEvent {
|
|
|
98
117
|
get eventType(): string;
|
|
99
118
|
get topic(): string;
|
|
100
119
|
get payload(): string;
|
|
101
|
-
get status():
|
|
120
|
+
get status(): ProcessStatus;
|
|
102
121
|
get attempts(): number;
|
|
103
122
|
get errorMessage(): string | undefined;
|
|
104
123
|
get publishedAt(): DateTime | undefined;
|
|
@@ -109,7 +128,7 @@ declare class DomainEvent {
|
|
|
109
128
|
markProcessing(): void;
|
|
110
129
|
markWithError(error: string): void;
|
|
111
130
|
toPrimitives(): Record<string, unknown>;
|
|
112
|
-
static reconstitute(data: Record<string, any>):
|
|
131
|
+
static reconstitute(data: Record<string, any>): OutboxRecord;
|
|
113
132
|
}
|
|
114
133
|
|
|
115
134
|
interface BaseEntity {
|
|
@@ -120,26 +139,21 @@ interface BaseEntity {
|
|
|
120
139
|
}
|
|
121
140
|
declare abstract class DomainEntity<T extends BaseEntity> {
|
|
122
141
|
protected readonly props: T;
|
|
123
|
-
protected _events:
|
|
142
|
+
protected _events: OutboxRecord[];
|
|
124
143
|
protected constructor(props: T);
|
|
125
|
-
protected recordEvent(event:
|
|
144
|
+
protected recordEvent(event: OutboxRecord): void;
|
|
126
145
|
protected touch(): void;
|
|
127
146
|
get uuid(): UUID;
|
|
128
147
|
get createdAt(): DateTime;
|
|
129
148
|
get updatedAt(): DateTime;
|
|
130
149
|
get deletedAt(): DateTime | undefined;
|
|
131
150
|
get isDeleted(): boolean;
|
|
132
|
-
pullEvents():
|
|
151
|
+
pullEvents(): OutboxRecord[];
|
|
133
152
|
abstract equals(entity?: DomainEntity<T>): boolean;
|
|
134
153
|
abstract toProps(): T;
|
|
135
154
|
abstract toPrimitives(): Record<string, unknown>;
|
|
136
155
|
}
|
|
137
156
|
|
|
138
|
-
declare abstract class DomainError extends Error {
|
|
139
|
-
readonly type: string;
|
|
140
|
-
protected constructor(type: string, message?: string);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
157
|
declare abstract class BaseObject<T = unknown> {
|
|
144
158
|
protected readonly props: T;
|
|
145
159
|
protected constructor(props: T);
|
|
@@ -147,6 +161,11 @@ declare abstract class BaseObject<T = unknown> {
|
|
|
147
161
|
abstract toPrimitives(): Record<string, unknown>;
|
|
148
162
|
}
|
|
149
163
|
|
|
164
|
+
declare abstract class DomainError extends Error {
|
|
165
|
+
readonly type: string;
|
|
166
|
+
protected constructor(type: string, message?: string);
|
|
167
|
+
}
|
|
168
|
+
|
|
150
169
|
declare class FatalError extends DomainError {
|
|
151
170
|
constructor(type: string, message?: string);
|
|
152
171
|
}
|
|
@@ -160,6 +179,102 @@ declare class UsageError extends DomainError {
|
|
|
160
179
|
constructor(type: string, vars?: Record<string, any>);
|
|
161
180
|
}
|
|
162
181
|
|
|
182
|
+
declare class DomainEvent extends BaseEvent {
|
|
183
|
+
protected readonly _aggregateUuid: UUID;
|
|
184
|
+
protected readonly _aggregateType: string;
|
|
185
|
+
protected constructor(version: string, type: string, payload: Record<string, unknown>, aggregateUuid: UUID, aggregateType: string);
|
|
186
|
+
get aggregateUuid(): UUID;
|
|
187
|
+
get aggregateType(): string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare class PaymentGateway extends ValueObject<string> {
|
|
191
|
+
static readonly SUPPORTED: readonly string[];
|
|
192
|
+
private static readonly EXTERNALS;
|
|
193
|
+
static readonly MERCADOPAGO: PaymentGateway;
|
|
194
|
+
static readonly HANDY: PaymentGateway;
|
|
195
|
+
static readonly WONA_DEBIT: PaymentGateway;
|
|
196
|
+
static readonly WONA_CARD: PaymentGateway;
|
|
197
|
+
static readonly WONA_CASH: PaymentGateway;
|
|
198
|
+
static readonly WONA_TRANSFER: PaymentGateway;
|
|
199
|
+
static readonly WONA_MERCADOPAGO: PaymentGateway;
|
|
200
|
+
private constructor();
|
|
201
|
+
protected validate(value: string): void;
|
|
202
|
+
isExternal(): boolean;
|
|
203
|
+
toPrimitives(): Record<string, unknown>;
|
|
204
|
+
static create(gateway: string): PaymentGateway;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declare class PaymentStatus extends ValueObject<string> {
|
|
208
|
+
static readonly SUPPORTED: readonly string[];
|
|
209
|
+
static readonly DONE: PaymentStatus;
|
|
210
|
+
static readonly PENDING: PaymentStatus;
|
|
211
|
+
static readonly IN_PROGRESS: PaymentStatus;
|
|
212
|
+
static readonly FAILED: PaymentStatus;
|
|
213
|
+
static readonly CANCELED: PaymentStatus;
|
|
214
|
+
static readonly HOLD: PaymentStatus;
|
|
215
|
+
static readonly PENDING_REFUND: PaymentStatus;
|
|
216
|
+
static readonly REFUNDED: PaymentStatus;
|
|
217
|
+
private constructor();
|
|
218
|
+
protected validate(status: string): void;
|
|
219
|
+
get isDone(): boolean;
|
|
220
|
+
get isPending(): boolean;
|
|
221
|
+
get isInProgress(): boolean;
|
|
222
|
+
get isFailed(): boolean;
|
|
223
|
+
get isCanceled(): boolean;
|
|
224
|
+
get isHold(): boolean;
|
|
225
|
+
get isPendingRefund(): boolean;
|
|
226
|
+
get isRefunded(): boolean;
|
|
227
|
+
toPrimitives(): Record<string, unknown>;
|
|
228
|
+
static create(gateway: string): PaymentStatus;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
declare class Country extends ValueObject<string> {
|
|
232
|
+
static COUNTRIES: {
|
|
233
|
+
[key: string]: {
|
|
234
|
+
alpha2: string;
|
|
235
|
+
alpha3: string;
|
|
236
|
+
numeric: string;
|
|
237
|
+
uuid: string;
|
|
238
|
+
phoneCode: string;
|
|
239
|
+
url: string;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
private static readonly NAMES;
|
|
243
|
+
static readonly DEFAULT: Country;
|
|
244
|
+
static readonly ARGENTINA: Country;
|
|
245
|
+
static readonly ECUADOR: Country;
|
|
246
|
+
static readonly PERU: Country;
|
|
247
|
+
static readonly BRASIL: Country;
|
|
248
|
+
static readonly CHILE: Country;
|
|
249
|
+
static readonly VENEZUELA: Country;
|
|
250
|
+
static readonly COLOMBIA: Country;
|
|
251
|
+
static readonly BOLIVIA: Country;
|
|
252
|
+
static readonly PARAGUAY: Country;
|
|
253
|
+
static readonly USA: Country;
|
|
254
|
+
private readonly _name;
|
|
255
|
+
private readonly _alpha2;
|
|
256
|
+
private readonly _alpha3;
|
|
257
|
+
private readonly _numeric;
|
|
258
|
+
private readonly _uuid;
|
|
259
|
+
private readonly _phoneCode;
|
|
260
|
+
private readonly _url;
|
|
261
|
+
private constructor();
|
|
262
|
+
protected validate(country: string): void;
|
|
263
|
+
name(): string;
|
|
264
|
+
alpha2(): string;
|
|
265
|
+
alpha3(): string;
|
|
266
|
+
numeric(): string;
|
|
267
|
+
uuid(): string;
|
|
268
|
+
phoneCode(): string;
|
|
269
|
+
url(): string;
|
|
270
|
+
static findCountryByAlpha2(alpha2: string): Country;
|
|
271
|
+
static findCountryByUUID(uuid: string): Country;
|
|
272
|
+
static create(country: string): Country;
|
|
273
|
+
static createOrDefault(country: string): Country;
|
|
274
|
+
toPrimitives(): Record<string, unknown>;
|
|
275
|
+
static isValid(country: string): boolean;
|
|
276
|
+
}
|
|
277
|
+
|
|
163
278
|
declare class Currency extends ValueObject<string> {
|
|
164
279
|
static readonly ALPHA_REGEX: RegExp;
|
|
165
280
|
static readonly NUM_REGEX: RegExp;
|
|
@@ -252,58 +367,18 @@ declare class Price extends ValueObject<PriceProps> {
|
|
|
252
367
|
static createFromPrimitives(data: Record<string, unknown>): Price;
|
|
253
368
|
}
|
|
254
369
|
|
|
255
|
-
declare class PaymentGateway extends ValueObject<string> {
|
|
256
|
-
static readonly SUPPORTED: readonly string[];
|
|
257
|
-
private static readonly EXTERNALS;
|
|
258
|
-
static readonly MERCADOPAGO: PaymentGateway;
|
|
259
|
-
static readonly HANDY: PaymentGateway;
|
|
260
|
-
static readonly WONA_DEBIT: PaymentGateway;
|
|
261
|
-
static readonly WONA_CARD: PaymentGateway;
|
|
262
|
-
static readonly WONA_CASH: PaymentGateway;
|
|
263
|
-
static readonly WONA_TRANSFER: PaymentGateway;
|
|
264
|
-
static readonly WONA_MERCADOPAGO: PaymentGateway;
|
|
265
|
-
private constructor();
|
|
266
|
-
protected validate(value: string): void;
|
|
267
|
-
isExternal(): boolean;
|
|
268
|
-
toPrimitives(): Record<string, unknown>;
|
|
269
|
-
static create(gateway: string): PaymentGateway;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
declare class PaymentStatus extends ValueObject<string> {
|
|
273
|
-
static readonly SUPPORTED: readonly string[];
|
|
274
|
-
static readonly DONE: PaymentStatus;
|
|
275
|
-
static readonly PENDING: PaymentStatus;
|
|
276
|
-
static readonly IN_PROGRESS: PaymentStatus;
|
|
277
|
-
static readonly FAILED: PaymentStatus;
|
|
278
|
-
static readonly CANCELED: PaymentStatus;
|
|
279
|
-
static readonly HOLD: PaymentStatus;
|
|
280
|
-
static readonly PENDING_REFUND: PaymentStatus;
|
|
281
|
-
static readonly REFUNDED: PaymentStatus;
|
|
282
|
-
private constructor();
|
|
283
|
-
protected validate(status: string): void;
|
|
284
|
-
get isDone(): boolean;
|
|
285
|
-
get isPending(): boolean;
|
|
286
|
-
get isInProgress(): boolean;
|
|
287
|
-
get isFailed(): boolean;
|
|
288
|
-
get isCanceled(): boolean;
|
|
289
|
-
get isHold(): boolean;
|
|
290
|
-
get isPendingRefund(): boolean;
|
|
291
|
-
get isRefunded(): boolean;
|
|
292
|
-
toPrimitives(): Record<string, unknown>;
|
|
293
|
-
static create(gateway: string): PaymentStatus;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
370
|
interface EventBusRepository {
|
|
297
|
-
create(event:
|
|
298
|
-
update(event:
|
|
299
|
-
listPending(limit: number): Promise<
|
|
371
|
+
create(event: OutboxRecord): Promise<void>;
|
|
372
|
+
update(event: OutboxRecord): Promise<void>;
|
|
373
|
+
listPending(limit: number): Promise<OutboxRecord[]>;
|
|
300
374
|
}
|
|
301
375
|
|
|
302
|
-
declare class
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
376
|
+
declare class IntegrationEvent extends BaseEvent {
|
|
377
|
+
protected readonly _aggregateUuid: UUID;
|
|
378
|
+
protected readonly _aggregateType: string;
|
|
379
|
+
protected constructor(version: string, type: string, payload: Record<string, unknown>, aggregateUuid: UUID, aggregateType: string);
|
|
380
|
+
get aggregateUuid(): UUID;
|
|
381
|
+
get aggregateType(): string;
|
|
307
382
|
}
|
|
308
383
|
|
|
309
384
|
interface DatabaseConnector<C extends DatabaseConnection = DatabaseConnection> {
|
|
@@ -327,6 +402,16 @@ interface UnitOfWork<C extends DatabaseConnection = DatabaseConnection> {
|
|
|
327
402
|
execute<T>(fn: () => Promise<T>): Promise<T>;
|
|
328
403
|
}
|
|
329
404
|
|
|
405
|
+
type MapperEvent = (event: BaseEvent) => OutboxRecord;
|
|
406
|
+
declare class EventBus {
|
|
407
|
+
private static readonly MAPPERS;
|
|
408
|
+
private readonly repository;
|
|
409
|
+
constructor(repository: EventBusRepository);
|
|
410
|
+
publish(event: BaseEvent): Promise<void>;
|
|
411
|
+
publishMany(events: BaseEvent[]): Promise<void>;
|
|
412
|
+
static addMapper(eventType: string, mapper: MapperEvent): void;
|
|
413
|
+
}
|
|
414
|
+
|
|
330
415
|
declare class BasicUnitOfWork implements UnitOfWork {
|
|
331
416
|
readonly connection: DatabaseConnection;
|
|
332
417
|
constructor(conn: DatabaseConnection);
|
|
@@ -339,21 +424,12 @@ declare class BasicUnitOfWorkFactory {
|
|
|
339
424
|
create(): Promise<BasicUnitOfWork>;
|
|
340
425
|
}
|
|
341
426
|
|
|
342
|
-
interface EventMessage {
|
|
343
|
-
producer?: string;
|
|
344
|
-
eventUuid: string;
|
|
345
|
-
eventType: string;
|
|
346
|
-
tenantUuid: string;
|
|
347
|
-
topic: string;
|
|
348
|
-
payload: Record<string, any>;
|
|
349
|
-
date?: string;
|
|
350
|
-
}
|
|
351
427
|
interface EventManagerConnection {
|
|
352
428
|
userName: string;
|
|
353
429
|
password: string;
|
|
354
430
|
brokers: string[];
|
|
355
431
|
}
|
|
356
|
-
type RouteCallback = (message:
|
|
432
|
+
type RouteCallback = (message: string) => void;
|
|
357
433
|
interface RoutesCallbackList {
|
|
358
434
|
[key: string]: RouteCallback;
|
|
359
435
|
}
|
|
@@ -369,9 +445,9 @@ declare abstract class EventManager {
|
|
|
369
445
|
protected _onCrash: CallableFunction | null;
|
|
370
446
|
protected _onReconnect: CallableFunction | null;
|
|
371
447
|
protected constructor(connection: EventManagerConnection);
|
|
372
|
-
protected execRoute(topic: string, message:
|
|
448
|
+
protected execRoute(topic: string, message: string): Promise<void>;
|
|
373
449
|
protected execCallback(callback: CallableFunction | null, data: any): Promise<void>;
|
|
374
|
-
abstract send(message:
|
|
450
|
+
abstract send(topic: string, message: string): void;
|
|
375
451
|
abstract start(): void;
|
|
376
452
|
abstract restart(): void;
|
|
377
453
|
abstract stop(): void;
|
|
@@ -388,14 +464,6 @@ declare abstract class EventManager {
|
|
|
388
464
|
get callbackList(): RoutesCallbackList;
|
|
389
465
|
}
|
|
390
466
|
|
|
391
|
-
interface Logger {
|
|
392
|
-
debug(type: string, message: string, meta?: Record<string, any>): void;
|
|
393
|
-
info(type: string, message: string, meta?: Record<string, any>): void;
|
|
394
|
-
warn(type: string, message: string, meta?: Record<string, any>): void;
|
|
395
|
-
error(type: string, message: string, meta?: Record<string, any>): void;
|
|
396
|
-
fatal(type: string, message: string, meta?: Record<string, any>): void;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
467
|
interface HttpRequest {
|
|
400
468
|
readonly headers: Record<string, string>;
|
|
401
469
|
readonly params: Record<string, string>;
|
|
@@ -421,6 +489,14 @@ interface HttpController {
|
|
|
421
489
|
handle(request: HttpRequest): Promise<HttpResponse>;
|
|
422
490
|
}
|
|
423
491
|
|
|
492
|
+
interface Logger {
|
|
493
|
+
debug(type: string, message: string, meta?: Record<string, any>): void;
|
|
494
|
+
info(type: string, message: string, meta?: Record<string, any>): void;
|
|
495
|
+
warn(type: string, message: string, meta?: Record<string, any>): void;
|
|
496
|
+
error(type: string, message: string, meta?: Record<string, any>): void;
|
|
497
|
+
fatal(type: string, message: string, meta?: Record<string, any>): void;
|
|
498
|
+
}
|
|
499
|
+
|
|
424
500
|
interface ErrorTemplate {
|
|
425
501
|
type: string;
|
|
426
502
|
languages: Record<string, string>;
|
|
@@ -448,27 +524,18 @@ declare class ErrorManager {
|
|
|
448
524
|
static addTemplate(template: ErrorTemplate): void;
|
|
449
525
|
}
|
|
450
526
|
|
|
451
|
-
declare class
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
closePool(): Promise<void>;
|
|
459
|
-
static ping(): Promise<boolean>;
|
|
460
|
-
}
|
|
461
|
-
declare class MysqlConnection implements DatabaseConnection<string, any[], RowDataPacket> {
|
|
462
|
-
private readonly _conn;
|
|
463
|
-
constructor(conn: PoolConnection);
|
|
464
|
-
query<R = RowDataPacket>(statement: string, params?: any[]): Promise<R[]>;
|
|
465
|
-
begin(): Promise<void>;
|
|
466
|
-
commit(): Promise<void>;
|
|
467
|
-
rollback(): Promise<void>;
|
|
468
|
-
transaction<T>(fn: (conn: this) => Promise<T>): Promise<T>;
|
|
469
|
-
close(): Promise<void>;
|
|
527
|
+
declare class EventBusMysqlRepository implements EventBusRepository {
|
|
528
|
+
private readonly connection;
|
|
529
|
+
constructor(connection: DatabaseConnection);
|
|
530
|
+
private eventToRowValues;
|
|
531
|
+
create(event: OutboxRecord): Promise<void>;
|
|
532
|
+
update(event: OutboxRecord): Promise<void>;
|
|
533
|
+
listPending(limit: number): Promise<OutboxRecord[]>;
|
|
470
534
|
}
|
|
471
535
|
|
|
536
|
+
declare function adaptExpressRoute(Controller: new () => HttpController): RequestHandler;
|
|
537
|
+
declare function adaptExpressErrorHandler(errorManager: ErrorManager): ErrorRequestHandler;
|
|
538
|
+
|
|
472
539
|
declare class HttpHealthCheckController implements HttpController {
|
|
473
540
|
handle(request: HttpRequest): Promise<HttpResponse>;
|
|
474
541
|
}
|
|
@@ -476,32 +543,40 @@ declare class HttpNotFoundController implements HttpController {
|
|
|
476
543
|
handle(request: HttpRequest): Promise<HttpResponse>;
|
|
477
544
|
}
|
|
478
545
|
|
|
479
|
-
declare function adaptExpressRoute(Controller: new () => HttpController): RequestHandler;
|
|
480
|
-
declare function adaptExpressErrorHandler(errorManager: ErrorManager): ErrorRequestHandler;
|
|
481
|
-
|
|
482
|
-
declare class EventBusMysqlRepository implements EventBusRepository {
|
|
483
|
-
private readonly connection;
|
|
484
|
-
constructor(connection: DatabaseConnection);
|
|
485
|
-
private eventToRowValues;
|
|
486
|
-
create(event: DomainEvent): Promise<void>;
|
|
487
|
-
update(event: DomainEvent): Promise<void>;
|
|
488
|
-
listPending(limit: number): Promise<DomainEvent[]>;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
546
|
declare class KafkaManager extends EventManager {
|
|
492
547
|
private readonly kafka;
|
|
493
548
|
private readonly consumer;
|
|
494
549
|
private readonly producer;
|
|
495
550
|
constructor(connection: EventManagerConnection);
|
|
496
551
|
private run;
|
|
497
|
-
send(message:
|
|
498
|
-
sendRaw(message: string, topic: string): Promise<void>;
|
|
552
|
+
send(topic: string, message: string): Promise<void>;
|
|
499
553
|
start(autocommit?: boolean): Promise<void>;
|
|
500
554
|
pause(): Promise<void>;
|
|
501
555
|
restart(): Promise<void>;
|
|
502
556
|
stop(): Promise<void>;
|
|
503
557
|
}
|
|
504
558
|
|
|
559
|
+
declare class MysqlConnector implements DatabaseConnector<MysqlConnection> {
|
|
560
|
+
static readonly DEFAULT_POOL_SIZE: number;
|
|
561
|
+
private readonly _pool;
|
|
562
|
+
constructor(pool?: Pool);
|
|
563
|
+
private wrap;
|
|
564
|
+
query(sql: string, params?: any[]): Promise<any[]>;
|
|
565
|
+
getConnection(): Promise<MysqlConnection>;
|
|
566
|
+
closePool(): Promise<void>;
|
|
567
|
+
static ping(): Promise<boolean>;
|
|
568
|
+
}
|
|
569
|
+
declare class MysqlConnection implements DatabaseConnection<string, any[], RowDataPacket> {
|
|
570
|
+
private readonly _conn;
|
|
571
|
+
constructor(conn: PoolConnection);
|
|
572
|
+
query<R = RowDataPacket>(statement: string, params?: any[]): Promise<R[]>;
|
|
573
|
+
begin(): Promise<void>;
|
|
574
|
+
commit(): Promise<void>;
|
|
575
|
+
rollback(): Promise<void>;
|
|
576
|
+
transaction<T>(fn: (conn: this) => Promise<T>): Promise<T>;
|
|
577
|
+
close(): Promise<void>;
|
|
578
|
+
}
|
|
579
|
+
|
|
505
580
|
interface ExchangeRatesProps {
|
|
506
581
|
base: Currency;
|
|
507
582
|
rates: Record<string, number>;
|
|
@@ -520,4 +595,10 @@ declare class ExchangeRates extends BaseObject<ExchangeRatesProps> {
|
|
|
520
595
|
static createFromPrimitives(data: any): ExchangeRates;
|
|
521
596
|
}
|
|
522
597
|
|
|
523
|
-
|
|
598
|
+
declare class StringVars {
|
|
599
|
+
static parse(str: string, ob: {
|
|
600
|
+
[key: string]: any;
|
|
601
|
+
}): string;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export { BaseEntity, BaseEvent, BaseObject, BasicUnitOfWork, BasicUnitOfWorkFactory, Country, Currency, DatabaseConnection, DatabaseConnector, DateTime, DomainEntity, DomainError, DomainEvent, Email, ErrorManager, ErrorManagerHandleResult, ErrorTemplate, EventBus, EventBusMysqlRepository, EventBusRepository, EventManager, EventManagerConnection, ExchangeRates, FatalError, HttpController, HttpHealthCheckController, HttpNotFoundController, HttpRequest, HttpResponse, IntegrationEvent, InternalError, KafkaManager, Language, Logger, MysqlConnection, MysqlConnector, OutboxRecord, PaymentGateway, PaymentStatus, Price, ProcessStatus, RouteCallback, RoutesCallbackList, StringVars, UUID, UnitOfWork, UploadedFile, UsageError, ValueObject, adaptExpressErrorHandler, adaptExpressRoute };
|