@orion-js/echoes 4.4.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/echo/index.d.ts +5 -5
- package/dist/errors.d.ts +26 -0
- package/dist/events/EventBus.d.ts +22 -0
- package/dist/events/EventTransport.d.ts +17 -0
- package/dist/events/PulseManager.d.ts +14 -0
- package/dist/events/createEventBus.d.ts +10 -0
- package/dist/index.cjs +744 -235
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +731 -234
- package/dist/index.js.map +1 -1
- package/dist/publish/index.d.ts +1 -1
- package/dist/request/getSignature.d.ts +1 -1
- package/dist/requestsHandler/index.d.ts +18 -1
- package/dist/runtime.d.ts +49 -0
- package/dist/schema.d.ts +42 -0
- package/dist/startService/KafkaManager.d.ts +25 -19
- package/dist/types.d.ts +129 -16
- package/package.json +15 -10
package/dist/echo/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { EchoesSchema } from '../schema';
|
|
2
|
+
import { EchoConfig, EchoEventConfig, EchoRequestConfig, EchoType } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated Use createEchoRequest and createEchoEvent instead
|
|
5
5
|
*/
|
|
6
|
-
declare const echo: <TParamsSchema extends
|
|
7
|
-
export declare function createEchoRequest<TParamsSchema extends
|
|
8
|
-
export declare function createEchoEvent<TParamsSchema extends
|
|
6
|
+
declare const echo: <TParamsSchema extends EchoesSchema, TReturnsSchema extends EchoesSchema, TEchoType extends 'event' | 'request'>(options: EchoConfig<TParamsSchema, TReturnsSchema, TEchoType>) => EchoType<TParamsSchema, TReturnsSchema, TEchoType>;
|
|
7
|
+
export declare function createEchoRequest<TParamsSchema extends EchoesSchema, TReturnsSchema extends EchoesSchema>(options: EchoRequestConfig<TParamsSchema, TReturnsSchema>): EchoType<TParamsSchema, TReturnsSchema, 'request'>;
|
|
8
|
+
export declare function createEchoEvent<TParamsSchema extends EchoesSchema, TReturnsSchema extends EchoesSchema>(options: EchoEventConfig<TParamsSchema, TReturnsSchema>): EchoType<TParamsSchema, TReturnsSchema, 'event'>;
|
|
9
9
|
export { echo };
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface EchoesErrorInfo {
|
|
2
|
+
error: string;
|
|
3
|
+
message: string;
|
|
4
|
+
extra?: any;
|
|
5
|
+
validationErrors?: Record<string, string>;
|
|
6
|
+
labels?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export declare class EchoesUserError extends Error {
|
|
9
|
+
readonly isEchoesError = true;
|
|
10
|
+
readonly isOrionError = true;
|
|
11
|
+
readonly isUserError = true;
|
|
12
|
+
readonly code: string;
|
|
13
|
+
readonly extra: any;
|
|
14
|
+
constructor(code: string, message?: string, extra?: any);
|
|
15
|
+
getInfo(): EchoesErrorInfo;
|
|
16
|
+
}
|
|
17
|
+
export declare class EchoesValidationError extends Error {
|
|
18
|
+
readonly isEchoesError = true;
|
|
19
|
+
readonly isOrionError = true;
|
|
20
|
+
readonly isValidationError = true;
|
|
21
|
+
readonly code = "validationError";
|
|
22
|
+
readonly validationErrors: Record<string, string>;
|
|
23
|
+
readonly labels: Record<string, string>;
|
|
24
|
+
constructor(validationErrors: Record<string, string>, labels?: Record<string, string>);
|
|
25
|
+
getInfo(): EchoesErrorInfo;
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EchoesEventTransportName, EchoesMap, PublishOptions } from '../types';
|
|
2
|
+
import type { EventTransport } from './EventTransport';
|
|
3
|
+
export interface EventBusOptions {
|
|
4
|
+
echoes: EchoesMap;
|
|
5
|
+
transports: Partial<Record<EchoesEventTransportName, EventTransport>>;
|
|
6
|
+
consumeFrom: EchoesEventTransportName[];
|
|
7
|
+
publishTo?: EchoesEventTransportName;
|
|
8
|
+
}
|
|
9
|
+
export default class EventBus {
|
|
10
|
+
private readonly echoes;
|
|
11
|
+
private readonly transports;
|
|
12
|
+
private readonly consumeFrom;
|
|
13
|
+
private readonly publishTo?;
|
|
14
|
+
private readonly startedTransports;
|
|
15
|
+
private started;
|
|
16
|
+
private closed;
|
|
17
|
+
constructor(options: EventBusOptions);
|
|
18
|
+
start(): Promise<void>;
|
|
19
|
+
publish<TParams = any>(options: PublishOptions<TParams>): Promise<any>;
|
|
20
|
+
close(): Promise<void>;
|
|
21
|
+
private handleEvent;
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EchoesEventTransportName, EchoesReceivedEvent, PublishOptions } from '../types';
|
|
2
|
+
export interface EventSubscriptionDefinition {
|
|
3
|
+
topic: string;
|
|
4
|
+
attemptsBeforeDeadLetter?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface EventTransportStartOptions {
|
|
7
|
+
consume: boolean;
|
|
8
|
+
publish: boolean;
|
|
9
|
+
subscriptions: EventSubscriptionDefinition[];
|
|
10
|
+
onEvent(event: EchoesReceivedEvent): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export interface EventTransport {
|
|
13
|
+
readonly name: EchoesEventTransportName;
|
|
14
|
+
start(options: EventTransportStartOptions): Promise<void>;
|
|
15
|
+
publish<TParams = any>(options: PublishOptions<TParams>): Promise<any>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EchoesPulseEventsConfig, PublishOptions } from '../types';
|
|
2
|
+
import type { EventTransport, EventTransportStartOptions } from './EventTransport';
|
|
3
|
+
export default class PulseManager implements EventTransport {
|
|
4
|
+
readonly name: 'pulse';
|
|
5
|
+
private readonly options;
|
|
6
|
+
private pulse?;
|
|
7
|
+
private subscriptions;
|
|
8
|
+
constructor(options: EchoesPulseEventsConfig);
|
|
9
|
+
start(options: EventTransportStartOptions): Promise<void>;
|
|
10
|
+
publish<TParams = any>(options: PublishOptions<TParams>): Promise<any>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
private getSubscribeOptions;
|
|
13
|
+
private createReceivedEvent;
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EchoesEventTransportName, EchoesKafkaEventsConfig, EchoesOptions, EchoesPulseEventsConfig } from '../types';
|
|
2
|
+
import EventBus from './EventBus';
|
|
3
|
+
export interface ResolvedEventsConfig {
|
|
4
|
+
kafka?: EchoesKafkaEventsConfig;
|
|
5
|
+
pulse?: EchoesPulseEventsConfig;
|
|
6
|
+
consumeFrom: EchoesEventTransportName[];
|
|
7
|
+
publishTo?: EchoesEventTransportName;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveEventsConfig(options: EchoesOptions): ResolvedEventsConfig | undefined;
|
|
10
|
+
export default function createEventBus(options: EchoesOptions): EventBus;
|