@wenlarge/communication 1.1.14 → 1.1.17

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 @@
1
+ export declare const NOTIFICATION_PROTO_PATH: string[];
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NOTIFICATION_PROTO_PATH = void 0;
4
+ exports.NOTIFICATION_PROTO_PATH = ["proto/notification.proto"];
@@ -0,0 +1,25 @@
1
+ import { Metadata } from "@grpc/grpc-js";
2
+ import { Observable } from "rxjs";
3
+ import { Empty } from "./google/protobuf/empty";
4
+ export declare const protobufPackage = "notification";
5
+ export interface AddMailRequest {
6
+ to: string;
7
+ subject: string;
8
+ text: string;
9
+ html: string;
10
+ }
11
+ export interface AddSmsRequest {
12
+ to: string;
13
+ body: string;
14
+ }
15
+ export declare const NOTIFICATION_PACKAGE_NAME = "notification";
16
+ export interface NotificationServiceClient {
17
+ addMail(request: AddMailRequest, metadata?: Metadata): Observable<Empty>;
18
+ addSms(request: AddSmsRequest, metadata?: Metadata): Observable<Empty>;
19
+ }
20
+ export interface NotificationServiceController {
21
+ addMail(request: AddMailRequest, metadata?: Metadata): void;
22
+ addSms(request: AddSmsRequest, metadata?: Metadata): void;
23
+ }
24
+ export declare function NotificationServiceControllerMethods(): (constructor: Function) => void;
25
+ export declare const NOTIFICATION_SERVICE_NAME = "NotificationService";
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v1.181.2
5
+ // protoc v7.34.0
6
+ // source: notification.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.NOTIFICATION_SERVICE_NAME = exports.NOTIFICATION_PACKAGE_NAME = exports.protobufPackage = void 0;
9
+ exports.NotificationServiceControllerMethods = NotificationServiceControllerMethods;
10
+ const microservices_1 = require("@nestjs/microservices");
11
+ exports.protobufPackage = "notification";
12
+ exports.NOTIFICATION_PACKAGE_NAME = "notification";
13
+ function NotificationServiceControllerMethods() {
14
+ return function (constructor) {
15
+ const grpcMethods = ["addMail", "addSms"];
16
+ for (const method of grpcMethods) {
17
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
18
+ (0, microservices_1.GrpcMethod)("NotificationService", method)(constructor.prototype[method], method, descriptor);
19
+ }
20
+ const grpcStreamMethods = [];
21
+ for (const method of grpcStreamMethods) {
22
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
23
+ (0, microservices_1.GrpcStreamMethod)("NotificationService", method)(constructor.prototype[method], method, descriptor);
24
+ }
25
+ };
26
+ }
27
+ exports.NOTIFICATION_SERVICE_NAME = "NotificationService";
@@ -8,6 +8,7 @@ export interface GrpcClientModuleOptions {
8
8
  executorCoreServiceUrl: string;
9
9
  executorHttpServiceUrl: string;
10
10
  executorWebhookServiceUrl: string;
11
+ notificationServiceUrl: string;
11
12
  }
12
13
  export declare class GrpcClientModule {
13
14
  static forRoot(options: GrpcClientModuleOptions): DynamicModule;
@@ -50,6 +50,8 @@ const workflow_1 = require("../generated/workflow");
50
50
  const workflow_config_1 = require("../config/workflow-config");
51
51
  const executor_core_1 = require("../generated/executor-core");
52
52
  const executor_core_config_1 = require("../config/executor-core-config");
53
+ const notification_1 = require("../generated/notification");
54
+ const notification_config_1 = require("../config/notification-config");
53
55
  exports.EXECUTOR_HTTP_GRPC_CLIENT = "EXECUTOR_HTTP_GRPC_CLIENT";
54
56
  exports.EXECUTOR_WEBHOOK_GRPC_CLIENT = "EXECUTOR_WEBHOOK_GRPC_CLIENT";
55
57
  let GrpcClientModule = (() => {
@@ -161,6 +163,22 @@ let GrpcClientModule = (() => {
161
163
  },
162
164
  },
163
165
  },
166
+ {
167
+ name: notification_1.NOTIFICATION_SERVICE_NAME,
168
+ transport: microservices_1.Transport.GRPC,
169
+ options: {
170
+ package: notification_1.NOTIFICATION_PACKAGE_NAME,
171
+ protoPath: notification_config_1.NOTIFICATION_PROTO_PATH.map((p) => (0, path_1.join)(__dirname, "../../" + p)),
172
+ url: options.notificationServiceUrl,
173
+ loader: {
174
+ keepCase: true,
175
+ longs: String,
176
+ enums: String,
177
+ defaults: true,
178
+ oneofs: true,
179
+ },
180
+ },
181
+ },
164
182
  ]),
165
183
  ],
166
184
  exports: [microservices_1.ClientsModule],
