@open-loyalty/mcp-server 1.0.3 → 1.3.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/README.md +180 -177
- package/dist/auth/provider.js +2 -14
- package/dist/auth/storage.js +22 -0
- package/dist/client/http.d.ts +5 -0
- package/dist/client/http.js +62 -3
- package/dist/config.d.ts +6 -5
- package/dist/config.js +15 -11
- package/dist/http.js +170 -65
- package/dist/instructions.d.ts +5 -0
- package/dist/instructions.js +420 -0
- package/dist/prompts/fan-engagement-setup.d.ts +107 -0
- package/dist/prompts/fan-engagement-setup.js +492 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +68 -278
- package/dist/tools/achievement/handlers.d.ts +117 -0
- package/dist/tools/achievement/handlers.js +161 -0
- package/dist/tools/achievement/index.d.ts +479 -0
- package/dist/tools/achievement/index.js +74 -0
- package/dist/tools/achievement/schemas.d.ts +433 -0
- package/dist/tools/achievement/schemas.js +142 -0
- package/dist/tools/achievement.d.ts +155 -121
- package/dist/tools/achievement.js +82 -39
- package/dist/tools/admin.d.ts +18 -6
- package/dist/tools/admin.js +24 -12
- package/dist/tools/analytics.d.ts +29 -11
- package/dist/tools/analytics.js +58 -48
- package/dist/tools/apikey.d.ts +10 -3
- package/dist/tools/apikey.js +13 -6
- package/dist/tools/audit.d.ts +6 -2
- package/dist/tools/audit.js +8 -4
- package/dist/tools/badge.d.ts +14 -6
- package/dist/tools/badge.js +36 -27
- package/dist/tools/campaign/handlers.d.ts +42 -0
- package/dist/tools/campaign/handlers.js +223 -0
- package/dist/tools/campaign/index.d.ts +783 -0
- package/dist/tools/campaign/index.js +112 -0
- package/dist/tools/campaign/member-handlers.d.ts +60 -0
- package/dist/tools/campaign/member-handlers.js +159 -0
- package/dist/tools/campaign/schemas.d.ts +704 -0
- package/dist/tools/campaign/schemas.js +259 -0
- package/dist/tools/campaign/types.d.ts +161 -0
- package/dist/tools/campaign/types.js +2 -0
- package/dist/tools/campaign.d.ts +41 -16
- package/dist/tools/campaign.js +38 -25
- package/dist/tools/custom-event.d.ts +315 -0
- package/dist/tools/custom-event.js +270 -0
- package/dist/tools/export.d.ts +12 -4
- package/dist/tools/export.js +25 -20
- package/dist/tools/import.d.ts +9 -3
- package/dist/tools/import.js +33 -21
- package/dist/tools/index.d.ts +3 -11
- package/dist/tools/index.js +17 -475
- package/dist/tools/member/handlers.d.ts +111 -0
- package/dist/tools/member/handlers.js +206 -0
- package/dist/tools/member/index.d.ts +169 -0
- package/dist/tools/member/index.js +92 -0
- package/dist/tools/member/schemas.d.ts +89 -0
- package/dist/tools/member/schemas.js +65 -0
- package/dist/tools/member.d.ts +21 -0
- package/dist/tools/member.js +56 -62
- package/dist/tools/points.d.ts +19 -6
- package/dist/tools/points.js +51 -49
- package/dist/tools/referral/handlers.d.ts +47 -0
- package/dist/tools/referral/handlers.js +115 -0
- package/dist/tools/referral/index.d.ts +44 -0
- package/dist/tools/referral/index.js +44 -0
- package/dist/tools/referral/schemas.d.ts +34 -0
- package/dist/tools/referral/schemas.js +52 -0
- package/dist/tools/reward/handlers.d.ts +110 -0
- package/dist/tools/reward/handlers.js +289 -0
- package/dist/tools/reward/index.d.ts +177 -0
- package/dist/tools/reward/index.js +90 -0
- package/dist/tools/reward/schemas.d.ts +116 -0
- package/dist/tools/reward/schemas.js +91 -0
- package/dist/tools/reward.d.ts +18 -0
- package/dist/tools/reward.js +56 -66
- package/dist/tools/role.d.ts +26 -7
- package/dist/tools/role.js +25 -12
- package/dist/tools/segment/handlers.d.ts +87 -0
- package/dist/tools/segment/handlers.js +174 -0
- package/dist/tools/segment/index.d.ts +395 -0
- package/dist/tools/segment/index.js +87 -0
- package/dist/tools/segment/schemas.d.ts +337 -0
- package/dist/tools/segment/schemas.js +79 -0
- package/dist/tools/segment.d.ts +29 -10
- package/dist/tools/segment.js +84 -50
- package/dist/tools/store.d.ts +12 -4
- package/dist/tools/store.js +16 -8
- package/dist/tools/tierset.d.ts +19 -7
- package/dist/tools/tierset.js +44 -35
- package/dist/tools/transaction.d.ts +16 -8
- package/dist/tools/transaction.js +25 -21
- package/dist/tools/wallet-type.d.ts +7 -3
- package/dist/tools/wallet-type.js +14 -12
- package/dist/tools/webhook.d.ts +23 -10
- package/dist/tools/webhook.js +135 -33
- package/dist/types/schemas/achievement.d.ts +12 -309
- 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 +64 -832
- package/dist/types/schemas/campaign.js +2 -25
- package/dist/types/schemas/common.d.ts +5 -0
- package/dist/types/schemas/common.js +5 -0
- 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 +71 -68
- package/dist/types/schemas/reward.js +8 -28
- 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/wallet-type.d.ts +8 -8
- package/dist/types/schemas/wallet-type.js +1 -1
- package/dist/types/schemas/webhook.d.ts +0 -58
- package/dist/types/schemas/webhook.js +0 -12
- package/dist/utils/errors.js +30 -3
- package/dist/utils/payload.d.ts +12 -0
- package/dist/utils/payload.js +14 -0
- package/dist/workflows/app-login-streak.d.ts +39 -0
- package/dist/workflows/app-login-streak.js +298 -0
- package/dist/workflows/early-arrival.d.ts +33 -0
- package/dist/workflows/early-arrival.js +148 -0
- package/dist/workflows/index.d.ts +101 -0
- package/dist/workflows/index.js +208 -0
- package/dist/workflows/match-attendance.d.ts +45 -0
- package/dist/workflows/match-attendance.js +308 -0
- package/dist/workflows/sportsbar-visit.d.ts +41 -0
- package/dist/workflows/sportsbar-visit.js +284 -0
- package/dist/workflows/vod-watching.d.ts +43 -0
- package/dist/workflows/vod-watching.js +326 -0
- package/package.json +10 -2
|
@@ -1,15 +1,36 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { apiGet, apiPost, apiPut, apiPatch } from "../client/http.js";
|
|
3
3
|
import { formatApiError } from "../utils/errors.js";
|
|
4
|
-
import {
|
|
4
|
+
import { getStoreCode } from "../config.js";
|
|
5
5
|
// Input Schemas
|
|
6
6
|
export const AchievementListInputSchema = {
|
|
7
|
-
storeCode: z.string().optional().describe("Store code.
|
|
7
|
+
storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
|
|
8
8
|
page: z.number().optional().describe("Page number (default: 1)."),
|
|
9
9
|
perPage: z.number().optional().describe("Items per page (default: 10)."),
|
|
10
10
|
active: z.boolean().optional().describe("Filter by active status."),
|
|
11
11
|
name: z.string().optional().describe("Filter by achievement name."),
|
|
12
12
|
};
|
|
13
|
+
// Period type enum for achievements
|
|
14
|
+
// NOTE: "forever" is NOT valid - use "day" with consecutive=1 for all-time tracking
|
|
15
|
+
const AchievementPeriodTypeEnum = z.enum([
|
|
16
|
+
"day",
|
|
17
|
+
"week",
|
|
18
|
+
"month",
|
|
19
|
+
"year",
|
|
20
|
+
"last_day",
|
|
21
|
+
"calendarDays",
|
|
22
|
+
"calendarWeeks",
|
|
23
|
+
"calendarMonths",
|
|
24
|
+
"calendarYears",
|
|
25
|
+
]);
|
|
26
|
+
// Aggregation type enum for achievements
|
|
27
|
+
const AchievementAggregationTypeEnum = z.enum([
|
|
28
|
+
"quantity",
|
|
29
|
+
"sum",
|
|
30
|
+
"average",
|
|
31
|
+
"min",
|
|
32
|
+
"max",
|
|
33
|
+
]);
|
|
13
34
|
// Rule input schema
|
|
14
35
|
const AchievementRuleInputSchema = z.object({
|
|
15
36
|
achievementRuleId: z.string().optional().describe("Rule ID (for updates)."),
|
|
@@ -17,32 +38,44 @@ const AchievementRuleInputSchema = z.object({
|
|
|
17
38
|
name: z.string(),
|
|
18
39
|
description: z.string().optional(),
|
|
19
40
|
})).optional().describe("Rule name and description translations."),
|
|
20
|
-
trigger: z.
|
|
21
|
-
|
|
22
|
-
|
|
41
|
+
trigger: z.enum([
|
|
42
|
+
"transaction",
|
|
43
|
+
"custom_event",
|
|
44
|
+
"points_transfer",
|
|
45
|
+
"reward_redemption",
|
|
46
|
+
"referral",
|
|
47
|
+
"achievement",
|
|
48
|
+
"tier_change",
|
|
49
|
+
"registration",
|
|
50
|
+
"profile_update",
|
|
51
|
+
]).optional().describe("Event type that triggers rule progress. For login tracking, use custom_event with a custom 'app_login' event schema."),
|
|
52
|
+
type: z.enum(["direct", "referral"]).optional().describe("Rule type: direct (default) or referral."),
|
|
53
|
+
event: z.string().optional().describe("Custom event code (required for trigger='custom_event'). Must match an existing custom event schema."),
|
|
23
54
|
completeRule: z.object({
|
|
24
|
-
periodGoal: z.union([z.number(), z.string()]).describe("Goal value to reach."),
|
|
55
|
+
periodGoal: z.union([z.number(), z.string()]).describe("Goal value to reach (e.g., 5 for 5 purchases, 100 for 100 points)."),
|
|
25
56
|
period: z.object({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
57
|
+
type: AchievementPeriodTypeEnum.describe("Period type: 'day' (all-time when consecutive=1), 'last_day' (rolling N days), " +
|
|
58
|
+
"'calendarDays' (reset daily), 'calendarWeeks' (reset weekly), 'calendarMonths' (reset monthly)."),
|
|
59
|
+
consecutive: z.number().min(1).describe("Required consecutive periods. Use 1 for all-time tracking, 7 for weekly streaks, etc."),
|
|
60
|
+
}).describe("Period configuration. REQUIRED: both type and consecutive must be provided."),
|
|
61
|
+
uniqueAttribute: z.string().optional().describe("Attribute for unique counting (e.g., 'sku' to count unique products)."),
|
|
30
62
|
}).describe("Completion goal configuration."),
|
|
31
63
|
aggregation: z.object({
|
|
32
|
-
|
|
33
|
-
|
|
64
|
+
type: AchievementAggregationTypeEnum.describe("How to aggregate: 'quantity' (count events), 'sum' (add values), etc."),
|
|
65
|
+
rule: z.string().optional().describe("Expression for value extraction (e.g., 'transaction.grossValue' for sum of transaction values)."),
|
|
66
|
+
}).optional().describe("Value aggregation. Use type='quantity' for event counting, type='sum' with rule for value-based goals."),
|
|
34
67
|
conditions: z.array(z.record(z.unknown())).optional().describe("Conditions that must be met."),
|
|
35
68
|
limit: z.object({
|
|
36
|
-
value: z.number().optional(),
|
|
69
|
+
value: z.number().optional().describe("Max events per interval (e.g., 1 for once-per-day limit)."),
|
|
37
70
|
interval: z.object({
|
|
38
|
-
type: z.string(),
|
|
39
|
-
value: z.number().optional(),
|
|
40
|
-
}).optional(),
|
|
41
|
-
}).optional().describe("Per-rule limit."),
|
|
42
|
-
uniqueReferee: z.boolean().optional().describe("Whether referee must be unique."),
|
|
71
|
+
type: z.string().describe("Interval type: 'calendarDays', 'calendarWeeks', etc."),
|
|
72
|
+
value: z.number().optional().describe("Interval value."),
|
|
73
|
+
}).optional().describe("Time interval for the limit."),
|
|
74
|
+
}).optional().describe("Per-rule execution limit (use for streak patterns: limit 1 per day)."),
|
|
75
|
+
uniqueReferee: z.boolean().optional().describe("Whether referee must be unique (for referral achievements)."),
|
|
43
76
|
});
|
|
44
77
|
export const AchievementCreateInputSchema = {
|
|
45
|
-
storeCode: z.string().optional().describe("Store code.
|
|
78
|
+
storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
|
|
46
79
|
translations: z.record(z.string(), z.object({
|
|
47
80
|
name: z.string(),
|
|
48
81
|
description: z.string().optional(),
|
|
@@ -64,11 +97,11 @@ export const AchievementCreateInputSchema = {
|
|
|
64
97
|
badgeTypeId: z.string().optional().describe("Badge type ID to award upon completion."),
|
|
65
98
|
};
|
|
66
99
|
export const AchievementGetInputSchema = {
|
|
67
|
-
storeCode: z.string().optional().describe("Store code.
|
|
100
|
+
storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
|
|
68
101
|
achievementId: z.string().describe("The achievement ID (UUID) to retrieve."),
|
|
69
102
|
};
|
|
70
103
|
export const AchievementUpdateInputSchema = {
|
|
71
|
-
storeCode: z.string().optional().describe("Store code.
|
|
104
|
+
storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
|
|
72
105
|
achievementId: z.string().describe("The achievement ID (UUID) to update."),
|
|
73
106
|
translations: z.record(z.string(), z.object({
|
|
74
107
|
name: z.string(),
|
|
@@ -91,7 +124,7 @@ export const AchievementUpdateInputSchema = {
|
|
|
91
124
|
badgeTypeId: z.string().optional().describe("Badge type ID to award."),
|
|
92
125
|
};
|
|
93
126
|
export const AchievementPatchInputSchema = {
|
|
94
|
-
storeCode: z.string().optional().describe("Store code.
|
|
127
|
+
storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
|
|
95
128
|
achievementId: z.string().describe("The achievement ID (UUID) to patch."),
|
|
96
129
|
active: z.boolean().optional().describe("Whether achievement is active."),
|
|
97
130
|
translations: z.record(z.string(), z.object({
|
|
@@ -100,12 +133,12 @@ export const AchievementPatchInputSchema = {
|
|
|
100
133
|
})).optional().describe("Partial translation updates."),
|
|
101
134
|
};
|
|
102
135
|
export const AchievementGetMemberProgressInputSchema = {
|
|
103
|
-
storeCode: z.string().optional().describe("Store code.
|
|
136
|
+
storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
|
|
104
137
|
memberId: z.string().describe("The member ID (UUID)."),
|
|
105
138
|
achievementId: z.string().describe("The achievement ID (UUID)."),
|
|
106
139
|
};
|
|
107
140
|
export const AchievementListMemberAchievementsInputSchema = {
|
|
108
|
-
storeCode: z.string().optional().describe("Store code.
|
|
141
|
+
storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
|
|
109
142
|
memberId: z.string().describe("The member ID (UUID)."),
|
|
110
143
|
page: z.number().optional().describe("Page number (default: 1)."),
|
|
111
144
|
perPage: z.number().optional().describe("Items per page (default: 25)."),
|
|
@@ -114,8 +147,7 @@ export const AchievementListMemberAchievementsInputSchema = {
|
|
|
114
147
|
};
|
|
115
148
|
// Handler functions
|
|
116
149
|
export async function achievementList(input) {
|
|
117
|
-
const
|
|
118
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
150
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
119
151
|
const params = new URLSearchParams();
|
|
120
152
|
if (input.page)
|
|
121
153
|
params.append("_page", String(input.page));
|
|
@@ -150,8 +182,7 @@ export async function achievementList(input) {
|
|
|
150
182
|
}
|
|
151
183
|
}
|
|
152
184
|
export async function achievementCreate(input) {
|
|
153
|
-
const
|
|
154
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
185
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
155
186
|
const achievementPayload = {
|
|
156
187
|
translations: input.translations,
|
|
157
188
|
rules: input.rules,
|
|
@@ -174,8 +205,7 @@ export async function achievementCreate(input) {
|
|
|
174
205
|
}
|
|
175
206
|
}
|
|
176
207
|
export async function achievementGet(input) {
|
|
177
|
-
const
|
|
178
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
208
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
179
209
|
try {
|
|
180
210
|
const response = await apiGet(`/${storeCode}/achievement/${input.achievementId}`);
|
|
181
211
|
return response;
|
|
@@ -185,8 +215,7 @@ export async function achievementGet(input) {
|
|
|
185
215
|
}
|
|
186
216
|
}
|
|
187
217
|
export async function achievementUpdate(input) {
|
|
188
|
-
const
|
|
189
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
218
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
190
219
|
const achievementPayload = {
|
|
191
220
|
translations: input.translations,
|
|
192
221
|
rules: input.rules,
|
|
@@ -208,8 +237,7 @@ export async function achievementUpdate(input) {
|
|
|
208
237
|
}
|
|
209
238
|
}
|
|
210
239
|
export async function achievementPatch(input) {
|
|
211
|
-
const
|
|
212
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
240
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
213
241
|
const achievementPayload = {};
|
|
214
242
|
if (input.active !== undefined)
|
|
215
243
|
achievementPayload.active = input.active;
|
|
@@ -224,8 +252,7 @@ export async function achievementPatch(input) {
|
|
|
224
252
|
}
|
|
225
253
|
}
|
|
226
254
|
export async function achievementGetMemberProgress(input) {
|
|
227
|
-
const
|
|
228
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
255
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
229
256
|
try {
|
|
230
257
|
const response = await apiGet(`/${storeCode}/member/${input.memberId}/achievement/${input.achievementId}`);
|
|
231
258
|
return response;
|
|
@@ -235,8 +262,7 @@ export async function achievementGetMemberProgress(input) {
|
|
|
235
262
|
}
|
|
236
263
|
}
|
|
237
264
|
export async function achievementListMemberAchievements(input) {
|
|
238
|
-
const
|
|
239
|
-
const storeCode = input.storeCode || config.defaultStoreCode;
|
|
265
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
240
266
|
const params = new URLSearchParams();
|
|
241
267
|
if (input.page)
|
|
242
268
|
params.append("_page", String(input.page));
|
|
@@ -268,43 +294,60 @@ export async function achievementListMemberAchievements(input) {
|
|
|
268
294
|
export const achievementToolDefinitions = [
|
|
269
295
|
{
|
|
270
296
|
name: "openloyalty_achievement_list",
|
|
297
|
+
title: "List Achievements",
|
|
271
298
|
description: "List achievements. Achievements gamify member behavior by setting goals (e.g., 'Make 5 purchases this month'). Returns achievementId, name, active status, and associated badge. Use achievement_get for full rules and configuration.",
|
|
299
|
+
readOnly: true,
|
|
272
300
|
inputSchema: AchievementListInputSchema,
|
|
273
301
|
handler: achievementList,
|
|
274
302
|
},
|
|
275
303
|
{
|
|
276
304
|
name: "openloyalty_achievement_create",
|
|
277
|
-
|
|
305
|
+
title: "Create Achievement",
|
|
306
|
+
description: "Create achievement with rules that track member progress. Triggers: transaction, custom_event, points_transfer, referral, etc. " +
|
|
307
|
+
"REQUIRED in each rule: type='direct', completeRule with periodGoal and period (type + consecutive). " +
|
|
308
|
+
"Example - '5 purchases all-time': rules: [{ type: 'direct', trigger: 'transaction', aggregation: { type: 'quantity' }, completeRule: { periodGoal: 5, period: { type: 'day', consecutive: 1 } } }]. " +
|
|
309
|
+
"For streaks, use consecutive > 1 with limit: { value: 1, interval: { type: 'calendarDays', value: 1 } }.",
|
|
310
|
+
readOnly: false,
|
|
278
311
|
inputSchema: AchievementCreateInputSchema,
|
|
279
312
|
handler: achievementCreate,
|
|
280
313
|
},
|
|
281
314
|
{
|
|
282
315
|
name: "openloyalty_achievement_get",
|
|
316
|
+
title: "Get Achievement Details",
|
|
283
317
|
description: "Get achievement details including all rules, conditions, activity period, limits, and completions count.",
|
|
318
|
+
readOnly: true,
|
|
284
319
|
inputSchema: AchievementGetInputSchema,
|
|
285
320
|
handler: achievementGet,
|
|
286
321
|
},
|
|
287
322
|
{
|
|
288
323
|
name: "openloyalty_achievement_update",
|
|
324
|
+
title: "Update Achievement",
|
|
289
325
|
description: "Update achievement configuration. Requires full achievement object (translations, rules). Use achievement_get first to retrieve current configuration.",
|
|
326
|
+
readOnly: false,
|
|
290
327
|
inputSchema: AchievementUpdateInputSchema,
|
|
291
328
|
handler: achievementUpdate,
|
|
292
329
|
},
|
|
293
330
|
{
|
|
294
331
|
name: "openloyalty_achievement_patch",
|
|
332
|
+
title: "Patch Achievement",
|
|
295
333
|
description: "Partial update of achievement. Use for simple changes like activating/deactivating or updating translations without providing full rules.",
|
|
334
|
+
readOnly: false,
|
|
296
335
|
inputSchema: AchievementPatchInputSchema,
|
|
297
336
|
handler: achievementPatch,
|
|
298
337
|
},
|
|
299
338
|
{
|
|
300
339
|
name: "openloyalty_achievement_get_member_progress",
|
|
340
|
+
title: "Get Member Achievement Progress",
|
|
301
341
|
description: "Get member's progress on a specific achievement. Returns completedCount, and for each rule: periodGoal, currentPeriodValue, and consecutive period tracking.",
|
|
342
|
+
readOnly: true,
|
|
302
343
|
inputSchema: AchievementGetMemberProgressInputSchema,
|
|
303
344
|
handler: achievementGetMemberProgress,
|
|
304
345
|
},
|
|
305
346
|
{
|
|
306
347
|
name: "openloyalty_achievement_list_member_achievements",
|
|
348
|
+
title: "List Member Achievements",
|
|
307
349
|
description: "List all achievements with member's progress. Returns each achievement's status, completion count, and per-rule progress. Use for displaying gamification dashboard.",
|
|
350
|
+
readOnly: true,
|
|
308
351
|
inputSchema: AchievementListMemberAchievementsInputSchema,
|
|
309
352
|
handler: achievementListMemberAchievements,
|
|
310
353
|
},
|
package/dist/tools/admin.d.ts
CHANGED
|
@@ -87,8 +87,10 @@ export declare function adminChangePassword(input: {
|
|
|
87
87
|
}): Promise<void>;
|
|
88
88
|
export declare function adminGetPermissions(): Promise<AdminPermission>;
|
|
89
89
|
export declare const adminToolDefinitions: readonly [{
|
|
90
|
-
readonly name: "
|
|
90
|
+
readonly name: "ol_admin_list";
|
|
91
|
+
readonly title: "List Admin Users";
|
|
91
92
|
readonly description: "List admin users with optional filtering. Returns paginated list of admin users with id, email, firstName, lastName, isActive, createdAt.";
|
|
93
|
+
readonly readOnly: true;
|
|
92
94
|
readonly inputSchema: {
|
|
93
95
|
page: z.ZodOptional<z.ZodNumber>;
|
|
94
96
|
perPage: z.ZodOptional<z.ZodNumber>;
|
|
@@ -100,8 +102,10 @@ export declare const adminToolDefinitions: readonly [{
|
|
|
100
102
|
};
|
|
101
103
|
readonly handler: typeof adminList;
|
|
102
104
|
}, {
|
|
103
|
-
readonly name: "
|
|
105
|
+
readonly name: "ol_admin_create";
|
|
106
|
+
readonly title: "Create Admin User";
|
|
104
107
|
readonly description: "Create a new admin user. Requires email and password. Optionally assign roles, set active status, and configure notifications. Returns adminId.";
|
|
108
|
+
readonly readOnly: false;
|
|
105
109
|
readonly inputSchema: {
|
|
106
110
|
email: z.ZodString;
|
|
107
111
|
password: z.ZodString;
|
|
@@ -115,15 +119,19 @@ export declare const adminToolDefinitions: readonly [{
|
|
|
115
119
|
};
|
|
116
120
|
readonly handler: typeof adminCreate;
|
|
117
121
|
}, {
|
|
118
|
-
readonly name: "
|
|
122
|
+
readonly name: "ol_admin_get";
|
|
123
|
+
readonly title: "Get Admin User Details";
|
|
119
124
|
readonly description: "Get full admin user details by ID. Returns profile including email, name, roles, settings, active status, and creation date.";
|
|
125
|
+
readonly readOnly: true;
|
|
120
126
|
readonly inputSchema: {
|
|
121
127
|
adminId: z.ZodString;
|
|
122
128
|
};
|
|
123
129
|
readonly handler: typeof adminGet;
|
|
124
130
|
}, {
|
|
125
|
-
readonly name: "
|
|
131
|
+
readonly name: "ol_admin_update";
|
|
132
|
+
readonly title: "Update Admin User";
|
|
126
133
|
readonly description: "Update admin user profile. Can update email, name, phone, roles, active status, and password. Returns adminId on success.";
|
|
134
|
+
readonly readOnly: false;
|
|
127
135
|
readonly inputSchema: {
|
|
128
136
|
adminId: z.ZodString;
|
|
129
137
|
email: z.ZodOptional<z.ZodString>;
|
|
@@ -138,16 +146,20 @@ export declare const adminToolDefinitions: readonly [{
|
|
|
138
146
|
};
|
|
139
147
|
readonly handler: typeof adminUpdate;
|
|
140
148
|
}, {
|
|
141
|
-
readonly name: "
|
|
149
|
+
readonly name: "ol_admin_change_password";
|
|
150
|
+
readonly title: "Change Admin Password";
|
|
142
151
|
readonly description: "Change the currently logged-in admin's password. Requires current password for verification. Returns void on success.";
|
|
152
|
+
readonly readOnly: false;
|
|
143
153
|
readonly inputSchema: {
|
|
144
154
|
currentPassword: z.ZodString;
|
|
145
155
|
newPassword: z.ZodString;
|
|
146
156
|
};
|
|
147
157
|
readonly handler: typeof adminChangePassword;
|
|
148
158
|
}, {
|
|
149
|
-
readonly name: "
|
|
159
|
+
readonly name: "ol_admin_get_permissions";
|
|
160
|
+
readonly title: "Get Admin Permissions";
|
|
150
161
|
readonly description: "Get the current admin user's permissions. Returns superAdmin flag, list of roles, and list of permission strings. Use to check what actions are available.";
|
|
162
|
+
readonly readOnly: true;
|
|
151
163
|
readonly inputSchema: {};
|
|
152
164
|
readonly handler: typeof adminGetPermissions;
|
|
153
165
|
}];
|
package/dist/tools/admin.js
CHANGED
|
@@ -65,7 +65,7 @@ export async function adminList(input) {
|
|
|
65
65
|
return response;
|
|
66
66
|
}
|
|
67
67
|
catch (error) {
|
|
68
|
-
throw formatApiError(error, "
|
|
68
|
+
throw formatApiError(error, "ol_admin_list");
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
export async function adminCreate(input) {
|
|
@@ -92,7 +92,7 @@ export async function adminCreate(input) {
|
|
|
92
92
|
return response;
|
|
93
93
|
}
|
|
94
94
|
catch (error) {
|
|
95
|
-
throw formatApiError(error, "
|
|
95
|
+
throw formatApiError(error, "ol_admin_create");
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
export async function adminGet(input) {
|
|
@@ -101,7 +101,7 @@ export async function adminGet(input) {
|
|
|
101
101
|
return response;
|
|
102
102
|
}
|
|
103
103
|
catch (error) {
|
|
104
|
-
throw formatApiError(error, "
|
|
104
|
+
throw formatApiError(error, "ol_admin_get");
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
export async function adminUpdate(input) {
|
|
@@ -129,7 +129,7 @@ export async function adminUpdate(input) {
|
|
|
129
129
|
return response;
|
|
130
130
|
}
|
|
131
131
|
catch (error) {
|
|
132
|
-
throw formatApiError(error, "
|
|
132
|
+
throw formatApiError(error, "ol_admin_update");
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
export async function adminChangePassword(input) {
|
|
@@ -140,7 +140,7 @@ export async function adminChangePassword(input) {
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
catch (error) {
|
|
143
|
-
throw formatApiError(error, "
|
|
143
|
+
throw formatApiError(error, "ol_admin_change_password");
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
export async function adminGetPermissions() {
|
|
@@ -149,44 +149,56 @@ export async function adminGetPermissions() {
|
|
|
149
149
|
return response;
|
|
150
150
|
}
|
|
151
151
|
catch (error) {
|
|
152
|
-
throw formatApiError(error, "
|
|
152
|
+
throw formatApiError(error, "ol_admin_get_permissions");
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
// Tool definitions
|
|
156
156
|
export const adminToolDefinitions = [
|
|
157
157
|
{
|
|
158
|
-
name: "
|
|
158
|
+
name: "ol_admin_list",
|
|
159
|
+
title: "List Admin Users",
|
|
159
160
|
description: "List admin users with optional filtering. Returns paginated list of admin users with id, email, firstName, lastName, isActive, createdAt.",
|
|
161
|
+
readOnly: true,
|
|
160
162
|
inputSchema: AdminListInputSchema,
|
|
161
163
|
handler: adminList,
|
|
162
164
|
},
|
|
163
165
|
{
|
|
164
|
-
name: "
|
|
166
|
+
name: "ol_admin_create",
|
|
167
|
+
title: "Create Admin User",
|
|
165
168
|
description: "Create a new admin user. Requires email and password. Optionally assign roles, set active status, and configure notifications. Returns adminId.",
|
|
169
|
+
readOnly: false,
|
|
166
170
|
inputSchema: AdminCreateInputSchema,
|
|
167
171
|
handler: adminCreate,
|
|
168
172
|
},
|
|
169
173
|
{
|
|
170
|
-
name: "
|
|
174
|
+
name: "ol_admin_get",
|
|
175
|
+
title: "Get Admin User Details",
|
|
171
176
|
description: "Get full admin user details by ID. Returns profile including email, name, roles, settings, active status, and creation date.",
|
|
177
|
+
readOnly: true,
|
|
172
178
|
inputSchema: AdminGetInputSchema,
|
|
173
179
|
handler: adminGet,
|
|
174
180
|
},
|
|
175
181
|
{
|
|
176
|
-
name: "
|
|
182
|
+
name: "ol_admin_update",
|
|
183
|
+
title: "Update Admin User",
|
|
177
184
|
description: "Update admin user profile. Can update email, name, phone, roles, active status, and password. Returns adminId on success.",
|
|
185
|
+
readOnly: false,
|
|
178
186
|
inputSchema: AdminUpdateInputSchema,
|
|
179
187
|
handler: adminUpdate,
|
|
180
188
|
},
|
|
181
189
|
{
|
|
182
|
-
name: "
|
|
190
|
+
name: "ol_admin_change_password",
|
|
191
|
+
title: "Change Admin Password",
|
|
183
192
|
description: "Change the currently logged-in admin's password. Requires current password for verification. Returns void on success.",
|
|
193
|
+
readOnly: false,
|
|
184
194
|
inputSchema: AdminChangePasswordInputSchema,
|
|
185
195
|
handler: adminChangePassword,
|
|
186
196
|
},
|
|
187
197
|
{
|
|
188
|
-
name: "
|
|
198
|
+
name: "ol_admin_get_permissions",
|
|
199
|
+
title: "Get Admin Permissions",
|
|
189
200
|
description: "Get the current admin user's permissions. Returns superAdmin flag, list of roles, and list of permission strings. Use to check what actions are available.",
|
|
201
|
+
readOnly: true,
|
|
190
202
|
inputSchema: {},
|
|
191
203
|
handler: adminGetPermissions,
|
|
192
204
|
},
|
|
@@ -24,7 +24,7 @@ export declare const AnalyticsCampaignsInputSchema: {
|
|
|
24
24
|
};
|
|
25
25
|
export declare const AnalyticsDashboardInputSchema: {
|
|
26
26
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
27
|
-
dataType: z.
|
|
27
|
+
dataType: z.ZodEnum<["registeredMembers", "activeMembers", "revenue", "avgSpending", "transactions", "avgTransactionValue", "avgNumberOfTransactions"]>;
|
|
28
28
|
aggregationType: z.ZodOptional<z.ZodEnum<["day", "week", "month"]>>;
|
|
29
29
|
intervalStartDate: z.ZodOptional<z.ZodString>;
|
|
30
30
|
intervalEndDate: z.ZodOptional<z.ZodString>;
|
|
@@ -83,44 +83,56 @@ export declare function analyticsCampaignDetail(input: {
|
|
|
83
83
|
campaignId: string;
|
|
84
84
|
}): Promise<Record<string, unknown>>;
|
|
85
85
|
export declare const analyticsToolDefinitions: readonly [{
|
|
86
|
-
readonly name: "
|
|
86
|
+
readonly name: "ol_analytics_tiers";
|
|
87
|
+
readonly title: "Get Tier Analytics";
|
|
87
88
|
readonly description: "Get tier (level) analytics showing member distribution across tiers. Returns tier IDs, names, and member counts for each tier level.";
|
|
89
|
+
readonly readOnly: true;
|
|
88
90
|
readonly inputSchema: {
|
|
89
91
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
90
92
|
};
|
|
91
93
|
readonly handler: typeof analyticsTiers;
|
|
92
94
|
}, {
|
|
93
|
-
readonly name: "
|
|
95
|
+
readonly name: "ol_analytics_members";
|
|
96
|
+
readonly title: "Get Member Analytics";
|
|
94
97
|
readonly description: "Get member analytics showing registration trends. Returns member counts by time intervals (1 day, 7 days, 30 days, 365 days). Filter by transaction status to see engaged vs unengaged members.";
|
|
98
|
+
readonly readOnly: true;
|
|
95
99
|
readonly inputSchema: {
|
|
96
100
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
97
101
|
withTransaction: z.ZodOptional<z.ZodBoolean>;
|
|
98
102
|
};
|
|
99
103
|
readonly handler: typeof analyticsMembers;
|
|
100
104
|
}, {
|
|
101
|
-
readonly name: "
|
|
105
|
+
readonly name: "ol_analytics_points";
|
|
106
|
+
readonly title: "Get Points Analytics";
|
|
102
107
|
readonly description: "Get points analytics showing program health. Returns total active points, points spent, points issued, expired points, and pending points. Use to monitor points economy.";
|
|
108
|
+
readonly readOnly: true;
|
|
103
109
|
readonly inputSchema: {
|
|
104
110
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
105
111
|
};
|
|
106
112
|
readonly handler: typeof analyticsPoints;
|
|
107
113
|
}, {
|
|
108
|
-
readonly name: "
|
|
114
|
+
readonly name: "ol_analytics_transactions";
|
|
115
|
+
readonly title: "Get Transaction Analytics";
|
|
109
116
|
readonly description: "Get transaction analytics showing purchase trends. Returns transaction counts by intervals, total count, total amount, and average values. Use to monitor sales performance.";
|
|
117
|
+
readonly readOnly: true;
|
|
110
118
|
readonly inputSchema: {
|
|
111
119
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
112
120
|
};
|
|
113
121
|
readonly handler: typeof analyticsTransactions;
|
|
114
122
|
}, {
|
|
115
|
-
readonly name: "
|
|
123
|
+
readonly name: "ol_analytics_referrals";
|
|
124
|
+
readonly title: "Get Referral Analytics";
|
|
116
125
|
readonly description: "Get referral program analytics showing referral activity. Returns total referral count. Use to monitor referral program performance.";
|
|
126
|
+
readonly readOnly: true;
|
|
117
127
|
readonly inputSchema: {
|
|
118
128
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
119
129
|
};
|
|
120
130
|
readonly handler: typeof analyticsReferrals;
|
|
121
131
|
}, {
|
|
122
|
-
readonly name: "
|
|
132
|
+
readonly name: "ol_analytics_campaigns";
|
|
133
|
+
readonly title: "Get Campaign Analytics";
|
|
123
134
|
readonly description: "Get campaign analytics showing execution counts per campaign. Returns list of campaigns with their execution counts. Use to identify most successful campaigns.";
|
|
135
|
+
readonly readOnly: true;
|
|
124
136
|
readonly inputSchema: {
|
|
125
137
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
126
138
|
page: z.ZodOptional<z.ZodNumber>;
|
|
@@ -129,19 +141,23 @@ export declare const analyticsToolDefinitions: readonly [{
|
|
|
129
141
|
};
|
|
130
142
|
readonly handler: typeof analyticsCampaigns;
|
|
131
143
|
}, {
|
|
132
|
-
readonly name: "
|
|
144
|
+
readonly name: "ol_analytics_dashboard";
|
|
145
|
+
readonly title: "Get Dashboard Overview";
|
|
133
146
|
readonly description: "Get dashboard overview metrics with time-series data. Returns key metrics (registered members, active members, revenue, avg spending, transactions) with optional date range and aggregation. Use for high-level program dashboards.";
|
|
147
|
+
readonly readOnly: true;
|
|
134
148
|
readonly inputSchema: {
|
|
135
149
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
136
|
-
dataType: z.
|
|
150
|
+
dataType: z.ZodEnum<["registeredMembers", "activeMembers", "revenue", "avgSpending", "transactions", "avgTransactionValue", "avgNumberOfTransactions"]>;
|
|
137
151
|
aggregationType: z.ZodOptional<z.ZodEnum<["day", "week", "month"]>>;
|
|
138
152
|
intervalStartDate: z.ZodOptional<z.ZodString>;
|
|
139
153
|
intervalEndDate: z.ZodOptional<z.ZodString>;
|
|
140
154
|
};
|
|
141
155
|
readonly handler: typeof analyticsDashboard;
|
|
142
156
|
}, {
|
|
143
|
-
readonly name: "
|
|
157
|
+
readonly name: "ol_analytics_units";
|
|
158
|
+
readonly title: "Get Units Overview";
|
|
144
159
|
readonly description: "Get wallet-specific analytics (units overview). Returns units issued, spent, expired, pending, active, plus redemption and breakage rates. Requires walletTypeCode parameter. Use for detailed points economy analysis.";
|
|
160
|
+
readonly readOnly: true;
|
|
145
161
|
readonly inputSchema: {
|
|
146
162
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
147
163
|
walletTypeCode: z.ZodString;
|
|
@@ -152,8 +168,10 @@ export declare const analyticsToolDefinitions: readonly [{
|
|
|
152
168
|
};
|
|
153
169
|
readonly handler: typeof analyticsUnits;
|
|
154
170
|
}, {
|
|
155
|
-
readonly name: "
|
|
171
|
+
readonly name: "ol_analytics_campaign_detail";
|
|
172
|
+
readonly title: "Get Campaign Detail Analytics";
|
|
156
173
|
readonly description: "Get detailed analytics for a specific campaign. Returns campaign-specific performance metrics. Use after analytics_campaigns to drill into individual campaign performance.";
|
|
174
|
+
readonly readOnly: true;
|
|
157
175
|
readonly inputSchema: {
|
|
158
176
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
159
177
|
campaignId: z.ZodString;
|