@managesome/eposmatic-toolkit 0.2.260 → 0.2.261

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.
@@ -1,4 +1,5 @@
1
1
  import { Schema } from 'mongoose';
2
+ import { GIFT_CARD_REWARD_TYPE_ENUM } from '../../constants';
2
3
  export declare const GiftCardsSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
3
4
  timestamps: true;
4
5
  versionKey: false;
@@ -16,26 +17,122 @@ export declare const GiftCardsSchema: Schema<any, import("mongoose").Model<any,
16
17
  brand_id: string;
17
18
  active: boolean;
18
19
  code: string;
19
- reward_type: import("../../constants").GIFT_CARD_REWARD_TYPE_ENUM;
20
+ reward_type: GIFT_CARD_REWARD_TYPE_ENUM;
20
21
  used_count: number;
21
- reward_items?: any;
22
- reward_discount?: any;
23
- reward_discount_items?: any;
24
- reward_points?: any;
25
- reward_cashback?: any;
26
- reward_voucher?: any;
22
+ reward_items?: {
23
+ item_ids: import("mongoose").Types.ObjectId[];
24
+ excluded_refs: string[];
25
+ exclusive_refs: string[];
26
+ num_of_items: number;
27
+ allocation?: import("mongoose").Types.DocumentArray<{
28
+ item_ids: import("mongoose").Types.ObjectId[];
29
+ quantity: number;
30
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
31
+ item_ids: import("mongoose").Types.ObjectId[];
32
+ quantity: number;
33
+ }> & {
34
+ item_ids: import("mongoose").Types.ObjectId[];
35
+ quantity: number;
36
+ }> | null | undefined;
37
+ } | null | undefined;
38
+ reward_discount?: {
39
+ is_discount_percentage: boolean;
40
+ excluded_refs: string[];
41
+ discount_value: number;
42
+ max_discount_amount?: number | null | undefined;
43
+ max_discount_percentage?: number | null | undefined;
44
+ } | null | undefined;
45
+ reward_discount_items?: {
46
+ is_discount_percentage: boolean;
47
+ item_ids: import("mongoose").Types.ObjectId[];
48
+ excluded_refs: string[];
49
+ exclusive_refs: string[];
50
+ num_of_items: number;
51
+ discount_value: number;
52
+ allocation?: import("mongoose").Types.DocumentArray<{
53
+ item_ids: import("mongoose").Types.ObjectId[];
54
+ quantity: number;
55
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
56
+ item_ids: import("mongoose").Types.ObjectId[];
57
+ quantity: number;
58
+ }> & {
59
+ item_ids: import("mongoose").Types.ObjectId[];
60
+ quantity: number;
61
+ }> | null | undefined;
62
+ } | null | undefined;
63
+ reward_points?: {
64
+ num_of_points: number;
65
+ once_per_order: boolean;
66
+ } | null | undefined;
67
+ reward_cashback?: {
68
+ excluded_refs: string[];
69
+ cashback_value: number;
70
+ is_cashback_percentage: boolean;
71
+ max_cashback_amount?: number | null | undefined;
72
+ } | null | undefined;
73
+ reward_voucher?: {
74
+ voucher_ids: Map<string, number>;
75
+ } | null | undefined;
27
76
  max_uses?: number | null | undefined;
28
77
  max_uses_per_customer?: number | null | undefined;
29
78
  last_used_at?: NativeDate | null | undefined;
30
79
  expire_at?: NativeDate | null | undefined;
