@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.
Files changed (142) hide show
  1. package/README.md +180 -177
  2. package/dist/auth/provider.js +2 -14
  3. package/dist/auth/storage.js +22 -0
  4. package/dist/client/http.d.ts +5 -0
  5. package/dist/client/http.js +62 -3
  6. package/dist/config.d.ts +6 -5
  7. package/dist/config.js +15 -11
  8. package/dist/http.js +170 -65
  9. package/dist/instructions.d.ts +5 -0
  10. package/dist/instructions.js +420 -0
  11. package/dist/prompts/fan-engagement-setup.d.ts +107 -0
  12. package/dist/prompts/fan-engagement-setup.js +492 -0
  13. package/dist/server.d.ts +1 -1
  14. package/dist/server.js +68 -278
  15. package/dist/tools/achievement/handlers.d.ts +117 -0
  16. package/dist/tools/achievement/handlers.js +161 -0
  17. package/dist/tools/achievement/index.d.ts +479 -0
  18. package/dist/tools/achievement/index.js +74 -0
  19. package/dist/tools/achievement/schemas.d.ts +433 -0
  20. package/dist/tools/achievement/schemas.js +142 -0
  21. package/dist/tools/achievement.d.ts +155 -121
  22. package/dist/tools/achievement.js +82 -39
  23. package/dist/tools/admin.d.ts +18 -6
  24. package/dist/tools/admin.js +24 -12
  25. package/dist/tools/analytics.d.ts +29 -11
  26. package/dist/tools/analytics.js +58 -48
  27. package/dist/tools/apikey.d.ts +10 -3
  28. package/dist/tools/apikey.js +13 -6
  29. package/dist/tools/audit.d.ts +6 -2
  30. package/dist/tools/audit.js +8 -4
  31. package/dist/tools/badge.d.ts +14 -6
  32. package/dist/tools/badge.js +36 -27
  33. package/dist/tools/campaign/handlers.d.ts +42 -0
  34. package/dist/tools/campaign/handlers.js +223 -0
  35. package/dist/tools/campaign/index.d.ts +783 -0
  36. package/dist/tools/campaign/index.js +112 -0
  37. package/dist/tools/campaign/member-handlers.d.ts +60 -0
  38. package/dist/tools/campaign/member-handlers.js +159 -0
  39. package/dist/tools/campaign/schemas.d.ts +704 -0
  40. package/dist/tools/campaign/schemas.js +259 -0
  41. package/dist/tools/campaign/types.d.ts +161 -0
  42. package/dist/tools/campaign/types.js +2 -0
  43. package/dist/tools/campaign.d.ts +41 -16
  44. package/dist/tools/campaign.js +38 -25
  45. package/dist/tools/custom-event.d.ts +315 -0
  46. package/dist/tools/custom-event.js +270 -0
  47. package/dist/tools/export.d.ts +12 -4
  48. package/dist/tools/export.js +25 -20
  49. package/dist/tools/import.d.ts +9 -3
  50. package/dist/tools/import.js +33 -21
  51. package/dist/tools/index.d.ts +3 -11
  52. package/dist/tools/index.js +17 -475
  53. package/dist/tools/member/handlers.d.ts +111 -0
  54. package/dist/tools/member/handlers.js +206 -0
  55. package/dist/tools/member/index.d.ts +169 -0
  56. package/dist/tools/member/index.js +92 -0
  57. package/dist/tools/member/schemas.d.ts +89 -0
  58. package/dist/tools/member/schemas.js +65 -0
  59. package/dist/tools/member.d.ts +21 -0
  60. package/dist/tools/member.js +56 -62
  61. package/dist/tools/points.d.ts +19 -6
  62. package/dist/tools/points.js +51 -49
  63. package/dist/tools/referral/handlers.d.ts +47 -0
  64. package/dist/tools/referral/handlers.js +115 -0
  65. package/dist/tools/referral/index.d.ts +44 -0
  66. package/dist/tools/referral/index.js +44 -0
  67. package/dist/tools/referral/schemas.d.ts +34 -0
  68. package/dist/tools/referral/schemas.js +52 -0
  69. package/dist/tools/reward/handlers.d.ts +110 -0
  70. package/dist/tools/reward/handlers.js +289 -0
  71. package/dist/tools/reward/index.d.ts +177 -0
  72. package/dist/tools/reward/index.js +90 -0
  73. package/dist/tools/reward/schemas.d.ts +116 -0
  74. package/dist/tools/reward/schemas.js +91 -0
  75. package/dist/tools/reward.d.ts +18 -0
  76. package/dist/tools/reward.js +56 -66
  77. package/dist/tools/role.d.ts +26 -7
  78. package/dist/tools/role.js +25 -12
  79. package/dist/tools/segment/handlers.d.ts +87 -0
  80. package/dist/tools/segment/handlers.js +174 -0
  81. package/dist/tools/segment/index.d.ts +395 -0
  82. package/dist/tools/segment/index.js +87 -0
  83. package/dist/tools/segment/schemas.d.ts +337 -0
  84. package/dist/tools/segment/schemas.js +79 -0
  85. package/dist/tools/segment.d.ts +29 -10
  86. package/dist/tools/segment.js +84 -50
  87. package/dist/tools/store.d.ts +12 -4
  88. package/dist/tools/store.js +16 -8
  89. package/dist/tools/tierset.d.ts +19 -7
  90. package/dist/tools/tierset.js +44 -35
  91. package/dist/tools/transaction.d.ts +16 -8
  92. package/dist/tools/transaction.js +25 -21
  93. package/dist/tools/wallet-type.d.ts +7 -3
  94. package/dist/tools/wallet-type.js +14 -12
  95. package/dist/tools/webhook.d.ts +23 -10
  96. package/dist/tools/webhook.js +135 -33
  97. package/dist/types/schemas/achievement.d.ts +12 -309
  98. package/dist/types/schemas/achievement.js +0 -13
  99. package/dist/types/schemas/admin.d.ts +10 -97
  100. package/dist/types/schemas/admin.js +0 -38
  101. package/dist/types/schemas/badge.d.ts +0 -37
  102. package/dist/types/schemas/badge.js +0 -11
  103. package/dist/types/schemas/campaign.d.ts +64 -832
  104. package/dist/types/schemas/campaign.js +2 -25
  105. package/dist/types/schemas/common.d.ts +5 -0
  106. package/dist/types/schemas/common.js +5 -0
  107. package/dist/types/schemas/export.d.ts +0 -17
  108. package/dist/types/schemas/export.js +0 -7
  109. package/dist/types/schemas/member.d.ts +37 -176
  110. package/dist/types/schemas/member.js +0 -27
  111. package/dist/types/schemas/points.d.ts +0 -63
  112. package/dist/types/schemas/points.js +0 -22
  113. package/dist/types/schemas/reward.d.ts +71 -68
  114. package/dist/types/schemas/reward.js +8 -28
  115. package/dist/types/schemas/role.d.ts +0 -100
  116. package/dist/types/schemas/role.js +0 -29
  117. package/dist/types/schemas/segment.d.ts +0 -58
  118. package/dist/types/schemas/segment.js +0 -17
  119. package/dist/types/schemas/tierset.d.ts +0 -176
  120. package/dist/types/schemas/tierset.js +0 -27
  121. package/dist/types/schemas/transaction.d.ts +23 -254
  122. package/dist/types/schemas/transaction.js +0 -7
  123. package/dist/types/schemas/wallet-type.d.ts +8 -8
  124. package/dist/types/schemas/wallet-type.js +1 -1
  125. package/dist/types/schemas/webhook.d.ts +0 -58
  126. package/dist/types/schemas/webhook.js +0 -12
  127. package/dist/utils/errors.js +30 -3
  128. package/dist/utils/payload.d.ts +12 -0
  129. package/dist/utils/payload.js +14 -0
  130. package/dist/workflows/app-login-streak.d.ts +39 -0
  131. package/dist/workflows/app-login-streak.js +298 -0
  132. package/dist/workflows/early-arrival.d.ts +33 -0
  133. package/dist/workflows/early-arrival.js +148 -0
  134. package/dist/workflows/index.d.ts +101 -0
  135. package/dist/workflows/index.js +208 -0
  136. package/dist/workflows/match-attendance.d.ts +45 -0
  137. package/dist/workflows/match-attendance.js +308 -0
  138. package/dist/workflows/sportsbar-visit.d.ts +41 -0
  139. package/dist/workflows/sportsbar-visit.js +284 -0
  140. package/dist/workflows/vod-watching.d.ts +43 -0
  141. package/dist/workflows/vod-watching.js +326 -0
  142. package/package.json +10 -2
