@citec-spbu/contracts 1.0.4 → 1.0.6

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,25 @@
1
+ import { Observable } from "rxjs";
2
+ export declare const protobufPackage = "account.v1";
3
+ export declare enum Role {
4
+ ROLE_UNSPECIFIED = 0,
5
+ ROLE_USER = 1,
6
+ ROLE_SUPERVISOR = 2,
7
+ ROLE_ADMIN = 3,
8
+ UNRECOGNIZED = -1
9
+ }
10
+ export interface GetAccountRequest {
11
+ id: string;
12
+ }
13
+ export interface GetAccountResponse {
14
+ id: string;
15
+ role: Role;
16
+ }
17
+ export declare const ACCOUNT_V1_PACKAGE_NAME = "account.v1";
18
+ export interface AccountServiceClient {
19
+ getAccount(request: GetAccountRequest): Observable<GetAccountResponse>;
20
+ }
21
+ export interface AccountServiceController {
22
+ getAccount(request: GetAccountRequest): Promise<GetAccountResponse> | Observable<GetAccountResponse> | GetAccountResponse;
23
+ }
24
+ export declare function AccountServiceControllerMethods(): (constructor: Function) => void;
25
+ export declare const ACCOUNT_SERVICE_NAME = "AccountService";
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.10.1
5
+ // protoc v3.21.12
6
+ // source: account.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ACCOUNT_SERVICE_NAME = exports.ACCOUNT_V1_PACKAGE_NAME = exports.Role = exports.protobufPackage = void 0;
9
+ exports.AccountServiceControllerMethods = AccountServiceControllerMethods;
10
+ /* eslint-disable */
11
+ const microservices_1 = require("@nestjs/microservices");
12
+ exports.protobufPackage = "account.v1";
13
+ var Role;
14
+ (function (Role) {
15
+ Role[Role["ROLE_UNSPECIFIED"] = 0] = "ROLE_UNSPECIFIED";
16
+ Role[Role["ROLE_USER"] = 1] = "ROLE_USER";
17
+ Role[Role["ROLE_SUPERVISOR"] = 2] = "ROLE_SUPERVISOR";
18
+ Role[Role["ROLE_ADMIN"] = 3] = "ROLE_ADMIN";
19
+ Role[Role["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
20
+ })(Role || (exports.Role = Role = {}));
21
+ exports.ACCOUNT_V1_PACKAGE_NAME = "account.v1";
22
+ function AccountServiceControllerMethods() {
23
+ return function (constructor) {
24
+ const grpcMethods = ["getAccount"];
25
+ for (const method of grpcMethods) {
26
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
27
+ (0, microservices_1.GrpcMethod)("AccountService", method)(constructor.prototype[method], method, descriptor);
28
+ }
29
+ const grpcStreamMethods = [];
30
+ for (const method of grpcStreamMethods) {
31
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
32
+ (0, microservices_1.GrpcStreamMethod)("AccountService", method)(constructor.prototype[method], method, descriptor);
33
+ }
34
+ };
35
+ }
36
+ exports.ACCOUNT_SERVICE_NAME = "AccountService";
@@ -0,0 +1,47 @@
1
+ import { Observable } from "rxjs";
2
+ export declare const protobufPackage = "auth.v1";
3
+ export declare enum Provider {
4
+ PROVIDER_UNSPECIFIED = 0,
5
+ PROVIDER_GITHUB = 1,
6
+ UNRECOGNIZED = -1
7
+ }
8
+ export interface GithubLoginRequest {
9
+ provider: Provider;
10
+ providerId: string;
11
+ username: string;
12
+ profileUrl: string;
13
+ avatarUrl: string;
14
+ }
15
+ export interface GithubLoginResponse {
16
+ tokens: TokenPair | undefined;
17
+ }
18
+ export interface ValidateJwtRequest {
19
+ accessToken: string;
20
+ }
21
+ export interface ValidateJwtResponse {
22
+ valid: boolean;
23
+ accountId: string;
24
+ }
25
+ export interface RefreshRequest {
26
+ refreshToken: string;
27
+ }
28
+ export interface RefreshResponse {
29
+ tokens: TokenPair | undefined;
30
+ }
31
+ export interface TokenPair {
32
+ accessToken: string;
33
+ refreshToken: string;
34
+ }
35
+ export declare const AUTH_V1_PACKAGE_NAME = "auth.v1";
36
+ export interface AuthServiceClient {
37
+ githubLogin(request: GithubLoginRequest): Observable<GithubLoginResponse>;
38
+ validateJwt(request: ValidateJwtRequest): Observable<ValidateJwtResponse>;
39
+ refresh(request: RefreshRequest): Observable<RefreshResponse>;
40
+ }
41
+ export interface AuthServiceController {
42
+ githubLogin(request: GithubLoginRequest): Promise<GithubLoginResponse> | Observable<GithubLoginResponse> | GithubLoginResponse;
43
+ validateJwt(request: ValidateJwtRequest): Promise<ValidateJwtResponse> | Observable<ValidateJwtResponse> | ValidateJwtResponse;
44
+ refresh(request: RefreshRequest): Promise<RefreshResponse> | Observable<RefreshResponse> | RefreshResponse;
45
+ }
46
+ export declare function AuthServiceControllerMethods(): (constructor: Function) => void;
47
+ export declare const AUTH_SERVICE_NAME = "AuthService";
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.10.1
5
+ // protoc v3.21.12
6
+ // source: auth.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.AUTH_SERVICE_NAME = exports.AUTH_V1_PACKAGE_NAME = exports.Provider = exports.protobufPackage = void 0;
9
+ exports.AuthServiceControllerMethods = AuthServiceControllerMethods;
10
+ /* eslint-disable */
11
+ const microservices_1 = require("@nestjs/microservices");
12
+ exports.protobufPackage = "auth.v1";
13
+ var Provider;
14
+ (function (Provider) {
15
+ Provider[Provider["PROVIDER_UNSPECIFIED"] = 0] = "PROVIDER_UNSPECIFIED";
16
+ Provider[Provider["PROVIDER_GITHUB"] = 1] = "PROVIDER_GITHUB";
17
+ Provider[Provider["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
18
+ })(Provider || (exports.Provider = Provider = {}));
19
+ exports.AUTH_V1_PACKAGE_NAME = "auth.v1";
20
+ function AuthServiceControllerMethods() {
21
+ return function (constructor) {
22
+ const grpcMethods = ["githubLogin", "validateJwt", "refresh"];
23
+ for (const method of grpcMethods) {
24
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
25
+ (0, microservices_1.GrpcMethod)("AuthService", method)(constructor.prototype[method], method, descriptor);
26
+ }
27
+ const grpcStreamMethods = [];
28
+ for (const method of grpcStreamMethods) {
29
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
30
+ (0, microservices_1.GrpcStreamMethod)("AuthService", method)(constructor.prototype[method], method, descriptor);
31
+ }
32
+ };
33
+ }
34
+ exports.AUTH_SERVICE_NAME = "AuthService";
package/gen/ts/auth.ts CHANGED
@@ -10,12 +10,21 @@ import { Observable } from "rxjs";
10
10
 
11
11
  export const protobufPackage = "auth.v1";
12
12
 
13
- export interface GenerateJwtRequest {
14
- provider: string;
13
+ export enum Provider {
14
+ PROVIDER_UNSPECIFIED = 0,
15
+ PROVIDER_GITHUB = 1,
16
+ UNRECOGNIZED = -1,
17
+ }
18
+
19
+ export interface GithubLoginRequest {
20
+ provider: Provider;
15
21
  providerId: string;
22
+ username: string;
23
+ profileUrl: string;
24
+ avatarUrl: string;
16
25
  }
17
26
 
18
- export interface GenerateJwtResponse {
27
+ export interface GithubLoginResponse {
19
28
  tokens: TokenPair | undefined;
20
29
  }
21
30
 
@@ -44,7 +53,7 @@ export interface TokenPair {
44
53
  export const AUTH_V1_PACKAGE_NAME = "auth.v1";
45
54
 
46
55
  export interface AuthServiceClient {
47
- generateJwt(request: GenerateJwtRequest): Observable<GenerateJwtResponse>;
56
+ githubLogin(request: GithubLoginRequest): Observable<GithubLoginResponse>;
48
57
 
49
58
  validateJwt(request: ValidateJwtRequest): Observable<ValidateJwtResponse>;
50
59
 
@@ -52,9 +61,9 @@ export interface AuthServiceClient {
52
61
  }
53
62
 
54
63
  export interface AuthServiceController {
55
- generateJwt(
56
- request: GenerateJwtRequest,
57
- ): Promise<GenerateJwtResponse> | Observable<GenerateJwtResponse> | GenerateJwtResponse;
64
+ githubLogin(
65
+ request: GithubLoginRequest,
66
+ ): Promise<GithubLoginResponse> | Observable<GithubLoginResponse> | GithubLoginResponse;
58
67
 
59
68
  validateJwt(
60
69
  request: ValidateJwtRequest,
@@ -65,7 +74,7 @@ export interface AuthServiceController {
65
74
 
66
75
  export function AuthServiceControllerMethods() {
67
76
  return function (constructor: Function) {
68
- const grpcMethods: string[] = ["generateJwt", "validateJwt", "refresh"];
77
+ const grpcMethods: string[] = ["githubLogin", "validateJwt", "refresh"];
69
78
  for (const method of grpcMethods) {
70
79
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
71
80
  GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
package/package.json CHANGED
@@ -1,12 +1,26 @@
1
1
  {
2
2
  "name": "@citec-spbu/contracts",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Protobuf definitions and generated TypeScript types",
5
- "main": "./dist/index.js",
6
- "types": "./dist/index.d.js",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./gen/ts/auth": {
13
+ "types": "./dist/gen/ts/auth.d.ts",
14
+ "default": "./dist/gen/ts/auth.js"
15
+ },
16
+ "./gen/ts/account": {
17
+ "types": "./dist/gen/ts/account.d.ts",
18
+ "default": "./dist/gen/ts/account.js"
19
+ }
20
+ },
7
21
  "scripts": {
8
- "build": "tsc -p tsconfig.build.json",
9
- "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen/ts --ts_proto_opt=nestJs=true,package=omit"
22
+ "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen/ts --ts_proto_opt=nestJs=true,package=omit",
23
+ "build": "tsc -p tsconfig.build.json && tsc -p tsconfig.gen.json"
10
24
  },
11
25
  "files": [
12
26
  "dist",
package/proto/auth.proto CHANGED
@@ -3,19 +3,22 @@ syntax = "proto3";
3
3
  package auth.v1;
4
4
 
5
5
  service AuthService {
6
- rpc GenerateJwt(GenerateJwtRequest) returns (GenerateJwtResponse);
6
+ rpc GithubLogin(GithubLoginRequest) returns (GithubLoginResponse);
7
7
 
8
8
  rpc ValidateJwt(ValidateJwtRequest) returns (ValidateJwtResponse);
9
9
 
10
10
  rpc Refresh(RefreshRequest) returns (RefreshResponse);
11
11
  }
12
12
 
13
- message GenerateJwtRequest {
14
- string provider = 1;
13
+ message GithubLoginRequest {
14
+ Provider provider = 1;
15
15
  string provider_id = 2;
16
+ string username = 3;
17
+ string profile_url = 4;
18
+ string avatar_url = 5;
16
19
  }
17
20
 
18
- message GenerateJwtResponse {
21
+ message GithubLoginResponse {
19
22
  TokenPair tokens = 1;
20
23
  }
21
24
 
@@ -40,3 +43,8 @@ message TokenPair {
40
43
  string access_token = 1;
41
44
  string refresh_token = 2;
42
45
  }
46
+
47
+ enum Provider {
48
+ PROVIDER_UNSPECIFIED = 0;
49
+ PROVIDER_GITHUB = 1;
50
+ }