@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.
- package/dist/gen/calculation.d.ts +55 -0
- package/dist/gen/calculation.js +28 -0
- package/dist/gen/common_promo.d.ts +18 -0
- package/dist/gen/common_promo.js +11 -0
- package/dist/gen/coupon.d.ts +96 -0
- package/dist/gen/coupon.js +37 -0
- package/dist/gen/promotion.d.ts +284 -0
- package/dist/gen/promotion.js +91 -0
- package/dist/proto/calculation.proto +66 -0
- package/dist/proto/common_promo.proto +23 -0
- package/dist/proto/coupon.proto +121 -0
- package/dist/proto/promotion.proto +257 -0
- package/dist/src/proto/paths.d.ts +4 -0
- package/dist/src/proto/paths.js +5 -1
- package/gen/calculation.ts +94 -0
- package/gen/common_promo.ts +31 -0
- package/gen/coupon.ts +169 -0
- package/gen/promotion.ts +353 -0
- package/package.json +1 -1
- package/proto/calculation.proto +66 -0
- package/proto/common_promo.proto +23 -0
- package/proto/coupon.proto +121 -0
- package/proto/promotion.proto +257 -0
package/gen/coupon.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
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: coupon.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
|
+
import { Observable } from "rxjs";
|
|
10
|
+
import { PaginationMeta, PaginationRequest, SuccessResponse } from "./common_promo";
|
|
11
|
+
|
|
12
|
+
export const protobufPackage = "promo.v1";
|
|
13
|
+
|
|
14
|
+
export interface CouponResponse {
|
|
15
|
+
id: string;
|
|
16
|
+
promotionId: string;
|
|
17
|
+
code: string;
|
|
18
|
+
usageLimitTotal?: number | undefined;
|
|
19
|
+
usageLimitPerUser?: number | undefined;
|
|
20
|
+
usageCount: number;
|
|
21
|
+
isActive: boolean;
|
|
22
|
+
expiresAt?: string | undefined;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface GetCouponsRequest {
|
|
27
|
+
pagination: PaginationRequest | undefined;
|
|
28
|
+
promotionId?: string | undefined;
|
|
29
|
+
isActive?: boolean | undefined;
|
|
30
|
+
search?: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface GetCouponsResponse {
|
|
34
|
+
items: CouponResponse[];
|
|
35
|
+
meta: PaginationMeta | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface GetCouponRequest {
|
|
39
|
+
id: string;
|
|
40
|
+
code?: string | undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface CreateCouponRequest {
|
|
44
|
+
promotionId: string;
|
|
45
|
+
code: string;
|
|
46
|
+
usageLimitTotal?: number | undefined;
|
|
47
|
+
usageLimitPerUser?: number | undefined;
|
|
48
|
+
expiresAt?: string | undefined;
|
|
49
|
+
isActive: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface UpdateCouponRequest {
|
|
53
|
+
id: string;
|
|
54
|
+
usageLimitTotal?: number | undefined;
|
|
55
|
+
usageLimitPerUser?: number | undefined;
|
|
56
|
+
expiresAt?: string | undefined;
|
|
57
|
+
isActive?: boolean | undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface DeactivateCouponRequest {
|
|
61
|
+
id: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface GenerateCouponsRequest {
|
|
65
|
+
promotionId: string;
|
|
66
|
+
count: number;
|
|
67
|
+
prefix?: string | undefined;
|
|
68
|
+
randomLength?: number | undefined;
|
|
69
|
+
usageLimitPerUser?: number | undefined;
|
|
70
|
+
expiresAt?: string | undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface GenerateCouponsResponse {
|
|
74
|
+
generated: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ExportCouponsRequest {
|
|
78
|
+
promotionId: string;
|
|
79
|
+
activeOnly?: boolean | undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ExportCouponsResponse {
|
|
83
|
+
csvContent: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface ImportCouponsRequest {
|
|
87
|
+
promotionId: string;
|
|
88
|
+
csvContent: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface ImportCouponsResponse {
|
|
92
|
+
imported: number;
|
|
93
|
+
skipped: number;
|
|
94
|
+
errors: string[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const PROMO_V1_PACKAGE_NAME = "promo.v1";
|
|
98
|
+
|
|
99
|
+
export interface CouponServiceClient {
|
|
100
|
+
getCoupons(request: GetCouponsRequest): Observable<GetCouponsResponse>;
|
|
101
|
+
|
|
102
|
+
getCoupon(request: GetCouponRequest): Observable<CouponResponse>;
|
|
103
|
+
|
|
104
|
+
createCoupon(request: CreateCouponRequest): Observable<CouponResponse>;
|
|
105
|
+
|
|
106
|
+
updateCoupon(request: UpdateCouponRequest): Observable<CouponResponse>;
|
|
107
|
+
|
|
108
|
+
deactivateCoupon(request: DeactivateCouponRequest): Observable<SuccessResponse>;
|
|
109
|
+
|
|
110
|
+
generateCoupons(request: GenerateCouponsRequest): Observable<GenerateCouponsResponse>;
|
|
111
|
+
|
|
112
|
+
exportCoupons(request: ExportCouponsRequest): Observable<ExportCouponsResponse>;
|
|
113
|
+
|
|
114
|
+
importCoupons(request: ImportCouponsRequest): Observable<ImportCouponsResponse>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface CouponServiceController {
|
|
118
|
+
getCoupons(
|
|
119
|
+
request: GetCouponsRequest,
|
|
120
|
+
): Promise<GetCouponsResponse> | Observable<GetCouponsResponse> | GetCouponsResponse;
|
|
121
|
+
|
|
122
|
+
getCoupon(request: GetCouponRequest): Promise<CouponResponse> | Observable<CouponResponse> | CouponResponse;
|
|
123
|
+
|
|
124
|
+
createCoupon(request: CreateCouponRequest): Promise<CouponResponse> | Observable<CouponResponse> | CouponResponse;
|
|
125
|
+
|
|
126
|
+
updateCoupon(request: UpdateCouponRequest): Promise<CouponResponse> | Observable<CouponResponse> | CouponResponse;
|
|
127
|
+
|
|
128
|
+
deactivateCoupon(
|
|
129
|
+
request: DeactivateCouponRequest,
|
|
130
|
+
): Promise<SuccessResponse> | Observable<SuccessResponse> | SuccessResponse;
|
|
131
|
+
|
|
132
|
+
generateCoupons(
|
|
133
|
+
request: GenerateCouponsRequest,
|
|
134
|
+
): Promise<GenerateCouponsResponse> | Observable<GenerateCouponsResponse> | GenerateCouponsResponse;
|
|
135
|
+
|
|
136
|
+
exportCoupons(
|
|
137
|
+
request: ExportCouponsRequest,
|
|
138
|
+
): Promise<ExportCouponsResponse> | Observable<ExportCouponsResponse> | ExportCouponsResponse;
|
|
139
|
+
|
|
140
|
+
importCoupons(
|
|
141
|
+
request: ImportCouponsRequest,
|
|
142
|
+
): Promise<ImportCouponsResponse> | Observable<ImportCouponsResponse> | ImportCouponsResponse;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function CouponServiceControllerMethods() {
|
|
146
|
+
return function (constructor: Function) {
|
|
147
|
+
const grpcMethods: string[] = [
|
|
148
|
+
"getCoupons",
|
|
149
|
+
"getCoupon",
|
|
150
|
+
"createCoupon",
|
|
151
|
+
"updateCoupon",
|
|
152
|
+
"deactivateCoupon",
|
|
153
|
+
"generateCoupons",
|
|
154
|
+
"exportCoupons",
|
|
155
|
+
"importCoupons",
|
|
156
|
+
];
|
|
157
|
+
for (const method of grpcMethods) {
|
|
158
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
159
|
+
GrpcMethod("CouponService", method)(constructor.prototype[method], method, descriptor);
|
|
160
|
+
}
|
|
161
|
+
const grpcStreamMethods: string[] = [];
|
|
162
|
+
for (const method of grpcStreamMethods) {
|
|
163
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
164
|
+
GrpcStreamMethod("CouponService", method)(constructor.prototype[method], method, descriptor);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export const COUPON_SERVICE_NAME = "CouponService";
|
package/gen/promotion.ts
ADDED
|
@@ -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
|
@@ -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
|
+
}
|