@classytic/loyalty 0.1.0 → 0.2.1
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 +68 -0
- package/dist/config-DoZPGBfW.d.mts +136 -0
- package/dist/{constants-C75GvizO.mjs → constants-DkQYkOK1.mjs} +3 -2
- package/dist/domain/enums/index.d.mts +1 -1
- package/dist/domain/enums/index.mjs +1 -1
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.mjs +3 -3
- package/dist/events-BtZOdiPw.mjs +311 -0
- package/dist/index-BOWqBSWx.d.mts +281 -0
- package/dist/index-C4jFHS7m.d.mts +400 -0
- package/dist/index-ClPKmtxh.d.mts +361 -0
- package/dist/{index-CaH4GhSF.d.mts → index-DMK8a98J.d.mts} +1 -1
- package/dist/index.d.mts +28 -12
- package/dist/index.mjs +30 -26
- package/dist/loyalty-events-Cyt9TwX6.mjs +50 -0
- package/dist/models/index.d.mts +1225 -2
- package/dist/models/index.mjs +2 -2
- package/dist/{models-CrZPmVxt.mjs → models-uhh9c-7k.mjs} +104 -41
- package/dist/notifications/index.d.mts +1 -1
- package/dist/repositories/index.d.mts +2 -2
- package/dist/repositories/index.mjs +1 -1
- package/dist/repositories-DBSxe9st.mjs +1919 -0
- package/dist/types/index.d.mts +2 -2
- package/package.json +22 -17
- package/dist/config-aNigy4ec.d.mts +0 -90
- package/dist/domain/index.d.mts +0 -90
- package/dist/domain/index.mjs +0 -4
- package/dist/domain-errors-D7q-2LYD.mjs +0 -120
- package/dist/event-emitter.port-CLYPoMni.d.mts +0 -8
- package/dist/event-types-xQBtYBbX.mjs +0 -24
- package/dist/events-CprEWlN7.mjs +0 -25
- package/dist/index-B6ZstxSP.d.mts +0 -2357
- package/dist/index-BcoGeDco.d.mts +0 -127
- package/dist/index-DqzTjeEB.d.mts +0 -148
- package/dist/index-O7TL4R2P.d.mts +0 -86
- package/dist/index-_pg4J11t.d.mts +0 -191
- package/dist/repositories-qMX7Xh_y.mjs +0 -440
- package/dist/services/index.d.mts +0 -2
- package/dist/services/index.mjs +0 -2
- package/dist/services-CoTqC4E6.mjs +0 -1098
- package/dist/tier-definition-Djf72UPa.d.mts +0 -120
- package/dist/tier-definition.port-BzrHYBRo.d.mts +0 -143
- /package/dist/{notification.port-BzUsH0It.d.mts → notification.port-CJ9nXj0k.d.mts} +0 -0
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { a as RuleStatus, n as MemberStatus, o as RuleType, s as TransactionType } from "./index-CaH4GhSF.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/domain/entities/earning-rule.d.ts
|
|
4
|
-
interface EarningConditions {
|
|
5
|
-
minOrderAmount?: number;
|
|
6
|
-
categories?: string[];
|
|
7
|
-
tiers?: string[];
|
|
8
|
-
actions?: string[];
|
|
9
|
-
dayOfWeek?: number[];
|
|
10
|
-
dateRange?: {
|
|
11
|
-
start?: Date;
|
|
12
|
-
end?: Date;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
interface EarningReward {
|
|
16
|
-
pointsPerAmount?: number;
|
|
17
|
-
amountPerPoint?: number;
|
|
18
|
-
fixedPoints?: number;
|
|
19
|
-
multiplier?: number;
|
|
20
|
-
roundingMode?: 'floor' | 'round' | 'ceil';
|
|
21
|
-
maxPointsPerTransaction?: number;
|
|
22
|
-
}
|
|
23
|
-
interface EarningRule {
|
|
24
|
-
_id: string;
|
|
25
|
-
programId: string;
|
|
26
|
-
name: string;
|
|
27
|
-
description?: string;
|
|
28
|
-
type: RuleType;
|
|
29
|
-
status: RuleStatus;
|
|
30
|
-
priority: number;
|
|
31
|
-
conditions: EarningConditions;
|
|
32
|
-
reward: EarningReward;
|
|
33
|
-
startsAt?: Date;
|
|
34
|
-
endsAt?: Date;
|
|
35
|
-
metadata?: Record<string, unknown>;
|
|
36
|
-
createdAt: Date;
|
|
37
|
-
updatedAt: Date;
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/domain/entities/member.d.ts
|
|
41
|
-
interface MemberBalance {
|
|
42
|
-
current: number;
|
|
43
|
-
lifetime: number;
|
|
44
|
-
redeemed: number;
|
|
45
|
-
expired: number;
|
|
46
|
-
}
|
|
47
|
-
interface Member {
|
|
48
|
-
_id: string;
|
|
49
|
-
programId: string;
|
|
50
|
-
externalId: string;
|
|
51
|
-
externalType: string;
|
|
52
|
-
status: MemberStatus;
|
|
53
|
-
/** Public loyalty card identifier (e.g., MBR-DHK-00004821-8). Set by the integration layer. */
|
|
54
|
-
cardId?: string;
|
|
55
|
-
/** Referral code for the referral system (separate from cardId). Auto-generated on enrollment. */
|
|
56
|
-
referralCode: string;
|
|
57
|
-
tier: string | null;
|
|
58
|
-
tierOverride: string | null;
|
|
59
|
-
tierOverrideReason?: string;
|
|
60
|
-
tierQualifiedAt?: Date;
|
|
61
|
-
tierExpiresAt?: Date;
|
|
62
|
-
balance: MemberBalance;
|
|
63
|
-
enrolledAt: Date;
|
|
64
|
-
deactivatedAt?: Date;
|
|
65
|
-
metadata?: Record<string, unknown>;
|
|
66
|
-
createdAt: Date;
|
|
67
|
-
updatedAt: Date;
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/domain/entities/point-transaction.d.ts
|
|
71
|
-
interface PointTransaction {
|
|
72
|
-
_id: string;
|
|
73
|
-
memberId: string;
|
|
74
|
-
programId: string;
|
|
75
|
-
type: TransactionType;
|
|
76
|
-
points: number;
|
|
77
|
-
balanceAfter: number;
|
|
78
|
-
description: string;
|
|
79
|
-
referenceType?: string;
|
|
80
|
-
referenceId?: string;
|
|
81
|
-
idempotencyKey?: string;
|
|
82
|
-
earningRuleId?: string;
|
|
83
|
-
expiresAt?: Date;
|
|
84
|
-
expiredAt?: Date;
|
|
85
|
-
metadata?: Record<string, unknown>;
|
|
86
|
-
actorId: string;
|
|
87
|
-
createdAt: Date;
|
|
88
|
-
}
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/domain/entities/tier-definition.d.ts
|
|
91
|
-
interface TierQualification {
|
|
92
|
-
minLifetimePoints?: number;
|
|
93
|
-
minLifetimeSpend?: number;
|
|
94
|
-
evaluationPeriodDays?: number;
|
|
95
|
-
}
|
|
96
|
-
interface TierBenefits {
|
|
97
|
-
pointsMultiplier?: number;
|
|
98
|
-
discountPercent?: number;
|
|
99
|
-
freeShipping?: boolean;
|
|
100
|
-
customBenefits?: Record<string, unknown>;
|
|
101
|
-
}
|
|
102
|
-
interface TierDowngrade {
|
|
103
|
-
enabled: boolean;
|
|
104
|
-
gracePeriodDays: number;
|
|
105
|
-
}
|
|
106
|
-
interface TierDefinition {
|
|
107
|
-
_id: string;
|
|
108
|
-
programId: string;
|
|
109
|
-
name: string;
|
|
110
|
-
rank: number;
|
|
111
|
-
qualificationCriteria: TierQualification;
|
|
112
|
-
benefits: TierBenefits;
|
|
113
|
-
downgrade: TierDowngrade;
|
|
114
|
-
color?: string;
|
|
115
|
-
metadata?: Record<string, unknown>;
|
|
116
|
-
createdAt: Date;
|
|
117
|
-
updatedAt: Date;
|
|
118
|
-
}
|
|
119
|
-
//#endregion
|
|
120
|
-
export { PointTransaction as a, EarningConditions as c, TierQualification as i, EarningReward as l, TierDefinition as n, Member as o, TierDowngrade as r, MemberBalance as s, TierBenefits as t, EarningRule as u };
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { i as ReferralStatus, r as RedemptionStatus } from "./index-CaH4GhSF.mjs";
|
|
2
|
-
import { a as PointTransaction, n as TierDefinition, o as Member, u as EarningRule } from "./tier-definition-Djf72UPa.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/domain/entities/redemption.d.ts
|
|
5
|
-
interface Redemption {
|
|
6
|
-
_id: string;
|
|
7
|
-
memberId: string;
|
|
8
|
-
programId: string;
|
|
9
|
-
pointsReserved: number;
|
|
10
|
-
pointsConfirmed: number;
|
|
11
|
-
discountAmount: number;
|
|
12
|
-
conversionRate: number;
|
|
13
|
-
status: RedemptionStatus;
|
|
14
|
-
ownerType: string;
|
|
15
|
-
ownerId: string;
|
|
16
|
-
expiresAt?: Date;
|
|
17
|
-
confirmedAt?: Date;
|
|
18
|
-
releasedAt?: Date;
|
|
19
|
-
transactionId?: string;
|
|
20
|
-
createdAt: Date;
|
|
21
|
-
updatedAt: Date;
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/domain/entities/referral.d.ts
|
|
25
|
-
interface Referral {
|
|
26
|
-
_id: string;
|
|
27
|
-
programId: string;
|
|
28
|
-
referrerId: string;
|
|
29
|
-
refereeId: string;
|
|
30
|
-
referralCode: string;
|
|
31
|
-
status: ReferralStatus;
|
|
32
|
-
referrerRewardPoints?: number;
|
|
33
|
-
refereeRewardPoints?: number;
|
|
34
|
-
referrerTransactionId?: string;
|
|
35
|
-
refereeTransactionId?: string;
|
|
36
|
-
approvedAt?: Date;
|
|
37
|
-
rejectedAt?: Date;
|
|
38
|
-
rejectionReason?: string;
|
|
39
|
-
expiresAt?: Date;
|
|
40
|
-
metadata?: Record<string, unknown>;
|
|
41
|
-
createdAt: Date;
|
|
42
|
-
updatedAt: Date;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/domain/ports/unit-of-work.port.d.ts
|
|
46
|
-
type TransactionSession = unknown;
|
|
47
|
-
interface UnitOfWork {
|
|
48
|
-
withTransaction<T>(callback: (session: TransactionSession) => Promise<T>): Promise<T>;
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/domain/ports/earning-rule.port.d.ts
|
|
52
|
-
interface EarningRulePort {
|
|
53
|
-
create(data: Record<string, unknown>, session?: TransactionSession): Promise<EarningRule>;
|
|
54
|
-
getById(id: string, tenantId?: string): Promise<EarningRule | null>;
|
|
55
|
-
update(id: string, data: Record<string, unknown>, tenantId?: string, session?: TransactionSession): Promise<EarningRule>;
|
|
56
|
-
findActive(tenantId?: string, programId?: string): Promise<EarningRule[]>;
|
|
57
|
-
paginate(query: Record<string, unknown>, options: {
|
|
58
|
-
page?: number;
|
|
59
|
-
limit?: number;
|
|
60
|
-
sort?: Record<string, number>;
|
|
61
|
-
}): Promise<{
|
|
62
|
-
docs: EarningRule[];
|
|
63
|
-
total: number;
|
|
64
|
-
page: number;
|
|
65
|
-
pages: number;
|
|
66
|
-
}>;
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/domain/ports/member.port.d.ts
|
|
70
|
-
interface MemberPort {
|
|
71
|
-
create(data: Record<string, unknown>, session?: TransactionSession): Promise<Member>;
|
|
72
|
-
getById(id: string, tenantId?: string): Promise<Member | null>;
|
|
73
|
-
getByExternalId(externalId: string, externalType: string, tenantId?: string): Promise<Member | null>;
|
|
74
|
-
getByCardId(cardId: string, tenantId?: string): Promise<Member | null>;
|
|
75
|
-
getByReferralCode(code: string, tenantId?: string): Promise<Member | null>;
|
|
76
|
-
update(id: string, data: Record<string, unknown>, tenantId?: string, session?: TransactionSession): Promise<Member>;
|
|
77
|
-
updateBalance(id: string, balanceUpdate: Record<string, number>, tenantId?: string, session?: TransactionSession): Promise<Member>;
|
|
78
|
-
findMany(query: Record<string, unknown>, options?: Record<string, unknown>): Promise<Member[]>;
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/domain/ports/point-transaction.port.d.ts
|
|
82
|
-
interface PointTransactionPort {
|
|
83
|
-
create(data: Record<string, unknown>, session?: TransactionSession): Promise<PointTransaction>;
|
|
84
|
-
getById(id: string, tenantId?: string): Promise<PointTransaction | null>;
|
|
85
|
-
getByIdempotencyKey(key: string, tenantId?: string): Promise<PointTransaction | null>;
|
|
86
|
-
update(id: string, data: Record<string, unknown>, session?: TransactionSession): Promise<PointTransaction>;
|
|
87
|
-
findMany(query: Record<string, unknown>, options?: Record<string, unknown>): Promise<PointTransaction[]>;
|
|
88
|
-
paginate(query: Record<string, unknown>, options: {
|
|
89
|
-
page?: number;
|
|
90
|
-
limit?: number;
|
|
91
|
-
sort?: Record<string, number>;
|
|
92
|
-
}): Promise<{
|
|
93
|
-
docs: PointTransaction[];
|
|
94
|
-
total: number;
|
|
95
|
-
page: number;
|
|
96
|
-
pages: number;
|
|
97
|
-
}>;
|
|
98
|
-
findExpired(now: Date, tenantId?: string, limit?: number): Promise<PointTransaction[]>;
|
|
99
|
-
}
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/domain/ports/redemption.port.d.ts
|
|
102
|
-
interface RedemptionPort {
|
|
103
|
-
create(data: Record<string, unknown>, session?: TransactionSession): Promise<Redemption>;
|
|
104
|
-
getById(id: string, tenantId?: string): Promise<Redemption | null>;
|
|
105
|
-
getByOwner(ownerType: string, ownerId: string, tenantId?: string): Promise<Redemption | null>;
|
|
106
|
-
update(id: string, data: Record<string, unknown>, tenantId?: string, session?: TransactionSession): Promise<Redemption>;
|
|
107
|
-
/** Atomically update only if current status matches. Returns null if status already changed. */
|
|
108
|
-
atomicStatusTransition(id: string, expectedStatus: string, data: Record<string, unknown>, tenantId?: string, session?: TransactionSession): Promise<Redemption | null>;
|
|
109
|
-
findExpired(now: Date, tenantId?: string): Promise<Redemption[]>;
|
|
110
|
-
}
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/domain/ports/referral.port.d.ts
|
|
113
|
-
interface ReferralPort {
|
|
114
|
-
create(data: Record<string, unknown>, session?: TransactionSession): Promise<Referral>;
|
|
115
|
-
getById(id: string, tenantId?: string): Promise<Referral | null>;
|
|
116
|
-
getByReferee(refereeId: string, tenantId?: string): Promise<Referral | null>;
|
|
117
|
-
update(id: string, data: Record<string, unknown>, tenantId?: string, session?: TransactionSession): Promise<Referral>;
|
|
118
|
-
/** Atomically update only if current status matches. Returns null if status already changed. */
|
|
119
|
-
atomicStatusTransition(id: string, expectedStatus: string, data: Record<string, unknown>, tenantId?: string, session?: TransactionSession): Promise<Referral | null>;
|
|
120
|
-
countByReferrerInPeriod(referrerId: string, since: Date, tenantId?: string): Promise<number>;
|
|
121
|
-
findByReferrer(referrerId: string, options: {
|
|
122
|
-
page?: number;
|
|
123
|
-
limit?: number;
|
|
124
|
-
}, tenantId?: string): Promise<{
|
|
125
|
-
docs: Referral[];
|
|
126
|
-
total: number;
|
|
127
|
-
page: number;
|
|
128
|
-
pages: number;
|
|
129
|
-
}>;
|
|
130
|
-
findExpired(now: Date, tenantId?: string): Promise<Referral[]>;
|
|
131
|
-
}
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/domain/ports/tier-definition.port.d.ts
|
|
134
|
-
interface TierDefinitionPort {
|
|
135
|
-
create(data: Record<string, unknown>, session?: TransactionSession): Promise<TierDefinition>;
|
|
136
|
-
getById(id: string, tenantId?: string): Promise<TierDefinition | null>;
|
|
137
|
-
getByName(name: string, tenantId?: string, programId?: string): Promise<TierDefinition | null>;
|
|
138
|
-
update(id: string, data: Record<string, unknown>, tenantId?: string, session?: TransactionSession): Promise<TierDefinition>;
|
|
139
|
-
delete(id: string, tenantId?: string): Promise<void>;
|
|
140
|
-
findAll(tenantId?: string, programId?: string): Promise<TierDefinition[]>;
|
|
141
|
-
}
|
|
142
|
-
//#endregion
|
|
143
|
-
export { MemberPort as a, UnitOfWork as c, PointTransactionPort as i, Referral as l, ReferralPort as n, EarningRulePort as o, RedemptionPort as r, TransactionSession as s, TierDefinitionPort as t, Redemption as u };
|
|
File without changes
|