@noildm/contracts 1.0.5 → 1.0.7

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.
@@ -0,0 +1,6 @@
1
+ import { RabbitExchangeConfig } from '../shared/rabbit-exchange-config.interface';
2
+
3
+ export const EXCHANGE_MAIL: RabbitExchangeConfig = {
4
+ name: 'mail',
5
+ type: 'direct',
6
+ };
@@ -0,0 +1,11 @@
1
+ export interface SendMailRequest {
2
+ from?: string;
3
+
4
+ toEmail: string;
5
+
6
+ subject: string;
7
+
8
+ text: string;
9
+
10
+ html?: string;
11
+ }
@@ -0,0 +1,14 @@
1
+ import { EXCHANGE_MAIL } from "../../exchanges/mail.exchange";
2
+ import { AmqpBaseRequest } from "../../shared/amqp-base-request.interface";
3
+ import { QueueDeclaration } from "../../shared/queue-declaration.interface";
4
+ import { SendMailRequest } from "./request-type";
5
+
6
+ export namespace SendMailContract {
7
+ export const queue: QueueDeclaration<unknown> = {
8
+ exchange: EXCHANGE_MAIL,
9
+ queue: `${EXCHANGE_MAIL.name}-send`,
10
+ routingKey: `${EXCHANGE_MAIL.name}-send`,
11
+ queueOptions: { durable: true },
12
+ };
13
+ export type request = AmqpBaseRequest<SendMailRequest>;
14
+ }
@@ -0,0 +1,8 @@
1
+ export interface AmqpBaseRequest<T = unknown> {
2
+ type: string;
3
+ payload: T;
4
+ requestId: string;
5
+ timeStamp: string;
6
+ exchange?: string;
7
+ routingKey?: string;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { AmqpBaseRequest } from './amqp-base-request.interface';
2
+
3
+ export interface AmqpBaseResponse<T = unknown> extends AmqpBaseRequest<T> {
4
+ error?: {
5
+ code: string;
6
+ message: string;
7
+ };
8
+ }
@@ -0,0 +1,31 @@
1
+ import { RabbitExchangeConfig } from "./rabbit-exchange-config.interface";
2
+
3
+ interface QueueOptions<ConsumeOptions> {
4
+ durable?: boolean;
5
+ exclusive?: boolean;
6
+ autoDelete?: boolean;
7
+ arguments?: any;
8
+ messageTtl?: number;
9
+ expires?: number;
10
+ deadLetterExchange?: string;
11
+ deadLetterRoutingKey?: string;
12
+ maxLength?: number;
13
+ maxPriority?: number;
14
+ bindQueueArguments?: any;
15
+ /**
16
+ * Set this to the name of the channel you want to consume messages from to enable this feature.
17
+ *
18
+ * If channel does not exist or you haven't specified one, it will use the default channel.
19
+ *
20
+ * For channel to exist it needs to be created in module config.
21
+ */
22
+ channel?: string;
23
+ consumerOptions?: ConsumeOptions;
24
+ }
25
+
26
+ export interface QueueDeclaration<ConsumeOptions> {
27
+ exchange: RabbitExchangeConfig;
28
+ routingKey: string;
29
+ queue: string;
30
+ queueOptions: QueueOptions<ConsumeOptions>;
31
+ }
@@ -0,0 +1,13 @@
1
+ export interface RabbitExchangeConfig {
2
+ name: string;
3
+ type: 'topic' | 'direct' | 'fanout';
4
+ options?: AssertExchange;
5
+ }
6
+
7
+ interface AssertExchange {
8
+ durable?: boolean;
9
+ internal?: boolean;
10
+ autoDelete?: boolean;
11
+ alternateExchange?: string;
12
+ arguments?: unknown | unknown[];
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noildm/contracts",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Protobuf and RabbitMQ contracts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,8 @@
12
12
  "files": [
13
13
  "proto",
14
14
  "gen",
15
- "dist"
15
+ "dist",
16
+ "contracts"
16
17
  ],
17
18
  "dependencies": {
18
19
  "@bufbuild/buf": "^1.65.0",