@@ -0,0 +1,116 @@
1
+ import { z } from "zod";
2
+ export declare const RewardListInputSchema: {
3
+ storeCode: z.ZodOptional<z.ZodString>;
4
+ page: z.ZodOptional<z.ZodNumber>;
5
+ perPage: z.ZodOptional<z.ZodNumber>;
6
+ active: z.ZodOptional<z.ZodBoolean>;
7
+ type: z.ZodOptional<z.ZodEnum<["static_coupon", "dynamic_coupon", "conversion_coupon", "material", "fortune_wheel"]>>;
8
+ categoryId: z.ZodOptional<z.ZodString>;
9
+ };
10
+ export declare const RewardCreateInputSchema: {
11
+ storeCode: z.ZodOptional<z.ZodString>;
12
+ translations: z.ZodObject<{
13
+ en: z.ZodObject<{
14
+ name: z.ZodString;
15
+ }, "strip", z.ZodTypeAny, {
16
+ name: string;
17
+ }, {
18
+ name: string;
19
+ }>;
20
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
21
+ en: z.ZodObject<{
22
+ name: z.ZodString;
23
+ }, "strip", z.ZodTypeAny, {
24
+ name: string;
25
+ }, {
26
+ name: string;
27
+ }>;
28
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
29
+ en: z.ZodObject<{
30
+ name: z.ZodString;
31
+ }, "strip", z.ZodTypeAny, {
32
+ name: string;
33
+ }, {
34
+ name: string;
35
+ }>;
36
+ }, z.ZodTypeAny, "passthrough">>;
37
+ reward: z.ZodEnum<["static_coupon", "dynamic_coupon", "conversion_coupon", "material", "fortune_wheel"]>;
38
+ activity: z.ZodObject<{
39
+ from: z.ZodString;
40
+ to: z.ZodString;
41
+ }, "strip", z.ZodTypeAny, {
42
+ from: string;
43
+ to: string;
44
+ }, {
45
+ from: string;
46
+ to: string;
47
+ }>;
48
+ visibility: z.ZodObject<{
49
+ from: z.ZodString;
50
+ to: z.ZodString;
51
+ }, "strip", z.ZodTypeAny, {
52
+ from: string;
53
+ to: string;
54
+ }, {
55
+ from: string;
56
+ to: string;
57
+ }>;
58
+ usageLimit: z.ZodObject<{
59
+ perUser: z.ZodNumber;
60
+ general: z.ZodOptional<z.ZodNumber>;
61
+ }, "strip", z.ZodTypeAny, {
62
+ perUser: number;
63
+ general?: number | undefined;
64
+ }, {
65
+ perUser: number;
66
+ general?: number | undefined;
67
+ }>;
68
+ costInPoints: z.ZodOptional<z.ZodNumber>;
69
+ usageInstruction: z.ZodOptional<z.ZodString>;
70
+ active: z.ZodOptional<z.ZodBoolean>;
71
+ categories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
72
+ levels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
73
+ segments: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
74
+ target: z.ZodOptional<z.ZodNullable<z.ZodEnum<["level", "segment"]>>>;
75
+ couponValue: z.ZodOptional<z.ZodNumber>;
76
+ couponValueType: z.ZodOptional<z.ZodEnum<["money", "percentage"]>>;
77
+ daysValid: z.ZodOptional<z.ZodNumber>;
78
+ };
79
+ export declare const RewardGetInputSchema: {
80
+ storeCode: z.ZodOptional<z.ZodString>;
81
+ rewardId: z.ZodString;
82
+ };
83
+ export declare const RewardUpdateInputSchema: {
84
+ storeCode: z.ZodOptional<z.ZodString>;
85
+ rewardId: z.ZodString;
86
+ name: z.ZodOptional<z.ZodString>;
87
+ costInPoints: z.ZodOptional<z.ZodNumber>;
88
+ description: z.ZodOptional<z.ZodString>;
89
+ active: z.ZodOptional<z.ZodBoolean>;
90
+ categories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
91
+ levels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
92
+ segments: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
93
+ };
94
+ export declare const RewardIdInputSchema: {
95
+ storeCode: z.ZodOptional<z.ZodString>;
96
+ rewardId: z.ZodString;
97
+ };
98
+ export declare const RewardBuyInputSchema: {
99
+ storeCode: z.ZodOptional<z.ZodString>;
100
+ rewardId: z.ZodString;
101
+ memberId: z.ZodString;
102
+ quantity: z.ZodOptional<z.ZodNumber>;
103
+ couponValue: z.ZodOptional<z.ZodNumber>;
104
+ withoutPoints: z.ZodOptional<z.ZodBoolean>;
105
+ };
106
+ export declare const RewardRedeemInputSchema: {
107
+ storeCode: z.ZodOptional<z.ZodString>;
108
+ memberId: z.ZodString;
109
+ couponCode: z.ZodString;
110
+ };
111
+ export declare const RewardCategoryListInputSchema: {
112
+ storeCode: z.ZodOptional<z.ZodString>;
113
+ page: z.ZodOptional<z.ZodNumber>;
114
+ perPage: z.ZodOptional<z.ZodNumber>;
115
+ active: z.ZodOptional<z.ZodBoolean>;
116
+ };
@@ -0,0 +1,91 @@
1
+ import { z } from "zod";
2
+ export const RewardListInputSchema = {
3
+ 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."),
4
+ page: z.number().optional().describe("Page number (default: 1)."),
5
+ perPage: z.number().optional().describe("Items per page (default: 10)."),
6
+ active: z.boolean().optional().describe("Filter by active status."),
7
+ type: z.enum(["static_coupon", "dynamic_coupon", "conversion_coupon", "material", "fortune_wheel"]).optional().describe("Filter by reward type."),
8
+ categoryId: z.string().optional().describe("Filter by category ID."),
9
+ };
10
+ // Translations schema for rewards (API requires translations.en at minimum)
11
+ // Note: translations.en must ONLY contain name, description is a separate field at top level
12
+ const RewardTranslationsInputSchema = z.object({
13
+ en: z.object({
14
+ name: z.string().describe("Reward name in English (required)."),
15
+ }),
16
+ }).passthrough().describe("Translations object with at least 'en' key containing { name }. Description goes at top level.");
17
+ // Activity period schema (REQUIRED by API)
18
+ // API requires datetime format: YYYY-MM-DD HH:mm (NOT just YYYY-MM-DD)
19
+ const RewardActivityInputSchema = z.object({
20
+ from: z.string().describe("Start datetime (format: 'YYYY-MM-DD HH:mm', e.g., '2026-01-01 00:00'). REQUIRED."),
21
+ to: z.string().describe("End datetime (format: 'YYYY-MM-DD HH:mm', e.g., '2026-12-31 23:59'). REQUIRED."),
22
+ });
23
+ // Visibility period schema (REQUIRED by API)
24
+ // API requires datetime format: YYYY-MM-DD HH:mm (NOT just YYYY-MM-DD)
25
+ const RewardVisibilityInputSchema = z.object({
26
+ from: z.string().describe("Visibility start datetime (format: 'YYYY-MM-DD HH:mm'). REQUIRED."),
27
+ to: z.string().describe("Visibility end datetime (format: 'YYYY-MM-DD HH:mm'). REQUIRED."),
28
+ });
29
+ // Usage limit schema (REQUIRED by API for coupon types)
30
+ // NOTE: API uses 'general' (not 'total') for total redemptions limit
31
+ const RewardUsageLimitInputSchema = z.object({
32
+ perUser: z.number().describe("Maximum redemptions per member. REQUIRED for coupon types."),
33
+ general: z.number().optional().describe("Total redemptions across all members (API calls this 'general')."),
34
+ });
35
+ export const RewardCreateInputSchema = {
36
+ 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."),
37
+ translations: RewardTranslationsInputSchema.describe("Reward name translations. At least 'en' key with { name } is REQUIRED."),
38
+ reward: z.enum(["static_coupon", "dynamic_coupon", "conversion_coupon", "material", "fortune_wheel"]).describe("Reward type: static_coupon (fixed discount), dynamic_coupon (variable value), " +
39
+ "conversion_coupon (converts points to coupon), material (physical goods), fortune_wheel (gamified)."),
40
+ activity: RewardActivityInputSchema.describe("Activity period when reward can be purchased. Use datetime format 'YYYY-MM-DD HH:mm'. REQUIRED."),
41
+ visibility: RewardVisibilityInputSchema.describe("Visibility period when reward is shown. Use datetime format 'YYYY-MM-DD HH:mm'. REQUIRED."),
42
+ usageLimit: RewardUsageLimitInputSchema.describe("Usage limits. perUser is REQUIRED for coupon types."),
43
+ costInPoints: z.number().optional().describe("Points required to redeem this reward."),
44
+ usageInstruction: z.string().optional().describe("Instructions for using the reward."),
45
+ active: z.boolean().optional().describe("Whether reward is active (default: false)."),
46
+ categories: z.array(z.string()).optional().describe("Array of category UUIDs."),
47
+ levels: z.array(z.string()).optional().describe("Array of tier level UUIDs that can see/redeem."),
48
+ segments: z.array(z.string()).optional().describe("Array of segment UUIDs that can see/redeem."),
49
+ target: z.enum(["level", "segment"]).nullable().optional().describe("Target type for visibility: level (tier-based), segment (segment-based), or null (all)."),
50
+ couponValue: z.number().optional().describe("Coupon value (required for static_coupon)."),
51
+ couponValueType: z.enum(["money", "percentage"]).optional().describe("Coupon value type: 'money' or 'percentage' (lowercase)."),
52
+ daysValid: z.number().optional().describe("Days the coupon remains valid after purchase."),
53
+ };
54
+ export const RewardGetInputSchema = {
55
+ 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."),
56
+ rewardId: z.string().describe("The reward ID (UUID) to retrieve."),
57
+ };
58
+ export const RewardUpdateInputSchema = {
59
+ 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."),
60
+ rewardId: z.string().describe("The reward ID (UUID) to update."),
61
+ name: z.string().optional().describe("Reward name."),
62
+ costInPoints: z.number().optional().describe("Points required to redeem."),
63
+ description: z.string().optional().describe("Reward description."),
64
+ active: z.boolean().optional().describe("Whether reward is active."),
65
+ categories: z.array(z.string()).optional().describe("Array of category UUIDs."),
66
+ levels: z.array(z.string()).optional().describe("Array of tier level UUIDs."),
67
+ segments: z.array(z.string()).optional().describe("Array of segment UUIDs."),
68
+ };
69
+ export const RewardIdInputSchema = {
70
+ 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."),
71
+ rewardId: z.string().describe("The reward ID (UUID)."),
72
+ };
73
+ export const RewardBuyInputSchema = {
74
+ 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."),
75
+ rewardId: z.string().describe("The reward ID (UUID) to purchase."),
76
+ memberId: z.string().describe("The member ID (UUID) purchasing the reward."),
77
+ quantity: z.number().optional().describe("Number of rewards to purchase (1-32, default: 1)."),
78
+ couponValue: z.number().optional().describe("Coupon value (for dynamic coupons)."),
79
+ withoutPoints: z.boolean().optional().describe("Admin only: skip points deduction."),
80
+ };
81
+ export const RewardRedeemInputSchema = {
82
+ 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."),
83
+ memberId: z.string().describe("The member ID (UUID) redeeming the coupon."),
84
+ couponCode: z.string().describe("The coupon code to redeem."),
85
+ };
86
+ export const RewardCategoryListInputSchema = {
87
+ 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."),
88
+ page: z.number().optional().describe("Page number (default: 1)."),
89
+ perPage: z.number().optional().describe("Items per page (default: 10)."),
90
+ active: z.boolean().optional().describe("Filter by active status."),
91
+ };
@@ -158,7 +158,9 @@ export declare function rewardCategoryList(input: {
158
158
  }>;
159
159
  export declare const rewardToolDefinitions: readonly [{
160
160
  readonly name: "openloyalty_reward_list";
161
+ readonly title: "Browse Rewards";
161
162
  readonly description: string;
163
+ readonly readOnly: true;
162
164
  readonly inputSchema: {
163
165
  storeCode: z.ZodOptional<z.ZodString>;
164
166
  page: z.ZodOptional<z.ZodNumber>;
@@ -170,7 +172,9 @@ export declare const rewardToolDefinitions: readonly [{
170
172
  readonly handler: typeof rewardList;
171
173
  }, {
172
174
  readonly name: "openloyalty_reward_create";
175
+ readonly title: "Create New Reward";
173
176
  readonly description: string;
177
+ readonly readOnly: false;
174
178
  readonly inputSchema: {
175
179
  storeCode: z.ZodOptional<z.ZodString>;
176
180
  name: z.ZodString;
@@ -190,7 +194,9 @@ export declare const rewardToolDefinitions: readonly [{
190
194
  readonly handler: typeof rewardCreate;
191
195
  }, {
192
196
  readonly name: "openloyalty_reward_get";
197
+ readonly title: "Get Reward Details";
193
198
  readonly description: "Get full reward details including configuration, targeting, and coupon settings.";
199
+ readonly readOnly: true;
194
200
  readonly inputSchema: {
195
201
  storeCode: z.ZodOptional<z.ZodString>;
196
202
  rewardId: z.ZodString;
@@ -198,7 +204,9 @@ export declare const rewardToolDefinitions: readonly [{
198
204
  readonly handler: typeof rewardGet;
199
205
  }, {
200
206
  readonly name: "openloyalty_reward_update";
207
+ readonly title: "Update Reward";
201
208
  readonly description: "Update reward configuration. Cannot change reward type after creation.";
209
+ readonly readOnly: false;
202
210
  readonly inputSchema: {
203
211
  storeCode: z.ZodOptional<z.ZodString>;
204
212
  rewardId: z.ZodString;
@@ -213,7 +221,9 @@ export declare const rewardToolDefinitions: readonly [{
213
221
  readonly handler: typeof rewardUpdate;
214
222
  }, {
215
223
  readonly name: "openloyalty_reward_activate";
224
+ readonly title: "Activate Reward";
216
225
  readonly description: "Activate a reward, making it available for members to redeem.";
226
+ readonly readOnly: false;
217
227
  readonly inputSchema: {
218
228
  storeCode: z.ZodOptional<z.ZodString>;
219
229
  rewardId: z.ZodString;
@@ -221,7 +231,9 @@ export declare const rewardToolDefinitions: readonly [{
221
231
  readonly handler: typeof rewardActivate;
222
232
  }, {
223
233
  readonly name: "openloyalty_reward_deactivate";
234
+ readonly title: "Deactivate Reward";
224
235
  readonly description: "Deactivate a reward, hiding it from members. Already purchased rewards remain valid.";
236
+ readonly readOnly: false;
225
237
  readonly inputSchema: {
226
238
  storeCode: z.ZodOptional<z.ZodString>;
227
239
  rewardId: z.ZodString;
@@ -229,7 +241,9 @@ export declare const rewardToolDefinitions: readonly [{
229
241
  readonly handler: typeof rewardDeactivate;
230
242
  }, {
231
243
  readonly name: "openloyalty_reward_buy";
244
+ readonly title: "Redeem Reward for Member";
232
245
  readonly description: string;
246
+ readonly readOnly: false;
233
247
  readonly inputSchema: {
234
248
  storeCode: z.ZodOptional<z.ZodString>;
235
249
  rewardId: z.ZodString;
@@ -241,7 +255,9 @@ export declare const rewardToolDefinitions: readonly [{
241
255
  readonly handler: typeof rewardBuy;
242
256
  }, {
243
257
  readonly name: "openloyalty_reward_redeem";
258
+ readonly title: "Use Coupon Code";
244
259
  readonly description: string;
260
+ readonly readOnly: false;
245
261
  readonly inputSchema: {
246
262
  storeCode: z.ZodOptional<z.ZodString>;
247
263
  memberId: z.ZodString;
@@ -250,7 +266,9 @@ export declare const rewardToolDefinitions: readonly [{
250
266
  readonly handler: typeof rewardRedeem;
251
267
  }, {
252
268
  readonly name: "openloyalty_reward_category_list";
269
+ readonly title: "List Reward Categories";
253
270
  readonly description: "List reward categories. Use categoryId when creating or filtering rewards.";
271
+ readonly readOnly: true;
254
272
  readonly inputSchema: {
255
273
  storeCode: z.ZodOptional<z.ZodString>;
256
274
  page: z.ZodOptional<z.ZodNumber>;
@@ -2,7 +2,8 @@ import { z } from "zod";
2
2
  import { apiGet, apiPost, apiPut } from "../client/http.js";
3
3
  import { RewardSchema, } from "../types/schemas/reward.js";
4
4
  import { formatApiError, OpenLoyaltyError } from "../utils/errors.js";
5
- import { getConfig } from "../config.js";
5
+ import { getStoreCode } from "../config.js";
6
+ import { omitUndefined } from "../utils/payload.js";
6
7
  // Input Schemas
7
8
  export const RewardListInputSchema = {
8
9
  storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
@@ -69,8 +70,7 @@ export const RewardCategoryListInputSchema = {
69
70
  };
70
71
  // Handler functions
71
72
  export async function rewardList(input) {
72
- const config = getConfig();
73
- const storeCode = input.storeCode || config.defaultStoreCode;
73
+ const storeCode = getStoreCode(input.storeCode);
74
74
  const params = new URLSearchParams();
75
75
  if (input.page)
76
76
  params.append("_page", String(input.page));
@@ -111,34 +111,22 @@ export async function rewardList(input) {
111
111
  }
112
112
  }
113
113
  export async function rewardCreate(input) {
114
- const config = getConfig();
115
- const storeCode = input.storeCode || config.defaultStoreCode;
116
- const payload = {
114
+ const storeCode = getStoreCode(input.storeCode);
115
+ const payload = omitUndefined({
117
116
  name: input.name,
118
117
  type: input.type,
119
- };
120
- if (input.costInPoints !== undefined)
121
- payload.costInPoints = input.costInPoints;
122
- if (input.description)
123
- payload.description = input.description;
124
- if (input.usageInstruction)
125
- payload.usageInstruction = input.usageInstruction;
126
- if (input.active !== undefined)
127
- payload.active = input.active;
128
- if (input.categories)
129
- payload.categories = input.categories;
130
- if (input.levels)
131
- payload.levels = input.levels;
132
- if (input.segments)
133
- payload.segments = input.segments;
134
- if (input.target !== undefined)
135
- payload.target = input.target;
136
- if (input.couponValue !== undefined)
137
- payload.couponValue = input.couponValue;
138
- if (input.couponValueType)
139
- payload.couponValueType = input.couponValueType;
140
- if (input.daysValid !== undefined)
141
- payload.daysValid = input.daysValid;
118
+ costInPoints: input.costInPoints,
119
+ description: input.description,
120
+ usageInstruction: input.usageInstruction,
121
+ active: input.active,
122
+ categories: input.categories,
123
+ levels: input.levels,
124
+ segments: input.segments,
125
+ target: input.target,
126
+ couponValue: input.couponValue,
127
+ couponValueType: input.couponValueType,
128
+ daysValid: input.daysValid,
129
+ });
142
130
  try {
143
131
  const response = await apiPost(`/${storeCode}/reward`, { reward: payload });
144
132
  return {
@@ -152,8 +140,7 @@ export async function rewardCreate(input) {
152
140
  }
153
141
  }
154
142
  export async function rewardGet(input) {
155
- const config = getConfig();
156
- const storeCode = input.storeCode || config.defaultStoreCode;
143
+ const storeCode = getStoreCode(input.storeCode);
157
144
  try {
158
145
  const response = await apiGet(`/${storeCode}/reward/${input.rewardId}`);
159
146
  return RewardSchema.parse(response);
@@ -163,23 +150,16 @@ export async function rewardGet(input) {
163
150
  }
164
151
  }
165
152
  export async function rewardUpdate(input) {
166
- const config = getConfig();
167
- const storeCode = input.storeCode || config.defaultStoreCode;
168
- const payload = {};
169
- if (input.name)
170
- payload.name = input.name;
171
- if (input.costInPoints !== undefined)
172
- payload.costInPoints = input.costInPoints;
173
- if (input.description)
174
- payload.description = input.description;
175
- if (input.active !== undefined)
176
- payload.active = input.active;
177
- if (input.categories)
178
- payload.categories = input.categories;
179
- if (input.levels)
180
- payload.levels = input.levels;
181
- if (input.segments)
182
- payload.segments = input.segments;
153
+ const storeCode = getStoreCode(input.storeCode);
154
+ const payload = omitUndefined({
155
+ name: input.name,
156
+ costInPoints: input.costInPoints,
157
+ description: input.description,
158
+ active: input.active,
159
+ categories: input.categories,
160
+ levels: input.levels,
161
+ segments: input.segments,
162
+ });
183
163
  try {
184
164
  await apiPut(`/${storeCode}/reward/${input.rewardId}`, { reward: payload });
185
165
  }
@@ -188,8 +168,7 @@ export async function rewardUpdate(input) {
188
168
  }
189
169
  }
190
170
  export async function rewardActivate(input) {
191
- const config = getConfig();
192
- const storeCode = input.storeCode || config.defaultStoreCode;
171
+ const storeCode = getStoreCode(input.storeCode);
193
172
  try {
194
173
  await apiPost(`/${storeCode}/reward/${input.rewardId}/activate`);
195
174
  }
@@ -198,8 +177,7 @@ export async function rewardActivate(input) {
198
177
  }
199
178
  }
200
179
  export async function rewardDeactivate(input) {
201
- const config = getConfig();
202
- const storeCode = input.storeCode || config.defaultStoreCode;
180
+ const storeCode = getStoreCode(input.storeCode);
203
181
  try {
204
182
  await apiPost(`/${storeCode}/reward/${input.rewardId}/deactivate`);
205
183
  }
@@ -208,17 +186,13 @@ export async function rewardDeactivate(input) {
208
186
  }
209
187
  }
210
188
  export async function rewardBuy(input) {
211
- const config = getConfig();
212
- const storeCode = input.storeCode || config.defaultStoreCode;
213
- const payload = {
189
+ const storeCode = getStoreCode(input.storeCode);
190
+ const payload = omitUndefined({
214
191
  customerId: input.memberId,
215
- };
216
- if (input.quantity)
217
- payload.quantity = input.quantity;
218
- if (input.couponValue !== undefined)
219
- payload.couponValue = input.couponValue;
220
- if (input.withoutPoints !== undefined)
221
- payload.withoutPoints = input.withoutPoints;
192
+ quantity: input.quantity,
193
+ couponValue: input.couponValue,
194
+ withoutPoints: input.withoutPoints,
195
+ });
222
196
  try {
223
197
  const response = await apiPost(`/${storeCode}/reward/${input.rewardId}/buy`, payload);
224
198
  // API returns array of issued rewards
@@ -242,8 +216,7 @@ export async function rewardBuy(input) {
242
216
  }
243
217
  }
244
218
  export async function rewardRedeem(input) {
245
- const config = getConfig();
246
- const storeCode = input.storeCode || config.defaultStoreCode;
219
+ const storeCode = getStoreCode(input.storeCode);
247
220
  try {
248
221
  const response = await apiPost(`/${storeCode}/member/${input.memberId}/reward/redeem`, { couponCode: input.couponCode });
249
222
  return { code: response.code || input.couponCode, used: true };
@@ -278,8 +251,7 @@ export async function rewardRedeem(input) {
278
251
  }
279
252
  }
280
253
  export async function rewardCategoryList(input) {
281
- const config = getConfig();
282
- const storeCode = input.storeCode || config.defaultStoreCode;
254
+ const storeCode = getStoreCode(input.storeCode);
283
255
  const params = new URLSearchParams();
284
256
  if (input.page)
285
257
  params.append("_page", String(input.page));
@@ -310,61 +282,79 @@ export async function rewardCategoryList(input) {
310
282
  export const rewardToolDefinitions = [
311
283
  {
312
284
  name: "openloyalty_reward_list",
285
+ title: "Browse Rewards",
313
286
  description: "List available rewards. Use reward_get for full details or reward_buy to redeem. " +
314
287
  "Filter by type, active status, or category.",
288
+ readOnly: true,
315
289
  inputSchema: RewardListInputSchema,
316
290
  handler: rewardList,
317
291
  },
318
292
  {
319
293
  name: "openloyalty_reward_create",
294
+ title: "Create New Reward",
320
295
  description: "Create a new reward that members can redeem with points. " +
321
296
  "Types: static_coupon (fixed discount), dynamic_coupon (variable value set at purchase), " +
322
297
  "material (physical goods), conversion_coupon (converts points), fortune_wheel (gamified). " +
323
298
  "Returns rewardId.",
299
+ readOnly: false,
324
300
  inputSchema: RewardCreateInputSchema,
325
301
  handler: rewardCreate,
326
302
  },
327
303
  {
328
304
  name: "openloyalty_reward_get",
305
+ title: "Get Reward Details",
329
306
  description: "Get full reward details including configuration, targeting, and coupon settings.",
307
+ readOnly: true,
330
308
  inputSchema: RewardGetInputSchema,
331
309
  handler: rewardGet,
332
310
  },
333
311
  {
334
312
  name: "openloyalty_reward_update",
313
+ title: "Update Reward",
335
314
  description: "Update reward configuration. Cannot change reward type after creation.",
315
+ readOnly: false,
336
316
  inputSchema: RewardUpdateInputSchema,
337
317
  handler: rewardUpdate,
338
318
  },
339
319
  {
340
320
  name: "openloyalty_reward_activate",
321
+ title: "Activate Reward",
341
322
  description: "Activate a reward, making it available for members to redeem.",
323
+ readOnly: false,
342
324
  inputSchema: RewardIdInputSchema,
343
325
  handler: rewardActivate,
344
326
  },
345
327
  {
346
328
  name: "openloyalty_reward_deactivate",
329
+ title: "Deactivate Reward",
347
330
  description: "Deactivate a reward, hiding it from members. Already purchased rewards remain valid.",
331
+ readOnly: false,
348
332
  inputSchema: RewardIdInputSchema,
349
333
  handler: rewardDeactivate,
350
334
  },
351
335
  {
352
336
  name: "openloyalty_reward_buy",
337
+ title: "Redeem Reward for Member",
353
338
  description: "Purchase reward for member, deducting points. Returns issuedRewardId and couponCode if applicable. " +
354
339
  "Use reward_redeem to mark the coupon as used.",
340
+ readOnly: false,
355
341
  inputSchema: RewardBuyInputSchema,
356
342
  handler: rewardBuy,
357
343
  },
358
344
  {
359
345
  name: "openloyalty_reward_redeem",
346
+ title: "Use Coupon Code",
360
347
  description: "Mark coupon as used. Validates coupon exists, belongs to member, and is active. " +
361
348
  "Fails if coupon is expired, already used, or doesn't exist.",
349
+ readOnly: false,
362
350
  inputSchema: RewardRedeemInputSchema,
363
351
  handler: rewardRedeem,
364
352
  },
365
353
  {
366
354
  name: "openloyalty_reward_category_list",
355
+ title: "List Reward Categories",
367
356
  description: "List reward categories. Use categoryId when creating or filtering rewards.",
357
+ readOnly: true,
368
358
  inputSchema: RewardCategoryListInputSchema,
369
359
  handler: rewardCategoryList,
370
360
  },
@@ -1,5 +1,10 @@
1
1
  import { z } from "zod";
2
- import { Role, RoleListItem, ACLResource, RolePermissionInput } from "../types/schemas/role.js";
2
+ import { Role, RoleListItem, ACLResource } from "../types/schemas/role.js";
3
+ interface RolePermissionInput {
4
+ resource: string;
5
+ access: string;
6
+ filterQuery?: string;
7
+ }
3
8
  export declare const RoleListInputSchema: {
4
9
  page: z.ZodOptional<z.ZodNumber>;
5
10
  perPage: z.ZodOptional<z.ZodNumber>;
@@ -84,8 +89,10 @@ export declare function aclGetResources(): Promise<{
84
89
  total?: Record<string, unknown>;
85
90
  }>;
86
91
  export declare const roleToolDefinitions: readonly [{
87
- readonly name: "openloyalty_role_list";
92
+ readonly name: "ol_role_list";
93
+ readonly title: "List Roles";
88
94
  readonly description: "List all roles with optional filtering. Returns paginated list of roles with id, name, permissions, master status, and default status.";
95
+ readonly readOnly: true;
89
96
  readonly inputSchema: {
90
97
  page: z.ZodOptional<z.ZodNumber>;
91
98
  perPage: z.ZodOptional<z.ZodNumber>;
@@ -95,8 +102,10 @@ export declare const roleToolDefinitions: readonly [{
95
102
  };
96
103
  readonly handler: typeof roleList;
97
104
  }, {
98
- readonly name: "openloyalty_role_create";
105
+ readonly name: "ol_role_create";
106
+ readonly title: "Create Role";
99
107
  readonly description: "Create a new role with permissions. Requires name. Optionally specify permissions (array of {resource, access, filterQuery}) and stores. Returns void on success (201 Created).";
108
+ readonly readOnly: false;
100
109
  readonly inputSchema: {
101
110
  name: z.ZodString;
102
111
  permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -117,15 +126,19 @@ export declare const roleToolDefinitions: readonly [{
117
126
  };
118
127
  readonly handler: typeof roleCreate;
119
128
  }, {
120
- readonly name: "openloyalty_role_get";
129
+ readonly name: "ol_role_get";
130
+ readonly title: "Get Role Details";
121
131
  readonly description: "Get full role details by ID. Returns role with name, permissions array, master status, default status, and stores.";
132
+ readonly readOnly: true;
122
133
  readonly inputSchema: {
123
134
  roleId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
124
135
  };
125
136
  readonly handler: typeof roleGet;
126
137
  }, {
127
- readonly name: "openloyalty_role_update";
138
+ readonly name: "ol_role_update";
139
+ readonly title: "Update Role";
128
140
  readonly description: "Update a role's name, permissions, or stores. Returns void on success (204 No Content).";
141
+ readonly readOnly: false;
129
142
  readonly inputSchema: {
130
143
  roleId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
131
144
  name: z.ZodOptional<z.ZodString>;
@@ -147,15 +160,21 @@ export declare const roleToolDefinitions: readonly [{
147
160
  };
148
161
  readonly handler: typeof roleUpdate;
149
162
  }, {
150
- readonly name: "openloyalty_role_delete";
163
+ readonly name: "ol_role_delete";
164
+ readonly title: "Delete Role (Permanent)";
151
165
  readonly description: "Delete a role by ID. Returns void on success (204 No Content). Cannot delete roles that are assigned to admin users.";
166
+ readonly readOnly: false;
167
+ readonly destructive: true;
152
168
  readonly inputSchema: {
153
169
  roleId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
154
170
  };
155
171
  readonly handler: typeof roleDelete;
156
172
  }, {
157
- readonly name: "openloyalty_acl_get_resources";
173
+ readonly name: "ol_acl_get_resources";
174
+ readonly title: "Get ACL Resources";
158
175
  readonly description: "Get list of available ACL resources. Returns items with code and name for each resource type. Use this to discover available permissions before creating roles.";
176
+ readonly readOnly: true;
159
177
  readonly inputSchema: {};
160
178
  readonly handler: typeof aclGetResources;
161
179
  }];
180
+ export {};