@classytic/promo 0.2.5 → 0.4.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.
@@ -0,0 +1,233 @@
1
+ import { DomainEvent } from "@classytic/primitives/events";
2
+ import { z } from "zod";
3
+
4
+ //#region src/events/promo-event-catalog.d.ts
5
+ interface PromoEventSchema {
6
+ type: 'object';
7
+ properties?: Record<string, {
8
+ type?: string;
9
+ format?: string;
10
+ [key: string]: unknown;
11
+ }>;
12
+ required?: string[];
13
+ [key: string]: unknown;
14
+ }
15
+ interface PromoEventDefinition<TSchema extends z.ZodType = z.ZodType> {
16
+ readonly name: string;
17
+ readonly version: number;
18
+ readonly description?: string;
19
+ readonly schema: PromoEventSchema;
20
+ readonly zodSchema: TSchema;
21
+ create(payload: z.infer<TSchema>, meta?: Partial<DomainEvent['meta']>): DomainEvent<z.infer<TSchema>>;
22
+ readonly __payload?: z.infer<TSchema>;
23
+ }
24
+ type PromoEventPayloadOf<D> = D extends PromoEventDefinition<infer S> ? z.infer<S> : never;
25
+ /** Mirrors `ProgramLifecyclePayload`. */
26
+ declare const programLifecycleSchema: z.ZodObject<{
27
+ programId: z.ZodString;
28
+ programType: z.ZodString;
29
+ status: z.ZodString;
30
+ actorRef: z.ZodOptional<z.ZodString>;
31
+ }, z.core.$strip>;
32
+ /** Mirrors `RulePayload`. */
33
+ declare const ruleSchema: z.ZodObject<{
34
+ programId: z.ZodString;
35
+ ruleId: z.ZodString;
36
+ actorRef: z.ZodOptional<z.ZodString>;
37
+ }, z.core.$strip>;
38
+ /** Mirrors `RewardPayload`. */
39
+ declare const rewardSchema: z.ZodObject<{
40
+ programId: z.ZodString;
41
+ rewardId: z.ZodString;
42
+ actorRef: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strip>;
44
+ /** Mirrors `VoucherGeneratedPayload`. */
45
+ declare const voucherGeneratedSchema: z.ZodObject<{
46
+ programId: z.ZodString;
47
+ voucherIds: z.ZodArray<z.ZodString>;
48
+ codes: z.ZodArray<z.ZodString>;
49
+ count: z.ZodNumber;
50
+ actorRef: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$strip>;
52
+ /** Mirrors `VoucherRedeemedPayload`. */
53
+ declare const voucherRedeemedSchema: z.ZodObject<{
54
+ voucherId: z.ZodString;
55
+ code: z.ZodString;
56
+ orderId: z.ZodString;
57
+ discountAmount: z.ZodNumber;
58
+ customerId: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strip>;
60
+ /**
61
+ * Mirrors `VoucherLifecyclePayload` — shared by VOUCHER_CANCELLED,
62
+ * VOUCHER_EXPIRED, and GIFT_CARD_EXHAUSTED (repo emits `status: 'cancelled'`
63
+ * / `'used'` / host-supplied terminal value).
64
+ */
65
+ declare const voucherLifecycleSchema: z.ZodObject<{
66
+ voucherId: z.ZodString;
67
+ code: z.ZodString;
68
+ status: z.ZodString;
69
+ }, z.core.$strip>;
70
+ /** Mirrors `GiftCardSpentPayload`. */
71
+ declare const giftCardSpentSchema: z.ZodObject<{
72
+ voucherId: z.ZodString;
73
+ code: z.ZodString;
74
+ amount: z.ZodNumber;
75
+ remainingBalance: z.ZodNumber;
76
+ orderId: z.ZodString;
77
+ }, z.core.$strip>;
78
+ /** Mirrors `GiftCardToppedUpPayload`. */
79
+ declare const giftCardToppedUpSchema: z.ZodObject<{
80
+ voucherId: z.ZodString;
81
+ code: z.ZodString;
82
+ amount: z.ZodNumber;
83
+ newBalance: z.ZodNumber;
84
+ }, z.core.$strip>;
85
+ /** Mirrors `EvaluationCompletedPayload`. */
86
+ declare const evaluationCompletedSchema: z.ZodObject<{
87
+ evaluationId: z.ZodString;
88
+ totalDiscount: z.ZodNumber;
89
+ programsApplied: z.ZodNumber;
90
+ codesUsed: z.ZodArray<z.ZodString>;
91
+ isPreview: z.ZodBoolean;
92
+ }, z.core.$strip>;
93
+ /** Mirrors `EvaluationCommittedPayload`. */
94
+ declare const evaluationCommittedSchema: z.ZodObject<{
95
+ evaluationId: z.ZodString;
96
+ orderId: z.ZodString;
97
+ totalDiscount: z.ZodNumber;
98
+ }, z.core.$strip>;
99
+ /** Single-field rollback payload — emitted by `evaluation.service.ts`. */
100
+ declare const evaluationRolledBackSchema: z.ZodObject<{
101
+ evaluationId: z.ZodString;
102
+ }, z.core.$strip>;
103
+ type ProgramLifecyclePayloadSchema = z.infer<typeof programLifecycleSchema>;
104
+ type RulePayloadSchema = z.infer<typeof ruleSchema>;
105
+ type RewardPayloadSchema = z.infer<typeof rewardSchema>;
106
+ type VoucherGeneratedPayloadSchema = z.infer<typeof voucherGeneratedSchema>;
107
+ type VoucherRedeemedPayloadSchema = z.infer<typeof voucherRedeemedSchema>;
108
+ type VoucherLifecyclePayloadSchema = z.infer<typeof voucherLifecycleSchema>;
109
+ type GiftCardSpentPayloadSchema = z.infer<typeof giftCardSpentSchema>;
110
+ type GiftCardToppedUpPayloadSchema = z.infer<typeof giftCardToppedUpSchema>;
111
+ type EvaluationCompletedPayloadSchema = z.infer<typeof evaluationCompletedSchema>;
112
+ type EvaluationCommittedPayloadSchema = z.infer<typeof evaluationCommittedSchema>;
113
+ type EvaluationRolledBackPayloadSchema = z.infer<typeof evaluationRolledBackSchema>;
114
+ declare const ProgramCreated: PromoEventDefinition<z.ZodObject<{
115
+ programId: z.ZodString;
116
+ programType: z.ZodString;
117
+ status: z.ZodString;
118
+ actorRef: z.ZodOptional<z.ZodString>;
119
+ }, z.core.$strip>>;
120
+ declare const ProgramActivated: PromoEventDefinition<z.ZodObject<{
121
+ programId: z.ZodString;
122
+ programType: z.ZodString;
123
+ status: z.ZodString;
124
+ actorRef: z.ZodOptional<z.ZodString>;
125
+ }, z.core.$strip>>;
126
+ declare const ProgramPaused: PromoEventDefinition<z.ZodObject<{
127
+ programId: z.ZodString;
128
+ programType: z.ZodString;
129
+ status: z.ZodString;
130
+ actorRef: z.ZodOptional<z.ZodString>;
131
+ }, z.core.$strip>>;
132
+ declare const ProgramArchived: PromoEventDefinition<z.ZodObject<{
133
+ programId: z.ZodString;
134
+ programType: z.ZodString;
135
+ status: z.ZodString;
136
+ actorRef: z.ZodOptional<z.ZodString>;
137
+ }, z.core.$strip>>;
138
+ declare const RuleAdded: PromoEventDefinition<z.ZodObject<{
139
+ programId: z.ZodString;
140
+ ruleId: z.ZodString;
141
+ actorRef: z.ZodOptional<z.ZodString>;
142
+ }, z.core.$strip>>;
143
+ declare const RuleUpdated: PromoEventDefinition<z.ZodObject<{
144
+ programId: z.ZodString;
145
+ ruleId: z.ZodString;
146
+ actorRef: z.ZodOptional<z.ZodString>;
147
+ }, z.core.$strip>>;
148
+ declare const RuleRemoved: PromoEventDefinition<z.ZodObject<{
149
+ programId: z.ZodString;
150
+ ruleId: z.ZodString;
151
+ actorRef: z.ZodOptional<z.ZodString>;
152
+ }, z.core.$strip>>;
153
+ declare const RewardAdded: PromoEventDefinition<z.ZodObject<{
154
+ programId: z.ZodString;
155
+ rewardId: z.ZodString;
156
+ actorRef: z.ZodOptional<z.ZodString>;
157
+ }, z.core.$strip>>;
158
+ declare const RewardUpdated: PromoEventDefinition<z.ZodObject<{
159
+ programId: z.ZodString;
160
+ rewardId: z.ZodString;
161
+ actorRef: z.ZodOptional<z.ZodString>;
162
+ }, z.core.$strip>>;
163
+ declare const RewardRemoved: PromoEventDefinition<z.ZodObject<{
164
+ programId: z.ZodString;
165
+ rewardId: z.ZodString;
166
+ actorRef: z.ZodOptional<z.ZodString>;
167
+ }, z.core.$strip>>;
168
+ declare const VoucherGenerated: PromoEventDefinition<z.ZodObject<{
169
+ programId: z.ZodString;
170
+ voucherIds: z.ZodArray<z.ZodString>;
171
+ codes: z.ZodArray<z.ZodString>;
172
+ count: z.ZodNumber;
173
+ actorRef: z.ZodOptional<z.ZodString>;
174
+ }, z.core.$strip>>;
175
+ declare const VoucherRedeemed: PromoEventDefinition<z.ZodObject<{
176
+ voucherId: z.ZodString;
177
+ code: z.ZodString;
178
+ orderId: z.ZodString;
179
+ discountAmount: z.ZodNumber;
180
+ customerId: z.ZodOptional<z.ZodString>;
181
+ }, z.core.$strip>>;
182
+ declare const VoucherCancelled: PromoEventDefinition<z.ZodObject<{
183
+ voucherId: z.ZodString;
184
+ code: z.ZodString;
185
+ status: z.ZodString;
186
+ }, z.core.$strip>>;
187
+ declare const VoucherExpired: PromoEventDefinition<z.ZodObject<{
188
+ voucherId: z.ZodString;
189
+ code: z.ZodString;
190
+ status: z.ZodString;
191
+ }, z.core.$strip>>;
192
+ declare const GiftCardSpent: PromoEventDefinition<z.ZodObject<{
193
+ voucherId: z.ZodString;
194
+ code: z.ZodString;
195
+ amount: z.ZodNumber;
196
+ remainingBalance: z.ZodNumber;
197
+ orderId: z.ZodString;
198
+ }, z.core.$strip>>;
199
+ declare const GiftCardToppedUp: PromoEventDefinition<z.ZodObject<{
200
+ voucherId: z.ZodString;
201
+ code: z.ZodString;
202
+ amount: z.ZodNumber;
203
+ newBalance: z.ZodNumber;
204
+ }, z.core.$strip>>;
205
+ declare const GiftCardExhausted: PromoEventDefinition<z.ZodObject<{
206
+ voucherId: z.ZodString;
207
+ code: z.ZodString;
208
+ status: z.ZodString;
209
+ }, z.core.$strip>>;
210
+ declare const EvaluationCompleted: PromoEventDefinition<z.ZodObject<{
211
+ evaluationId: z.ZodString;
212
+ totalDiscount: z.ZodNumber;
213
+ programsApplied: z.ZodNumber;
214
+ codesUsed: z.ZodArray<z.ZodString>;
215
+ isPreview: z.ZodBoolean;
216
+ }, z.core.$strip>>;
217
+ declare const EvaluationCommitted: PromoEventDefinition<z.ZodObject<{
218
+ evaluationId: z.ZodString;
219
+ orderId: z.ZodString;
220
+ totalDiscount: z.ZodNumber;
221
+ }, z.core.$strip>>;
222
+ declare const EvaluationRolledBack: PromoEventDefinition<z.ZodObject<{
223
+ evaluationId: z.ZodString;
224
+ }, z.core.$strip>>;
225
+ /**
226
+ * Every promo event defined in the package — pass to Arc's
227
+ * `EventRegistry`. Hosts wire ONE array; the whole `promo.*` namespace
228
+ * becomes introspectable via OpenAPI and auto-validated at publish time
229
+ * when `eventPlugin({ validateMode: 'reject' })` is set.
230
+ */
231
+ declare const promoEventDefinitions: ReadonlyArray<PromoEventDefinition>;
232
+ //#endregion
233
+ export { EvaluationCommitted, EvaluationCommittedPayloadSchema, EvaluationCompleted, EvaluationCompletedPayloadSchema, EvaluationRolledBack, EvaluationRolledBackPayloadSchema, GiftCardExhausted, GiftCardSpent, GiftCardSpentPayloadSchema, GiftCardToppedUp, GiftCardToppedUpPayloadSchema, ProgramActivated, ProgramArchived, ProgramCreated, ProgramLifecyclePayloadSchema, ProgramPaused, PromoEventDefinition, PromoEventPayloadOf, PromoEventSchema, RewardAdded, RewardPayloadSchema, RewardRemoved, RewardUpdated, RuleAdded, RulePayloadSchema, RuleRemoved, RuleUpdated, VoucherCancelled, VoucherExpired, VoucherGenerated, VoucherGeneratedPayloadSchema, VoucherLifecyclePayloadSchema, VoucherRedeemed, VoucherRedeemedPayloadSchema, promoEventDefinitions };
@@ -0,0 +1,2 @@
1
+ import { _ as VoucherCancelled, a as GiftCardSpent, b as VoucherRedeemed, c as ProgramArchived, d as RewardAdded, f as RewardRemoved, g as RuleUpdated, h as RuleRemoved, i as GiftCardExhausted, l as ProgramCreated, m as RuleAdded, n as EvaluationCompleted, o as GiftCardToppedUp, p as RewardUpdated, r as EvaluationRolledBack, s as ProgramActivated, t as EvaluationCommitted, u as ProgramPaused, v as VoucherExpired, x as promoEventDefinitions, y as VoucherGenerated } from "../promo-event-catalog-Dyh0xQ6w.mjs";
2
+ export { EvaluationCommitted, EvaluationCompleted, EvaluationRolledBack, GiftCardExhausted, GiftCardSpent, GiftCardToppedUp, ProgramActivated, ProgramArchived, ProgramCreated, ProgramPaused, RewardAdded, RewardRemoved, RewardUpdated, RuleAdded, RuleRemoved, RuleUpdated, VoucherCancelled, VoucherExpired, VoucherGenerated, VoucherRedeemed, promoEventDefinitions };