@open-loyalty/mcp-server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +654 -0
- package/dist/client/http.d.ts +8 -0
- package/dist/client/http.js +69 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +40 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +334 -0
- package/dist/tools/achievement.d.ts +983 -0
- package/dist/tools/achievement.js +311 -0
- package/dist/tools/admin.d.ts +153 -0
- package/dist/tools/admin.js +193 -0
- package/dist/tools/analytics.d.ts +162 -0
- package/dist/tools/analytics.js +245 -0
- package/dist/tools/apikey.d.ts +72 -0
- package/dist/tools/apikey.js +78 -0
- package/dist/tools/audit.d.ts +107 -0
- package/dist/tools/audit.js +90 -0
- package/dist/tools/badge.d.ts +135 -0
- package/dist/tools/badge.js +165 -0
- package/dist/tools/campaign.d.ts +1775 -0
- package/dist/tools/campaign.js +724 -0
- package/dist/tools/export.d.ts +110 -0
- package/dist/tools/export.js +147 -0
- package/dist/tools/import.d.ts +110 -0
- package/dist/tools/import.js +126 -0
- package/dist/tools/index.d.ts +22 -0
- package/dist/tools/index.js +527 -0
- package/dist/tools/member.d.ts +345 -0
- package/dist/tools/member.js +358 -0
- package/dist/tools/member.test.d.ts +1 -0
- package/dist/tools/member.test.js +213 -0
- package/dist/tools/points.d.ts +188 -0
- package/dist/tools/points.js +306 -0
- package/dist/tools/points.test.d.ts +1 -0
- package/dist/tools/points.test.js +292 -0
- package/dist/tools/reward.d.ts +261 -0
- package/dist/tools/reward.js +371 -0
- package/dist/tools/reward.test.d.ts +1 -0
- package/dist/tools/reward.test.js +240 -0
- package/dist/tools/role.d.ts +161 -0
- package/dist/tools/role.js +160 -0
- package/dist/tools/segment.d.ts +797 -0
- package/dist/tools/segment.js +299 -0
- package/dist/tools/store.d.ts +101 -0
- package/dist/tools/store.js +117 -0
- package/dist/tools/tierset.d.ts +288 -0
- package/dist/tools/tierset.js +244 -0
- package/dist/tools/transaction.d.ts +357 -0
- package/dist/tools/transaction.js +242 -0
- package/dist/tools/transaction.test.d.ts +1 -0
- package/dist/tools/transaction.test.js +235 -0
- package/dist/tools/wallet-type.d.ts +32 -0
- package/dist/tools/wallet-type.js +58 -0
- package/dist/tools/webhook.d.ts +179 -0
- package/dist/tools/webhook.js +171 -0
- package/dist/types/schemas/achievement.d.ts +1116 -0
- package/dist/types/schemas/achievement.js +172 -0
- package/dist/types/schemas/admin.d.ts +263 -0
- package/dist/types/schemas/admin.js +99 -0
- package/dist/types/schemas/analytics.d.ts +542 -0
- package/dist/types/schemas/analytics.js +130 -0
- package/dist/types/schemas/badge.d.ts +131 -0
- package/dist/types/schemas/badge.js +48 -0
- package/dist/types/schemas/campaign.d.ts +2005 -0
- package/dist/types/schemas/campaign.js +189 -0
- package/dist/types/schemas/common.d.ts +52 -0
- package/dist/types/schemas/common.js +26 -0
- package/dist/types/schemas/export.d.ts +127 -0
- package/dist/types/schemas/export.js +43 -0
- package/dist/types/schemas/import.d.ts +344 -0
- package/dist/types/schemas/import.js +68 -0
- package/dist/types/schemas/member.d.ts +443 -0
- package/dist/types/schemas/member.js +92 -0
- package/dist/types/schemas/points.d.ts +188 -0
- package/dist/types/schemas/points.js +54 -0
- package/dist/types/schemas/reward.d.ts +278 -0
- package/dist/types/schemas/reward.js +69 -0
- package/dist/types/schemas/role.d.ts +260 -0
- package/dist/types/schemas/role.js +75 -0
- package/dist/types/schemas/segment.d.ts +592 -0
- package/dist/types/schemas/segment.js +114 -0
- package/dist/types/schemas/tierset.d.ts +552 -0
- package/dist/types/schemas/tierset.js +87 -0
- package/dist/types/schemas/transaction.d.ts +1022 -0
- package/dist/types/schemas/transaction.js +63 -0
- package/dist/types/schemas/wallet-type.d.ts +99 -0
- package/dist/types/schemas/wallet-type.js +17 -0
- package/dist/types/schemas/webhook.d.ts +195 -0
- package/dist/types/schemas/webhook.js +39 -0
- package/dist/utils/cursor.d.ts +84 -0
- package/dist/utils/cursor.js +117 -0
- package/dist/utils/errors.d.ts +12 -0
- package/dist/utils/errors.js +69 -0
- package/dist/utils/pagination.d.ts +39 -0
- package/dist/utils/pagination.js +77 -0
- package/package.json +65 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Role Permission Schema.
|
|
4
|
+
* Represents a permission entry within a role.
|
|
5
|
+
*/
|
|
6
|
+
export declare const RolePermissionSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
resource: z.ZodString;
|
|
9
|
+
access: z.ZodString;
|
|
10
|
+
filterQuery: z.ZodOptional<z.ZodString>;
|
|
11
|
+
role: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
resource: string;
|
|
14
|
+
access: string;
|
|
15
|
+
id?: number | undefined;
|
|
16
|
+
role?: Record<string, unknown> | undefined;
|
|
17
|
+
filterQuery?: string | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
resource: string;
|
|
20
|
+
access: string;
|
|
21
|
+
id?: number | undefined;
|
|
22
|
+
role?: Record<string, unknown> | undefined;
|
|
23
|
+
filterQuery?: string | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export type RolePermission = z.infer<typeof RolePermissionSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Role Schema.
|
|
28
|
+
* Full role from GET /api/acl/role/{roleId}
|
|
29
|
+
*/
|
|
30
|
+
export declare const RoleSchema: z.ZodObject<{
|
|
31
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
32
|
+
role: z.ZodOptional<z.ZodString>;
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
master: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
37
|
+
id: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
resource: z.ZodString;
|
|
39
|
+
access: z.ZodString;
|
|
40
|
+
filterQuery: z.ZodOptional<z.ZodString>;
|
|
41
|
+
role: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
resource: string;
|
|
44
|
+
access: string;
|
|
45
|
+
id?: number | undefined;
|
|
46
|
+
role?: Record<string, unknown> | undefined;
|
|
47
|
+
filterQuery?: string | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
resource: string;
|
|
50
|
+
access: string;
|
|
51
|
+
id?: number | undefined;
|
|
52
|
+
role?: Record<string, unknown> | undefined;
|
|
53
|
+
filterQuery?: string | undefined;
|
|
54
|
+
}>, "many">>;
|
|
55
|
+
stores: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
name: string;
|
|
58
|
+
id: string | number;
|
|
59
|
+
role?: string | undefined;
|
|
60
|
+
master?: boolean | undefined;
|
|
61
|
+
default?: boolean | undefined;
|
|
62
|
+
permissions?: {
|
|
63
|
+
resource: string;
|
|
64
|
+
access: string;
|
|
65
|
+
id?: number | undefined;
|
|
66
|
+
role?: Record<string, unknown> | undefined;
|
|
67
|
+
filterQuery?: string | undefined;
|
|
68
|
+
}[] | undefined;
|
|
69
|
+
stores?: string[] | undefined;
|
|
70
|
+
}, {
|
|
71
|
+
name: string;
|
|
72
|
+
id: string | number;
|
|
73
|
+
role?: string | undefined;
|
|
74
|
+
master?: boolean | undefined;
|
|
75
|
+
default?: boolean | undefined;
|
|
76
|
+
permissions?: {
|
|
77
|
+
resource: string;
|
|
78
|
+
access: string;
|
|
79
|
+
id?: number | undefined;
|
|
80
|
+
role?: Record<string, unknown> | undefined;
|
|
81
|
+
filterQuery?: string | undefined;
|
|
82
|
+
}[] | undefined;
|
|
83
|
+
stores?: string[] | undefined;
|
|
84
|
+
}>;
|
|
85
|
+
export type Role = z.infer<typeof RoleSchema>;
|
|
86
|
+
/**
|
|
87
|
+
* Role List Item Schema.
|
|
88
|
+
* Used in list responses.
|
|
89
|
+
*/
|
|
90
|
+
export declare const RoleListItemSchema: z.ZodObject<{
|
|
91
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
92
|
+
role: z.ZodOptional<z.ZodString>;
|
|
93
|
+
name: z.ZodString;
|
|
94
|
+
master: z.ZodOptional<z.ZodBoolean>;
|
|
95
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
96
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
97
|
+
id: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
resource: z.ZodString;
|
|
99
|
+
access: z.ZodString;
|
|
100
|
+
filterQuery: z.ZodOptional<z.ZodString>;
|
|
101
|
+
role: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
resource: string;
|
|
104
|
+
access: string;
|
|
105
|
+
id?: number | undefined;
|
|
106
|
+
role?: Record<string, unknown> | undefined;
|
|
107
|
+
filterQuery?: string | undefined;
|
|
108
|
+
}, {
|
|
109
|
+
resource: string;
|
|
110
|
+
access: string;
|
|
111
|
+
id?: number | undefined;
|
|
112
|
+
role?: Record<string, unknown> | undefined;
|
|
113
|
+
filterQuery?: string | undefined;
|
|
114
|
+
}>, "many">>;
|
|
115
|
+
stores: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
name: string;
|
|
118
|
+
id: string | number;
|
|
119
|
+
role?: string | undefined;
|
|
120
|
+
master?: boolean | undefined;
|
|
121
|
+
default?: boolean | undefined;
|
|
122
|
+
permissions?: {
|
|
123
|
+
resource: string;
|
|
124
|
+
access: string;
|
|
125
|
+
id?: number | undefined;
|
|
126
|
+
role?: Record<string, unknown> | undefined;
|
|
127
|
+
filterQuery?: string | undefined;
|
|
128
|
+
}[] | undefined;
|
|
129
|
+
stores?: string[] | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
name: string;
|
|
132
|
+
id: string | number;
|
|
133
|
+
role?: string | undefined;
|
|
134
|
+
master?: boolean | undefined;
|
|
135
|
+
default?: boolean | undefined;
|
|
136
|
+
permissions?: {
|
|
137
|
+
resource: string;
|
|
138
|
+
access: string;
|
|
139
|
+
id?: number | undefined;
|
|
140
|
+
role?: Record<string, unknown> | undefined;
|
|
141
|
+
filterQuery?: string | undefined;
|
|
142
|
+
}[] | undefined;
|
|
143
|
+
stores?: string[] | undefined;
|
|
144
|
+
}>;
|
|
145
|
+
export type RoleListItem = z.infer<typeof RoleListItemSchema>;
|
|
146
|
+
/**
|
|
147
|
+
* Role Permission Input Schema.
|
|
148
|
+
* Used when creating/updating a role.
|
|
149
|
+
*/
|
|
150
|
+
export declare const RolePermissionInputSchema: z.ZodObject<{
|
|
151
|
+
resource: z.ZodString;
|
|
152
|
+
access: z.ZodString;
|
|
153
|
+
filterQuery: z.ZodOptional<z.ZodString>;
|
|
154
|
+
}, "strip", z.ZodTypeAny, {
|
|
155
|
+
resource: string;
|
|
156
|
+
access: string;
|
|
157
|
+
filterQuery?: string | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
resource: string;
|
|
160
|
+
access: string;
|
|
161
|
+
filterQuery?: string | undefined;
|
|
162
|
+
}>;
|
|
163
|
+
export type RolePermissionInput = z.infer<typeof RolePermissionInputSchema>;
|
|
164
|
+
/**
|
|
165
|
+
* Role Create Input Schema.
|
|
166
|
+
* Input for POST /api/acl/role - uses { role: {...} } wrapper
|
|
167
|
+
*/
|
|
168
|
+
export declare const RoleCreateInputSchema: z.ZodObject<{
|
|
169
|
+
name: z.ZodString;
|
|
170
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
171
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
172
|
+
resource: z.ZodString;
|
|
173
|
+
access: z.ZodString;
|
|
174
|
+
filterQuery: z.ZodOptional<z.ZodString>;
|
|
175
|
+
}, "strip", z.ZodTypeAny, {
|
|
176
|
+
resource: string;
|
|
177
|
+
access: string;
|
|
178
|
+
filterQuery?: string | undefined;
|
|
179
|
+
}, {
|
|
180
|
+
resource: string;
|
|
181
|
+
access: string;
|
|
182
|
+
filterQuery?: string | undefined;
|
|
183
|
+
}>, "many">>;
|
|
184
|
+
stores: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
185
|
+
}, "strip", z.ZodTypeAny, {
|
|
186
|
+
name: string;
|
|
187
|
+
default?: boolean | undefined;
|
|
188
|
+
permissions?: {
|
|
189
|
+
resource: string;
|
|
190
|
+
access: string;
|
|
191
|
+
filterQuery?: string | undefined;
|
|
192
|
+
}[] | undefined;
|
|
193
|
+
stores?: string[] | undefined;
|
|
194
|
+
}, {
|
|
195
|
+
name: string;
|
|
196
|
+
default?: boolean | undefined;
|
|
197
|
+
permissions?: {
|
|
198
|
+
resource: string;
|
|
199
|
+
access: string;
|
|
200
|
+
filterQuery?: string | undefined;
|
|
201
|
+
}[] | undefined;
|
|
202
|
+
stores?: string[] | undefined;
|
|
203
|
+
}>;
|
|
204
|
+
export type RoleCreateInput = z.infer<typeof RoleCreateInputSchema>;
|
|
205
|
+
/**
|
|
206
|
+
* Role Update Input Schema.
|
|
207
|
+
* Input for PUT /api/acl/role/{roleId}
|
|
208
|
+
*/
|
|
209
|
+
export declare const RoleUpdateInputSchema: z.ZodObject<{
|
|
210
|
+
name: z.ZodOptional<z.ZodString>;
|
|
211
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
212
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
213
|
+
resource: z.ZodString;
|
|
214
|
+
access: z.ZodString;
|
|
215
|
+
filterQuery: z.ZodOptional<z.ZodString>;
|
|
216
|
+
}, "strip", z.ZodTypeAny, {
|
|
217
|
+
resource: string;
|
|
218
|
+
access: string;
|
|
219
|
+
filterQuery?: string | undefined;
|
|
220
|
+
}, {
|
|
221
|
+
resource: string;
|
|
222
|
+
access: string;
|
|
223
|
+
filterQuery?: string | undefined;
|
|
224
|
+
}>, "many">>;
|
|
225
|
+
stores: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
226
|
+
}, "strip", z.ZodTypeAny, {
|
|
227
|
+
name?: string | undefined;
|
|
228
|
+
default?: boolean | undefined;
|
|
229
|
+
permissions?: {
|
|
230
|
+
resource: string;
|
|
231
|
+
access: string;
|
|
232
|
+
filterQuery?: string | undefined;
|
|
233
|
+
}[] | undefined;
|
|
234
|
+
stores?: string[] | undefined;
|
|
235
|
+
}, {
|
|
236
|
+
name?: string | undefined;
|
|
237
|
+
default?: boolean | undefined;
|
|
238
|
+
permissions?: {
|
|
239
|
+
resource: string;
|
|
240
|
+
access: string;
|
|
241
|
+
filterQuery?: string | undefined;
|
|
242
|
+
}[] | undefined;
|
|
243
|
+
stores?: string[] | undefined;
|
|
244
|
+
}>;
|
|
245
|
+
export type RoleUpdateInput = z.infer<typeof RoleUpdateInputSchema>;
|
|
246
|
+
/**
|
|
247
|
+
* ACL Resource Schema.
|
|
248
|
+
* Represents an available ACL resource from GET /api/acl/resources
|
|
249
|
+
*/
|
|
250
|
+
export declare const ACLResourceSchema: z.ZodObject<{
|
|
251
|
+
code: z.ZodString;
|
|
252
|
+
name: z.ZodString;
|
|
253
|
+
}, "strip", z.ZodTypeAny, {
|
|
254
|
+
code: string;
|
|
255
|
+
name: string;
|
|
256
|
+
}, {
|
|
257
|
+
code: string;
|
|
258
|
+
name: string;
|
|
259
|
+
}>;
|
|
260
|
+
export type ACLResource = z.infer<typeof ACLResourceSchema>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Role Permission Schema.
|
|
4
|
+
* Represents a permission entry within a role.
|
|
5
|
+
*/
|
|
6
|
+
export const RolePermissionSchema = z.object({
|
|
7
|
+
id: z.number().optional().describe("Permission ID."),
|
|
8
|
+
resource: z.string().describe("Resource name (e.g., ANALYTICS, EVENTS, MEMBER)."),
|
|
9
|
+
access: z.string().describe("Access level (e.g., VIEW, MODIFY)."),
|
|
10
|
+
filterQuery: z.string().optional().describe("Optional filter query for scoped access."),
|
|
11
|
+
role: z.record(z.string(), z.unknown()).optional().describe("Parent role reference."),
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Role Schema.
|
|
15
|
+
* Full role from GET /api/acl/role/{roleId}
|
|
16
|
+
*/
|
|
17
|
+
export const RoleSchema = z.object({
|
|
18
|
+
id: z.union([z.string(), z.number()]).describe("Role ID."),
|
|
19
|
+
role: z.string().optional().describe("Role identifier/code."),
|
|
20
|
+
name: z.string().describe("Role name."),
|
|
21
|
+
master: z.boolean().optional().describe("Whether this is a master/super role."),
|
|
22
|
+
default: z.boolean().optional().describe("Whether this is a default role assigned to new admins."),
|
|
23
|
+
permissions: z.array(RolePermissionSchema).optional().describe("Permissions assigned to this role."),
|
|
24
|
+
stores: z.array(z.string()).optional().describe("Store codes this role has access to."),
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Role List Item Schema.
|
|
28
|
+
* Used in list responses.
|
|
29
|
+
*/
|
|
30
|
+
export const RoleListItemSchema = z.object({
|
|
31
|
+
id: z.union([z.string(), z.number()]).describe("Role ID."),
|
|
32
|
+
role: z.string().optional().describe("Role identifier/code."),
|
|
33
|
+
name: z.string().describe("Role name."),
|
|
34
|
+
master: z.boolean().optional().describe("Whether this is a master/super role."),
|
|
35
|
+
default: z.boolean().optional().describe("Whether this is a default role."),
|
|
36
|
+
permissions: z.array(RolePermissionSchema).optional().describe("Permissions assigned to this role."),
|
|
37
|
+
stores: z.array(z.string()).optional().describe("Store codes this role has access to."),
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Role Permission Input Schema.
|
|
41
|
+
* Used when creating/updating a role.
|
|
42
|
+
*/
|
|
43
|
+
export const RolePermissionInputSchema = z.object({
|
|
44
|
+
resource: z.string().describe("Resource name (e.g., ANALYTICS, EVENTS)."),
|
|
45
|
+
access: z.string().describe("Access level (e.g., VIEW, MODIFY)."),
|
|
46
|
+
filterQuery: z.string().optional().describe("Optional filter query."),
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Role Create Input Schema.
|
|
50
|
+
* Input for POST /api/acl/role - uses { role: {...} } wrapper
|
|
51
|
+
*/
|
|
52
|
+
export const RoleCreateInputSchema = z.object({
|
|
53
|
+
name: z.string().describe("Role name (required)."),
|
|
54
|
+
default: z.boolean().optional().describe("Whether this is a default role for new admins."),
|
|
55
|
+
permissions: z.array(RolePermissionInputSchema).optional().describe("Permissions to assign."),
|
|
56
|
+
stores: z.array(z.string()).optional().describe("Store codes to assign access."),
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* Role Update Input Schema.
|
|
60
|
+
* Input for PUT /api/acl/role/{roleId}
|
|
61
|
+
*/
|
|
62
|
+
export const RoleUpdateInputSchema = z.object({
|
|
63
|
+
name: z.string().optional().describe("Role name."),
|
|
64
|
+
default: z.boolean().optional().describe("Whether this is a default role."),
|
|
65
|
+
permissions: z.array(RolePermissionInputSchema).optional().describe("Permissions to assign."),
|
|
66
|
+
stores: z.array(z.string()).optional().describe("Store codes to assign access."),
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* ACL Resource Schema.
|
|
70
|
+
* Represents an available ACL resource from GET /api/acl/resources
|
|
71
|
+
*/
|
|
72
|
+
export const ACLResourceSchema = z.object({
|
|
73
|
+
code: z.string().describe("Resource code (e.g., ANALYTICS, MEMBER)."),
|
|
74
|
+
name: z.string().describe("Human-readable resource name."),
|
|
75
|
+
});
|