@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.
@@ -1,9 +1,14 @@
1
- import { a as RuleStatus, n as MemberStatus, o as RuleType, s as TransactionType } from "./index-DMK8a98J.mjs";
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 `LoyaltyConfig.timezone`.
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 `LoyaltyConfig.program.id`, matching
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
  */