@wenlarge/communication 1.0.2 → 1.0.4

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.
@@ -27,6 +27,24 @@ export interface Company {
27
27
  export interface CompanyUser {
28
28
  company?: Company | undefined;
29
29
  }
30
+ export interface InviteToCompanyRequest {
31
+ companyId: string;
32
+ email: string;
33
+ }
34
+ export interface InviteToCompanyResponse {
35
+ id: string;
36
+ companyId: string;
37
+ email: string;
38
+ }
39
+ export interface UpdateInviteStatusRequest {
40
+ inviteId: string;
41
+ userId: string;
42
+ status: string;
43
+ }
44
+ export interface UpdateInviteStatusResponse {
45
+ id: string;
46
+ status: string;
47
+ }
30
48
  export interface GetMeResponse {
31
49
  id: string;
32
50
  name: string;
@@ -40,11 +58,15 @@ export interface AuthServiceClient {
40
58
  login(request: LoginRequest, metadata?: Metadata): Observable<LoginResponse>;
41
59
  register(request: RegisterRequest, metadata?: Metadata): Observable<Empty>;
42
60
  getMe(request: GetMeRequest, metadata?: Metadata): Observable<GetMeResponse>;
61
+ inviteToCompany(request: InviteToCompanyRequest, metadata?: Metadata): Observable<InviteToCompanyResponse>;
62
+ updateInviteStatus(request: UpdateInviteStatusRequest, metadata?: Metadata): Observable<UpdateInviteStatusResponse>;
43
63
  }
44
64
  export interface AuthServiceController {
45
65
  login(request: LoginRequest, metadata?: Metadata): Promise<LoginResponse> | Observable<LoginResponse> | LoginResponse;
46
66
  register(request: RegisterRequest, metadata?: Metadata): void;
47
67
  getMe(request: GetMeRequest, metadata?: Metadata): Promise<GetMeResponse> | Observable<GetMeResponse> | GetMeResponse;
68
+ inviteToCompany(request: InviteToCompanyRequest, metadata?: Metadata): Promise<InviteToCompanyResponse> | Observable<InviteToCompanyResponse> | InviteToCompanyResponse;
69
+ updateInviteStatus(request: UpdateInviteStatusRequest, metadata?: Metadata): Promise<UpdateInviteStatusResponse> | Observable<UpdateInviteStatusResponse> | UpdateInviteStatusResponse;
48
70
  }
49
71
  export declare function AuthServiceControllerMethods(): (constructor: Function) => void;
50
72
  export declare const AUTH_SERVICE_NAME = "AuthService";
@@ -12,7 +12,7 @@ exports.protobufPackage = "auth";
12
12
  exports.AUTH_PACKAGE_NAME = "auth";
13
13
  function AuthServiceControllerMethods() {
14
14
  return function (constructor) {
15
- const grpcMethods = ["login", "register", "getMe"];
15
+ const grpcMethods = ["login", "register", "getMe", "inviteToCompany", "updateInviteStatus"];
16
16
  for (const method of grpcMethods) {
17
17
  const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
18
18
  (0, microservices_1.GrpcMethod)("AuthService", method)(constructor.prototype[method], method, descriptor);
@@ -0,0 +1,8 @@
1
+ import { DynamicModule } from "@nestjs/common";
2
+ export interface GrpcClientModuleOptions {
3
+ authServiceUrl: string;
4
+ projectServiceUrl: string;
5
+ }
6
+ export declare class GrpcClientModule {
7
+ static forRoot(options: GrpcClientModuleOptions): DynamicModule;
8
+ }
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.GrpcClientModule = void 0;
42
+ const common_1 = require("@nestjs/common");
43
+ const microservices_1 = require("@nestjs/microservices");
44
+ const path_1 = require("path");
45
+ const auth_1 = require("../generated/auth");
46
+ const project_1 = require("../generated/project");
47
+ const auth_config_1 = require("../config/auth-config");
48
+ const project_config_1 = require("../config/project-config");
49
+ let GrpcClientModule = (() => {
50
+ let _classDecorators = [(0, common_1.Module)({})];
51
+ let _classDescriptor;
52
+ let _classExtraInitializers = [];
53
+ let _classThis;
54
+ var GrpcClientModule = _classThis = class {
55
+ static forRoot(options) {
56
+ return {
57
+ module: GrpcClientModule,
58
+ global: true,
59
+ imports: [
60
+ microservices_1.ClientsModule.register([
61
+ {
62
+ name: auth_1.AUTH_PACKAGE_NAME,
63
+ transport: microservices_1.Transport.GRPC,
64
+ options: {
65
+ package: auth_1.AUTH_PACKAGE_NAME,
66
+ protoPath: auth_config_1.AUTH_PROTO_PATH.map((p) => (0, path_1.join)(__dirname, "../../" + p)),
67
+ url: options.authServiceUrl,
68
+ loader: {
69
+ keepCase: true,
70
+ longs: String,
71
+ enums: String,
72
+ defaults: true,
73
+ oneofs: true,
74
+ },
75
+ },
76
+ },
77
+ {
78
+ name: project_1.PROJECT_PACKAGE_NAME,
79
+ transport: microservices_1.Transport.GRPC,
80
+ options: {
81
+ package: project_1.PROJECT_PACKAGE_NAME,
82
+ protoPath: project_config_1.PROJECT_PROTO_PATH.map((p) => (0, path_1.join)(__dirname, "../../" + p)),
83
+ url: options.projectServiceUrl,
84
+ loader: {
85
+ keepCase: true,
86
+ longs: String,
87
+ enums: String,
88
+ defaults: true,
89
+ oneofs: true,
90
+ },
91
+ },
92
+ },
93
+ ]),
94
+ ],
95
+ exports: [microservices_1.ClientsModule],
96
+ };
97
+ }
98
+ };
99
+ __setFunctionName(_classThis, "GrpcClientModule");
100
+ (() => {
101
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
102
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
103
+ GrpcClientModule = _classThis = _classDescriptor.value;
104
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
105
+ __runInitializers(_classThis, _classExtraInitializers);
106
+ })();
107
+ return GrpcClientModule = _classThis;
108
+ })();
109
+ exports.GrpcClientModule = GrpcClientModule;
@@ -0,0 +1 @@
1
+ export * from "./grpc-client.module";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./grpc-client.module"), exports);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export * from './helpers/helper';
2
- export * as Auth from './generated/auth';
3
- export * from './config/auth-config';
4
- export * as Project from './generated/project';
5
- export * from './config/project-config';
1
+ export * from "./helpers/helper";
2
+ export * as Auth from "./generated/auth";
3
+ export * from "./config/auth-config";
4
+ export * as Project from "./generated/project";
5
+ export * from "./config/project-config";
6
+ export * from "./grpc-client";
package/dist/index.js CHANGED
@@ -42,3 +42,4 @@ exports.Auth = __importStar(require("./generated/auth"));
42
42
  __exportStar(require("./config/auth-config"), exports);
43
43
  exports.Project = __importStar(require("./generated/project"));
44
44
  __exportStar(require("./config/project-config"), exports);
45
+ __exportStar(require("./grpc-client"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenlarge/communication",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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",
@@ -34,13 +34,13 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@grpc/grpc-js": "^1.13.3",
37
- "@grpc/proto-loader": "^0.6.13",
38
- "rxjs": "^7.8.2"
37
+ "@grpc/proto-loader": "^0.7.15",
38
+ "rxjs": "^7.8.1"
39
39
  },
40
40
  "devDependencies": {
41
- "@nestjs/microservices": "^11.1.0",
41
+ "@nestjs/microservices": "^10.4.20",
42
42
  "@types/node": "^24.9.1",
43
43
  "ts-proto": "^1.152.2",
44
- "typescript": "^5.0.0"
44
+ "typescript": "^5.3.3"
45
45
  }
46
46
  }
package/proto/auth.proto CHANGED
@@ -8,6 +8,8 @@ service AuthService {
8
8
  rpc Login (LoginRequest) returns (LoginResponse);
9
9
  rpc Register (RegisterRequest) returns (google.protobuf.Empty);
10
10
  rpc GetMe (GetMeRequest) returns (GetMeResponse);
11
+ rpc InviteToCompany (InviteToCompanyRequest) returns (InviteToCompanyResponse);
12
+ rpc UpdateInviteStatus (UpdateInviteStatusRequest) returns (UpdateInviteStatusResponse);
11
13
  }
12
14
 
13
15
  message LoginRequest {
@@ -41,6 +43,28 @@ message CompanyUser {
41
43
  Company company = 1;
42
44
  }
43
45
 
46
+ message InviteToCompanyRequest {
47
+ string companyId = 1;
48
+ string email = 2;
49
+ }
50
+
51
+ message InviteToCompanyResponse{
52
+ string id = 1;
53
+ string companyId = 2;
54
+ string email = 3;
55
+ }
56
+
57
+ message UpdateInviteStatusRequest{
58
+ string inviteId = 1;
59
+ string userId =2;
60
+ string status = 3;
61
+ }
62
+
63
+ message UpdateInviteStatusResponse{
64
+ string id = 1 ;
65
+ string status = 2;
66
+ }
67
+
44
68
  message GetMeResponse {
45
69
  string id = 1;
46
70
  string name = 2;
@@ -43,6 +43,28 @@ export interface CompanyUser {
43
43
  company?: Company | undefined;
44
44
  }
45
45
 
46
+ export interface InviteToCompanyRequest {
47
+ companyId: string;
48
+ email: string;
49
+ }
50
+
51
+ export interface InviteToCompanyResponse {
52
+ id: string;
53
+ companyId: string;
54
+ email: string;
55
+ }
56
+
57
+ export interface UpdateInviteStatusRequest {
58
+ inviteId: string;
59
+ userId: string;
60
+ status: string;
61
+ }
62
+
63
+ export interface UpdateInviteStatusResponse {
64
+ id: string;
65
+ status: string;
66
+ }
67
+
46
68
  export interface GetMeResponse {
47
69
  id: string;
48
70
  name: string;
@@ -60,6 +82,10 @@ export interface AuthServiceClient {
60
82
  register(request: RegisterRequest, metadata?: Metadata): Observable<Empty>;
61
83
 
62
84
  getMe(request: GetMeRequest, metadata?: Metadata): Observable<GetMeResponse>;
85
+
86
+ inviteToCompany(request: InviteToCompanyRequest, metadata?: Metadata): Observable<InviteToCompanyResponse>;
87
+
88
+ updateInviteStatus(request: UpdateInviteStatusRequest, metadata?: Metadata): Observable<UpdateInviteStatusResponse>;
63
89
  }
64
90
 
65
91
  export interface AuthServiceController {
@@ -68,11 +94,21 @@ export interface AuthServiceController {
68
94
  register(request: RegisterRequest, metadata?: Metadata): void;
69
95
 
70
96
  getMe(request: GetMeRequest, metadata?: Metadata): Promise<GetMeResponse> | Observable<GetMeResponse> | GetMeResponse;
97
+
98
+ inviteToCompany(
99
+ request: InviteToCompanyRequest,
100
+ metadata?: Metadata,
101
+ ): Promise<InviteToCompanyResponse> | Observable<InviteToCompanyResponse> | InviteToCompanyResponse;
102
+
103
+ updateInviteStatus(
104
+ request: UpdateInviteStatusRequest,
105
+ metadata?: Metadata,
106
+ ): Promise<UpdateInviteStatusResponse> | Observable<UpdateInviteStatusResponse> | UpdateInviteStatusResponse;
71
107
  }
72
108
 
73
109
  export function AuthServiceControllerMethods() {
74
110
  return function (constructor: Function) {
75
- const grpcMethods: string[] = ["login", "register", "getMe"];
111
+ const grpcMethods: string[] = ["login", "register", "getMe", "inviteToCompany", "updateInviteStatus"];
76
112
  for (const method of grpcMethods) {
77
113
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
78
114
  GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);