@aepstore-dev/contracts 1.32.0 → 1.33.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/users.proto CHANGED
@@ -1,286 +1,411 @@
1
- syntax = "proto3";
2
-
3
- package users.v1;
4
-
5
- service UsersService {
6
- rpc GetPublicProfile(GetPublicProfileRequest) returns (PublicProfileResponse);
7
- rpc UpdateProfile(UpdateProfileRequest) returns (PublicProfileResponse);
8
- rpc UpdateUser(UpdateUserRequest) returns (UserResponse);
9
- rpc UpdateUserRole(UpdateUserRoleRequest) returns (UserResponse);
10
- rpc GetUsers(GetUsersRequest) returns (GetUsersResponse);
11
- rpc GetActiveDevices(GetActiveDevicesRequest) returns (GetActiveDevicesResponse);
12
- rpc ManageDevices(ManageDevicesRequest) returns (ManageDevicesResponse);
13
- rpc GetUserFields(GetUserFieldsRequest) returns (GetUserFieldsResponse);
14
-
15
- rpc CreateSubscription(SubscriptionRequest) returns (SubscriptionResponse);
16
- rpc DeleteSubscription(SubscriptionRequest) returns (SubscriptionResponse);
17
-
18
- rpc BanUser(BanUserRequest) returns (UserResponse);
19
- rpc UnbanUser(UnbanUserRequest) returns (UserResponse);
20
- }
21
-
22
- // =================================================================
23
- // Common types
24
- // =================================================================
25
-
26
- message User {
27
- string id = 1;
28
- string email = 2;
29
- string username = 3;
30
- string avatar_url = 4;
31
- repeated string roles = 5;
32
- string role = 6; // primary role for backwards compat
33
- string created_at = 7; // ISO 8601
34
- string updated_at = 8;
35
- bool is_banned = 9;
36
- string banned_until = 10; // ISO 8601, empty = permanent/none
37
- string ban_reason = 11;
38
- }
39
-
40
- message BanUserRequest {
41
- string admin_id = 1;
42
- string user_id = 2;
43
- string reason = 3;
44
- string until = 4; // ISO 8601; empty = permanent ban
45
- }
46
-
47
- message UnbanUserRequest {
48
- string admin_id = 1;
49
- string user_id = 2;
50
- }
51
-
52
- message Country {
53
- string id = 1;
54
- string code = 2;
55
- string name = 3;
56
- }
57
-
58
- message SocialMedia {
59
- string id = 1;
60
- string platform = 2;
61
- string url = 3;
62
- }
63
-
64
- message CreateSocialMedia {
65
- string platform = 1;
66
- string url = 2;
67
- }
68
-
69
- message ProductUser {
70
- string id = 1;
71
- string username = 2;
72
- string avatar_url = 3;
73
- }
74
-
75
- message Category {
76
- string id = 1;
77
- string name = 2;
78
- }
79
-
80
- message Product {
81
- string id = 1;
82
- string name = 2;
83
- string description = 3;
84
- string price = 4; // Decimal as string (D7)
85
- string created_at = 5;
86
- string updated_at = 6;
87
- // profile-card preview fields
88
- string preview = 7;
89
- string final_price = 8; // Decimal as string
90
- string average_rating = 9; // number as string
91
- string status = 10;
92
- // Author of the product (same person as the profile owner, but echoed per
93
- // product so cards can render the author independently).
94
- ProductUser user = 11;
95
- repeated Category categories = 12;
96
- }
97
-
98
- message Video {
99
- string id = 1;
100
- string title = 2;
101
- string description = 3;
102
- string url = 4;
103
- string created_at = 5;
104
- string updated_at = 6;
105
- }
106
-
107
- message ActiveDevice {
108
- string id = 1;
109
- string user_agent = 2;
110
- string ip = 3;
111
- string created_at = 4;
112
- string last_used_at = 5;
113
- }
114
-
115
- message ProfileStats {
116
- int32 subscribers_count = 1;
117
- int32 subscriptions_count = 2;
118
- int32 products_count = 3;
119
- int32 videos_count = 4;
120
- }
121
-
122
- // Compact public user card for subscriber/subscription lists — no email/ban data.
123
- message ProfileUser {
124
- string id = 1;
125
- string username = 2;
126
- string avatar_url = 3;
127
- }
128
-
129
- // =================================================================
130
- // GetPublicProfile
131
- // =================================================================
132
-
133
- message GetPublicProfileRequest {
134
- string username = 1;
135
- string viewer_user_id = 2; // optional — present when caller is authenticated
136
- }
137
-
138
- message PublicProfileResponse {
139
- string id = 1;
140
- string username = 2;
141
- string full_name = 3;
142
- string rating = 4; // Decimal as string
143
- string about_me = 5;
144
- repeated SocialMedia social_media = 6;
145
- ProfileStats stats = 7;
146
- repeated Video videos = 8;
147
- repeated Product products = 9;
148
- Country country = 10;
149
- string avatar_url = 11;
150
- string banner_url = 12;
151
- string role = 13;
152
- string created_at = 14;
153
- bool hide_subscriptions = 15;
154
- // Either populated lists or empty depending on hide_subscriptions
155
- repeated ProfileUser subscriptions = 16;
156
- repeated ProfileUser subscribers = 17;
157
- bool is_owner = 18;
158
- bool is_subscribed = 19; // viewer is subscribed to this profile (false when anonymous / self)
159
- }
160
-
161
- // =================================================================
162
- // UpdateProfile
163
- // =================================================================
164
-
165
- message UpdateProfileRequest {
166
- string user_id = 1;
167
- string full_name = 2;
168
- string about_me = 3;
169
- bool newsletter_subscription = 4;
170
- bool hide_subscriptions = 5;
171
- string avatar_url = 6;
172
- string banner_url = 7;
173
- string country_id = 8;
174
- string timezone = 9;
175
- repeated CreateSocialMedia social_media = 10;
176
- }
177
-
178
- // =================================================================
179
- // UpdateUser
180
- // =================================================================
181
-
182
- message UpdateUserRequest {
183
- string user_id = 1;
184
- string username = 2;
185
- string email = 3;
186
- string code = 4; // confirmation code when changing email/username
187
- }
188
-
189
- message UserResponse {
190
- User user = 1;
191
- }
192
-
193
- // =================================================================
194
- // UpdateUserRole (admin)
195
- // =================================================================
196
-
197
- message UpdateUserRoleRequest {
198
- string admin_id = 1;
199
- string user_id = 2;
200
- string role = 3;
201
- string action = 4; // "grant" (default) | "revoke"
202
- }
203
-
204
- // =================================================================
205
- // GetUsers (paginated)
206
- // =================================================================
207
-
208
- message GetUsersRequest {
209
- string page = 1;
210
- string limit = 2;
211
- string search = 3;
212
- string role_name = 4;
213
- }
214
-
215
- message GetUsersResponse {
216
- repeated User items = 1;
217
- int32 total = 2;
218
- int32 page = 3;
219
- int32 limit = 4;
220
- }
221
-
222
- // =================================================================
223
- // Active devices
224
- // =================================================================
225
-
226
- message GetActiveDevicesRequest {
227
- string user_id = 1;
228
- }
229
-
230
- message GetActiveDevicesResponse {
231
- repeated ActiveDevice devices = 1;
232
- }
233
-
234
- message ManageDevicesRequest {
235
- string user_id = 1;
236
- repeated string device_ids_to_remove = 2;
237
- }
238
-
239
- message ManageDevicesResponse {
240
- bool ok = 1;
241
- int32 removed_count = 2;
242
- }
243
-
244
- // =================================================================
245
- // GetUserFields — paginated dynamic field sets
246
- // =================================================================
247
-
248
- enum UserFieldsType {
249
- USER_FIELDS_TYPE_UNSPECIFIED = 0;
250
- USER_FIELDS_TYPE_VIDEOS = 1;
251
- USER_FIELDS_TYPE_PRODUCTS = 2;
252
- USER_FIELDS_TYPE_SUBSCRIPTIONS = 3;
253
- USER_FIELDS_TYPE_SUBSCRIBERS = 4;
254
- }
255
-
256
- message GetUserFieldsRequest {
257
- string username = 1;
258
- UserFieldsType type = 2;
259
- int32 page = 3;
260
- int32 limit = 4;
261
- string viewer_user_id = 5; // optional
262
- }
263
-
264
- message GetUserFieldsResponse {
265
- repeated Video videos = 1;
266
- repeated Product products = 2;
267
- repeated ProfileUser subscriptions = 3;
268
- repeated ProfileUser subscribers = 4;
269
- int32 total = 5;
270
- int32 page = 6;
271
- int32 limit = 7;
272
- }
273
-
274
- // =================================================================
275
- // Subscriptions
276
- // =================================================================
277
-
278
- message SubscriptionRequest {
279
- string subscriber_id = 1; // the authenticated user performing the action
280
- string target_id = 2; // the user being (un)subscribed to/from
281
- }
282
-
283
- message SubscriptionResponse {
284
- bool subscribed = 1; // state after the call
285
- int32 subscribers_count = 2; // target's subscriber count after the call
286
- }
1
+ syntax = "proto3";
2
+
3
+ package users.v1;
4
+
5
+ service UsersService {
6
+ rpc GetPublicProfile(GetPublicProfileRequest) returns (PublicProfileResponse);
7
+ rpc UpdateProfile(UpdateProfileRequest) returns (PublicProfileResponse);
8
+ rpc UpdateUser(UpdateUserRequest) returns (UserResponse);
9
+ rpc UpdateUserRole(UpdateUserRoleRequest) returns (UserResponse);
10
+ rpc GetUsers(GetUsersRequest) returns (GetUsersResponse);
11
+ rpc GetActiveDevices(GetActiveDevicesRequest) returns (GetActiveDevicesResponse);
12
+ rpc ManageDevices(ManageDevicesRequest) returns (ManageDevicesResponse);
13
+ rpc GetUserFields(GetUserFieldsRequest) returns (GetUserFieldsResponse);
14
+
15
+ rpc CreateSubscription(SubscriptionRequest) returns (SubscriptionResponse);
16
+ rpc DeleteSubscription(SubscriptionRequest) returns (SubscriptionResponse);
17
+
18
+ rpc BanUser(BanUserRequest) returns (UserResponse);
19
+ rpc UnbanUser(UnbanUserRequest) returns (UserResponse);
20
+
21
+ // Premium (paid). State lives in users-service; payments-service handles
22
+ // money and calls ActivatePremium (internal) on completion.
23
+ rpc GetMyPremium(GetMyPremiumRequest) returns (PremiumStateResponse);
24
+ rpc SetPremiumAutoRenew(SetPremiumAutoRenewRequest) returns (PremiumStateResponse);
25
+ // Internal — InternalServiceGuard. Called by payments-service after a
26
+ // successful premium payment (balance or YooKassa webhook).
27
+ rpc ActivatePremium(ActivatePremiumRequest) returns (PremiumStateResponse);
28
+ // Internal fast lookup for the commission engine in payments-service.
29
+ rpc IsPremiumActive(IsPremiumActiveRequest) returns (IsPremiumActiveResponse);
30
+
31
+ // Avatar borders (catalog + admin CRUD). Catalog read is public; mutations
32
+ // are admin only (gateway enforces with RolesGuard).
33
+ rpc ListAvatarBorders(ListAvatarBordersRequest) returns (ListAvatarBordersResponse);
34
+ rpc UpsertAvatarBorder(UpsertAvatarBorderRequest) returns (AvatarBorder);
35
+ rpc DeleteAvatarBorder(DeleteAvatarBorderRequest) returns (DeleteAvatarBorderResponse);
36
+ }
37
+
38
+ // =================================================================
39
+ // Common types
40
+ // =================================================================
41
+
42
+ message User {
43
+ string id = 1;
44
+ string email = 2;
45
+ string username = 3;
46
+ string avatar_url = 4;
47
+ repeated string roles = 5;
48
+ string role = 6; // primary role for backwards compat
49
+ string created_at = 7; // ISO 8601
50
+ string updated_at = 8;
51
+ bool is_banned = 9;
52
+ string banned_until = 10; // ISO 8601, empty = permanent/none
53
+ string ban_reason = 11;
54
+ }
55
+
56
+ message BanUserRequest {
57
+ string admin_id = 1;
58
+ string user_id = 2;
59
+ string reason = 3;
60
+ string until = 4; // ISO 8601; empty = permanent ban
61
+ }
62
+
63
+ message UnbanUserRequest {
64
+ string admin_id = 1;
65
+ string user_id = 2;
66
+ }
67
+
68
+ message Country {
69
+ string id = 1;
70
+ string code = 2;
71
+ string name = 3;
72
+ }
73
+
74
+ message SocialMedia {
75
+ string id = 1;
76
+ string platform = 2;
77
+ string url = 3;
78
+ }
79
+
80
+ message CreateSocialMedia {
81
+ string platform = 1;
82
+ string url = 2;
83
+ }
84
+
85
+ message ProductUser {
86
+ string id = 1;
87
+ string username = 2;
88
+ string avatar_url = 3;
89
+ }
90
+
91
+ message Category {
92
+ string id = 1;
93
+ string name = 2;
94
+ }
95
+
96
+ message Product {
97
+ string id = 1;
98
+ string name = 2;
99
+ string description = 3;
100
+ string price = 4; // Decimal as string (D7)
101
+ string created_at = 5;
102
+ string updated_at = 6;
103
+ // profile-card preview fields
104
+ string preview = 7;
105
+ string final_price = 8; // Decimal as string
106
+ string average_rating = 9; // number as string
107
+ string status = 10;
108
+ // Author of the product (same person as the profile owner, but echoed per
109
+ // product so cards can render the author independently).
110
+ ProductUser user = 11;
111
+ repeated Category categories = 12;
112
+ }
113
+
114
+ message Video {
115
+ string id = 1;
116
+ string title = 2;
117
+ string description = 3;
118
+ string url = 4;
119
+ string created_at = 5;
120
+ string updated_at = 6;
121
+ }
122
+
123
+ message ActiveDevice {
124
+ string id = 1;
125
+ string user_agent = 2;
126
+ string ip = 3;
127
+ string created_at = 4;
128
+ string last_used_at = 5;
129
+ }
130
+
131
+ message ProfileStats {
132
+ int32 subscribers_count = 1;
133
+ int32 subscriptions_count = 2;
134
+ int32 products_count = 3;
135
+ int32 videos_count = 4;
136
+ }
137
+
138
+ // Compact public user card for subscriber/subscription lists — no email/ban data.
139
+ message ProfileUser {
140
+ string id = 1;
141
+ string username = 2;
142
+ string avatar_url = 3;
143
+ }
144
+
145
+ // =================================================================
146
+ // GetPublicProfile
147
+ // =================================================================
148
+
149
+ message GetPublicProfileRequest {
150
+ string username = 1;
151
+ string viewer_user_id = 2; // optional — present when caller is authenticated
152
+ }
153
+
154
+ message PublicProfileResponse {
155
+ string id = 1;
156
+ string username = 2;
157
+ string full_name = 3;
158
+ string rating = 4; // Decimal as string
159
+ string about_me = 5;
160
+ repeated SocialMedia social_media = 6;
161
+ ProfileStats stats = 7;
162
+ repeated Video videos = 8;
163
+ repeated Product products = 9;
164
+ Country country = 10;
165
+ string avatar_url = 11;
166
+ string banner_url = 12;
167
+ string role = 13;
168
+ string created_at = 14;
169
+ bool hide_subscriptions = 15;
170
+ // Either populated lists or empty depending on hide_subscriptions
171
+ repeated ProfileUser subscriptions = 16;
172
+ repeated ProfileUser subscribers = 17;
173
+ bool is_owner = 18;
174
+ bool is_subscribed = 19; // viewer is subscribed to this profile (false when anonymous / self)
175
+ // Premium fields populated only when the profile owner has an active
176
+ // PremiumSubscription. Non-premium viewers and non-premium profiles see
177
+ // empty strings / false.
178
+ bool is_premium = 20;
179
+ string profile_color = 21;
180
+ AvatarBorder avatar_border = 22;
181
+ string animated_avatar_url = 23;
182
+ string animated_banner_url = 24;
183
+ string premium_expires_at = 25; // ISO 8601, empty when not premium
184
+ }
185
+
186
+ // =================================================================
187
+ // UpdateProfile
188
+ // =================================================================
189
+
190
+ message UpdateProfileRequest {
191
+ string user_id = 1;
192
+ string full_name = 2;
193
+ string about_me = 3;
194
+ bool newsletter_subscription = 4;
195
+ bool hide_subscriptions = 5;
196
+ string avatar_url = 6;
197
+ string banner_url = 7;
198
+ string country_id = 8;
199
+ string timezone = 9;
200
+ repeated CreateSocialMedia social_media = 10;
201
+ // Premium-only fields rejected with FAILED_PRECONDITION when the caller
202
+ // has no active premium. Empty string clears the value.
203
+ string profile_color = 11;
204
+ string avatar_border_id = 12;
205
+ string animated_avatar_url = 13;
206
+ string animated_banner_url = 14;
207
+ }
208
+
209
+ // =================================================================
210
+ // UpdateUser
211
+ // =================================================================
212
+
213
+ message UpdateUserRequest {
214
+ string user_id = 1;
215
+ string username = 2;
216
+ string email = 3;
217
+ string code = 4; // confirmation code when changing email/username
218
+ }
219
+
220
+ message UserResponse {
221
+ User user = 1;
222
+ }
223
+
224
+ // =================================================================
225
+ // UpdateUserRole (admin)
226
+ // =================================================================
227
+
228
+ message UpdateUserRoleRequest {
229
+ string admin_id = 1;
230
+ string user_id = 2;
231
+ string role = 3;
232
+ string action = 4; // "grant" (default) | "revoke"
233
+ }
234
+
235
+ // =================================================================
236
+ // GetUsers (paginated)
237
+ // =================================================================
238
+
239
+ message GetUsersRequest {
240
+ string page = 1;
241
+ string limit = 2;
242
+ string search = 3;
243
+ string role_name = 4;
244
+ }
245
+
246
+ message GetUsersResponse {
247
+ repeated User items = 1;
248
+ int32 total = 2;
249
+ int32 page = 3;
250
+ int32 limit = 4;
251
+ }
252
+
253
+ // =================================================================
254
+ // Active devices
255
+ // =================================================================
256
+
257
+ message GetActiveDevicesRequest {
258
+ string user_id = 1;
259
+ }
260
+
261
+ message GetActiveDevicesResponse {
262
+ repeated ActiveDevice devices = 1;
263
+ }
264
+
265
+ message ManageDevicesRequest {
266
+ string user_id = 1;
267
+ repeated string device_ids_to_remove = 2;
268
+ }
269
+
270
+ message ManageDevicesResponse {
271
+ bool ok = 1;
272
+ int32 removed_count = 2;
273
+ }
274
+
275
+ // =================================================================
276
+ // GetUserFields — paginated dynamic field sets
277
+ // =================================================================
278
+
279
+ enum UserFieldsType {
280
+ USER_FIELDS_TYPE_UNSPECIFIED = 0;
281
+ USER_FIELDS_TYPE_VIDEOS = 1;
282
+ USER_FIELDS_TYPE_PRODUCTS = 2;
283
+ USER_FIELDS_TYPE_SUBSCRIPTIONS = 3;
284
+ USER_FIELDS_TYPE_SUBSCRIBERS = 4;
285
+ }
286
+
287
+ message GetUserFieldsRequest {
288
+ string username = 1;
289
+ UserFieldsType type = 2;
290
+ int32 page = 3;
291
+ int32 limit = 4;
292
+ string viewer_user_id = 5; // optional
293
+ }
294
+
295
+ message GetUserFieldsResponse {
296
+ repeated Video videos = 1;
297
+ repeated Product products = 2;
298
+ repeated ProfileUser subscriptions = 3;
299
+ repeated ProfileUser subscribers = 4;
300
+ int32 total = 5;
301
+ int32 page = 6;
302
+ int32 limit = 7;
303
+ }
304
+
305
+ // =================================================================
306
+ // Subscriptions
307
+ // =================================================================
308
+
309
+ message SubscriptionRequest {
310
+ string subscriber_id = 1; // the authenticated user performing the action
311
+ string target_id = 2; // the user being (un)subscribed to/from
312
+ }
313
+
314
+ message SubscriptionResponse {
315
+ bool subscribed = 1; // state after the call
316
+ int32 subscribers_count = 2; // target's subscriber count after the call
317
+ }
318
+
319
+ // =================================================================
320
+ // Premium
321
+ // =================================================================
322
+
323
+ // Periods mirror PremiumPeriod enum in schema.prisma.
324
+ enum PremiumPeriod {
325
+ PREMIUM_PERIOD_UNSPECIFIED = 0;
326
+ PREMIUM_PERIOD_MONTH_1 = 1;
327
+ PREMIUM_PERIOD_MONTH_3 = 2;
328
+ PREMIUM_PERIOD_MONTH_6 = 3;
329
+ PREMIUM_PERIOD_MONTH_12 = 4;
330
+ }
331
+
332
+ message GetMyPremiumRequest {
333
+ string user_id = 1;
334
+ }
335
+
336
+ message PremiumStateResponse {
337
+ bool is_active = 1;
338
+ string status = 2; // ACTIVE | EXPIRED | CANCELED | empty (never purchased)
339
+ PremiumPeriod current_period = 3;
340
+ string started_at = 4; // ISO 8601, empty when never purchased
341
+ string expires_at = 5; // ISO 8601
342
+ bool auto_renew = 6;
343
+ bool has_saved_payment_method = 7;
344
+ }
345
+
346
+ message SetPremiumAutoRenewRequest {
347
+ string user_id = 1;
348
+ bool enabled = 2;
349
+ }
350
+
351
+ // Internal — payments-service hands us the period that was just paid for, plus
352
+ // the YooKassa payment_method id (empty for balance/non-recurring purchases).
353
+ message ActivatePremiumRequest {
354
+ string user_id = 1;
355
+ PremiumPeriod period = 2;
356
+ string payment_method_id = 3; // empty for BALANCE / one-shot
357
+ bool is_renewal = 4; // false = first purchase; true = cron-driven renewal
358
+ }
359
+
360
+ message IsPremiumActiveRequest {
361
+ string user_id = 1;
362
+ }
363
+
364
+ message IsPremiumActiveResponse {
365
+ bool is_active = 1;
366
+ }
367
+
368
+ // =================================================================
369
+ // Avatar borders
370
+ // =================================================================
371
+
372
+ message AvatarBorder {
373
+ string id = 1;
374
+ string code = 2;
375
+ string name = 3;
376
+ string description = 4;
377
+ string image_url = 5;
378
+ bool is_animated = 6;
379
+ string source = 7;
380
+ int32 sort_order = 8;
381
+ bool is_active = 9;
382
+ }
383
+
384
+ message ListAvatarBordersRequest {
385
+ bool include_inactive = 1; // admin-only — gateway gates by role
386
+ string source = 2; // optional filter
387
+ }
388
+
389
+ message ListAvatarBordersResponse {
390
+ repeated AvatarBorder items = 1;
391
+ }
392
+
393
+ message UpsertAvatarBorderRequest {
394
+ string id = 1; // empty = create
395
+ string code = 2; // required when creating
396
+ string name = 3;
397
+ string description = 4;
398
+ string image_url = 5;
399
+ bool is_animated = 6;
400
+ string source = 7;
401
+ int32 sort_order = 8;
402
+ bool is_active = 9;
403
+ }
404
+
405
+ message DeleteAvatarBorderRequest {
406
+ string id = 1;
407
+ }
408
+
409
+ message DeleteAvatarBorderResponse {
410
+ bool ok = 1;
411
+ }