@open-loyalty/mcp-server 1.14.0 → 1.16.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/dist/index.js +6 -0
- package/dist/instructions.d.ts +1 -1
- package/dist/instructions.js +1 -1
- package/dist/server.js +1 -1
- package/dist/tools/analytics/handlers.js +2 -2
- package/dist/tools/analytics/index.d.ts +4 -4
- package/dist/tools/analytics/schemas.d.ts +4 -4
- package/dist/tools/analytics/schemas.js +7 -5
- package/dist/tools/apps/dashboard/handlers.d.ts +21 -6
- package/dist/tools/apps/dashboard/handlers.js +70 -13
- package/dist/tools/campaign/handlers.js +24 -5
- package/dist/tools/campaign/index.d.ts +227 -116
- package/dist/tools/campaign/index.js +4 -1
- package/dist/tools/campaign/normalizers.d.ts +5 -0
- package/dist/tools/campaign/normalizers.js +50 -0
- package/dist/tools/campaign/schemas.d.ts +227 -116
- package/dist/tools/campaign/schemas.js +34 -20
- package/dist/tools/campaign/types.d.ts +9 -7
- package/dist/types/schemas/analytics.d.ts +38 -6
- package/dist/types/schemas/analytics.js +6 -2
- package/dist/types/schemas/campaign.d.ts +120 -120
- package/dist/types/schemas/campaign.js +3 -3
- package/dist/ui/campaign-builder.html +45 -28
- package/dist/ui/dashboard.html +124 -133
- package/dist/ui/member-profile.html +50 -33
- package/dist/ui/rewards-catalog.html +36 -19
- package/dist/ui/tier-visualizer.html +38 -21
- package/dist/ui/transaction-timeline.html +44 -27
- package/dist/utils/errors.js +4 -3
- package/package.json +3 -3
|
@@ -79,7 +79,7 @@ export declare const campaignToolDefinitions: readonly [{
|
|
|
79
79
|
target: import("zod").ZodOptional<import("zod").ZodEnum<["self", "referrer"]>>;
|
|
80
80
|
effects: import("zod").ZodArray<import("zod").ZodObject<{
|
|
81
81
|
effect: import("zod").ZodEnum<["give_points", "give_reward", "deduct_unit", "assign_member_custom_attribute", "remove_member_custom_attribute"]>;
|
|
82
|
-
pointsRule: import("zod").ZodOptional<import("zod").ZodString
|
|
82
|
+
pointsRule: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>>;
|
|
83
83
|
walletCode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
84
84
|
rewardId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
85
85
|
customAttributeKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -88,14 +88,14 @@ export declare const campaignToolDefinitions: readonly [{
|
|
|
88
88
|
effect: "give_points" | "give_reward" | "deduct_unit" | "assign_member_custom_attribute" | "remove_member_custom_attribute";
|
|
89
89
|
walletCode?: string | undefined;
|
|
90
90
|
rewardId?: string | undefined;
|
|
91
|
-
pointsRule?: string | undefined;
|
|
91
|
+
pointsRule?: string | number | undefined;
|
|
92
92
|
customAttributeKey?: string | undefined;
|
|
93
93
|
customAttributeValueRule?: string | undefined;
|
|
94
94
|
}, {
|
|
95
95
|
effect: "give_points" | "give_reward" | "deduct_unit" | "assign_member_custom_attribute" | "remove_member_custom_attribute";
|
|
96
96
|
walletCode?: string | undefined;
|
|
97
97
|
rewardId?: string | undefined;
|
|
98
|
-
pointsRule?: string | undefined;
|
|
98
|
+
pointsRule?: string | number | undefined;
|
|
99
99
|
customAttributeKey?: string | undefined;
|
|
100
100
|
customAttributeValueRule?: string | undefined;
|
|
101
101
|
}>, "many">;
|
|
@@ -118,7 +118,7 @@ export declare const campaignToolDefinitions: readonly [{
|
|
|
118
118
|
effect: "give_points" | "give_reward" | "deduct_unit" | "assign_member_custom_attribute" | "remove_member_custom_attribute";
|
|
119
119
|
walletCode?: string | undefined;
|
|
120
120
|
rewardId?: string | undefined;
|
|
121
|
-
pointsRule?: string | undefined;
|
|
121
|
+
pointsRule?: string | number | undefined;
|
|
122
122
|
customAttributeKey?: string | undefined;
|
|
123
123
|
customAttributeValueRule?: string | undefined;
|
|
124
124
|
}[];
|
|
@@ -135,7 +135,7 @@ export declare const campaignToolDefinitions: readonly [{
|
|
|
135
135
|
effect: "give_points" | "give_reward" | "deduct_unit" | "assign_member_custom_attribute" | "remove_member_custom_attribute";
|
|
136
136
|
walletCode?: string | undefined;
|
|
137
137
|
rewardId?: string | undefined;
|
|
138
|
-
pointsRule?: string | undefined;
|
|
138
|
+
pointsRule?: string | number | undefined;
|
|
139
139
|
customAttributeKey?: string | undefined;
|
|
140
140
|
customAttributeValueRule?: string | undefined;
|
|
141
141
|
}[];
|
|
@@ -148,15 +148,15 @@ export declare const campaignToolDefinitions: readonly [{
|
|
|
148
148
|
target?: "self" | "referrer" | undefined;
|
|
149
149
|
}>, "many">;
|
|
150
150
|
visibility: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
151
|
-
target: import("zod").ZodEnum<["
|
|
151
|
+
target: import("zod").ZodEnum<["none", "tier", "segment", "all"]>;
|
|
152
152
|
tiers: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
153
153
|
segments: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
154
154
|
}, "strip", import("zod").ZodTypeAny, {
|
|
155
|
-
target: "all" | "tier" | "segment";
|
|
155
|
+
target: "all" | "none" | "tier" | "segment";
|
|
156
156
|
tiers?: string[] | undefined;
|
|
157
157
|
segments?: string[] | undefined;
|
|
158
158
|
}, {
|
|
159
|
-
target: "all" | "tier" | "segment";
|
|
159
|
+
target: "all" | "none" | "tier" | "segment";
|
|
160
160
|
tiers?: string[] | undefined;
|
|
161
161
|
segments?: string[] | undefined;
|
|
162
162
|
}>>;
|
|
@@ -174,126 +174,237 @@ export declare const campaignToolDefinitions: readonly [{
|
|
|
174
174
|
segments?: string[] | undefined;
|
|
175
175
|
}>>;
|
|
176
176
|
limits: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
177
|
-
points: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
177
|
+
points: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
178
178
|
value: import("zod").ZodNumber;
|
|
179
179
|
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
180
|
-
type: import("zod").ZodEnum<["calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
181
|
-
value: import("zod").
|
|
180
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
181
|
+
value: import("zod").ZodNumber;
|
|
182
182
|
}, "strip", import("zod").ZodTypeAny, {
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
value: number;
|
|
184
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
185
185
|
}, {
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
value: number;
|
|
187
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
188
188
|
}>>;
|
|
189
189
|
}, "strip", import("zod").ZodTypeAny, {
|
|
190
190
|
value: number;
|
|
191
191
|
interval?: {
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
value: number;
|
|
193
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
194
194
|
} | undefined;
|
|
195
195
|
}, {
|
|
196
196
|
value: number;
|
|
197
197
|
interval?: {
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
value: number;
|
|
199
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
200
200
|
} | undefined;
|
|
201
|
-
}>>;
|
|
202
|
-
pointsPerMember: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
201
|
+
}>, import("zod").ZodNumber]>>;
|
|
202
|
+
pointsPerMember: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
203
203
|
value: import("zod").ZodNumber;
|
|
204
204
|
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
205
|
-
type: import("zod").ZodEnum<["calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
206
|
-
value: import("zod").
|
|
205
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
206
|
+
value: import("zod").ZodNumber;
|
|
207
207
|
}, "strip", import("zod").ZodTypeAny, {
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
value: number;
|
|
209
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
210
210
|
}, {
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
value: number;
|
|
212
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
213
213
|
}>>;
|
|
214
214
|
}, "strip", import("zod").ZodTypeAny, {
|
|
215
215
|
value: number;
|
|
216
216
|
interval?: {
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
value: number;
|
|
218
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
219
219
|
} | undefined;
|
|
220
220
|
}, {
|
|
221
221
|
value: number;
|
|
222
222
|
interval?: {
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
value: number;
|
|
224
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
225
225
|
} | undefined;
|
|
226
|
-
}>>;
|
|
227
|
-
executionsPerMember: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
226
|
+
}>, import("zod").ZodNumber]>>;
|
|
227
|
+
executionsPerMember: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
228
228
|
value: import("zod").ZodNumber;
|
|
229
229
|
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
230
|
-
type: import("zod").ZodEnum<["calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
231
|
-
value: import("zod").
|
|
230
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
231
|
+
value: import("zod").ZodNumber;
|
|
232
232
|
}, "strip", import("zod").ZodTypeAny, {
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
value: number;
|
|
234
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
235
235
|
}, {
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
value: number;
|
|
237
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
238
238
|
}>>;
|
|
239
239
|
}, "strip", import("zod").ZodTypeAny, {
|
|
240
240
|
value: number;
|
|
241
241
|
interval?: {
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
value: number;
|
|
243
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
244
244
|
} | undefined;
|
|
245
245
|
}, {
|
|
246
246
|
value: number;
|
|
247
247
|
interval?: {
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
value: number;
|
|
249
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
250
250
|
} | undefined;
|
|
251
|
-
}>>;
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
}>, import("zod").ZodNumber]>>;
|
|
252
|
+
perTransaction: import("zod").ZodOptional<import("zod").ZodUnknown>;
|
|
253
|
+
}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
|
|
254
|
+
points: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
255
|
+
value: import("zod").ZodNumber;
|
|
256
|
+
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
257
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
258
|
+
value: import("zod").ZodNumber;
|
|
259
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
260
|
+
value: number;
|
|
261
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
262
|
+
}, {
|
|
263
|
+
value: number;
|
|
264
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
265
|
+
}>>;
|
|
266
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
254
267
|
value: number;
|
|
255
268
|
interval?: {
|
|
256
|
-
|
|
257
|
-
|
|
269
|
+
value: number;
|
|
270
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
258
271
|
} | undefined;
|
|
259
|
-
}
|
|
260
|
-
pointsPerMember?: {
|
|
272
|
+
}, {
|
|
261
273
|
value: number;
|
|
262
274
|
interval?: {
|
|
263
|
-
|
|
264
|
-
|
|
275
|
+
value: number;
|
|
276
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
265
277
|
} | undefined;
|
|
266
|
-
}
|
|
267
|
-
|
|
278
|
+
}>, import("zod").ZodNumber]>>;
|
|
279
|
+
pointsPerMember: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
280
|
+
value: import("zod").ZodNumber;
|
|
281
|
+
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
282
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
283
|
+
value: import("zod").ZodNumber;
|
|
284
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
285
|
+
value: number;
|
|
286
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
287
|
+
}, {
|
|
288
|
+
value: number;
|
|
289
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
290
|
+
}>>;
|
|
291
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
268
292
|
value: number;
|
|
269
293
|
interval?: {
|
|
270
|
-
|
|
271
|
-
|
|
294
|
+
value: number;
|
|
295
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
272
296
|
} | undefined;
|
|
273
|
-
}
|
|
274
|
-
}, {
|
|
275
|
-
points?: {
|
|
297
|
+
}, {
|
|
276
298
|
value: number;
|
|
277
299
|
interval?: {
|
|
278
|
-
|
|
279
|
-
|
|
300
|
+
value: number;
|
|
301
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
280
302
|
} | undefined;
|
|
281
|
-
}
|
|
282
|
-
|
|
303
|
+
}>, import("zod").ZodNumber]>>;
|
|
304
|
+
executionsPerMember: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
305
|
+
value: import("zod").ZodNumber;
|
|
306
|
+
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
307
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
308
|
+
value: import("zod").ZodNumber;
|
|
309
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
310
|
+
value: number;
|
|
311
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
312
|
+
}, {
|
|
313
|
+
value: number;
|
|
314
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
315
|
+
}>>;
|
|
316
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
283
317
|
value: number;
|
|
284
318
|
interval?: {
|
|
285
|
-
|
|
286
|
-
|
|
319
|
+
value: number;
|
|
320
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
287
321
|
} | undefined;
|
|
288
|
-
}
|
|
289
|
-
executionsPerMember?: {
|
|
322
|
+
}, {
|
|
290
323
|
value: number;
|
|
291
324
|
interval?: {
|
|
292
|
-
|
|
293
|
-
|
|
325
|
+
value: number;
|
|
326
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
294
327
|
} | undefined;
|
|
295
|
-
}
|
|
296
|
-
|
|
328
|
+
}>, import("zod").ZodNumber]>>;
|
|
329
|
+
perTransaction: import("zod").ZodOptional<import("zod").ZodUnknown>;
|
|
330
|
+
}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
|
|
331
|
+
points: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
332
|
+
value: import("zod").ZodNumber;
|
|
333
|
+
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
334
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
335
|
+
value: import("zod").ZodNumber;
|
|
336
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
337
|
+
value: number;
|
|
338
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
339
|
+
}, {
|
|
340
|
+
value: number;
|
|
341
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
342
|
+
}>>;
|
|
343
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
344
|
+
value: number;
|
|
345
|
+
interval?: {
|
|
346
|
+
value: number;
|
|
347
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
348
|
+
} | undefined;
|
|
349
|
+
}, {
|
|
350
|
+
value: number;
|
|
351
|
+
interval?: {
|
|
352
|
+
value: number;
|
|
353
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
354
|
+
} | undefined;
|
|
355
|
+
}>, import("zod").ZodNumber]>>;
|
|
356
|
+
pointsPerMember: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
357
|
+
value: import("zod").ZodNumber;
|
|
358
|
+
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
359
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
360
|
+
value: import("zod").ZodNumber;
|
|
361
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
362
|
+
value: number;
|
|
363
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
364
|
+
}, {
|
|
365
|
+
value: number;
|
|
366
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
367
|
+
}>>;
|
|
368
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
369
|
+
value: number;
|
|
370
|
+
interval?: {
|
|
371
|
+
value: number;
|
|
372
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
373
|
+
} | undefined;
|
|
374
|
+
}, {
|
|
375
|
+
value: number;
|
|
376
|
+
interval?: {
|
|
377
|
+
value: number;
|
|
378
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
379
|
+
} | undefined;
|
|
380
|
+
}>, import("zod").ZodNumber]>>;
|
|
381
|
+
executionsPerMember: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
382
|
+
value: import("zod").ZodNumber;
|
|
383
|
+
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
384
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
385
|
+
value: import("zod").ZodNumber;
|
|
386
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
387
|
+
value: number;
|
|
388
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
389
|
+
}, {
|
|
390
|
+
value: number;
|
|
391
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
392
|
+
}>>;
|
|
393
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
394
|
+
value: number;
|
|
395
|
+
interval?: {
|
|
396
|
+
value: number;
|
|
397
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
398
|
+
} | undefined;
|
|
399
|
+
}, {
|
|
400
|
+
value: number;
|
|
401
|
+
interval?: {
|
|
402
|
+
value: number;
|
|
403
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
404
|
+
} | undefined;
|
|
405
|
+
}>, import("zod").ZodNumber]>>;
|
|
406
|
+
perTransaction: import("zod").ZodOptional<import("zod").ZodUnknown>;
|
|
407
|
+
}, import("zod").ZodTypeAny, "passthrough">>>;
|
|
297
408
|
active: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
298
409
|
displayOrder: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
299
410
|
labels: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
@@ -441,15 +552,15 @@ export declare const campaignToolDefinitions: readonly [{
|
|
|
441
552
|
target?: "self" | "referrer" | undefined;
|
|
442
553
|
}>, "many">;
|
|
443
554
|
visibility: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
444
|
-
target: import("zod").ZodEnum<["
|
|
555
|
+
target: import("zod").ZodEnum<["none", "tier", "segment"]>;
|
|
445
556
|
tiers: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
446
557
|
segments: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
447
558
|
}, "strip", import("zod").ZodTypeAny, {
|
|
448
|
-
target: "
|
|
559
|
+
target: "none" | "tier" | "segment";
|
|
449
560
|
tiers?: string[] | undefined;
|
|
450
561
|
segments?: string[] | undefined;
|
|
451
562
|
}, {
|
|
452
|
-
target: "
|
|
563
|
+
target: "none" | "tier" | "segment";
|
|
453
564
|
tiers?: string[] | undefined;
|
|
454
565
|
segments?: string[] | undefined;
|
|
455
566
|
}>>;
|
|
@@ -470,120 +581,120 @@ export declare const campaignToolDefinitions: readonly [{
|
|
|
470
581
|
points: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
471
582
|
value: import("zod").ZodNumber;
|
|
472
583
|
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
473
|
-
type: import("zod").ZodEnum<["calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
474
|
-
value: import("zod").
|
|
584
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
585
|
+
value: import("zod").ZodNumber;
|
|
475
586
|
}, "strip", import("zod").ZodTypeAny, {
|
|
476
|
-
|
|
477
|
-
|
|
587
|
+
value: number;
|
|
588
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
478
589
|
}, {
|
|
479
|
-
|
|
480
|
-
|
|
590
|
+
value: number;
|
|
591
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
481
592
|
}>>;
|
|
482
593
|
}, "strip", import("zod").ZodTypeAny, {
|
|
483
594
|
value: number;
|
|
484
595
|
interval?: {
|
|
485
|
-
|
|
486
|
-
|
|
596
|
+
value: number;
|
|
597
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
487
598
|
} | undefined;
|
|
488
599
|
}, {
|
|
489
600
|
value: number;
|
|
490
601
|
interval?: {
|
|
491
|
-
|
|
492
|
-
|
|
602
|
+
value: number;
|
|
603
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
493
604
|
} | undefined;
|
|
494
605
|
}>>;
|
|
495
606
|
pointsPerMember: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
496
607
|
value: import("zod").ZodNumber;
|
|
497
608
|
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
498
|
-
type: import("zod").ZodEnum<["calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
499
|
-
value: import("zod").
|
|
609
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
610
|
+
value: import("zod").ZodNumber;
|
|
500
611
|
}, "strip", import("zod").ZodTypeAny, {
|
|
501
|
-
|
|
502
|
-
|
|
612
|
+
value: number;
|
|
613
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
503
614
|
}, {
|
|
504
|
-
|
|
505
|
-
|
|
615
|
+
value: number;
|
|
616
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
506
617
|
}>>;
|
|
507
618
|
}, "strip", import("zod").ZodTypeAny, {
|
|
508
619
|
value: number;
|
|
509
620
|
interval?: {
|
|
510
|
-
|
|
511
|
-
|
|
621
|
+
value: number;
|
|
622
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
512
623
|
} | undefined;
|
|
513
624
|
}, {
|
|
514
625
|
value: number;
|
|
515
626
|
interval?: {
|
|
516
|
-
|
|
517
|
-
|
|
627
|
+
value: number;
|
|
628
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
518
629
|
} | undefined;
|
|
519
630
|
}>>;
|
|
520
631
|
executionsPerMember: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
521
632
|
value: import("zod").ZodNumber;
|
|
522
633
|
interval: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
523
|
-
type: import("zod").ZodEnum<["calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
524
|
-
value: import("zod").
|
|
634
|
+
type: import("zod").ZodEnum<["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"]>;
|
|
635
|
+
value: import("zod").ZodNumber;
|
|
525
636
|
}, "strip", import("zod").ZodTypeAny, {
|
|
526
|
-
|
|
527
|
-
|
|
637
|
+
value: number;
|
|
638
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
528
639
|
}, {
|
|
529
|
-
|
|
530
|
-
|
|
640
|
+
value: number;
|
|
641
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
531
642
|
}>>;
|
|
532
643
|
}, "strip", import("zod").ZodTypeAny, {
|
|
533
644
|
value: number;
|
|
534
645
|
interval?: {
|
|
535
|
-
|
|
536
|
-
|
|
646
|
+
value: number;
|
|
647
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
537
648
|
} | undefined;
|
|
538
649
|
}, {
|
|
539
650
|
value: number;
|
|
540
651
|
interval?: {
|
|
541
|
-
|
|
542
|
-
|
|
652
|
+
value: number;
|
|
653
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
543
654
|
} | undefined;
|
|
544
655
|
}>>;
|
|
545
656
|
}, "strip", import("zod").ZodTypeAny, {
|
|
546
657
|
points?: {
|
|
547
658
|
value: number;
|
|
548
659
|
interval?: {
|
|
549
|
-
|
|
550
|
-
|
|
660
|
+
value: number;
|
|
661
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
551
662
|
} | undefined;
|
|
552
663
|
} | undefined;
|
|
553
664
|
pointsPerMember?: {
|
|
554
665
|
value: number;
|
|
555
666
|
interval?: {
|
|
556
|
-
|
|
557
|
-
|
|
667
|
+
value: number;
|
|
668
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
558
669
|
} | undefined;
|
|
559
670
|
} | undefined;
|
|
560
671
|
executionsPerMember?: {
|
|
561
672
|
value: number;
|
|
562
673
|
interval?: {
|
|
563
|
-
|
|
564
|
-
|
|
674
|
+
value: number;
|
|
675
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
565
676
|
} | undefined;
|
|
566
677
|
} | undefined;
|
|
567
678
|
}, {
|
|
568
679
|
points?: {
|
|
569
680
|
value: number;
|
|
570
681
|
interval?: {
|
|
571
|
-
|
|
572
|
-
|
|
682
|
+
value: number;
|
|
683
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
573
684
|
} | undefined;
|
|
574
685
|
} | undefined;
|
|
575
686
|
pointsPerMember?: {
|
|
576
687
|
value: number;
|
|
577
688
|
interval?: {
|
|
578
|
-
|
|
579
|
-
|
|
689
|
+
value: number;
|
|
690
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
580
691
|
} | undefined;
|
|
581
692
|
} | undefined;
|
|
582
693
|
executionsPerMember?: {
|
|
583
694
|
value: number;
|
|
584
695
|
interval?: {
|
|
585
|
-
|
|
586
|
-
|
|
696
|
+
value: number;
|
|
697
|
+
type: "calendarHours" | "calendarDays" | "calendarWeeks" | "calendarMonths" | "calendarYears";
|
|
587
698
|
} | undefined;
|
|
588
699
|
} | undefined;
|
|
589
700
|
}>>;
|
|
@@ -35,7 +35,10 @@ export const campaignToolDefinitions = [
|
|
|
35
35
|
"For labels: { operator: 'has_at_least_one_label', attribute: 'transaction.labels', data: [{key: 'category', value: 'electronics'}] }. " +
|
|
36
36
|
"For between: { operator: 'is_between', attribute: 'transaction.grossValue', data: {from: 50, to: 200} }. " +
|
|
37
37
|
"AUDIENCE: OMIT entirely for all members. Do NOT pass audience: { target: 'all' } -- the API rejects 'all'. Only use audience for tier/segment targeting. " +
|
|
38
|
-
"VISIBILITY vs AUDIENCE: visibility = who can see the campaign. audience = who can participate.
|
|
38
|
+
"VISIBILITY vs AUDIENCE: visibility = who can see the campaign. audience = who can participate. " +
|
|
39
|
+
"Visibility accepts target='tier', 'segment', or 'none' (invisible to everyone). OMIT visibility for everyone. Legacy visibility target='all' is normalized by omitting visibility. " +
|
|
40
|
+
"Limits support only points, pointsPerMember, executionsPerMember. Do NOT use perTransaction; cap pointsRule for per-transaction point caps. " +
|
|
41
|
+
"Limit interval types: calendarHours, calendarDays, calendarWeeks, calendarMonths, calendarYears, and interval.value is required when interval is present.",
|
|
39
42
|
readOnly: false,
|
|
40
43
|
idempotent: false,
|
|
41
44
|
inputSchema: CampaignCreateInputSchema,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CampaignCreateInput } from "./types.js";
|
|
2
|
+
export declare const VALID_LIMIT_INTERVAL_TYPES: readonly ["calendarHours", "calendarDays", "calendarWeeks", "calendarMonths", "calendarYears"];
|
|
3
|
+
export declare function normalizeCampaignRules(input: CampaignCreateInput["rules"]): CampaignCreateInput["rules"];
|
|
4
|
+
export declare function normalizeCampaignVisibility(visibility: CampaignCreateInput["visibility"]): CampaignCreateInput["visibility"];
|
|
5
|
+
export declare function normalizeCampaignLimits(input: CampaignCreateInput): Record<string, unknown> | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { OpenLoyaltyError } from "../../utils/errors.js";
|
|
2
|
+
const SUPPORTED_LIMIT_KEYS = ["points", "pointsPerMember", "executionsPerMember"];
|
|
3
|
+
const SUPPORTED_LIMIT_KEY_SET = new Set(SUPPORTED_LIMIT_KEYS);
|
|
4
|
+
export const VALID_LIMIT_INTERVAL_TYPES = [
|
|
5
|
+
"calendarHours",
|
|
6
|
+
"calendarDays",
|
|
7
|
+
"calendarWeeks",
|
|
8
|
+
"calendarMonths",
|
|
9
|
+
"calendarYears",
|
|
10
|
+
];
|
|
11
|
+
export function normalizeCampaignRules(input) {
|
|
12
|
+
return input.map((rule) => ({
|
|
13
|
+
...rule,
|
|
14
|
+
effects: rule.effects?.map((effect) => ({
|
|
15
|
+
...effect,
|
|
16
|
+
pointsRule: effect.pointsRule === undefined ? undefined : String(effect.pointsRule),
|
|
17
|
+
})),
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
export function normalizeCampaignVisibility(visibility) {
|
|
21
|
+
if (!visibility || visibility.target === "all") {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return visibility;
|
|
25
|
+
}
|
|
26
|
+
export function normalizeCampaignLimits(input) {
|
|
27
|
+
const limits = input.limits;
|
|
28
|
+
if (!limits) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const unsupportedKeys = Object.keys(limits).filter((key) => !SUPPORTED_LIMIT_KEY_SET.has(key));
|
|
32
|
+
if (unsupportedKeys.length > 0) {
|
|
33
|
+
throw new OpenLoyaltyError({
|
|
34
|
+
code: "INVALID_LIMITS",
|
|
35
|
+
message: `Unsupported campaign limit key: ${unsupportedKeys.join(", ")}`,
|
|
36
|
+
hint: "Campaign limits support only points, pointsPerMember, and executionsPerMember. " +
|
|
37
|
+
"Do not use perTransaction; for maximum points per transaction, cap the pointsRule expression, " +
|
|
38
|
+
"for example: '(transaction.grossValue * 2 >= 100) ? 100 : transaction.grossValue * 2'.",
|
|
39
|
+
relatedTool: "ol_campaign_create",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const normalized = {};
|
|
43
|
+
for (const key of SUPPORTED_LIMIT_KEYS) {
|
|
44
|
+
const value = limits[key];
|
|
45
|
+
if (value !== undefined) {
|
|
46
|
+
normalized[key] = typeof value === "number" ? { value } : value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return normalized;
|
|
50
|
+
}
|