@aepstore-dev/contracts 1.0.6 → 1.2.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/proto/auth.proto CHANGED
@@ -2,37 +2,120 @@ syntax = "proto3";
2
2
 
3
3
  package auth.v1;
4
4
 
5
+ // Ported from legacy auth-service (@MessagePattern → @GrpcMethod).
6
+ // All tokens are HMAC primitives minted by @aepstore-dev/passport;
7
+ // the access token only carries `userId`. Username / roles / 2FA state
8
+ // must be looked up via Prisma or RbacService on the consumer side.
5
9
  service AuthService {
6
- rpc SendOtp (SendOtpRequest) returns (SendOtpResponse);
7
- rpc VerifyOtp (VerifyOtpRequest) returns (VerifyOtpResponse);
8
- rpc Refresh (RefreshRequest) returns (RefreshResponse);
10
+ rpc Login(LoginRequest) returns (AuthResponse);
11
+ rpc Register(RegisterRequest) returns (AuthResponse);
12
+ rpc CreateCode(CreateCodeRequest) returns (CreateCodeResponse);
13
+ rpc VerifyCode(VerifyCodeRequest) returns (VerifyCodeResponse);
14
+ rpc CheckToken(CheckTokenRequest) returns (CheckTokenResponse);
15
+ rpc RefreshToken(RefreshTokenRequest) returns (AuthResponse);
16
+ rpc Get2faStatus(Get2faStatusRequest) returns (Get2faStatusResponse);
17
+ rpc GetProfile(GetProfileRequest) returns (UserProfileResponse);
18
+ rpc CleanupExpiredTotpSetups(Empty) returns (Empty);
9
19
  }
10
20
 
