@mamindom/contracts 1.0.50 → 1.0.52

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.
Files changed (55) hide show
  1. package/dist/gen/calculation.d.ts +55 -0
  2. package/dist/gen/calculation.js +28 -0
  3. package/dist/gen/common_post.d.ts +18 -0
  4. package/dist/gen/common_post.js +11 -0
  5. package/dist/gen/coupon.d.ts +96 -0
  6. package/dist/gen/coupon.js +37 -0
  7. package/dist/gen/post.d.ts +304 -0
  8. package/dist/gen/post.js +55 -0
  9. package/dist/gen/post_category.d.ts +104 -0
  10. package/dist/gen/post_category.js +43 -0
  11. package/dist/gen/post_comment.d.ts +54 -0
  12. package/dist/gen/post_comment.js +36 -0
  13. package/dist/gen/post_tag.d.ts +68 -0
  14. package/dist/gen/post_tag.js +28 -0
  15. package/dist/gen/post_version.d.ts +73 -0
  16. package/dist/gen/post_version.js +28 -0
  17. package/dist/gen/promotion.d.ts +284 -0
  18. package/dist/gen/promotion.js +91 -0
  19. package/dist/proto/calculation.proto +66 -0
  20. package/dist/proto/common_post.proto +23 -0
  21. package/dist/proto/common_promo.proto +6 -7
  22. package/dist/proto/coupon.proto +121 -0
  23. package/dist/proto/post.proto +193 -0
  24. package/dist/proto/post_category.proto +84 -0
  25. package/dist/proto/post_comment.proto +66 -0
  26. package/dist/proto/post_tag.proto +57 -0
  27. package/dist/proto/post_version.proto +61 -0
  28. package/dist/proto/promotion.proto +257 -0
  29. package/dist/src/proto/paths.d.ts +8 -1
  30. package/dist/src/proto/paths.js +8 -1
  31. package/gen/calculation.ts +94 -0
  32. package/gen/common_post.ts +31 -0
  33. package/gen/coupon.ts +169 -0
  34. package/gen/post.ts +346 -0
  35. package/gen/post_category.ts +157 -0
  36. package/gen/post_comment.ts +99 -0
  37. package/gen/post_tag.ts +113 -0
  38. package/gen/post_version.ts +112 -0
  39. package/gen/promotion.ts +353 -0
  40. package/package.json +1 -1
  41. package/proto/calculation.proto +66 -0
  42. package/proto/common_post.proto +23 -0
  43. package/proto/common_promo.proto +6 -7
  44. package/proto/coupon.proto +121 -0
  45. package/proto/post.proto +193 -0
  46. package/proto/post_category.proto +84 -0
  47. package/proto/post_comment.proto +66 -0
  48. package/proto/post_tag.proto +57 -0
  49. package/proto/post_version.proto +61 -0
  50. package/proto/promotion.proto +257 -0
  51. package/dist/gen/promo.d.ts +0 -293
  52. package/dist/gen/promo.js +0 -73
  53. package/dist/proto/promo.proto +0 -238
  54. package/gen/promo.ts +0 -390
  55. package/proto/promo.proto +0 -238
