@mediaryorg/contracts 1.0.4 → 1.0.5

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.
@@ -1,3 +1,10 @@
1
1
  export declare const PROTO_PATH: {
2
2
  readonly AUTH: string;
3
+ readonly USER: string;
3
4
  };
5
+ /**
6
+ * Root directories for protobuf imports.
7
+ * Pass these to the gRPC loader so that cross-package imports resolve correctly
8
+ * (e.g. `import "user/v1/user.proto";` from auth.proto).
9
+ */
10
+ export declare const PROTO_INCLUDE_DIRS: readonly [string];
@@ -1,7 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROTO_PATH = void 0;
3
+ exports.PROTO_INCLUDE_DIRS = exports.PROTO_PATH = void 0;
4
4
  const path_1 = require("path");
5
+ const PROTO_DIR = (0, path_1.join)(__dirname, "../../proto");
5
6
  exports.PROTO_PATH = {
6
- AUTH: (0, path_1.join)(__dirname, "../../proto/auth.proto"),
7
+ AUTH: (0, path_1.join)(PROTO_DIR, "auth/v1/auth.proto"),
8
+ USER: (0, path_1.join)(PROTO_DIR, "user/v1/user.proto"),
7
9
  };
10
+ /**
11
+ * Root directories for protobuf imports.
12
+ * Pass these to the gRPC loader so that cross-package imports resolve correctly
13
+ * (e.g. `import "user/v1/user.proto";` from auth.proto).
14
+ */
15
+ exports.PROTO_INCLUDE_DIRS = [PROTO_DIR];
@@ -0,0 +1,243 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.6
4
+ // protoc v3.21.12
5
+ // source: auth/v1/auth.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+ import { User } from "../../user/v1/user";
11
+
12
+ export const protobufPackage = "auth.v1";
13
+
14
+ export interface LoginResponse {
15
+ user: User | undefined;
16
+ sessionId: string;
17
+ maxAgeMs: number;
18
+ }
19
+
20
+ export interface ConfirmEmailResponse {
21
+ user: User | undefined;
22
+ sessionId: string;
23
+ maxAgeMs: number;
24
+ }
25
+
26
+ export interface OauthCallbackResponse {
27
+ user: User | undefined;
28
+ sessionId: string;
29
+ maxAgeMs: number;
30
+ }
31
+
32
+ export interface AdminLoginResponse {
33
+ user: User | undefined;
34
+ sessionId: string;
35
+ maxAgeMs: number;
36
+ }
37
+
38
+ export interface ValidateSessionResponse {
39
+ valid: boolean;
40
+ user: User | undefined;
41
+ }
42
+
43
+ export interface AdminValidateSessionResponse {
44
+ valid: boolean;
45
+ user: User | undefined;
46
+ }
47
+
48
+ export interface ResendVerificationResponse {
49
+ message: string;
50
+ }
51
+
52
+ export interface RequestPasswordResetResponse {
53
+ message: string;
54
+ }
55
+
56
+ export interface SetNewPasswordResponse {
57
+ message: string;
58
+ }
59
+
60
+ export interface LogoutResponse {
61
+ }
62
+
63
+ export interface AdminLogoutResponse {
64
+ }
65
+
66
+ export interface RegisterRequest {
67
+ name: string;
68
+ email: string;
69
+ password: string;
70
+ passwordRepeat: string;
71
+ }
72
+
73
+ export interface RegisterResponse {
74
+ message: string;
75
+ email: string;
76
+ }
77
+
78
+ export interface LoginRequest {
79
+ email: string;
80
+ password: string;
81
+ }
82
+
83
+ export interface LogoutRequest {
84
+ sessionId: string;
85
+ }
86
+
87
+ export interface ValidateSessionRequest {
88
+ sessionId: string;
89
+ }
90
+
91
+ export interface ConfirmEmailRequest {
92
+ email: string;
93
+ code: string;
94
+ }
95
+
96
+ export interface ResendVerificationRequest {
97
+ email: string;
98
+ }
99
+
100
+ export interface RequestPasswordResetRequest {
101
+ email: string;
102
+ }
103
+
104
+ export interface SetNewPasswordRequest {
105
+ email: string;
106
+ code: string;
107
+ password: string;
108
+ }
109
+
110
+ export interface OauthConnectRequest {
111
+ provider: string;
112
+ }
113
+
114
+ export interface OauthConnectResponse {
115
+ url: string;
116
+ }
117
+
118
+ export interface OauthCallbackRequest {
119
+ provider: string;
120
+ code: string;
121
+ }
122
+
123
+ export interface AdminLoginRequest {
124
+ email: string;
125
+ password: string;
126
+ }
127
+
128
+ export interface AdminLogoutRequest {
129
+ sessionId: string;
130
+ }
131
+
132
+ export interface AdminValidateSessionRequest {
133
+ sessionId: string;
134
+ }
135
+
136
+ export const AUTH_V1_PACKAGE_NAME = "auth.v1";
137
+
138
+ export interface AuthServiceClient {
139
+ register(request: RegisterRequest): Observable<RegisterResponse>;
140
+
141
+ login(request: LoginRequest): Observable<LoginResponse>;
142
+
143
+ logout(request: LogoutRequest): Observable<LogoutResponse>;
144
+
145
+ validateSession(request: ValidateSessionRequest): Observable<ValidateSessionResponse>;
146
+
147
+ confirmEmail(request: ConfirmEmailRequest): Observable<ConfirmEmailResponse>;
148
+
149
+ resendVerification(request: ResendVerificationRequest): Observable<ResendVerificationResponse>;
150
+
151
+ requestPasswordReset(request: RequestPasswordResetRequest): Observable<RequestPasswordResetResponse>;
152
+
153
+ setNewPassword(request: SetNewPasswordRequest): Observable<SetNewPasswordResponse>;
154
+
155
+ oauthConnect(request: OauthConnectRequest): Observable<OauthConnectResponse>;
156
+
157
+ oauthCallback(request: OauthCallbackRequest): Observable<OauthCallbackResponse>;
158
+
159
+ adminLogin(request: AdminLoginRequest): Observable<AdminLoginResponse>;
160
+
161
+ adminLogout(request: AdminLogoutRequest): Observable<AdminLogoutResponse>;
162
+
163
+ adminValidateSession(request: AdminValidateSessionRequest): Observable<AdminValidateSessionResponse>;
164
+ }
165
+
166
+ export interface AuthServiceController {
167
+ register(request: RegisterRequest): Promise<RegisterResponse> | Observable<RegisterResponse> | RegisterResponse;
168
+
169
+ login(request: LoginRequest): Promise<LoginResponse> | Observable<LoginResponse> | LoginResponse;
170
+
171
+ logout(request: LogoutRequest): Promise<LogoutResponse> | Observable<LogoutResponse> | LogoutResponse;
172
+
173
+ validateSession(
174
+ request: ValidateSessionRequest,
175
+ ): Promise<ValidateSessionResponse> | Observable<ValidateSessionResponse> | ValidateSessionResponse;
176
+
177
+ confirmEmail(
178
+ request: ConfirmEmailRequest,
179
+ ): Promise<ConfirmEmailResponse> | Observable<ConfirmEmailResponse> | ConfirmEmailResponse;
180
+
181
+ resendVerification(
182
+ request: ResendVerificationRequest,
183
+ ): Promise<ResendVerificationResponse> | Observable<ResendVerificationResponse> | ResendVerificationResponse;
184
+
185
+ requestPasswordReset(
186
+ request: RequestPasswordResetRequest,
187
+ ): Promise<RequestPasswordResetResponse> | Observable<RequestPasswordResetResponse> | RequestPasswordResetResponse;
188
+
189
+ setNewPassword(
190
+ request: SetNewPasswordRequest,
191
+ ): Promise<SetNewPasswordResponse> | Observable<SetNewPasswordResponse> | SetNewPasswordResponse;
192
+
193
+ oauthConnect(
194
+ request: OauthConnectRequest,
195
+ ): Promise<OauthConnectResponse> | Observable<OauthConnectResponse> | OauthConnectResponse;
196
+
197
+ oauthCallback(
198
+ request: OauthCallbackRequest,
199
+ ): Promise<OauthCallbackResponse> | Observable<OauthCallbackResponse> | OauthCallbackResponse;
200
+
201
+ adminLogin(
202
+ request: AdminLoginRequest,
203
+ ): Promise<AdminLoginResponse> | Observable<AdminLoginResponse> | AdminLoginResponse;
204
+
205
+ adminLogout(
206
+ request: AdminLogoutRequest,
207
+ ): Promise<AdminLogoutResponse> | Observable<AdminLogoutResponse> | AdminLogoutResponse;
208
+
209
+ adminValidateSession(
210
+ request: AdminValidateSessionRequest,
211
+ ): Promise<AdminValidateSessionResponse> | Observable<AdminValidateSessionResponse> | AdminValidateSessionResponse;
212
+ }
213
+
214
+ export function AuthServiceControllerMethods() {
215
+ return function (constructor: Function) {
216
+ const grpcMethods: string[] = [
217
+ "register",
218
+ "login",
219
+ "logout",
220
+ "validateSession",
221
+ "confirmEmail",
222
+ "resendVerification",
223
+ "requestPasswordReset",
224
+ "setNewPassword",
225
+ "oauthConnect",
226
+ "oauthCallback",
227
+ "adminLogin",
228
+ "adminLogout",
229
+ "adminValidateSession",
230
+ ];
231
+ for (const method of grpcMethods) {
232
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
233
+ GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
234
+ }
235
+ const grpcStreamMethods: string[] = [];
236
+ for (const method of grpcStreamMethods) {
237
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
238
+ GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
239
+ }
240
+ };
241
+ }
242
+
243
+ export const AUTH_SERVICE_NAME = "AuthService";
@@ -0,0 +1,11 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.6
4
+ // protoc v7.34.1
5
+ // source: google/protobuf/empty.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ export const protobufPackage = "google.protobuf";
10
+
11
+ export interface Empty {}
@@ -0,0 +1,60 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.6
4
+ // protoc v3.21.12
5
+ // source: user/v1/user.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "user.v1";
12
+
13
+ export interface User {
14
+ id: string;
15
+ email: string;
16
+ displayName: string;
17
+ picture: string;
18
+ role: string;
19
+ authProvider: string;
20
+ isVerified: boolean;
21
+ createdAt: string;
22
+ updatedAt: string;
23
+ }
24
+
25
+ export interface GetUserByIdRequest {
26
+ userId: string;
27
+ }
28
+
29
+ export interface GetUserByIdResponse {
30
+ user: User | undefined;
31
+ }
32
+
33
+ export const USER_V1_PACKAGE_NAME = "user.v1";
34
+
35
+ export interface UserServiceClient {
36
+ getUserById(request: GetUserByIdRequest): Observable<GetUserByIdResponse>;
37
+ }
38
+
39
+ export interface UserServiceController {
40
+ getUserById(
41
+ request: GetUserByIdRequest,
42
+ ): Promise<GetUserByIdResponse> | Observable<GetUserByIdResponse> | GetUserByIdResponse;
43
+ }
44
+
45
+ export function UserServiceControllerMethods() {
46
+ return function (constructor: Function) {
47
+ const grpcMethods: string[] = ["getUserById"];
48
+ for (const method of grpcMethods) {
49
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
50
+ GrpcMethod("UserService", method)(constructor.prototype[method], method, descriptor);
51
+ }
52
+ const grpcStreamMethods: string[] = [];
53
+ for (const method of grpcStreamMethods) {
54
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
55
+ GrpcStreamMethod("UserService", method)(constructor.prototype[method], method, descriptor);
56
+ }
57
+ };
58
+ }
59
+
60
+ export const USER_SERVICE_NAME = "UserService";
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mediaryorg/contracts",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Protobuf definitions and generated TypeScript types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "scripts": {
8
8
  "generate": "npm run generate:win",