@@ -1,2 +1,3 @@
1
- export declare function unwrapStruct(fields: Record<string, any>): Record<string, any>;
2
- export declare function wrapStruct(obj: any): any;
1
+ import { Struct } from "../generated/google/protobuf/struct";
2
+ export declare function normalizeStructLike(value: any): any;
3
+ export declare function wrapStruct(obj: Record<string, any> | null | undefined): Struct | undefined;
@@ -1,30 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unwrapStruct = unwrapStruct;
3
+ exports.normalizeStructLike = normalizeStructLike;
4
4
  exports.wrapStruct = wrapStruct;
5
5
  const struct_1 = require("../generated/google/protobuf/struct");
6
- function unwrapStruct(fields) {
7
- var _a, _b;
8
- const result = {};
9
- for (const key in fields) {
10
- const value = fields[key];
11
- if ("stringValue" in value)
12
- result[key] = value.stringValue;
13
- else if ("numberValue" in value)
14
- result[key] = value.numberValue;
15
- else if ("boolValue" in value)
16
- result[key] = value.boolValue;
17
- else if ("structValue" in value)
18
- result[key] = unwrapStruct((_a = value.structValue.fields) !== null && _a !== void 0 ? _a : {});
19
- else if ("listValue" in value)
20
- result[key] = (_b = value.listValue.values) === null || _b === void 0 ? void 0 : _b.map((v) => unwrapStruct({ tmp: v }).tmp);
21
- else
22
- result[key] = null;
6
+ function normalizeStructLike(value) {
7
+ var _a, _b, _c;
8
+ if (value == null)
9
+ return value;
10
+ if (Array.isArray(value)) {
11
+ return value.map(normalizeStructLike);
23
12
  }
24
- return result;
13
+ if (typeof value !== "object") {
14
+ return value;
15
+ }
16
+ if ("stringValue" in value)
17
+ return value.stringValue;
18
+ if ("numberValue" in value)
19
+ return value.numberValue;
20
+ if ("boolValue" in value)
21
+ return value.boolValue;
22
+ if ("nullValue" in value)
23
+ return null;
24
+ if ("structValue" in value) {
25
+ return normalizeStructLike(value.structValue);
26
+ }
27
+ if ("listValue" in value) {
28
+ return ((_b = (_a = value.listValue) === null || _a === void 0 ? void 0 : _a.values) !== null && _b !== void 0 ? _b : []).map(normalizeStructLike);
29
+ }
30
+ if ("fields" in value) {
31
+ const out = {};
32
+ for (const [k, v] of Object.entries((_c = value.fields) !== null && _c !== void 0 ? _c : {})) {
33
+ out[k] = normalizeStructLike(v);
34
+ }
35
+ return out;
36
+ }
37
+ const out = {};
38
+ for (const [k, v] of Object.entries(value)) {
39
+ out[k] = normalizeStructLike(v);
40
+ }
41
+ return out;
25
42
  }
26
43
  function wrapStruct(obj) {
27
- if (!obj)
44
+ if (obj == null)
28
45
  return undefined;
29
46
  return struct_1.Struct.wrap(obj);
30
47
  }
package/dist/index.d.ts CHANGED
@@ -9,5 +9,7 @@ export * from "./grpc-client";
9
9
  export * from "./config/executor-core-config";
10
10
  export { Metadata } from "@grpc/grpc-js";
11
11
  export * as ExecutorCore from "./generated/executor-core";
12
+ export * from "./config/notification-config";
13
+ export * as Notification from "./generated/notification";
12
14
  export * from "./kafka/kafka-topics";
13
15
  export { Struct, Value, ListValue } from "./generated/google/protobuf/struct";
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ListValue = exports.Value = exports.Struct = exports.ExecutorCore = exports.Metadata = exports.Project = exports.Workflow = exports.Auth = void 0;
39
+ exports.ListValue = exports.Value = exports.Struct = exports.Notification = exports.ExecutorCore = exports.Metadata = exports.Project = exports.Workflow = exports.Auth = void 0;
40
40
  __exportStar(require("./helpers/helper"), exports);
41
41
  exports.Auth = __importStar(require("./generated/auth"));
42
42
  __exportStar(require("./config/auth-config"), exports);
@@ -49,6 +49,8 @@ __exportStar(require("./config/executor-core-config"), exports);
49
49
  var grpc_js_1 = require("@grpc/grpc-js");
50
50
  Object.defineProperty(exports, "Metadata", { enumerable: true, get: function () { return grpc_js_1.Metadata; } });
51
51
  exports.ExecutorCore = __importStar(require("./generated/executor-core"));
52
+ __exportStar(require("./config/notification-config"), exports);
53
+ exports.Notification = __importStar(require("./generated/notification"));
52
54
  __exportStar(require("./kafka/kafka-topics"), exports);
53
55
  var struct_1 = require("./generated/google/protobuf/struct");
54
56
  Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return struct_1.Struct; } });