@@ -0,0 +1,353 @@
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: promotion.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+ import { DeleteResponse, PaginationMeta, PaginationRequest, SuccessResponse } from "./common_promo";
11
+
12
+ export const protobufPackage = "promo.v1";
13
+
14
+ export enum PromotionType {
15
+ PROMOTION_TYPE_UNSPECIFIED = 0,
16
+ PROMOTION_TYPE_FIXED = 1,
17
+ PROMOTION_TYPE_PERCENTAGE = 2,
18
+ PROMOTION_TYPE_COUPON = 3,
19
+ PROMOTION_TYPE_BUY_N_GET_M = 4,
20
+ PROMOTION_TYPE_FIRST_ORDER = 5,
21
+ PROMOTION_TYPE_LOYALTY = 6,
22
+ PROMOTION_TYPE_PROMO_PERIOD = 7,
23
+ UNRECOGNIZED = -1,
24
+ }
25
+
26
+ export enum DiscountType {
27
+ DISCOUNT_TYPE_UNSPECIFIED = 0,
28
+ DISCOUNT_TYPE_FIXED = 1,
29
+ DISCOUNT_TYPE_PERCENTAGE = 2,
30
+ UNRECOGNIZED = -1,
31
+ }
32
+
33
+ export enum PromotionStatus {
34
+ PROMOTION_STATUS_UNSPECIFIED = 0,
35
+ PROMOTION_STATUS_DRAFT = 1,
36
+ PROMOTION_STATUS_ACTIVE = 2,
37
+ PROMOTION_STATUS_INACTIVE = 3,
38
+ PROMOTION_STATUS_EXPIRED = 4,
39
+ UNRECOGNIZED = -1,
40
+ }
41
+
42
+ export enum ConditionLogic {
43
+ CONDITION_LOGIC_UNSPECIFIED = 0,
44
+ CONDITION_LOGIC_AND = 1,
45
+ CONDITION_LOGIC_OR = 2,
46
+ UNRECOGNIZED = -1,
47
+ }
48
+
49
+ export enum ConditionType {
50
+ CONDITION_TYPE_UNSPECIFIED = 0,
51
+ CONDITION_TYPE_PRODUCT = 1,
52
+ CONDITION_TYPE_CATEGORY = 2,
53
+ CONDITION_TYPE_BRAND = 3,
54
+ CONDITION_TYPE_USER_GROUP = 4,
55
+ CONDITION_TYPE_FIRST_ORDER = 5,
56
+ CONDITION_TYPE_MIN_ORDER_COUNT = 6,
57
+ CONDITION_TYPE_MIN_AMOUNT = 7,
58
+ UNRECOGNIZED = -1,
59
+ }
60
+
61
+ export enum ExclusionEntityType {
62
+ EXCLUSION_ENTITY_UNSPECIFIED = 0,
63
+ EXCLUSION_ENTITY_PRODUCT = 1,
64
+ EXCLUSION_ENTITY_CATEGORY = 2,
65
+ EXCLUSION_ENTITY_BRAND = 3,
66
+ UNRECOGNIZED = -1,
67
+ }
68
+
69
+ export interface PromotionConditionPayload {
70
+ logicType: ConditionLogic;
71
+ conditionType: ConditionType;
72
+ value: string;
73
+ }
74
+
75
+ export interface PromotionExclusionPayload {
76
+ entityType: ExclusionEntityType;
77
+ entityId: string;
78
+ }
79
+
80
+ export interface PromotionConditionResponse {
81
+ id: string;
82
+ logicType: ConditionLogic;
83
+ conditionType: ConditionType;
84
+ value: string;
85
+ }
86
+
87
+ export interface PromotionExclusionResponse {
88
+ id: string;
89
+ entityType: ExclusionEntityType;
90
+ entityId: string;
91
+ }
92
+
93
+ export interface PromotionResponse {
94
+ id: string;
95
+ name: { [key: string]: string };
96
+ description: { [key: string]: string };
97
+ type: PromotionType;
98
+ discountType: DiscountType;
99
+ status: PromotionStatus;
100
+ discountValue: number;
101
+ startsAt?: string | undefined;
102
+ endsAt?: string | undefined;
103
+ minOrderAmount?: number | undefined;
104
+ usageLimitTotal?: number | undefined;
105
+ usageLimitPerUser?: number | undefined;
106
+ usageCount: number;
107
+ isActive: boolean;
108
+ isExclusive: boolean;
109
+ buyQuantity?: number | undefined;
110
+ getQuantity?: number | undefined;
111
+ seoSlug?: string | undefined;
112
+ seoTitle: { [key: string]: string };
113
+ seoDescription: { [key: string]: string };
114
+ createdById: string;
115
+ createdAt: string;
116
+ updatedAt: string;
117
+ conditions: PromotionConditionResponse[];
118
+ exclusions: PromotionExclusionResponse[];
119
+ }
120
+
121
+ export interface PromotionResponse_NameEntry {
122
+ key: string;
123
+ value: string;
124
+ }
125
+
126
+ export interface PromotionResponse_DescriptionEntry {
127
+ key: string;
128
+ value: string;
129
+ }
130
+
131
+ export interface PromotionResponse_SeoTitleEntry {
132
+ key: string;
133
+ value: string;
134
+ }
135
+
136
+ export interface PromotionResponse_SeoDescriptionEntry {
137
+ key: string;
138
+ value: string;
139
+ }
140
+
141
+ export interface GetPromotionsRequest {
142
+ pagination: PaginationRequest | undefined;
143
+ type?: PromotionType | undefined;
144
+ status?: PromotionStatus | undefined;
145
+ search?: string | undefined;
146
+ categoryId?: string | undefined;
147
+ dateFrom?: string | undefined;
148
+ dateTo?: string | undefined;
149
+ }
150
+
151
+ export interface GetPromotionsResponse {
152
+ items: PromotionListItem[];
153
+ meta: PaginationMeta | undefined;
154
+ }
155
+
156
+ export interface PromotionListItem {
157
+ id: string;
158
+ name: { [key: string]: string };
159
+ type: PromotionType;
160
+ status: PromotionStatus;
161
+ startsAt?: string | undefined;
162
+ endsAt?: string | undefined;
163
+ usageCount: number;
164
+ isActive: boolean;
165
+ createdAt: string;
166
+ }
167
+
168
+ export interface PromotionListItem_NameEntry {
169
+ key: string;
170
+ value: string;
171
+ }
172
+
173
+ export interface GetPromotionRequest {
174
+ id: string;
175
+ }
176
+
177
+ export interface CreatePromotionRequest {
178
+ name: { [key: string]: string };
179
+ description: { [key: string]: string };
180
+ type: PromotionType;
181
+ discountType: DiscountType;
182
+ discountValue: number;
183
+ startsAt?: string | undefined;
184
+ endsAt?: string | undefined;
185
+ minOrderAmount?: number | undefined;
186
+ usageLimitTotal?: number | undefined;
187
+ usageLimitPerUser?: number | undefined;
188
+ isActive: boolean;
189
+ isExclusive: boolean;
190
+ buyQuantity?: number | undefined;
191
+ getQuantity?: number | undefined;
192
+ seoSlug?: string | undefined;
193
+ seoTitle: { [key: string]: string };
194
+ seoDescription: { [key: string]: string };
195
+ createdById: string;
196
+ conditions: PromotionConditionPayload[];
197
+ exclusions: PromotionExclusionPayload[];
198
+ }
199
+
200
+ export interface CreatePromotionRequest_NameEntry {
201
+ key: string;
202
+ value: string;
203
+ }
204
+
205
+ export interface CreatePromotionRequest_DescriptionEntry {
206
+ key: string;
207
+ value: string;
208
+ }
209
+
210
+ export interface CreatePromotionRequest_SeoTitleEntry {
211
+ key: string;
212
+ value: string;
213
+ }
214
+
215
+ export interface CreatePromotionRequest_SeoDescriptionEntry {
216
+ key: string;
217
+ value: string;
218
+ }
219
+
220
+ export interface UpdatePromotionRequest {
221
+ id: string;
222
+ name: { [key: string]: string };
223
+ description: { [key: string]: string };
224
+ type?: PromotionType | undefined;
225
+ discountType?: DiscountType | undefined;
226
+ discountValue?: number | undefined;
227
+ startsAt?: string | undefined;
228
+ endsAt?: string | undefined;
229
+ minOrderAmount?: number | undefined;
230
+ usageLimitTotal?: number | undefined;
231
+ usageLimitPerUser?: number | undefined;
232
+ isActive?: boolean | undefined;
233
+ isExclusive?: boolean | undefined;
234
+ buyQuantity?: number | undefined;
235
+ getQuantity?: number | undefined;
236
+ seoSlug?: string | undefined;
237
+ seoTitle: { [key: string]: string };
238
+ seoDescription: { [key: string]: string };
239
+ conditions: PromotionConditionPayload[];
240
+ exclusions: PromotionExclusionPayload[];
241
+ }
242
+
243
+ export interface UpdatePromotionRequest_NameEntry {
244
+ key: string;
245
+ value: string;
246
+ }
247
+
248
+ export interface UpdatePromotionRequest_DescriptionEntry {
249
+ key: string;
250
+ value: string;
251
+ }
252
+
253
+ export interface UpdatePromotionRequest_SeoTitleEntry {
254
+ key: string;
255
+ value: string;
256
+ }
257
+
258
+ export interface UpdatePromotionRequest_SeoDescriptionEntry {
259
+ key: string;
260
+ value: string;
261
+ }
262
+
263
+ export interface DeletePromotionRequest {
264
+ id: string;
265
+ }
266
+
267
+ export interface BulkApplyToCategoriesRequest {
268
+ promotionId: string;
269
+ categoryIds: string[];
270
+ }
271
+
272
+ export interface GetActivePromotionsRequest {
273
+ pagination: PaginationRequest | undefined;
274
+ lang?: string | undefined;
275
+ }
276
+
277
+ export interface GetActivePromotionsResponse {
278
+ items: PromotionListItem[];
279
+ meta: PaginationMeta | undefined;
280
+ }
281
+
282
+ export const PROMO_V1_PACKAGE_NAME = "promo.v1";
283
+
284
+ export interface PromotionServiceClient {
285
+ getPromotions(request: GetPromotionsRequest): Observable<GetPromotionsResponse>;
286
+
287
+ getPromotion(request: GetPromotionRequest): Observable<PromotionResponse>;
288
+
289
+ createPromotion(request: CreatePromotionRequest): Observable<PromotionResponse>;
290
+
291
+ updatePromotion(request: UpdatePromotionRequest): Observable<PromotionResponse>;
292
+
293
+ deletePromotion(request: DeletePromotionRequest): Observable<DeleteResponse>;
294
+
295
+ bulkApplyToCategories(request: BulkApplyToCategoriesRequest): Observable<SuccessResponse>;
296
+
297
+ getActivePromotions(request: GetActivePromotionsRequest): Observable<GetActivePromotionsResponse>;
298
+ }
299
+
300
+ export interface PromotionServiceController {
301
+ getPromotions(
302
+ request: GetPromotionsRequest,
303
+ ): Promise<GetPromotionsResponse> | Observable<GetPromotionsResponse> | GetPromotionsResponse;
304
+
305
+ getPromotion(
306
+ request: GetPromotionRequest,
307
+ ): Promise<PromotionResponse> | Observable<PromotionResponse> | PromotionResponse;
308
+
309
+ createPromotion(
310
+ request: CreatePromotionRequest,
311
+ ): Promise<PromotionResponse> | Observable<PromotionResponse> | PromotionResponse;
312
+
313
+ updatePromotion(
314
+ request: UpdatePromotionRequest,
315
+ ): Promise<PromotionResponse> | Observable<PromotionResponse> | PromotionResponse;
316
+
317
+ deletePromotion(
318
+ request: DeletePromotionRequest,
319
+ ): Promise<DeleteResponse> | Observable<DeleteResponse> | DeleteResponse;
320
+
321
+ bulkApplyToCategories(
322
+ request: BulkApplyToCategoriesRequest,
323
+ ): Promise<SuccessResponse> | Observable<SuccessResponse> | SuccessResponse;
324
+
325
+ getActivePromotions(
326
+ request: GetActivePromotionsRequest,
327
+ ): Promise<GetActivePromotionsResponse> | Observable<GetActivePromotionsResponse> | GetActivePromotionsResponse;
328
+ }
329
+
330
+ export function PromotionServiceControllerMethods() {
331
+ return function (constructor: Function) {
332
+ const grpcMethods: string[] = [
333
+ "getPromotions",
334
+ "getPromotion",
335
+ "createPromotion",
336
+ "updatePromotion",
337
+ "deletePromotion",
338
+ "bulkApplyToCategories",
339
+ "getActivePromotions",
340
+ ];
341
+ for (const method of grpcMethods) {
342
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
343
+ GrpcMethod("PromotionService", method)(constructor.prototype[method], method, descriptor);
344
+ }
345
+ const grpcStreamMethods: string[] = [];
346
+ for (const method of grpcStreamMethods) {
347
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
348
+ GrpcStreamMethod("PromotionService", method)(constructor.prototype[method], method, descriptor);
349
+ }
350
+ };
351
+ }
352
+
353
+ export const PROMOTION_SERVICE_NAME = "PromotionService";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mamindom/contracts",
3
3
  "description": "proto",
4
- "version": "1.0.50",
4
+ "version": "1.0.52",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
7
7
  "exports": {
@@ -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 content.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
+ }
@@ -10,15 +10,14 @@ message DeleteResponse {
10
10
  bool success = 1;
11
11
  }
12
12
 
13
-
14
13
  message PaginationRequest {
15
- int32 page = 1;
16
- int32 limit = 2;
14
+ int32 page = 1;
15
+ int32 limit = 2;
17
16
  }
18
17
 
19
18
  message PaginationMeta {
20
- int32 total_items = 1;
21
- int32 total_pages = 2;
19
+ int32 total_items = 1;
20
+ int32 total_pages = 2;
22
21
  int32 current_page = 3;
23
- int32 per_page = 4;
24
- }
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
+ }