9
- "generate:win": "protoc -I .\\proto .\\proto\\auth.proto --plugin=protoc-gen-ts_proto=.\\node_modules\\.bin\\protoc-gen-ts_proto.cmd --ts_proto_out=.\\generated --ts_proto_opt=nestJs=true,package=omit",
10
- "generate:ci": "protoc -I ./proto ./proto/auth.proto --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./generated --ts_proto_opt=nestJs=true,package=omit",
9
+ "generate:win": "protoc -I .\\proto .\\proto\\auth\\v1\\auth.proto .\\proto\\user\\v1\\user.proto --plugin=protoc-gen-ts_proto=.\\node_modules\\.bin\\protoc-gen-ts_proto.cmd --ts_proto_out=.\\generated --ts_proto_opt=nestJs=true,package=omit",
10
+ "generate:ci": "protoc -I ./proto ./proto/auth/v1/auth.proto ./proto/user/v1/user.proto --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./generated --ts_proto_opt=nestJs=true,package=omit",
11
11
  "build": "tsc -p tsconfig.build.json"
12
12
  },
13
13
  "files": [
@@ -0,0 +1,148 @@
1
+ syntax = "proto3";
2
+
3
+ package auth.v1;
4
+
5
+ import "user/v1/user.proto";
6
+
7
+ service AuthService {
8
+ rpc Register(RegisterRequest) returns (RegisterResponse);
9
+
10
+ rpc Login(LoginRequest) returns (LoginResponse);
11
+ rpc Logout(LogoutRequest) returns (LogoutResponse);
12
+ rpc ValidateSession(ValidateSessionRequest) returns (ValidateSessionResponse);
13
+
14
+ rpc ConfirmEmail(ConfirmEmailRequest) returns (ConfirmEmailResponse);
15
+ rpc ResendVerification(ResendVerificationRequest) returns (ResendVerificationResponse);
16
+
17
+ rpc RequestPasswordReset(RequestPasswordResetRequest) returns (RequestPasswordResetResponse);
18
+ rpc SetNewPassword(SetNewPasswordRequest) returns (SetNewPasswordResponse);
19
+
20
+ rpc OauthConnect(OauthConnectRequest) returns (OauthConnectResponse);
21
+ rpc OauthCallback(OauthCallbackRequest) returns (OauthCallbackResponse);
22
+
23
+ rpc AdminLogin(AdminLoginRequest) returns (AdminLoginResponse);
24
+ rpc AdminLogout(AdminLogoutRequest) returns (AdminLogoutResponse);
25
+ rpc AdminValidateSession(AdminValidateSessionRequest) returns (AdminValidateSessionResponse);
26
+ }
27
+
28
+ message LoginResponse {
29
+ user.v1.User user = 1;
30
+ string session_id = 2;
31
+ int64 max_age_ms = 3;
32
+ }
33
+
34
+ message ConfirmEmailResponse {
35
+ user.v1.User user = 1;
36
+ string session_id = 2;
37
+ int64 max_age_ms = 3;
38
+ }
39
+
40
+ message OauthCallbackResponse {
41
+ user.v1.User user = 1;
42
+ string session_id = 2;
43
+ int64 max_age_ms = 3;
44
+ }
45
+
46
+ message AdminLoginResponse {
47
+ user.v1.User user = 1;
48
+ string session_id = 2;
49
+ int64 max_age_ms = 3;
50
+ }
51
+
52
+ message ValidateSessionResponse {
53
+ bool valid = 1;
54
+ user.v1.User user = 2;
55
+ }
56
+
57
+ message AdminValidateSessionResponse {
58
+ bool valid = 1;
59
+ user.v1.User user = 2;
60
+ }
61
+
62
+ message ResendVerificationResponse {
63
+ string message = 1;
64
+ }
65
+
66
+ message RequestPasswordResetResponse {
67
+ string message = 1;
68
+ }
69
+
70
+ message SetNewPasswordResponse {
71
+ string message = 1;
72
+ }
73
+
74
+ message LogoutResponse {}
75
+
76
+ message AdminLogoutResponse {}
77
+
78
+ // --- Requests ---
79
+
80
+ message RegisterRequest {
81
+ string name = 1;
82
+ string email = 2;
83
+ string password = 3;
84
+ string password_repeat = 4;
85
+ }
86
+
87
+ message RegisterResponse {
88
+ string message = 1;
89
+ string email = 2;
90
+ }
91
+
92
+ message LoginRequest {
93
+ string email = 1;
94
+ string password = 2;
95
+ }
96
+
97
+ message LogoutRequest {
98
+ string session_id = 1;
99
+ }
100
+
101
+ message ValidateSessionRequest {
102
+ string session_id = 1;
103
+ }
104
+
105
+ message ConfirmEmailRequest {
106
+ string email = 1;
107
+ string code = 2;
108
+ }
109
+
110
+ message ResendVerificationRequest {
111
+ string email = 1;
112
+ }
113
+
114
+ message RequestPasswordResetRequest {
115
+ string email = 1;
116
+ }
117
+
118
+ message SetNewPasswordRequest {
119
+ string email = 1;
120
+ string code = 2;
121
+ string password = 3;
122
+ }
123
+
124
+ message OauthConnectRequest {
125
+ string provider = 1;
126
+ }
127
+
128
+ message OauthConnectResponse {
129
+ string url = 1;
130
+ }
131
+
132
+ message OauthCallbackRequest {
133
+ string provider = 1;
134
+ string code = 2;
135
+ }
136
+
137
+ message AdminLoginRequest {
138
+ string email = 1;
139
+ string password = 2;
140
+ }
141
+
142
+ message AdminLogoutRequest {
143
+ string session_id = 1;
144
+ }
145
+
146
+ message AdminValidateSessionRequest {
147
+ string session_id = 1;
148
+ }
package/proto/buf.yaml CHANGED
@@ -3,8 +3,6 @@ version: v2
3
3
  lint:
4
4
  use:
5
5
  - STANDARD
6
- except:
7
- - PACKAGE_DIRECTORY_MATCH
8
6
 
9
7
  breaking:
10
8
  use:
@@ -0,0 +1,27 @@
1
+ syntax = "proto3";
2
+
3
+ package user.v1;
4
+
5
+ service UserService {
6
+ rpc GetUserById(GetUserByIdRequest) returns (GetUserByIdResponse);
7
+ }
8
+
9
+ message User {
10
+ string id = 1;
11
+ string email = 2;
12
+ string display_name = 3;
13
+ string picture = 4;
14
+ string role = 5;
15
+ string auth_provider = 6;
16
+ bool is_verified = 7;
17
+ string created_at = 8;
18
+ string updated_at = 9;
19
+ }
20
+
21
+ message GetUserByIdRequest {
22
+ string user_id = 1;
23
+ }
24
+
25
+ message GetUserByIdResponse {
26
+ User user = 1;
27
+ }
package/generated/auth.ts DELETED
@@ -1,62 +0,0 @@
1
- // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
- // versions:
3
- // protoc-gen-ts_proto v2.11.6
4
- // protoc v3.21.12
5
- // source: auth.proto
6
-
7
- /* eslint-disable */
8
- import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
- import { Observable } from "rxjs";
10
-
11
- export const protobufPackage = "auth.v1";
12
-
13
- export interface SendOtpRequest {
14
- identifier: string;
15
- type: string;
16
- }
17
-
18
- export interface SendOtpResponse {
19
- ok: boolean;
20
- }
21
-
22
- export interface VerifyOtpRequest {
23
- identifier: string;
24
- type: string;
25
- code: string;
26
- }
27
-
28
- export interface VerifyOtpResponse {
29
- accessToken: string;
30
- refreshToken: string;
31
- }
32
-
33
- export const AUTH_V1_PACKAGE_NAME = "auth.v1";
34
-
35
- export interface AuthServiceClient {
36
- sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
37
-
38
- verifyOtp(request: VerifyOtpRequest): Observable<VerifyOtpResponse>;
39
- }
40
-
41
- export interface AuthServiceController {
42
- sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
43
-
44
- verifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse> | Observable<VerifyOtpResponse> | VerifyOtpResponse;
45
- }
46
-
47
- export function AuthServiceControllerMethods() {
48
- return function (constructor: Function) {
49
- const grpcMethods: string[] = ["sendOtp", "verifyOtp"];
50
- for (const method of grpcMethods) {
51
- const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
52
- GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
53
- }
54
- const grpcStreamMethods: string[] = [];
55
- for (const method of grpcStreamMethods) {
56
- const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
57
- GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
58
- }
59
- };
60
- }
61
-
62
- export const AUTH_SERVICE_NAME = "AuthService";
package/proto/auth.proto DELETED
@@ -1,28 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package auth.v1;
4
-
5
- service AuthService {
6
- rpc SendOtp(SendOtpRequest) returns (SendOtpResponse);
7
- rpc VerifyOtp(VerifyOtpRequest) returns (VerifyOtpResponse);
8
- }
9
-
10
- message SendOtpRequest {
11
- string identifier = 1;
12
- string type = 2;
13
- }
14
-
15
- message SendOtpResponse {
16
- bool ok = 1;
17
- }
18
-
19
- message VerifyOtpRequest {
20
- string identifier = 1;
21
- string type = 2;
22
- string code = 3;
23
- }
24
-
25
- message VerifyOtpResponse {
26
- string access_token = 1;
27
- string refresh_token = 2;
28
- }