@@ -2,4 +2,6 @@ export declare const KafkaTopics: {
2
2
  readonly EXECUTION_COMPLETED: "execution.completed";
3
3
  readonly EXECUTION_FAILED: "execution.failed";
4
4
  readonly EXECUTION_WAITING: "execution.waiting";
5
+ readonly NOTIFICATION_EMAIL: "notification.email";
6
+ readonly NOTIFICATION_SMS: "notification.sms";
5
7
  };
@@ -5,4 +5,6 @@ exports.KafkaTopics = {
5
5
  EXECUTION_COMPLETED: "execution.completed",
6
6
  EXECUTION_FAILED: "execution.failed",
7
7
  EXECUTION_WAITING: "execution.waiting",
8
+ NOTIFICATION_EMAIL: "notification.email",
9
+ NOTIFICATION_SMS: "notification.sms",
8
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenlarge/communication",
3
- "version": "1.1.14",
3
+ "version": "1.1.17",
4
4
  "description": "Shared gRPC proto interfaces and generated clients for Wenlarge microservices.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "src/generated"
11
11
  ],
12
12
  "scripts": {
13
- "proto:build": "npx protoc --plugin=protoc-gen-ts_proto=%CD%\\node_modules\\.bin\\protoc-gen-ts_proto.cmd --proto_path=proto --ts_proto_out=src/generated proto/*.proto --ts_proto_opt=nestJs=true,esModuleInterop=true,forceLong=string,useOptionals=messages,useDate=true,addGrpcMetadata=true,stringEnums=true",
13
+ "proto:build": "npx protoc --plugin=node_modules/.bin/protoc-gen-ts_proto.cmd --proto_path=proto --ts_proto_out=src/generated proto/*.proto --ts_proto_opt=nestJs=true,esModuleInterop=true,forceLong=string,useOptionals=messages,useDate=true,addGrpcMetadata=true,stringEnums=true",
14
14
  "build": "npm run proto:build && tsc",
15
15
  "prepare": "npm run build"
16
16
  },
@@ -38,6 +38,7 @@
38
38
  "rxjs": "^7.8.1"
39
39
  },
40
40
  "devDependencies": {
41
+ "@bufbuild/buf": "^1.66.1",
41
42
  "@nestjs/microservices": "^10.4.20",
42
43
  "@types/node": "^24.9.1",
43
44
  "ts-proto": "^1.152.2",
@@ -0,0 +1,22 @@
1
+ syntax = "proto3";
2
+
3
+ import "google/protobuf/empty.proto";
4
+
5
+ package notification;
6
+
7
+ service NotificationService {
8
+ rpc AddMail (AddMailRequest) returns (google.protobuf.Empty);
9
+ rpc AddSms (AddSmsRequest) returns (google.protobuf.Empty);
10
+ }
11
+
12
+ message AddMailRequest {
13
+ string to = 1;
14
+ string subject = 2;
15
+ string text = 3;
16
+ string html = 4;
17
+ }
18
+
19
+ message AddSmsRequest {
20
+ string to = 1;
21
+ string body = 2;
22
+ }
@@ -0,0 +1,56 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v1.181.2
4
+ // protoc v7.34.0
5
+ // source: notification.proto
6
+
7
+ /* eslint-disable */
8
+ import { Metadata } from "@grpc/grpc-js";
9
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
10
+ import { Observable } from "rxjs";
11
+ import { Empty } from "./google/protobuf/empty";
12
+
13
+ export const protobufPackage = "notification";
14
+
15
+ export interface AddMailRequest {
16
+ to: string;
17
+ subject: string;
18
+ text: string;
19
+ html: string;
20
+ }
21
+
22
+ export interface AddSmsRequest {
23
+ to: string;
24
+ body: string;
25
+ }
26
+
27
+ export const NOTIFICATION_PACKAGE_NAME = "notification";
28
+
29
+ export interface NotificationServiceClient {
30
+ addMail(request: AddMailRequest, metadata?: Metadata): Observable<Empty>;
31
+
32
+ addSms(request: AddSmsRequest, metadata?: Metadata): Observable<Empty>;
33
+ }
34
+
35
+ export interface NotificationServiceController {
36
+ addMail(request: AddMailRequest, metadata?: Metadata): void;
37
+
38
+ addSms(request: AddSmsRequest, metadata?: Metadata): void;
39
+ }
40
+
41
+ export function NotificationServiceControllerMethods() {
42
+ return function (constructor: Function) {
43
+ const grpcMethods: string[] = ["addMail", "addSms"];
44
+ for (const method of grpcMethods) {
45
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
46
+ GrpcMethod("NotificationService", method)(constructor.prototype[method], method, descriptor);
47
+ }
48
+ const grpcStreamMethods: string[] = [];
49
+ for (const method of grpcStreamMethods) {
50
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
51
+ GrpcStreamMethod("NotificationService", method)(constructor.prototype[method], method, descriptor);
52
+ }
53
+ };
54
+ }
55
+
56
+ export const NOTIFICATION_SERVICE_NAME = "NotificationService";