31
80
  reward_mystery_gift?: {
32
81
  choice_of_rewards: string[];
33
- reward_items?: any;
34
- reward_discount?: any;
35
- reward_discount_items?: any;
36
- reward_points?: any;
37
- reward_cashback?: any;
38
- reward_voucher?: any;
82
+ reward_items?: {
83
+ item_ids: import("mongoose").Types.ObjectId[];
84
+ excluded_refs: string[];
85
+ exclusive_refs: string[];
86
+ num_of_items: number;
87
+ allocation?: import("mongoose").Types.DocumentArray<{
88
+ item_ids: import("mongoose").Types.ObjectId[];
89
+ quantity: number;
90
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
91
+ item_ids: import("mongoose").Types.ObjectId[];
92
+ quantity: number;
93
+ }> & {
94
+ item_ids: import("mongoose").Types.ObjectId[];
95
+ quantity: number;
96
+ }> | null | undefined;
97
+ } | null | undefined;
98
+ reward_discount?: {
99
+ is_discount_percentage: boolean;
100
+ excluded_refs: string[];
101
+ discount_value: number;
102
+ max_discount_amount?: number | null | undefined;
103
+ max_discount_percentage?: number | null | undefined;
104
+ } | null | undefined;
105
+ reward_discount_items?: {
106
+ is_discount_percentage: boolean;
107
+ item_ids: import("mongoose").Types.ObjectId[];
108
+ excluded_refs: string[];
109
+ exclusive_refs: string[];
110
+ num_of_items: number;
111
+ discount_value: number;
112
+ allocation?: import("mongoose").Types.DocumentArray<{
113
+ item_ids: import("mongoose").Types.ObjectId[];
114
+ quantity: number;
115
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
116
+ item_ids: import("mongoose").Types.ObjectId[];
117
+ quantity: number;
118
+ }> & {
119
+ item_ids: import("mongoose").Types.ObjectId[];
120
+ quantity: number;
121
+ }> | null | undefined;
122
+ } | null | undefined;
123
+ reward_points?: {
124
+ num_of_points: number;
125
+ once_per_order: boolean;
126
+ } | null | undefined;
127
+ reward_cashback?: {
128
+ excluded_refs: string[];
129
+ cashback_value: number;
130
+ is_cashback_percentage: boolean;
131
+ max_cashback_amount?: number | null | undefined;
132
+ } | null | undefined;
133
+ reward_voucher?: {
134
+ voucher_ids: Map<string, number>;
135
+ } | null | undefined;
39
136
  } | null | undefined;
40
137
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
41
138
  createdAt: NativeDate;
@@ -50,26 +147,122 @@ export declare const GiftCardsSchema: Schema<any, import("mongoose").Model<any,
50
147
  brand_id: string;
51
148
  active: boolean;
52
149
  code: string;
53
- reward_type: import("../../constants").GIFT_CARD_REWARD_TYPE_ENUM;
150
+ reward_type: GIFT_CARD_REWARD_TYPE_ENUM;
54
151
  used_count: number;
55
- reward_items?: any;
56
- reward_discount?: any;
57
- reward_discount_items?: any;
58
- reward_points?: any;
59
- reward_cashback?: any;
60
- reward_voucher?: any;
152
+ reward_items?: {
153
+ item_ids: import("mongoose").Types.ObjectId[];
154
+ excluded_refs: string[];
155
+ exclusive_refs: string[];
156
+ num_of_items: number;
157
+ allocation?: import("mongoose").Types.DocumentArray<{
158
+ item_ids: import("mongoose").Types.ObjectId[];
159
+ quantity: number;
160
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
161
+ item_ids: import("mongoose").Types.ObjectId[];
162
+ quantity: number;
163
+ }> & {
164
+ item_ids: import("mongoose").Types.ObjectId[];
165
+ quantity: number;
166
+ }> | null | undefined;
167
+ } | null | undefined;
168
+ reward_discount?: {
169
+ is_discount_percentage: boolean;
170
+ excluded_refs: string[];
171
+ discount_value: number;
172
+ max_discount_amount?: number | null | undefined;
173
+ max_discount_percentage?: number | null | undefined;
174
+ } | null | undefined;
175
+ reward_discount_items?: {
176
+ is_discount_percentage: boolean;
177
+ item_ids: import("mongoose").Types.ObjectId[];
178
+ excluded_refs: string[];
179
+ exclusive_refs: string[];
180
+ num_of_items: number;
181
+ discount_value: number;
182
+ allocation?: import("mongoose").Types.DocumentArray<{
183
+ item_ids: import("mongoose").Types.ObjectId[];
184
+ quantity: number;
185
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
186
+ item_ids: import("mongoose").Types.ObjectId[];
187
+ quantity: number;
188
+ }> & {
189
+ item_ids: import("mongoose").Types.ObjectId[];
190
+ quantity: number;
191
+ }> | null | undefined;
192
+ } | null | undefined;
193
+ reward_points?: {
194
+ num_of_points: number;
195
+ once_per_order: boolean;
196
+ } | null | undefined;
197
+ reward_cashback?: {
198
+ excluded_refs: string[];
199
+ cashback_value: number;
200
+ is_cashback_percentage: boolean;
201
+ max_cashback_amount?: number | null | undefined;
202
+ } | null | undefined;
203
+ reward_voucher?: {
204
+ voucher_ids: Map<string, number>;
205
+ } | null | undefined;
61
206
  max_uses?: number | null | undefined;
