@open-loyalty/mcp-server 1.0.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/LICENSE +21 -0
- package/README.md +654 -0
- package/dist/client/http.d.ts +8 -0
- package/dist/client/http.js +69 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +40 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +334 -0
- package/dist/tools/achievement.d.ts +983 -0
- package/dist/tools/achievement.js +311 -0
- package/dist/tools/admin.d.ts +153 -0
- package/dist/tools/admin.js +193 -0
- package/dist/tools/analytics.d.ts +162 -0
- package/dist/tools/analytics.js +245 -0
- package/dist/tools/apikey.d.ts +72 -0
- package/dist/tools/apikey.js +78 -0
- package/dist/tools/audit.d.ts +107 -0
- package/dist/tools/audit.js +90 -0
- package/dist/tools/badge.d.ts +135 -0
- package/dist/tools/badge.js +165 -0
- package/dist/tools/campaign.d.ts +1775 -0
- package/dist/tools/campaign.js +724 -0
- package/dist/tools/export.d.ts +110 -0
- package/dist/tools/export.js +147 -0
- package/dist/tools/import.d.ts +110 -0
- package/dist/tools/import.js +126 -0
- package/dist/tools/index.d.ts +22 -0
- package/dist/tools/index.js +527 -0
- package/dist/tools/member.d.ts +345 -0
- package/dist/tools/member.js +358 -0
- package/dist/tools/member.test.d.ts +1 -0
- package/dist/tools/member.test.js +213 -0
- package/dist/tools/points.d.ts +188 -0
- package/dist/tools/points.js +306 -0
- package/dist/tools/points.test.d.ts +1 -0
- package/dist/tools/points.test.js +292 -0
- package/dist/tools/reward.d.ts +261 -0
- package/dist/tools/reward.js +371 -0
- package/dist/tools/reward.test.d.ts +1 -0
- package/dist/tools/reward.test.js +240 -0
- package/dist/tools/role.d.ts +161 -0
- package/dist/tools/role.js +160 -0
- package/dist/tools/segment.d.ts +797 -0
- package/dist/tools/segment.js +299 -0
- package/dist/tools/store.d.ts +101 -0
- package/dist/tools/store.js +117 -0
- package/dist/tools/tierset.d.ts +288 -0
- package/dist/tools/tierset.js +244 -0
- package/dist/tools/transaction.d.ts +357 -0
- package/dist/tools/transaction.js +242 -0
- package/dist/tools/transaction.test.d.ts +1 -0
- package/dist/tools/transaction.test.js +235 -0
- package/dist/tools/wallet-type.d.ts +32 -0
- package/dist/tools/wallet-type.js +58 -0
- package/dist/tools/webhook.d.ts +179 -0
- package/dist/tools/webhook.js +171 -0
- package/dist/types/schemas/achievement.d.ts +1116 -0
- package/dist/types/schemas/achievement.js +172 -0
- package/dist/types/schemas/admin.d.ts +263 -0
- package/dist/types/schemas/admin.js +99 -0
- package/dist/types/schemas/analytics.d.ts +542 -0
- package/dist/types/schemas/analytics.js +130 -0
- package/dist/types/schemas/badge.d.ts +131 -0
- package/dist/types/schemas/badge.js +48 -0
- package/dist/types/schemas/campaign.d.ts +2005 -0
- package/dist/types/schemas/campaign.js +189 -0
- package/dist/types/schemas/common.d.ts +52 -0
- package/dist/types/schemas/common.js +26 -0
- package/dist/types/schemas/export.d.ts +127 -0
- package/dist/types/schemas/export.js +43 -0
- package/dist/types/schemas/import.d.ts +344 -0
- package/dist/types/schemas/import.js +68 -0
- package/dist/types/schemas/member.d.ts +443 -0
- package/dist/types/schemas/member.js +92 -0
- package/dist/types/schemas/points.d.ts +188 -0
- package/dist/types/schemas/points.js +54 -0
- package/dist/types/schemas/reward.d.ts +278 -0
- package/dist/types/schemas/reward.js +69 -0
- package/dist/types/schemas/role.d.ts +260 -0
- package/dist/types/schemas/role.js +75 -0
- package/dist/types/schemas/segment.d.ts +592 -0
- package/dist/types/schemas/segment.js +114 -0
- package/dist/types/schemas/tierset.d.ts +552 -0
- package/dist/types/schemas/tierset.js +87 -0
- package/dist/types/schemas/transaction.d.ts +1022 -0
- package/dist/types/schemas/transaction.js +63 -0
- package/dist/types/schemas/wallet-type.d.ts +99 -0
- package/dist/types/schemas/wallet-type.js +17 -0
- package/dist/types/schemas/webhook.d.ts +195 -0
- package/dist/types/schemas/webhook.js +39 -0
- package/dist/utils/cursor.d.ts +84 -0
- package/dist/utils/cursor.js +117 -0
- package/dist/utils/errors.d.ts +12 -0
- package/dist/utils/errors.js +69 -0
- package/dist/utils/pagination.d.ts +39 -0
- package/dist/utils/pagination.js +77 -0
- package/package.json +65 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { TranslationsSchema } from "./common.js";
|
|
3
|
+
// Campaign Type Enum
|
|
4
|
+
export const CampaignTypeEnum = z.enum(["direct", "referral"]);
|
|
5
|
+
// Campaign Trigger Enum
|
|
6
|
+
export const CampaignTriggerEnum = z.enum([
|
|
7
|
+
"transaction",
|
|
8
|
+
"custom_event",
|
|
9
|
+
"time",
|
|
10
|
+
"achievement",
|
|
11
|
+
"custom_event_unique_code",
|
|
12
|
+
"leaderboard",
|
|
13
|
+
"internal_event",
|
|
14
|
+
"return_transaction",
|
|
15
|
+
"challenge",
|
|
16
|
+
"fortune_wheel",
|
|
17
|
+
]);
|
|
18
|
+
// Campaign Effect Enum
|
|
19
|
+
export const CampaignEffectEnum = z.enum([
|
|
20
|
+
"give_points",
|
|
21
|
+
"give_reward",
|
|
22
|
+
"deduct_unit",
|
|
23
|
+
"assign_member_custom_attribute",
|
|
24
|
+
"remove_member_custom_attribute",
|
|
25
|
+
]);
|
|
26
|
+
// Points Rule Schema for give_points effect
|
|
27
|
+
export const CampaignPointsRuleSchema = z.object({
|
|
28
|
+
description: z.string().optional(),
|
|
29
|
+
expression: z.string().optional(),
|
|
30
|
+
multiplier: z.number().optional(),
|
|
31
|
+
fixedValue: z.number().optional(),
|
|
32
|
+
});
|
|
33
|
+
// Units Lock Rule Schema
|
|
34
|
+
export const CampaignUnitsLockRuleSchema = z.object({
|
|
35
|
+
lockStrategy: z.enum(["from_wallet", "no_pending", "expression"]).optional(),
|
|
36
|
+
expression: z.string().optional(),
|
|
37
|
+
});
|
|
38
|
+
// Units Expiration Rule Schema
|
|
39
|
+
export const CampaignUnitsExpirationRuleSchema = z.object({
|
|
40
|
+
expirationStrategy: z.enum(["from_wallet", "never_expires", "expression"]).optional(),
|
|
41
|
+
expression: z.string().optional(),
|
|
42
|
+
});
|
|
43
|
+
// Campaign Effect Schema
|
|
44
|
+
export const CampaignEffectSchema = z.object({
|
|
45
|
+
effect: CampaignEffectEnum,
|
|
46
|
+
pointsRule: CampaignPointsRuleSchema.optional(),
|
|
47
|
+
walletCode: z.string().optional(),
|
|
48
|
+
unitsLockRule: CampaignUnitsLockRuleSchema.optional(),
|
|
49
|
+
unitsExpirationRule: CampaignUnitsExpirationRuleSchema.optional(),
|
|
50
|
+
rewardId: z.string().optional(),
|
|
51
|
+
couponValueRule: z.string().optional(),
|
|
52
|
+
customAttributeKey: z.string().optional(),
|
|
53
|
+
customAttributeValueRule: z.string().optional(),
|
|
54
|
+
});
|
|
55
|
+
// Campaign Condition Schema
|
|
56
|
+
export const CampaignConditionSchema = z.object({
|
|
57
|
+
operator: z.string(),
|
|
58
|
+
attribute: z.string(),
|
|
59
|
+
data: z.record(z.unknown()).optional(),
|
|
60
|
+
});
|
|
61
|
+
// Campaign Rule Schema
|
|
62
|
+
export const CampaignRuleSchema = z.object({
|
|
63
|
+
name: z.string(),
|
|
64
|
+
description: z.string().optional(),
|
|
65
|
+
target: z.enum(["self", "referrer"]).optional(),
|
|
66
|
+
effects: z.array(CampaignEffectSchema),
|
|
67
|
+
conditions: z.array(CampaignConditionSchema).optional(),
|
|
68
|
+
});
|
|
69
|
+
// Campaign Activity Schema (time period)
|
|
70
|
+
export const CampaignActivitySchema = z.object({
|
|
71
|
+
startsAt: z.string(), // ISO datetime
|
|
72
|
+
endsAt: z.string().optional(), // ISO datetime
|
|
73
|
+
});
|
|
74
|
+
// Campaign Visibility Schema (who can see the campaign)
|
|
75
|
+
export const CampaignVisibilitySchema = z.object({
|
|
76
|
+
target: z.enum(["all", "tier", "segment"]),
|
|
77
|
+
tiers: z.array(z.string()).optional(),
|
|
78
|
+
segments: z.array(z.string()).optional(),
|
|
79
|
+
});
|
|
80
|
+
// Campaign Audience Schema (who can participate)
|
|
81
|
+
export const CampaignAudienceSchema = z.object({
|
|
82
|
+
target: z.enum(["all", "tier", "segment"]),
|
|
83
|
+
tiers: z.array(z.string()).optional(),
|
|
84
|
+
segments: z.array(z.string()).optional(),
|
|
85
|
+
});
|
|
86
|
+
// Limit Interval Schema
|
|
87
|
+
export const CampaignLimitIntervalSchema = z.object({
|
|
88
|
+
type: z.enum(["days", "weeks", "months", "years", "forever"]),
|
|
89
|
+
value: z.number().optional(),
|
|
90
|
+
});
|
|
91
|
+
// Limit Value Schema
|
|
92
|
+
export const CampaignLimitValueSchema = z.object({
|
|
93
|
+
value: z.number(),
|
|
94
|
+
interval: CampaignLimitIntervalSchema.optional(),
|
|
95
|
+
});
|
|
96
|
+
// Campaign Limits Schema
|
|
97
|
+
export const CampaignLimitsSchema = z.object({
|
|
98
|
+
points: CampaignLimitValueSchema.optional(),
|
|
99
|
+
pointsPerMember: CampaignLimitValueSchema.optional(),
|
|
100
|
+
executionsPerMember: CampaignLimitValueSchema.optional(),
|
|
101
|
+
});
|
|
102
|
+
// Trigger Strategy Schema
|
|
103
|
+
export const CampaignTriggerStrategySchema = z.object({
|
|
104
|
+
type: z.enum(["daily", "weekly", "monthly", "cron"]).optional(),
|
|
105
|
+
executionSchedule: z.object({
|
|
106
|
+
dayOfWeek: z.array(z.number()).optional(),
|
|
107
|
+
dayOfMonth: z.array(z.number()).optional(),
|
|
108
|
+
}).optional(),
|
|
109
|
+
});
|
|
110
|
+
// Transaction Items Filter Schema
|
|
111
|
+
export const CampaignTransactionItemFilterSchema = z.object({
|
|
112
|
+
value: z.object({
|
|
113
|
+
field: z.enum(["sku", "name", "category", "maker", "qty"]),
|
|
114
|
+
}),
|
|
115
|
+
condition: z.object({
|
|
116
|
+
operator: z.string(),
|
|
117
|
+
value: z.union([z.string(), z.number()]),
|
|
118
|
+
}),
|
|
119
|
+
});
|
|
120
|
+
export const CampaignTransactionItemsFilterSchema = z.object({
|
|
121
|
+
code: z.string(),
|
|
122
|
+
name: z.string().optional(),
|
|
123
|
+
filters: z.array(CampaignTransactionItemFilterSchema),
|
|
124
|
+
});
|
|
125
|
+
// Label Schema
|
|
126
|
+
export const CampaignLabelSchema = z.object({
|
|
127
|
+
key: z.string(),
|
|
128
|
+
value: z.string(),
|
|
129
|
+
});
|
|
130
|
+
// Main Campaign Schema
|
|
131
|
+
export const CampaignSchema = z.object({
|
|
132
|
+
campaignId: z.string(),
|
|
133
|
+
type: CampaignTypeEnum,
|
|
134
|
+
trigger: CampaignTriggerEnum,
|
|
135
|
+
translations: TranslationsSchema,
|
|
136
|
+
active: z.boolean(),
|
|
137
|
+
activity: CampaignActivitySchema.optional(),
|
|
138
|
+
rules: z.array(CampaignRuleSchema),
|
|
139
|
+
visibility: CampaignVisibilitySchema.optional(),
|
|
140
|
+
audience: CampaignAudienceSchema.optional(),
|
|
141
|
+
limits: CampaignLimitsSchema.optional(),
|
|
142
|
+
triggerStrategy: CampaignTriggerStrategySchema.optional(),
|
|
143
|
+
transactionItemsFilters: z.array(CampaignTransactionItemsFilterSchema).optional(),
|
|
144
|
+
event: z.string().optional(),
|
|
145
|
+
displayOrder: z.number().optional(),
|
|
146
|
+
labels: z.array(CampaignLabelSchema).optional(),
|
|
147
|
+
memberFilter: z.record(z.unknown()).optional(),
|
|
148
|
+
});
|
|
149
|
+
// Campaign Create Input Schema (matches POST body structure)
|
|
150
|
+
export const CampaignCreateInputSchema = z.object({
|
|
151
|
+
type: CampaignTypeEnum,
|
|
152
|
+
trigger: CampaignTriggerEnum,
|
|
153
|
+
translations: TranslationsSchema,
|
|
154
|
+
activity: CampaignActivitySchema,
|
|
155
|
+
rules: z.array(CampaignRuleSchema),
|
|
156
|
+
visibility: CampaignVisibilitySchema.optional(),
|
|
157
|
+
audience: CampaignAudienceSchema.optional(),
|
|
158
|
+
limits: CampaignLimitsSchema.optional(),
|
|
159
|
+
triggerStrategy: CampaignTriggerStrategySchema.optional(),
|
|
160
|
+
transactionItemsFilters: z.array(CampaignTransactionItemsFilterSchema).optional(),
|
|
161
|
+
event: z.string().optional(),
|
|
162
|
+
displayOrder: z.number().optional(),
|
|
163
|
+
active: z.boolean().optional(),
|
|
164
|
+
labels: z.array(CampaignLabelSchema).optional(),
|
|
165
|
+
memberFilter: z.record(z.unknown()).optional(),
|
|
166
|
+
});
|
|
167
|
+
// Campaign List Item Schema (simplified for list responses)
|
|
168
|
+
export const CampaignListItemSchema = z.object({
|
|
169
|
+
campaignId: z.string(),
|
|
170
|
+
name: z.string().optional(),
|
|
171
|
+
type: CampaignTypeEnum,
|
|
172
|
+
trigger: CampaignTriggerEnum,
|
|
173
|
+
active: z.boolean(),
|
|
174
|
+
displayOrder: z.number().optional(),
|
|
175
|
+
});
|
|
176
|
+
// Simulated Effect Schema
|
|
177
|
+
export const CampaignSimulatedEffectSchema = z.object({
|
|
178
|
+
campaignId: z.string(),
|
|
179
|
+
campaignName: z.string().optional(),
|
|
180
|
+
effects: z.array(z.record(z.unknown())),
|
|
181
|
+
limitReached: z.boolean().optional(),
|
|
182
|
+
});
|
|
183
|
+
// Campaign Code Schema
|
|
184
|
+
export const CampaignCodeSchema = z.object({
|
|
185
|
+
code: z.string(),
|
|
186
|
+
used: z.boolean(),
|
|
187
|
+
usedAt: z.string().optional(),
|
|
188
|
+
memberId: z.string().optional(),
|
|
189
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Common schema for paginated list responses.
|
|
4
|
+
* The Open Loyalty API returns total in varying formats depending on the endpoint:
|
|
5
|
+
* - Sometimes empty object {}
|
|
6
|
+
* - Sometimes { all: number|boolean, filtered: number|boolean, estimated: boolean|string|number }
|
|
7
|
+
* We use a flexible schema that accepts all variations.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TotalSchema: z.ZodObject<{
|
|
10
|
+
all: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBoolean]>>;
|
|
11
|
+
filtered: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBoolean, z.ZodString]>>;
|
|
12
|
+
estimated: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodNumber]>>;
|
|
13
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
14
|
+
all: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBoolean]>>;
|
|
15
|
+
filtered: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBoolean, z.ZodString]>>;
|
|
16
|
+
estimated: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodNumber]>>;
|
|
17
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
18
|
+
all: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBoolean]>>;
|
|
19
|
+
filtered: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBoolean, z.ZodString]>>;
|
|
20
|
+
estimated: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodNumber]>>;
|
|
21
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
22
|
+
export type Total = z.infer<typeof TotalSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* Translation entry schema for multilingual content.
|
|
25
|
+
* Most Open Loyalty endpoints require translations with at least 'en' key.
|
|
26
|
+
*/
|
|
27
|
+
export declare const TranslationEntrySchema: z.ZodObject<{
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
description: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
name: string;
|
|
32
|
+
description?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export type TranslationEntry = z.infer<typeof TranslationEntrySchema>;
|
|
38
|
+
/**
|
|
39
|
+
* Translations schema - keyed by language code.
|
|
40
|
+
* The 'en' key is typically required, other languages (pl, de, etc.) are optional.
|
|
41
|
+
*/
|
|
42
|
+
export declare const TranslationsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
43
|
+
name: z.ZodString;
|
|
44
|
+
description: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
name: string;
|
|
47
|
+
description?: string | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
name: string;
|
|
50
|
+
description?: string | undefined;
|
|
51
|
+
}>>;
|
|
52
|
+
export type Translations = z.infer<typeof TranslationsSchema>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Common schema for paginated list responses.
|
|
4
|
+
* The Open Loyalty API returns total in varying formats depending on the endpoint:
|
|
5
|
+
* - Sometimes empty object {}
|
|
6
|
+
* - Sometimes { all: number|boolean, filtered: number|boolean, estimated: boolean|string|number }
|
|
7
|
+
* We use a flexible schema that accepts all variations.
|
|
8
|
+
*/
|
|
9
|
+
export const TotalSchema = z.object({
|
|
10
|
+
all: z.union([z.number(), z.boolean()]).optional(),
|
|
11
|
+
filtered: z.union([z.number(), z.boolean(), z.string()]).optional(),
|
|
12
|
+
estimated: z.union([z.boolean(), z.string(), z.number()]).optional(),
|
|
13
|
+
}).passthrough(); // Allow additional fields
|
|
14
|
+
/**
|
|
15
|
+
* Translation entry schema for multilingual content.
|
|
16
|
+
* Most Open Loyalty endpoints require translations with at least 'en' key.
|
|
17
|
+
*/
|
|
18
|
+
export const TranslationEntrySchema = z.object({
|
|
19
|
+
name: z.string(),
|
|
20
|
+
description: z.string().optional(),
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Translations schema - keyed by language code.
|
|
24
|
+
* The 'en' key is typically required, other languages (pl, de, etc.) are optional.
|
|
25
|
+
*/
|
|
26
|
+
export const TranslationsSchema = z.record(z.string(), TranslationEntrySchema);
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ExportTypeEnum: z.ZodEnum<["campaignCode", "member", "memberTier", "memberSegment", "rewardFulfillment"]>;
|
|
3
|
+
export type ExportType = z.infer<typeof ExportTypeEnum>;
|
|
4
|
+
export declare const ExportStatusEnum: z.ZodEnum<["pending", "done", "failed", "error"]>;
|
|
5
|
+
export type ExportStatus = z.infer<typeof ExportStatusEnum>;
|
|
6
|
+
export declare const ExportSchema: z.ZodObject<{
|
|
7
|
+
exportId: z.ZodString;
|
|
8
|
+
type: z.ZodOptional<z.ZodEnum<["campaignCode", "member", "memberTier", "memberSegment", "rewardFulfillment"]>>;
|
|
9
|
+
status: z.ZodOptional<z.ZodEnum<["pending", "done", "failed", "error"]>>;
|
|
10
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
11
|
+
finishedAt: z.ZodOptional<z.ZodString>;
|
|
12
|
+
criteria: z.ZodOptional<z.ZodString>;
|
|
13
|
+
exportedRows: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
message: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
exportId: string;
|
|
17
|
+
message?: string | undefined;
|
|
18
|
+
type?: "member" | "campaignCode" | "memberTier" | "memberSegment" | "rewardFulfillment" | undefined;
|
|
19
|
+
status?: "pending" | "done" | "failed" | "error" | undefined;
|
|
20
|
+
createdAt?: string | undefined;
|
|
21
|
+
criteria?: string | undefined;
|
|
22
|
+
finishedAt?: string | undefined;
|
|
23
|
+
exportedRows?: number | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
exportId: string;
|
|
26
|
+
message?: string | undefined;
|
|
27
|
+
type?: "member" | "campaignCode" | "memberTier" | "memberSegment" | "rewardFulfillment" | undefined;
|
|
28
|
+
status?: "pending" | "done" | "failed" | "error" | undefined;
|
|
29
|
+
createdAt?: string | undefined;
|
|
30
|
+
criteria?: string | undefined;
|
|
31
|
+
finishedAt?: string | undefined;
|
|
32
|
+
exportedRows?: number | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
export type Export = z.infer<typeof ExportSchema>;
|
|
35
|
+
export declare const ExportListResponseSchema: z.ZodObject<{
|
|
36
|
+
items: z.ZodArray<z.ZodObject<{
|
|
37
|
+
exportId: z.ZodString;
|
|
38
|
+
type: z.ZodOptional<z.ZodEnum<["campaignCode", "member", "memberTier", "memberSegment", "rewardFulfillment"]>>;
|
|
39
|
+
status: z.ZodOptional<z.ZodEnum<["pending", "done", "failed", "error"]>>;
|
|
40
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
41
|
+
finishedAt: z.ZodOptional<z.ZodString>;
|
|
42
|
+
criteria: z.ZodOptional<z.ZodString>;
|
|
43
|
+
exportedRows: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
message: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
exportId: string;
|
|
47
|
+
message?: string | undefined;
|
|
48
|
+
type?: "member" | "campaignCode" | "memberTier" | "memberSegment" | "rewardFulfillment" | undefined;
|
|
49
|
+
status?: "pending" | "done" | "failed" | "error" | undefined;
|
|
50
|
+
createdAt?: string | undefined;
|
|
51
|
+
criteria?: string | undefined;
|
|
52
|
+
finishedAt?: string | undefined;
|
|
53
|
+
exportedRows?: number | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
exportId: string;
|
|
56
|
+
message?: string | undefined;
|
|
57
|
+
type?: "member" | "campaignCode" | "memberTier" | "memberSegment" | "rewardFulfillment" | undefined;
|
|
58
|
+
status?: "pending" | "done" | "failed" | "error" | undefined;
|
|
59
|
+
createdAt?: string | undefined;
|
|
60
|
+
criteria?: string | undefined;
|
|
61
|
+
finishedAt?: string | undefined;
|
|
62
|
+
exportedRows?: number | undefined;
|
|
63
|
+
}>, "many">;
|
|
64
|
+
total: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
all: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
66
|
+
filtered: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
67
|
+
estimated: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
all?: string | number | undefined;
|
|
70
|
+
filtered?: string | number | undefined;
|
|
71
|
+
estimated?: boolean | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
all?: string | number | undefined;
|
|
74
|
+
filtered?: string | number | undefined;
|
|
75
|
+
estimated?: boolean | undefined;
|
|
76
|
+
}>>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
items: {
|
|
79
|
+
exportId: string;
|
|
80
|
+
message?: string | undefined;
|
|
81
|
+
type?: "member" | "campaignCode" | "memberTier" | "memberSegment" | "rewardFulfillment" | undefined;
|
|
82
|
+
status?: "pending" | "done" | "failed" | "error" | undefined;
|
|
83
|
+
createdAt?: string | undefined;
|
|
84
|
+
criteria?: string | undefined;
|
|
85
|
+
finishedAt?: string | undefined;
|
|
86
|
+
exportedRows?: number | undefined;
|
|
87
|
+
}[];
|
|
88
|
+
total?: {
|
|
89
|
+
all?: string | number | undefined;
|
|
90
|
+
filtered?: string | number | undefined;
|
|
91
|
+
estimated?: boolean | undefined;
|
|
92
|
+
} | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
items: {
|
|
95
|
+
exportId: string;
|
|
96
|
+
message?: string | undefined;
|
|
97
|
+
type?: "member" | "campaignCode" | "memberTier" | "memberSegment" | "rewardFulfillment" | undefined;
|
|
98
|
+
status?: "pending" | "done" | "failed" | "error" | undefined;
|
|
99
|
+
createdAt?: string | undefined;
|
|
100
|
+
criteria?: string | undefined;
|
|
101
|
+
finishedAt?: string | undefined;
|
|
102
|
+
exportedRows?: number | undefined;
|
|
103
|
+
}[];
|
|
104
|
+
total?: {
|
|
105
|
+
all?: string | number | undefined;
|
|
106
|
+
filtered?: string | number | undefined;
|
|
107
|
+
estimated?: boolean | undefined;
|
|
108
|
+
} | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
export type ExportListResponse = z.infer<typeof ExportListResponseSchema>;
|
|
111
|
+
export declare const ExportCreateInputSchema: z.ZodObject<{
|
|
112
|
+
type: z.ZodEnum<["campaignCode", "member", "memberTier", "memberSegment", "rewardFulfillment"]>;
|
|
113
|
+
filters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
114
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
perPage: z.ZodOptional<z.ZodNumber>;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
type: "member" | "campaignCode" | "memberTier" | "memberSegment" | "rewardFulfillment";
|
|
118
|
+
filters?: Record<string, unknown> | undefined;
|
|
119
|
+
page?: number | undefined;
|
|
120
|
+
perPage?: number | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
type: "member" | "campaignCode" | "memberTier" | "memberSegment" | "rewardFulfillment";
|
|
123
|
+
filters?: Record<string, unknown> | undefined;
|
|
124
|
+
page?: number | undefined;
|
|
125
|
+
perPage?: number | undefined;
|
|
126
|
+
}>;
|
|
127
|
+
export type ExportCreateInput = z.infer<typeof ExportCreateInputSchema>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Export type enum
|
|
3
|
+
export const ExportTypeEnum = z.enum([
|
|
4
|
+
"campaignCode",
|
|
5
|
+
"member",
|
|
6
|
+
"memberTier",
|
|
7
|
+
"memberSegment",
|
|
8
|
+
"rewardFulfillment",
|
|
9
|
+
]);
|
|
10
|
+
// Export status enum
|
|
11
|
+
export const ExportStatusEnum = z.enum([
|
|
12
|
+
"pending",
|
|
13
|
+
"done",
|
|
14
|
+
"failed",
|
|
15
|
+
"error",
|
|
16
|
+
]);
|
|
17
|
+
// Export schema
|
|
18
|
+
export const ExportSchema = z.object({
|
|
19
|
+
exportId: z.string().describe("Unique export ID (UUID)."),
|
|
20
|
+
type: ExportTypeEnum.optional().describe("Export type."),
|
|
21
|
+
status: ExportStatusEnum.optional().describe("Export status: pending, done, failed, error."),
|
|
22
|
+
createdAt: z.string().optional().describe("Creation timestamp."),
|
|
23
|
+
finishedAt: z.string().optional().describe("Completion timestamp."),
|
|
24
|
+
criteria: z.string().optional().describe("Filter criteria used for export."),
|
|
25
|
+
exportedRows: z.number().optional().describe("Number of rows exported."),
|
|
26
|
+
message: z.string().optional().describe("Status message or error description."),
|
|
27
|
+
});
|
|
28
|
+
// Export list response
|
|
29
|
+
export const ExportListResponseSchema = z.object({
|
|
30
|
+
items: z.array(ExportSchema),
|
|
31
|
+
total: z.object({
|
|
32
|
+
all: z.union([z.number(), z.string()]).optional(),
|
|
33
|
+
filtered: z.union([z.number(), z.string()]).optional(),
|
|
34
|
+
estimated: z.boolean().optional(),
|
|
35
|
+
}).optional(),
|
|
36
|
+
});
|
|
37
|
+
// Export create input schema - filters vary by type
|
|
38
|
+
export const ExportCreateInputSchema = z.object({
|
|
39
|
+
type: ExportTypeEnum.describe("Export type: campaignCode, member, memberTier, memberSegment, rewardFulfillment."),
|
|
40
|
+
filters: z.record(z.unknown()).optional().describe("Type-specific filters. For campaignCode: { campaignId?, code?, status?, codeId?, usedByMemberId?, createdAt?, usedAt? }. For member exports: member-specific filters."),
|
|
41
|
+
page: z.number().optional().describe("Page number for export."),
|
|
42
|
+
perPage: z.number().optional().describe("Items per page for export."),
|
|
43
|
+
});
|