@classytic/loyalty 0.6.0 → 0.10.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.
- package/CHANGELOG.md +180 -0
- package/dist/constants-DfrENxFG.mjs +75 -0
- package/dist/domain/earn-base.d.mts +35 -0
- package/dist/domain/earn-base.mjs +37 -0
- package/dist/domain/enums/index.d.mts +2 -2
- package/dist/domain/enums/index.mjs +1 -2
- package/dist/domain/rule-schedule.d.mts +24 -0
- package/dist/domain/rule-schedule.mjs +12 -0
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.mjs +3 -3
- package/dist/{events-BLjg3uLA.mjs → events-DhZolW61.mjs} +104 -4
- package/dist/{index-CR2k7jQ8.d.mts → index-BvyzKU7R.d.mts} +294 -34
- package/dist/{index-D6GvuvmF.d.mts → index-CorB0JL6.d.mts} +259 -113
- package/dist/index-DRrEhE0r.d.mts +604 -0
- package/dist/{index-YUFamhDk.d.mts → index-Db5Gb7x_.d.mts} +187 -39
- package/dist/index-tjMMmPzU.d.mts +36 -0
- package/dist/index.d.mts +121 -30
- package/dist/index.mjs +63 -10
- package/dist/{loyalty-events-DXirolM_.mjs → loyalty-events-j29B66YW.mjs} +20 -13
- package/dist/models/index.d.mts +2 -2
- package/dist/models/index.mjs +1 -2
- package/dist/{models-weWqS5Bc.mjs → models-BEGLduz1.mjs} +276 -7
- package/dist/notifications/index.d.mts +3 -4
- package/dist/repositories/index.d.mts +2 -2
- package/dist/repositories/index.mjs +1 -2
- package/dist/{repositories-B676z4bE.mjs → repositories-ER68JmUo.mjs} +1178 -102
- package/dist/types/index.d.mts +2 -3
- package/package.json +39 -22
- package/dist/config-CtkGj3xZ.d.mts +0 -178
- package/dist/constants-DOPBh6kt.mjs +0 -48
- package/dist/index-Cp_sXNpG.d.mts +0 -349
- package/dist/index-D_Oe3aDk.d.mts +0 -19
|
@@ -1,35 +1,170 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as StampAwardStatus, l as StampEarnUnit, u as StampProgramStatus } from "./index-tjMMmPzU.mjs";
|
|
2
|
+
import { C as IndexDefinition, O as ModelName, T as LoyaltyModelName } from "./index-DRrEhE0r.mjs";
|
|
2
3
|
import { ModelBlueprint } from "@classytic/mongokit";
|
|
3
4
|
import { ResolvedTenantConfig } from "@classytic/repo-core/tenant";
|
|
4
|
-
import mongoose, { InferSchemaType, Model } from "mongoose";
|
|
5
|
+
import mongoose, { InferSchemaType, Model, Types } from "mongoose";
|
|
6
|
+
//#region src/domain/entities/stamp.d.ts
|
|
7
|
+
/** What earns a stamp. An absent filter means "any"; an EMPTY list is refused at write. */
|
|
8
|
+
interface StampEarn {
|
|
9
|
+
unit: StampEarnUnit;
|
|
10
|
+
/** Category SLUGS (what an order line freezes as `snapshot.metadata.categoryId`). */
|
|
11
|
+
categoryIds?: string[];
|
|
12
|
+
productIds?: string[];
|
|
13
|
+
/** `spend` only (required there): one stamp per `perMinor` minor units, floored. */
|
|
14
|
+
perMinor?: number;
|
|
15
|
+
/** The order total (minor units) an order must reach to earn at all. */
|
|
16
|
+
minOrderMinor?: number;
|
|
17
|
+
}
|
|
18
|
+
type StampReward = {
|
|
19
|
+
kind: 'points';
|
|
20
|
+
points: number;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'voucher';
|
|
23
|
+
voucherProgramId: string;
|
|
24
|
+
};
|
|
25
|
+
interface StampProgram {
|
|
26
|
+
_id: Types.ObjectId;
|
|
27
|
+
/** The loyalty program (as on earning rules and members) — not this stamp program's id. */
|
|
28
|
+
programId: string;
|
|
29
|
+
name: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
status: StampProgramStatus;
|
|
32
|
+
earn: StampEarn;
|
|
33
|
+
stampsRequired: number;
|
|
34
|
+
/** Stamps expire this many days after the order that earned them; absent = never. */
|
|
35
|
+
stampValidityDays?: number;
|
|
36
|
+
/** Only orders placed in `[startsAt, endsAt)` earn. */
|
|
37
|
+
startsAt?: Date;
|
|
38
|
+
endsAt?: Date;
|
|
39
|
+
reward: StampReward;
|
|
40
|
+
maxRewardsPerMember?: number;
|
|
41
|
+
/** Branches whose orders earn; absent = every branch. */
|
|
42
|
+
branchIds?: string[];
|
|
43
|
+
metadata?: Record<string, unknown>;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
updatedAt: Date;
|
|
46
|
+
}
|
|
47
|
+
/** Stamps one order earned on one program. Idempotency is the unique index, never a lookup. */
|
|
48
|
+
interface StampEntry {
|
|
49
|
+
_id: Types.ObjectId;
|
|
50
|
+
stampProgramId: Types.ObjectId;
|
|
51
|
+
memberId: Types.ObjectId;
|
|
52
|
+
orderRef: string;
|
|
53
|
+
stamps: number;
|
|
54
|
+
/** Stamps of this entry already spent on awards (oldest entries are consumed first). */
|
|
55
|
+
consumed: number;
|
|
56
|
+
earnedAt: Date;
|
|
57
|
+
expiresAt?: Date;
|
|
58
|
+
/** The business day (`YYYY-MM-DD` in the engine's timezone) the order fell on. */
|
|
59
|
+
businessDay: string;
|
|
60
|
+
/** Set on `visit` entries while live — the unique index allows one visit stamp per day. */
|
|
61
|
+
visitKey?: string;
|
|
62
|
+
branchId?: string;
|
|
63
|
+
reversedAt?: Date;
|
|
64
|
+
/** Unconsumed stamps the reversal removed. */
|
|
65
|
+
reversedStamps?: number;
|
|
66
|
+
}
|
|
67
|
+
interface StampAwardReward {
|
|
68
|
+
kind: 'points' | 'voucher';
|
|
69
|
+
points?: number;
|
|
70
|
+
pointTransactionId?: Types.ObjectId;
|
|
71
|
+
voucherProgramId?: string;
|
|
72
|
+
voucherId?: string;
|
|
73
|
+
code?: string;
|
|
74
|
+
}
|
|
75
|
+
interface StampAward {
|
|
76
|
+
_id: Types.ObjectId;
|
|
77
|
+
stampProgramId: Types.ObjectId;
|
|
78
|
+
memberId: Types.ObjectId;
|
|
79
|
+
/** 1-based per (program, member); unique, so two concurrent settles cannot both award #n. */
|
|
80
|
+
sequence: number;
|
|
81
|
+
/** `stamp:<stampProgramId>:<memberId>:<sequence>` — the reward's idempotency key. */
|
|
82
|
+
awardKey: string;
|
|
83
|
+
entries: Array<{
|
|
84
|
+
entryId: Types.ObjectId;
|
|
85
|
+
stamps: number;
|
|
86
|
+
}>;
|
|
87
|
+
stampsConsumed: number;
|
|
88
|
+
status: StampAwardStatus;
|
|
89
|
+
reward: StampAwardReward;
|
|
90
|
+
awardedAt: Date;
|
|
91
|
+
issuedAt?: Date;
|
|
92
|
+
}
|
|
93
|
+
/** One priced order line, integer minor units. */
|
|
94
|
+
interface StampOrderLine {
|
|
95
|
+
productId?: string | undefined;
|
|
96
|
+
categoryId?: string | undefined;
|
|
97
|
+
quantity: number;
|
|
98
|
+
amountMinor: number;
|
|
99
|
+
/** The quantity increment the line sells in (`0.001` for rice by the kg). Absent = 1, a whole-unit item. */
|
|
100
|
+
quantityStep?: number | undefined;
|
|
101
|
+
}
|
|
102
|
+
interface StampOrderInput {
|
|
103
|
+
memberId: string;
|
|
104
|
+
/** Retry-stable order identity (the order number). */
|
|
105
|
+
orderRef: string;
|
|
106
|
+
occurredAt: Date;
|
|
107
|
+
branchId?: string | undefined;
|
|
108
|
+
orderTotalMinor: number;
|
|
109
|
+
lines: StampOrderLine[];
|
|
110
|
+
}
|
|
111
|
+
interface StampProgress {
|
|
112
|
+
stampProgramId: string;
|
|
113
|
+
name: string;
|
|
114
|
+
stampsRequired: number;
|
|
115
|
+
/** Unexpired, unconsumed, unreversed stamps. */
|
|
116
|
+
stamps: number;
|
|
117
|
+
/** When the soonest of those stamps expires; absent when none expire. */
|
|
118
|
+
nextExpiry?: Date;
|
|
119
|
+
rewardsEarned: number;
|
|
120
|
+
maxRewardsPerMember?: number;
|
|
121
|
+
reward: StampReward;
|
|
122
|
+
}
|
|
123
|
+
interface StampRecordResult {
|
|
124
|
+
stampProgramId: string;
|
|
125
|
+
/** Stamps this call added — 0 when the order (or the visit day) was already recorded. */
|
|
126
|
+
stamps: number;
|
|
127
|
+
duplicate: boolean;
|
|
128
|
+
awards: StampAward[];
|
|
129
|
+
}
|
|
130
|
+
interface StampReversal {
|
|
131
|
+
stampProgramId: string;
|
|
132
|
+
memberId: string;
|
|
133
|
+
entryId: string;
|
|
134
|
+
/** Unconsumed stamps removed. */
|
|
135
|
+
reversed: number;
|
|
136
|
+
/** Stamps already consumed into an award — kept, never clawed back. */
|
|
137
|
+
retainedInAwards: number;
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
5
140
|
//#region src/models/schemas/earning-rule.schema.d.ts
|
|
6
141
|
declare function createEarningRuleSchema(): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
7
142
|
timestamps: true;
|
|
8
143
|
}, {
|
|
9
144
|
programId: string;
|
|
10
|
-
type: "order" | "action" | "category" | "tier_bonus";
|
|
11
145
|
name: string;
|
|
12
|
-
status: "active" | "paused" | "expired";
|
|
13
|
-
priority: number;
|
|
14
146
|
description?: string | null;
|
|
147
|
+
type: "action" | "category" | "order" | "tier_bonus";
|
|
148
|
+
status: "active" | "expired" | "paused";
|
|
149
|
+
priority: number;
|
|
15
150
|
conditions?: {
|
|
151
|
+
minOrderAmount?: number | null;
|
|
16
152
|
categories: string[];
|
|
17
153
|
tiers: string[];
|
|
18
154
|
actions: string[];
|
|
19
155
|
dayOfWeek: number[];
|
|
20
|
-
minOrderAmount?: number | null;
|
|
21
156
|
dateRange?: {
|
|
22
157
|
start?: NativeDate | null;
|
|
23
158
|
end?: NativeDate | null;
|
|
24
159
|
} | null;
|
|
25
160
|
} | null;
|
|
26
161
|
reward?: {
|
|
27
|
-
roundingMode: "floor" | "round" | "ceil";
|
|
28
162
|
pointsPerAmount?: number | null;
|
|
29
163
|
rateBasis?: number | null;
|
|
30
164
|
amountPerPoint?: number | null;
|
|
31
165
|
fixedPoints?: number | null;
|
|
32
166
|
multiplier?: number | null;
|
|
167
|
+
roundingMode: "ceil" | "floor" | "round";
|
|
33
168
|
maxPointsPerTransaction?: number | null;
|
|
34
169
|
} | null;
|
|
35
170
|
startsAt?: NativeDate | null;
|
|
@@ -37,29 +172,29 @@ declare function createEarningRuleSchema(): mongoose.Schema<any, mongoose.Model<
|
|
|
37
172
|
metadata?: any;
|
|
38
173
|
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
|
|
39
174
|
programId: string;
|
|
40
|
-
type: "order" | "action" | "category" | "tier_bonus";
|
|
41
175
|
name: string;
|
|
42
|
-
status: "active" | "paused" | "expired";
|
|
43
|
-
priority: number;
|
|
44
176
|
description?: string | null;
|
|
177
|
+
type: "action" | "category" | "order" | "tier_bonus";
|
|
178
|
+
status: "active" | "expired" | "paused";
|
|
179
|
+
priority: number;
|
|
45
180
|
conditions?: {
|
|
181
|
+
minOrderAmount?: number | null;
|
|
46
182
|
categories: string[];
|
|
47
183
|
tiers: string[];
|
|
48
184
|
actions: string[];
|
|
49
185
|
dayOfWeek: number[];
|
|
50
|
-
minOrderAmount?: number | null;
|
|
51
186
|
dateRange?: {
|
|
52
187
|
start?: NativeDate | null;
|
|
53
188
|
end?: NativeDate | null;
|
|
54
189
|
} | null;
|
|
55
190
|
} | null;
|
|
56
191
|
reward?: {
|
|
57
|
-
roundingMode: "floor" | "round" | "ceil";
|
|
58
192
|
pointsPerAmount?: number | null;
|
|
59
193
|
rateBasis?: number | null;
|
|
60
194
|
amountPerPoint?: number | null;
|
|
61
195
|
fixedPoints?: number | null;
|
|
62
196
|
multiplier?: number | null;
|
|
197
|
+
roundingMode: "ceil" | "floor" | "round";
|
|
63
198
|
maxPointsPerTransaction?: number | null;
|
|
64
199
|
} | null;
|
|
65
200
|
startsAt?: NativeDate | null;
|
|
@@ -71,29 +206,29 @@ declare function createEarningRuleSchema(): mongoose.Schema<any, mongoose.Model<
|
|
|
71
206
|
timestamps: true;
|
|
72
207
|
}> & Omit<{
|
|
73
208
|
programId: string;
|
|
74
|
-
type: "order" | "action" | "category" | "tier_bonus";
|
|
75
209
|
name: string;
|
|
76
|
-
status: "active" | "paused" | "expired";
|
|
77
|
-
priority: number;
|
|
78
210
|
description?: string | null;
|
|
211
|
+
type: "action" | "category" | "order" | "tier_bonus";
|
|
212
|
+
status: "active" | "expired" | "paused";
|
|
213
|
+
priority: number;
|
|
79
214
|
conditions?: {
|
|
215
|
+
minOrderAmount?: number | null;
|
|
80
216
|
categories: string[];
|
|
81
217
|
tiers: string[];
|
|
82
218
|
actions: string[];
|
|
83
219
|
dayOfWeek: number[];
|
|
84
|
-
minOrderAmount?: number | null;
|
|
85
220
|
dateRange?: {
|
|
86
221
|
start?: NativeDate | null;
|
|
87
222
|
end?: NativeDate | null;
|
|
88
223
|
} | null;
|
|
89
224
|
} | null;
|
|
90
225
|
reward?: {
|
|
91
|
-
roundingMode: "floor" | "round" | "ceil";
|
|
92
226
|
pointsPerAmount?: number | null;
|
|
93
227
|
rateBasis?: number | null;
|
|
94
228
|
amountPerPoint?: number | null;
|
|
95
229
|
fixedPoints?: number | null;
|
|
96
230
|
multiplier?: number | null;
|
|
231
|
+
roundingMode: "ceil" | "floor" | "round";
|
|
97
232
|
maxPointsPerTransaction?: number | null;
|
|
98
233
|
} | null;
|
|
99
234
|
startsAt?: NativeDate | null;
|
|
@@ -106,37 +241,37 @@ declare function createEarningRuleSchema(): mongoose.Schema<any, mongoose.Model<
|
|
|
106
241
|
}, "id"> & mongoose.HydratedDocumentOverrides<{
|
|
107
242
|
id: string;
|
|
108
243
|
}>, unknown, {
|
|
244
|
+
createdAt: NativeDate;
|
|
245
|
+
updatedAt: NativeDate;
|
|
109
246
|
programId: string;
|
|
110
|
-
type: "order" | "action" | "category" | "tier_bonus";
|
|
111
247
|
name: string;
|
|
112
|
-
status: "active" | "paused" | "expired";
|
|
113
|
-
priority: number;
|
|
114
248
|
description?: string | null;
|
|
249
|
+
type: "action" | "category" | "order" | "tier_bonus";
|
|
250
|
+
status: "active" | "expired" | "paused";
|
|
251
|
+
priority: number;
|
|
115
252
|
conditions?: {
|
|
253
|
+
minOrderAmount?: number | null;
|
|
116
254
|
categories: string[];
|
|
117
255
|
tiers: string[];
|
|
118
256
|
actions: string[];
|
|
119
257
|
dayOfWeek: number[];
|
|
120
|
-
minOrderAmount?: number | null;
|
|
121
258
|
dateRange?: {
|
|
122
259
|
start?: NativeDate | null;
|
|
123
260
|
end?: NativeDate | null;
|
|
124
261
|
} | null;
|
|
125
262
|
} | null;
|
|
126
263
|
reward?: {
|
|
127
|
-
roundingMode: "floor" | "round" | "ceil";
|
|
128
264
|
pointsPerAmount?: number | null;
|
|
129
265
|
rateBasis?: number | null;
|
|
130
266
|
amountPerPoint?: number | null;
|
|
131
267
|
fixedPoints?: number | null;
|
|
132
268
|
multiplier?: number | null;
|
|
269
|
+
roundingMode: "ceil" | "floor" | "round";
|
|
133
270
|
maxPointsPerTransaction?: number | null;
|
|
134
271
|
} | null;
|
|
135
272
|
startsAt?: NativeDate | null;
|
|
136
273
|
endsAt?: NativeDate | null;
|
|
137
274
|
metadata?: any;
|
|
138
|
-
createdAt: NativeDate;
|
|
139
|
-
updatedAt: NativeDate;
|
|
140
275
|
} & {
|
|
141
276
|
_id: mongoose.Types.ObjectId;
|
|
142
277
|
} & {
|
|
@@ -148,11 +283,9 @@ declare function createMemberSchema(): mongoose.Schema<any, mongoose.Model<any,
|
|
|
148
283
|
timestamps: true;
|
|
149
284
|
}, {
|
|
150
285
|
programId: string;
|
|
151
|
-
status: "active" | "inactive" | "suspended";
|
|
152
286
|
externalId: string;
|
|
153
287
|
externalType: string;
|
|
154
|
-
|
|
155
|
-
metadata?: any;
|
|
288
|
+
status: "active" | "inactive" | "suspended";
|
|
156
289
|
cardId?: string | null;
|
|
157
290
|
referralCode?: string | null;
|
|
158
291
|
tier?: string | null;
|
|
@@ -163,19 +296,19 @@ declare function createMemberSchema(): mongoose.Schema<any, mongoose.Model<any,
|
|
|
163
296
|
tierQualifiedAt?: NativeDate | null;
|
|
164
297
|
tierExpiresAt?: NativeDate | null;
|
|
165
298
|
balance?: {
|
|
166
|
-
expired: number;
|
|
167
299
|
current: number;
|
|
168
300
|
lifetime: number;
|
|
169
301
|
redeemed: number;
|
|
302
|
+
expired: number;
|
|
170
303
|
} | null;
|
|
304
|
+
enrolledAt: NativeDate;
|
|
171
305
|
deactivatedAt?: NativeDate | null;
|
|
306
|
+
metadata?: any;
|
|
172
307
|
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
|
|
173
308
|
programId: string;
|
|
174
|
-
status: "active" | "inactive" | "suspended";
|
|
175
309
|
externalId: string;
|
|
176
310
|
externalType: string;
|
|
177
|
-
|
|
178
|
-
metadata?: any;
|
|
311
|
+
status: "active" | "inactive" | "suspended";
|
|
179
312
|
cardId?: string | null;
|
|
180
313
|
referralCode?: string | null;
|
|
181
314
|
tier?: string | null;
|
|
@@ -186,23 +319,23 @@ declare function createMemberSchema(): mongoose.Schema<any, mongoose.Model<any,
|
|
|
186
319
|
tierQualifiedAt?: NativeDate | null;
|
|
187
320
|
tierExpiresAt?: NativeDate | null;
|
|
188
321
|
balance?: {
|
|
189
|
-
expired: number;
|
|
190
322
|
current: number;
|
|
191
323
|
lifetime: number;
|
|
192
324
|
redeemed: number;
|
|
325
|
+
expired: number;
|
|
193
326
|
} | null;
|
|
327
|
+
enrolledAt: NativeDate;
|
|
194
328
|
deactivatedAt?: NativeDate | null;
|
|
329
|
+
metadata?: any;
|
|
195
330
|
} & mongoose.DefaultTimestampProps, {
|
|
196
331
|
id: string;
|
|
197
332
|
}, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
|
|
198
333
|
timestamps: true;
|
|
199
334
|
}> & Omit<{
|
|
200
335
|
programId: string;
|
|
201
|
-
status: "active" | "inactive" | "suspended";
|
|
202
336
|
externalId: string;
|
|
203
337
|
externalType: string;
|
|
204
|
-
|
|
205
|
-
metadata?: any;
|
|
338
|
+
status: "active" | "inactive" | "suspended";
|
|
206
339
|
cardId?: string | null;
|
|
207
340
|
referralCode?: string | null;
|
|
208
341
|
tier?: string | null;
|
|
@@ -213,12 +346,14 @@ declare function createMemberSchema(): mongoose.Schema<any, mongoose.Model<any,
|
|
|
213
346
|
tierQualifiedAt?: NativeDate | null;
|
|
214
347
|
tierExpiresAt?: NativeDate | null;
|
|
215
348
|
balance?: {
|
|
216
|
-
expired: number;
|
|
217
349
|
current: number;
|
|
218
350
|
lifetime: number;
|
|
219
351
|
redeemed: number;
|
|
352
|
+
expired: number;
|
|
220
353
|
} | null;
|
|
354
|
+
enrolledAt: NativeDate;
|
|
221
355
|
deactivatedAt?: NativeDate | null;
|
|
356
|
+
metadata?: any;
|
|
222
357
|
} & mongoose.DefaultTimestampProps & {
|
|
223
358
|
_id: mongoose.Types.ObjectId;
|
|
224
359
|
} & {
|
|
@@ -226,12 +361,12 @@ declare function createMemberSchema(): mongoose.Schema<any, mongoose.Model<any,
|
|
|
226
361
|
}, "id"> & mongoose.HydratedDocumentOverrides<{
|
|
227
362
|
id: string;
|
|
228
363
|
}>, unknown, {
|
|
364
|
+
createdAt: NativeDate;
|
|
365
|
+
updatedAt: NativeDate;
|
|
229
366
|
programId: string;
|
|
230
|
-
status: "active" | "inactive" | "suspended";
|
|
231
367
|
externalId: string;
|
|
232
368
|
externalType: string;
|
|
233
|
-
|
|
234
|
-
metadata?: any;
|
|
369
|
+
status: "active" | "inactive" | "suspended";
|
|
235
370
|
cardId?: string | null;
|
|
236
371
|
referralCode?: string | null;
|
|
237
372
|
tier?: string | null;
|
|
@@ -242,14 +377,14 @@ declare function createMemberSchema(): mongoose.Schema<any, mongoose.Model<any,
|
|
|
242
377
|
tierQualifiedAt?: NativeDate | null;
|
|
243
378
|
tierExpiresAt?: NativeDate | null;
|
|
244
379
|
balance?: {
|
|
245
|
-
expired: number;
|
|
246
380
|
current: number;
|
|
247
381
|
lifetime: number;
|
|
248
382
|
redeemed: number;
|
|
383
|
+
expired: number;
|
|
249
384
|
} | null;
|
|
385
|
+
enrolledAt: NativeDate;
|
|
250
386
|
deactivatedAt?: NativeDate | null;
|
|
251
|
-
|
|
252
|
-
updatedAt: NativeDate;
|
|
387
|
+
metadata?: any;
|
|
253
388
|
} & {
|
|
254
389
|
_id: mongoose.Types.ObjectId;
|
|
255
390
|
} & {
|
|
@@ -263,42 +398,46 @@ declare function createPointTransactionSchema(): mongoose.Schema<any, mongoose.M
|
|
|
263
398
|
updatedAt: false;
|
|
264
399
|
};
|
|
265
400
|
}, {
|
|
266
|
-
programId: string;
|
|
267
|
-
type: "earn" | "redeem" | "adjust" | "expire" | "transfer" | "referral_bonus";
|
|
268
|
-
description: string;
|
|
269
401
|
memberId: mongoose.Types.ObjectId;
|
|
402
|
+
programId: string;
|
|
403
|
+
type: "adjust" | "earn" | "expire" | "redeem" | "referral_bonus" | "reverse" | "transfer";
|
|
270
404
|
points: number;
|
|
271
405
|
balanceAfter: number;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
approvals?: any;
|
|
276
|
-
approvalPolicyId?: string | null;
|
|
277
|
-
approvalPolicyVersion?: number | null;
|
|
406
|
+
description: string;
|
|
407
|
+
source?: "action" | "campaign" | "order" | "referral" | null;
|
|
408
|
+
pointValueMinor?: number | null;
|
|
278
409
|
referenceType?: string | null;
|
|
279
410
|
referenceId?: string | null;
|
|
280
411
|
idempotencyKey?: string | null;
|
|
281
412
|
earningRuleId?: mongoose.Types.ObjectId | null;
|
|
413
|
+
expiresAt?: NativeDate | null;
|
|
282
414
|
expiredAt?: NativeDate | null;
|
|
415
|
+
metadata?: any;
|
|
416
|
+
actorId: string;
|
|
417
|
+
approvals?: any;
|
|
418
|
+
approvalPolicyId?: string | null;
|
|
419
|
+
approvalPolicyVersion?: number | null;
|
|
283
420
|
createdAt: NativeDate;
|
|
284
421
|
}, mongoose.Document<unknown, {}, {
|
|
285
|
-
programId: string;
|
|
286
|
-
type: "earn" | "redeem" | "adjust" | "expire" | "transfer" | "referral_bonus";
|
|
287
|
-
description: string;
|
|
288
422
|
memberId: mongoose.Types.ObjectId;
|
|
423
|
+
programId: string;
|
|
424
|
+
type: "adjust" | "earn" | "expire" | "redeem" | "referral_bonus" | "reverse" | "transfer";
|
|
289
425
|
points: number;
|
|
290
426
|
balanceAfter: number;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
approvals?: any;
|
|
295
|
-
approvalPolicyId?: string | null;
|
|
296
|
-
approvalPolicyVersion?: number | null;
|
|
427
|
+
description: string;
|
|
428
|
+
source?: "action" | "campaign" | "order" | "referral" | null;
|
|
429
|
+
pointValueMinor?: number | null;
|
|
297
430
|
referenceType?: string | null;
|
|
298
431
|
referenceId?: string | null;
|
|
299
432
|
idempotencyKey?: string | null;
|
|
300
433
|
earningRuleId?: mongoose.Types.ObjectId | null;
|
|
434
|
+
expiresAt?: NativeDate | null;
|
|
301
435
|
expiredAt?: NativeDate | null;
|
|
436
|
+
metadata?: any;
|
|
437
|
+
actorId: string;
|
|
438
|
+
approvals?: any;
|
|
439
|
+
approvalPolicyId?: string | null;
|
|
440
|
+
approvalPolicyVersion?: number | null;
|
|
302
441
|
createdAt: NativeDate;
|
|
303
442
|
}, {
|
|
304
443
|
id: string;
|
|
@@ -308,23 +447,25 @@ declare function createPointTransactionSchema(): mongoose.Schema<any, mongoose.M
|
|
|
308
447
|
updatedAt: false;
|
|
309
448
|
};
|
|
310
449
|
}> & Omit<{
|
|
311
|
-
programId: string;
|
|
312
|
-
type: "earn" | "redeem" | "adjust" | "expire" | "transfer" | "referral_bonus";
|
|
313
|
-
description: string;
|
|
314
450
|
memberId: mongoose.Types.ObjectId;
|
|
451
|
+
programId: string;
|
|
452
|
+
type: "adjust" | "earn" | "expire" | "redeem" | "referral_bonus" | "reverse" | "transfer";
|
|
315
453
|
points: number;
|
|
316
454
|
balanceAfter: number;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
approvals?: any;
|
|
321
|
-
approvalPolicyId?: string | null;
|
|
322
|
-
approvalPolicyVersion?: number | null;
|
|
455
|
+
description: string;
|
|
456
|
+
source?: "action" | "campaign" | "order" | "referral" | null;
|
|
457
|
+
pointValueMinor?: number | null;
|
|
323
458
|
referenceType?: string | null;
|
|
324
459
|
referenceId?: string | null;
|
|
325
460
|
idempotencyKey?: string | null;
|
|
326
461
|
earningRuleId?: mongoose.Types.ObjectId | null;
|
|
462
|
+
expiresAt?: NativeDate | null;
|
|
327
463
|
expiredAt?: NativeDate | null;
|
|
464
|
+
metadata?: any;
|
|
465
|
+
actorId: string;
|
|
466
|
+
approvals?: any;
|
|
467
|
+
approvalPolicyId?: string | null;
|
|
468
|
+
approvalPolicyVersion?: number | null;
|
|
328
469
|
createdAt: NativeDate;
|
|
329
470
|
} & {
|
|
330
471
|
_id: mongoose.Types.ObjectId;
|
|
@@ -333,23 +474,25 @@ declare function createPointTransactionSchema(): mongoose.Schema<any, mongoose.M
|
|
|
333
474
|
}, "id"> & mongoose.HydratedDocumentOverrides<{
|
|
334
475
|
id: string;
|
|
335
476
|
}>, unknown, {
|
|
336
|
-
programId: string;
|
|
337
|
-
type: "earn" | "redeem" | "adjust" | "expire" | "transfer" | "referral_bonus";
|
|
338
|
-
description: string;
|
|
339
477
|
memberId: mongoose.Types.ObjectId;
|
|
478
|
+
programId: string;
|
|
479
|
+
type: "adjust" | "earn" | "expire" | "redeem" | "referral_bonus" | "reverse" | "transfer";
|
|
340
480
|
points: number;
|
|
341
481
|
balanceAfter: number;
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
approvals?: any;
|
|
346
|
-
approvalPolicyId?: string | null;
|
|
347
|
-
approvalPolicyVersion?: number | null;
|
|
482
|
+
description: string;
|
|
483
|
+
source?: "action" | "campaign" | "order" | "referral" | null;
|
|
484
|
+
pointValueMinor?: number | null;
|
|
348
485
|
referenceType?: string | null;
|
|
349
486
|
referenceId?: string | null;
|
|
350
487
|
idempotencyKey?: string | null;
|
|
351
488
|
earningRuleId?: mongoose.Types.ObjectId | null;
|
|
489
|
+
expiresAt?: NativeDate | null;
|
|
352
490
|
expiredAt?: NativeDate | null;
|
|
491
|
+
metadata?: any;
|
|
492
|
+
actorId: string;
|
|
493
|
+
approvals?: any;
|
|
494
|
+
approvalPolicyId?: string | null;
|
|
495
|
+
approvalPolicyVersion?: number | null;
|
|
353
496
|
createdAt: NativeDate;
|
|
354
497
|
} & {
|
|
355
498
|
_id: mongoose.Types.ObjectId;
|
|
@@ -361,13 +504,13 @@ declare function createPointTransactionSchema(): mongoose.Schema<any, mongoose.M
|
|
|
361
504
|
declare function createRedemptionSchema(): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
362
505
|
timestamps: true;
|
|
363
506
|
}, {
|
|
364
|
-
programId: string;
|
|
365
|
-
status: "expired" | "reserved" | "confirmed" | "released" | "reversed";
|
|
366
507
|
memberId: mongoose.Types.ObjectId;
|
|
508
|
+
programId: string;
|
|
367
509
|
pointsReserved: number;
|
|
368
510
|
pointsConfirmed: number;
|
|
369
511
|
discountAmount: number;
|
|
370
512
|
pointValueMinor: number;
|
|
513
|
+
status: "confirmed" | "expired" | "released" | "reserved" | "reversed";
|
|
371
514
|
ownerType: string;
|
|
372
515
|
ownerId: string;
|
|
373
516
|
expiresAt?: NativeDate | null;
|
|
@@ -383,13 +526,13 @@ declare function createRedemptionSchema(): mongoose.Schema<any, mongoose.Model<a
|
|
|
383
526
|
approvalPolicyId?: string | null;
|
|
384
527
|
approvalPolicyVersion?: number | null;
|
|
385
528
|
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
|
|
386
|
-
programId: string;
|
|
387
|
-
status: "expired" | "reserved" | "confirmed" | "released" | "reversed";
|
|
388
529
|
memberId: mongoose.Types.ObjectId;
|
|
530
|
+
programId: string;
|
|
389
531
|
pointsReserved: number;
|
|
390
532
|
pointsConfirmed: number;
|
|
391
533
|
discountAmount: number;
|
|
392
534
|
pointValueMinor: number;
|
|
535
|
+
status: "confirmed" | "expired" | "released" | "reserved" | "reversed";
|
|
393
536
|
ownerType: string;
|
|
394
537
|
ownerId: string;
|
|
395
538
|
expiresAt?: NativeDate | null;
|
|
@@ -409,13 +552,13 @@ declare function createRedemptionSchema(): mongoose.Schema<any, mongoose.Model<a
|
|
|
409
552
|
}, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
|
|
410
553
|
timestamps: true;
|
|
411
554
|
}> & Omit<{
|
|
412
|
-
programId: string;
|
|
413
|
-
status: "expired" | "reserved" | "confirmed" | "released" | "reversed";
|
|
414
555
|
memberId: mongoose.Types.ObjectId;
|
|
556
|
+
programId: string;
|
|
415
557
|
pointsReserved: number;
|
|
416
558
|
pointsConfirmed: number;
|
|
417
559
|
discountAmount: number;
|
|
418
560
|
pointValueMinor: number;
|
|
561
|
+
status: "confirmed" | "expired" | "released" | "reserved" | "reversed";
|
|
419
562
|
ownerType: string;
|
|
420
563
|
ownerId: string;
|
|
421
564
|
expiresAt?: NativeDate | null;
|
|
@@ -437,13 +580,15 @@ declare function createRedemptionSchema(): mongoose.Schema<any, mongoose.Model<a
|
|
|
437
580
|
}, "id"> & mongoose.HydratedDocumentOverrides<{
|
|
438
581
|
id: string;
|
|
439
582
|
}>, unknown, {
|
|
440
|
-
|
|
441
|
-
|
|
583
|
+
createdAt: NativeDate;
|
|
584
|
+
updatedAt: NativeDate;
|
|
442
585
|
memberId: mongoose.Types.ObjectId;
|
|
586
|
+
programId: string;
|
|
443
587
|
pointsReserved: number;
|
|
444
588
|
pointsConfirmed: number;
|
|
445
589
|
discountAmount: number;
|
|
446
590
|
pointValueMinor: number;
|
|
591
|
+
status: "confirmed" | "expired" | "released" | "reserved" | "reversed";
|
|
447
592
|
ownerType: string;
|
|
448
593
|
ownerId: string;
|
|
449
594
|
expiresAt?: NativeDate | null;
|
|
@@ -458,8 +603,6 @@ declare function createRedemptionSchema(): mongoose.Schema<any, mongoose.Model<a
|
|
|
458
603
|
approvals?: any;
|
|
459
604
|
approvalPolicyId?: string | null;
|
|
460
605
|
approvalPolicyVersion?: number | null;
|
|
461
|
-
createdAt: NativeDate;
|
|
462
|
-
updatedAt: NativeDate;
|
|
463
606
|
} & {
|
|
464
607
|
_id: mongoose.Types.ObjectId;
|
|
465
608
|
} & {
|
|
@@ -471,12 +614,10 @@ declare function createReferralSchema(): mongoose.Schema<any, mongoose.Model<any
|
|
|
471
614
|
timestamps: true;
|
|
472
615
|
}, {
|
|
473
616
|
programId: string;
|
|
474
|
-
status: "expired" | "pending" | "approved" | "rejected";
|
|
475
|
-
referralCode: string;
|
|
476
617
|
referrerId: mongoose.Types.ObjectId;
|
|
477
618
|
refereeId: mongoose.Types.ObjectId;
|
|
478
|
-
|
|
479
|
-
|
|
619
|
+
referralCode: string;
|
|
620
|
+
status: "approved" | "expired" | "pending" | "rejected";
|
|
480
621
|
referrerRewardPoints?: number | null;
|
|
481
622
|
refereeRewardPoints?: number | null;
|
|
482
623
|
referrerTransactionId?: mongoose.Types.ObjectId | null;
|
|
@@ -484,14 +625,14 @@ declare function createReferralSchema(): mongoose.Schema<any, mongoose.Model<any
|
|
|
484
625
|
approvedAt?: NativeDate | null;
|
|
485
626
|
rejectedAt?: NativeDate | null;
|
|
486
627
|
rejectionReason?: string | null;
|
|
628
|
+
expiresAt?: NativeDate | null;
|
|
629
|
+
metadata?: any;
|
|
487
630
|
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
|
|
488
631
|
programId: string;
|
|
489
|
-
status: "expired" | "pending" | "approved" | "rejected";
|
|
490
|
-
referralCode: string;
|
|
491
632
|
referrerId: mongoose.Types.ObjectId;
|
|
492
633
|
refereeId: mongoose.Types.ObjectId;
|
|
493
|
-
|
|
494
|
-
|
|
634
|
+
referralCode: string;
|
|
635
|
+
status: "approved" | "expired" | "pending" | "rejected";
|
|
495
636
|
referrerRewardPoints?: number | null;
|
|
496
637
|
refereeRewardPoints?: number | null;
|
|
497
638
|
referrerTransactionId?: mongoose.Types.ObjectId | null;
|
|
@@ -499,18 +640,18 @@ declare function createReferralSchema(): mongoose.Schema<any, mongoose.Model<any
|
|
|
499
640
|
approvedAt?: NativeDate | null;
|
|
500
641
|
rejectedAt?: NativeDate | null;
|
|
501
642
|
rejectionReason?: string | null;
|
|
643
|
+
expiresAt?: NativeDate | null;
|
|
644
|
+
metadata?: any;
|
|
502
645
|
} & mongoose.DefaultTimestampProps, {
|
|
503
646
|
id: string;
|
|
504
647
|
}, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
|
|
505
648
|
timestamps: true;
|
|
506
649
|
}> & Omit<{
|
|
507
650
|
programId: string;
|
|
508
|
-
status: "expired" | "pending" | "approved" | "rejected";
|
|
509
|
-
referralCode: string;
|
|
510
651
|
referrerId: mongoose.Types.ObjectId;
|
|
511
652
|
refereeId: mongoose.Types.ObjectId;
|
|
512
|
-
|
|
513
|
-
|
|
653
|
+
referralCode: string;
|
|
654
|
+
status: "approved" | "expired" | "pending" | "rejected";
|
|
514
655
|
referrerRewardPoints?: number | null;
|
|
515
656
|
refereeRewardPoints?: number | null;
|
|
516
657
|
referrerTransactionId?: mongoose.Types.ObjectId | null;
|
|
@@ -518,6 +659,8 @@ declare function createReferralSchema(): mongoose.Schema<any, mongoose.Model<any
|
|
|
518
659
|
approvedAt?: NativeDate | null;
|
|
519
660
|
rejectedAt?: NativeDate | null;
|
|
520
661
|
rejectionReason?: string | null;
|
|
662
|
+
expiresAt?: NativeDate | null;
|
|
663
|
+
metadata?: any;
|
|
521
664
|
} & mongoose.DefaultTimestampProps & {
|
|
522
665
|
_id: mongoose.Types.ObjectId;
|
|
523
666
|
} & {
|
|
@@ -525,13 +668,13 @@ declare function createReferralSchema(): mongoose.Schema<any, mongoose.Model<any
|
|
|
525
668
|
}, "id"> & mongoose.HydratedDocumentOverrides<{
|
|
526
669
|
id: string;
|
|
527
670
|
}>, unknown, {
|
|
671
|
+
createdAt: NativeDate;
|
|
672
|
+
updatedAt: NativeDate;
|
|
528
673
|
programId: string;
|
|
529
|
-
status: "expired" | "pending" | "approved" | "rejected";
|
|
530
|
-
referralCode: string;
|
|
531
674
|
referrerId: mongoose.Types.ObjectId;
|
|
532
675
|
refereeId: mongoose.Types.ObjectId;
|
|
533
|
-
|
|
534
|
-
|
|
676
|
+
referralCode: string;
|
|
677
|
+
status: "approved" | "expired" | "pending" | "rejected";
|
|
535
678
|
referrerRewardPoints?: number | null;
|
|
536
679
|
refereeRewardPoints?: number | null;
|
|
537
680
|
referrerTransactionId?: mongoose.Types.ObjectId | null;
|
|
@@ -539,8 +682,8 @@ declare function createReferralSchema(): mongoose.Schema<any, mongoose.Model<any
|
|
|
539
682
|
approvedAt?: NativeDate | null;
|
|
540
683
|
rejectedAt?: NativeDate | null;
|
|
541
684
|
rejectionReason?: string | null;
|
|
542
|
-
|
|
543
|
-
|
|
685
|
+
expiresAt?: NativeDate | null;
|
|
686
|
+
metadata?: any;
|
|
544
687
|
} & {
|
|
545
688
|
_id: mongoose.Types.ObjectId;
|
|
546
689
|
} & {
|
|
@@ -554,7 +697,6 @@ declare function createTierDefinitionSchema(): mongoose.Schema<any, mongoose.Mod
|
|
|
554
697
|
programId: string;
|
|
555
698
|
name: string;
|
|
556
699
|
rank: number;
|
|
557
|
-
metadata?: any;
|
|
558
700
|
qualificationCriteria?: {
|
|
559
701
|
minLifetimePoints?: number | null;
|
|
560
702
|
minLifetimeSpend?: number | null;
|
|
@@ -571,11 +713,11 @@ declare function createTierDefinitionSchema(): mongoose.Schema<any, mongoose.Mod
|
|
|
571
713
|
gracePeriodDays: number;
|
|
572
714
|
} | null;
|
|
573
715
|
color?: string | null;
|
|
716
|
+
metadata?: any;
|
|
574
717
|
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
|
|
575
718
|
programId: string;
|
|
576
719
|
name: string;
|
|
577
720
|
rank: number;
|
|
578
|
-
metadata?: any;
|
|
579
721
|
qualificationCriteria?: {
|
|
580
722
|
minLifetimePoints?: number | null;
|
|
581
723
|
minLifetimeSpend?: number | null;
|
|
@@ -592,6 +734,7 @@ declare function createTierDefinitionSchema(): mongoose.Schema<any, mongoose.Mod
|
|
|
592
734
|
gracePeriodDays: number;
|
|
593
735
|
} | null;
|
|
594
736
|
color?: string | null;
|
|
737
|
+
metadata?: any;
|
|
595
738
|
} & mongoose.DefaultTimestampProps, {
|
|
596
739
|
id: string;
|
|
597
740
|
}, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
|
|
@@ -600,7 +743,6 @@ declare function createTierDefinitionSchema(): mongoose.Schema<any, mongoose.Mod
|
|
|
600
743
|
programId: string;
|
|
601
744
|
name: string;
|
|
602
745
|
rank: number;
|
|
603
|
-
metadata?: any;
|
|
604
746
|
qualificationCriteria?: {
|
|
605
747
|
minLifetimePoints?: number | null;
|
|
606
748
|
minLifetimeSpend?: number | null;
|
|
@@ -617,6 +759,7 @@ declare function createTierDefinitionSchema(): mongoose.Schema<any, mongoose.Mod
|
|
|
617
759
|
gracePeriodDays: number;
|
|
618
760
|
} | null;
|
|
619
761
|
color?: string | null;
|
|
762
|
+
metadata?: any;
|
|
620
763
|
} & mongoose.DefaultTimestampProps & {
|
|
621
764
|
_id: mongoose.Types.ObjectId;
|
|
622
765
|
} & {
|
|
@@ -624,10 +767,11 @@ declare function createTierDefinitionSchema(): mongoose.Schema<any, mongoose.Mod
|
|
|
624
767
|
}, "id"> & mongoose.HydratedDocumentOverrides<{
|
|
625
768
|
id: string;
|
|
626
769
|
}>, unknown, {
|
|
770
|
+
createdAt: NativeDate;
|
|
771
|
+
updatedAt: NativeDate;
|
|
627
772
|
programId: string;
|
|
628
773
|
name: string;
|
|
629
774
|
rank: number;
|
|
630
|
-
metadata?: any;
|
|
631
775
|
qualificationCriteria?: {
|
|
632
776
|
minLifetimePoints?: number | null;
|
|
633
777
|
minLifetimeSpend?: number | null;
|
|
@@ -644,8 +788,7 @@ declare function createTierDefinitionSchema(): mongoose.Schema<any, mongoose.Mod
|
|
|
644
788
|
gracePeriodDays: number;
|
|
645
789
|
} | null;
|
|
646
790
|
color?: string | null;
|
|
647
|
-
|
|
648
|
-
updatedAt: NativeDate;
|
|
791
|
+
metadata?: any;
|
|
649
792
|
} & {
|
|
650
793
|
_id: mongoose.Types.ObjectId;
|
|
651
794
|
} & {
|
|
@@ -661,6 +804,9 @@ interface LoyaltyModels {
|
|
|
661
804
|
TierDefinition: Model<InferSchemaType<ReturnType<typeof createTierDefinitionSchema>>>;
|
|
662
805
|
Redemption: Model<InferSchemaType<ReturnType<typeof createRedemptionSchema>>>;
|
|
663
806
|
Referral: Model<InferSchemaType<ReturnType<typeof createReferralSchema>>>;
|
|
807
|
+
StampProgram: Model<StampProgram>;
|
|
808
|
+
StampEntry: Model<StampEntry>;
|
|
809
|
+
StampAward: Model<StampAward>;
|
|
664
810
|
}
|
|
665
811
|
interface DefineLoyaltyModelsConfig {
|
|
666
812
|
/** Resolved tenant descriptor — injected into every schema (see `injectTenantField`). */
|
|
@@ -689,4 +835,4 @@ interface DefineLoyaltyModelsConfig {
|
|
|
689
835
|
*/
|
|
690
836
|
declare function defineLoyaltyModels(config: DefineLoyaltyModelsConfig): ModelBlueprint<LoyaltyModels>;
|
|
691
837
|
//#endregion
|
|
692
|
-
export { LoyaltyModels as n, defineLoyaltyModels as r, DefineLoyaltyModelsConfig as t };
|
|
838
|
+
export { StampAwardReward as a, StampOrderInput as c, StampProgress as d, StampRecordResult as f, StampAward as i, StampOrderLine as l, StampReward as m, LoyaltyModels as n, StampEarn as o, StampReversal as p, defineLoyaltyModels as r, StampEntry as s, DefineLoyaltyModelsConfig as t, StampProgram as u };
|