62
207
  max_uses_per_customer?: number | null | undefined;
63
208
  last_used_at?: NativeDate | null | undefined;
64
209
  expire_at?: NativeDate | null | undefined;
65
210
  reward_mystery_gift?: {
66
211
  choice_of_rewards: string[];
67
- reward_items?: any;
68
- reward_discount?: any;
69
- reward_discount_items?: any;
70
- reward_points?: any;
71
- reward_cashback?: any;
72
- reward_voucher?: any;
212
+ reward_items?: {
213
+ item_ids: import("mongoose").Types.ObjectId[];
214
+ excluded_refs: string[];
215
+ exclusive_refs: string[];
216
+ num_of_items: number;
217
+ allocation?: import("mongoose").Types.DocumentArray<{
218
+ item_ids: import("mongoose").Types.ObjectId[];
219
+ quantity: number;
220
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
221
+ item_ids: import("mongoose").Types.ObjectId[];
222
+ quantity: number;
223
+ }> & {
224
+ item_ids: import("mongoose").Types.ObjectId[];
225
+ quantity: number;
226
+ }> | null | undefined;
227
+ } | null | undefined;
228
+ reward_discount?: {
229
+ is_discount_percentage: boolean;
230
+ excluded_refs: string[];
231
+ discount_value: number;
232
+ max_discount_amount?: number | null | undefined;
233
+ max_discount_percentage?: number | null | undefined;
234
+ } | null | undefined;
235
+ reward_discount_items?: {
236
+ is_discount_percentage: boolean;
237
+ item_ids: import("mongoose").Types.ObjectId[];
238
+ excluded_refs: string[];
239
+ exclusive_refs: string[];
240
+ num_of_items: number;
241
+ discount_value: number;
242
+ allocation?: import("mongoose").Types.DocumentArray<{
243
+ item_ids: import("mongoose").Types.ObjectId[];
244
+ quantity: number;
245
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
246
+ item_ids: import("mongoose").Types.ObjectId[];
247
+ quantity: number;
248
+ }> & {
249
+ item_ids: import("mongoose").Types.ObjectId[];
250
+ quantity: number;
251
+ }> | null | undefined;
252
+ } | null | undefined;
253
+ reward_points?: {
254
+ num_of_points: number;
255
+ once_per_order: boolean;
256
+ } | null | undefined;
257
+ reward_cashback?: {
258
+ excluded_refs: string[];
259
+ cashback_value: number;
260
+ is_cashback_percentage: boolean;
261
+ max_cashback_amount?: number | null | undefined;
262
+ } | null | undefined;
263
+ reward_voucher?: {
264
+ voucher_ids: Map<string, number>;
265
+ } | null | undefined;
73
266
  } | null | undefined;
