@exium/core 1.0.0-rc.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/LICENSE.md +21 -0
- package/README.md +140 -0
- package/dist/index.d.mts +1801 -0
- package/dist/index.d.ts +1801 -0
- package/dist/index.js +7247 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7035 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +119 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1801 @@
|
|
|
1
|
+
import { DynamicModule, OnApplicationBootstrap, NestInterceptor, ExecutionContext, CallHandler, ExceptionFilter, ArgumentsHost, OnApplicationShutdown, INestApplication, INestApplicationContext, Type } from '@nestjs/common';
|
|
2
|
+
import { Logger } from 'nestjs-pino';
|
|
3
|
+
import { ConfigService } from '@nestjs/config';
|
|
4
|
+
import * as _mikro_orm_core from '@mikro-orm/core';
|
|
5
|
+
import { EntityManager, EntityClass, AnyEntity, EntitySchema, FilterQuery } from '@mikro-orm/core';
|
|
6
|
+
import { DiscoveryService } from '@nestjs/core';
|
|
7
|
+
import { Observable } from 'rxjs';
|
|
8
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
9
|
+
import Redis from 'ioredis';
|
|
10
|
+
import { Kysely } from 'kysely';
|
|
11
|
+
|
|
12
|
+
interface ExiumApplicationModuleOptions {
|
|
13
|
+
readonly defaults?: {
|
|
14
|
+
readonly cacheStore?: boolean;
|
|
15
|
+
readonly cacheVersionService?: boolean;
|
|
16
|
+
readonly idempotencyStore?: boolean;
|
|
17
|
+
readonly auditWriter?: boolean;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
declare class ExiumApplicationModule {
|
|
21
|
+
static forRoot(options?: ExiumApplicationModuleOptions): DynamicModule;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type FailureKind = 'validation' | 'not_found' | 'business_rule' | 'authentication' | 'authorization' | 'conflict' | 'idempotency' | 'internal';
|
|
25
|
+
interface Failure {
|
|
26
|
+
readonly kind: FailureKind;
|
|
27
|
+
readonly code: string;
|
|
28
|
+
readonly message: string;
|
|
29
|
+
readonly field?: string;
|
|
30
|
+
readonly metadata?: Record<string, unknown>;
|
|
31
|
+
readonly internal?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
declare const Failure: {
|
|
34
|
+
validation(code: string, message: string, options?: {
|
|
35
|
+
field?: string;
|
|
36
|
+
metadata?: Record<string, unknown>;
|
|
37
|
+
internal?: Record<string, unknown>;
|
|
38
|
+
}): Failure;
|
|
39
|
+
notFound(code: string, message: string, metadata?: Record<string, unknown>): Failure;
|
|
40
|
+
businessRule(code: string, message: string, metadata?: Record<string, unknown>): Failure;
|
|
41
|
+
authentication(code: string, message: string, metadata?: Record<string, unknown>): Failure;
|
|
42
|
+
authorization(code: string, message: string, metadata?: Record<string, unknown>): Failure;
|
|
43
|
+
conflict(code: string, message: string, metadata?: Record<string, unknown>): Failure;
|
|
44
|
+
idempotency(code: string, message: string, metadata?: Record<string, unknown>): Failure;
|
|
45
|
+
internal(code: string, message: string, metadata?: Record<string, unknown>): Failure;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
interface SuccessResult$1<T, E = Failure> {
|
|
49
|
+
readonly type: 'success';
|
|
50
|
+
readonly value: T;
|
|
51
|
+
isSuccess(): this is SuccessResult$1<T, E>;
|
|
52
|
+
isFailure(): this is FailureResult<T, E>;
|
|
53
|
+
map<U>(mapper: (value: T) => U): Result<U, E>;
|
|
54
|
+
flatMap<U, E2 = E>(mapper: (value: T) => Result<U, E2>): Result<U, E | E2>;
|
|
55
|
+
mapFailure<E2>(mapper: (error: E) => E2): Result<T, E2>;
|
|
56
|
+
match<U>(handlers: {
|
|
57
|
+
success: (value: T) => U;
|
|
58
|
+
failure: (error: E) => U;
|
|
59
|
+
}): U;
|
|
60
|
+
}
|
|
61
|
+
interface FailureResult<T = never, E = Failure> {
|
|
62
|
+
readonly type: 'failure';
|
|
63
|
+
readonly error: E;
|
|
64
|
+
isSuccess(): this is SuccessResult$1<T, E>;
|
|
65
|
+
isFailure(): this is FailureResult<T, E>;
|
|
66
|
+
map<U>(mapper: (value: T) => U): Result<U, E>;
|
|
67
|
+
flatMap<U, E2 = E>(mapper: (value: T) => Result<U, E2>): Result<U, E | E2>;
|
|
68
|
+
mapFailure<E2>(mapper: (error: E) => E2): Result<T, E2>;
|
|
69
|
+
match<U>(handlers: {
|
|
70
|
+
success: (value: T) => U;
|
|
71
|
+
failure: (error: E) => U;
|
|
72
|
+
}): U;
|
|
73
|
+
}
|
|
74
|
+
type ResultValue<R> = R extends Result<infer T, any> ? T : never;
|
|
75
|
+
type ResultError<R> = R extends Result<any, infer E> ? E : never;
|
|
76
|
+
type ResultRecord = Record<string, Result<any, any>>;
|
|
77
|
+
type CompileValues<T extends ResultRecord> = {
|
|
78
|
+
[K in keyof T]: ResultValue<T[K]>;
|
|
79
|
+
};
|
|
80
|
+
type CompileErrors<T extends ResultRecord> = Array<ResultError<T[keyof T]>>;
|
|
81
|
+
type Result<T, E = Failure> = SuccessResult$1<T, E> | FailureResult<T, E>;
|
|
82
|
+
declare const Result: {
|
|
83
|
+
ok<T>(value: T): Result<T, never>;
|
|
84
|
+
fail<E = Failure>(error: E): Result<never, E>;
|
|
85
|
+
combine<T, E = Failure>(results: readonly Result<T, E>[]): Result<T[], E[]>;
|
|
86
|
+
compile<T extends ResultRecord>(results: T): Result<CompileValues<T>, CompileErrors<T>>;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
type ResultType<T, E = Failure> = Result<T, E>;
|
|
90
|
+
type FailureType = Failure;
|
|
91
|
+
|
|
92
|
+
type ReadonlyDate = Omit<Date, 'setTime' | 'setMilliseconds' | 'setUTCMilliseconds' | 'setSeconds' | 'setUTCSeconds' | 'setMinutes' | 'setUTCMinutes' | 'setHours' | 'setUTCHours' | 'setDate' | 'setUTCDate' | 'setMonth' | 'setUTCMonth' | 'setFullYear' | 'setUTCFullYear'>;
|
|
93
|
+
type DeepReadonly<T> = T extends Date ? ReadonlyDate : T extends readonly (infer Item)[] ? ReadonlyArray<DeepReadonly<Item>> : T extends object ? {
|
|
94
|
+
readonly [Key in keyof T]: DeepReadonly<T[Key]>;
|
|
95
|
+
} : T;
|
|
96
|
+
declare abstract class ValueObject<TProps extends Record<string, unknown>> {
|
|
97
|
+
protected readonly props: DeepReadonly<TProps>;
|
|
98
|
+
protected constructor(props: TProps);
|
|
99
|
+
equals(other?: ValueObject<TProps>): boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type IdStatic<TId extends Id> = {
|
|
103
|
+
readonly prototype: TId;
|
|
104
|
+
readonly name: string;
|
|
105
|
+
};
|
|
106
|
+
declare abstract class Id extends ValueObject<{
|
|
107
|
+
value: string;
|
|
108
|
+
}> {
|
|
109
|
+
protected constructor(value: string);
|
|
110
|
+
protected static newUuid(): string;
|
|
111
|
+
static generate<TId extends Id>(this: IdStatic<TId>): TId;
|
|
112
|
+
static of<TId extends Id>(this: IdStatic<TId>, value: string): TId;
|
|
113
|
+
static parse<TId extends Id>(this: IdStatic<TId>, value: string, options?: {
|
|
114
|
+
field?: string;
|
|
115
|
+
}): ResultType<TId>;
|
|
116
|
+
protected static parseUuid(value: string, options: {
|
|
117
|
+
idType: string;
|
|
118
|
+
field?: string;
|
|
119
|
+
}): ResultType<string>;
|
|
120
|
+
private static create;
|
|
121
|
+
private static isUuidV7;
|
|
122
|
+
get value(): string;
|
|
123
|
+
toString(): string;
|
|
124
|
+
toJSON(): string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare abstract class Entity<TId extends Id> {
|
|
128
|
+
readonly id: TId;
|
|
129
|
+
protected constructor(id: TId);
|
|
130
|
+
equals(other?: Entity<Id> | null): boolean;
|
|
131
|
+
toString(): string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
declare abstract class DomainEvent {
|
|
135
|
+
readonly aggregateId: string;
|
|
136
|
+
readonly eventId: string;
|
|
137
|
+
readonly occurredAt: Date;
|
|
138
|
+
abstract readonly name: string;
|
|
139
|
+
protected constructor(aggregateId: string);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
declare abstract class AggregateRoot<TId extends Id> extends Entity<TId> {
|
|
143
|
+
private domainEvents;
|
|
144
|
+
protected raise(event: DomainEvent): void;
|
|
145
|
+
pullDomainEvents(): DomainEvent[];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Marker base class for domain services.
|
|
150
|
+
*
|
|
151
|
+
* Domain services contain business logic that does not naturally belong
|
|
152
|
+
* to a single entity or aggregate — typically operations that coordinate
|
|
153
|
+
* between multiple domain objects.
|
|
154
|
+
*
|
|
155
|
+
* Rules:
|
|
156
|
+
* - Stateless: no mutable instance state
|
|
157
|
+
* - Pure: no infrastructure dependencies, no I/O
|
|
158
|
+
* - No framework imports: do not use @Injectable() or any NestJS decorator
|
|
159
|
+
*
|
|
160
|
+
* Registration:
|
|
161
|
+
* Domain services are registered as plain providers in NestJS modules.
|
|
162
|
+
* Since they have no injected dependencies, @Injectable() is not needed.
|
|
163
|
+
*
|
|
164
|
+
* @Module({ providers: [MoneyTransferService] })
|
|
165
|
+
*/
|
|
166
|
+
declare abstract class DomainService {
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
declare abstract class Specification<T> {
|
|
170
|
+
abstract isSatisfiedBy(candidate: T): boolean;
|
|
171
|
+
and(other: Specification<T>): Specification<T>;
|
|
172
|
+
or(other: Specification<T>): Specification<T>;
|
|
173
|
+
not(): Specification<T>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface Repository<TAggregate extends AggregateRoot<TId>, TId extends Id> {
|
|
177
|
+
findById(id: TId): Promise<TAggregate | null>;
|
|
178
|
+
findByIds(ids: readonly TId[]): Promise<TAggregate[]>;
|
|
179
|
+
exists(id: TId): Promise<boolean>;
|
|
180
|
+
save(aggregate: TAggregate): Promise<void>;
|
|
181
|
+
delete(id: TId): Promise<void>;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface Auditable$1 {
|
|
185
|
+
createdAt: Date;
|
|
186
|
+
updatedAt: Date;
|
|
187
|
+
}
|
|
188
|
+
declare function isAuditable(obj: any): obj is Auditable$1;
|
|
189
|
+
|
|
190
|
+
interface Versionable {
|
|
191
|
+
version: number;
|
|
192
|
+
}
|
|
193
|
+
declare function isVersionable(obj: any): obj is Versionable;
|
|
194
|
+
|
|
195
|
+
declare abstract class UnitOfWork {
|
|
196
|
+
abstract execute<T>(work: () => Promise<T>): Promise<T>;
|
|
197
|
+
abstract registerAggregate(aggregate: AggregateRoot<any>): void;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
declare abstract class Command<TResult = void> {
|
|
201
|
+
readonly __resultType?: TResult;
|
|
202
|
+
}
|
|
203
|
+
type CommandResultOf<TCommand extends Command<any>> = TCommand extends Command<infer TResult> ? TResult : never;
|
|
204
|
+
|
|
205
|
+
declare abstract class CommandHandler<TCommand extends Command<any>> {
|
|
206
|
+
abstract handle(command: TCommand): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
interface CommandMiddleware {
|
|
210
|
+
use<TCommand extends Command<any>>(command: TCommand, next: () => Promise<ResultType<CommandResultOf<TCommand>>>): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
type CommandConstructor<TCommand extends Command<any>> = new (...args: any[]) => TCommand;
|
|
214
|
+
declare class CommandRegistry {
|
|
215
|
+
private readonly handlers;
|
|
216
|
+
private readonly middlewares;
|
|
217
|
+
register<TCommand extends Command<any>>(commandType: CommandConstructor<TCommand>, handler: CommandHandler<TCommand>): void;
|
|
218
|
+
registerMiddleware(middleware: CommandMiddleware, priority?: number): void;
|
|
219
|
+
resolve<TCommand extends Command<any>>(command: TCommand): CommandHandler<TCommand>;
|
|
220
|
+
getMiddlewares(): CommandMiddleware[];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare class CommandExecutor {
|
|
224
|
+
private readonly registry;
|
|
225
|
+
constructor(registry: CommandRegistry);
|
|
226
|
+
execute<TCommand extends Command<any>>(command: TCommand): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
declare abstract class Query<TResult = unknown> {
|
|
230
|
+
readonly __resultType?: TResult;
|
|
231
|
+
}
|
|
232
|
+
type QueryResultOf<TQuery extends Query<any>> = TQuery extends Query<infer TResult> ? TResult : never;
|
|
233
|
+
|
|
234
|
+
declare abstract class QueryResult {
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
declare abstract class QueryHandler<TQuery extends Query<any>> {
|
|
238
|
+
abstract handle(query: TQuery): Promise<ResultType<QueryResultOf<TQuery>>>;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
interface QueryMiddleware {
|
|
242
|
+
use<TQuery extends Query<any>>(query: TQuery, next: () => Promise<ResultType<QueryResultOf<TQuery>>>): Promise<ResultType<QueryResultOf<TQuery>>>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
type QueryConstructor<TQuery extends Query<any>> = new (...args: any[]) => TQuery;
|
|
246
|
+
declare class QueryRegistry {
|
|
247
|
+
private readonly handlers;
|
|
248
|
+
private readonly middlewares;
|
|
249
|
+
register<TQuery extends Query<any>>(queryType: QueryConstructor<TQuery>, handler: QueryHandler<TQuery>): void;
|
|
250
|
+
registerMiddleware(middleware: QueryMiddleware, priority?: number): void;
|
|
251
|
+
resolve<TQuery extends Query<any>>(query: TQuery): QueryHandler<TQuery>;
|
|
252
|
+
getMiddlewares(): QueryMiddleware[];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
declare class QueryExecutor {
|
|
256
|
+
private readonly registry;
|
|
257
|
+
constructor(registry: QueryRegistry);
|
|
258
|
+
execute<TQuery extends Query<any>>(query: TQuery): Promise<ResultType<QueryResultOf<TQuery>>>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
declare abstract class EventHandler<TEvent extends DomainEvent> {
|
|
262
|
+
abstract handle(event: TEvent): Promise<void>;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
type EventConstructor<TEvent extends DomainEvent> = new (...args: any[]) => TEvent;
|
|
266
|
+
declare class EventRegistry {
|
|
267
|
+
private readonly handlers;
|
|
268
|
+
register<TEvent extends DomainEvent>(eventType: EventConstructor<TEvent>, handler: EventHandler<TEvent>): void;
|
|
269
|
+
resolve<TEvent extends DomainEvent>(event: TEvent): EventHandler<TEvent>[];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
declare class EventBus {
|
|
273
|
+
private readonly registry;
|
|
274
|
+
constructor(registry: EventRegistry);
|
|
275
|
+
publish<TEvent extends DomainEvent>(event: TEvent): Promise<void>;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
declare function HandleCommand<TCommand extends Command<any>>(commandType: new (...args: any[]) => TCommand): ClassDecorator;
|
|
279
|
+
|
|
280
|
+
declare function HandleQuery<TQuery extends Query<any>>(queryType: new (...args: any[]) => TQuery): ClassDecorator;
|
|
281
|
+
|
|
282
|
+
declare function HandleEvent<TEvent extends DomainEvent>(eventType: new (...args: any[]) => TEvent): ClassDecorator;
|
|
283
|
+
|
|
284
|
+
interface MiddlewareOptions {
|
|
285
|
+
priority?: number;
|
|
286
|
+
}
|
|
287
|
+
declare function RegisterCommandMiddleware(options?: MiddlewareOptions): ClassDecorator;
|
|
288
|
+
declare function RegisterQueryMiddleware(options?: MiddlewareOptions): ClassDecorator;
|
|
289
|
+
|
|
290
|
+
declare const TRANSACTIONAL_METADATA: unique symbol;
|
|
291
|
+
interface TransactionalOptions {
|
|
292
|
+
readonly enabled?: boolean;
|
|
293
|
+
}
|
|
294
|
+
declare function Transactional(options?: TransactionalOptions): ClassDecorator;
|
|
295
|
+
declare function NonTransactional(): ClassDecorator;
|
|
296
|
+
|
|
297
|
+
declare const SKIP_VALIDATION_METADATA: unique symbol;
|
|
298
|
+
declare function SkipValidation(): ClassDecorator;
|
|
299
|
+
|
|
300
|
+
declare const AUTHORIZATION_METADATA: unique symbol;
|
|
301
|
+
type AuthorizationRequirementMode = 'all' | 'any';
|
|
302
|
+
interface AuthorizationMetadata {
|
|
303
|
+
readonly allowAnonymous?: boolean;
|
|
304
|
+
readonly permissions?: readonly string[];
|
|
305
|
+
readonly permissionMode?: AuthorizationRequirementMode;
|
|
306
|
+
readonly roles?: readonly string[];
|
|
307
|
+
readonly roleMode?: AuthorizationRequirementMode;
|
|
308
|
+
}
|
|
309
|
+
declare function AllowAnonymous(): ClassDecorator;
|
|
310
|
+
declare function RequirePermission(...permissions: string[]): ClassDecorator;
|
|
311
|
+
declare function RequireAnyPermission(...permissions: string[]): ClassDecorator;
|
|
312
|
+
declare function RequireRole(...roles: string[]): ClassDecorator;
|
|
313
|
+
declare function RequireAnyRole(...roles: string[]): ClassDecorator;
|
|
314
|
+
|
|
315
|
+
declare class HandlerNotFoundException extends Error {
|
|
316
|
+
constructor(name: string);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
declare class DuplicateHandlerException extends Error {
|
|
320
|
+
constructor(type: 'command' | 'query', name: string);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
type AuthorizationFailureReason = 'missing_context' | 'missing_user' | 'missing_permission' | 'missing_role' | 'custom_denied';
|
|
324
|
+
declare class AuthorizationException extends Error {
|
|
325
|
+
readonly operationName: string;
|
|
326
|
+
readonly reason: AuthorizationFailureReason;
|
|
327
|
+
readonly required?: readonly string[] | undefined;
|
|
328
|
+
constructor(operationName: string, reason: AuthorizationFailureReason, required?: readonly string[] | undefined);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
type IdempotencyFailureReason = 'missing_key' | 'in_progress' | 'conflict' | 'store_not_configured';
|
|
332
|
+
interface IdempotencyExceptionDetails {
|
|
333
|
+
readonly scope?: string;
|
|
334
|
+
readonly key?: string;
|
|
335
|
+
readonly existingFingerprint?: string;
|
|
336
|
+
readonly incomingFingerprint?: string;
|
|
337
|
+
}
|
|
338
|
+
declare class IdempotencyException extends Error {
|
|
339
|
+
readonly operationName: string;
|
|
340
|
+
readonly reason: IdempotencyFailureReason;
|
|
341
|
+
readonly details: IdempotencyExceptionDetails;
|
|
342
|
+
constructor(operationName: string, reason: IdempotencyFailureReason, details?: IdempotencyExceptionDetails);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
declare const INTEGRATION_EVENT_MAPPER_METADATA: unique symbol;
|
|
346
|
+
declare function RegisterIntegrationEventMapper(): ClassDecorator;
|
|
347
|
+
|
|
348
|
+
declare abstract class IntegrationEvent {
|
|
349
|
+
readonly id: string;
|
|
350
|
+
readonly name: string;
|
|
351
|
+
readonly version: number;
|
|
352
|
+
readonly occurredAt: Date;
|
|
353
|
+
protected constructor(params: {
|
|
354
|
+
id: string;
|
|
355
|
+
name: string;
|
|
356
|
+
version: number;
|
|
357
|
+
occurredAt?: Date;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
declare abstract class IntegrationEventMapper<TDomainEvent extends DomainEvent = DomainEvent> {
|
|
362
|
+
abstract supports(event: DomainEvent): event is TDomainEvent;
|
|
363
|
+
abstract map(event: TDomainEvent): IntegrationEvent | IntegrationEvent[] | null;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
declare class IntegrationEventRegistry {
|
|
367
|
+
private readonly mappers;
|
|
368
|
+
register(mapper: IntegrationEventMapper): void;
|
|
369
|
+
map(domainEvents: readonly DomainEvent[]): IntegrationEvent[];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
declare abstract class OutboxWriter {
|
|
373
|
+
abstract write(events: readonly IntegrationEvent[]): Promise<void>;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
declare class NoopOutboxWriter extends OutboxWriter {
|
|
377
|
+
write(_events: readonly IntegrationEvent[]): Promise<void>;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
declare const CACHE_QUERY_METADATA: unique symbol;
|
|
381
|
+
interface CacheQueryOptions {
|
|
382
|
+
readonly namespace?: string;
|
|
383
|
+
readonly ttlSeconds?: number;
|
|
384
|
+
readonly versioned?: boolean;
|
|
385
|
+
}
|
|
386
|
+
interface CacheQueryMetadata {
|
|
387
|
+
readonly enabled: boolean;
|
|
388
|
+
readonly namespace?: string;
|
|
389
|
+
readonly ttlSeconds?: number;
|
|
390
|
+
readonly versioned: boolean;
|
|
391
|
+
}
|
|
392
|
+
declare function CacheQuery(options?: CacheQueryOptions): ClassDecorator;
|
|
393
|
+
declare function NonCacheable(): ClassDecorator;
|
|
394
|
+
|
|
395
|
+
declare const INVALIDATE_CACHE_METADATA: unique symbol;
|
|
396
|
+
type CacheInvalidationMode = 'version-bump' | 'delete-prefix' | 'both';
|
|
397
|
+
interface InvalidateCacheOptions {
|
|
398
|
+
readonly namespaces: readonly string[];
|
|
399
|
+
readonly mode?: CacheInvalidationMode;
|
|
400
|
+
/**
|
|
401
|
+
* Default false.
|
|
402
|
+
*
|
|
403
|
+
* Cache invalidation happens after the command succeeds.
|
|
404
|
+
* If invalidation fails after DB commit, failing the command response may be misleading.
|
|
405
|
+
*/
|
|
406
|
+
readonly failOnError?: boolean;
|
|
407
|
+
}
|
|
408
|
+
interface InvalidateCacheMetadata {
|
|
409
|
+
readonly enabled: boolean;
|
|
410
|
+
readonly namespaces: readonly string[];
|
|
411
|
+
readonly mode: CacheInvalidationMode;
|
|
412
|
+
readonly failOnError: boolean;
|
|
413
|
+
}
|
|
414
|
+
declare function InvalidateCache(namespace: string, ...namespaces: string[]): ClassDecorator;
|
|
415
|
+
declare function InvalidateCache(options: InvalidateCacheOptions): ClassDecorator;
|
|
416
|
+
|
|
417
|
+
declare const IDEMPOTENT_METADATA: unique symbol;
|
|
418
|
+
interface IdempotentOptions {
|
|
419
|
+
/**
|
|
420
|
+
* The command property that contains the idempotency key.
|
|
421
|
+
*
|
|
422
|
+
* Default: "idempotencyKey"
|
|
423
|
+
*/
|
|
424
|
+
readonly keyProperty?: string;
|
|
425
|
+
/**
|
|
426
|
+
* Logical idempotency scope.
|
|
427
|
+
*
|
|
428
|
+
* Default: command class name.
|
|
429
|
+
*/
|
|
430
|
+
readonly scope?: string;
|
|
431
|
+
/**
|
|
432
|
+
* How long the idempotency record should live.
|
|
433
|
+
*
|
|
434
|
+
* Default: 24 hours.
|
|
435
|
+
*/
|
|
436
|
+
readonly ttlSeconds?: number;
|
|
437
|
+
/**
|
|
438
|
+
* Protects against reusing the same idempotency key with a different payload.
|
|
439
|
+
*
|
|
440
|
+
* Default: true.
|
|
441
|
+
*/
|
|
442
|
+
readonly fingerprintPayload?: boolean;
|
|
443
|
+
}
|
|
444
|
+
interface IdempotentMetadata {
|
|
445
|
+
readonly enabled: boolean;
|
|
446
|
+
readonly keyProperty: string;
|
|
447
|
+
readonly scope?: string;
|
|
448
|
+
readonly ttlSeconds: number;
|
|
449
|
+
readonly fingerprintPayload: boolean;
|
|
450
|
+
}
|
|
451
|
+
declare function Idempotent(options?: IdempotentOptions): ClassDecorator;
|
|
452
|
+
declare function NonIdempotent(): ClassDecorator;
|
|
453
|
+
|
|
454
|
+
declare const AUDITABLE_METADATA: unique symbol;
|
|
455
|
+
interface AuditableOptions {
|
|
456
|
+
readonly action: string;
|
|
457
|
+
readonly resource?: string;
|
|
458
|
+
/**
|
|
459
|
+
* Optional static resource id.
|
|
460
|
+
*
|
|
461
|
+
* Dynamic resource id extraction can be added later with resourceIdProperty.
|
|
462
|
+
*/
|
|
463
|
+
readonly resourceId?: string;
|
|
464
|
+
/**
|
|
465
|
+
* Optional command/query property path for resource id extraction.
|
|
466
|
+
*
|
|
467
|
+
* Example:
|
|
468
|
+
* resourceIdProperty: "userId"
|
|
469
|
+
* resourceIdProperty: "payload.customerId"
|
|
470
|
+
*/
|
|
471
|
+
readonly resourceIdProperty?: string;
|
|
472
|
+
/**
|
|
473
|
+
* Extra static metadata written to audit event.
|
|
474
|
+
*/
|
|
475
|
+
readonly metadata?: Record<string, unknown>;
|
|
476
|
+
/**
|
|
477
|
+
* Default false.
|
|
478
|
+
*
|
|
479
|
+
* If audit write fails, command/query result should usually not fail.
|
|
480
|
+
*/
|
|
481
|
+
readonly failOnError?: boolean;
|
|
482
|
+
}
|
|
483
|
+
interface AuditableMetadata {
|
|
484
|
+
readonly enabled: boolean;
|
|
485
|
+
readonly action: string;
|
|
486
|
+
readonly resource?: string;
|
|
487
|
+
readonly resourceId?: string;
|
|
488
|
+
readonly resourceIdProperty?: string;
|
|
489
|
+
readonly metadata?: Record<string, unknown>;
|
|
490
|
+
readonly failOnError: boolean;
|
|
491
|
+
}
|
|
492
|
+
declare function Auditable(options: AuditableOptions): ClassDecorator;
|
|
493
|
+
declare function NonAuditable(): ClassDecorator;
|
|
494
|
+
|
|
495
|
+
declare const ApplicationMiddlewarePriority: {
|
|
496
|
+
readonly Context: 1000;
|
|
497
|
+
readonly Logging: 900;
|
|
498
|
+
readonly Validation: 800;
|
|
499
|
+
readonly Authorization: 700;
|
|
500
|
+
readonly Idempotency: 600;
|
|
501
|
+
/**
|
|
502
|
+
* Runs outside/around transaction middleware.
|
|
503
|
+
* Its "after next()" section executes after transactional command has committed.
|
|
504
|
+
*/
|
|
505
|
+
readonly CacheInvalidation: 550;
|
|
506
|
+
readonly Audit: 525;
|
|
507
|
+
readonly Transaction: 500;
|
|
508
|
+
readonly Cache: 400;
|
|
509
|
+
readonly Metrics: 100;
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
interface ApplicationValidationErrorItem {
|
|
513
|
+
readonly property: string;
|
|
514
|
+
readonly constraints: Record<string, string>;
|
|
515
|
+
readonly children?: ApplicationValidationErrorItem[];
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
type ExiumOperationType = 'command' | 'query' | 'event' | 'http' | 'job' | 'unknown';
|
|
519
|
+
interface ExiumExecutionContext {
|
|
520
|
+
readonly correlationId: string;
|
|
521
|
+
readonly causationId?: string;
|
|
522
|
+
readonly requestId?: string;
|
|
523
|
+
readonly tenantId?: string;
|
|
524
|
+
readonly userId?: string;
|
|
525
|
+
readonly roles?: readonly string[];
|
|
526
|
+
readonly permissions?: readonly string[];
|
|
527
|
+
readonly locale?: string;
|
|
528
|
+
readonly source?: string;
|
|
529
|
+
readonly operationType?: ExiumOperationType;
|
|
530
|
+
readonly operationName?: string;
|
|
531
|
+
readonly startedAt: Date;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
declare class ExiumContextService {
|
|
535
|
+
private readonly storage;
|
|
536
|
+
run<T>(context: Partial<ExiumExecutionContext>, callback: () => Promise<T> | T): Promise<T> | T;
|
|
537
|
+
get(): ExiumExecutionContext;
|
|
538
|
+
getOrUndefined(): ExiumExecutionContext | undefined;
|
|
539
|
+
getCorrelationId(): string | undefined;
|
|
540
|
+
getTenantId(): string | undefined;
|
|
541
|
+
getUserId(): string | undefined;
|
|
542
|
+
withOperation<T>(operationType: ExiumOperationType, operationName: string, callback: () => Promise<T> | T): Promise<T> | T;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
declare class ContextCommandMiddleware implements CommandMiddleware {
|
|
546
|
+
private readonly contextService;
|
|
547
|
+
constructor(contextService: ExiumContextService);
|
|
548
|
+
use<TCommand extends Command<any>>(command: TCommand, next: () => Promise<ResultType<CommandResultOf<TCommand>>>): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
declare class ContextQueryMiddleware implements QueryMiddleware {
|
|
552
|
+
private readonly contextService;
|
|
553
|
+
constructor(contextService: ExiumContextService);
|
|
554
|
+
use<TQuery extends Query<any>>(query: TQuery, next: () => Promise<ResultType<QueryResultOf<TQuery>>>): Promise<ResultType<QueryResultOf<TQuery>>>;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
declare class LoggingCommandMiddleware implements CommandMiddleware {
|
|
558
|
+
private readonly logger;
|
|
559
|
+
private readonly contextService;
|
|
560
|
+
constructor(logger: Logger, contextService: ExiumContextService);
|
|
561
|
+
use<TCommand extends Command<any>>(command: TCommand, next: () => Promise<ResultType<CommandResultOf<TCommand>>>): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
declare class LoggingQueryMiddleware implements QueryMiddleware {
|
|
565
|
+
private readonly logger;
|
|
566
|
+
private readonly contextService;
|
|
567
|
+
constructor(logger: Logger, contextService: ExiumContextService);
|
|
568
|
+
use<TQuery extends Query<any>>(query: TQuery, next: () => Promise<ResultType<QueryResultOf<TQuery>>>): Promise<ResultType<QueryResultOf<TQuery>>>;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
declare class ValidationCommandMiddleware implements CommandMiddleware {
|
|
572
|
+
use<TCommand extends Command<any>>(command: TCommand, next: () => Promise<ResultType<CommandResultOf<TCommand>>>): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
declare class ValidationQueryMiddleware implements QueryMiddleware {
|
|
576
|
+
use<TQuery extends Query<any>>(query: TQuery, next: () => Promise<ResultType<QueryResultOf<TQuery>>>): Promise<ResultType<QueryResultOf<TQuery>>>;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
interface PermissionCheckInput {
|
|
580
|
+
readonly context: ExiumExecutionContext;
|
|
581
|
+
readonly operationName: string;
|
|
582
|
+
readonly permissions?: readonly string[];
|
|
583
|
+
readonly permissionMode?: 'all' | 'any';
|
|
584
|
+
readonly roles?: readonly string[];
|
|
585
|
+
readonly roleMode?: 'all' | 'any';
|
|
586
|
+
}
|
|
587
|
+
interface PermissionCheckResult {
|
|
588
|
+
readonly allowed: boolean;
|
|
589
|
+
readonly reason?: string;
|
|
590
|
+
}
|
|
591
|
+
declare abstract class PermissionChecker {
|
|
592
|
+
abstract check(input: PermissionCheckInput): Promise<PermissionCheckResult>;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
declare class AuthorizationCommandMiddleware implements CommandMiddleware {
|
|
596
|
+
private readonly contextService;
|
|
597
|
+
private readonly permissionChecker;
|
|
598
|
+
constructor(contextService: ExiumContextService, permissionChecker: PermissionChecker);
|
|
599
|
+
use<TCommand extends Command<any>>(command: TCommand, next: () => Promise<ResultType<CommandResultOf<TCommand>>>): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
declare class AuthorizationQueryMiddleware implements QueryMiddleware {
|
|
603
|
+
private readonly contextService;
|
|
604
|
+
private readonly permissionChecker;
|
|
605
|
+
constructor(contextService: ExiumContextService, permissionChecker: PermissionChecker);
|
|
606
|
+
use<TQuery extends Query<any>>(query: TQuery, next: () => Promise<ResultType<QueryResultOf<TQuery>>>): Promise<ResultType<QueryResultOf<TQuery>>>;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
interface CacheGetResult<T> {
|
|
610
|
+
readonly hit: boolean;
|
|
611
|
+
readonly value?: T;
|
|
612
|
+
}
|
|
613
|
+
interface CacheSetOptions {
|
|
614
|
+
readonly ttlSeconds?: number;
|
|
615
|
+
}
|
|
616
|
+
declare abstract class CacheStore {
|
|
617
|
+
abstract get<T>(key: string): Promise<CacheGetResult<T>>;
|
|
618
|
+
abstract set<T>(key: string, value: T, options?: CacheSetOptions): Promise<void>;
|
|
619
|
+
abstract delete(key: string): Promise<void>;
|
|
620
|
+
abstract deleteByPrefix(prefix: string): Promise<void>;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
declare class NoopCacheStore extends CacheStore {
|
|
624
|
+
get<T>(_key: string): Promise<CacheGetResult<T>>;
|
|
625
|
+
set<T>(_key: string, _value: T, _options?: CacheSetOptions): Promise<void>;
|
|
626
|
+
delete(_key: string): Promise<void>;
|
|
627
|
+
deleteByPrefix(_prefix: string): Promise<void>;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
interface CacheKeyFactoryInput {
|
|
631
|
+
readonly namespace: string;
|
|
632
|
+
readonly queryName: string;
|
|
633
|
+
readonly version: string | number;
|
|
634
|
+
readonly payload: unknown;
|
|
635
|
+
}
|
|
636
|
+
interface CacheKeyPrefixInput {
|
|
637
|
+
readonly namespace: string;
|
|
638
|
+
readonly version?: string | number;
|
|
639
|
+
readonly queryName?: string;
|
|
640
|
+
}
|
|
641
|
+
declare abstract class CacheKeyFactory {
|
|
642
|
+
abstract create(input: CacheKeyFactoryInput): string;
|
|
643
|
+
abstract createPrefix(input: CacheKeyPrefixInput): string;
|
|
644
|
+
}
|
|
645
|
+
declare class DefaultCacheKeyFactory extends CacheKeyFactory {
|
|
646
|
+
create(input: CacheKeyFactoryInput): string;
|
|
647
|
+
createPrefix(input: CacheKeyPrefixInput): string;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
declare abstract class CacheVersionService {
|
|
651
|
+
abstract getVersion(namespace: string): Promise<string | number>;
|
|
652
|
+
abstract bumpVersion(namespace: string): Promise<string | number>;
|
|
653
|
+
}
|
|
654
|
+
declare class InMemoryCacheVersionService extends CacheVersionService {
|
|
655
|
+
private readonly versions;
|
|
656
|
+
getVersion(namespace: string): Promise<number>;
|
|
657
|
+
bumpVersion(namespace: string): Promise<number>;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
declare class CacheQueryMiddleware implements QueryMiddleware {
|
|
661
|
+
private readonly cacheStore;
|
|
662
|
+
private readonly cacheKeyFactory;
|
|
663
|
+
private readonly cacheVersionService;
|
|
664
|
+
constructor(cacheStore: CacheStore, cacheKeyFactory: CacheKeyFactory, cacheVersionService: CacheVersionService);
|
|
665
|
+
use<TQuery extends Query<any>>(query: TQuery, next: () => Promise<ResultType<QueryResultOf<TQuery>>>): Promise<ResultType<QueryResultOf<TQuery>>>;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
declare class CacheInvalidationCommandMiddleware implements CommandMiddleware {
|
|
669
|
+
private readonly cacheStore;
|
|
670
|
+
private readonly cacheKeyFactory;
|
|
671
|
+
private readonly cacheVersionService;
|
|
672
|
+
private readonly logger;
|
|
673
|
+
constructor(cacheStore: CacheStore, cacheKeyFactory: CacheKeyFactory, cacheVersionService: CacheVersionService, logger: Logger);
|
|
674
|
+
use<TCommand extends Command<any>>(command: TCommand, next: () => Promise<ResultType<CommandResultOf<TCommand>>>): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
675
|
+
private invalidate;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
type IdempotencyBeginStatus = 'started' | 'completed' | 'in_progress' | 'conflict';
|
|
679
|
+
interface IdempotencyBeginInput {
|
|
680
|
+
readonly scope: string;
|
|
681
|
+
readonly key: string;
|
|
682
|
+
readonly fingerprint: string;
|
|
683
|
+
readonly ttlSeconds: number;
|
|
684
|
+
readonly operationName: string;
|
|
685
|
+
readonly startedAt: Date;
|
|
686
|
+
}
|
|
687
|
+
type IdempotencyBeginResult<TResult = unknown> = {
|
|
688
|
+
readonly status: 'started';
|
|
689
|
+
} | {
|
|
690
|
+
readonly status: 'completed';
|
|
691
|
+
readonly result: TResult;
|
|
692
|
+
} | {
|
|
693
|
+
readonly status: 'in_progress';
|
|
694
|
+
} | {
|
|
695
|
+
readonly status: 'conflict';
|
|
696
|
+
readonly existingFingerprint?: string;
|
|
697
|
+
readonly incomingFingerprint: string;
|
|
698
|
+
};
|
|
699
|
+
interface IdempotencyCompleteInput<TResult = unknown> {
|
|
700
|
+
readonly scope: string;
|
|
701
|
+
readonly key: string;
|
|
702
|
+
readonly result: TResult;
|
|
703
|
+
readonly completedAt: Date;
|
|
704
|
+
}
|
|
705
|
+
interface IdempotencyFailInput {
|
|
706
|
+
readonly scope: string;
|
|
707
|
+
readonly key: string;
|
|
708
|
+
readonly failedAt: Date;
|
|
709
|
+
readonly error: unknown;
|
|
710
|
+
}
|
|
711
|
+
declare abstract class IdempotencyStore {
|
|
712
|
+
abstract begin<TResult = unknown>(input: IdempotencyBeginInput): Promise<IdempotencyBeginResult<TResult>>;
|
|
713
|
+
abstract complete<TResult = unknown>(input: IdempotencyCompleteInput<TResult>): Promise<void>;
|
|
714
|
+
abstract fail(input: IdempotencyFailInput): Promise<void>;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
declare class NoopIdempotencyStore extends IdempotencyStore {
|
|
718
|
+
begin<TResult = unknown>(input: IdempotencyBeginInput): Promise<IdempotencyBeginResult<TResult>>;
|
|
719
|
+
complete<TResult = unknown>(_input: IdempotencyCompleteInput<TResult>): Promise<void>;
|
|
720
|
+
fail(_input: IdempotencyFailInput): Promise<void>;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
interface IdempotencyKeyResolverInput {
|
|
724
|
+
readonly command: object;
|
|
725
|
+
readonly operationName: string;
|
|
726
|
+
readonly keyProperty: string;
|
|
727
|
+
}
|
|
728
|
+
declare abstract class IdempotencyKeyResolver {
|
|
729
|
+
abstract resolve(input: IdempotencyKeyResolverInput): Promise<string | undefined>;
|
|
730
|
+
}
|
|
731
|
+
declare class DefaultIdempotencyKeyResolver extends IdempotencyKeyResolver {
|
|
732
|
+
resolve(input: IdempotencyKeyResolverInput): Promise<string | undefined>;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
interface IdempotencyFingerprintFactoryInput {
|
|
736
|
+
readonly operationName: string;
|
|
737
|
+
readonly payload: unknown;
|
|
738
|
+
readonly excludeProperties?: readonly string[];
|
|
739
|
+
}
|
|
740
|
+
declare abstract class IdempotencyFingerprintFactory {
|
|
741
|
+
abstract create(input: IdempotencyFingerprintFactoryInput): string;
|
|
742
|
+
}
|
|
743
|
+
declare class DefaultIdempotencyFingerprintFactory extends IdempotencyFingerprintFactory {
|
|
744
|
+
create(input: IdempotencyFingerprintFactoryInput): string;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
declare class IdempotencyCommandMiddleware implements CommandMiddleware {
|
|
748
|
+
private readonly store;
|
|
749
|
+
private readonly keyResolver;
|
|
750
|
+
private readonly fingerprintFactory;
|
|
751
|
+
constructor(store: IdempotencyStore, keyResolver: IdempotencyKeyResolver, fingerprintFactory: IdempotencyFingerprintFactory);
|
|
752
|
+
use<TCommand extends Command<any>>(command: TCommand, next: () => Promise<ResultType<CommandResultOf<TCommand>>>): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
type AuditOperationType = 'command' | 'query';
|
|
756
|
+
type AuditOutcome = 'success' | 'failure';
|
|
757
|
+
interface AuditEvent {
|
|
758
|
+
readonly id?: string;
|
|
759
|
+
readonly action: string;
|
|
760
|
+
readonly resource?: string;
|
|
761
|
+
readonly resourceId?: string;
|
|
762
|
+
readonly operationType: AuditOperationType;
|
|
763
|
+
readonly operationName: string;
|
|
764
|
+
readonly outcome: AuditOutcome;
|
|
765
|
+
readonly errorName?: string;
|
|
766
|
+
readonly errorMessage?: string;
|
|
767
|
+
readonly failureKind?: FailureKind;
|
|
768
|
+
readonly failureCode?: string;
|
|
769
|
+
readonly failureMessage?: string;
|
|
770
|
+
readonly correlationId?: string;
|
|
771
|
+
readonly causationId?: string;
|
|
772
|
+
readonly requestId?: string;
|
|
773
|
+
readonly tenantId?: string;
|
|
774
|
+
readonly userId?: string;
|
|
775
|
+
readonly source?: string;
|
|
776
|
+
readonly locale?: string;
|
|
777
|
+
readonly durationMs: number;
|
|
778
|
+
readonly occurredAt: Date;
|
|
779
|
+
readonly metadata?: Record<string, unknown>;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
declare abstract class AuditWriter {
|
|
783
|
+
abstract write(event: AuditEvent): Promise<void>;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
declare class NoopAuditWriter extends AuditWriter {
|
|
787
|
+
write(_event: AuditEvent): Promise<void>;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
declare class AuditCommandMiddleware implements CommandMiddleware {
|
|
791
|
+
private readonly auditWriter;
|
|
792
|
+
private readonly contextService;
|
|
793
|
+
private readonly logger;
|
|
794
|
+
constructor(auditWriter: AuditWriter, contextService: ExiumContextService, logger: Logger);
|
|
795
|
+
use<TCommand extends Command<any>>(command: TCommand, next: () => Promise<ResultType<CommandResultOf<TCommand>>>): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
796
|
+
private writeAuditSafely;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
declare class AuditQueryMiddleware implements QueryMiddleware {
|
|
800
|
+
private readonly auditWriter;
|
|
801
|
+
private readonly contextService;
|
|
802
|
+
private readonly logger;
|
|
803
|
+
constructor(auditWriter: AuditWriter, contextService: ExiumContextService, logger: Logger);
|
|
804
|
+
use<TQuery extends Query<any>>(query: TQuery, next: () => Promise<ResultType<QueryResultOf<TQuery>>>): Promise<ResultType<QueryResultOf<TQuery>>>;
|
|
805
|
+
private writeAuditSafely;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
declare class ContextPermissionChecker extends PermissionChecker {
|
|
809
|
+
check(input: PermissionCheckInput): Promise<PermissionCheckResult>;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
interface Finder {
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
interface ReadModel {
|
|
816
|
+
}
|
|
817
|
+
interface View {
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
declare class ReadQueryException extends Error {
|
|
821
|
+
constructor(message: string);
|
|
822
|
+
}
|
|
823
|
+
declare class ReadFieldNotFoundException extends ReadQueryException {
|
|
824
|
+
constructor(sourceName: string, field: string);
|
|
825
|
+
}
|
|
826
|
+
declare class ReadOperationNotSupportedException extends ReadQueryException {
|
|
827
|
+
constructor(operation: string, reason?: string);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
type CriteriaOperator = 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'notIn' | 'contains' | 'startsWith' | 'endsWith' | 'isNull' | 'isNotNull' | 'between';
|
|
831
|
+
interface ComparisonCriteriaNode {
|
|
832
|
+
readonly type: 'comparison';
|
|
833
|
+
readonly field: string;
|
|
834
|
+
readonly operator: Exclude<CriteriaOperator, 'in' | 'notIn' | 'isNull' | 'isNotNull' | 'between'>;
|
|
835
|
+
readonly value: unknown;
|
|
836
|
+
}
|
|
837
|
+
interface InCriteriaNode {
|
|
838
|
+
readonly type: 'in';
|
|
839
|
+
readonly field: string;
|
|
840
|
+
readonly operator: 'in' | 'notIn';
|
|
841
|
+
readonly values: readonly unknown[];
|
|
842
|
+
}
|
|
843
|
+
interface IsNullCriteriaNode {
|
|
844
|
+
readonly type: 'isNull';
|
|
845
|
+
readonly field: string;
|
|
846
|
+
}
|
|
847
|
+
interface IsNotNullCriteriaNode {
|
|
848
|
+
readonly type: 'isNotNull';
|
|
849
|
+
readonly field: string;
|
|
850
|
+
}
|
|
851
|
+
interface BetweenCriteriaNode {
|
|
852
|
+
readonly type: 'between';
|
|
853
|
+
readonly field: string;
|
|
854
|
+
readonly lower: unknown;
|
|
855
|
+
readonly upper: unknown;
|
|
856
|
+
}
|
|
857
|
+
interface AndCriteriaNode {
|
|
858
|
+
readonly type: 'and';
|
|
859
|
+
readonly nodes: readonly CriteriaNode[];
|
|
860
|
+
}
|
|
861
|
+
interface OrCriteriaNode {
|
|
862
|
+
readonly type: 'or';
|
|
863
|
+
readonly nodes: readonly CriteriaNode[];
|
|
864
|
+
}
|
|
865
|
+
interface NotCriteriaNode {
|
|
866
|
+
readonly type: 'not';
|
|
867
|
+
readonly node: CriteriaNode;
|
|
868
|
+
}
|
|
869
|
+
type CriteriaNode = ComparisonCriteriaNode | InCriteriaNode | IsNullCriteriaNode | IsNotNullCriteriaNode | BetweenCriteriaNode | AndCriteriaNode | OrCriteriaNode | NotCriteriaNode;
|
|
870
|
+
type CriteriaConnector = 'and' | 'or';
|
|
871
|
+
declare class Criteria {
|
|
872
|
+
readonly node: CriteriaNode | null;
|
|
873
|
+
private constructor();
|
|
874
|
+
static empty(): Criteria;
|
|
875
|
+
static where(field: string): CriteriaFieldBuilder;
|
|
876
|
+
where(field: string): CriteriaFieldBuilder;
|
|
877
|
+
and(field: string): CriteriaFieldBuilder;
|
|
878
|
+
or(field: string): CriteriaFieldBuilder;
|
|
879
|
+
andGroup(factory: (group: Criteria) => Criteria): Criteria;
|
|
880
|
+
orGroup(factory: (group: Criteria) => Criteria): Criteria;
|
|
881
|
+
not(): Criteria;
|
|
882
|
+
isEmpty(): boolean;
|
|
883
|
+
private append;
|
|
884
|
+
}
|
|
885
|
+
declare class CriteriaFieldBuilder {
|
|
886
|
+
private readonly criteria;
|
|
887
|
+
private readonly connector;
|
|
888
|
+
private readonly field;
|
|
889
|
+
constructor(criteria: Criteria, connector: CriteriaConnector, field: string);
|
|
890
|
+
eq(value: unknown): Criteria;
|
|
891
|
+
ne(value: unknown): Criteria;
|
|
892
|
+
gt(value: unknown): Criteria;
|
|
893
|
+
gte(value: unknown): Criteria;
|
|
894
|
+
lt(value: unknown): Criteria;
|
|
895
|
+
lte(value: unknown): Criteria;
|
|
896
|
+
in(values: readonly unknown[]): Criteria;
|
|
897
|
+
notIn(values: readonly unknown[]): Criteria;
|
|
898
|
+
contains(value: string): Criteria;
|
|
899
|
+
startsWith(value: string): Criteria;
|
|
900
|
+
endsWith(value: string): Criteria;
|
|
901
|
+
isNull(): Criteria;
|
|
902
|
+
isNotNull(): Criteria;
|
|
903
|
+
between(lower: unknown, upper: unknown): Criteria;
|
|
904
|
+
private comparison;
|
|
905
|
+
private inclusion;
|
|
906
|
+
private addNode;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
interface PageRequestOptions {
|
|
910
|
+
readonly maxSize?: number;
|
|
911
|
+
}
|
|
912
|
+
declare class PageRequest {
|
|
913
|
+
readonly page: number;
|
|
914
|
+
readonly size: number;
|
|
915
|
+
private constructor();
|
|
916
|
+
static of(page: number, size: number, options?: PageRequestOptions): ResultType<PageRequest>;
|
|
917
|
+
get offset(): number;
|
|
918
|
+
}
|
|
919
|
+
declare class Page<T> {
|
|
920
|
+
readonly items: readonly T[];
|
|
921
|
+
readonly page: number;
|
|
922
|
+
readonly size: number;
|
|
923
|
+
readonly totalItems: number;
|
|
924
|
+
readonly totalPages: number;
|
|
925
|
+
private constructor();
|
|
926
|
+
static of<T>(items: readonly T[], request: PageRequest, totalItems: number): Page<T>;
|
|
927
|
+
}
|
|
928
|
+
declare class CursorRequest {
|
|
929
|
+
readonly after: string | null;
|
|
930
|
+
readonly before: string | null;
|
|
931
|
+
readonly limit: number;
|
|
932
|
+
private constructor();
|
|
933
|
+
static first(limit: number, options?: PageRequestOptions): ResultType<CursorRequest>;
|
|
934
|
+
static after(cursor: string, limit: number, options?: PageRequestOptions): ResultType<CursorRequest>;
|
|
935
|
+
static before(cursor: string, limit: number, options?: PageRequestOptions): ResultType<CursorRequest>;
|
|
936
|
+
private static create;
|
|
937
|
+
}
|
|
938
|
+
declare class CursorPage<T> {
|
|
939
|
+
readonly items: readonly T[];
|
|
940
|
+
readonly hasNext: boolean;
|
|
941
|
+
readonly hasPrevious: boolean;
|
|
942
|
+
readonly nextCursor?: string | undefined;
|
|
943
|
+
readonly previousCursor?: string | undefined;
|
|
944
|
+
constructor(items: readonly T[], hasNext: boolean, hasPrevious: boolean, nextCursor?: string | undefined, previousCursor?: string | undefined);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
type SortDirection = 'asc' | 'desc';
|
|
948
|
+
type SortNulls = 'first' | 'last';
|
|
949
|
+
interface SortField {
|
|
950
|
+
readonly field: string;
|
|
951
|
+
readonly direction: SortDirection;
|
|
952
|
+
readonly nulls?: SortNulls;
|
|
953
|
+
}
|
|
954
|
+
declare class Sort {
|
|
955
|
+
readonly fields: readonly SortField[];
|
|
956
|
+
private constructor();
|
|
957
|
+
static none(): Sort;
|
|
958
|
+
static by(field: string): SortDirectionBuilder;
|
|
959
|
+
thenBy(field: string): SortDirectionBuilder;
|
|
960
|
+
isEmpty(): boolean;
|
|
961
|
+
static fromFields(fields: readonly SortField[]): Sort;
|
|
962
|
+
}
|
|
963
|
+
declare class SortDirectionBuilder {
|
|
964
|
+
private readonly previousFields;
|
|
965
|
+
private readonly field;
|
|
966
|
+
constructor(previousFields: readonly SortField[], field: string);
|
|
967
|
+
asc(options?: {
|
|
968
|
+
readonly nulls?: SortNulls;
|
|
969
|
+
}): Sort;
|
|
970
|
+
desc(options?: {
|
|
971
|
+
readonly nulls?: SortNulls;
|
|
972
|
+
}): Sort;
|
|
973
|
+
private build;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
interface ReadSource {
|
|
977
|
+
readonly name: string;
|
|
978
|
+
}
|
|
979
|
+
type SqlJoinType = 'left' | 'inner';
|
|
980
|
+
type SqlJoinOperator = '=' | '!=' | '<' | '<=' | '>' | '>=';
|
|
981
|
+
interface SqlJoinOnRef {
|
|
982
|
+
readonly left: string;
|
|
983
|
+
readonly operator: SqlJoinOperator;
|
|
984
|
+
readonly right: string;
|
|
985
|
+
}
|
|
986
|
+
interface SqlJoin {
|
|
987
|
+
readonly type: SqlJoinType;
|
|
988
|
+
readonly table: string;
|
|
989
|
+
readonly alias: string;
|
|
990
|
+
readonly on: SqlJoinOnRef;
|
|
991
|
+
}
|
|
992
|
+
interface SqlReadSourceDefinition {
|
|
993
|
+
readonly name: string;
|
|
994
|
+
readonly table: string;
|
|
995
|
+
readonly alias?: string;
|
|
996
|
+
readonly fields: Record<string, string>;
|
|
997
|
+
readonly joins?: readonly SqlJoin[];
|
|
998
|
+
readonly defaultSort?: Sort;
|
|
999
|
+
readonly defaultSelectedFields?: readonly string[];
|
|
1000
|
+
}
|
|
1001
|
+
declare class SqlReadSource implements ReadSource {
|
|
1002
|
+
readonly name: string;
|
|
1003
|
+
readonly table: string;
|
|
1004
|
+
readonly alias: string | undefined;
|
|
1005
|
+
readonly fields: Readonly<Record<string, string>>;
|
|
1006
|
+
readonly joins: readonly SqlJoin[];
|
|
1007
|
+
readonly defaultSort: Sort | undefined;
|
|
1008
|
+
readonly defaultSelectedFields: readonly string[] | undefined;
|
|
1009
|
+
private constructor();
|
|
1010
|
+
static define(definition: SqlReadSourceDefinition): SqlReadSource;
|
|
1011
|
+
static is(source: ReadSource): source is SqlReadSource;
|
|
1012
|
+
resolveField(field: string): string;
|
|
1013
|
+
getSelectFields(): readonly string[];
|
|
1014
|
+
getFromExpression(): string;
|
|
1015
|
+
}
|
|
1016
|
+
declare class Join {
|
|
1017
|
+
static left(table: string, alias: string): JoinBuilder;
|
|
1018
|
+
static inner(table: string, alias: string): JoinBuilder;
|
|
1019
|
+
}
|
|
1020
|
+
declare class JoinBuilder {
|
|
1021
|
+
private readonly type;
|
|
1022
|
+
private readonly table;
|
|
1023
|
+
private readonly alias;
|
|
1024
|
+
constructor(type: SqlJoinType, table: string, alias: string);
|
|
1025
|
+
onRef(left: string, operator: SqlJoinOperator, right: string): SqlJoin;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
type RowMapper<TView> = (row: unknown) => TView;
|
|
1029
|
+
interface BaseReadQuery<TView> {
|
|
1030
|
+
readonly from: ReadSource;
|
|
1031
|
+
readonly criteria?: Criteria;
|
|
1032
|
+
readonly sort?: Sort;
|
|
1033
|
+
readonly map?: RowMapper<TView>;
|
|
1034
|
+
}
|
|
1035
|
+
interface FindOneQuery<TView> extends BaseReadQuery<TView> {
|
|
1036
|
+
}
|
|
1037
|
+
interface FindManyQuery<TView> extends BaseReadQuery<TView> {
|
|
1038
|
+
readonly limit?: number;
|
|
1039
|
+
}
|
|
1040
|
+
interface FindPageQuery<TView> extends BaseReadQuery<TView> {
|
|
1041
|
+
readonly page: PageRequest;
|
|
1042
|
+
}
|
|
1043
|
+
interface FindCursorQuery<TView> extends BaseReadQuery<TView> {
|
|
1044
|
+
readonly cursor: CursorRequest;
|
|
1045
|
+
readonly sort: Sort;
|
|
1046
|
+
}
|
|
1047
|
+
interface ExistsQuery {
|
|
1048
|
+
readonly from: ReadSource;
|
|
1049
|
+
readonly criteria?: Criteria;
|
|
1050
|
+
}
|
|
1051
|
+
interface CountQuery {
|
|
1052
|
+
readonly from: ReadSource;
|
|
1053
|
+
readonly criteria?: Criteria;
|
|
1054
|
+
}
|
|
1055
|
+
interface ReadEngine {
|
|
1056
|
+
findOne<TView>(query: FindOneQuery<TView>): Promise<TView | null>;
|
|
1057
|
+
findMany<TView>(query: FindManyQuery<TView>): Promise<readonly TView[]>;
|
|
1058
|
+
findPage<TView>(query: FindPageQuery<TView>): Promise<Page<TView>>;
|
|
1059
|
+
findCursor<TView>(query: FindCursorQuery<TView>): Promise<CursorPage<TView>>;
|
|
1060
|
+
exists(query: ExistsQuery): Promise<boolean>;
|
|
1061
|
+
count(query: CountQuery): Promise<number>;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
declare abstract class AuditableEntity<TId extends Id> extends Entity<TId> {
|
|
1065
|
+
readonly createdAt: Date;
|
|
1066
|
+
updatedAt: Date;
|
|
1067
|
+
constructor(id: TId, createdAt?: Date, updatedAt?: Date);
|
|
1068
|
+
protected touch(): void;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
declare abstract class AuditableAggregateRoot<TId extends Id> extends AggregateRoot<TId> implements Auditable$1, Versionable {
|
|
1072
|
+
readonly createdAt: Date;
|
|
1073
|
+
updatedAt: Date;
|
|
1074
|
+
version: number;
|
|
1075
|
+
constructor(id: TId, createdAt?: Date, updatedAt?: Date, version?: number);
|
|
1076
|
+
protected touch(): void;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
declare abstract class PrimitiveValueObject<T> extends ValueObject<{
|
|
1080
|
+
value: T;
|
|
1081
|
+
}> {
|
|
1082
|
+
get value(): T;
|
|
1083
|
+
protected constructor(value: T);
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
declare class ExiumConfigModule {
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
declare class ExiumEnvironment {
|
|
1090
|
+
EXIUM_DB_URL?: string;
|
|
1091
|
+
EXIUM_RABBITMQ_URL?: string;
|
|
1092
|
+
EXIUM_REDIS_URL?: string;
|
|
1093
|
+
EXIUM_LOG_LEVEL?: string;
|
|
1094
|
+
EXIUM_LOG_PRETTY?: boolean;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
declare class ExiumConfigService {
|
|
1098
|
+
private readonly configService;
|
|
1099
|
+
constructor(configService: ConfigService<ExiumEnvironment, true>);
|
|
1100
|
+
get isProduction(): boolean;
|
|
1101
|
+
get databaseUrl(): string | undefined;
|
|
1102
|
+
getRequiredDatabaseUrl(): string;
|
|
1103
|
+
get rabbitMqUrl(): string | undefined;
|
|
1104
|
+
get redisUrl(): string | undefined;
|
|
1105
|
+
get logLevel(): string | undefined;
|
|
1106
|
+
get logPretty(): boolean | undefined;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
declare abstract class ApiResponse {
|
|
1110
|
+
success: boolean;
|
|
1111
|
+
message?: string;
|
|
1112
|
+
timestamp: string;
|
|
1113
|
+
constructor(message?: string);
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
declare class SuccessResult extends ApiResponse {
|
|
1117
|
+
constructor(message?: string);
|
|
1118
|
+
}
|
|
1119
|
+
declare class SuccessDataResult<T> extends SuccessResult {
|
|
1120
|
+
data: T;
|
|
1121
|
+
constructor(data: T, message?: string);
|
|
1122
|
+
}
|
|
1123
|
+
declare class SuccessListResult<T> extends SuccessResult {
|
|
1124
|
+
data: T[];
|
|
1125
|
+
constructor(data: T[], message?: string);
|
|
1126
|
+
}
|
|
1127
|
+
declare class SuccessPageResult<T> extends SuccessResult {
|
|
1128
|
+
data: T[];
|
|
1129
|
+
meta: {
|
|
1130
|
+
total: number;
|
|
1131
|
+
page: number;
|
|
1132
|
+
size: number;
|
|
1133
|
+
totalPages?: number;
|
|
1134
|
+
};
|
|
1135
|
+
constructor(data: T[], meta: {
|
|
1136
|
+
total: number;
|
|
1137
|
+
page: number;
|
|
1138
|
+
size: number;
|
|
1139
|
+
totalPages?: number;
|
|
1140
|
+
}, message?: string);
|
|
1141
|
+
}
|
|
1142
|
+
declare class SuccessCursorResult<T> extends SuccessResult {
|
|
1143
|
+
data: T[];
|
|
1144
|
+
meta: {
|
|
1145
|
+
nextCursor?: string;
|
|
1146
|
+
previousCursor?: string;
|
|
1147
|
+
hasNext: boolean;
|
|
1148
|
+
hasPrevious: boolean;
|
|
1149
|
+
};
|
|
1150
|
+
constructor(data: T[], meta: {
|
|
1151
|
+
nextCursor?: string;
|
|
1152
|
+
previousCursor?: string;
|
|
1153
|
+
hasNext: boolean;
|
|
1154
|
+
hasPrevious: boolean;
|
|
1155
|
+
}, message?: string);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
declare class ErrorResult extends ApiResponse {
|
|
1159
|
+
error: {
|
|
1160
|
+
code: string;
|
|
1161
|
+
kind?: FailureKind;
|
|
1162
|
+
details?: unknown;
|
|
1163
|
+
};
|
|
1164
|
+
constructor(code: string, message: string, details?: unknown, kind?: FailureKind);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
type HttpApiExposure = 'external' | 'internal';
|
|
1168
|
+
type InternalApiMode = 'auto' | 'local' | 'remote';
|
|
1169
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
1170
|
+
interface HttpApiMetadata {
|
|
1171
|
+
readonly exposure: HttpApiExposure;
|
|
1172
|
+
readonly name?: string;
|
|
1173
|
+
readonly version?: string;
|
|
1174
|
+
readonly owner?: string;
|
|
1175
|
+
readonly audience?: string;
|
|
1176
|
+
readonly description?: string;
|
|
1177
|
+
readonly tags?: readonly string[];
|
|
1178
|
+
readonly internalMode?: InternalApiMode;
|
|
1179
|
+
}
|
|
1180
|
+
declare const EXIUM_HTTP_API_METADATA: unique symbol;
|
|
1181
|
+
declare function defineHttpApiMetadata(metadata: HttpApiMetadata, target: object, propertyKey?: string | symbol): void;
|
|
1182
|
+
declare function getHttpApiMetadata(target: object, propertyKey?: string | symbol): HttpApiMetadata | undefined;
|
|
1183
|
+
|
|
1184
|
+
type ExternalApiOptions = Omit<HttpApiMetadata, 'exposure' | 'internalMode'>;
|
|
1185
|
+
declare function ExternalApi(options?: ExternalApiOptions): ClassDecorator & MethodDecorator;
|
|
1186
|
+
|
|
1187
|
+
interface InternalApiOptions extends Omit<HttpApiMetadata, 'exposure' | 'internalMode'> {
|
|
1188
|
+
readonly mode?: InternalApiMode;
|
|
1189
|
+
}
|
|
1190
|
+
declare function InternalApi(options?: InternalApiOptions): ClassDecorator & MethodDecorator;
|
|
1191
|
+
|
|
1192
|
+
declare const EXIUM_HTTP_OPTIONS: unique symbol;
|
|
1193
|
+
type ExiumHttpAdapter = 'express';
|
|
1194
|
+
interface ExiumHttpHeaderNames {
|
|
1195
|
+
readonly requestId: string;
|
|
1196
|
+
readonly correlationId: string;
|
|
1197
|
+
readonly causationId: string;
|
|
1198
|
+
readonly tenantId: string;
|
|
1199
|
+
readonly userId: string;
|
|
1200
|
+
readonly roles: string;
|
|
1201
|
+
readonly permissions: string;
|
|
1202
|
+
readonly source: string;
|
|
1203
|
+
readonly locale: string;
|
|
1204
|
+
}
|
|
1205
|
+
interface ExiumHttpOptions {
|
|
1206
|
+
readonly adapter?: ExiumHttpAdapter;
|
|
1207
|
+
readonly context?: {
|
|
1208
|
+
readonly headerNames?: Partial<ExiumHttpHeaderNames>;
|
|
1209
|
+
};
|
|
1210
|
+
readonly internalApis?: {
|
|
1211
|
+
readonly defaultMode?: InternalApiMode;
|
|
1212
|
+
readonly remoteServices?: Record<string, string>;
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
interface ResolvedExiumHttpOptions {
|
|
1216
|
+
readonly adapter: ExiumHttpAdapter;
|
|
1217
|
+
readonly context: {
|
|
1218
|
+
readonly headerNames: ExiumHttpHeaderNames;
|
|
1219
|
+
};
|
|
1220
|
+
readonly internalApis: {
|
|
1221
|
+
readonly defaultMode: InternalApiMode;
|
|
1222
|
+
readonly remoteServices: Record<string, string>;
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
declare const DEFAULT_EXIUM_HTTP_HEADER_NAMES: ExiumHttpHeaderNames;
|
|
1226
|
+
declare function resolveExiumHttpOptions(options?: ExiumHttpOptions): ResolvedExiumHttpOptions;
|
|
1227
|
+
|
|
1228
|
+
declare class ExiumHttpModule {
|
|
1229
|
+
static forRoot(options?: ExiumHttpOptions): DynamicModule;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
interface InternalApiHandlerContext {
|
|
1233
|
+
readonly sourceServiceName: string;
|
|
1234
|
+
readonly targetServiceName: string;
|
|
1235
|
+
readonly operation: string;
|
|
1236
|
+
readonly mode: Exclude<InternalApiMode, 'auto'>;
|
|
1237
|
+
readonly method?: HttpMethod;
|
|
1238
|
+
readonly path?: string;
|
|
1239
|
+
}
|
|
1240
|
+
interface InternalApiHandler<TRequest = unknown, TResponse = unknown> {
|
|
1241
|
+
handle(request: TRequest, context: InternalApiHandlerContext): Promise<ResultType<TResponse> | TResponse> | ResultType<TResponse> | TResponse;
|
|
1242
|
+
}
|
|
1243
|
+
interface InternalApiHandlerMetadata {
|
|
1244
|
+
readonly operation: string;
|
|
1245
|
+
readonly serviceName?: string;
|
|
1246
|
+
readonly description?: string;
|
|
1247
|
+
}
|
|
1248
|
+
declare const INTERNAL_API_HANDLER_METADATA: unique symbol;
|
|
1249
|
+
declare function HandleInternalApi(options: InternalApiHandlerMetadata): ClassDecorator;
|
|
1250
|
+
declare function getInternalApiHandlerMetadata(target: object): InternalApiHandlerMetadata | undefined;
|
|
1251
|
+
|
|
1252
|
+
interface RegisteredInternalApiHandler {
|
|
1253
|
+
readonly metadata: InternalApiHandlerMetadata;
|
|
1254
|
+
readonly handler: InternalApiHandler<any, any>;
|
|
1255
|
+
}
|
|
1256
|
+
declare class ExiumInternalApiRegistry {
|
|
1257
|
+
private readonly handlers;
|
|
1258
|
+
register(metadata: InternalApiHandlerMetadata, handler: InternalApiHandler<any, any>): void;
|
|
1259
|
+
resolve(serviceName: string, operation: string): RegisteredInternalApiHandler | undefined;
|
|
1260
|
+
has(serviceName: string, operation: string): boolean;
|
|
1261
|
+
list(): RegisteredInternalApiHandler[];
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
declare class ExiumHttpDiscoveryService implements OnApplicationBootstrap {
|
|
1265
|
+
private readonly discovery;
|
|
1266
|
+
private readonly internalApiRegistry;
|
|
1267
|
+
constructor(discovery: DiscoveryService, internalApiRegistry: ExiumInternalApiRegistry);
|
|
1268
|
+
onApplicationBootstrap(): void;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
declare abstract class ExiumInternalApiEndpointResolver {
|
|
1272
|
+
abstract resolve(serviceName: string): Promise<string | undefined> | string | undefined;
|
|
1273
|
+
}
|
|
1274
|
+
declare class ConfiguredInternalApiEndpointResolver extends ExiumInternalApiEndpointResolver {
|
|
1275
|
+
private readonly options;
|
|
1276
|
+
constructor(options: ResolvedExiumHttpOptions);
|
|
1277
|
+
resolve(serviceName: string): string | undefined;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
type InternalApiQueryScalar = string | number | boolean | null | undefined;
|
|
1281
|
+
type InternalApiQueryValue = InternalApiQueryScalar | readonly InternalApiQueryScalar[];
|
|
1282
|
+
interface InternalApiCall<TRequest = unknown> {
|
|
1283
|
+
readonly serviceName: string;
|
|
1284
|
+
readonly operation: string;
|
|
1285
|
+
readonly mode?: InternalApiMode;
|
|
1286
|
+
readonly method?: HttpMethod;
|
|
1287
|
+
readonly path?: string;
|
|
1288
|
+
readonly query?: Record<string, InternalApiQueryValue>;
|
|
1289
|
+
readonly body?: TRequest;
|
|
1290
|
+
readonly headers?: Record<string, string>;
|
|
1291
|
+
readonly timeoutMs?: number;
|
|
1292
|
+
}
|
|
1293
|
+
declare class ExiumInternalApiClient {
|
|
1294
|
+
private readonly registry;
|
|
1295
|
+
private readonly endpointResolver;
|
|
1296
|
+
private readonly contextService;
|
|
1297
|
+
private readonly sourceServiceName;
|
|
1298
|
+
private readonly options;
|
|
1299
|
+
constructor(registry: ExiumInternalApiRegistry, endpointResolver: ExiumInternalApiEndpointResolver, contextService: ExiumContextService, sourceServiceName?: string, options?: ResolvedExiumHttpOptions);
|
|
1300
|
+
call<TResult, TRequest = unknown>(call: InternalApiCall<TRequest>): Promise<ResultType<TResult>>;
|
|
1301
|
+
private callLocal;
|
|
1302
|
+
private callRemote;
|
|
1303
|
+
private createRemoteHeaders;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
declare class ExiumHttpContextInterceptor implements NestInterceptor {
|
|
1307
|
+
private readonly contextService;
|
|
1308
|
+
private readonly options;
|
|
1309
|
+
constructor(contextService: ExiumContextService, options?: ResolvedExiumHttpOptions);
|
|
1310
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
1311
|
+
private createExecutionContext;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
declare class ExiumResponseInterceptor implements NestInterceptor {
|
|
1315
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
1316
|
+
private wrapSuccess;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* Exception policy:
|
|
1321
|
+
*
|
|
1322
|
+
* - Thrown exceptions represent unexpected failures (programmer errors,
|
|
1323
|
+
* infrastructure faults). They are logged and surfaced as HTTP 500 with a
|
|
1324
|
+
* generic message — internal details never leak to clients.
|
|
1325
|
+
* - Expected business failures must be returned as `Result.fail(Failure...)`,
|
|
1326
|
+
* which the response interceptor maps to the appropriate 4xx status.
|
|
1327
|
+
*
|
|
1328
|
+
* `HttpException` is the only exception with a meaningful HTTP status — it is
|
|
1329
|
+
* preserved for compatibility with NestJS pipes (e.g. ValidationPipe) and any
|
|
1330
|
+
* controller-level redirect/throw semantics.
|
|
1331
|
+
*/
|
|
1332
|
+
declare class ExiumExceptionFilter implements ExceptionFilter {
|
|
1333
|
+
private readonly logger?;
|
|
1334
|
+
constructor(logger?: Logger | undefined);
|
|
1335
|
+
catch(exception: unknown, host: ArgumentsHost): void;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
type ExiumCacheInfrastructureDriver = 'redis';
|
|
1339
|
+
interface ExiumCacheInfrastructureOptions {
|
|
1340
|
+
readonly driver?: ExiumCacheInfrastructureDriver;
|
|
1341
|
+
}
|
|
1342
|
+
declare class ExiumCacheInfrastructureModule {
|
|
1343
|
+
static forRoot(options?: ExiumCacheInfrastructureOptions): DynamicModule;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
declare const EXIUM_REDIS_OPTIONS: unique symbol;
|
|
1347
|
+
declare const EXIUM_REDIS_CLIENT: unique symbol;
|
|
1348
|
+
interface ExiumRedisOptions {
|
|
1349
|
+
readonly url: string;
|
|
1350
|
+
/**
|
|
1351
|
+
* Application-level Redis key prefix.
|
|
1352
|
+
*
|
|
1353
|
+
* This is intentionally not passed to ioredis as native keyPrefix.
|
|
1354
|
+
* Framework adapters apply it manually so scan/delete-by-prefix behavior
|
|
1355
|
+
* stays deterministic.
|
|
1356
|
+
*/
|
|
1357
|
+
readonly keyPrefix?: string;
|
|
1358
|
+
readonly connectTimeoutMs: number;
|
|
1359
|
+
readonly lazyConnect: boolean;
|
|
1360
|
+
readonly maxRetriesPerRequest: number;
|
|
1361
|
+
readonly enableOfflineQueue: boolean;
|
|
1362
|
+
}
|
|
1363
|
+
type ExiumRedisOptionsInput = Partial<ExiumRedisOptions>;
|
|
1364
|
+
declare const DEFAULT_EXIUM_REDIS_OPTIONS: Omit<ExiumRedisOptions, 'url'>;
|
|
1365
|
+
declare function normalizeExiumRedisOptions(input?: ExiumRedisOptionsInput): ExiumRedisOptions;
|
|
1366
|
+
|
|
1367
|
+
declare class ExiumRedisModule {
|
|
1368
|
+
static forRoot(options?: ExiumRedisOptionsInput): DynamicModule;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
declare class ExiumRedisClient implements OnApplicationShutdown {
|
|
1372
|
+
private readonly options;
|
|
1373
|
+
private client?;
|
|
1374
|
+
constructor(options: ExiumRedisOptions);
|
|
1375
|
+
get native(): Redis;
|
|
1376
|
+
ping(): Promise<string>;
|
|
1377
|
+
onApplicationShutdown(): Promise<void>;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
declare class RedisCacheStore extends CacheStore {
|
|
1381
|
+
private readonly redis;
|
|
1382
|
+
private readonly options;
|
|
1383
|
+
constructor(redis: Redis, options: ExiumRedisOptions);
|
|
1384
|
+
get<T>(key: string): Promise<CacheGetResult<T>>;
|
|
1385
|
+
set<T>(key: string, value: T, options?: CacheSetOptions): Promise<void>;
|
|
1386
|
+
delete(key: string): Promise<void>;
|
|
1387
|
+
deleteByPrefix(prefix: string): Promise<void>;
|
|
1388
|
+
private toPhysicalKey;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
declare class RedisCacheVersionService extends CacheVersionService {
|
|
1392
|
+
private readonly redis;
|
|
1393
|
+
private readonly options;
|
|
1394
|
+
constructor(redis: Redis, options: ExiumRedisOptions);
|
|
1395
|
+
getVersion(namespace: string): Promise<number>;
|
|
1396
|
+
bumpVersion(namespace: string): Promise<number>;
|
|
1397
|
+
private createVersionKey;
|
|
1398
|
+
private toPhysicalKey;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
type ExiumIdempotencyInfrastructureDriver = 'redis';
|
|
1402
|
+
interface ExiumIdempotencyInfrastructureOptions {
|
|
1403
|
+
readonly driver?: ExiumIdempotencyInfrastructureDriver;
|
|
1404
|
+
}
|
|
1405
|
+
declare class ExiumIdempotencyInfrastructureModule {
|
|
1406
|
+
static forRoot(options?: ExiumIdempotencyInfrastructureOptions): DynamicModule;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
declare class RedisIdempotencyStore extends IdempotencyStore {
|
|
1410
|
+
private readonly redis;
|
|
1411
|
+
private readonly options;
|
|
1412
|
+
constructor(redis: Redis, options: ExiumRedisOptions);
|
|
1413
|
+
begin<TResult = unknown>(input: IdempotencyBeginInput): Promise<IdempotencyBeginResult<TResult>>;
|
|
1414
|
+
complete<TResult = unknown>(input: IdempotencyCompleteInput<TResult>): Promise<void>;
|
|
1415
|
+
fail(input: IdempotencyFailInput): Promise<void>;
|
|
1416
|
+
private readRecord;
|
|
1417
|
+
private writePreservingTtl;
|
|
1418
|
+
private createPhysicalKey;
|
|
1419
|
+
private toPhysicalKey;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
interface IntegrationMessageEnvelope {
|
|
1423
|
+
readonly id: string;
|
|
1424
|
+
readonly name: string;
|
|
1425
|
+
readonly version: number;
|
|
1426
|
+
readonly occurredAt: Date;
|
|
1427
|
+
readonly payload: Record<string, unknown>;
|
|
1428
|
+
}
|
|
1429
|
+
declare abstract class IntegrationMessagePublisher {
|
|
1430
|
+
abstract publish(message: IntegrationMessageEnvelope): Promise<void>;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
declare class NoopIntegrationMessagePublisher extends IntegrationMessagePublisher {
|
|
1434
|
+
publish(message: IntegrationMessageEnvelope): Promise<void>;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
declare const RABBITMQ_OPTIONS: unique symbol;
|
|
1438
|
+
type RabbitMqExchangeType = 'topic' | 'direct' | 'fanout';
|
|
1439
|
+
interface RabbitMqOptions {
|
|
1440
|
+
readonly url: string;
|
|
1441
|
+
readonly exchange: string;
|
|
1442
|
+
readonly exchangeType: RabbitMqExchangeType;
|
|
1443
|
+
readonly routingKey?: string;
|
|
1444
|
+
readonly durable: boolean;
|
|
1445
|
+
readonly persistent: boolean;
|
|
1446
|
+
}
|
|
1447
|
+
type RabbitMqOptionsInput = Partial<RabbitMqOptions>;
|
|
1448
|
+
declare const DEFAULT_RABBITMQ_OPTIONS: Omit<RabbitMqOptions, 'url'>;
|
|
1449
|
+
declare function normalizeRabbitMqOptions(input: RabbitMqOptionsInput): RabbitMqOptions;
|
|
1450
|
+
|
|
1451
|
+
type ExiumMessagingDriver = 'noop' | 'rabbitmq';
|
|
1452
|
+
interface ExiumMessagingOptions {
|
|
1453
|
+
readonly driver?: ExiumMessagingDriver;
|
|
1454
|
+
readonly rabbitmq?: RabbitMqOptionsInput;
|
|
1455
|
+
}
|
|
1456
|
+
declare class ExiumMessagingModule {
|
|
1457
|
+
static forRoot(options?: ExiumMessagingOptions): DynamicModule;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
declare class RabbitMqIntegrationMessagePublisher extends IntegrationMessagePublisher implements OnApplicationShutdown {
|
|
1461
|
+
private readonly options;
|
|
1462
|
+
private connection?;
|
|
1463
|
+
private channel?;
|
|
1464
|
+
private initializing?;
|
|
1465
|
+
constructor(options: RabbitMqOptions);
|
|
1466
|
+
publish(message: IntegrationMessageEnvelope): Promise<void>;
|
|
1467
|
+
onApplicationShutdown(): Promise<void>;
|
|
1468
|
+
private ensureChannel;
|
|
1469
|
+
private initialize;
|
|
1470
|
+
private closeSafely;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
declare const OutboxMessageSchema: _mikro_orm_core.EntitySchemaWithMeta<"OutboxMessageEntity", "exium_outbox_messages", _mikro_orm_core.InferEntityFromProperties<{
|
|
1474
|
+
readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
|
|
1475
|
+
primary: true;
|
|
1476
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1477
|
+
readonly eventId: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1478
|
+
readonly eventName: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1479
|
+
readonly eventVersion: _mikro_orm_core.UniversalPropertyOptionsBuilder<number, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1480
|
+
readonly payload: _mikro_orm_core.UniversalPropertyOptionsBuilder<Record<string, unknown>, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1481
|
+
readonly occurredAt: _mikro_orm_core.UniversalPropertyOptionsBuilder<Date, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1482
|
+
/**
|
|
1483
|
+
* Keep status as string instead of enum metadata here.
|
|
1484
|
+
* This keeps the schema simple and portable across SQL/Mongo drivers.
|
|
1485
|
+
*/
|
|
1486
|
+
readonly status: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1487
|
+
readonly retryCount: _mikro_orm_core.UniversalPropertyOptionsBuilder<number, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1488
|
+
readonly nextAttemptAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1489
|
+
nullable: true;
|
|
1490
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1491
|
+
readonly publishedAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1492
|
+
nullable: true;
|
|
1493
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1494
|
+
readonly lockedAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1495
|
+
nullable: true;
|
|
1496
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1497
|
+
readonly lockedBy: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1498
|
+
nullable: true;
|
|
1499
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1500
|
+
readonly lastError: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1501
|
+
nullable: true;
|
|
1502
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1503
|
+
readonly createdAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, _mikro_orm_core.EmptyOptions & {
|
|
1504
|
+
onCreate: (...args: any[]) => any;
|
|
1505
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1506
|
+
readonly updatedAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, _mikro_orm_core.EmptyOptions & {
|
|
1507
|
+
onCreate: (...args: any[]) => any;
|
|
1508
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1509
|
+
}, undefined, never, never, false>, never, {
|
|
1510
|
+
readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
|
|
1511
|
+
primary: true;
|
|
1512
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1513
|
+
readonly eventId: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1514
|
+
readonly eventName: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1515
|
+
readonly eventVersion: _mikro_orm_core.UniversalPropertyOptionsBuilder<number, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1516
|
+
readonly payload: _mikro_orm_core.UniversalPropertyOptionsBuilder<Record<string, unknown>, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1517
|
+
readonly occurredAt: _mikro_orm_core.UniversalPropertyOptionsBuilder<Date, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1518
|
+
/**
|
|
1519
|
+
* Keep status as string instead of enum metadata here.
|
|
1520
|
+
* This keeps the schema simple and portable across SQL/Mongo drivers.
|
|
1521
|
+
*/
|
|
1522
|
+
readonly status: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1523
|
+
readonly retryCount: _mikro_orm_core.UniversalPropertyOptionsBuilder<number, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1524
|
+
readonly nextAttemptAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1525
|
+
nullable: true;
|
|
1526
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1527
|
+
readonly publishedAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1528
|
+
nullable: true;
|
|
1529
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1530
|
+
readonly lockedAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1531
|
+
nullable: true;
|
|
1532
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1533
|
+
readonly lockedBy: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1534
|
+
nullable: true;
|
|
1535
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1536
|
+
readonly lastError: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1537
|
+
nullable: true;
|
|
1538
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1539
|
+
readonly createdAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, _mikro_orm_core.EmptyOptions & {
|
|
1540
|
+
onCreate: (...args: any[]) => any;
|
|
1541
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1542
|
+
readonly updatedAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, _mikro_orm_core.EmptyOptions & {
|
|
1543
|
+
onCreate: (...args: any[]) => any;
|
|
1544
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1545
|
+
}, _mikro_orm_core.EntityCtor<_mikro_orm_core.InferEntityFromProperties<{
|
|
1546
|
+
readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
|
|
1547
|
+
primary: true;
|
|
1548
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1549
|
+
readonly eventId: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1550
|
+
readonly eventName: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1551
|
+
readonly eventVersion: _mikro_orm_core.UniversalPropertyOptionsBuilder<number, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1552
|
+
readonly payload: _mikro_orm_core.UniversalPropertyOptionsBuilder<Record<string, unknown>, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1553
|
+
readonly occurredAt: _mikro_orm_core.UniversalPropertyOptionsBuilder<Date, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1554
|
+
/**
|
|
1555
|
+
* Keep status as string instead of enum metadata here.
|
|
1556
|
+
* This keeps the schema simple and portable across SQL/Mongo drivers.
|
|
1557
|
+
*/
|
|
1558
|
+
readonly status: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1559
|
+
readonly retryCount: _mikro_orm_core.UniversalPropertyOptionsBuilder<number, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1560
|
+
readonly nextAttemptAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1561
|
+
nullable: true;
|
|
1562
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1563
|
+
readonly publishedAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1564
|
+
nullable: true;
|
|
1565
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1566
|
+
readonly lockedAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1567
|
+
nullable: true;
|
|
1568
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1569
|
+
readonly lockedBy: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1570
|
+
nullable: true;
|
|
1571
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1572
|
+
readonly lastError: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "nullable"> & {
|
|
1573
|
+
nullable: true;
|
|
1574
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1575
|
+
readonly createdAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, _mikro_orm_core.EmptyOptions & {
|
|
1576
|
+
onCreate: (...args: any[]) => any;
|
|
1577
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1578
|
+
readonly updatedAt: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<Date, _mikro_orm_core.EmptyOptions & {
|
|
1579
|
+
onCreate: (...args: any[]) => any;
|
|
1580
|
+
}, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
|
|
1581
|
+
}, undefined, never, never, false>>>;
|
|
1582
|
+
declare class OutboxMessageEntity extends OutboxMessageSchema.class {
|
|
1583
|
+
static create(params: {
|
|
1584
|
+
eventId: string;
|
|
1585
|
+
eventName: string;
|
|
1586
|
+
eventVersion: number;
|
|
1587
|
+
payload: Record<string, unknown>;
|
|
1588
|
+
occurredAt: Date;
|
|
1589
|
+
}): OutboxMessageEntity;
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
declare enum OutboxMessageStatus {
|
|
1593
|
+
Pending = "pending",
|
|
1594
|
+
Published = "published",
|
|
1595
|
+
Failed = "failed"
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
declare class MikroOrmOutboxWriter extends OutboxWriter {
|
|
1599
|
+
write(events: readonly IntegrationEvent[]): Promise<void>;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
declare const OUTBOX_PUBLISHER_OPTIONS: unique symbol;
|
|
1603
|
+
interface OutboxPublisherOptions {
|
|
1604
|
+
readonly batchSize: number;
|
|
1605
|
+
readonly maxRetryCount: number;
|
|
1606
|
+
readonly retryDelayMs: number;
|
|
1607
|
+
readonly lockTimeoutMs: number;
|
|
1608
|
+
readonly publisherId: string;
|
|
1609
|
+
}
|
|
1610
|
+
type OutboxPublisherOptionsInput = Partial<OutboxPublisherOptions>;
|
|
1611
|
+
declare const DEFAULT_OUTBOX_PUBLISHER_OPTIONS: OutboxPublisherOptions;
|
|
1612
|
+
declare function normalizeOutboxPublisherOptions(input?: OutboxPublisherOptionsInput): OutboxPublisherOptions;
|
|
1613
|
+
|
|
1614
|
+
declare class OutboxPublisher {
|
|
1615
|
+
private readonly em;
|
|
1616
|
+
private readonly messagePublisher;
|
|
1617
|
+
private readonly logger;
|
|
1618
|
+
private readonly options;
|
|
1619
|
+
constructor(em: EntityManager, messagePublisher: IntegrationMessagePublisher, logger: Logger, options: OutboxPublisherOptions);
|
|
1620
|
+
publishPending(): Promise<number>;
|
|
1621
|
+
private findPublishableMessages;
|
|
1622
|
+
private claim;
|
|
1623
|
+
private toEnvelope;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
interface ExiumPersistenceOutboxOptions {
|
|
1627
|
+
readonly enabled?: boolean;
|
|
1628
|
+
readonly publisher?: OutboxPublisherOptionsInput;
|
|
1629
|
+
}
|
|
1630
|
+
type ExiumPersistenceDriver = 'postgres' | 'mongo';
|
|
1631
|
+
type ExiumPersistenceEntity = string | EntityClass<AnyEntity> | EntitySchema;
|
|
1632
|
+
interface ExiumPersistenceOptions {
|
|
1633
|
+
readonly driver: ExiumPersistenceDriver;
|
|
1634
|
+
readonly entities: ExiumPersistenceEntity[];
|
|
1635
|
+
readonly outbox?: ExiumPersistenceOutboxOptions;
|
|
1636
|
+
}
|
|
1637
|
+
declare class ExiumPersistenceModule {
|
|
1638
|
+
static forRoot(options: ExiumPersistenceOptions): DynamicModule;
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
declare class MikroOrmUnitOfWork extends UnitOfWork {
|
|
1642
|
+
private readonly rootEntityManager;
|
|
1643
|
+
private readonly eventBus;
|
|
1644
|
+
private readonly integrationEventRegistry;
|
|
1645
|
+
private readonly outboxWriter;
|
|
1646
|
+
private readonly logger;
|
|
1647
|
+
constructor(rootEntityManager: EntityManager, eventBus: EventBus, integrationEventRegistry: IntegrationEventRegistry, outboxWriter: OutboxWriter, logger: Logger);
|
|
1648
|
+
execute<T>(work: () => Promise<T>): Promise<T>;
|
|
1649
|
+
registerAggregate(aggregate: AggregateRoot<any>): void;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
interface MikroOrmRepositoryOptions<TPersistenceEntity extends object> {
|
|
1653
|
+
/**
|
|
1654
|
+
* Persistence entity id field.
|
|
1655
|
+
*
|
|
1656
|
+
* Default: "id"
|
|
1657
|
+
*
|
|
1658
|
+
* Examples:
|
|
1659
|
+
* - Postgres entity: "id"
|
|
1660
|
+
* - Mongo entity: "_id"
|
|
1661
|
+
* - Legacy entity: "uuid"
|
|
1662
|
+
*/
|
|
1663
|
+
readonly idField?: keyof TPersistenceEntity & string;
|
|
1664
|
+
}
|
|
1665
|
+
interface EntityManagerLike {
|
|
1666
|
+
getContext(): EntityManagerLike;
|
|
1667
|
+
findOne(entityName: unknown, where: FilterQuery<any>): Promise<any>;
|
|
1668
|
+
find(entityName: unknown, where: FilterQuery<any>): Promise<any[]>;
|
|
1669
|
+
count(entityName: unknown, where: FilterQuery<any>): Promise<number>;
|
|
1670
|
+
persist(entity: object): void;
|
|
1671
|
+
remove(entity: object): void;
|
|
1672
|
+
}
|
|
1673
|
+
declare abstract class MikroOrmRepository<TPersistenceEntity extends object, TPrimitiveId> {
|
|
1674
|
+
private readonly entityName;
|
|
1675
|
+
private readonly rootEntityManager;
|
|
1676
|
+
private readonly idField;
|
|
1677
|
+
protected constructor(entityName: unknown, rootEntityManager: EntityManagerLike, options?: MikroOrmRepositoryOptions<TPersistenceEntity>);
|
|
1678
|
+
/**
|
|
1679
|
+
* Read operations may run outside explicit transaction.
|
|
1680
|
+
* If a transaction exists, reads use the transaction EntityManager.
|
|
1681
|
+
*/
|
|
1682
|
+
protected get em(): EntityManagerLike;
|
|
1683
|
+
/**
|
|
1684
|
+
* Write operations must be executed inside UnitOfWork transaction.
|
|
1685
|
+
*/
|
|
1686
|
+
protected get transactionalEm(): EntityManagerLike;
|
|
1687
|
+
protected getIdField(): keyof TPersistenceEntity & string;
|
|
1688
|
+
protected createIdFilter(id: TPrimitiveId): FilterQuery<TPersistenceEntity>;
|
|
1689
|
+
protected createIdsFilter(ids: readonly TPrimitiveId[]): FilterQuery<TPersistenceEntity>;
|
|
1690
|
+
protected findOrmById(id: TPrimitiveId): Promise<TPersistenceEntity | null>;
|
|
1691
|
+
protected findOrmByIds(ids: readonly TPrimitiveId[]): Promise<TPersistenceEntity[]>;
|
|
1692
|
+
protected persistOrm(entity: TPersistenceEntity): void;
|
|
1693
|
+
protected removeOrm(entity: TPersistenceEntity): void;
|
|
1694
|
+
protected deleteOrmById(id: TPrimitiveId): Promise<void>;
|
|
1695
|
+
protected existsOrm(id: TPrimitiveId): Promise<boolean>;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
interface PersistenceMapper<TAggregate extends AggregateRoot<TId>, TId extends Id, TPersistenceEntity extends object, TPrimitiveId> {
|
|
1699
|
+
toDomain(entity: TPersistenceEntity): TAggregate;
|
|
1700
|
+
toPersistence(aggregate: TAggregate): TPersistenceEntity;
|
|
1701
|
+
toPersistenceId(id: TId): TPrimitiveId;
|
|
1702
|
+
getPersistenceId(aggregate: TAggregate): TPrimitiveId;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
declare abstract class MikroOrmAggregateRepository<TAggregate extends AggregateRoot<TId>, TId extends Id, TPersistenceEntity extends object, TPrimitiveId> extends MikroOrmRepository<TPersistenceEntity, TPrimitiveId> implements Repository<TAggregate, TId> {
|
|
1706
|
+
private readonly mapper;
|
|
1707
|
+
private readonly unitOfWork;
|
|
1708
|
+
protected constructor(entityName: unknown, rootEntityManager: EntityManagerLike, mapper: PersistenceMapper<TAggregate, TId, TPersistenceEntity, TPrimitiveId>, unitOfWork: UnitOfWork, options?: MikroOrmRepositoryOptions<TPersistenceEntity>);
|
|
1709
|
+
findById(id: TId): Promise<TAggregate | null>;
|
|
1710
|
+
findByIds(ids: readonly TId[]): Promise<TAggregate[]>;
|
|
1711
|
+
save(aggregate: TAggregate): Promise<void>;
|
|
1712
|
+
delete(id: TId): Promise<void>;
|
|
1713
|
+
exists(id: TId): Promise<boolean>;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
interface PersistenceTransactionContext {
|
|
1717
|
+
readonly em: EntityManager;
|
|
1718
|
+
readonly aggregates: Set<AggregateRoot<any>>;
|
|
1719
|
+
}
|
|
1720
|
+
declare const TransactionContext: AsyncLocalStorage<PersistenceTransactionContext>;
|
|
1721
|
+
declare function getTransactionContext(): PersistenceTransactionContext | undefined;
|
|
1722
|
+
declare function getTransactionEntityManager(): EntityManager | undefined;
|
|
1723
|
+
declare function getTransactionAggregates(): Set<AggregateRoot<any>> | undefined;
|
|
1724
|
+
|
|
1725
|
+
declare class TransactionCommandMiddleware implements CommandMiddleware {
|
|
1726
|
+
private readonly unitOfWork;
|
|
1727
|
+
constructor(unitOfWork: UnitOfWork);
|
|
1728
|
+
use<TCommand extends Command<any>>(command: TCommand, next: () => Promise<ResultType<CommandResultOf<TCommand>>>): Promise<ResultType<CommandResultOf<TCommand>>>;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
declare class PersistenceTransactionNotActiveException extends Error {
|
|
1732
|
+
constructor(operation: string);
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
interface ExiumInfrastructureOptions {
|
|
1736
|
+
readonly messaging?: ExiumMessagingOptions;
|
|
1737
|
+
readonly persistence?: ExiumPersistenceOptions;
|
|
1738
|
+
readonly redis?: ExiumRedisOptionsInput;
|
|
1739
|
+
readonly cache?: ExiumCacheInfrastructureOptions;
|
|
1740
|
+
readonly idempotency?: ExiumIdempotencyInfrastructureOptions;
|
|
1741
|
+
}
|
|
1742
|
+
declare class ExiumInfrastructureModule {
|
|
1743
|
+
static forRoot(options?: ExiumInfrastructureOptions): DynamicModule;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
type AnyDatabase = Record<string, any>;
|
|
1747
|
+
declare class KyselyReadEngine<TDatabase extends AnyDatabase = AnyDatabase> implements ReadEngine {
|
|
1748
|
+
private readonly db;
|
|
1749
|
+
constructor(db: Kysely<TDatabase>);
|
|
1750
|
+
findOne<TView>(query: FindOneQuery<TView>): Promise<TView | null>;
|
|
1751
|
+
findMany<TView>(query: FindManyQuery<TView>): Promise<readonly TView[]>;
|
|
1752
|
+
findPage<TView>(query: FindPageQuery<TView>): Promise<Page<TView>>;
|
|
1753
|
+
findCursor<TView>(query: FindCursorQuery<TView>): Promise<CursorPage<TView>>;
|
|
1754
|
+
exists(query: ExistsQuery): Promise<boolean>;
|
|
1755
|
+
count(query: CountQuery): Promise<number>;
|
|
1756
|
+
private createSelect;
|
|
1757
|
+
private createBaseQuery;
|
|
1758
|
+
private applyCriteria;
|
|
1759
|
+
private applySort;
|
|
1760
|
+
private applyCursorPredicate;
|
|
1761
|
+
private toKyselyExpression;
|
|
1762
|
+
private toComparisonExpression;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
interface ExiumModuleOptions {
|
|
1766
|
+
readonly serviceName: string;
|
|
1767
|
+
readonly http?: ExiumHttpOptions;
|
|
1768
|
+
readonly infrastructure?: ExiumInfrastructureOptions;
|
|
1769
|
+
}
|
|
1770
|
+
declare class ExiumModule {
|
|
1771
|
+
static forRoot(options: ExiumModuleOptions): DynamicModule;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
interface ExiumApp {
|
|
1775
|
+
start(): Promise<void>;
|
|
1776
|
+
stop(): Promise<void>;
|
|
1777
|
+
getNestApp(): INestApplication | INestApplicationContext;
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
type ExiumMode = 'http' | 'context';
|
|
1781
|
+
interface ExiumOptions {
|
|
1782
|
+
readonly serviceName: string;
|
|
1783
|
+
readonly mode?: ExiumMode;
|
|
1784
|
+
readonly port?: number;
|
|
1785
|
+
readonly module: Type<unknown> | DynamicModule;
|
|
1786
|
+
readonly shutdownHooks?: boolean;
|
|
1787
|
+
readonly http?: ExiumHttpOptions;
|
|
1788
|
+
/**
|
|
1789
|
+
* Optional framework infrastructure modules.
|
|
1790
|
+
*
|
|
1791
|
+
* If omitted, Exium runs only with config/logger/application layer.
|
|
1792
|
+
*/
|
|
1793
|
+
readonly infrastructure?: ExiumInfrastructureOptions;
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
declare function createExiumApp(options: ExiumOptions): Promise<ExiumApp>;
|
|
1797
|
+
|
|
1798
|
+
declare class ExiumLoggerModule {
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
export { AUDITABLE_METADATA, AUTHORIZATION_METADATA, AggregateRoot, AllowAnonymous, type AndCriteriaNode, ApiResponse, ApplicationMiddlewarePriority, type ApplicationValidationErrorItem, AuditCommandMiddleware, type AuditEvent, type AuditOperationType, type AuditOutcome, AuditQueryMiddleware, AuditWriter, Auditable, AuditableAggregateRoot, AuditableEntity, type AuditableMetadata, type AuditableOptions, AuthorizationCommandMiddleware, AuthorizationException, type AuthorizationFailureReason, type AuthorizationMetadata, AuthorizationQueryMiddleware, type AuthorizationRequirementMode, type BaseReadQuery, type BetweenCriteriaNode, CACHE_QUERY_METADATA, type CacheGetResult, CacheInvalidationCommandMiddleware, type CacheInvalidationMode, CacheKeyFactory, type CacheKeyFactoryInput, type CacheKeyPrefixInput, CacheQuery, type CacheQueryMetadata, CacheQueryMiddleware, type CacheQueryOptions, type CacheSetOptions, CacheStore, CacheVersionService, Command, CommandExecutor, CommandHandler, type CommandMiddleware, type CommandResultOf, type ComparisonCriteriaNode, ConfiguredInternalApiEndpointResolver, ContextCommandMiddleware, ContextPermissionChecker, ContextQueryMiddleware, type CountQuery, Criteria, CriteriaFieldBuilder, type CriteriaNode, type CriteriaOperator, CursorPage, CursorRequest, DEFAULT_EXIUM_HTTP_HEADER_NAMES, DEFAULT_EXIUM_REDIS_OPTIONS, DEFAULT_OUTBOX_PUBLISHER_OPTIONS, DEFAULT_RABBITMQ_OPTIONS, DefaultCacheKeyFactory, DefaultIdempotencyFingerprintFactory, DefaultIdempotencyKeyResolver, type Auditable$1 as DomainAuditable, DomainEvent, DomainService, DuplicateHandlerException, EXIUM_HTTP_API_METADATA, EXIUM_HTTP_OPTIONS, EXIUM_REDIS_CLIENT, EXIUM_REDIS_OPTIONS, Entity, ErrorResult, EventBus, EventHandler, type ExistsQuery, type ExiumApp, ExiumApplicationModule, type ExiumCacheInfrastructureDriver, ExiumCacheInfrastructureModule, type ExiumCacheInfrastructureOptions, ExiumConfigModule, ExiumConfigService, ExiumContextService, ExiumEnvironment, ExiumExceptionFilter, type ExiumExecutionContext, type ExiumHttpAdapter, ExiumHttpContextInterceptor, ExiumHttpDiscoveryService, type ExiumHttpHeaderNames, ExiumHttpModule, type ExiumHttpOptions, type ExiumIdempotencyInfrastructureDriver, ExiumIdempotencyInfrastructureModule, type ExiumIdempotencyInfrastructureOptions, ExiumInfrastructureModule, type ExiumInfrastructureOptions, ExiumInternalApiClient, ExiumInternalApiEndpointResolver, ExiumInternalApiRegistry, ExiumLoggerModule, type ExiumMessagingDriver, ExiumMessagingModule, type ExiumMessagingOptions, type ExiumMode, ExiumModule, type ExiumModuleOptions, type ExiumOperationType, type ExiumOptions, type ExiumPersistenceDriver, ExiumPersistenceModule, type ExiumPersistenceOptions, type ExiumPersistenceOutboxOptions, ExiumRedisClient, ExiumRedisModule, type ExiumRedisOptions, type ExiumRedisOptionsInput, ExiumResponseInterceptor, ExternalApi, type ExternalApiOptions, Failure, type FailureKind, type FailureResult, type FailureType, type FindCursorQuery, type FindManyQuery, type FindOneQuery, type FindPageQuery, type Finder, HandleCommand, HandleEvent, HandleInternalApi, HandleQuery, HandlerNotFoundException, type HttpApiExposure, type HttpApiMetadata, type HttpMethod, SuccessResult as HttpSuccessResult, IDEMPOTENT_METADATA, INTEGRATION_EVENT_MAPPER_METADATA, INTERNAL_API_HANDLER_METADATA, INVALIDATE_CACHE_METADATA, Id, type IdempotencyBeginInput, type IdempotencyBeginResult, type IdempotencyBeginStatus, IdempotencyCommandMiddleware, type IdempotencyCompleteInput, IdempotencyException, type IdempotencyExceptionDetails, type IdempotencyFailInput, type IdempotencyFailureReason, IdempotencyFingerprintFactory, type IdempotencyFingerprintFactoryInput, IdempotencyKeyResolver, type IdempotencyKeyResolverInput, IdempotencyStore, Idempotent, type IdempotentMetadata, type IdempotentOptions, type InCriteriaNode, InMemoryCacheVersionService, IntegrationEvent, IntegrationEventMapper, IntegrationEventRegistry, type IntegrationMessageEnvelope, IntegrationMessagePublisher, InternalApi, type InternalApiCall, type InternalApiHandler, type InternalApiHandlerContext, type InternalApiHandlerMetadata, type InternalApiMode, type InternalApiOptions, type InternalApiQueryScalar, type InternalApiQueryValue, InvalidateCache, type InvalidateCacheMetadata, type InvalidateCacheOptions, type IsNotNullCriteriaNode, type IsNullCriteriaNode, Join, JoinBuilder, KyselyReadEngine, LoggingCommandMiddleware, LoggingQueryMiddleware, MikroOrmAggregateRepository, MikroOrmOutboxWriter, MikroOrmRepository, type MikroOrmRepositoryOptions, MikroOrmUnitOfWork, NonAuditable, NonCacheable, NonIdempotent, NonTransactional, NoopAuditWriter, NoopCacheStore, NoopIdempotencyStore, NoopIntegrationMessagePublisher, NoopOutboxWriter, type NotCriteriaNode, OUTBOX_PUBLISHER_OPTIONS, type OrCriteriaNode, OutboxMessageEntity, OutboxMessageStatus, OutboxPublisher, type OutboxPublisherOptions, type OutboxPublisherOptionsInput, OutboxWriter, Page, PageRequest, type PageRequestOptions, type PermissionCheckInput, type PermissionCheckResult, PermissionChecker, type PersistenceMapper, type PersistenceTransactionContext, PersistenceTransactionNotActiveException, PrimitiveValueObject, Query, QueryExecutor, QueryHandler, type QueryMiddleware, QueryResult, type QueryResultOf, RABBITMQ_OPTIONS, type RabbitMqExchangeType, RabbitMqIntegrationMessagePublisher, type RabbitMqOptions, type RabbitMqOptionsInput, type ReadEngine, ReadFieldNotFoundException, type ReadModel, ReadOperationNotSupportedException, ReadQueryException, type ReadSource, RedisCacheStore, RedisCacheVersionService, RedisIdempotencyStore, RegisterCommandMiddleware, RegisterIntegrationEventMapper, RegisterQueryMiddleware, type RegisteredInternalApiHandler, type Repository, RequireAnyPermission, RequireAnyRole, RequirePermission, RequireRole, type ResolvedExiumHttpOptions, Result, type ResultType, type RowMapper, SKIP_VALIDATION_METADATA, SkipValidation, Sort, type SortDirection, SortDirectionBuilder, type SortField, type SortNulls, Specification, type SqlJoin, type SqlJoinOnRef, type SqlJoinOperator, type SqlJoinType, SqlReadSource, type SqlReadSourceDefinition, SuccessCursorResult, SuccessDataResult, SuccessListResult, SuccessPageResult, type SuccessResult$1 as SuccessResult, TRANSACTIONAL_METADATA, TransactionCommandMiddleware, TransactionContext, Transactional, UnitOfWork, ValidationCommandMiddleware, ValidationQueryMiddleware, ValueObject, type Versionable, type View, createExiumApp, defineHttpApiMetadata, getHttpApiMetadata, getInternalApiHandlerMetadata, getTransactionAggregates, getTransactionContext, getTransactionEntityManager, isAuditable, isVersionable, normalizeExiumRedisOptions, normalizeOutboxPublisherOptions, normalizeRabbitMqOptions, resolveExiumHttpOptions };
|