@aepstore-dev/contracts 1.10.0 → 1.12.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.
@@ -2,6 +2,7 @@ export declare const PROTO_PATHS: {
2
2
  readonly ACTIVITY: string;
3
3
  readonly AUTH: string;
4
4
  readonly MAIL: string;
5
+ readonly PAYMENTS: string;
5
6
  readonly PRODUCTS: string;
6
7
  readonly SUPPORT: string;
7
8
  readonly TAXONOMY: string;
@@ -12,6 +13,7 @@ export declare const PROTO_PACKAGES: {
12
13
  readonly ACTIVITY: "activity.v1";
13
14
  readonly AUTH: "auth.v1";
14
15
  readonly MAIL: "mail.v1";
16
+ readonly PAYMENTS: "payments.v1";
15
17
  readonly PRODUCTS: "products.v1";
16
18
  readonly SUPPORT: "support.v1";
17
19
  readonly TAXONOMY: "taxonomy.v1";
@@ -7,6 +7,7 @@ exports.PROTO_PATHS = {
7
7
  ACTIVITY: (0, path_1.join)(PROTO_DIR, "activity.proto"),
8
8
  AUTH: (0, path_1.join)(PROTO_DIR, "auth.proto"),
9
9
  MAIL: (0, path_1.join)(PROTO_DIR, "mail.proto"),
10
+ PAYMENTS: (0, path_1.join)(PROTO_DIR, "payments.proto"),
10
11
  PRODUCTS: (0, path_1.join)(PROTO_DIR, "products.proto"),
11
12
  SUPPORT: (0, path_1.join)(PROTO_DIR, "support.proto"),
12
13
  TAXONOMY: (0, path_1.join)(PROTO_DIR, "taxonomy.proto"),
@@ -17,6 +18,7 @@ exports.PROTO_PACKAGES = {
17
18
  ACTIVITY: "activity.v1",
18
19
  AUTH: "auth.v1",
19
20
  MAIL: "mail.v1",
21
+ PAYMENTS: "payments.v1",
20
22
  PRODUCTS: "products.v1",
21
23
  SUPPORT: "support.v1",
22
24
  TAXONOMY: "taxonomy.v1",
@@ -0,0 +1,257 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.10.1
4
+ // protoc v7.35.0
5
+ // source: payments.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "payments.v1";
12
+
13
+ export interface Ok {
14
+ ok: boolean;
15
+ }
16
+
17
+ /**
18
+ * ---------------------------------------------------------------------------
19
+ * Purchase / checkout
20
+ * ---------------------------------------------------------------------------
21
+ */
22
+ export interface Purchase {
23
+ id: string;
24
+ productId: string;
25
+ productName: string;
26
+ /** buyer */
27
+ userId: string;
28
+ /** Decimal as string */
29
+ price: string;
30
+ /** PENDING | COMPLETED | FAILED | REFUNDED */
31
+ status: string;
32
+ /** YooKassa payment id */
33
+ paymentId: string;
34
+ /** snapshot, Decimal as string */
35
+ commissionPercent: string;
36
+ /** snapshot, Decimal as string */
37
+ sellerAmount: string;
38
+ createdAt: string;
39
+ completedAt: string;
40
+ }
41
+
42
+ export interface CreateCheckoutRequest {
43
+ /** buyer */
44
+ userId: string;
45
+ productId: string;
46
+ /** optional override; where YooKassa returns the buyer */
47
+ returnUrl: string;
48
+ }
49
+
50
+ export interface CheckoutResponse {
51
+ purchaseId: string;
52
+ paymentId: string;
53
+ /** redirect the buyer here */
54
+ confirmationUrl: string;
55
+ status: string;
56
+ }
57
+
58
+ export interface PaymentEventRequest {
59
+ /** payment.succeeded | payment.canceled | refund.succeeded */
60
+ event: string;
61
+ /** YooKassa payment object id (re-fetched & verified by the service) */
62
+ paymentId: string;
63
+ }
64
+
65
+ export interface GetMyPurchasesRequest {
66
+ userId: string;
67
+ page: number;
68
+ limit: number;
69
+ }
70
+
71
+ export interface PurchasesListResponse {
72
+ items: Purchase[];
73
+ total: number;
74
+ page: number;
75
+ limit: number;
76
+ }
77
+
78
+ export interface GetPurchaseRequest {
79
+ id: string;
80
+ /** requester (must be buyer or admin) */
81
+ userId: string;
82
+ }
83
+
84
+ export interface RefundPurchaseRequest {
85
+ purchaseId: string;
86
+ /** buyer (own) or admin */
87
+ actorUserId: string;
88
+ isAdmin: boolean;
89
+ reason: string;
90
+ }
91
+
92
+ /**
93
+ * ---------------------------------------------------------------------------
94
+ * Seller balance & withdrawals
95
+ * ---------------------------------------------------------------------------
96
+ */
97
+ export interface GetSellerBalanceRequest {
98
+ sellerId: string;
99
+ }
100
+
101
+ export interface SellerBalanceResponse {
102
+ /** withdrawable now (cleared past the grace window) */
103
+ available: string;
104
+ /** still in the hold window */
105
+ pending: string;
106
+ /** reserved by non-rejected withdrawals */
107
+ withdrawn: string;
108
+ /** RUB */
109
+ currency: string;
110
+ /** completed, non-refunded sales count */
111
+ lifetimeSales: number;
112
+ /** tier the NEXT sale would use */
113
+ currentCommissionPercent: string;
114
+ }
115
+
116
+ export interface Withdrawal {
117
+ id: string;
118
+ sellerId: string;
119
+ /** Decimal as string */
120
+ amount: string;
121
+ /** PENDING | PROCESSING | COMPLETED | REJECTED */
122
+ status: string;
123
+ method: string;
124
+ details: string;
125
+ comment: string;
126
+ processedBy: string;
127
+ processedAt: string;
128
+ createdAt: string;
129
+ }
130
+
131
+ export interface RequestWithdrawalRequest {
132
+ sellerId: string;
133
+ /** Decimal as string */
134
+ amount: string;
135
+ method: string;
136
+ details: string;
137
+ }
138
+
139
+ export interface ListWithdrawalsRequest {
140
+ /** empty = all (admin only) */
141
+ sellerId: string;
142
+ status: string;
143
+ page: number;
144
+ limit: number;
145
+ }
146
+
147
+ export interface WithdrawalsListResponse {
148
+ items: Withdrawal[];
149
+ total: number;
150
+ page: number;
151
+ limit: number;
152
+ }
153
+
154
+ export interface ProcessWithdrawalRequest {
155
+ withdrawalId: string;
156
+ adminId: string;
157
+ /** approve (→PROCESSING) | complete (→COMPLETED) | reject (→REJECTED) */
158
+ action: string;
159
+ comment: string;
160
+ }
161
+
162
+ export const PAYMENTS_V1_PACKAGE_NAME = "payments.v1";
163
+
164
+ /**
165
+ * Commerce: YooKassa acceptance + our hold/withdrawal model (D9).
166
+ * Money values are Decimal-as-string (D7). Statuses are strings matching the DB
167
+ * enum values (PENDING/COMPLETED/FAILED/REFUNDED for purchases;
168
+ * PENDING/PROCESSING/COMPLETED/REJECTED for withdrawals) — kept as `string`
169
+ * rather than proto enums to avoid value-name clashes inside one proto package.
170
+ */
171
+
172
+ export interface PaymentsServiceClient {
173
+ createCheckout(request: CreateCheckoutRequest): Observable<CheckoutResponse>;
174
+
175
+ /** Gateway forwards a verified YooKassa webhook event here. */
176
+
177
+ handlePaymentEvent(request: PaymentEventRequest): Observable<Ok>;
178
+
179
+ getMyPurchases(request: GetMyPurchasesRequest): Observable<PurchasesListResponse>;
180
+
181
+ getPurchase(request: GetPurchaseRequest): Observable<Purchase>;
182
+
183
+ refundPurchase(request: RefundPurchaseRequest): Observable<Purchase>;
184
+
185
+ getSellerBalance(request: GetSellerBalanceRequest): Observable<SellerBalanceResponse>;
186
+
187
+ requestWithdrawal(request: RequestWithdrawalRequest): Observable<Withdrawal>;
188
+
189
+ listWithdrawals(request: ListWithdrawalsRequest): Observable<WithdrawalsListResponse>;
190
+
191
+ processWithdrawal(request: ProcessWithdrawalRequest): Observable<Withdrawal>;
192
+ }
193
+
194
+ /**
195
+ * Commerce: YooKassa acceptance + our hold/withdrawal model (D9).
196
+ * Money values are Decimal-as-string (D7). Statuses are strings matching the DB
197
+ * enum values (PENDING/COMPLETED/FAILED/REFUNDED for purchases;
198
+ * PENDING/PROCESSING/COMPLETED/REJECTED for withdrawals) — kept as `string`
199
+ * rather than proto enums to avoid value-name clashes inside one proto package.
200
+ */
201
+
202
+ export interface PaymentsServiceController {
203
+ createCheckout(
204
+ request: CreateCheckoutRequest,
205
+ ): Promise<CheckoutResponse> | Observable<CheckoutResponse> | CheckoutResponse;
206
+
207
+ /** Gateway forwards a verified YooKassa webhook event here. */
208
+
209
+ handlePaymentEvent(request: PaymentEventRequest): Promise<Ok> | Observable<Ok> | Ok;
210
+
211
+ getMyPurchases(
212
+ request: GetMyPurchasesRequest,
213
+ ): Promise<PurchasesListResponse> | Observable<PurchasesListResponse> | PurchasesListResponse;
214
+
215
+ getPurchase(request: GetPurchaseRequest): Promise<Purchase> | Observable<Purchase> | Purchase;
216
+
217
+ refundPurchase(request: RefundPurchaseRequest): Promise<Purchase> | Observable<Purchase> | Purchase;
218
+
219
+ getSellerBalance(
220
+ request: GetSellerBalanceRequest,
221
+ ): Promise<SellerBalanceResponse> | Observable<SellerBalanceResponse> | SellerBalanceResponse;
222
+
223
+ requestWithdrawal(request: RequestWithdrawalRequest): Promise<Withdrawal> | Observable<Withdrawal> | Withdrawal;
224
+
225
+ listWithdrawals(
226
+ request: ListWithdrawalsRequest,
227
+ ): Promise<WithdrawalsListResponse> | Observable<WithdrawalsListResponse> | WithdrawalsListResponse;
228
+
229
+ processWithdrawal(request: ProcessWithdrawalRequest): Promise<Withdrawal> | Observable<Withdrawal> | Withdrawal;
230
+ }
231
+
232
+ export function PaymentsServiceControllerMethods() {
233
+ return function (constructor: Function) {
234
+ const grpcMethods: string[] = [
235
+ "createCheckout",
236
+ "handlePaymentEvent",
237
+ "getMyPurchases",
238
+ "getPurchase",
239
+ "refundPurchase",
240
+ "getSellerBalance",
241
+ "requestWithdrawal",
242
+ "listWithdrawals",
243
+ "processWithdrawal",
244
+ ];
245
+ for (const method of grpcMethods) {
246
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
247
+ GrpcMethod("PaymentsService", method)(constructor.prototype[method], method, descriptor);
248
+ }
249
+ const grpcStreamMethods: string[] = [];
250
+ for (const method of grpcStreamMethods) {
251
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
252
+ GrpcStreamMethod("PaymentsService", method)(constructor.prototype[method], method, descriptor);
253
+ }
254
+ };
255
+ }
256
+
257
+ export const PAYMENTS_SERVICE_NAME = "PaymentsService";
package/gen/users.ts CHANGED
@@ -148,6 +148,8 @@ export interface UpdateUserRoleRequest {
148
148
  adminId: string;
149
149
  userId: string;
150
150
  role: string;
151
+ /** "grant" (default) | "revoke" */
152
+ action: string;
151
153
  }
152
154
 
153
155
  export interface GetUsersRequest {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aepstore-dev/contracts",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Protobuf definitions for aepstore microservices",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -0,0 +1,142 @@
1
+ syntax = "proto3";
2
+
3
+ package payments.v1;
4
+
5
+ // Commerce: YooKassa acceptance + our hold/withdrawal model (D9).
6
+ // Money values are Decimal-as-string (D7). Statuses are strings matching the DB
7
+ // enum values (PENDING/COMPLETED/FAILED/REFUNDED for purchases;
8
+ // PENDING/PROCESSING/COMPLETED/REJECTED for withdrawals) — kept as `string`
9
+ // rather than proto enums to avoid value-name clashes inside one proto package.
10
+ service PaymentsService {
11
+ rpc CreateCheckout(CreateCheckoutRequest) returns (CheckoutResponse);
12
+ // Gateway forwards a verified YooKassa webhook event here.
13
+ rpc HandlePaymentEvent(PaymentEventRequest) returns (Ok);
14
+
15
+ rpc GetMyPurchases(GetMyPurchasesRequest) returns (PurchasesListResponse);
16
+ rpc GetPurchase(GetPurchaseRequest) returns (Purchase);
17
+ rpc RefundPurchase(RefundPurchaseRequest) returns (Purchase);
18
+
19
+ rpc GetSellerBalance(GetSellerBalanceRequest) returns (SellerBalanceResponse);
20
+ rpc RequestWithdrawal(RequestWithdrawalRequest) returns (Withdrawal);
21
+ rpc ListWithdrawals(ListWithdrawalsRequest) returns (WithdrawalsListResponse);
22
+ rpc ProcessWithdrawal(ProcessWithdrawalRequest) returns (Withdrawal);
23
+ }
24
+
25
+ message Ok { bool ok = 1; }
26
+
27
+ // ---------------------------------------------------------------------------
28
+ // Purchase / checkout
29
+ // ---------------------------------------------------------------------------
30
+ message Purchase {
31
+ string id = 1;
32
+ string product_id = 2;
33
+ string product_name = 3;
34
+ string user_id = 4; // buyer
35
+ string price = 5; // Decimal as string
36
+ string status = 6; // PENDING | COMPLETED | FAILED | REFUNDED
37
+ string payment_id = 7; // YooKassa payment id
38
+ string commission_percent = 8; // snapshot, Decimal as string
39
+ string seller_amount = 9; // snapshot, Decimal as string
40
+ string created_at = 10;
41
+ string completed_at = 11;
42
+ }
43
+
44
+ message CreateCheckoutRequest {
45
+ string user_id = 1; // buyer
46
+ string product_id = 2;
47
+ string return_url = 3; // optional override; where YooKassa returns the buyer
48
+ }
49
+
50
+ message CheckoutResponse {
51
+ string purchase_id = 1;
52
+ string payment_id = 2;
53
+ string confirmation_url = 3; // redirect the buyer here
54
+ string status = 4;
55
+ }
56
+
57
+ message PaymentEventRequest {
58
+ string event = 1; // payment.succeeded | payment.canceled | refund.succeeded
59
+ string payment_id = 2; // YooKassa payment object id (re-fetched & verified by the service)
60
+ }
61
+
62
+ message GetMyPurchasesRequest {
63
+ string user_id = 1;
64
+ int32 page = 2;
65
+ int32 limit = 3;
66
+ }
67
+
68
+ message PurchasesListResponse {
69
+ repeated Purchase items = 1;
70
+ int32 total = 2;
71
+ int32 page = 3;
72
+ int32 limit = 4;
73
+ }
74
+
75
+ message GetPurchaseRequest {
76
+ string id = 1;
77
+ string user_id = 2; // requester (must be buyer or admin)
78
+ }
79
+
80
+ message RefundPurchaseRequest {
81
+ string purchase_id = 1;
82
+ string actor_user_id = 2; // buyer (own) or admin
83
+ bool is_admin = 3;
84
+ string reason = 4;
85
+ }
86
+
87
+ // ---------------------------------------------------------------------------
88
+ // Seller balance & withdrawals
89
+ // ---------------------------------------------------------------------------
90
+ message GetSellerBalanceRequest {
91
+ string seller_id = 1;
92
+ }
93
+
94
+ message SellerBalanceResponse {
95
+ string available = 1; // withdrawable now (cleared past the grace window)
96
+ string pending = 2; // still in the hold window
97
+ string withdrawn = 3; // reserved by non-rejected withdrawals
98
+ string currency = 4; // RUB
99
+ int32 lifetime_sales = 5; // completed, non-refunded sales count
100
+ string current_commission_percent = 6; // tier the NEXT sale would use
101
+ }
102
+
103
+ message Withdrawal {
104
+ string id = 1;
105
+ string seller_id = 2;
106
+ string amount = 3; // Decimal as string
107
+ string status = 4; // PENDING | PROCESSING | COMPLETED | REJECTED
108
+ string method = 5;
109
+ string details = 6;
110
+ string comment = 7;
111
+ string processed_by = 8;
112
+ string processed_at = 9;
113
+ string created_at = 10;
114
+ }
115
+
116
+ message RequestWithdrawalRequest {
117
+ string seller_id = 1;
118
+ string amount = 2; // Decimal as string
119
+ string method = 3;
120
+ string details = 4;
121
+ }
122
+
123
+ message ListWithdrawalsRequest {
124
+ string seller_id = 1; // empty = all (admin only)
125
+ string status = 2;
126
+ int32 page = 3;
127
+ int32 limit = 4;
128
+ }
129
+
130
+ message WithdrawalsListResponse {
131
+ repeated Withdrawal items = 1;
132
+ int32 total = 2;
133
+ int32 page = 3;
134
+ int32 limit = 4;
135
+ }
136
+
137
+ message ProcessWithdrawalRequest {
138
+ string withdrawal_id = 1;
139
+ string admin_id = 2;
140
+ string action = 3; // approve (→PROCESSING) | complete (→COMPLETED) | reject (→REJECTED)
141
+ string comment = 4;
142
+ }
package/proto/users.proto CHANGED
@@ -157,6 +157,7 @@ message UpdateUserRoleRequest {
157
157
  string admin_id = 1;
158
158
  string user_id = 2;
159
159
  string role = 3;
160
+ string action = 4; // "grant" (default) | "revoke"
160
161
  }
161
162
 
162
163
  // =================================================================