@orion-js/echoes 3.11.8 → 4.0.0-alpha.2

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.
Files changed (47) hide show
  1. package/dist/index.cjs +74280 -0
  2. package/dist/index.d.ts +124 -0
  3. package/dist/index.js +74244 -0
  4. package/package.json +25 -19
  5. package/LICENSE +0 -21
  6. package/lib/config.d.ts +0 -3
  7. package/lib/config.js +0 -4
  8. package/lib/echo/deserialize.d.ts +0 -1
  9. package/lib/echo/deserialize.js +0 -11
  10. package/lib/echo/index.d.ts +0 -9
  11. package/lib/echo/index.js +0 -29
  12. package/lib/echo/types.d.ts +0 -5
  13. package/lib/echo/types.js +0 -6
  14. package/lib/index.d.ts +0 -7
  15. package/lib/index.js +0 -43
  16. package/lib/publish/index.d.ts +0 -5
  17. package/lib/publish/index.js +0 -29
  18. package/lib/publish/serialize.d.ts +0 -1
  19. package/lib/publish/serialize.js +0 -13
  20. package/lib/request/getPassword.d.ts +0 -1
  21. package/lib/request/getPassword.js +0 -16
  22. package/lib/request/getSignature.d.ts +0 -1
  23. package/lib/request/getSignature.js +0 -15
  24. package/lib/request/getURL.d.ts +0 -1
  25. package/lib/request/getURL.js +0 -16
  26. package/lib/request/index.d.ts +0 -2
  27. package/lib/request/index.js +0 -57
  28. package/lib/request/makeRequest.d.ts +0 -2
  29. package/lib/request/makeRequest.js +0 -26
  30. package/lib/requestsHandler/checkSignature.d.ts +0 -1
  31. package/lib/requestsHandler/checkSignature.js +0 -13
  32. package/lib/requestsHandler/getEcho.d.ts +0 -1
  33. package/lib/requestsHandler/getEcho.js +0 -18
  34. package/lib/requestsHandler/index.d.ts +0 -3
  35. package/lib/requestsHandler/index.js +0 -44
  36. package/lib/service/index.d.ts +0 -8
  37. package/lib/service/index.js +0 -54
  38. package/lib/service/index.test.d.ts +0 -1
  39. package/lib/service/index.test.js +0 -51
  40. package/lib/startService/KafkaManager.d.ts +0 -24
  41. package/lib/startService/KafkaManager.js +0 -146
  42. package/lib/startService/index.d.ts +0 -3
  43. package/lib/startService/index.js +0 -33
  44. package/lib/tests/requests/index.test.d.ts +0 -1
  45. package/lib/tests/requests/index.test.js +0 -99
  46. package/lib/types.d.ts +0 -98
  47. package/lib/types.js +0 -2
@@ -0,0 +1,124 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { Consumer, ConsumerConfig, EachMessagePayload, KafkaConfig, Producer, ProducerConfig } from 'kafkajs';
4
+
5
+ export interface EchoConfig {
6
+ type: "event" | "request";
7
+ resolve(params: any, context?: any): Promise<any>;
8
+ attemptsBeforeDeadLetter?: number;
9
+ }
10
+ export interface EchoType extends EchoConfig {
11
+ onMessage(messageData: EachMessagePayload): Promise<void>;
12
+ onRequest(serializedParams: string): any;
13
+ }
14
+ export interface PublishOptions<TParams = any> {
15
+ topic: string;
16
+ params: TParams;
17
+ acks?: number;
18
+ timeout?: number;
19
+ }
20
+ export interface RequestOptions<TParams> {
21
+ method: string;
22
+ service: string;
23
+ params: TParams;
24
+ retries?: number;
25
+ timeout?: number;
26
+ }
27
+ export interface RequestHandlerResponse {
28
+ result?: any;
29
+ error?: any;
30
+ isUserError?: boolean;
31
+ isValidationError?: boolean;
32
+ errorInfo?: {
33
+ error: string;
34
+ message: string;
35
+ extra?: any;
36
+ validationErrors?: any;
37
+ };
38
+ }
39
+ export interface MakeRequestParams {
40
+ url: string;
41
+ retries?: number;
42
+ timeout?: number;
43
+ data: {
44
+ body: object;
45
+ signature: string;
46
+ };
47
+ }
48
+ export interface RequestMakerResult {
49
+ statusCode: number;
50
+ data: object;
51
+ }
52
+ export type RequestMaker = (options: MakeRequestParams) => Promise<RequestMakerResult>;
53
+ export interface RequestsConfig {
54
+ /**
55
+ * The secret key used to sign all requests. Shared between all your services.
56
+ * You can also set the env var echoes_password or process.env.ECHOES_PASSWORD
57
+ */
58
+ key?: string;
59
+ /**
60
+ * The path of the echoes http receiver. Defaults to /echoes-services
61
+ */
62
+ handlerPath?: string;
63
+ /**
64
+ * Map of all the services that have echoes requests handlers
65
+ */
66
+ services?: {
67
+ [key: string]: string;
68
+ };
69
+ /**
70
+ * A custom function that make the requests to the services. Uses axios by default
71
+ */
72
+ makeRequest?: RequestMaker;
73
+ }
74
+ export interface EchoesMap {
75
+ [key: string]: EchoType;
76
+ }
77
+ export interface EchoesOptions {
78
+ client?: KafkaConfig;
79
+ producer?: ProducerConfig;
80
+ consumer?: ConsumerConfig;
81
+ requests?: RequestsConfig;
82
+ echoes: EchoesMap;
83
+ /**
84
+ * Defaults to true. When true, allows a reconnecting service to read missed messages.
85
+ */
86
+ readTopicsFromBeginning?: boolean;
87
+ /**
88
+ * Defaults to 4. How many partitions to consume concurrently, adjust this with the members to partitions ratio to avoid idle consumers.
89
+ */
90
+ partitionsConsumedConcurrently?: number;
91
+ /**
92
+ * 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.
93
+ */
94
+ membersToPartitionsRatio?: number;
95
+ }
96
+ export interface EchoesConfigHandler {
97
+ producer?: Producer;
98
+ consumer?: Consumer;
99
+ requests?: RequestsConfig;
100
+ echoes?: EchoesMap;
101
+ }
102
+ export function startService(options: EchoesOptions): Promise<void>;
103
+ export declare function stopService(): Promise<void>;
104
+ /**
105
+ * Publish
106
+ */
107
+ export function publish<TParams = any>(options: PublishOptions<TParams>): Promise<import("kafkajs").RecordMetadata[]>;
108
+ export declare const echo: {
109
+ (options: EchoConfig): EchoType;
110
+ types: {
111
+ event: string;
112
+ request: string;
113
+ };
114
+ };
115
+ export function request<TData = any, TParams = any>(options: RequestOptions<TParams>): Promise<TData>;
116
+ export declare function Echoes(): ClassDecorator;
117
+ export interface EchoesPropertyDescriptor extends Omit<PropertyDecorator, "value"> {
118
+ value?: EchoConfig["resolve"];
119
+ }
120
+ export declare function EchoRequest(options?: Omit<EchoConfig, "resolve" | "type">): (target: any, propertyKey: string, descriptor: EchoesPropertyDescriptor) => void;
121
+ export declare function EchoEvent(options?: Omit<EchoConfig, "resolve" | "type">): (target: any, propertyKey: string, descriptor: EchoesPropertyDescriptor) => void;
122
+ export declare function getServiceEchoes(target: any): EchoesMap;
123
+
124
+ export {};