@mamindom/contracts 1.0.49 → 1.0.51

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,66 @@
1
+ syntax = "proto3";
2
+
3
+ package promo.v1;
4
+
5
+ import "common_promo.proto";
6
+
7
+
8
+ service PromoCalculationService {
9
+
10
+ rpc ValidateAndCalculate (ValidateAndCalculateRequest) returns (ValidateAndCalculateResponse);
11
+
12
+
13
+ rpc ApplyPromotion (ApplyPromotionRequest) returns (SuccessResponse);
14
+ }
15
+
16
+
17
+ message CartItem {
18
+ string product_id = 1;
19
+ string category_id = 2;
20
+ string brand_id = 3;
21
+ int32 quantity = 4;
22
+ double price = 5;
23
+ }
24
+
25
+
26
+ message ValidateAndCalculateRequest {
27
+ string user_id = 1;
28
+ repeated CartItem items = 2;
29
+ double order_total = 3;
30
+ optional string coupon_code = 4;
31
+ bool is_first_order = 5;
32
+ int32 order_count = 6;
33
+ }
34
+
35
+ message ValidateAndCalculateResponse {
36
+ bool is_valid = 1;
37
+ double discount_amount = 2;
38
+ double final_total = 3;
39
+
40
+ repeated AppliedPromotion applied_promotions = 4;
41
+ optional AppliedCoupon applied_coupon = 5;
42
+
43
+ optional string error_message = 6;
44
+ }
45
+
46
+ message AppliedPromotion {
47
+ string promotion_id = 1;
48
+ string promotion_name = 2;
49
+ double discount_amount = 3;
50
+ }
51
+
52
+ message AppliedCoupon {
53
+ string coupon_id = 1;
54
+ string code = 2;
55
+ string promotion_id = 3;
56
+ double discount_amount = 4;
57
+ }
58
+
59
+
60
+ message ApplyPromotionRequest {
61
+ string user_id = 1;
62
+ string order_id = 2;
63
+ double discount_amount = 3;
64
+ optional string coupon_code = 4;
65
+ repeated string promotion_ids = 5;
66
+ }
@@ -0,0 +1,23 @@
1
+ syntax = "proto3";
2
+
3
+ package promo.v1;
4
+
5
+ message SuccessResponse {
6
+ bool success = 1;
7
+ }
8
+
9
+ message DeleteResponse {
10
+ bool success = 1;
11
+ }
12
+
13
+ message PaginationRequest {
14
+ int32 page = 1;
15
+ int32 limit = 2;
16
+ }
17
+
18
+ message PaginationMeta {
19
+ int32 total_items = 1;
20
+ int32 total_pages = 2;
21
+ int32 current_page = 3;
22
+ int32 per_page = 4;
23
+ }
@@ -0,0 +1,121 @@
1
+ syntax = "proto3";
2
+
3
+ package promo.v1;
4
+
5
+ import "common_promo.proto";
6
+
7
+
8
+ service CouponService {
9
+ rpc GetCoupons (GetCouponsRequest) returns (GetCouponsResponse);
10
+ rpc GetCoupon (GetCouponRequest) returns (CouponResponse);
11
+ rpc CreateCoupon (CreateCouponRequest) returns (CouponResponse);
12
+ rpc UpdateCoupon (UpdateCouponRequest) returns (CouponResponse);
13
+ rpc DeactivateCoupon (DeactivateCouponRequest) returns (SuccessResponse);
14
+
15
+
16
+ rpc GenerateCoupons (GenerateCouponsRequest) returns (GenerateCouponsResponse);
17
+
18
+
19
+ rpc ExportCoupons (ExportCouponsRequest) returns (ExportCouponsResponse);
20
+ rpc ImportCoupons (ImportCouponsRequest) returns (ImportCouponsResponse);
21
+ }
22
+
23
+
24
+ message CouponResponse {
25
+ string id = 1;
26
+ string promotion_id = 2;
27
+ string code = 3;
28
+
29
+ optional int32 usage_limit_total = 4;
30
+ optional int32 usage_limit_per_user = 5;
31
+ int32 usage_count = 6;
32
+
33
+ bool is_active = 7;
34
+ optional string expires_at = 8;
35
+
36
+ string created_at = 9;
37
+ }
38
+
39
+
40
+ message GetCouponsRequest {
41
+ PaginationRequest pagination = 1;
42
+ optional string promotion_id = 2;
43
+ optional bool is_active = 3;
44
+ optional string search = 4;
45
+ }
46
+
47
+ message GetCouponsResponse {
48
+ repeated CouponResponse items = 1;
49
+ PaginationMeta meta = 2;
50
+ }
51
+
52
+
53
+ message GetCouponRequest {
54
+ string id = 1;
55
+ optional string code = 2;
56
+ }
57
+
58
+
59
+ message CreateCouponRequest {
60
+ string promotion_id = 1;
61
+ string code = 2;
62
+
63
+ optional int32 usage_limit_total = 3;
64
+ optional int32 usage_limit_per_user = 4;
65
+ optional string expires_at = 5;
66
+ bool is_active = 6;
67
+ }
68
+
69
+
70
+ message UpdateCouponRequest {
71
+ string id = 1;
72
+
73
+ optional int32 usage_limit_total = 2;
74
+ optional int32 usage_limit_per_user = 3;
75
+ optional string expires_at = 4;
76
+ optional bool is_active = 5;
77
+ }
78
+
79
+
80
+ message DeactivateCouponRequest {
81
+ string id = 1;
82
+ }
83
+
84
+
85
+ message GenerateCouponsRequest {
86
+ string promotion_id = 1;
87
+ int32 count = 2;
88
+
89
+
90
+ optional string prefix = 3;
91
+ optional int32 random_length = 4;
92
+
93
+ optional int32 usage_limit_per_user = 5;
94
+ optional string expires_at = 6;
95
+ }
96
+
97
+ message GenerateCouponsResponse {
98
+ int32 generated = 1;
99
+ }
100
+
101
+
102
+ message ExportCouponsRequest {
103
+ string promotion_id = 1;
104
+ optional bool active_only = 2;
105
+ }
106
+
107
+ message ExportCouponsResponse {
108
+ string csv_content = 1;
109
+ }
110
+
111
+
112
+ message ImportCouponsRequest {
113
+ string promotion_id = 1;
114
+ string csv_content = 2;
115
+ }
116
+
117
+ message ImportCouponsResponse {
118
+ int32 imported = 1;
119
+ int32 skipped = 2;
120
+ repeated string errors = 3;
121
+ }
@@ -0,0 +1,257 @@
1
+ syntax = "proto3";
2
+
3
+ package promo.v1;
4
+
5
+ import "common_promo.proto";
6
+
7
+
8
+ service PromotionService {
9
+
10
+ rpc GetPromotions (GetPromotionsRequest) returns (GetPromotionsResponse);
11
+ rpc GetPromotion (GetPromotionRequest) returns (PromotionResponse);
12
+ rpc CreatePromotion (CreatePromotionRequest) returns (PromotionResponse);
13
+ rpc UpdatePromotion (UpdatePromotionRequest) returns (PromotionResponse);
14
+ rpc DeletePromotion (DeletePromotionRequest) returns (DeleteResponse);
15
+
16
+
17
+ rpc BulkApplyToCategories (BulkApplyToCategoriesRequest) returns (SuccessResponse);
18
+
19
+
20
+ rpc GetActivePromotions (GetActivePromotionsRequest) returns (GetActivePromotionsResponse);
21
+ }
22
+
23
+
24
+ enum PromotionType {
25
+ PROMOTION_TYPE_UNSPECIFIED = 0;
26
+ PROMOTION_TYPE_FIXED = 1;
27
+ PROMOTION_TYPE_PERCENTAGE = 2;
28
+ PROMOTION_TYPE_COUPON = 3;
29
+ PROMOTION_TYPE_BUY_N_GET_M = 4;
30
+ PROMOTION_TYPE_FIRST_ORDER = 5;
31
+ PROMOTION_TYPE_LOYALTY = 6;
32
+ PROMOTION_TYPE_PROMO_PERIOD = 7;
33
+ }
34
+
35
+ enum DiscountType {
36
+ DISCOUNT_TYPE_UNSPECIFIED = 0;
37
+ DISCOUNT_TYPE_FIXED = 1;
38
+ DISCOUNT_TYPE_PERCENTAGE = 2;
39
+ }
40
+
41
+ enum PromotionStatus {
42
+ PROMOTION_STATUS_UNSPECIFIED = 0;
43
+ PROMOTION_STATUS_DRAFT = 1;
44
+ PROMOTION_STATUS_ACTIVE = 2;
45
+ PROMOTION_STATUS_INACTIVE = 3;
46
+ PROMOTION_STATUS_EXPIRED = 4;
47
+ }
48
+
49
+ enum ConditionLogic {
50
+ CONDITION_LOGIC_UNSPECIFIED = 0;
51
+ CONDITION_LOGIC_AND = 1;
52
+ CONDITION_LOGIC_OR = 2;
53
+ }
54
+
55
+ enum ConditionType {
56
+ CONDITION_TYPE_UNSPECIFIED = 0;
57
+ CONDITION_TYPE_PRODUCT = 1;
58
+ CONDITION_TYPE_CATEGORY = 2;
59
+ CONDITION_TYPE_BRAND = 3;
60
+ CONDITION_TYPE_USER_GROUP = 4;
61
+ CONDITION_TYPE_FIRST_ORDER = 5;
62
+ CONDITION_TYPE_MIN_ORDER_COUNT = 6;
63
+ CONDITION_TYPE_MIN_AMOUNT = 7;
64
+ }
65
+
66
+ enum ExclusionEntityType {
67
+ EXCLUSION_ENTITY_UNSPECIFIED = 0;
68
+ EXCLUSION_ENTITY_PRODUCT = 1;
69
+ EXCLUSION_ENTITY_CATEGORY = 2;
70
+ EXCLUSION_ENTITY_BRAND = 3;
71
+ }
72
+
73
+
74
+ message PromotionConditionPayload {
75
+ ConditionLogic logic_type = 1;
76
+ ConditionType condition_type = 2;
77
+ string value = 3;
78
+ }
79
+
80
+ message PromotionExclusionPayload {
81
+ ExclusionEntityType entity_type = 1;
82
+ string entity_id = 2;
83
+ }
84
+
85
+ message PromotionConditionResponse {
86
+ string id = 1;
87
+ ConditionLogic logic_type = 2;
88
+ ConditionType condition_type = 3;
89
+ string value = 4;
90
+ }
91
+
92
+ message PromotionExclusionResponse {
93
+ string id = 1;
94
+ ExclusionEntityType entity_type = 2;
95
+ string entity_id = 3;
96
+ }
97
+
98
+
99
+ message PromotionResponse {
100
+ string id = 1;
101
+ map<string, string> name = 2;
102
+ map<string, string> description = 3;
103
+
104
+ PromotionType type = 4;
105
+ DiscountType discount_type = 5;
106
+ PromotionStatus status = 6;
107
+
108
+ double discount_value = 7;
109
+
110
+ optional string starts_at = 8;
111
+ optional string ends_at = 9;
112
+
113
+ optional double min_order_amount = 10;
114
+ optional int32 usage_limit_total = 11;
115
+ optional int32 usage_limit_per_user = 12;
116
+ int32 usage_count = 13;
117
+
118
+ bool is_active = 14;
119
+ bool is_exclusive = 15;
120
+
121
+
122
+ optional int32 buy_quantity = 16;
123
+ optional int32 get_quantity = 17;
124
+
125
+
126
+ optional string seo_slug = 18;
127
+ map<string, string> seo_title = 19;
128
+ map<string, string> seo_description = 20;
129
+
130
+ string created_by_id = 21;
131
+ string created_at = 22;
132
+ string updated_at = 23;
133
+
134
+ repeated PromotionConditionResponse conditions = 24;
135
+ repeated PromotionExclusionResponse exclusions = 25;
136
+ }
137
+
138
+
139
+ message GetPromotionsRequest {
140
+ PaginationRequest pagination = 1;
141
+
142
+ optional PromotionType type = 2;
143
+ optional PromotionStatus status = 3;
144
+ optional string search = 4;
145
+ optional string category_id = 5;
146
+ optional string date_from = 6;
147
+ optional string date_to = 7;
148
+ }
149
+
150
+ message GetPromotionsResponse {
151
+ repeated PromotionListItem items = 1;
152
+ PaginationMeta meta = 2;
153
+ }
154
+
155
+ message PromotionListItem {
156
+ string id = 1;
157
+ map<string, string> name = 2;
158
+ PromotionType type = 3;
159
+ PromotionStatus status = 4;
160
+ optional string starts_at = 5;
161
+ optional string ends_at = 6;
162
+ int32 usage_count = 7;
163
+ bool is_active = 8;
164
+ string created_at = 9;
165
+ }
166
+
167
+
168
+ message GetPromotionRequest {
169
+ string id = 1;
170
+ }
171
+
172
+
173
+ message CreatePromotionRequest {
174
+ map<string, string> name = 1;
175
+ map<string, string> description = 2;
176
+
177
+ PromotionType type = 3;
178
+ DiscountType discount_type = 4;
179
+ double discount_value = 5;
180
+
181
+ optional string starts_at = 6;
182
+ optional string ends_at = 7;
183
+
184
+ optional double min_order_amount = 8;
185
+ optional int32 usage_limit_total = 9;
186
+ optional int32 usage_limit_per_user = 10;
187
+
188
+ bool is_active = 11;
189
+ bool is_exclusive = 12;
190
+
191
+ optional int32 buy_quantity = 13;
192
+ optional int32 get_quantity = 14;
193
+
194
+ optional string seo_slug = 15;
195
+ map<string, string> seo_title = 16;
196
+ map<string, string> seo_description = 17;
197
+
198
+ string created_by_id = 18;
199
+
200
+ repeated PromotionConditionPayload conditions = 19;
201
+ repeated PromotionExclusionPayload exclusions = 20;
202
+ }
203
+
204
+
205
+ message UpdatePromotionRequest {
206
+ string id = 1;
207
+
208
+ map<string, string> name = 2;
209
+ map<string, string> description = 3;
210
+
211
+ optional PromotionType type = 4;
212
+ optional DiscountType discount_type = 5;
213
+ optional double discount_value = 6;
214
+
215
+ optional string starts_at = 7;
216
+ optional string ends_at = 8;
217
+
218
+ optional double min_order_amount = 9;
219
+ optional int32 usage_limit_total = 10;
220
+ optional int32 usage_limit_per_user = 11;
221
+
222
+ optional bool is_active = 12;
223
+ optional bool is_exclusive = 13;
224
+
225
+ optional int32 buy_quantity = 14;
226
+ optional int32 get_quantity = 15;
227
+
228
+ optional string seo_slug = 16;
229
+ map<string, string> seo_title = 17;
230
+ map<string, string> seo_description = 18;
231
+
232
+
233
+ repeated PromotionConditionPayload conditions = 19;
234
+ repeated PromotionExclusionPayload exclusions = 20;
235
+ }
236
+
237
+
238
+ message DeletePromotionRequest {
239
+ string id = 1;
240
+ }
241
+
242
+
243
+ message BulkApplyToCategoriesRequest {
244
+ string promotion_id = 1;
245
+ repeated string category_ids = 2;
246
+ }
247
+
248
+
249
+ message GetActivePromotionsRequest {
250
+ PaginationRequest pagination = 1;
251
+ optional string lang = 2;
252
+ }
253
+
254
+ message GetActivePromotionsResponse {
255
+ repeated PromotionListItem items = 1;
256
+ PaginationMeta meta = 2;
257
+ }
@@ -10,4 +10,8 @@ export declare const PROTO_PATHS: {
10
10
  readonly MEDIA: string;
11
11
  readonly SIZE_CHART: string;
12
12
  readonly STICKER: string;
13
+ readonly COMMON_PROMO: string;
14
+ readonly CALCULATION: string;
15
+ readonly COUPON: string;
16
+ readonly PROMOTION: string;
13
17
  };
