@noildm/contracts 1.0.6 → 1.0.8

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
+ }
@@ -0,0 +1,23 @@
1
+ import { Observable } from "rxjs";
2
+ import { Empty as Empty1 } from "./google/protobuf/empty";
3
+ export declare const protobufPackage = "test.v1";
4
+ export interface TestRequest {
5
+ testRequest: string;
6
+ }
7
+ export interface TestResponse {
8
+ testResponse: string;
9
+ }
10
+ export interface Empty {
11
+ empty: Empty1 | undefined;
12
+ }
13
+ export declare const TEST_V1_PACKAGE_NAME = "test.v1";
14
+ export interface TestServiceClient {
15
+ test(request: TestRequest): Observable<TestResponse>;
16
+ ping(request: Empty): Observable<Empty>;
17
+ }
18
+ export interface TestServiceController {
19
+ test(request: TestRequest): Promise<TestResponse> | Observable<TestResponse> | TestResponse;
20
+ ping(request: Empty): Promise<Empty> | Observable<Empty> | Empty;
21
+ }
22
+ export declare function TestServiceControllerMethods(): (constructor: Function) => void;
23
+ export declare const TEST_SERVICE_NAME = "TestService";
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.11.2
5
+ // protoc v6.33.5
6
+ // source: test.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.TEST_SERVICE_NAME = exports.TEST_V1_PACKAGE_NAME = exports.protobufPackage = void 0;
9
+ exports.TestServiceControllerMethods = TestServiceControllerMethods;
10
+ /* eslint-disable */
11
+ const microservices_1 = require("@nestjs/microservices");
12
+ exports.protobufPackage = "test.v1";
13
+ exports.TEST_V1_PACKAGE_NAME = "test.v1";
14
+ function TestServiceControllerMethods() {
15
+ return function (constructor) {
16
+ const grpcMethods = ["test", "ping"];
17
+ for (const method of grpcMethods) {
18
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
19
+ (0, microservices_1.GrpcMethod)("TestService", method)(constructor.prototype[method], method, descriptor);
20
+ }
21
+ const grpcStreamMethods = [];
22
+ for (const method of grpcStreamMethods) {
23
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
24
+ (0, microservices_1.GrpcStreamMethod)("TestService", method)(constructor.prototype[method], method, descriptor);
25
+ }
26
+ };
27
+ }
28
+ exports.TEST_SERVICE_NAME = "TestService";
package/gen/test.ts ADDED
@@ -0,0 +1,55 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.2
4
+ // protoc v6.33.5
5
+ // source: test.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+ import { Empty as Empty1 } from "./google/protobuf/empty";
11
+
12
+ export const protobufPackage = "test.v1";
13
+
14
+ export interface TestRequest {
15
+ testRequest: string;
16
+ }
17
+
18
+ export interface TestResponse {
19
+ testResponse: string;
20
+ }
21
+
22
+ export interface Empty {
23
+ empty: Empty1 | undefined;
24
+ }
25
+
26
+ export const TEST_V1_PACKAGE_NAME = "test.v1";
27
+
28
+ export interface TestServiceClient {
29
+ test(request: TestRequest): Observable<TestResponse>;
30
+
31
+ ping(request: Empty): Observable<Empty>;
32
+ }
33
+
34
+ export interface TestServiceController {
35
+ test(request: TestRequest): Promise<TestResponse> | Observable<TestResponse> | TestResponse;
36
+
37
+ ping(request: Empty): Promise<Empty> | Observable<Empty> | Empty;
38
+ }
39
+
40
+ export function TestServiceControllerMethods() {
41
+ return function (constructor: Function) {
42
+ const grpcMethods: string[] = ["test", "ping"];
43
+ for (const method of grpcMethods) {
44
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
45
+ GrpcMethod("TestService", method)(constructor.prototype[method], method, descriptor);
46
+ }
47
+ const grpcStreamMethods: string[] = [];
48
+ for (const method of grpcStreamMethods) {
49
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
50
+ GrpcStreamMethod("TestService", method)(constructor.prototype[method], method, descriptor);
51
+ }
52
+ };
53
+ }
54
+
55
+ export const TEST_SERVICE_NAME = "TestService";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noildm/contracts",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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",
@@ -0,0 +1,21 @@
1
+ syntax = "proto3";
2
+
3
+ package test.v1;
4
+
5
+ import "google/protobuf/empty.proto";//emty object
6
+ service TestService {
7
+ rpc Test(TestRequest) returns (TestResponse);
8
+ rpc Ping (Empty) returns (Empty);
9
+ }
10
+
11
+ message TestRequest {
12
+ string test_request = 1;
13
+ }
14
+
15
+ message TestResponse {
16
+ string test_response =1;
17
+ }
18
+
19
+ message Empty {
20
+ google.protobuf.Empty empty = 1;
21
+ }