@orion-js/echoes 4.3.2 → 4.4.1
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 +21 -0
- package/dist/config.d.ts +3 -0
- package/dist/echo/deserialize.d.ts +1 -0
- package/dist/echo/index.d.ts +9 -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 +443 -166
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -145
- package/dist/index.js +440 -163
- package/dist/index.js.map +1 -1
- package/dist/publish/index.d.ts +5 -0
- package/dist/publish/serialize.d.ts +1 -0
- package/dist/request/getPassword.d.ts +1 -0
- package/dist/request/getSignature.d.ts +1 -0
- package/dist/request/getURL.d.ts +1 -0
- package/dist/request/index.d.ts +2 -0
- package/dist/request/makeRequest.d.ts +2 -0
- package/dist/requestsHandler/checkSignature.d.ts +1 -0
- package/dist/requestsHandler/getEcho.d.ts +1 -0
- package/dist/requestsHandler/index.d.ts +3 -0
- package/dist/service/index.d.ts +10 -0
- package/dist/startService/KafkaManager.d.ts +29 -0
- package/dist/startService/index.d.ts +3 -0
- package/dist/types.d.ts +198 -0
- package/package.json +24 -16
- package/dist/index.d.cts +0 -145
package/dist/index.d.cts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { SchemaFieldType, InferSchemaType } from '@orion-js/schema';
|
|
2
|
-
import * as kafkajs from 'kafkajs';
|
|
3
|
-
import { EachMessagePayload, Producer, Consumer, KafkaConfig, ProducerConfig, ConsumerConfig } from 'kafkajs';
|
|
4
|
-
|
|
5
|
-
interface EchoRequestConfig<TParamsSchema extends SchemaFieldType, TReturnsSchema extends SchemaFieldType> {
|
|
6
|
-
params?: TParamsSchema;
|
|
7
|
-
returns?: TReturnsSchema;
|
|
8
|
-
resolve(params?: InferSchemaType<TParamsSchema>, context?: any): Promise<InferSchemaType<TReturnsSchema>>;
|
|
9
|
-
attemptsBeforeDeadLetter?: number;
|
|
10
|
-
}
|
|
11
|
-
interface EchoEventConfig<TParamsSchema extends SchemaFieldType, TReturnsSchema extends SchemaFieldType> {
|
|
12
|
-
params?: TParamsSchema;
|
|
13
|
-
returns?: TReturnsSchema;
|
|
14
|
-
resolve(params?: InferSchemaType<TParamsSchema>, context?: any): Promise<InferSchemaType<TReturnsSchema>>;
|
|
15
|
-
attemptsBeforeDeadLetter?: number;
|
|
16
|
-
}
|
|
17
|
-
type EchoConfig<TParamsSchema extends SchemaFieldType, TReturnsSchema extends SchemaFieldType, TEchoType extends 'event' | 'request' = 'event' | 'request'> = (TEchoType extends 'event' ? EchoEventConfig<TParamsSchema, TReturnsSchema> : EchoRequestConfig<TParamsSchema, TReturnsSchema>) & {
|
|
18
|
-
type: TEchoType;
|
|
19
|
-
};
|
|
20
|
-
type EchoType<TParamsSchema extends SchemaFieldType = any, TReturnsSchema extends SchemaFieldType = any, TEchoType extends 'event' | 'request' = 'event' | 'request'> = {
|
|
21
|
-
params?: TParamsSchema;
|
|
22
|
-
returns?: TReturnsSchema;
|
|
23
|
-
attemptsBeforeDeadLetter?: number;
|
|
24
|
-
type: TEchoType;
|
|
25
|
-
resolve(params?: InferSchemaType<TParamsSchema>, context?: any): Promise<InferSchemaType<TReturnsSchema>>;
|
|
26
|
-
onMessage(messageData: EachMessagePayload): Promise<void>;
|
|
27
|
-
onRequest(serializedParams: string): any;
|
|
28
|
-
};
|
|
29
|
-
interface PublishOptions<TParams = any> {
|
|
30
|
-
topic: string;
|
|
31
|
-
params: TParams;
|
|
32
|
-
acks?: number;
|
|
33
|
-
timeout?: number;
|
|
34
|
-
}
|
|
35
|
-
interface RequestOptions<TParams> {
|
|
36
|
-
method: string;
|
|
37
|
-
service: string;
|
|
38
|
-
params: TParams;
|
|
39
|
-
retries?: number;
|
|
40
|
-
timeout?: number;
|
|
41
|
-
}
|
|
42
|
-
interface RequestHandlerResponse {
|
|
43
|
-
result?: any;
|
|
44
|
-
error?: any;
|
|
45
|
-
isUserError?: boolean;
|
|
46
|
-
isValidationError?: boolean;
|
|
47
|
-
errorInfo?: {
|
|
48
|
-
error: string;
|
|
49
|
-
message: string;
|
|
50
|
-
extra?: any;
|
|
51
|
-
validationErrors?: any;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
interface MakeRequestParams {
|
|
55
|
-
url: string;
|
|
56
|
-
retries?: number;
|
|
57
|
-
timeout?: number;
|
|
58
|
-
data: {
|
|
59
|
-
body: object;
|
|
60
|
-
signature: string;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
interface RequestMakerResult {
|
|
64
|
-
statusCode: number;
|
|
65
|
-
data: object;
|
|
66
|
-
}
|
|
67
|
-
type RequestMaker = (options: MakeRequestParams) => Promise<RequestMakerResult>;
|
|
68
|
-
interface RequestsConfig {
|
|
69
|
-
/**
|
|
70
|
-
* The secret key used to sign all requests. Shared between all your services.
|
|
71
|
-
* You can also set the env var echoes_password or process.env.ECHOES_PASSWORD
|
|
72
|
-
*/
|
|
73
|
-
key?: string;
|
|
74
|
-
/**
|
|
75
|
-
* The path of the echoes http receiver. Defaults to /echoes-services
|
|
76
|
-
*/
|
|
77
|
-
handlerPath?: string;
|
|
78
|
-
/**
|
|
79
|
-
* Map of all the services that have echoes requests handlers
|
|
80
|
-
*/
|
|
81
|
-
services?: {
|
|
82
|
-
[key: string]: string;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* A custom function that make the requests to the services. Uses axios by default
|
|
86
|
-
*/
|
|
87
|
-
makeRequest?: RequestMaker;
|
|
88
|
-
}
|
|
89
|
-
interface EchoesMap {
|
|
90
|
-
[key: string]: EchoType<any, any>;
|
|
91
|
-
}
|
|
92
|
-
interface EchoesOptions {
|
|
93
|
-
client?: KafkaConfig;
|
|
94
|
-
producer?: ProducerConfig;
|
|
95
|
-
consumer?: ConsumerConfig;
|
|
96
|
-
requests?: RequestsConfig;
|
|
97
|
-
echoes: EchoesMap;
|
|
98
|
-
/**
|
|
99
|
-
* Defaults to true. When true, allows a reconnecting service to read missed messages.
|
|
100
|
-
*/
|
|
101
|
-
readTopicsFromBeginning?: boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Defaults to 4. How many partitions to consume concurrently, adjust this with the members to partitions ratio to avoid idle consumers.
|
|
104
|
-
*/
|
|
105
|
-
partitionsConsumedConcurrently?: number;
|
|
106
|
-
/**
|
|
107
|
-
* Defaults to 1. How many members are in comparison to partitions, this is used to determine if the consumer group has room for more members. Numbers over 1 leads to idle consumers. Numbers under 1 needs partitionsConsumedConcurrently to be more than 1.
|
|
108
|
-
*/
|
|
109
|
-
membersToPartitionsRatio?: number;
|
|
110
|
-
}
|
|
111
|
-
interface EchoesConfigHandler {
|
|
112
|
-
producer?: Producer;
|
|
113
|
-
consumer?: Consumer;
|
|
114
|
-
requests?: RequestsConfig;
|
|
115
|
-
echoes?: EchoesMap;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
declare function startService(options: EchoesOptions): Promise<void>;
|
|
119
|
-
declare function stopService(): Promise<void>;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Publish
|
|
123
|
-
*/
|
|
124
|
-
declare function publish<TParams = any>(options: PublishOptions<TParams>): Promise<kafkajs.RecordMetadata[]>;
|
|
125
|
-
|
|
126
|
-
declare function request<TData = any, TParams = any>(options: RequestOptions<TParams>): Promise<TData>;
|
|
127
|
-
|
|
128
|
-
interface EchoesPropertyDescriptor extends Omit<PropertyDecorator, 'value'> {
|
|
129
|
-
value?: EchoConfig<any, any>['resolve'];
|
|
130
|
-
}
|
|
131
|
-
declare function Echoes(): (target: any, context: ClassDecoratorContext<any>) => void;
|
|
132
|
-
declare function EchoEvent(): (method: any, context: ClassFieldDecoratorContext | ClassMethodDecoratorContext) => any;
|
|
133
|
-
declare function EchoEvent(options?: Omit<EchoConfig<any, any>, 'resolve' | 'type'>): (method: any, context: ClassMethodDecoratorContext) => any;
|
|
134
|
-
declare function EchoRequest(): (method: any, context: ClassFieldDecoratorContext | ClassMethodDecoratorContext) => any;
|
|
135
|
-
declare function EchoRequest(options?: Omit<EchoConfig<any, any>, 'resolve' | 'type'>): (method: any, context: ClassMethodDecoratorContext) => any;
|
|
136
|
-
declare function getServiceEchoes(target: any): EchoesMap;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated Use createEchoRequest and createEchoEvent instead
|
|
140
|
-
*/
|
|
141
|
-
declare const echo: <TParamsSchema extends SchemaFieldType, TReturnsSchema extends SchemaFieldType, TEchoType extends "event" | "request">(options: EchoConfig<TParamsSchema, TReturnsSchema, TEchoType>) => EchoType<TParamsSchema, TReturnsSchema, TEchoType>;
|
|
142
|
-
declare function createEchoRequest<TParamsSchema extends SchemaFieldType, TReturnsSchema extends SchemaFieldType>(options: EchoRequestConfig<TParamsSchema, TReturnsSchema>): EchoType<TParamsSchema, TReturnsSchema, 'request'>;
|
|
143
|
-
declare function createEchoEvent<TParamsSchema extends SchemaFieldType, TReturnsSchema extends SchemaFieldType>(options: EchoEventConfig<TParamsSchema, TReturnsSchema>): EchoType<TParamsSchema, TReturnsSchema, 'event'>;
|
|
144
|
-
|
|
145
|
-
export { type EchoConfig, EchoEvent, type EchoEventConfig, EchoRequest, type EchoRequestConfig, type EchoType, Echoes, type EchoesConfigHandler, type EchoesMap, type EchoesOptions, type EchoesPropertyDescriptor, type MakeRequestParams, type PublishOptions, type RequestHandlerResponse, type RequestMaker, type RequestMakerResult, type RequestOptions, type RequestsConfig, createEchoEvent, createEchoRequest, echo, getServiceEchoes, publish, request, startService, stopService };
|