@@ -13,5 +13,9 @@ exports.PROTO_PATHS = {
13
13
  PRODUCT: (0, node_path_1.join)(__dirname, '../../proto/product.proto'),
14
14
  MEDIA: (0, node_path_1.join)(__dirname, '../../proto/media.proto'),
15
15
  SIZE_CHART: (0, node_path_1.join)(__dirname, '../../proto/size_chart.proto'),
16
- STICKER: (0, node_path_1.join)(__dirname, '../../proto/sticker.proto')
16
+ STICKER: (0, node_path_1.join)(__dirname, '../../proto/sticker.proto'),
17
+ COMMON_PROMO: (0, node_path_1.join)(__dirname, '../../proto/common_promo.proto'),
18
+ CALCULATION: (0, node_path_1.join)(__dirname, '../../proto/calculation.proto'),
19
+ COUPON: (0, node_path_1.join)(__dirname, '../../proto/coupon.proto'),
20
+ PROMOTION: (0, node_path_1.join)(__dirname, '../../proto/promotion.proto')
17
21
  };
@@ -0,0 +1,94 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.4
4
+ // protoc v3.21.12
5
+ // source: calculation.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+ import { SuccessResponse } from "./common_promo";
11
+
12
+ export const protobufPackage = "promo.v1";
13
+
14
+ export interface CartItem {
15
+ productId: string;
16
+ categoryId: string;
17
+ brandId: string;
18
+ quantity: number;
19
+ price: number;
20
+ }
21
+
22
+ export interface ValidateAndCalculateRequest {
23
+ userId: string;
24
+ items: CartItem[];
25
+ orderTotal: number;
26
+ couponCode?: string | undefined;
27
+ isFirstOrder: boolean;
28
+ orderCount: number;
29
+ }
30
+
31
+ export interface ValidateAndCalculateResponse {
32
+ isValid: boolean;
33
+ discountAmount: number;
34
+ finalTotal: number;
35
+ appliedPromotions: AppliedPromotion[];
36
+ appliedCoupon?: AppliedCoupon | undefined;
37
+ errorMessage?: string | undefined;
38
+ }
39
+
40
+ export interface AppliedPromotion {
41
+ promotionId: string;
42
+ promotionName: string;
43
+ discountAmount: number;
44
+ }
45
+
46
+ export interface AppliedCoupon {
47
+ couponId: string;
48
+ code: string;
49
+ promotionId: string;
50
+ discountAmount: number;
51
+ }
52
+
53
+ export interface ApplyPromotionRequest {
54
+ userId: string;
55
+ orderId: string;
56
+ discountAmount: number;
57
+ couponCode?: string | undefined;
58
+ promotionIds: string[];
59
+ }
60
+
61
+ export const PROMO_V1_PACKAGE_NAME = "promo.v1";
62
+
63
+ export interface PromoCalculationServiceClient {
64
+ validateAndCalculate(request: ValidateAndCalculateRequest): Observable<ValidateAndCalculateResponse>;
65
+
66
+ applyPromotion(request: ApplyPromotionRequest): Observable<SuccessResponse>;
67
+ }
68
+
69
+ export interface PromoCalculationServiceController {
70
+ validateAndCalculate(
71
+ request: ValidateAndCalculateRequest,
72
+ ): Promise<ValidateAndCalculateResponse> | Observable<ValidateAndCalculateResponse> | ValidateAndCalculateResponse;
73
+
74
+ applyPromotion(
75
+ request: ApplyPromotionRequest,
76
+ ): Promise<SuccessResponse> | Observable<SuccessResponse> | SuccessResponse;
77
+ }
78
+
79
+ export function PromoCalculationServiceControllerMethods() {
80
+ return function (constructor: Function) {
81
+ const grpcMethods: string[] = ["validateAndCalculate", "applyPromotion"];
82
+ for (const method of grpcMethods) {
83
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
84
+ GrpcMethod("PromoCalculationService", method)(constructor.prototype[method], method, descriptor);
85
+ }
86
+ const grpcStreamMethods: string[] = [];
87
+ for (const method of grpcStreamMethods) {
88
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
89
+ GrpcStreamMethod("PromoCalculationService", method)(constructor.prototype[method], method, descriptor);
90
+ }
91
+ };
92
+ }
93
+
94
+ export const PROMO_CALCULATION_SERVICE_NAME = "PromoCalculationService";
@@ -0,0 +1,31 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.4
4
+ // protoc v3.21.12
5
+ // source: common_promo.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ export const protobufPackage = "promo.v1";
10
+
11
+ export interface SuccessResponse {
12
+ success: boolean;
13
+ }
14
+
15
+ export interface DeleteResponse {
16
+ success: boolean;
17
+ }
18
+
19
+ export interface PaginationRequest {
20
+ page: number;
21
+ limit: number;
22
+ }
23
+
24
+ export interface PaginationMeta {
25
+ totalItems: number;
26
+ totalPages: number;
27
+ currentPage: number;
28
+ perPage: number;
29
+ }
30
+
31
+ export const PROMO_V1_PACKAGE_NAME = "promo.v1";