@classytic/loyalty 0.7.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 +134 -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-BIPHUsfR.d.mts → index-BvyzKU7R.d.mts} +283 -34
- package/dist/{index-BIhVuwIZ.d.mts → index-CorB0JL6.d.mts} +255 -109
- 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 +59 -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-DErtHQou.mjs → repositories-ER68JmUo.mjs} +1161 -99
- 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,104 +1,239 @@
|
|
|
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
|
-
metadata?: any;
|
|
15
146
|
description?: string | null;
|
|
147
|
+
type: "action" | "category" | "order" | "tier_bonus";
|
|
148
|
+
status: "active" | "expired" | "paused";
|
|
149
|
+
priority: number;
|
|
16
150
|
conditions?: {
|
|
151
|
+
minOrderAmount?: number | null;
|
|
17
152
|
categories: string[];
|
|
18
153
|
tiers: string[];
|
|
19
154
|
actions: string[];
|
|
20
155
|
dayOfWeek: number[];
|
|
21
|
-
minOrderAmount?: number | null;
|
|
22
156
|
dateRange?: {
|
|
23
157
|
start?: NativeDate | null;
|
|
24
158
|
end?: NativeDate | null;
|
|
25
159
|
} | null;
|
|
26
160
|
} | null;
|
|
27
161
|
reward?: {
|
|
28
|
-
roundingMode: "floor" | "round" | "ceil";
|
|
29
162
|
pointsPerAmount?: number | null;
|
|
30
163
|
rateBasis?: number | null;
|
|
31
164
|
amountPerPoint?: number | null;
|
|
32
165
|
fixedPoints?: number | null;
|
|
33
166
|
multiplier?: number | null;
|
|
167
|
+
roundingMode: "ceil" | "floor" | "round";
|
|
34
168
|
maxPointsPerTransaction?: number | null;
|
|
35
169
|
} | null;
|
|
36
170
|
startsAt?: NativeDate | null;
|
|
37
171
|
endsAt?: NativeDate | null;
|
|
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
|
-
metadata?: any;
|
|
45
176
|
description?: string | null;
|
|
177
|
+
type: "action" | "category" | "order" | "tier_bonus";
|
|
178
|
+
status: "active" | "expired" | "paused";
|
|
179
|
+
priority: number;
|
|
46
180
|
conditions?: {
|
|
181
|
+
minOrderAmount?: number | null;
|
|
47
182
|
categories: string[];
|
|
48
183
|
tiers: string[];
|
|
49
184
|
actions: string[];
|
|
50
185
|
dayOfWeek: number[];
|
|
51
|
-
minOrderAmount?: number | null;
|
|
52
186
|
dateRange?: {
|
|
53
187
|
start?: NativeDate | null;
|
|
54
188
|
end?: NativeDate | null;
|
|
55
189
|
} | null;
|
|
56
190
|
} | null;
|
|
57
191
|
reward?: {
|
|
58
|
-
roundingMode: "floor" | "round" | "ceil";
|
|
59
192
|
pointsPerAmount?: number | null;
|
|
60
193
|
rateBasis?: number | null;
|
|
61
194
|
amountPerPoint?: number | null;
|
|
62
195
|
fixedPoints?: number | null;
|
|
63
196
|
multiplier?: number | null;
|
|
197
|
+
roundingMode: "ceil" | "floor" | "round";
|
|
64
198
|
maxPointsPerTransaction?: number | null;
|
|
65
199
|
} | null;
|
|
66
200
|
startsAt?: NativeDate | null;
|
|
67
201
|
endsAt?: NativeDate | null;
|
|
202
|
+
metadata?: any;
|
|
68
203
|
} & mongoose.DefaultTimestampProps, {
|
|
69
204
|
id: string;
|
|
70
205
|
}, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
|
|
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
|
-
metadata?: any;
|
|
79
210
|
description?: string | null;
|
|
211
|
+
type: "action" | "category" | "order" | "tier_bonus";
|
|
212
|
+
status: "active" | "expired" | "paused";
|
|
213
|
+
priority: number;
|
|
80
214
|
conditions?: {
|
|
215
|
+
minOrderAmount?: number | null;
|
|
81
216
|
categories: string[];
|
|
82
217
|
tiers: string[];
|
|
83
218
|
actions: string[];
|
|
84
219
|
dayOfWeek: number[];
|
|
85
|
-
minOrderAmount?: number | null;
|
|
86
220
|
dateRange?: {
|
|
87
221
|
start?: NativeDate | null;
|
|
88
222
|
end?: NativeDate | null;
|
|
89
223
|
} | null;
|
|
90
224
|
} | null;
|
|
91
225
|
reward?: {
|
|
92
|
-
roundingMode: "floor" | "round" | "ceil";
|
|
93
226
|
pointsPerAmount?: number | null;
|
|
94
227
|
rateBasis?: number | null;
|
|
95
228
|
amountPerPoint?: number | null;
|
|
96
229
|
fixedPoints?: number | null;
|
|
97
230
|
multiplier?: number | null;
|
|
231
|
+
roundingMode: "ceil" | "floor" | "round";
|
|
98
232
|
maxPointsPerTransaction?: number | null;
|
|
99
233
|
} | null;
|
|
100
234
|
startsAt?: NativeDate | null;
|
|
101
235
|
endsAt?: NativeDate | null;
|
|
236
|
+
metadata?: any;
|
|
102
237
|
} & mongoose.DefaultTimestampProps & {
|
|
103
238
|
_id: mongoose.Types.ObjectId;
|
|
104
239
|
} & {
|
|
@@ -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
|
-
metadata?: any;
|
|
115
248
|
description?: string | null;
|
|
249
|
+
type: "action" | "category" | "order" | "tier_bonus";
|
|
250
|
+
status: "active" | "expired" | "paused";
|
|
251
|
+
priority: number;
|
|
116
252
|
conditions?: {
|
|
253
|
+
minOrderAmount?: number | null;
|
|
117
254
|
categories: string[];
|
|
118
255
|
tiers: string[];
|
|
119
256
|
actions: string[];
|
|
120
257
|
dayOfWeek: number[];
|
|
121
|
-
minOrderAmount?: number | null;
|
|
122
258
|
dateRange?: {
|
|
123
259
|
start?: NativeDate | null;
|
|
124
260
|
end?: NativeDate | null;
|
|
125
261
|
} | null;
|
|
126
262
|
} | null;
|
|
127
263
|
reward?: {
|
|
128
|
-
roundingMode: "floor" | "round" | "ceil";
|
|
129
264
|
pointsPerAmount?: number | null;
|
|
130
265
|
rateBasis?: number | null;
|
|
131
266
|
amountPerPoint?: number | null;
|
|
132
267
|
fixedPoints?: number | null;
|
|
133
268
|
multiplier?: number | null;
|
|
269
|
+
roundingMode: "ceil" | "floor" | "round";
|
|
134
270
|
maxPointsPerTransaction?: number | null;
|
|
135
271
|
} | null;
|
|
136
272
|
startsAt?: NativeDate | null;
|
|
137
273
|
endsAt?: NativeDate | null;
|
|
138
|
-
|
|
139
|
-
updatedAt: NativeDate;
|
|
274
|
+
metadata?: any;
|
|
140
275
|
} & {
|
|
141
276
|
_id: mongoose.Types.ObjectId;
|
|
142
277
|
} & {
|
|
@@ -148,13 +283,11 @@ 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;
|
|
156
|
-
referralCode?: string | null;
|
|
288
|
+
status: "active" | "inactive" | "suspended";
|
|
157
289
|
cardId?: string | null;
|
|
290
|
+
referralCode?: string | null;
|
|
158
291
|
tier?: string | null;
|
|
159
292
|
tierOverride?: string | null;
|
|
160
293
|
tierOverrideReason?: string | null;
|
|
@@ -163,21 +296,21 @@ 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;
|
|
179
|
-
referralCode?: string | null;
|
|
311
|
+
status: "active" | "inactive" | "suspended";
|
|
180
312
|
cardId?: string | null;
|
|
313
|
+
referralCode?: string | null;
|
|
181
314
|
tier?: string | null;
|
|
182
315
|
tierOverride?: string | null;
|
|
183
316
|
tierOverrideReason?: string | null;
|
|
@@ -186,25 +319,25 @@ 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;
|
|
206
|
-
referralCode?: string | null;
|
|
338
|
+
status: "active" | "inactive" | "suspended";
|
|
207
339
|
cardId?: string | null;
|
|
340
|
+
referralCode?: string | null;
|
|
208
341
|
tier?: string | null;
|
|
209
342
|
tierOverride?: string | null;
|
|
210
343
|
tierOverrideReason?: 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,14 +361,14 @@ 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;
|
|
235
|
-
referralCode?: string | null;
|
|
369
|
+
status: "active" | "inactive" | "suspended";
|
|
236
370
|
cardId?: string | null;
|
|
371
|
+
referralCode?: string | null;
|
|
237
372
|
tier?: string | null;
|
|
238
373
|
tierOverride?: string | null;
|
|
239
374
|
tierOverrideReason?: 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,39 +398,43 @@ 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
|
-
|
|
406
|
+
description: string;
|
|
407
|
+
source?: "action" | "campaign" | "order" | "referral" | null;
|
|
408
|
+
pointValueMinor?: number | null;
|
|
274
409
|
referenceType?: string | null;
|
|
275
410
|
referenceId?: string | null;
|
|
276
411
|
idempotencyKey?: string | null;
|
|
277
412
|
earningRuleId?: mongoose.Types.ObjectId | null;
|
|
278
413
|
expiresAt?: NativeDate | null;
|
|
279
414
|
expiredAt?: NativeDate | null;
|
|
415
|
+
metadata?: any;
|
|
416
|
+
actorId: string;
|
|
280
417
|
approvals?: any;
|
|
281
418
|
approvalPolicyId?: string | null;
|
|
282
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
|
-
|
|
427
|
+
description: string;
|
|
428
|
+
source?: "action" | "campaign" | "order" | "referral" | null;
|
|
429
|
+
pointValueMinor?: number | null;
|
|
293
430
|
referenceType?: string | null;
|
|
294
431
|
referenceId?: string | null;
|
|
295
432
|
idempotencyKey?: string | null;
|
|
296
433
|
earningRuleId?: mongoose.Types.ObjectId | null;
|
|
297
434
|
expiresAt?: NativeDate | null;
|
|
298
435
|
expiredAt?: NativeDate | null;
|
|
436
|
+
metadata?: any;
|
|
437
|
+
actorId: string;
|
|
299
438
|
approvals?: any;
|
|
300
439
|
approvalPolicyId?: string | null;
|
|
301
440
|
approvalPolicyVersion?: number | null;
|
|
@@ -308,20 +447,22 @@ 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
|
-
|
|
455
|
+
description: string;
|
|
456
|
+
source?: "action" | "campaign" | "order" | "referral" | null;
|
|
457
|
+
pointValueMinor?: number | null;
|
|
319
458
|
referenceType?: string | null;
|
|
320
459
|
referenceId?: string | null;
|
|
321
460
|
idempotencyKey?: string | null;
|
|
322
461
|
earningRuleId?: mongoose.Types.ObjectId | null;
|
|
323
462
|
expiresAt?: NativeDate | null;
|
|
324
463
|
expiredAt?: NativeDate | null;
|
|
464
|
+
metadata?: any;
|
|
465
|
+
actorId: string;
|
|
325
466
|
approvals?: any;
|
|
326
467
|
approvalPolicyId?: string | null;
|
|
327
468
|
approvalPolicyVersion?: number | null;
|
|
@@ -333,20 +474,22 @@ 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
|
-
|
|
482
|
+
description: string;
|
|
483
|
+
source?: "action" | "campaign" | "order" | "referral" | null;
|
|
484
|
+
pointValueMinor?: number | null;
|
|
344
485
|
referenceType?: string | null;
|
|
345
486
|
referenceId?: string | null;
|
|
346
487
|
idempotencyKey?: string | null;
|
|
347
488
|
earningRuleId?: mongoose.Types.ObjectId | null;
|
|
348
489
|
expiresAt?: NativeDate | null;
|
|
349
490
|
expiredAt?: NativeDate | null;
|
|
491
|
+
metadata?: any;
|
|
492
|
+
actorId: string;
|
|
350
493
|
approvals?: any;
|
|
351
494
|
approvalPolicyId?: string | null;
|
|
352
495
|
approvalPolicyVersion?: number | null;
|
|
@@ -361,19 +504,16 @@ 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;
|
|
374
|
-
approvals?: any;
|
|
375
|
-
approvalPolicyId?: string | null;
|
|
376
|
-
approvalPolicyVersion?: number | null;
|
|
377
517
|
confirmedAt?: NativeDate | null;
|
|
378
518
|
releasedAt?: NativeDate | null;
|
|
379
519
|
reversedAt?: NativeDate | null;
|
|
@@ -382,20 +522,20 @@ declare function createRedemptionSchema(): mongoose.Schema<any, mongoose.Model<a
|
|
|
382
522
|
transactionId?: mongoose.Types.ObjectId | null;
|
|
383
523
|
initialBalance?: number | null;
|
|
384
524
|
remainingBalance?: number | null;
|
|
525
|
+
approvals?: any;
|
|
526
|
+
approvalPolicyId?: string | null;
|
|
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;
|
|
396
|
-
approvals?: any;
|
|
397
|
-
approvalPolicyId?: string | null;
|
|
398
|
-
approvalPolicyVersion?: number | null;
|
|
399
539
|
confirmedAt?: NativeDate | null;
|
|
400
540
|
releasedAt?: NativeDate | null;
|
|
401
541
|
reversedAt?: NativeDate | null;
|
|
@@ -404,24 +544,24 @@ declare function createRedemptionSchema(): mongoose.Schema<any, mongoose.Model<a
|
|
|
404
544
|
transactionId?: mongoose.Types.ObjectId | null;
|
|
405
545
|
initialBalance?: number | null;
|
|
406
546
|
remainingBalance?: number | null;
|
|
547
|
+
approvals?: any;
|
|
548
|
+
approvalPolicyId?: string | null;
|
|
549
|
+
approvalPolicyVersion?: number | null;
|
|
407
550
|
} & mongoose.DefaultTimestampProps, {
|
|
408
551
|
id: string;
|
|
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;
|
|
422
|
-
approvals?: any;
|
|
423
|
-
approvalPolicyId?: string | null;
|
|
424
|
-
approvalPolicyVersion?: number | null;
|
|
425
565
|
confirmedAt?: NativeDate | null;
|
|
426
566
|
releasedAt?: NativeDate | null;
|
|
427
567
|
reversedAt?: NativeDate | null;
|
|
@@ -430,6 +570,9 @@ declare function createRedemptionSchema(): mongoose.Schema<any, mongoose.Model<a
|
|
|
430
570
|
transactionId?: mongoose.Types.ObjectId | null;
|
|
431
571
|
initialBalance?: number | null;
|
|
432
572
|
remainingBalance?: number | null;
|
|
573
|
+
approvals?: any;
|
|
574
|
+
approvalPolicyId?: string | null;
|
|
575
|
+
approvalPolicyVersion?: number | null;
|
|
433
576
|
} & mongoose.DefaultTimestampProps & {
|
|
434
577
|
_id: mongoose.Types.ObjectId;
|
|
435
578
|
} & {
|
|
@@ -437,19 +580,18 @@ 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;
|
|
450
|
-
approvals?: any;
|
|
451
|
-
approvalPolicyId?: string | null;
|
|
452
|
-
approvalPolicyVersion?: number | null;
|
|
453
595
|
confirmedAt?: NativeDate | null;
|
|
454
596
|
releasedAt?: NativeDate | null;
|
|
455
597
|
reversedAt?: NativeDate | null;
|
|
@@ -458,8 +600,9 @@ declare function createRedemptionSchema(): mongoose.Schema<any, mongoose.Model<a
|
|
|
458
600
|
transactionId?: mongoose.Types.ObjectId | null;
|
|
459
601
|
initialBalance?: number | null;
|
|
460
602
|
remainingBalance?: number | null;
|
|
461
|
-
|
|
462
|
-
|
|
603
|
+
approvals?: any;
|
|
604
|
+
approvalPolicyId?: string | null;
|
|
605
|
+
approvalPolicyVersion?: number | null;
|
|
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
617
|
referrerId: mongoose.Types.ObjectId;
|
|
476
618
|
refereeId: mongoose.Types.ObjectId;
|
|
477
619
|
referralCode: string;
|
|
478
|
-
|
|
479
|
-
expiresAt?: NativeDate | null;
|
|
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
632
|
referrerId: mongoose.Types.ObjectId;
|
|
491
633
|
refereeId: mongoose.Types.ObjectId;
|
|
492
634
|
referralCode: string;
|
|
493
|
-
|
|
494
|
-
expiresAt?: NativeDate | null;
|
|
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
651
|
referrerId: mongoose.Types.ObjectId;
|
|
510
652
|
refereeId: mongoose.Types.ObjectId;
|
|
511
653
|
referralCode: string;
|
|
512
|
-
|
|
513
|
-
expiresAt?: NativeDate | null;
|
|
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
674
|
referrerId: mongoose.Types.ObjectId;
|
|
531
675
|
refereeId: mongoose.Types.ObjectId;
|
|
532
676
|
referralCode: string;
|
|
533
|
-
|
|
534
|
-
expiresAt?: NativeDate | null;
|
|
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
|
} & {
|
|
@@ -624,6 +767,8 @@ 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;
|
|
@@ -644,8 +789,6 @@ declare function createTierDefinitionSchema(): mongoose.Schema<any, mongoose.Mod
|
|
|
644
789
|
} | null;
|
|
645
790
|
color?: string | null;
|
|
646
791
|
metadata?: any;
|
|
647
|
-
createdAt: NativeDate;
|
|
648
|
-
updatedAt: NativeDate;
|
|
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 };
|