11
- message SendOtpRequest {
12
- string identifier = 1;
21
+ // Login by username OR email (one of the two must be set).
22
+ message LoginRequest {
23
+ string password = 1;
24
+ string username = 2; // optional
25
+ string email = 3; // optional
26
+ }
27
+
28
+ message RegisterRequest {
29
+ string email = 1;
30
+ string username = 2;
31
+ string password = 3;
32
+ string ip = 4; // optional, attached by gateway from req
33
+ }
34
+
35
+ // Standard tokens-plus-user payload returned by Login / Register / RefreshToken.
36
+ message AuthResponse {
37
+ string access_token = 1;
38
+ string refresh_token = 2;
39
+ AuthUser user = 3;
40
+ }
41
+
42
+ message AuthUser {
43
+ string id = 1;
44
+ string email = 2;
45
+ string username = 3;
46
+ string role = 4; // primary role for backwards compat ("User" / "Administrator" / "Moderator")
47
+ }
48
+
49
+ // Code types: '2fa', 'reset', 'confirm', 'totp' (legacy strings preserved as-is).
50
+ message CreateCodeRequest {
51
+ string email = 1;
13
52
  string type = 2;
14
53
  }
15
54
 
16
- message SendOtpResponse {
55
+ message CreateCodeResponse {
17
56
  bool ok = 1;
18
57
  }
19
58
 
20
- message VerifyOtpRequest {
21
- string identifier = 1;
22
- string type = 2;
23
- string code = 3;
59
+ // `new_password` is only used by the 'reset' flow.
60
+ message VerifyCodeRequest {
61
+ string email = 1;
62
+ string code = 2;
63
+ string type = 3;
64
+ string new_password = 4; // optional
24
65
  }
25
66
 
26
- message VerifyOtpResponse {
27
- string access_token = 1;
28
- string refresh_token = 2;
67
+ // Some verification flows (e.g. confirm-on-register) issue tokens immediately;
68
+ // others just return ok=true.
69
+ message VerifyCodeResponse {
70
+ bool ok = 1;
71
+ string access_token = 2; // optional
72
+ string refresh_token = 3; // optional
73
+ }
74
+
75
+ message CheckTokenRequest {
76
+ string token = 1;
77
+ }
78
+
79
+ message CheckTokenResponse {
80
+ bool valid = 1;
81
+ string user_id = 2;
82
+ string reason = 3; // populated when valid=false
29
83
  }
30
84
 
31
- message RefreshRequest {
85
+ message RefreshTokenRequest {
32
86
  string refresh_token = 1;
87
+ string user_agent = 2; // optional
88
+ string ip = 3; // optional
33
89
  }
34
90
 
35
- message RefreshResponse {
36
- string access_token = 1;
37
- string refresh_token = 2;
38
- }
91
+ message Get2faStatusRequest {
92
+ string username = 1;
93
+ }
94
+
95
+ message Get2faStatusResponse {
96
+ bool enabled = 1;
97
+ TwoFactorType type = 2;
98
+ }
99
+
100
+ enum TwoFactorType {
101
+ NONE = 0;
102
+ APP = 1;
103
+ EMAIL = 2;
104
+ }
105
+
106
+ message GetProfileRequest {
107
+ string user_id = 1;
108
+ }
109
+
110
+ message UserProfileResponse {
111
+ string id = 1;
112
+ string email = 2;
113
+ string username = 3;
114
+ string full_name = 4;
115
+ bool is_verified = 5;
116
+ bool two_factor_enabled = 6;
117
+ TwoFactorType two_factor_type = 7;
118
+ repeated string roles = 8;
119
+ }
120
+
121
+ message Empty {}
@@ -0,0 +1,42 @@
1
+ syntax = "proto3";
2
+
3
+ package mail.v1;
4
+
5
+ // Legacy mail-service used @EventPattern (fire-and-forget). In the new gRPC
6
+ // stack each becomes a unary RPC that returns an Ack. Callers ignore the
7
+ // response if they don't care about delivery.
8
+ service MailService {
9
+ rpc SendReg(SendRegRequest) returns (MailAck);
10
+ rpc Send2fa(Send2faRequest) returns (MailAck);
11
+ rpc SendPasswordReset(SendPasswordResetRequest) returns (MailAck);
12
+ rpc SendRegistrationConfirm(SendRegistrationConfirmRequest) returns (MailAck);
13
+ }
14
+
15
+ message MailAck {
16
+ bool queued = 1;
17
+ }
18
+
19
+ message SendRegRequest {
20
+ string user_id = 1;
21
+ string email = 2;
22
+ string username = 3;
23
+ string full_name = 4;
24
+ }
25
+
26
+ message Send2faRequest {
27
+ string email = 1;
28
+ string code = 2;
29
+ string username = 3;
30
+ }
31
+
32
+ message SendPasswordResetRequest {
33
+ string email = 1;
34
+ string code = 2;
35
+ string username = 3;
36
+ }
37
+
38
+ message SendRegistrationConfirmRequest {
39
+ string email = 1;
40
+ string code = 2;
41
+ string username = 3;
42
+ }
@@ -0,0 +1,327 @@
1
+ syntax = "proto3";
2
+
3
+ package products.v1;
4
+
5
+ service ProductsService {
6
+ rpc Create(CreateProductRequest) returns (ProductResponse);
7
+ rpc FindAll(QueryProductsRequest) returns (ProductsListResponse);
8
+ rpc FindAllApproved(QueryProductsRequest) returns (ProductsListResponse);
9
+ rpc FindMy(FindMyRequest) returns (ProductsListResponse);
10
+ rpc FindOne(FindOneRequest) returns (ProductResponse);
11
+ rpc Update(UpdateProductRequest) returns (ProductResponse);
12
+ rpc Remove(RemoveProductRequest) returns (Ok);
13
+ rpc SubmitForModeration(SubmitForModerationRequest) returns (ProductResponse);
14
+ rpc GetPriceRange(Empty) returns (PriceRangeResponse);
15
+
16
+ rpc AddToFavorites(FavoriteRequest) returns (Ok);
17
+ rpc RemoveFromFavorites(FavoriteRequest) returns (Ok);
18
+
19
+ rpc SaveMediaMetadata(SaveMediaMetadataRequest) returns (ProductResponse);
20
+ rpc SaveAttachmentMetadata(SaveAttachmentMetadataRequest) returns (ProductResponse);
21
+
22
+ rpc GetProductsForModeration(ProductModerationQueryRequest) returns (ProductsListResponse);
23
+ rpc ModerateProduct(ModerateProductRequest) returns (ModerationResponse);
24
+ rpc ResubmitProduct(ResubmitProductRequest) returns (ProductResponse);
25
+
26
+ rpc GetSecureDownloadLinks(GetSecureDownloadLinksRequest) returns (SecureDownloadLinksResponse);
27
+ rpc GetAttachmentDownloadInfo(GetAttachmentDownloadInfoRequest) returns (AttachmentDownloadInfoResponse);
28
+ rpc GetAttachmentStream(GetAttachmentStreamRequest) returns (stream AttachmentChunk);
29
+
30
+ rpc GetTopProduct(Empty) returns (ProductResponse);
31
+ rpc GetPopularProducts(QueryProductsRequest) returns (ProductsListResponse);
32
+ }
33
+
34
+ // =================================================================
35
+ // Enums
36
+ // =================================================================
37
+
38
+ enum ProductStatus {
39
+ PRODUCT_STATUS_UNSPECIFIED = 0;
40
+ PRODUCT_STATUS_ACTIVE = 1;
41
+ PRODUCT_STATUS_DRAFT = 2;
42
+ }
43
+
44
+ enum ModerationStatus {
45
+ MODERATION_STATUS_UNSPECIFIED = 0;
46
+ MODERATION_STATUS_PENDING = 1;
47
+ MODERATION_STATUS_APPROVED = 2;
48
+ MODERATION_STATUS_REJECTED = 3;
49
+ }
50
+
51
+ enum MediaType {
52
+ MEDIA_TYPE_UNSPECIFIED = 0;
53
+ MEDIA_TYPE_IMAGE = 1;
54
+ MEDIA_TYPE_VIDEO = 2;
55
+ }
56
+
57
+ // =================================================================
58
+ // Nested entities
59
+ // =================================================================
60
+
61
+ message Category {
62
+ string id = 1;
63
+ string name = 2;
64
+ }
65
+
66
+ message Application {
67
+ string id = 1;
68
+ string name = 2;
69
+ }
70
+
71
+ message Tag {
72
+ string id = 1;
73
+ string name = 2;
74
+ }
75
+
76
+ message ProductMedia {
77
+ string id = 1;
78
+ string url = 2;
79
+ MediaType type = 3;
80
+ }
81
+
82
+ message Attachment {
83
+ string id = 1;
84
+ string url = 2;
85
+ string file_key = 3;
86
+ string file_name = 4;
87
+ double file_size = 5;
88
+ string created_at = 6;
89
+ }
90
+
91
+ message ProductUser {
92
+ string id = 1;
93
+ string username = 2;
94
+ string avatar_url = 3;
95
+ }
96
+
97
+ message Product {
98
+ string id = 1;
99
+ string name = 2;
100
+ string description = 3;
101
+ string price = 4; // Decimal as string (D7)
102
+ string discount_percent = 5; // Decimal as string
103
+ string final_price = 6; // Decimal as string
104
+ string average_rating = 7; // double as string for consistency
105
+ ProductStatus status = 8;
106
+ ModerationStatus moderation_status = 9;
107
+ string moderation_comment = 10;
108
+ string moderated_by = 11;
109
+ string moderated_at = 12;
110
+ string created_at = 13;
111
+ string updated_at = 14;
112
+ string preview = 15;
113
+ string video = 16;
114
+ ProductUser user = 17;
115
+ repeated ProductMedia media = 18;
116
+ repeated Category categories = 19;
117
+ repeated Application applications = 20;
118
+ repeated Tag tags = 21;
119
+ }
120
+
121
+ message ProductResponse {
122
+ Product product = 1;
123
+ }
124
+
125
+ message ProductsListResponse {
126
+ repeated Product items = 1;
127
+ int32 total = 2;
128
+ int32 page = 3;
129
+ int32 limit = 4;
130
+ }
131
+
132
+ message Ok {
133
+ bool ok = 1;
134
+ }
135
+
136
+ message Empty {}
137
+
138
+ // =================================================================
139
+ // Create / Update / Query
140
+ // =================================================================
141
+
142
+ message CreateProductRequest {
143
+ string user_id = 1;
144
+ string name = 2;
145
+ string price = 3; // Decimal as string
146
+ repeated string category_ids = 4;
147
+ repeated string application_ids = 5;
148
+ repeated string tags = 6;
149
+ string discount_percent = 7; // optional
150
+ string final_price = 8; // optional
151
+ string video = 9;
152
+ string description = 10;
153
+ ProductStatus status = 11;
154
+ }
155
+
156
+ message UpdateProductRequest {
157
+ string user_id = 1;
158
+ string id = 2;
159
+ string name = 3;
160
+ string description = 4;
161
+ string price = 5;
162
+ string discount_percent = 6;
163
+ string final_price = 7;
164
+ repeated string tags = 8;
165
+ }
166
+
167
+ message QueryProductsRequest {
168
+ string search = 1;
169
+ repeated string category_ids = 2;
170
+ repeated string application_ids = 3;
171
+ repeated string tags = 4;
172
+ string min_price = 5;
173
+ string max_price = 6;
174
+ int32 page = 7;
175
+ int32 limit = 8;
176
+ string sort_by = 9; // createdAt | price | name | updatedAt | finalPrice
177
+ string sort_order = 10; // asc | desc
178
+ ProductStatus status = 11;
179
+ ModerationStatus moderation_status = 12;
180
+ }
181
+
182
+ message FindMyRequest {
183
+ string user_id = 1;
184
+ QueryProductsRequest query = 2;
185
+ }
186
+
187
+ message FindOneRequest {
188
+ string id = 1;
189
+ string viewer_user_id = 2; // optional — to compute is_favorited etc.
190
+ }
191
+
192
+ message RemoveProductRequest {
193
+ string id = 1;
194
+ string user_id = 2;
195
+ }
196
+
197
+ message SubmitForModerationRequest {
198
+ string id = 1;
199
+ string user_id = 2;
200
+ }
201
+
202
+ message PriceRangeResponse {
203
+ string min = 1; // Decimal as string
204
+ string max = 2;
205
+ }
206
+
207
+ // =================================================================
208
+ // Favorites
209
+ // =================================================================
210
+
211
+ message FavoriteRequest {
212
+ string user_id = 1;
213
+ string product_id = 2;
214
+ }
215
+
216
+ // =================================================================
217
+ // Media / Attachments metadata
218
+ // =================================================================
219
+
220
+ message MediaFile {
221
+ string url = 1;
222
+ MediaType type = 2;
223
+ }
224
+
225
+ message SaveMediaMetadataRequest {
226
+ string id = 1;
227
+ string user_id = 2;
228
+ repeated MediaFile files = 3;
229
+ string upload_id = 4;
230
+ }
231
+
232
+ message AttachmentMeta {
233
+ string url = 1;
234
+ string file_key = 2;
235
+ string file_name = 3;
236
+ double file_size = 4;
237
+ }
238
+
239
+ message SaveAttachmentMetadataRequest {
240
+ string id = 1;
241
+ string user_id = 2;
242
+ AttachmentMeta attachment = 3;
243
+ string upload_id = 4;
244
+ }
245
+
246
+ // =================================================================
247
+ // Moderation
248
+ // =================================================================
249
+
250
+ message ProductModerationQueryRequest {
251
+ ModerationStatus status = 1;
252
+ int32 page = 2;
253
+ int32 limit = 3;
254
+ string sort_by = 4;
255
+ string sort_order = 5;
256
+ }
257
+
258
+ message ModerateProductRequest {
259
+ string product_id = 1;
260
+ string moderator_id = 2;
261
+ string action = 3; // 'approve' | 'reject'
262
+ string comment = 4;
263
+ }
264
+
265
+ message ModerationResponse {
266
+ bool success = 1;
267
+ string message = 2;
268
+ Product product = 3;
269
+ ModerationStatus moderation_status = 4;
270
+ string moderation_comment = 5;
271
+ string moderated_by = 6;
272
+ string moderated_at = 7;
273
+ }
274
+
275
+ message ResubmitProductRequest {
276
+ string product_id = 1;
277
+ string user_id = 2;
278
+ string comment = 3;
279
+ // Free-form payload of changes — serialized as JSON string to keep the
280
+ // legacy `any` shape without forcing a strict schema on a free-form patch.
281
+ string changes_json = 4;
282
+ }
283
+
284
+ // =================================================================
285
+ // Secure downloads
286
+ // =================================================================
287
+
288
+ message GetSecureDownloadLinksRequest {
289
+ string product_id = 1;
290
+ string user_id = 2;
291
+ int32 expires_in = 3;
292
+ }
293
+
294
+ message SecureDownloadLink {
295
+ string download_url = 1;
296
+ int32 expires_in = 2;
297
+ string file_name = 3;
298
+ double file_size = 4;
299
+ string attachment_id = 5;
300
+ }
301
+
302
+ message SecureDownloadLinksResponse {
303
+ repeated SecureDownloadLink links = 1;
304
+ }
305
+
306
+ message GetAttachmentDownloadInfoRequest {
307
+ string product_id = 1;
308
+ string attachment_id = 2;
309
+ string user_id = 3;
310
+ }
311
+
312
+ message AttachmentDownloadInfoResponse {
313
+ string file_name = 1;
314
+ double file_size = 2;
315
+ string content_type = 3;
316
+ }
317
+
318
+ message GetAttachmentStreamRequest {
319
+ string product_id = 1;
320
+ string attachment_id = 2;
321
+ string user_id = 3;
322
+ }
323
+
324
+ message AttachmentChunk {
325
+ bytes data = 1;
326
+ bool last = 2;
327
+ }
@@ -0,0 +1,78 @@
1
+ syntax = "proto3";
2
+
3
+ package taxonomy.v1;
4
+
5
+ service TaxonomyService {
6
+ rpc FindAllCategories(Empty) returns (CategoriesListResponse);
7
+ rpc FindAllApplications(Empty) returns (ApplicationsListResponse);
8
+ rpc FindAllTags(QueryTagsRequest) returns (TagsListResponse);
9
+
10
+ rpc CreateCategory(CreateCategoryRequest) returns (CategoryResponse);
11
+ rpc CreateApplication(CreateApplicationRequest) returns (ApplicationResponse);
12
+ }
13
+
14
+ message Category {
15
+ string id = 1;
16
+ string name = 2;
17
+ string description = 3;
18
+ string created_at = 4;
19
+ string updated_at = 5;
20
+ }
21
+
22
+ message Application {
23
+ string id = 1;
24
+ string name = 2;
25
+ string description = 3;
26
+ string created_at = 4;
27
+ string updated_at = 5;
28
+ }
29
+
30
+ message Tag {
31
+ string id = 1;
32
+ string name = 2;
33
+ }
34
+
35
+ // =================================================================
36
+ // Requests / responses
37
+ // =================================================================
38
+
39
+ message Empty {}
40
+
41
+ message CategoriesListResponse {
42
+ repeated Category items = 1;
43
+ }
44
+
45
+ message ApplicationsListResponse {
46
+ repeated Application items = 1;
47
+ }
48
+
49
+ message QueryTagsRequest {
50
+ string search = 1;
51
+ int32 page = 2;
52
+ int32 limit = 3;
53
+ }
54
+
55
+ message TagsListResponse {
56
+ repeated Tag items = 1;
57
+ int32 total = 2;
58
+ int32 page = 3;
59
+ int32 limit = 4;
60
+ }
61
+
62
+ message CreateCategoryRequest {
63
+ string name = 1;
64
+ string description = 2;
65
+ }
66
+
67
+ message CategoryResponse {
68
+ Category category = 1;
69
+ }
70
+
71
+ message CreateApplicationRequest {
72
+ string name = 1;
73
+ string description = 2;
74
+ }
75
+
76
+ message ApplicationResponse {
77
+ Application application = 1;
78
+ }