@classytic/promo 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 +128 -0
- package/README.md +226 -22
- package/dist/{index-J5BC20DN.d.mts → constants-CrbSSQG5.d.mts} +1 -3
- package/dist/{constants-BVajdyL3.mjs → constants-D0Rntp2f.mjs} +1 -3
- package/dist/index.d.mts +1301 -10
- package/dist/index.mjs +2165 -46
- package/dist/schemas/index.d.mts +253 -0
- package/dist/schemas/index.mjs +134 -0
- package/package.json +23 -37
- package/dist/config-iZjn_8pp.d.mts +0 -71
- package/dist/domain/enums/index.d.mts +0 -2
- package/dist/domain/enums/index.mjs +0 -2
- package/dist/domain/index.d.mts +0 -61
- package/dist/domain/index.mjs +0 -4
- package/dist/domain-errors-BEkXvy5O.mjs +0 -80
- package/dist/event-emitter.port-DaodlJSG.d.mts +0 -8
- package/dist/event-types-CsTV1FKX.mjs +0 -25
- package/dist/events/index.d.mts +0 -2
- package/dist/events/index.mjs +0 -3
- package/dist/events-CprEWlN7.mjs +0 -25
- package/dist/index-B7lLH19a.d.mts +0 -13
- package/dist/index-C52zSBkI.d.mts +0 -96
- package/dist/index-Cu9iwy4v.d.mts +0 -99
- package/dist/index-l09KqnlE.d.mts +0 -81
- package/dist/models/index.d.mts +0 -2
- package/dist/models/index.mjs +0 -2
- package/dist/models-DdBNae7h.mjs +0 -277
- package/dist/repositories/index.d.mts +0 -2
- package/dist/repositories/index.mjs +0 -2
- package/dist/repositories-DgZIY9wD.mjs +0 -295
- package/dist/results-Ca5ZCNbN.d.mts +0 -218
- package/dist/services/index.d.mts +0 -2
- package/dist/services/index.mjs +0 -2
- package/dist/services-Cz0gHrmX.mjs +0 -815
- package/dist/types/index.d.mts +0 -3
- package/dist/types/index.mjs +0 -1
- package/dist/unit-of-work.port-DaMW8WZK.d.mts +0 -7
- package/dist/voucher.port-yxfb3MHJ.d.mts +0 -146
package/dist/types/index.d.mts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { a as RepositoryPlugins, c as TenantConfig, i as PromoConfig, n as ModelName, o as ResolvedConfig, r as PluginType, s as ResolvedTenant, t as IndexDefinition } from "../config-iZjn_8pp.mjs";
|
|
2
|
-
import { C as UpdateRuleInput, S as UpdateRewardInput, _ as GiftCardTopUpInput, a as GiftCardBalance, b as RedeemVoucherInput, c as VoucherValidation, d as CreateRewardInput, f as CreateRuleInput, g as GiftCardSpendInput, h as GenerateSingleCodeInput, i as FreeProductLine, l as CartItem, m as GenerateCodesInput, n as DiscountLine, o as PaginatedResult, p as EvaluateInput, r as EvaluationResult, s as RejectedCode, t as CommitResult, u as CreateProgramInput, v as ListQuery, x as UpdateProgramInput, y as PromoContext } from "../results-Ca5ZCNbN.mjs";
|
|
3
|
-
export { type CartItem, type CommitResult, type CreateProgramInput, type CreateRewardInput, type CreateRuleInput, type DiscountLine, type EvaluateInput, type EvaluationResult, type FreeProductLine, type GenerateCodesInput, type GenerateSingleCodeInput, type GiftCardBalance, type GiftCardSpendInput, type GiftCardTopUpInput, type IndexDefinition, type ListQuery, type ModelName, type PaginatedResult, type PluginType, type PromoConfig, type PromoContext, type RedeemVoucherInput, type RejectedCode, type RepositoryPlugins, type ResolvedConfig, type ResolvedTenant, type TenantConfig, type UpdateProgramInput, type UpdateRewardInput, type UpdateRuleInput, type VoucherValidation };
|
package/dist/types/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
//#region src/domain/ports/unit-of-work.port.d.ts
|
|
2
|
-
type TransactionSession = unknown;
|
|
3
|
-
interface UnitOfWork {
|
|
4
|
-
withTransaction<T>(cb: (session: TransactionSession) => Promise<T>): Promise<T>;
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
export { UnitOfWork as n, TransactionSession as t };
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { a as RewardType, c as VoucherStatus, i as ProgramType, n as DiscountScope, o as StackingMode, r as ProgramStatus, s as TriggerMode, t as DiscountMode } from "./index-J5BC20DN.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/domain/entities/program.d.ts
|
|
4
|
-
interface Program {
|
|
5
|
-
_id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
programType: ProgramType;
|
|
9
|
-
triggerMode: TriggerMode;
|
|
10
|
-
status: ProgramStatus;
|
|
11
|
-
stackingMode: StackingMode;
|
|
12
|
-
priority: number;
|
|
13
|
-
startsAt?: Date;
|
|
14
|
-
endsAt?: Date;
|
|
15
|
-
maxUsageTotal?: number;
|
|
16
|
-
usedCount: number;
|
|
17
|
-
maxUsagePerCustomer?: number;
|
|
18
|
-
applicableCustomerIds: string[];
|
|
19
|
-
applicableCustomerTags: string[];
|
|
20
|
-
customerUsageCounts?: Record<string, number>;
|
|
21
|
-
metadata?: Record<string, unknown>;
|
|
22
|
-
createdAt: Date;
|
|
23
|
-
updatedAt: Date;
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/domain/entities/reward.d.ts
|
|
27
|
-
interface Reward {
|
|
28
|
-
_id: string;
|
|
29
|
-
programId: string;
|
|
30
|
-
ruleId?: string;
|
|
31
|
-
rewardType: RewardType;
|
|
32
|
-
discountMode?: DiscountMode;
|
|
33
|
-
discountAmount?: number;
|
|
34
|
-
maxDiscountAmount?: number;
|
|
35
|
-
discountScope: DiscountScope;
|
|
36
|
-
applicableProductIds: string[];
|
|
37
|
-
freeProductId?: string;
|
|
38
|
-
freeProductSku?: string;
|
|
39
|
-
freeQuantity: number;
|
|
40
|
-
giftCardAmount?: number;
|
|
41
|
-
metadata?: Record<string, unknown>;
|
|
42
|
-
createdAt: Date;
|
|
43
|
-
updatedAt: Date;
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/domain/entities/rule.d.ts
|
|
47
|
-
interface Rule {
|
|
48
|
-
_id: string;
|
|
49
|
-
programId: string;
|
|
50
|
-
name?: string;
|
|
51
|
-
minimumAmount: number;
|
|
52
|
-
minimumQuantity: number;
|
|
53
|
-
applicableProductIds: string[];
|
|
54
|
-
applicableCategories: string[];
|
|
55
|
-
applicableSkus: string[];
|
|
56
|
-
buyQuantity?: number;
|
|
57
|
-
code?: string;
|
|
58
|
-
startsAt?: Date;
|
|
59
|
-
endsAt?: Date;
|
|
60
|
-
metadata?: Record<string, unknown>;
|
|
61
|
-
createdAt: Date;
|
|
62
|
-
updatedAt: Date;
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/domain/entities/voucher.d.ts
|
|
66
|
-
interface BalanceLedgerEntry {
|
|
67
|
-
amount: number;
|
|
68
|
-
orderId?: string;
|
|
69
|
-
description?: string;
|
|
70
|
-
createdAt: Date;
|
|
71
|
-
idempotencyKey?: string;
|
|
72
|
-
}
|
|
73
|
-
interface VoucherRedemption {
|
|
74
|
-
orderId: string;
|
|
75
|
-
customerId?: string;
|
|
76
|
-
discountAmount: number;
|
|
77
|
-
redeemedAt: Date;
|
|
78
|
-
idempotencyKey?: string;
|
|
79
|
-
}
|
|
80
|
-
interface Voucher {
|
|
81
|
-
_id: string;
|
|
82
|
-
programId: string;
|
|
83
|
-
code: string;
|
|
84
|
-
status: VoucherStatus;
|
|
85
|
-
customerId?: string;
|
|
86
|
-
usageLimit: number;
|
|
87
|
-
usedCount: number;
|
|
88
|
-
initialBalance?: number;
|
|
89
|
-
currentBalance?: number;
|
|
90
|
-
balanceLedger: BalanceLedgerEntry[];
|
|
91
|
-
expiresAt?: Date;
|
|
92
|
-
redemptions: VoucherRedemption[];
|
|
93
|
-
metadata?: Record<string, unknown>;
|
|
94
|
-
createdAt: Date;
|
|
95
|
-
updatedAt: Date;
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/domain/ports/program.port.d.ts
|
|
99
|
-
interface ProgramPort {
|
|
100
|
-
create(data: Record<string, unknown>, session?: unknown): Promise<Program>;
|
|
101
|
-
getById(id: string, tenantId?: string): Promise<Program | null>;
|
|
102
|
-
update(id: string, data: Record<string, unknown>, tenantId?: string, session?: unknown): Promise<Program>;
|
|
103
|
-
findMany(query: Record<string, unknown>, options?: Record<string, unknown>): Promise<Program[]>;
|
|
104
|
-
findActive(tenantId?: string, now?: Date): Promise<Program[]>;
|
|
105
|
-
incrementUsage(id: string, tenantId?: string, session?: unknown): Promise<Program>;
|
|
106
|
-
decrementUsage(id: string, tenantId?: string, session?: unknown): Promise<Program>;
|
|
107
|
-
getCustomerUsage(id: string, customerId: string, tenantId?: string): Promise<number>;
|
|
108
|
-
incrementCustomerUsage(id: string, customerId: string, tenantId?: string, session?: unknown): Promise<Program>;
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/domain/ports/reward.port.d.ts
|
|
112
|
-
interface RewardPort {
|
|
113
|
-
create(data: Record<string, unknown>, session?: unknown): Promise<Reward>;
|
|
114
|
-
getById(id: string, tenantId?: string): Promise<Reward | null>;
|
|
115
|
-
update(id: string, data: Record<string, unknown>, tenantId?: string, session?: unknown): Promise<Reward>;
|
|
116
|
-
delete(id: string, tenantId?: string, session?: unknown): Promise<void>;
|
|
117
|
-
findByProgramId(programId: string, tenantId?: string): Promise<Reward[]>;
|
|
118
|
-
findByProgramIds(programIds: string[], tenantId?: string): Promise<Reward[]>;
|
|
119
|
-
}
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/domain/ports/rule.port.d.ts
|
|
122
|
-
interface RulePort {
|
|
123
|
-
create(data: Record<string, unknown>, session?: unknown): Promise<Rule>;
|
|
124
|
-
getById(id: string, tenantId?: string): Promise<Rule | null>;
|
|
125
|
-
update(id: string, data: Record<string, unknown>, tenantId?: string, session?: unknown): Promise<Rule>;
|
|
126
|
-
delete(id: string, tenantId?: string, session?: unknown): Promise<void>;
|
|
127
|
-
findByProgramId(programId: string, tenantId?: string): Promise<Rule[]>;
|
|
128
|
-
findByCode(code: string, tenantId?: string): Promise<Rule | null>;
|
|
129
|
-
findByProgramIds(programIds: string[], tenantId?: string): Promise<Rule[]>;
|
|
130
|
-
}
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/domain/ports/voucher.port.d.ts
|
|
133
|
-
interface VoucherPort {
|
|
134
|
-
create(data: Record<string, unknown>, session?: unknown): Promise<Voucher>;
|
|
135
|
-
createMany(data: Record<string, unknown>[], session?: unknown): Promise<Voucher[]>;
|
|
136
|
-
getById(id: string, tenantId?: string): Promise<Voucher | null>;
|
|
137
|
-
getByCode(code: string, tenantId?: string): Promise<Voucher | null>;
|
|
138
|
-
update(id: string, data: Record<string, unknown>, tenantId?: string, session?: unknown): Promise<Voucher>;
|
|
139
|
-
findMany(query: Record<string, unknown>, options?: Record<string, unknown>): Promise<Voucher[]>;
|
|
140
|
-
incrementUsage(id: string, redemption: Record<string, unknown>, tenantId?: string, session?: unknown): Promise<Voucher>;
|
|
141
|
-
addLedgerEntry(id: string, entry: Record<string, unknown>, balanceDelta: number, tenantId?: string, session?: unknown): Promise<Voucher>;
|
|
142
|
-
expireByDate(before: Date, tenantId?: string): Promise<number>;
|
|
143
|
-
hasIdempotencyKey(id: string, key: string): Promise<boolean>;
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
|
-
export { BalanceLedgerEntry as a, Rule as c, ProgramPort as i, Reward as l, RulePort as n, Voucher as o, RewardPort as r, VoucherRedemption as s, VoucherPort as t, Program as u };
|