@wenlarge/communication 1.0.0
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.
- package/dist/config/auth-config.d.ts +1 -0
- package/dist/config/auth-config.js +6 -0
- package/dist/config/project-config.d.ts +1 -0
- package/dist/config/project-config.js +6 -0
- package/dist/generated/auth.d.ts +50 -0
- package/dist/generated/auth.js +27 -0
- package/dist/generated/google/protobuf/empty.d.ts +13 -0
- package/dist/generated/google/protobuf/empty.js +11 -0
- package/dist/generated/google/protobuf/timestamp.d.ts +108 -0
- package/dist/generated/google/protobuf/timestamp.js +11 -0
- package/dist/generated/project.d.ts +22 -0
- package/dist/generated/project.js +27 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +43 -0
- package/package.json +45 -0
- package/proto/auth.proto +51 -0
- package/proto/project.proto +19 -0
- package/src/generated/auth.ts +88 -0
- package/src/generated/google/protobuf/empty.ts +23 -0
- package/src/generated/google/protobuf/timestamp.ts +118 -0
- package/src/generated/project.ts +54 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AUTH_PROTO_PATH: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PROJECT_PROTO_PATH: string[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Metadata } from "@grpc/grpc-js";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { Empty } from "./google/protobuf/empty";
|
|
4
|
+
export declare const protobufPackage = "auth";
|
|
5
|
+
export interface LoginRequest {
|
|
6
|
+
email: string;
|
|
7
|
+
password: string;
|
|
8
|
+
}
|
|
9
|
+
export interface LoginResponse {
|
|
10
|
+
jwt: string;
|
|
11
|
+
expiresIn: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RegisterRequest {
|
|
14
|
+
name: string;
|
|
15
|
+
email: string;
|
|
16
|
+
password: string;
|
|
17
|
+
}
|
|
18
|
+
export interface GetMeRequest {
|
|
19
|
+
jwt: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Company {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
}
|
|
27
|
+
export interface CompanyUser {
|
|
28
|
+
company?: Company | undefined;
|
|
29
|
+
}
|
|
30
|
+
export interface GetMeResponse {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
email: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
updatedAt: string;
|
|
36
|
+
companyUsersOnUser: CompanyUser[];
|
|
37
|
+
}
|
|
38
|
+
export declare const AUTH_PACKAGE_NAME = "auth";
|
|
39
|
+
export interface AuthServiceClient {
|
|
40
|
+
login(request: LoginRequest, metadata?: Metadata): Observable<LoginResponse>;
|
|
41
|
+
register(request: RegisterRequest, metadata?: Metadata): Observable<Empty>;
|
|
42
|
+
getMe(request: GetMeRequest, metadata?: Metadata): Observable<GetMeResponse>;
|
|
43
|
+
}
|
|
44
|
+
export interface AuthServiceController {
|
|
45
|
+
login(request: LoginRequest, metadata?: Metadata): Promise<LoginResponse> | Observable<LoginResponse> | LoginResponse;
|
|
46
|
+
register(request: RegisterRequest, metadata?: Metadata): void;
|
|
47
|
+
getMe(request: GetMeRequest, metadata?: Metadata): Promise<GetMeResponse> | Observable<GetMeResponse> | GetMeResponse;
|
|
48
|
+
}
|
|
49
|
+
export declare function AuthServiceControllerMethods(): (constructor: Function) => void;
|
|
50
|
+
export declare const AUTH_SERVICE_NAME = "AuthService";
|
|
@@ -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 v3.21.5
|
|
6
|
+
// source: auth.proto
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.AUTH_SERVICE_NAME = exports.AUTH_PACKAGE_NAME = exports.protobufPackage = void 0;
|
|
9
|
+
exports.AuthServiceControllerMethods = AuthServiceControllerMethods;
|
|
10
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
11
|
+
exports.protobufPackage = "auth";
|
|
12
|
+
exports.AUTH_PACKAGE_NAME = "auth";
|
|
13
|
+
function AuthServiceControllerMethods() {
|
|
14
|
+
return function (constructor) {
|
|
15
|
+
const grpcMethods = ["login", "register", "getMe"];
|
|
16
|
+
for (const method of grpcMethods) {
|
|
17
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
18
|
+
(0, microservices_1.GrpcMethod)("AuthService", 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)("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.AUTH_SERVICE_NAME = "AuthService";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const protobufPackage = "google.protobuf";
|
|
2
|
+
/**
|
|
3
|
+
* A generic empty message that you can re-use to avoid defining duplicated
|
|
4
|
+
* empty messages in your APIs. A typical example is to use it as the request
|
|
5
|
+
* or the response type of an API method. For instance:
|
|
6
|
+
*
|
|
7
|
+
* service Foo {
|
|
8
|
+
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
|
9
|
+
* }
|
|
10
|
+
*/
|
|
11
|
+
export interface Empty {
|
|
12
|
+
}
|
|
13
|
+
export declare const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
|
|
@@ -0,0 +1,11 @@
|
|
|
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 v3.21.5
|
|
6
|
+
// source: google/protobuf/empty.proto
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.GOOGLE_PROTOBUF_PACKAGE_NAME = exports.protobufPackage = void 0;
|
|
9
|
+
/* eslint-disable */
|
|
10
|
+
exports.protobufPackage = "google.protobuf";
|
|
11
|
+
exports.GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export declare const protobufPackage = "google.protobuf";
|
|
2
|
+
/**
|
|
3
|
+
* A Timestamp represents a point in time independent of any time zone or local
|
|
4
|
+
* calendar, encoded as a count of seconds and fractions of seconds at
|
|
5
|
+
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
|
6
|
+
* January 1, 1970, in the proleptic Gregorian calendar which extends the
|
|
7
|
+
* Gregorian calendar backwards to year one.
|
|
8
|
+
*
|
|
9
|
+
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
|
10
|
+
* second table is needed for interpretation, using a [24-hour linear
|
|
11
|
+
* smear](https://developers.google.com/time/smear).
|
|
12
|
+
*
|
|
13
|
+
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
|
14
|
+
* restricting to that range, we ensure that we can convert to and from [RFC
|
|
15
|
+
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
|
16
|
+
*
|
|
17
|
+
* # Examples
|
|
18
|
+
*
|
|
19
|
+
* Example 1: Compute Timestamp from POSIX `time()`.
|
|
20
|
+
*
|
|
21
|
+
* Timestamp timestamp;
|
|
22
|
+
* timestamp.set_seconds(time(NULL));
|
|
23
|
+
* timestamp.set_nanos(0);
|
|
24
|
+
*
|
|
25
|
+
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
|
26
|
+
*
|
|
27
|
+
* struct timeval tv;
|
|
28
|
+
* gettimeofday(&tv, NULL);
|
|
29
|
+
*
|
|
30
|
+
* Timestamp timestamp;
|
|
31
|
+
* timestamp.set_seconds(tv.tv_sec);
|
|
32
|
+
* timestamp.set_nanos(tv.tv_usec * 1000);
|
|
33
|
+
*
|
|
34
|
+
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
|
35
|
+
*
|
|
36
|
+
* FILETIME ft;
|
|
37
|
+
* GetSystemTimeAsFileTime(&ft);
|
|
38
|
+
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
|
39
|
+
*
|
|
40
|
+
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
|
41
|
+
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
|
42
|
+
* Timestamp timestamp;
|
|
43
|
+
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
|
44
|
+
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
|
45
|
+
*
|
|
46
|
+
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
|
47
|
+
*
|
|
48
|
+
* long millis = System.currentTimeMillis();
|
|
49
|
+
*
|
|
50
|
+
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
|
51
|
+
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
52
|
+
*
|
|
53
|
+
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
|
54
|
+
*
|
|
55
|
+
* Instant now = Instant.now();
|
|
56
|
+
*
|
|
57
|
+
* Timestamp timestamp =
|
|
58
|
+
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
59
|
+
* .setNanos(now.getNano()).build();
|
|
60
|
+
*
|
|
61
|
+
* Example 6: Compute Timestamp from current time in Python.
|
|
62
|
+
*
|
|
63
|
+
* timestamp = Timestamp()
|
|
64
|
+
* timestamp.GetCurrentTime()
|
|
65
|
+
*
|
|
66
|
+
* # JSON Mapping
|
|
67
|
+
*
|
|
68
|
+
* In JSON format, the Timestamp type is encoded as a string in the
|
|
69
|
+
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
|
70
|
+
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
|
71
|
+
* where {year} is always expressed using four digits while {month}, {day},
|
|
72
|
+
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
|
73
|
+
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
|
74
|
+
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
|
75
|
+
* is required. A proto3 JSON serializer should always use UTC (as indicated by
|
|
76
|
+
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
|
77
|
+
* able to accept both UTC and other timezones (as indicated by an offset).
|
|
78
|
+
*
|
|
79
|
+
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
|
80
|
+
* 01:30 UTC on January 15, 2017.
|
|
81
|
+
*
|
|
82
|
+
* In JavaScript, one can convert a Date object to this format using the
|
|
83
|
+
* standard
|
|
84
|
+
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
|
85
|
+
* method. In Python, a standard `datetime.datetime` object can be converted
|
|
86
|
+
* to this format using
|
|
87
|
+
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
88
|
+
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
89
|
+
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
90
|
+
* http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
|
|
91
|
+
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
92
|
+
*/
|
|
93
|
+
export interface Timestamp {
|
|
94
|
+
/**
|
|
95
|
+
* Represents seconds of UTC time since Unix epoch
|
|
96
|
+
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
97
|
+
* 9999-12-31T23:59:59Z inclusive.
|
|
98
|
+
*/
|
|
99
|
+
seconds: string;
|
|
100
|
+
/**
|
|
101
|
+
* Non-negative fractions of a second at nanosecond resolution. Negative
|
|
102
|
+
* second values with fractions must still have non-negative nanos values
|
|
103
|
+
* that count forward in time. Must be from 0 to 999,999,999
|
|
104
|
+
* inclusive.
|
|
105
|
+
*/
|
|
106
|
+
nanos: number;
|
|
107
|
+
}
|
|
108
|
+
export declare const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
|
|
@@ -0,0 +1,11 @@
|
|
|
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 v3.21.5
|
|
6
|
+
// source: google/protobuf/timestamp.proto
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.GOOGLE_PROTOBUF_PACKAGE_NAME = exports.protobufPackage = void 0;
|
|
9
|
+
/* eslint-disable */
|
|
10
|
+
exports.protobufPackage = "google.protobuf";
|
|
11
|
+
exports.GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Metadata } from "@grpc/grpc-js";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
export declare const protobufPackage = "project";
|
|
4
|
+
export interface CreateProjectRequest {
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ProjectResponse {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
companyId: string;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const PROJECT_PACKAGE_NAME = "project";
|
|
15
|
+
export interface ProjectServiceClient {
|
|
16
|
+
create(request: CreateProjectRequest, metadata?: Metadata): Observable<ProjectResponse>;
|
|
17
|
+
}
|
|
18
|
+
export interface ProjectServiceController {
|
|
19
|
+
create(request: CreateProjectRequest, metadata?: Metadata): Promise<ProjectResponse> | Observable<ProjectResponse> | ProjectResponse;
|
|
20
|
+
}
|
|
21
|
+
export declare function ProjectServiceControllerMethods(): (constructor: Function) => void;
|
|
22
|
+
export declare const PROJECT_SERVICE_NAME = "ProjectService";
|
|
@@ -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 v3.21.5
|
|
6
|
+
// source: project.proto
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.PROJECT_SERVICE_NAME = exports.PROJECT_PACKAGE_NAME = exports.protobufPackage = void 0;
|
|
9
|
+
exports.ProjectServiceControllerMethods = ProjectServiceControllerMethods;
|
|
10
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
11
|
+
exports.protobufPackage = "project";
|
|
12
|
+
exports.PROJECT_PACKAGE_NAME = "project";
|
|
13
|
+
function ProjectServiceControllerMethods() {
|
|
14
|
+
return function (constructor) {
|
|
15
|
+
const grpcMethods = ["create"];
|
|
16
|
+
for (const method of grpcMethods) {
|
|
17
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
18
|
+
(0, microservices_1.GrpcMethod)("ProjectService", 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)("ProjectService", method)(constructor.prototype[method], method, descriptor);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.PROJECT_SERVICE_NAME = "ProjectService";
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Project = exports.Auth = void 0;
|
|
40
|
+
exports.Auth = __importStar(require("./generated/auth"));
|
|
41
|
+
__exportStar(require("./config/auth-config"), exports);
|
|
42
|
+
exports.Project = __importStar(require("./generated/project"));
|
|
43
|
+
__exportStar(require("./config/project-config"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wenlarge/communication",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared gRPC proto interfaces and generated clients for Wenlarge microservices.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"proto",
|
|
10
|
+
"src/generated"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"proto:build": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --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
|
+
"build": "npm run proto:build && tsc",
|
|
15
|
+
"prepare": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"nestjs",
|
|
19
|
+
"grpc",
|
|
20
|
+
"proto",
|
|
21
|
+
"typescript",
|
|
22
|
+
"microservices",
|
|
23
|
+
"communication",
|
|
24
|
+
"shared"
|
|
25
|
+
],
|
|
26
|
+
"author": "Kerem Çakır <admin@wenlarge.com>",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/wenlarge/communication.git"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@grpc/grpc-js": "^1.13.3",
|
|
37
|
+
"@grpc/proto-loader": "^0.6.13",
|
|
38
|
+
"rxjs": "^7.8.2"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@nestjs/microservices": "^11.1.0",
|
|
42
|
+
"ts-proto": "^1.152.2",
|
|
43
|
+
"typescript": "^5.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/proto/auth.proto
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
import "google/protobuf/empty.proto";
|
|
4
|
+
|
|
5
|
+
package auth;
|
|
6
|
+
|
|
7
|
+
service AuthService {
|
|
8
|
+
rpc Login (LoginRequest) returns (LoginResponse);
|
|
9
|
+
rpc Register (RegisterRequest) returns (google.protobuf.Empty);
|
|
10
|
+
rpc GetMe (GetMeRequest) returns (GetMeResponse);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
message LoginRequest {
|
|
14
|
+
string email = 1;
|
|
15
|
+
string password = 2;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
message LoginResponse {
|
|
19
|
+
string jwt = 1;
|
|
20
|
+
string expiresIn = 2;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
message RegisterRequest {
|
|
24
|
+
string name = 1;
|
|
25
|
+
string email = 2;
|
|
26
|
+
string password = 3;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
message GetMeRequest {
|
|
30
|
+
string jwt = 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
message Company {
|
|
34
|
+
string id = 1;
|
|
35
|
+
string name = 2;
|
|
36
|
+
string createdAt = 3;
|
|
37
|
+
string updatedAt = 4;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
message CompanyUser {
|
|
41
|
+
Company company = 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
message GetMeResponse {
|
|
45
|
+
string id = 1;
|
|
46
|
+
string name = 2;
|
|
47
|
+
string email = 3;
|
|
48
|
+
string createdAt = 4;
|
|
49
|
+
string updatedAt = 5;
|
|
50
|
+
repeated CompanyUser companyUsersOnUser = 6;
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package project;
|
|
4
|
+
|
|
5
|
+
service ProjectService {
|
|
6
|
+
rpc Create (CreateProjectRequest) returns (ProjectResponse);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
message CreateProjectRequest {
|
|
10
|
+
string name = 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
message ProjectResponse {
|
|
14
|
+
string id = 1;
|
|
15
|
+
string name = 2;
|
|
16
|
+
string companyId = 3;
|
|
17
|
+
string createdAt = 4;
|
|
18
|
+
string updatedAt = 5;
|
|
19
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v1.181.2
|
|
4
|
+
// protoc v3.21.5
|
|
5
|
+
// source: auth.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 = "auth";
|
|
14
|
+
|
|
15
|
+
export interface LoginRequest {
|
|
16
|
+
email: string;
|
|
17
|
+
password: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface LoginResponse {
|
|
21
|
+
jwt: string;
|
|
22
|
+
expiresIn: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface RegisterRequest {
|
|
26
|
+
name: string;
|
|
27
|
+
email: string;
|
|
28
|
+
password: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface GetMeRequest {
|
|
32
|
+
jwt: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface Company {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CompanyUser {
|
|
43
|
+
company?: Company | undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface GetMeResponse {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
email: string;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
updatedAt: string;
|
|
52
|
+
companyUsersOnUser: CompanyUser[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const AUTH_PACKAGE_NAME = "auth";
|
|
56
|
+
|
|
57
|
+
export interface AuthServiceClient {
|
|
58
|
+
login(request: LoginRequest, metadata?: Metadata): Observable<LoginResponse>;
|
|
59
|
+
|
|
60
|
+
register(request: RegisterRequest, metadata?: Metadata): Observable<Empty>;
|
|
61
|
+
|
|
62
|
+
getMe(request: GetMeRequest, metadata?: Metadata): Observable<GetMeResponse>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface AuthServiceController {
|
|
66
|
+
login(request: LoginRequest, metadata?: Metadata): Promise<LoginResponse> | Observable<LoginResponse> | LoginResponse;
|
|
67
|
+
|
|
68
|
+
register(request: RegisterRequest, metadata?: Metadata): void;
|
|
69
|
+
|
|
70
|
+
getMe(request: GetMeRequest, metadata?: Metadata): Promise<GetMeResponse> | Observable<GetMeResponse> | GetMeResponse;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function AuthServiceControllerMethods() {
|
|
74
|
+
return function (constructor: Function) {
|
|
75
|
+
const grpcMethods: string[] = ["login", "register", "getMe"];
|
|
76
|
+
for (const method of grpcMethods) {
|
|
77
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
78
|
+
GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
79
|
+
}
|
|
80
|
+
const grpcStreamMethods: string[] = [];
|
|
81
|
+
for (const method of grpcStreamMethods) {
|
|
82
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
83
|
+
GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const AUTH_SERVICE_NAME = "AuthService";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v1.181.2
|
|
4
|
+
// protoc v3.21.5
|
|
5
|
+
// source: google/protobuf/empty.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
|
|
9
|
+
export const protobufPackage = "google.protobuf";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A generic empty message that you can re-use to avoid defining duplicated
|
|
13
|
+
* empty messages in your APIs. A typical example is to use it as the request
|
|
14
|
+
* or the response type of an API method. For instance:
|
|
15
|
+
*
|
|
16
|
+
* service Foo {
|
|
17
|
+
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
export interface Empty {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v1.181.2
|
|
4
|
+
// protoc v3.21.5
|
|
5
|
+
// source: google/protobuf/timestamp.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
|
|
9
|
+
export const protobufPackage = "google.protobuf";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A Timestamp represents a point in time independent of any time zone or local
|
|
13
|
+
* calendar, encoded as a count of seconds and fractions of seconds at
|
|
14
|
+
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
|
15
|
+
* January 1, 1970, in the proleptic Gregorian calendar which extends the
|
|
16
|
+
* Gregorian calendar backwards to year one.
|
|
17
|
+
*
|
|
18
|
+
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
|
19
|
+
* second table is needed for interpretation, using a [24-hour linear
|
|
20
|
+
* smear](https://developers.google.com/time/smear).
|
|
21
|
+
*
|
|
22
|
+
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
|
23
|
+
* restricting to that range, we ensure that we can convert to and from [RFC
|
|
24
|
+
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
|
25
|
+
*
|
|
26
|
+
* # Examples
|
|
27
|
+
*
|
|
28
|
+
* Example 1: Compute Timestamp from POSIX `time()`.
|
|
29
|
+
*
|
|
30
|
+
* Timestamp timestamp;
|
|
31
|
+
* timestamp.set_seconds(time(NULL));
|
|
32
|
+
* timestamp.set_nanos(0);
|
|
33
|
+
*
|
|
34
|
+
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
|
35
|
+
*
|
|
36
|
+
* struct timeval tv;
|
|
37
|
+
* gettimeofday(&tv, NULL);
|
|
38
|
+
*
|
|
39
|
+
* Timestamp timestamp;
|
|
40
|
+
* timestamp.set_seconds(tv.tv_sec);
|
|
41
|
+
* timestamp.set_nanos(tv.tv_usec * 1000);
|
|
42
|
+
*
|
|
43
|
+
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
|
44
|
+
*
|
|
45
|
+
* FILETIME ft;
|
|
46
|
+
* GetSystemTimeAsFileTime(&ft);
|
|
47
|
+
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
|
48
|
+
*
|
|
49
|
+
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
|
50
|
+
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
|
51
|
+
* Timestamp timestamp;
|
|
52
|
+
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
|
53
|
+
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
|
54
|
+
*
|
|
55
|
+
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
|
56
|
+
*
|
|
57
|
+
* long millis = System.currentTimeMillis();
|
|
58
|
+
*
|
|
59
|
+
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
|
60
|
+
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
61
|
+
*
|
|
62
|
+
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
|
63
|
+
*
|
|
64
|
+
* Instant now = Instant.now();
|
|
65
|
+
*
|
|
66
|
+
* Timestamp timestamp =
|
|
67
|
+
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
68
|
+
* .setNanos(now.getNano()).build();
|
|
69
|
+
*
|
|
70
|
+
* Example 6: Compute Timestamp from current time in Python.
|
|
71
|
+
*
|
|
72
|
+
* timestamp = Timestamp()
|
|
73
|
+
* timestamp.GetCurrentTime()
|
|
74
|
+
*
|
|
75
|
+
* # JSON Mapping
|
|
76
|
+
*
|
|
77
|
+
* In JSON format, the Timestamp type is encoded as a string in the
|
|
78
|
+
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
|
79
|
+
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
|
80
|
+
* where {year} is always expressed using four digits while {month}, {day},
|
|
81
|
+
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
|
82
|
+
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
|
83
|
+
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
|
84
|
+
* is required. A proto3 JSON serializer should always use UTC (as indicated by
|
|
85
|
+
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
|
86
|
+
* able to accept both UTC and other timezones (as indicated by an offset).
|
|
87
|
+
*
|
|
88
|
+
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
|
89
|
+
* 01:30 UTC on January 15, 2017.
|
|
90
|
+
*
|
|
91
|
+
* In JavaScript, one can convert a Date object to this format using the
|
|
92
|
+
* standard
|
|
93
|
+
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
|
94
|
+
* method. In Python, a standard `datetime.datetime` object can be converted
|
|
95
|
+
* to this format using
|
|
96
|
+
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
97
|
+
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
98
|
+
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
99
|
+
* http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
|
|
100
|
+
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
101
|
+
*/
|
|
102
|
+
export interface Timestamp {
|
|
103
|
+
/**
|
|
104
|
+
* Represents seconds of UTC time since Unix epoch
|
|
105
|
+
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
106
|
+
* 9999-12-31T23:59:59Z inclusive.
|
|
107
|
+
*/
|
|
108
|
+
seconds: string;
|
|
109
|
+
/**
|
|
110
|
+
* Non-negative fractions of a second at nanosecond resolution. Negative
|
|
111
|
+
* second values with fractions must still have non-negative nanos values
|
|
112
|
+
* that count forward in time. Must be from 0 to 999,999,999
|
|
113
|
+
* inclusive.
|
|
114
|
+
*/
|
|
115
|
+
nanos: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v1.181.2
|
|
4
|
+
// protoc v3.21.5
|
|
5
|
+
// source: project.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
|
+
|
|
12
|
+
export const protobufPackage = "project";
|
|
13
|
+
|
|
14
|
+
export interface CreateProjectRequest {
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ProjectResponse {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
companyId: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const PROJECT_PACKAGE_NAME = "project";
|
|
27
|
+
|
|
28
|
+
export interface ProjectServiceClient {
|
|
29
|
+
create(request: CreateProjectRequest, metadata?: Metadata): Observable<ProjectResponse>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ProjectServiceController {
|
|
33
|
+
create(
|
|
34
|
+
request: CreateProjectRequest,
|
|
35
|
+
metadata?: Metadata,
|
|
36
|
+
): Promise<ProjectResponse> | Observable<ProjectResponse> | ProjectResponse;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function ProjectServiceControllerMethods() {
|
|
40
|
+
return function (constructor: Function) {
|
|
41
|
+
const grpcMethods: string[] = ["create"];
|
|
42
|
+
for (const method of grpcMethods) {
|
|
43
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
44
|
+
GrpcMethod("ProjectService", method)(constructor.prototype[method], method, descriptor);
|
|
45
|
+
}
|
|
46
|
+
const grpcStreamMethods: string[] = [];
|
|
47
|
+
for (const method of grpcStreamMethods) {
|
|
48
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
49
|
+
GrpcStreamMethod("ProjectService", method)(constructor.prototype[method], method, descriptor);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const PROJECT_SERVICE_NAME = "ProjectService";
|