@open-loyalty/mcp-server 1.1.0 → 1.3.3
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.js +10 -0
- package/dist/config.d.ts +0 -13
- package/dist/config.js +0 -14
- package/dist/http.js +35 -3
- package/dist/instructions.d.ts +5 -0
- package/dist/instructions.js +440 -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 +60 -273
- 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 +141 -121
- package/dist/tools/achievement.js +60 -24
- package/dist/tools/admin.d.ts +6 -6
- package/dist/tools/admin.js +12 -12
- package/dist/tools/analytics.d.ts +11 -11
- package/dist/tools/analytics.js +30 -29
- package/dist/tools/apikey.d.ts +3 -3
- package/dist/tools/apikey.js +6 -6
- package/dist/tools/audit.d.ts +2 -2
- package/dist/tools/audit.js +4 -4
- package/dist/tools/badge.d.ts +6 -6
- package/dist/tools/badge.js +23 -18
- 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 +117 -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/custom-event.d.ts +315 -0
- package/dist/tools/custom-event.js +270 -0
- package/dist/tools/export.d.ts +4 -4
- package/dist/tools/export.js +12 -12
- package/dist/tools/import.d.ts +3 -3
- package/dist/tools/import.js +23 -15
- package/dist/tools/index.js +13 -5
- 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/points.d.ts +7 -6
- package/dist/tools/points.js +21 -20
- 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 +93 -0
- package/dist/tools/reward/schemas.d.ts +116 -0
- package/dist/tools/reward/schemas.js +92 -0
- package/dist/tools/role.d.ts +6 -6
- package/dist/tools/role.js +12 -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 +88 -0
- package/dist/tools/segment/schemas.d.ts +337 -0
- package/dist/tools/segment/schemas.js +79 -0
- package/dist/tools/segment.d.ts +10 -10
- package/dist/tools/segment.js +55 -31
- package/dist/tools/store.d.ts +4 -4
- package/dist/tools/store.js +8 -8
- package/dist/tools/tierset.d.ts +10 -10
- package/dist/tools/tierset.js +69 -37
- package/dist/tools/transaction.d.ts +4 -4
- package/dist/tools/transaction.js +12 -12
- package/dist/tools/wallet-type.d.ts +221 -16
- package/dist/tools/wallet-type.js +248 -17
- package/dist/tools/webhook.d.ts +6 -6
- package/dist/tools/webhook.js +90 -31
- package/dist/types/schemas/achievement.d.ts +18 -18
- package/dist/types/schemas/campaign.d.ts +64 -184
- package/dist/types/schemas/campaign.js +2 -7
- package/dist/types/schemas/common.d.ts +5 -0
- package/dist/types/schemas/common.js +5 -0
- package/dist/types/schemas/member.d.ts +2 -2
- package/dist/types/schemas/reward.d.ts +94 -18
- package/dist/types/schemas/reward.js +8 -3
- package/dist/types/schemas/wallet-type.d.ts +306 -8
- package/dist/types/schemas/wallet-type.js +82 -1
- package/dist/utils/errors.js +32 -5
- 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 +8 -2
|
@@ -4,12 +4,33 @@ import { formatApiError } from "../utils/errors.js";
|
|
|
4
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)."),
|
|
@@ -270,7 +303,10 @@ export const achievementToolDefinitions = [
|
|
|
270
303
|
{
|
|
271
304
|
name: "openloyalty_achievement_create",
|
|
272
305
|
title: "Create Achievement",
|
|
273
|
-
description: "Create achievement with rules that track member progress. Triggers: transaction
|
|
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 } }.",
|
|
274
310
|
readOnly: false,
|
|
275
311
|
inputSchema: AchievementCreateInputSchema,
|
|
276
312
|
handler: achievementCreate,
|
package/dist/tools/admin.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ 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
91
|
readonly title: "List Admin Users";
|
|
92
92
|
readonly description: "List admin users with optional filtering. Returns paginated list of admin users with id, email, firstName, lastName, isActive, createdAt.";
|
|
93
93
|
readonly readOnly: true;
|
|
@@ -102,7 +102,7 @@ export declare const adminToolDefinitions: readonly [{
|
|
|
102
102
|
};
|
|
103
103
|
readonly handler: typeof adminList;
|
|
104
104
|
}, {
|
|
105
|
-
readonly name: "
|
|
105
|
+
readonly name: "ol_admin_create";
|
|
106
106
|
readonly title: "Create Admin User";
|
|
107
107
|
readonly description: "Create a new admin user. Requires email and password. Optionally assign roles, set active status, and configure notifications. Returns adminId.";
|
|
108
108
|
readonly readOnly: false;
|
|
@@ -119,7 +119,7 @@ export declare const adminToolDefinitions: readonly [{
|
|
|
119
119
|
};
|
|
120
120
|
readonly handler: typeof adminCreate;
|
|
121
121
|
}, {
|
|
122
|
-
readonly name: "
|
|
122
|
+
readonly name: "ol_admin_get";
|
|
123
123
|
readonly title: "Get Admin User Details";
|
|
124
124
|
readonly description: "Get full admin user details by ID. Returns profile including email, name, roles, settings, active status, and creation date.";
|
|
125
125
|
readonly readOnly: true;
|
|
@@ -128,7 +128,7 @@ export declare const adminToolDefinitions: readonly [{
|
|
|
128
128
|
};
|
|
129
129
|
readonly handler: typeof adminGet;
|
|
130
130
|
}, {
|
|
131
|
-
readonly name: "
|
|
131
|
+
readonly name: "ol_admin_update";
|
|
132
132
|
readonly title: "Update Admin User";
|
|
133
133
|
readonly description: "Update admin user profile. Can update email, name, phone, roles, active status, and password. Returns adminId on success.";
|
|
134
134
|
readonly readOnly: false;
|
|
@@ -146,7 +146,7 @@ export declare const adminToolDefinitions: readonly [{
|
|
|
146
146
|
};
|
|
147
147
|
readonly handler: typeof adminUpdate;
|
|
148
148
|
}, {
|
|
149
|
-
readonly name: "
|
|
149
|
+
readonly name: "ol_admin_change_password";
|
|
150
150
|
readonly title: "Change Admin Password";
|
|
151
151
|
readonly description: "Change the currently logged-in admin's password. Requires current password for verification. Returns void on success.";
|
|
152
152
|
readonly readOnly: false;
|
|
@@ -156,7 +156,7 @@ export declare const adminToolDefinitions: readonly [{
|
|
|
156
156
|
};
|
|
157
157
|
readonly handler: typeof adminChangePassword;
|
|
158
158
|
}, {
|
|
159
|
-
readonly name: "
|
|
159
|
+
readonly name: "ol_admin_get_permissions";
|
|
160
160
|
readonly title: "Get Admin Permissions";
|
|
161
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
162
|
readonly readOnly: true;
|
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,13 +149,13 @@ 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
159
|
title: "List Admin Users",
|
|
160
160
|
description: "List admin users with optional filtering. Returns paginated list of admin users with id, email, firstName, lastName, isActive, createdAt.",
|
|
161
161
|
readOnly: true,
|
|
@@ -163,7 +163,7 @@ export const adminToolDefinitions = [
|
|
|
163
163
|
handler: adminList,
|
|
164
164
|
},
|
|
165
165
|
{
|
|
166
|
-
name: "
|
|
166
|
+
name: "ol_admin_create",
|
|
167
167
|
title: "Create Admin User",
|
|
168
168
|
description: "Create a new admin user. Requires email and password. Optionally assign roles, set active status, and configure notifications. Returns adminId.",
|
|
169
169
|
readOnly: false,
|
|
@@ -171,7 +171,7 @@ export const adminToolDefinitions = [
|
|
|
171
171
|
handler: adminCreate,
|
|
172
172
|
},
|
|
173
173
|
{
|
|
174
|
-
name: "
|
|
174
|
+
name: "ol_admin_get",
|
|
175
175
|
title: "Get Admin User Details",
|
|
176
176
|
description: "Get full admin user details by ID. Returns profile including email, name, roles, settings, active status, and creation date.",
|
|
177
177
|
readOnly: true,
|
|
@@ -179,7 +179,7 @@ export const adminToolDefinitions = [
|
|
|
179
179
|
handler: adminGet,
|
|
180
180
|
},
|
|
181
181
|
{
|
|
182
|
-
name: "
|
|
182
|
+
name: "ol_admin_update",
|
|
183
183
|
title: "Update Admin User",
|
|
184
184
|
description: "Update admin user profile. Can update email, name, phone, roles, active status, and password. Returns adminId on success.",
|
|
185
185
|
readOnly: false,
|
|
@@ -187,7 +187,7 @@ export const adminToolDefinitions = [
|
|
|
187
187
|
handler: adminUpdate,
|
|
188
188
|
},
|
|
189
189
|
{
|
|
190
|
-
name: "
|
|
190
|
+
name: "ol_admin_change_password",
|
|
191
191
|
title: "Change Admin Password",
|
|
192
192
|
description: "Change the currently logged-in admin's password. Requires current password for verification. Returns void on success.",
|
|
193
193
|
readOnly: false,
|
|
@@ -195,7 +195,7 @@ export const adminToolDefinitions = [
|
|
|
195
195
|
handler: adminChangePassword,
|
|
196
196
|
},
|
|
197
197
|
{
|
|
198
|
-
name: "
|
|
198
|
+
name: "ol_admin_get_permissions",
|
|
199
199
|
title: "Get Admin Permissions",
|
|
200
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
201
|
readOnly: true,
|
|
@@ -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,7 +83,7 @@ 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
87
|
readonly title: "Get Tier Analytics";
|
|
88
88
|
readonly description: "Get tier (level) analytics showing member distribution across tiers. Returns tier IDs, names, and member counts for each tier level.";
|
|
89
89
|
readonly readOnly: true;
|
|
@@ -92,7 +92,7 @@ export declare const analyticsToolDefinitions: readonly [{
|
|
|
92
92
|
};
|
|
93
93
|
readonly handler: typeof analyticsTiers;
|
|
94
94
|
}, {
|
|
95
|
-
readonly name: "
|
|
95
|
+
readonly name: "ol_analytics_members";
|
|
96
96
|
readonly title: "Get Member Analytics";
|
|
97
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
98
|
readonly readOnly: true;
|
|
@@ -102,7 +102,7 @@ export declare const analyticsToolDefinitions: readonly [{
|
|
|
102
102
|
};
|
|
103
103
|
readonly handler: typeof analyticsMembers;
|
|
104
104
|
}, {
|
|
105
|
-
readonly name: "
|
|
105
|
+
readonly name: "ol_analytics_points";
|
|
106
106
|
readonly title: "Get Points Analytics";
|
|
107
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
108
|
readonly readOnly: true;
|
|
@@ -111,7 +111,7 @@ export declare const analyticsToolDefinitions: readonly [{
|
|
|
111
111
|
};
|
|
112
112
|
readonly handler: typeof analyticsPoints;
|
|
113
113
|
}, {
|
|
114
|
-
readonly name: "
|
|
114
|
+
readonly name: "ol_analytics_transactions";
|
|
115
115
|
readonly title: "Get Transaction Analytics";
|
|
116
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
117
|
readonly readOnly: true;
|
|
@@ -120,7 +120,7 @@ export declare const analyticsToolDefinitions: readonly [{
|
|
|
120
120
|
};
|
|
121
121
|
readonly handler: typeof analyticsTransactions;
|
|
122
122
|
}, {
|
|
123
|
-
readonly name: "
|
|
123
|
+
readonly name: "ol_analytics_referrals";
|
|
124
124
|
readonly title: "Get Referral Analytics";
|
|
125
125
|
readonly description: "Get referral program analytics showing referral activity. Returns total referral count. Use to monitor referral program performance.";
|
|
126
126
|
readonly readOnly: true;
|
|
@@ -129,7 +129,7 @@ export declare const analyticsToolDefinitions: readonly [{
|
|
|
129
129
|
};
|
|
130
130
|
readonly handler: typeof analyticsReferrals;
|
|
131
131
|
}, {
|
|
132
|
-
readonly name: "
|
|
132
|
+
readonly name: "ol_analytics_campaigns";
|
|
133
133
|
readonly title: "Get Campaign Analytics";
|
|
134
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
135
|
readonly readOnly: true;
|
|
@@ -141,20 +141,20 @@ export declare const analyticsToolDefinitions: readonly [{
|
|
|
141
141
|
};
|
|
142
142
|
readonly handler: typeof analyticsCampaigns;
|
|
143
143
|
}, {
|
|
144
|
-
readonly name: "
|
|
144
|
+
readonly name: "ol_analytics_dashboard";
|
|
145
145
|
readonly title: "Get Dashboard Overview";
|
|
146
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
147
|
readonly readOnly: true;
|
|
148
148
|
readonly inputSchema: {
|
|
149
149
|
storeCode: z.ZodOptional<z.ZodString>;
|
|
150
|
-
dataType: z.
|
|
150
|
+
dataType: z.ZodEnum<["registeredMembers", "activeMembers", "revenue", "avgSpending", "transactions", "avgTransactionValue", "avgNumberOfTransactions"]>;
|
|
151
151
|
aggregationType: z.ZodOptional<z.ZodEnum<["day", "week", "month"]>>;
|
|
152
152
|
intervalStartDate: z.ZodOptional<z.ZodString>;
|
|
153
153
|
intervalEndDate: z.ZodOptional<z.ZodString>;
|
|
154
154
|
};
|
|
155
155
|
readonly handler: typeof analyticsDashboard;
|
|
156
156
|
}, {
|
|
157
|
-
readonly name: "
|
|
157
|
+
readonly name: "ol_analytics_units";
|
|
158
158
|
readonly title: "Get Units Overview";
|
|
159
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
160
|
readonly readOnly: true;
|
|
@@ -168,7 +168,7 @@ export declare const analyticsToolDefinitions: readonly [{
|
|
|
168
168
|
};
|
|
169
169
|
readonly handler: typeof analyticsUnits;
|
|
170
170
|
}, {
|
|
171
|
-
readonly name: "
|
|
171
|
+
readonly name: "ol_analytics_campaign_detail";
|
|
172
172
|
readonly title: "Get Campaign Detail Analytics";
|
|
173
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
174
|
readonly readOnly: true;
|
package/dist/tools/analytics.js
CHANGED
|
@@ -4,39 +4,39 @@ import { formatApiError } from "../utils/errors.js";
|
|
|
4
4
|
import { getStoreCode } from "../config.js";
|
|
5
5
|
// Input Schemas
|
|
6
6
|
export const AnalyticsTiersInputSchema = {
|
|
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
|
};
|
|
9
9
|
export const AnalyticsMembersInputSchema = {
|
|
10
|
-
storeCode: z.string().optional().describe("Store code.
|
|
10
|
+
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."),
|
|
11
11
|
withTransaction: z.boolean().optional().describe("Filter: true for members with transactions, false for members without, omit for all."),
|
|
12
12
|
};
|
|
13
13
|
export const AnalyticsPointsInputSchema = {
|
|
14
|
-
storeCode: z.string().optional().describe("Store code.
|
|
14
|
+
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."),
|
|
15
15
|
};
|
|
16
16
|
export const AnalyticsTransactionsInputSchema = {
|
|
17
|
-
storeCode: z.string().optional().describe("Store code.
|
|
17
|
+
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."),
|
|
18
18
|
};
|
|
19
19
|
export const AnalyticsReferralsInputSchema = {
|
|
20
|
-
storeCode: z.string().optional().describe("Store code.
|
|
20
|
+
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."),
|
|
21
21
|
};
|
|
22
22
|
export const AnalyticsCampaignsInputSchema = {
|
|
23
|
-
storeCode: z.string().optional().describe("Store code.
|
|
23
|
+
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."),
|
|
24
24
|
page: z.number().optional().describe("Page number (default: 1)."),
|
|
25
25
|
perPage: z.number().optional().describe("Items per page (default: 25)."),
|
|
26
26
|
executedAt: z.string().optional().describe("Filter by execution date (ISO format)."),
|
|
27
27
|
};
|
|
28
28
|
export const AnalyticsDashboardInputSchema = {
|
|
29
|
-
storeCode: z.string().optional().describe("Store code.
|
|
29
|
+
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."),
|
|
30
30
|
dataType: z.enum([
|
|
31
31
|
"registeredMembers", "activeMembers", "revenue", "avgSpending",
|
|
32
32
|
"transactions", "avgTransactionValue", "avgNumberOfTransactions"
|
|
33
|
-
]).
|
|
33
|
+
]).describe("REQUIRED: Type of data to retrieve. Options: registeredMembers, activeMembers, revenue, avgSpending, transactions, avgTransactionValue, avgNumberOfTransactions."),
|
|
34
34
|
aggregationType: z.enum(["day", "week", "month"]).optional().describe("Aggregation granularity."),
|
|
35
35
|
intervalStartDate: z.string().optional().describe("Start date (YYYY-MM-DD format)."),
|
|
36
36
|
intervalEndDate: z.string().optional().describe("End date (YYYY-MM-DD format)."),
|
|
37
37
|
};
|
|
38
38
|
export const AnalyticsUnitsInputSchema = {
|
|
39
|
-
storeCode: z.string().optional().describe("Store code.
|
|
39
|
+
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."),
|
|
40
40
|
walletTypeCode: z.string().describe("Wallet type code (e.g., 'default' or 'points')."),
|
|
41
41
|
dataType: z.enum([
|
|
42
42
|
"unitsIssued", "unitsSpent", "unitsExpired", "unitsPending", "unitsActive"
|
|
@@ -46,7 +46,7 @@ export const AnalyticsUnitsInputSchema = {
|
|
|
46
46
|
intervalEndDate: z.string().optional().describe("End date (YYYY-MM-DD format)."),
|
|
47
47
|
};
|
|
48
48
|
export const AnalyticsCampaignDetailInputSchema = {
|
|
49
|
-
storeCode: z.string().optional().describe("Store code.
|
|
49
|
+
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."),
|
|
50
50
|
campaignId: z.string().describe("The campaign ID to get analytics for."),
|
|
51
51
|
};
|
|
52
52
|
// Handler functions
|
|
@@ -57,7 +57,7 @@ export async function analyticsTiers(input) {
|
|
|
57
57
|
return response;
|
|
58
58
|
}
|
|
59
59
|
catch (error) {
|
|
60
|
-
throw formatApiError(error, "
|
|
60
|
+
throw formatApiError(error, "ol_analytics_tiers");
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
export async function analyticsMembers(input) {
|
|
@@ -73,7 +73,7 @@ export async function analyticsMembers(input) {
|
|
|
73
73
|
return response;
|
|
74
74
|
}
|
|
75
75
|
catch (error) {
|
|
76
|
-
throw formatApiError(error, "
|
|
76
|
+
throw formatApiError(error, "ol_analytics_members");
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
export async function analyticsPoints(input) {
|
|
@@ -83,7 +83,7 @@ export async function analyticsPoints(input) {
|
|
|
83
83
|
return response;
|
|
84
84
|
}
|
|
85
85
|
catch (error) {
|
|
86
|
-
throw formatApiError(error, "
|
|
86
|
+
throw formatApiError(error, "ol_analytics_points");
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
export async function analyticsTransactions(input) {
|
|
@@ -93,7 +93,7 @@ export async function analyticsTransactions(input) {
|
|
|
93
93
|
return response;
|
|
94
94
|
}
|
|
95
95
|
catch (error) {
|
|
96
|
-
throw formatApiError(error, "
|
|
96
|
+
throw formatApiError(error, "ol_analytics_transactions");
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
export async function analyticsReferrals(input) {
|
|
@@ -103,7 +103,7 @@ export async function analyticsReferrals(input) {
|
|
|
103
103
|
return response;
|
|
104
104
|
}
|
|
105
105
|
catch (error) {
|
|
106
|
-
throw formatApiError(error, "
|
|
106
|
+
throw formatApiError(error, "ol_analytics_referrals");
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
export async function analyticsCampaigns(input) {
|
|
@@ -122,7 +122,7 @@ export async function analyticsCampaigns(input) {
|
|
|
122
122
|
return response;
|
|
123
123
|
}
|
|
124
124
|
catch (error) {
|
|
125
|
-
throw formatApiError(error, "
|
|
125
|
+
throw formatApiError(error, "ol_analytics_campaigns");
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
export async function analyticsDashboard(input) {
|
|
@@ -143,7 +143,7 @@ export async function analyticsDashboard(input) {
|
|
|
143
143
|
return response;
|
|
144
144
|
}
|
|
145
145
|
catch (error) {
|
|
146
|
-
throw formatApiError(error, "
|
|
146
|
+
throw formatApiError(error, "ol_analytics_dashboard");
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
export async function analyticsUnits(input) {
|
|
@@ -164,23 +164,24 @@ export async function analyticsUnits(input) {
|
|
|
164
164
|
return response;
|
|
165
165
|
}
|
|
166
166
|
catch (error) {
|
|
167
|
-
throw formatApiError(error, "
|
|
167
|
+
throw formatApiError(error, "ol_analytics_units");
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
export async function analyticsCampaignDetail(input) {
|
|
171
171
|
const storeCode = getStoreCode(input.storeCode);
|
|
172
172
|
try {
|
|
173
|
-
|
|
173
|
+
// API endpoint uses /campaigns (plural) with campaign ID as query param
|
|
174
|
+
const response = await apiGet(`/${storeCode}/analytics/campaigns?campaignId=${input.campaignId}`);
|
|
174
175
|
return response;
|
|
175
176
|
}
|
|
176
177
|
catch (error) {
|
|
177
|
-
throw formatApiError(error, "
|
|
178
|
+
throw formatApiError(error, "ol_analytics_campaign_detail");
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
// Tool definitions
|
|
181
182
|
export const analyticsToolDefinitions = [
|
|
182
183
|
{
|
|
183
|
-
name: "
|
|
184
|
+
name: "ol_analytics_tiers",
|
|
184
185
|
title: "Get Tier Analytics",
|
|
185
186
|
description: "Get tier (level) analytics showing member distribution across tiers. Returns tier IDs, names, and member counts for each tier level.",
|
|
186
187
|
readOnly: true,
|
|
@@ -188,7 +189,7 @@ export const analyticsToolDefinitions = [
|
|
|
188
189
|
handler: analyticsTiers,
|
|
189
190
|
},
|
|
190
191
|
{
|
|
191
|
-
name: "
|
|
192
|
+
name: "ol_analytics_members",
|
|
192
193
|
title: "Get Member Analytics",
|
|
193
194
|
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.",
|
|
194
195
|
readOnly: true,
|
|
@@ -196,7 +197,7 @@ export const analyticsToolDefinitions = [
|
|
|
196
197
|
handler: analyticsMembers,
|
|
197
198
|
},
|
|
198
199
|
{
|
|
199
|
-
name: "
|
|
200
|
+
name: "ol_analytics_points",
|
|
200
201
|
title: "Get Points Analytics",
|
|
201
202
|
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.",
|
|
202
203
|
readOnly: true,
|
|
@@ -204,7 +205,7 @@ export const analyticsToolDefinitions = [
|
|
|
204
205
|
handler: analyticsPoints,
|
|
205
206
|
},
|
|
206
207
|
{
|
|
207
|
-
name: "
|
|
208
|
+
name: "ol_analytics_transactions",
|
|
208
209
|
title: "Get Transaction Analytics",
|
|
209
210
|
description: "Get transaction analytics showing purchase trends. Returns transaction counts by intervals, total count, total amount, and average values. Use to monitor sales performance.",
|
|
210
211
|
readOnly: true,
|
|
@@ -212,7 +213,7 @@ export const analyticsToolDefinitions = [
|
|
|
212
213
|
handler: analyticsTransactions,
|
|
213
214
|
},
|
|
214
215
|
{
|
|
215
|
-
name: "
|
|
216
|
+
name: "ol_analytics_referrals",
|
|
216
217
|
title: "Get Referral Analytics",
|
|
217
218
|
description: "Get referral program analytics showing referral activity. Returns total referral count. Use to monitor referral program performance.",
|
|
218
219
|
readOnly: true,
|
|
@@ -220,7 +221,7 @@ export const analyticsToolDefinitions = [
|
|
|
220
221
|
handler: analyticsReferrals,
|
|
221
222
|
},
|
|
222
223
|
{
|
|
223
|
-
name: "
|
|
224
|
+
name: "ol_analytics_campaigns",
|
|
224
225
|
title: "Get Campaign Analytics",
|
|
225
226
|
description: "Get campaign analytics showing execution counts per campaign. Returns list of campaigns with their execution counts. Use to identify most successful campaigns.",
|
|
226
227
|
readOnly: true,
|
|
@@ -228,7 +229,7 @@ export const analyticsToolDefinitions = [
|
|
|
228
229
|
handler: analyticsCampaigns,
|
|
229
230
|
},
|
|
230
231
|
{
|
|
231
|
-
name: "
|
|
232
|
+
name: "ol_analytics_dashboard",
|
|
232
233
|
title: "Get Dashboard Overview",
|
|
233
234
|
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.",
|
|
234
235
|
readOnly: true,
|
|
@@ -236,7 +237,7 @@ export const analyticsToolDefinitions = [
|
|
|
236
237
|
handler: analyticsDashboard,
|
|
237
238
|
},
|
|
238
239
|
{
|
|
239
|
-
name: "
|
|
240
|
+
name: "ol_analytics_units",
|
|
240
241
|
title: "Get Units Overview",
|
|
241
242
|
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.",
|
|
242
243
|
readOnly: true,
|
|
@@ -244,7 +245,7 @@ export const analyticsToolDefinitions = [
|
|
|
244
245
|
handler: analyticsUnits,
|
|
245
246
|
},
|
|
246
247
|
{
|
|
247
|
-
name: "
|
|
248
|
+
name: "ol_analytics_campaign_detail",
|
|
248
249
|
title: "Get Campaign Detail Analytics",
|
|
249
250
|
description: "Get detailed analytics for a specific campaign. Returns campaign-specific performance metrics. Use after analytics_campaigns to drill into individual campaign performance.",
|
|
250
251
|
readOnly: true,
|