@open-loyalty/mcp-server 1.0.2 → 1.1.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/dist/client/http.d.ts +5 -0
- package/dist/client/http.js +52 -3
- package/dist/config.d.ts +16 -2
- package/dist/config.js +28 -10
- package/dist/http.js +135 -62
- package/dist/server.js +8 -5
- package/dist/tools/achievement.d.ts +14 -0
- package/dist/tools/achievement.js +22 -15
- package/dist/tools/admin.d.ts +12 -0
- package/dist/tools/admin.js +12 -0
- package/dist/tools/analytics.d.ts +18 -0
- package/dist/tools/analytics.js +28 -19
- package/dist/tools/apikey.d.ts +7 -0
- package/dist/tools/apikey.js +7 -0
- package/dist/tools/audit.d.ts +4 -0
- package/dist/tools/audit.js +4 -0
- package/dist/tools/badge.d.ts +8 -0
- package/dist/tools/badge.js +13 -9
- package/dist/tools/campaign.d.ts +41 -16
- package/dist/tools/campaign.js +38 -25
- package/dist/tools/export.d.ts +8 -0
- package/dist/tools/export.js +13 -8
- package/dist/tools/import.d.ts +6 -0
- package/dist/tools/import.js +10 -6
- package/dist/tools/index.d.ts +3 -11
- package/dist/tools/index.js +4 -470
- package/dist/tools/member.d.ts +21 -0
- package/dist/tools/member.js +56 -62
- package/dist/tools/points.d.ts +12 -0
- package/dist/tools/points.js +30 -29
- package/dist/tools/reward.d.ts +18 -0
- package/dist/tools/reward.js +56 -66
- package/dist/tools/role.d.ts +20 -1
- package/dist/tools/role.js +13 -0
- package/dist/tools/segment.d.ts +19 -0
- package/dist/tools/segment.js +29 -19
- package/dist/tools/store.d.ts +8 -0
- package/dist/tools/store.js +8 -0
- package/dist/tools/tierset.d.ts +12 -0
- package/dist/tools/tierset.js +19 -13
- package/dist/tools/transaction.d.ts +12 -4
- package/dist/tools/transaction.js +13 -9
- package/dist/tools/wallet-type.d.ts +4 -0
- package/dist/tools/wallet-type.js +7 -5
- package/dist/tools/webhook.d.ts +17 -4
- package/dist/tools/webhook.js +58 -15
- package/dist/types/schemas/achievement.d.ts +0 -297
- package/dist/types/schemas/achievement.js +0 -13
- package/dist/types/schemas/admin.d.ts +10 -97
- package/dist/types/schemas/admin.js +0 -38
- package/dist/types/schemas/badge.d.ts +0 -37
- package/dist/types/schemas/badge.js +0 -11
- package/dist/types/schemas/campaign.d.ts +0 -648
- package/dist/types/schemas/campaign.js +0 -18
- package/dist/types/schemas/export.d.ts +0 -17
- package/dist/types/schemas/export.js +0 -7
- package/dist/types/schemas/member.d.ts +37 -176
- package/dist/types/schemas/member.js +0 -27
- package/dist/types/schemas/points.d.ts +0 -63
- package/dist/types/schemas/points.js +0 -22
- package/dist/types/schemas/reward.d.ts +0 -73
- package/dist/types/schemas/reward.js +0 -25
- package/dist/types/schemas/role.d.ts +0 -100
- package/dist/types/schemas/role.js +0 -29
- package/dist/types/schemas/segment.d.ts +0 -58
- package/dist/types/schemas/segment.js +0 -17
- package/dist/types/schemas/tierset.d.ts +0 -176
- package/dist/types/schemas/tierset.js +0 -27
- package/dist/types/schemas/transaction.d.ts +23 -254
- package/dist/types/schemas/transaction.js +0 -7
- package/dist/types/schemas/webhook.d.ts +0 -58
- package/dist/types/schemas/webhook.js +0 -12
- package/dist/utils/payload.d.ts +12 -0
- package/dist/utils/payload.js +14 -0
- package/package.json +3 -1
package/dist/tools/webhook.js
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { apiGet, apiPost, apiPut, apiDelete } from "../client/http.js";
|
|
3
3
|
import { formatApiError } from "../utils/errors.js";
|
|
4
|
-
import {
|
|
4
|
+
import { getStoreCode } from "../config.js";
|
|
5
|
+
// SSRF protection: validate webhook URLs are external HTTPS endpoints
|
|
6
|
+
function isValidWebhookUrl(url) {
|
|
7
|
+
try {
|
|
8
|
+
const parsed = new URL(url);
|
|
9
|
+
// Must be HTTPS
|
|
10
|
+
if (parsed.protocol !== "https:") {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const hostname = parsed.hostname.toLowerCase();
|
|
14
|
+
// Block localhost and loopback
|
|
15
|
+
if (hostname === "localhost" ||
|
|
16
|
+
hostname === "127.0.0.1" ||
|
|
17
|
+
hostname === "0.0.0.0" ||
|
|
18
|
+
hostname === "::1" ||
|
|
19
|
+
hostname.endsWith(".localhost")) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
// Block cloud metadata endpoints
|
|
23
|
+
if (hostname === "169.254.169.254" || hostname === "metadata.google.internal") {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
// Block private IP ranges (basic check for common patterns)
|
|
27
|
+
if (hostname.startsWith("10.") ||
|
|
28
|
+
hostname.startsWith("192.168.") ||
|
|
29
|
+
hostname.match(/^172\.(1[6-9]|2[0-9]|3[0-1])\./)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const webhookUrlSchema = z.string()
|
|
39
|
+
.url("Must be a valid URL")
|
|
40
|
+
.refine(isValidWebhookUrl, "URL must be an external HTTPS endpoint (no localhost, private IPs, or metadata endpoints)");
|
|
5
41
|
// Input Schemas
|
|
6
42
|
export const WebhookListInputSchema = {
|
|
7
43
|
storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
|
|
@@ -13,7 +49,7 @@ export const WebhookListInputSchema = {
|
|
|
13
49
|
export const WebhookCreateInputSchema = {
|
|
14
50
|
storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
|
|
15
51
|
eventName: z.string().describe("Event name to subscribe to. Use webhook_events to discover available events."),
|
|
16
|
-
url:
|
|
52
|
+
url: webhookUrlSchema.describe("HTTPS URL to receive webhook events. Must be an external endpoint (no localhost or private IPs)."),
|
|
17
53
|
headers: z.array(z.object({
|
|
18
54
|
headerName: z.string().describe("Header name."),
|
|
19
55
|
headerValue: z.string().describe("Header value."),
|
|
@@ -27,7 +63,7 @@ export const WebhookUpdateInputSchema = {
|
|
|
27
63
|
storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
|
|
28
64
|
webhookSubscriptionId: z.string().describe("The webhook subscription ID (UUID) to update."),
|
|
29
65
|
eventName: z.string().optional().describe("Event name to subscribe to."),
|
|
30
|
-
url:
|
|
66
|
+
url: webhookUrlSchema.optional().describe("HTTPS URL to receive webhook events. Must be an external endpoint (no localhost or private IPs)."),
|
|
31
67
|
headers: z.array(z.object({
|
|
32
68
|
headerName: z.string().describe("Header name."),
|
|
33
69
|
headerValue: z.string().describe("Header value."),
|
|
@@ -42,8 +78,7 @@ export const WebhookEventsInputSchema = {
|
|
|
42
78
|
};
|
|
43
79
|
// Handler functions
|
|
44
80
|
export async function webhookList(input) {
|
|
45
|
-
const
|
|
46
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
81
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
47
82
|
const params = new URLSearchParams();
|
|
48
83
|
if (input.page)
|
|
49
84
|
params.append("_page", String(input.page));
|
|
@@ -64,8 +99,7 @@ export async function webhookList(input) {
|
|
|
64
99
|
}
|
|
65
100
|
}
|
|
66
101
|
export async function webhookCreate(input) {
|
|
67
|
-
const
|
|
68
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
102
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
69
103
|
const payload = {
|
|
70
104
|
eventName: input.eventName,
|
|
71
105
|
url: input.url,
|
|
@@ -82,8 +116,7 @@ export async function webhookCreate(input) {
|
|
|
82
116
|
}
|
|
83
117
|
}
|
|
84
118
|
export async function webhookGet(input) {
|
|
85
|
-
const
|
|
86
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
119
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
87
120
|
try {
|
|
88
121
|
const response = await apiGet(`/${storeCode}/webhook/subscription/${input.webhookSubscriptionId}`);
|
|
89
122
|
return response;
|
|
@@ -93,8 +126,7 @@ export async function webhookGet(input) {
|
|
|
93
126
|
}
|
|
94
127
|
}
|
|
95
128
|
export async function webhookUpdate(input) {
|
|
96
|
-
const
|
|
97
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
129
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
98
130
|
const payload = {};
|
|
99
131
|
if (input.eventName)
|
|
100
132
|
payload.eventName = input.eventName;
|
|
@@ -110,8 +142,7 @@ export async function webhookUpdate(input) {
|
|
|
110
142
|
}
|
|
111
143
|
}
|
|
112
144
|
export async function webhookDelete(input) {
|
|
113
|
-
const
|
|
114
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
145
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
115
146
|
try {
|
|
116
147
|
await apiDelete(`/${storeCode}/webhook/subscription/${input.webhookSubscriptionId}`);
|
|
117
148
|
}
|
|
@@ -120,8 +151,7 @@ export async function webhookDelete(input) {
|
|
|
120
151
|
}
|
|
121
152
|
}
|
|
122
153
|
export async function webhookEvents(input) {
|
|
123
|
-
const
|
|
124
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
154
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
125
155
|
try {
|
|
126
156
|
const response = await apiGet(`/${storeCode}/webhook/event`);
|
|
127
157
|
return response;
|
|
@@ -134,37 +164,50 @@ export async function webhookEvents(input) {
|
|
|
134
164
|
export const webhookToolDefinitions = [
|
|
135
165
|
{
|
|
136
166
|
name: "openloyalty_webhook_list",
|
|
167
|
+
title: "List Webhook Subscriptions",
|
|
137
168
|
description: "List webhook subscriptions with optional filtering. Returns paginated list of subscriptions with webhookSubscriptionId, eventName, url, and createdAt.",
|
|
169
|
+
readOnly: true,
|
|
138
170
|
inputSchema: WebhookListInputSchema,
|
|
139
171
|
handler: webhookList,
|
|
140
172
|
},
|
|
141
173
|
{
|
|
142
174
|
name: "openloyalty_webhook_create",
|
|
175
|
+
title: "Create Webhook Subscription",
|
|
143
176
|
description: "Create a new webhook subscription to receive event notifications. Returns webhookSubscriptionId on success. Use webhook_events to discover available event types before creating subscriptions.",
|
|
177
|
+
readOnly: false,
|
|
144
178
|
inputSchema: WebhookCreateInputSchema,
|
|
145
179
|
handler: webhookCreate,
|
|
146
180
|
},
|
|
147
181
|
{
|
|
148
182
|
name: "openloyalty_webhook_get",
|
|
183
|
+
title: "Get Webhook Subscription Details",
|
|
149
184
|
description: "Get full webhook subscription details including headers configuration.",
|
|
185
|
+
readOnly: true,
|
|
150
186
|
inputSchema: WebhookGetInputSchema,
|
|
151
187
|
handler: webhookGet,
|
|
152
188
|
},
|
|
153
189
|
{
|
|
154
190
|
name: "openloyalty_webhook_update",
|
|
191
|
+
title: "Update Webhook Subscription",
|
|
155
192
|
description: "Update a webhook subscription. Can update eventName, url, and headers. Returns void on success (204 No Content).",
|
|
193
|
+
readOnly: false,
|
|
156
194
|
inputSchema: WebhookUpdateInputSchema,
|
|
157
195
|
handler: webhookUpdate,
|
|
158
196
|
},
|
|
159
197
|
{
|
|
160
198
|
name: "openloyalty_webhook_delete",
|
|
199
|
+
title: "Delete Webhook Subscription (Permanent)",
|
|
161
200
|
description: "Delete a webhook subscription. Returns void on success (204 No Content). The subscription will stop receiving events immediately.",
|
|
201
|
+
readOnly: false,
|
|
202
|
+
destructive: true,
|
|
162
203
|
inputSchema: WebhookDeleteInputSchema,
|
|
163
204
|
handler: webhookDelete,
|
|
164
205
|
},
|
|
165
206
|
{
|
|
166
207
|
name: "openloyalty_webhook_events",
|
|
208
|
+
title: "List Available Webhook Events",
|
|
167
209
|
description: "Get available webhook event types. Returns list of event names that can be used when creating webhook subscriptions. Use this to discover available events before creating subscriptions.",
|
|
210
|
+
readOnly: true,
|
|
168
211
|
inputSchema: WebhookEventsInputSchema,
|
|
169
212
|
handler: webhookEvents,
|
|
170
213
|
},
|
|
@@ -607,303 +607,6 @@ export declare const AchievementListItemSchema: z.ZodObject<{
|
|
|
607
607
|
badgeTypeId?: string | undefined;
|
|
608
608
|
}>;
|
|
609
609
|
export type AchievementListItem = z.infer<typeof AchievementListItemSchema>;
|
|
610
|
-
/**
|
|
611
|
-
* Achievement Create Input Schema.
|
|
612
|
-
* Matches the POST /api/{storeCode}/achievement body structure.
|
|
613
|
-
* IMPORTANT: Request must be wrapped as { achievement: {...} }
|
|
614
|
-
*/
|
|
615
|
-
export declare const AchievementCreateInputSchema: z.ZodObject<{
|
|
616
|
-
translations: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
617
|
-
name: z.ZodString;
|
|
618
|
-
description: z.ZodOptional<z.ZodString>;
|
|
619
|
-
}, "strip", z.ZodTypeAny, {
|
|
620
|
-
name: string;
|
|
621
|
-
description?: string | undefined;
|
|
622
|
-
}, {
|
|
623
|
-
name: string;
|
|
624
|
-
description?: string | undefined;
|
|
625
|
-
}>>;
|
|
626
|
-
active: z.ZodOptional<z.ZodBoolean>;
|
|
627
|
-
activity: z.ZodOptional<z.ZodObject<{
|
|
628
|
-
startsAt: z.ZodOptional<z.ZodString>;
|
|
629
|
-
endsAt: z.ZodOptional<z.ZodString>;
|
|
630
|
-
data: z.ZodOptional<z.ZodString>;
|
|
631
|
-
operator: z.ZodOptional<z.ZodString>;
|
|
632
|
-
}, "strip", z.ZodTypeAny, {
|
|
633
|
-
data?: string | undefined;
|
|
634
|
-
operator?: string | undefined;
|
|
635
|
-
startsAt?: string | undefined;
|
|
636
|
-
endsAt?: string | undefined;
|
|
637
|
-
}, {
|
|
638
|
-
data?: string | undefined;
|
|
639
|
-
operator?: string | undefined;
|
|
640
|
-
startsAt?: string | undefined;
|
|
641
|
-
endsAt?: string | undefined;
|
|
642
|
-
}>>;
|
|
643
|
-
limit: z.ZodOptional<z.ZodObject<{
|
|
644
|
-
value: z.ZodOptional<z.ZodNumber>;
|
|
645
|
-
interval: z.ZodOptional<z.ZodObject<{
|
|
646
|
-
type: z.ZodString;
|
|
647
|
-
value: z.ZodOptional<z.ZodNumber>;
|
|
648
|
-
}, "strip", z.ZodTypeAny, {
|
|
649
|
-
type: string;
|
|
650
|
-
value?: number | undefined;
|
|
651
|
-
}, {
|
|
652
|
-
type: string;
|
|
653
|
-
value?: number | undefined;
|
|
654
|
-
}>>;
|
|
655
|
-
}, "strip", z.ZodTypeAny, {
|
|
656
|
-
value?: number | undefined;
|
|
657
|
-
interval?: {
|
|
658
|
-
type: string;
|
|
659
|
-
value?: number | undefined;
|
|
660
|
-
} | undefined;
|
|
661
|
-
}, {
|
|
662
|
-
value?: number | undefined;
|
|
663
|
-
interval?: {
|
|
664
|
-
type: string;
|
|
665
|
-
value?: number | undefined;
|
|
666
|
-
} | undefined;
|
|
667
|
-
}>>;
|
|
668
|
-
rules: z.ZodArray<z.ZodObject<{
|
|
669
|
-
achievementRuleId: z.ZodOptional<z.ZodString>;
|
|
670
|
-
translations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
671
|
-
name: z.ZodString;
|
|
672
|
-
description: z.ZodOptional<z.ZodString>;
|
|
673
|
-
}, "strip", z.ZodTypeAny, {
|
|
674
|
-
name: string;
|
|
675
|
-
description?: string | undefined;
|
|
676
|
-
}, {
|
|
677
|
-
name: string;
|
|
678
|
-
description?: string | undefined;
|
|
679
|
-
}>>>;
|
|
680
|
-
trigger: z.ZodOptional<z.ZodString>;
|
|
681
|
-
type: z.ZodOptional<z.ZodString>;
|
|
682
|
-
event: z.ZodOptional<z.ZodString>;
|
|
683
|
-
completeRule: z.ZodObject<{
|
|
684
|
-
periodGoal: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
|
|
685
|
-
period: z.ZodOptional<z.ZodObject<{
|
|
686
|
-
consecutive: z.ZodOptional<z.ZodNumber>;
|
|
687
|
-
value: z.ZodOptional<z.ZodNumber>;
|
|
688
|
-
}, "strip", z.ZodTypeAny, {
|
|
689
|
-
value?: number | undefined;
|
|
690
|
-
consecutive?: number | undefined;
|
|
691
|
-
}, {
|
|
692
|
-
value?: number | undefined;
|
|
693
|
-
consecutive?: number | undefined;
|
|
694
|
-
}>>;
|
|
695
|
-
uniqueAttribute: z.ZodOptional<z.ZodString>;
|
|
696
|
-
}, "strip", z.ZodTypeAny, {
|
|
697
|
-
periodGoal: string | number;
|
|
698
|
-
period?: {
|
|
699
|
-
value?: number | undefined;
|
|
700
|
-
consecutive?: number | undefined;
|
|
701
|
-
} | undefined;
|
|
702
|
-
uniqueAttribute?: string | undefined;
|
|
703
|
-
}, {
|
|
704
|
-
periodGoal: string | number;
|
|
705
|
-
period?: {
|
|
706
|
-
value?: number | undefined;
|
|
707
|
-
consecutive?: number | undefined;
|
|
708
|
-
} | undefined;
|
|
709
|
-
uniqueAttribute?: string | undefined;
|
|
710
|
-
}>;
|
|
711
|
-
aggregation: z.ZodOptional<z.ZodObject<{
|
|
712
|
-
rule: z.ZodOptional<z.ZodString>;
|
|
713
|
-
}, "strip", z.ZodTypeAny, {
|
|
714
|
-
rule?: string | undefined;
|
|
715
|
-
}, {
|
|
716
|
-
rule?: string | undefined;
|
|
717
|
-
}>>;
|
|
718
|
-
conditions: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
719
|
-
limit: z.ZodOptional<z.ZodObject<{
|
|
720
|
-
value: z.ZodOptional<z.ZodNumber>;
|
|
721
|
-
interval: z.ZodOptional<z.ZodObject<{
|
|
722
|
-
type: z.ZodString;
|
|
723
|
-
value: z.ZodOptional<z.ZodNumber>;
|
|
724
|
-
}, "strip", z.ZodTypeAny, {
|
|
725
|
-
type: string;
|
|
726
|
-
value?: number | undefined;
|
|
727
|
-
}, {
|
|
728
|
-
type: string;
|
|
729
|
-
value?: number | undefined;
|
|
730
|
-
}>>;
|
|
731
|
-
}, "strip", z.ZodTypeAny, {
|
|
732
|
-
value?: number | undefined;
|
|
733
|
-
interval?: {
|
|
734
|
-
type: string;
|
|
735
|
-
value?: number | undefined;
|
|
736
|
-
} | undefined;
|
|
737
|
-
}, {
|
|
738
|
-
value?: number | undefined;
|
|
739
|
-
interval?: {
|
|
740
|
-
type: string;
|
|
741
|
-
value?: number | undefined;
|
|
742
|
-
} | undefined;
|
|
743
|
-
}>>;
|
|
744
|
-
uniqueReferee: z.ZodOptional<z.ZodBoolean>;
|
|
745
|
-
}, "strip", z.ZodTypeAny, {
|
|
746
|
-
completeRule: {
|
|
747
|
-
periodGoal: string | number;
|
|
748
|
-
period?: {
|
|
749
|
-
value?: number | undefined;
|
|
750
|
-
consecutive?: number | undefined;
|
|
751
|
-
} | undefined;
|
|
752
|
-
uniqueAttribute?: string | undefined;
|
|
753
|
-
};
|
|
754
|
-
type?: string | undefined;
|
|
755
|
-
conditions?: Record<string, unknown>[] | undefined;
|
|
756
|
-
translations?: Record<string, {
|
|
757
|
-
name: string;
|
|
758
|
-
description?: string | undefined;
|
|
759
|
-
}> | undefined;
|
|
760
|
-
trigger?: string | undefined;
|
|
761
|
-
event?: string | undefined;
|
|
762
|
-
achievementRuleId?: string | undefined;
|
|
763
|
-
aggregation?: {
|
|
764
|
-
rule?: string | undefined;
|
|
765
|
-
} | undefined;
|
|
766
|
-
limit?: {
|
|
767
|
-
value?: number | undefined;
|
|
768
|
-
interval?: {
|
|
769
|
-
type: string;
|
|
770
|
-
value?: number | undefined;
|
|
771
|
-
} | undefined;
|
|
772
|
-
} | undefined;
|
|
773
|
-
uniqueReferee?: boolean | undefined;
|
|
774
|
-
}, {
|
|
775
|
-
completeRule: {
|
|
776
|
-
periodGoal: string | number;
|
|
777
|
-
period?: {
|
|
778
|
-
value?: number | undefined;
|
|
779
|
-
consecutive?: number | undefined;
|
|
780
|
-
} | undefined;
|
|
781
|
-
uniqueAttribute?: string | undefined;
|
|
782
|
-
};
|
|
783
|
-
type?: string | undefined;
|
|
784
|
-
conditions?: Record<string, unknown>[] | undefined;
|
|
785
|
-
translations?: Record<string, {
|
|
786
|
-
name: string;
|
|
787
|
-
description?: string | undefined;
|
|
788
|
-
}> | undefined;
|
|
789
|
-
trigger?: string | undefined;
|
|
790
|
-
event?: string | undefined;
|
|
791
|
-
achievementRuleId?: string | undefined;
|
|
792
|
-
aggregation?: {
|
|
793
|
-
rule?: string | undefined;
|
|
794
|
-
} | undefined;
|
|
795
|
-
limit?: {
|
|
796
|
-
value?: number | undefined;
|
|
797
|
-
interval?: {
|
|
798
|
-
type: string;
|
|
799
|
-
value?: number | undefined;
|
|
800
|
-
} | undefined;
|
|
801
|
-
} | undefined;
|
|
802
|
-
uniqueReferee?: boolean | undefined;
|
|
803
|
-
}>, "many">;
|
|
804
|
-
badgeTypeId: z.ZodOptional<z.ZodString>;
|
|
805
|
-
}, "strip", z.ZodTypeAny, {
|
|
806
|
-
translations: Record<string, {
|
|
807
|
-
name: string;
|
|
808
|
-
description?: string | undefined;
|
|
809
|
-
}>;
|
|
810
|
-
rules: {
|
|
811
|
-
completeRule: {
|
|
812
|
-
periodGoal: string | number;
|
|
813
|
-
period?: {
|
|
814
|
-
value?: number | undefined;
|
|
815
|
-
consecutive?: number | undefined;
|
|
816
|
-
} | undefined;
|
|
817
|
-
uniqueAttribute?: string | undefined;
|
|
818
|
-
};
|
|
819
|
-
type?: string | undefined;
|
|
820
|
-
conditions?: Record<string, unknown>[] | undefined;
|
|
821
|
-
translations?: Record<string, {
|
|
822
|
-
name: string;
|
|
823
|
-
description?: string | undefined;
|
|
824
|
-
}> | undefined;
|
|
825
|
-
trigger?: string | undefined;
|
|
826
|
-
event?: string | undefined;
|
|
827
|
-
achievementRuleId?: string | undefined;
|
|
828
|
-
aggregation?: {
|
|
829
|
-
rule?: string | undefined;
|
|
830
|
-
} | undefined;
|
|
831
|
-
limit?: {
|
|
832
|
-
value?: number | undefined;
|
|
833
|
-
interval?: {
|
|
834
|
-
type: string;
|
|
835
|
-
value?: number | undefined;
|
|
836
|
-
} | undefined;
|
|
837
|
-
} | undefined;
|
|
838
|
-
uniqueReferee?: boolean | undefined;
|
|
839
|
-
}[];
|
|
840
|
-
active?: boolean | undefined;
|
|
841
|
-
activity?: {
|
|
842
|
-
data?: string | undefined;
|
|
843
|
-
operator?: string | undefined;
|
|
844
|
-
startsAt?: string | undefined;
|
|
845
|
-
endsAt?: string | undefined;
|
|
846
|
-
} | undefined;
|
|
847
|
-
limit?: {
|
|
848
|
-
value?: number | undefined;
|
|
849
|
-
interval?: {
|
|
850
|
-
type: string;
|
|
851
|
-
value?: number | undefined;
|
|
852
|
-
} | undefined;
|
|
853
|
-
} | undefined;
|
|
854
|
-
badgeTypeId?: string | undefined;
|
|
855
|
-
}, {
|
|
856
|
-
translations: Record<string, {
|
|
857
|
-
name: string;
|
|
858
|
-
description?: string | undefined;
|
|
859
|
-
}>;
|
|
860
|
-
rules: {
|
|
861
|
-
completeRule: {
|
|
862
|
-
periodGoal: string | number;
|
|
863
|
-
period?: {
|
|
864
|
-
value?: number | undefined;
|
|
865
|
-
consecutive?: number | undefined;
|
|
866
|
-
} | undefined;
|
|
867
|
-
uniqueAttribute?: string | undefined;
|
|
868
|
-
};
|
|
869
|
-
type?: string | undefined;
|
|
870
|
-
conditions?: Record<string, unknown>[] | undefined;
|
|
871
|
-
translations?: Record<string, {
|
|
872
|
-
name: string;
|
|
873
|
-
description?: string | undefined;
|
|
874
|
-
}> | undefined;
|
|
875
|
-
trigger?: string | undefined;
|
|
876
|
-
event?: string | undefined;
|
|
877
|
-
achievementRuleId?: string | undefined;
|
|
878
|
-
aggregation?: {
|
|
879
|
-
rule?: string | undefined;
|
|
880
|
-
} | undefined;
|
|
881
|
-
limit?: {
|
|
882
|
-
value?: number | undefined;
|
|
883
|
-
interval?: {
|
|
884
|
-
type: string;
|
|
885
|
-
value?: number | undefined;
|
|
886
|
-
} | undefined;
|
|
887
|
-
} | undefined;
|
|
888
|
-
uniqueReferee?: boolean | undefined;
|
|
889
|
-
}[];
|
|
890
|
-
active?: boolean | undefined;
|
|
891
|
-
activity?: {
|
|
892
|
-
data?: string | undefined;
|
|
893
|
-
operator?: string | undefined;
|
|
894
|
-
startsAt?: string | undefined;
|
|
895
|
-
endsAt?: string | undefined;
|
|
896
|
-
} | undefined;
|
|
897
|
-
limit?: {
|
|
898
|
-
value?: number | undefined;
|
|
899
|
-
interval?: {
|
|
900
|
-
type: string;
|
|
901
|
-
value?: number | undefined;
|
|
902
|
-
} | undefined;
|
|
903
|
-
} | undefined;
|
|
904
|
-
badgeTypeId?: string | undefined;
|
|
905
|
-
}>;
|
|
906
|
-
export type AchievementCreateInput = z.infer<typeof AchievementCreateInputSchema>;
|
|
907
610
|
/**
|
|
908
611
|
* Achievement Rule Progress Schema.
|
|
909
612
|
* Tracks a member's progress on a single rule.
|
|
@@ -123,19 +123,6 @@ export const AchievementListItemSchema = z.object({
|
|
|
123
123
|
createdAt: z.string().optional(),
|
|
124
124
|
badgeTypeId: z.string().optional(),
|
|
125
125
|
});
|
|
126
|
-
/**
|
|
127
|
-
* Achievement Create Input Schema.
|
|
128
|
-
* Matches the POST /api/{storeCode}/achievement body structure.
|
|
129
|
-
* IMPORTANT: Request must be wrapped as { achievement: {...} }
|
|
130
|
-
*/
|
|
131
|
-
export const AchievementCreateInputSchema = z.object({
|
|
132
|
-
translations: TranslationsSchema.describe("Achievement name and description (at least 'en' required)."),
|
|
133
|
-
active: z.boolean().optional().describe("Whether achievement is active (default: false)."),
|
|
134
|
-
activity: AchievementActivitySchema.optional().describe("Time period configuration."),
|
|
135
|
-
limit: AchievementLimitSchema.optional().describe("Limit configuration."),
|
|
136
|
-
rules: z.array(AchievementRuleSchema).describe("Achievement rules."),
|
|
137
|
-
badgeTypeId: z.string().optional().describe("Badge type to award."),
|
|
138
|
-
});
|
|
139
126
|
/**
|
|
140
127
|
* Achievement Rule Progress Schema.
|
|
141
128
|
* Tracks a member's progress on a single rule.
|
|
@@ -79,12 +79,12 @@ export declare const AdminUserSchema: z.ZodObject<{
|
|
|
79
79
|
createdAt: z.ZodOptional<z.ZodString>;
|
|
80
80
|
dtype: z.ZodOptional<z.ZodString>;
|
|
81
81
|
}, "strip", z.ZodTypeAny, {
|
|
82
|
-
createdAt?: string | undefined;
|
|
83
|
-
id?: string | undefined;
|
|
84
82
|
email?: string | undefined;
|
|
83
|
+
phone?: string | undefined;
|
|
85
84
|
firstName?: string | undefined;
|
|
86
85
|
lastName?: string | undefined;
|
|
87
|
-
|
|
86
|
+
createdAt?: string | undefined;
|
|
87
|
+
id?: string | undefined;
|
|
88
88
|
adminId?: string | undefined;
|
|
89
89
|
username?: string | undefined;
|
|
90
90
|
isActive?: boolean | undefined;
|
|
@@ -102,12 +102,12 @@ export declare const AdminUserSchema: z.ZodObject<{
|
|
|
102
102
|
} | undefined;
|
|
103
103
|
dtype?: string | undefined;
|
|
104
104
|
}, {
|
|
105
|
-
createdAt?: string | undefined;
|
|
106
|
-
id?: string | undefined;
|
|
107
105
|
email?: string | undefined;
|
|
106
|
+
phone?: string | undefined;
|
|
108
107
|
firstName?: string | undefined;
|
|
109
108
|
lastName?: string | undefined;
|
|
110
|
-
|
|
109
|
+
createdAt?: string | undefined;
|
|
110
|
+
id?: string | undefined;
|
|
111
111
|
adminId?: string | undefined;
|
|
112
112
|
username?: string | undefined;
|
|
113
113
|
isActive?: boolean | undefined;
|
|
@@ -139,95 +139,23 @@ export declare const AdminUserListItemSchema: z.ZodObject<{
|
|
|
139
139
|
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
140
140
|
createdAt: z.ZodOptional<z.ZodString>;
|
|
141
141
|
}, "strip", z.ZodTypeAny, {
|
|
142
|
-
createdAt?: string | undefined;
|
|
143
|
-
id?: string | undefined;
|
|
144
142
|
email?: string | undefined;
|
|
145
143
|
firstName?: string | undefined;
|
|
146
144
|
lastName?: string | undefined;
|
|
147
|
-
username?: string | undefined;
|
|
148
|
-
isActive?: boolean | undefined;
|
|
149
|
-
}, {
|
|
150
145
|
createdAt?: string | undefined;
|
|
151
146
|
id?: string | undefined;
|
|
152
|
-
email?: string | undefined;
|
|
153
|
-
firstName?: string | undefined;
|
|
154
|
-
lastName?: string | undefined;
|
|
155
147
|
username?: string | undefined;
|
|
156
148
|
isActive?: boolean | undefined;
|
|
157
|
-
}>;
|
|
158
|
-
export type AdminUserListItem = z.infer<typeof AdminUserListItemSchema>;
|
|
159
|
-
/**
|
|
160
|
-
* Admin User Create Input Schema.
|
|
161
|
-
* Input for POST /api/admin/data - uses { admin: {...} } wrapper
|
|
162
|
-
*/
|
|
163
|
-
export declare const AdminUserCreateInputSchema: z.ZodObject<{
|
|
164
|
-
email: z.ZodString;
|
|
165
|
-
plainPassword: z.ZodString;
|
|
166
|
-
firstName: z.ZodOptional<z.ZodString>;
|
|
167
|
-
lastName: z.ZodOptional<z.ZodString>;
|
|
168
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
169
|
-
roles: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
|
|
170
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
171
|
-
external: z.ZodOptional<z.ZodBoolean>;
|
|
172
|
-
notificationsEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
173
|
-
}, "strip", z.ZodTypeAny, {
|
|
174
|
-
email: string;
|
|
175
|
-
plainPassword: string;
|
|
176
|
-
firstName?: string | undefined;
|
|
177
|
-
lastName?: string | undefined;
|
|
178
|
-
phone?: string | undefined;
|
|
179
|
-
notificationsEnabled?: boolean | undefined;
|
|
180
|
-
isActive?: boolean | undefined;
|
|
181
|
-
external?: boolean | undefined;
|
|
182
|
-
roles?: (string | number)[] | undefined;
|
|
183
|
-
}, {
|
|
184
|
-
email: string;
|
|
185
|
-
plainPassword: string;
|
|
186
|
-
firstName?: string | undefined;
|
|
187
|
-
lastName?: string | undefined;
|
|
188
|
-
phone?: string | undefined;
|
|
189
|
-
notificationsEnabled?: boolean | undefined;
|
|
190
|
-
isActive?: boolean | undefined;
|
|
191
|
-
external?: boolean | undefined;
|
|
192
|
-
roles?: (string | number)[] | undefined;
|
|
193
|
-
}>;
|
|
194
|
-
export type AdminUserCreateInput = z.infer<typeof AdminUserCreateInputSchema>;
|
|
195
|
-
/**
|
|
196
|
-
* Admin User Update Input Schema.
|
|
197
|
-
* Input for PUT /api/admin/data/{adminId} - uses { admin: {...} } wrapper
|
|
198
|
-
*/
|
|
199
|
-
export declare const AdminUserUpdateInputSchema: z.ZodObject<{
|
|
200
|
-
email: z.ZodOptional<z.ZodString>;
|
|
201
|
-
firstName: z.ZodOptional<z.ZodString>;
|
|
202
|
-
lastName: z.ZodOptional<z.ZodString>;
|
|
203
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
204
|
-
roles: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
|
|
205
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
206
|
-
external: z.ZodOptional<z.ZodBoolean>;
|
|
207
|
-
notificationsEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
208
|
-
plainPassword: z.ZodOptional<z.ZodString>;
|
|
209
|
-
}, "strip", z.ZodTypeAny, {
|
|
210
|
-
email?: string | undefined;
|
|
211
|
-
firstName?: string | undefined;
|
|
212
|
-
lastName?: string | undefined;
|
|
213
|
-
phone?: string | undefined;
|
|
214
|
-
notificationsEnabled?: boolean | undefined;
|
|
215
|
-
isActive?: boolean | undefined;
|
|
216
|
-
external?: boolean | undefined;
|
|
217
|
-
roles?: (string | number)[] | undefined;
|
|
218
|
-
plainPassword?: string | undefined;
|
|
219
149
|
}, {
|
|
220
150
|
email?: string | undefined;
|
|
221
151
|
firstName?: string | undefined;
|
|
222
152
|
lastName?: string | undefined;
|
|
223
|
-
|
|
224
|
-
|
|
153
|
+
createdAt?: string | undefined;
|
|
154
|
+
id?: string | undefined;
|
|
155
|
+
username?: string | undefined;
|
|
225
156
|
isActive?: boolean | undefined;
|
|
226
|
-
external?: boolean | undefined;
|
|
227
|
-
roles?: (string | number)[] | undefined;
|
|
228
|
-
plainPassword?: string | undefined;
|
|
229
157
|
}>;
|
|
230
|
-
export type
|
|
158
|
+
export type AdminUserListItem = z.infer<typeof AdminUserListItemSchema>;
|
|
231
159
|
/**
|
|
232
160
|
* Admin Permission Schema.
|
|
233
161
|
* Represents admin permissions.
|
|
@@ -246,18 +174,3 @@ export declare const AdminPermissionSchema: z.ZodObject<{
|
|
|
246
174
|
permissions?: string[] | undefined;
|
|
247
175
|
}>;
|
|
248
176
|
export type AdminPermission = z.infer<typeof AdminPermissionSchema>;
|
|
249
|
-
/**
|
|
250
|
-
* Change Password Input Schema.
|
|
251
|
-
* Input for PUT /api/admin/password
|
|
252
|
-
*/
|
|
253
|
-
export declare const ChangePasswordInputSchema: z.ZodObject<{
|
|
254
|
-
currentPassword: z.ZodString;
|
|
255
|
-
plainPassword: z.ZodString;
|
|
256
|
-
}, "strip", z.ZodTypeAny, {
|
|
257
|
-
plainPassword: string;
|
|
258
|
-
currentPassword: string;
|
|
259
|
-
}, {
|
|
260
|
-
plainPassword: string;
|
|
261
|
-
currentPassword: string;
|
|
262
|
-
}>;
|
|
263
|
-
export type ChangePasswordInput = z.infer<typeof ChangePasswordInputSchema>;
|
|
@@ -50,36 +50,6 @@ export const AdminUserListItemSchema = z.object({
|
|
|
50
50
|
isActive: z.boolean().optional().describe("Whether admin account is active."),
|
|
51
51
|
createdAt: z.string().optional().describe("Account creation timestamp."),
|
|
52
52
|
});
|
|
53
|
-
/**
|
|
54
|
-
* Admin User Create Input Schema.
|
|
55
|
-
* Input for POST /api/admin/data - uses { admin: {...} } wrapper
|
|
56
|
-
*/
|
|
57
|
-
export const AdminUserCreateInputSchema = z.object({
|
|
58
|
-
email: z.string().describe("Admin email address (required)."),
|
|
59
|
-
plainPassword: z.string().describe("Admin password (required)."),
|
|
60
|
-
firstName: z.string().optional().describe("Admin first name."),
|
|
61
|
-
lastName: z.string().optional().describe("Admin last name."),
|
|
62
|
-
phone: z.string().optional().describe("Admin phone number."),
|
|
63
|
-
roles: z.array(z.union([z.string(), z.number()])).optional().describe("Role IDs to assign."),
|
|
64
|
-
isActive: z.boolean().optional().describe("Whether account is active (default: true)."),
|
|
65
|
-
external: z.boolean().optional().describe("Whether admin is external."),
|
|
66
|
-
notificationsEnabled: z.boolean().optional().describe("Whether notifications are enabled."),
|
|
67
|
-
});
|
|
68
|
-
/**
|
|
69
|
-
* Admin User Update Input Schema.
|
|
70
|
-
* Input for PUT /api/admin/data/{adminId} - uses { admin: {...} } wrapper
|
|
71
|
-
*/
|
|
72
|
-
export const AdminUserUpdateInputSchema = z.object({
|
|
73
|
-
email: z.string().optional().describe("Admin email address."),
|
|
74
|
-
firstName: z.string().optional().describe("Admin first name."),
|
|
75
|
-
lastName: z.string().optional().describe("Admin last name."),
|
|
76
|
-
phone: z.string().optional().describe("Admin phone number."),
|
|
77
|
-
roles: z.array(z.union([z.string(), z.number()])).optional().describe("Role IDs to assign."),
|
|
78
|
-
isActive: z.boolean().optional().describe("Whether account is active."),
|
|
79
|
-
external: z.boolean().optional().describe("Whether admin is external."),
|
|
80
|
-
notificationsEnabled: z.boolean().optional().describe("Whether notifications are enabled."),
|
|
81
|
-
plainPassword: z.string().optional().describe("New password (if changing)."),
|
|
82
|
-
});
|
|
83
53
|
/**
|
|
84
54
|
* Admin Permission Schema.
|
|
85
55
|
* Represents admin permissions.
|
|
@@ -89,11 +59,3 @@ export const AdminPermissionSchema = z.object({
|
|
|
89
59
|
roles: z.array(z.string()).optional().describe("List of role names."),
|
|
90
60
|
permissions: z.array(z.string()).optional().describe("List of permission strings."),
|
|
91
61
|
});
|
|
92
|
-
/**
|
|
93
|
-
* Change Password Input Schema.
|
|
94
|
-
* Input for PUT /api/admin/password
|
|
95
|
-
*/
|
|
96
|
-
export const ChangePasswordInputSchema = z.object({
|
|
97
|
-
currentPassword: z.string().describe("Current password."),
|
|
98
|
-
plainPassword: z.string().describe("New password."),
|
|
99
|
-
});
|