@classytic/loyalty 0.4.0 → 0.6.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 +106 -0
- package/LICENSE +75 -21
- package/README.md +2 -2
- package/dist/{config-Dtun1duw.d.mts → config-CtkGj3xZ.d.mts} +41 -22
- package/dist/{constants-DkQYkOK1.mjs → constants-DOPBh6kt.mjs} +1 -3
- 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 +2 -2
- package/dist/{events-DN5_p6T0.mjs → events-BLjg3uLA.mjs} +22 -31
- package/dist/{index-Dngaj21_.d.mts → index-CR2k7jQ8.d.mts} +81 -14
- package/dist/{index-YSsi4e_G.d.mts → index-Cp_sXNpG.d.mts} +35 -4
- package/dist/index-D6GvuvmF.d.mts +692 -0
- package/dist/{index-D_5Ojc2c.d.mts → index-YUFamhDk.d.mts} +7 -17
- package/dist/index.d.mts +60 -29
- package/dist/index.mjs +99 -52
- package/dist/models/index.d.mts +3 -1273
- package/dist/models/index.mjs +2 -2
- package/dist/{models-Ddh62lgO.mjs → models-weWqS5Bc.mjs} +152 -70
- package/dist/notifications/index.d.mts +1 -2
- package/dist/repositories/index.d.mts +1 -1
- package/dist/repositories/index.mjs +1 -1
- package/dist/{repositories-DEwCbLCh.mjs → repositories-B676z4bE.mjs} +183 -67
- package/dist/types/index.d.mts +3 -3
- package/package.json +12 -9
- /package/dist/{index-DMK8a98J.d.mts → index-D_Oe3aDk.d.mts} +0 -0
- /package/dist/{loyalty-events-C38JA3cU.mjs → loyalty-events-DXirolM_.mjs} +0 -0
- /package/dist/{notification.port-CJ9nXj0k.d.mts → notification.port-wY4IKimz.d.mts} +0 -0
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { a as RuleStatus, n as MemberStatus, o as RuleType, s as TransactionType } from "./index-
|
|
1
|
+
import { a as RuleStatus, n as MemberStatus, o as RuleType, s as TransactionType } from "./index-D_Oe3aDk.mjs";
|
|
2
|
+
import "./config-CtkGj3xZ.mjs";
|
|
2
3
|
import { OperationContext } from "@classytic/primitives/context";
|
|
3
4
|
import { ApprovalChain } from "@classytic/primitives/approval";
|
|
4
|
-
|
|
5
5
|
//#region src/domain/entities/earning-rule.d.ts
|
|
6
6
|
interface EarningConditions {
|
|
7
|
+
/**
|
|
8
|
+
* Minimum order total for the rule to apply — **integer minor units** of the
|
|
9
|
+
* host's ambient currency (paisa for BDT). `10000` = ৳100. Compared against
|
|
10
|
+
* `evaluateOrder`'s `orderTotal` (also minor units).
|
|
11
|
+
*/
|
|
7
12
|
minOrderAmount?: number;
|
|
8
13
|
categories?: string[];
|
|
9
14
|
tiers?: string[];
|
|
@@ -12,7 +17,7 @@ interface EarningConditions {
|
|
|
12
17
|
* Days the rule applies, JS `getDay()` convention: 0=Sun … 6=Sat. Empty /
|
|
13
18
|
* omitted = every day. Evaluated against the wall-clock weekday in the
|
|
14
19
|
* engine's configured `timezone` (UTC when unset), never the server's local
|
|
15
|
-
* clock. See `
|
|
20
|
+
* clock. See `LoyaltyShape.timezone`.
|
|
16
21
|
*/
|
|
17
22
|
dayOfWeek?: number[];
|
|
18
23
|
dateRange?: {
|
|
@@ -21,7 +26,24 @@ interface EarningConditions {
|
|
|
21
26
|
};
|
|
22
27
|
}
|
|
23
28
|
interface EarningReward {
|
|
29
|
+
/**
|
|
30
|
+
* Points awarded per `rateBasis` minor units of spend:
|
|
31
|
+
* `points = pointsPerAmount × (orderTotalMinor / rateBasis)` (rounded once
|
|
32
|
+
* per `roundingMode`). REQUIRES `rateBasis` — there is no implicit
|
|
33
|
+
* "per 1 major unit" basis anymore (that ambiguity was the bug).
|
|
34
|
+
* "5 points per ৳100" = `{ pointsPerAmount: 5, rateBasis: 10000 }`.
|
|
35
|
+
*/
|
|
24
36
|
pointsPerAmount?: number;
|
|
37
|
+
/**
|
|
38
|
+
* RATE: the explicit integer minor-unit basis `pointsPerAmount` is quoted
|
|
39
|
+
* against (≥ 1). Required whenever `pointsPerAmount` is set.
|
|
40
|
+
*/
|
|
41
|
+
rateBasis?: number;
|
|
42
|
+
/**
|
|
43
|
+
* RATE: integer minor units of spend per single point (≥ 1).
|
|
44
|
+
* `points = orderTotalMinor / amountPerPoint` (rounded per `roundingMode`).
|
|
45
|
+
* "1 point per ৳100" = `amountPerPoint: 10000`.
|
|
46
|
+
*/
|
|
25
47
|
amountPerPoint?: number;
|
|
26
48
|
fixedPoints?: number;
|
|
27
49
|
multiplier?: number;
|
|
@@ -48,6 +70,11 @@ interface EarningRule {
|
|
|
48
70
|
//#region src/domain/entities/tier-definition.d.ts
|
|
49
71
|
interface TierQualification {
|
|
50
72
|
minLifetimePoints?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Minimum lifetime spend — **integer minor units** (paisa for BDT).
|
|
75
|
+
* Declared for host-side qualification logic only: the in-package tier
|
|
76
|
+
* evaluation checks lifetime POINTS exclusively and never reads this field.
|
|
77
|
+
*/
|
|
51
78
|
minLifetimeSpend?: number;
|
|
52
79
|
evaluationPeriodDays?: number;
|
|
53
80
|
}
|
|
@@ -178,6 +205,10 @@ interface RedemptionValidation {
|
|
|
178
205
|
valid: boolean;
|
|
179
206
|
error?: string;
|
|
180
207
|
pointsToRedeem: number;
|
|
208
|
+
/**
|
|
209
|
+
* Discount in **integer minor units** (paisa for BDT) — always exactly
|
|
210
|
+
* `pointsToRedeem × pointValueMinor`.
|
|
211
|
+
*/
|
|
181
212
|
discountAmount: number;
|
|
182
213
|
maxAllowedPoints: number;
|
|
183
214
|
}
|
|
@@ -278,7 +309,7 @@ interface CreateEarningRuleInput {
|
|
|
278
309
|
* Loyalty program this rule belongs to.
|
|
279
310
|
*
|
|
280
311
|
* Optional for repository-created rules: `EarningRuleRepository.create(...)`
|
|
281
|
-
* and `createMany(...)` fill this from `
|
|
312
|
+
* and `createMany(...)` fill this from `LoyaltyShape.program.id`, matching
|
|
282
313
|
* the default used by `MemberRepository.enroll(...)`. Pass explicitly only
|
|
283
314
|
* when creating a rule for a different program.
|
|
284
315
|
*/
|