74
267
  }>> & import("mongoose").FlatRecord<{
75
268
  createdAt: NativeDate;
@@ -84,26 +277,122 @@ export declare const GiftCardsSchema: Schema<any, import("mongoose").Model<any,
84
277
  brand_id: string;
85
278
  active: boolean;
86
279
  code: string;
87
- reward_type: import("../../constants").GIFT_CARD_REWARD_TYPE_ENUM;
280
+ reward_type: GIFT_CARD_REWARD_TYPE_ENUM;
88
281
  used_count: number;
89
- reward_items?: any;
90
- reward_discount?: any;
91
- reward_discount_items?: any;
92
- reward_points?: any;
93
- reward_cashback?: any;
94
- reward_voucher?: any;
282
+ reward_items?: {
283
+ item_ids: import("mongoose").Types.ObjectId[];
284
+ excluded_refs: string[];
285
+ exclusive_refs: string[];
286
+ num_of_items: number;
287
+ allocation?: import("mongoose").Types.DocumentArray<{
288
+ item_ids: import("mongoose").Types.ObjectId[];
289
+ quantity: number;
290
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
291
+ item_ids: import("mongoose").Types.ObjectId[];
292
+ quantity: number;
293
+ }> & {
294
+ item_ids: import("mongoose").Types.ObjectId[];
295
+ quantity: number;
296
+ }> | null | undefined;
297
+ } | null | undefined;
298
+ reward_discount?: {
299
+ is_discount_percentage: boolean;
300
+ excluded_refs: string[];
301
+ discount_value: number;
302
+ max_discount_amount?: number | null | undefined;
303
+ max_discount_percentage?: number | null | undefined;
304
+ } | null | undefined;
305
+ reward_discount_items?: {
306
+ is_discount_percentage: boolean;
307
+ item_ids: import("mongoose").Types.ObjectId[];
308
+ excluded_refs: string[];
309
+ exclusive_refs: string[];
310
+ num_of_items: number;
311
+ discount_value: number;
312
+ allocation?: import("mongoose").Types.DocumentArray<{
313
+ item_ids: import("mongoose").Types.ObjectId[];
314
+ quantity: number;
315
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
316
+ item_ids: import("mongoose").Types.ObjectId[];
317
+ quantity: number;
318
+ }> & {
319
+ item_ids: import("mongoose").Types.ObjectId[];
320
+ quantity: number;
321
+ }> | null | undefined;
322
+ } | null | undefined;
323
+ reward_points?: {
324
+ num_of_points: number;
325
+ once_per_order: boolean;
326
+ } | null | undefined;
327
+ reward_cashback?: {
328
+ excluded_refs: string[];
329
+ cashback_value: number;
330
+ is_cashback_percentage: boolean;
331
+ max_cashback_amount?: number | null | undefined;
332
+ } | null | undefined;
333
+ reward_voucher?: {
334
+ voucher_ids: Map<string, number>;
335
+ } | null | undefined;
95
336
  max_uses?: number | null | undefined;
96
337
  max_uses_per_customer?: number | null | undefined;
97
338
  last_used_at?: NativeDate | null | undefined;
98
339
  expire_at?: NativeDate | null | undefined;
99
340
  reward_mystery_gift?: {
100
341
  choice_of_rewards: string[];
101
- reward_items?: any;
102
- reward_discount?: any;
103
- reward_discount_items?: any;
104
- reward_points?: any;
105
- reward_cashback?: any;
106
- reward_voucher?: any;
342
+ reward_items?: {
343
+ item_ids: import("mongoose").Types.ObjectId[];
344
+ excluded_refs: string[];
345
+ exclusive_refs: string[];
346
+ num_of_items: number;
347
+ allocation?: import("mongoose").Types.DocumentArray<{
348
+ item_ids: import("mongoose").Types.ObjectId[];
349
+ quantity: number;
350
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
351
+ item_ids: import("mongoose").Types.ObjectId[];
352
+ quantity: number;
353
+ }> & {
354
+ item_ids: import("mongoose").Types.ObjectId[];
355
+ quantity: number;
356
+ }> | null | undefined;
357
+ } | null | undefined;
358
+ reward_discount?: {
359
+ is_discount_percentage: boolean;
360
+ excluded_refs: string[];
361
+ discount_value: number;
362
+ max_discount_amount?: number | null | undefined;
363
+ max_discount_percentage?: number | null | undefined;
364
+ } | null | undefined;
365
+ reward_discount_items?: {
366
+ is_discount_percentage: boolean;
367
+ item_ids: import("mongoose").Types.ObjectId[];
368
+ excluded_refs: string[];
369
+ exclusive_refs: string[];
370
+ num_of_items: number;
371
+ discount_value: number;
372
+ allocation?: import("mongoose").Types.DocumentArray<{
373
+ item_ids: import("mongoose").Types.ObjectId[];
374
+ quantity: number;
375
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
376
+ item_ids: import("mongoose").Types.ObjectId[];
377
+ quantity: number;
378
+ }> & {
379
+ item_ids: import("mongoose").Types.ObjectId[];
380
+ quantity: number;
381
+ }> | null | undefined;
382
+ } | null | undefined;
383
+ reward_points?: {
384
+ num_of_points: number;
385
+ once_per_order: boolean;
386
+ } | null | undefined;
387
+ reward_cashback?: {
388
+ excluded_refs: string[];
389
+ cashback_value: number;
390
+ is_cashback_percentage: boolean;
391
+ max_cashback_amount?: number | null | undefined;
392
+ } | null | undefined;
393
+ reward_voucher?: {
394
+ voucher_ids: Map<string, number>;
395
+ } | null | undefined;
107
396
  } | null | undefined;
108
397
  }> & Required<{
109
398
  _id: import("mongoose").Types.ObjectId;
@@ -3,6 +3,168 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GIFT_CARDS_COLLECTION_NAME = exports.GiftCardsSchema = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
5
  const constants_1 = require("../../constants");
6
+ const RewardItemsSchema = new mongoose_1.Schema({
7
+ num_of_items: {
8
+ type: Number,
9
+ required: true,
10
+ },
11
+ excluded_refs: {
12
+ type: [String],
13
+ required: true,
14
+ default: [],
15
+ },
16
+ exclusive_refs: {
17
+ type: [String],
18
+ required: true,
19
+ default: [],
20
+ },
21
+ item_ids: {
22
+ type: [mongoose_1.Schema.Types.ObjectId],
23
+ required: true,
24
+ min: 1,
25
+ },
26
+ allocation: {
27
+ type: [
28
+ {
29
+ quantity: {
30
+ type: Number,
31
+ required: true,
32
+ },
33
+ item_ids: {
34
+ type: [mongoose_1.Schema.Types.ObjectId],
35
+ required: true,
36
+ min: 1,
37
+ },
38
+ },
39
+ ],
40
+ required: false,
41
+ },
42
+ }, {
43
+ _id: false,
44
+ minimize: false,
45
+ });
46
+ const RewardDiscountSchema = new mongoose_1.Schema({
47
+ discount_value: {
48
+ type: Number,
49
+ required: true,
50
+ },
51
+ is_discount_percentage: {
52
+ type: Boolean,
53
+ required: true,
54
+ },
55
+ max_discount_amount: {
56
+ type: Number,
57
+ required: false,
58
+ default: null,
59
+ },
60
+ max_discount_percentage: {
61
+ type: Number,
62
+ required: false,
63
+ default: null,
64
+ },
65
+ excluded_refs: {
66
+ type: [String],
67
+ required: true,
68
+ default: [],
69
+ },
70
+ }, {
71
+ _id: false,
72
+ minimize: false,
73
+ });
74
+ const RewardDiscountItemsSchema = new mongoose_1.Schema({
75
+ num_of_items: {
76
+ type: Number,
77
+ required: true,
78
+ },
79
+ excluded_refs: {
80
+ type: [String],
81
+ required: true,
82
+ default: [],
83
+ },
84
+ exclusive_refs: {
85
+ type: [String],
86
+ required: true,
87
+ default: [],
88
+ },
89
+ item_ids: {
90
+ type: [mongoose_1.Schema.Types.ObjectId],
91
+ required: true,
92
+ min: 1,
93
+ },
94
+ allocation: {
95
+ type: [
96
+ {
97
+ quantity: {
98
+ type: Number,
99
+ required: true,
100
+ },
101
+ item_ids: {
102
+ type: [mongoose_1.Schema.Types.ObjectId],
103
+ required: true,
104
+ min: 1,
105
+ },
106
+ },
107
+ ],
108
+ required: false,
109
+ },
110
+ discount_value: {
111
+ type: Number,
112
+ required: true,
113
+ },
114
+ is_discount_percentage: {
115
+ type: Boolean,
116
+ required: true,
117
+ },
118
+ }, {
119
+ _id: false,
120
+ minimize: false,
121
+ });
122
+ const RewardPointsSchema = new mongoose_1.Schema({
123
+ num_of_points: {
124
+ type: Number,
125
+ required: true,
126
+ },
127
+ once_per_order: {
128
+ type: Boolean,
129
+ required: true,
130
+ },
131
+ }, {
132
+ _id: false,
133
+ minimize: false,
134
+ });
135
+ const RewardCashbackSchema = new mongoose_1.Schema({
136
+ cashback_value: {
137
+ type: Number,
138
+ required: true,
139
+ },
140
+ is_cashback_percentage: {
141
+ type: Boolean,
142
+ required: true,
143
+ },
144
+ max_cashback_amount: {
145
+ type: Number,
146
+ required: false,
147
+ default: null,
148
+ },
149
+ excluded_refs: {
150
+ type: [String],
151
+ required: true,
152
+ default: [],
153
+ },
154
+ }, {
155
+ _id: false,
156
+ minimize: false,
157
+ });
158
+ const RewardVoucherSchema = new mongoose_1.Schema({
159
+ voucher_ids: {
160
+ type: Map,
161
+ of: Number,
162
+ required: true,
163
+ },
164
+ }, {
165
+ _id: false,
166
+ minimize: false,
167
+ });
6
168
  const RewardMysteryGiftSchema = new mongoose_1.Schema({
7
169
  choice_of_rewards: {
8
170
  type: [String],
@@ -11,27 +173,27 @@ const RewardMysteryGiftSchema = new mongoose_1.Schema({
11
173
  min: 1,
12
174
  },
13
175
  reward_discount: {
14
- type: mongoose_1.Schema.Types.Mixed,
176
+ type: RewardDiscountSchema,
15
177
  required: false,
16
178
  },
17
179
  reward_discount_items: {
18
- type: mongoose_1.Schema.Types.Mixed,
180
+ type: RewardDiscountItemsSchema,
19
181
  required: false,
20
182
  },
21
183
  reward_points: {
22
- type: mongoose_1.Schema.Types.Mixed,
184
+ type: RewardPointsSchema,
23
185
  required: false,
24
186
  },
25
187
  reward_cashback: {
26
- type: mongoose_1.Schema.Types.Mixed,
188
+ type: RewardCashbackSchema,
27
189
  required: false,
28
190
  },
29
191
  reward_items: {
30
- type: mongoose_1.Schema.Types.Mixed,
192
+ type: RewardItemsSchema,
31
193
  required: false,
32
194
  },
33
195
  reward_voucher: {
34
- type: mongoose_1.Schema.Types.Mixed,
196
+ type: RewardVoucherSchema,
35
197
  required: false,
36
198
  },
37
199
  }, {
@@ -98,32 +260,46 @@ exports.GiftCardsSchema = new mongoose_1.Schema({
98
260
  required: true,
99
261
  },
100
262
  reward_items: {
101
- type: mongoose_1.Schema.Types.Mixed,
102
- required: false,
263
+ type: RewardItemsSchema,
264
+ required() {
265
+ return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.ITEMS;
266
+ },
103
267
  },
104
268
  reward_discount: {
105
- type: mongoose_1.Schema.Types.Mixed,
106
- required: false,
269
+ type: RewardDiscountSchema,
270
+ required() {
271
+ return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.DISCOUNT;
272
+ },
107
273
  },
108
274
  reward_discount_items: {
109
- type: mongoose_1.Schema.Types.Mixed,
110
- required: false,
275
+ type: RewardDiscountItemsSchema,
276
+ required() {
277
+ return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.DISCOUNT_ITEMS;
278
+ },
111
279
  },
112
280
  reward_points: {
113
- type: mongoose_1.Schema.Types.Mixed,
114
- required: false,
281
+ type: RewardPointsSchema,
282
+ required() {
283
+ return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.POINTS;
284
+ },
115
285
  },
116
286
  reward_cashback: {
117
- type: mongoose_1.Schema.Types.Mixed,
118
- required: false,
287
+ type: RewardCashbackSchema,
288
+ required() {
289
+ return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.CASHBACK;
290
+ },
119
291
  },
120
292
  reward_voucher: {
121
- type: mongoose_1.Schema.Types.Mixed,
122
- required: false,
293
+ type: RewardVoucherSchema,
294
+ required() {
295
+ return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.VOUCHER;
296
+ },
123
297
  },
124
298
  reward_mystery_gift: {
125
299
  type: RewardMysteryGiftSchema,
126
- required: false,
300
+ required() {
301
+ return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.MYSTERY_GIFT;
302
+ },
127
303
  },
128
304
  expire_at: {
129
305
  type: mongoose_1.Schema.Types.Date,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.260",
3
+ "version": "0.2.261",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",