@open-loyalty/mcp-server 1.5.3 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +4 -0
- package/dist/config.js +11 -0
- package/dist/index.js +0 -8
- package/dist/server.js +13 -0
- package/dist/tools/achievement/handlers.js +47 -0
- package/dist/tools/achievement/index.d.ts +11 -4
- package/dist/tools/achievement/index.js +12 -1
- package/dist/tools/achievement/schemas.d.ts +4 -4
- package/dist/tools/achievement/schemas.js +13 -12
- package/dist/tools/admin/handlers.d.ts +48 -0
- package/dist/tools/admin/handlers.js +159 -0
- package/dist/tools/admin/index.d.ts +86 -0
- package/dist/tools/admin/index.js +64 -0
- package/dist/tools/admin/schemas.d.ts +40 -0
- package/dist/tools/admin/schemas.js +40 -0
- package/dist/tools/analytics/handlers.d.ts +42 -0
- package/dist/tools/analytics/handlers.js +282 -0
- package/dist/tools/analytics/index.d.ts +108 -0
- package/dist/tools/analytics/index.js +91 -0
- package/dist/tools/analytics/schemas.d.ts +42 -0
- package/dist/tools/analytics/schemas.js +47 -0
- package/dist/tools/apikey/handlers.d.ts +15 -0
- package/dist/tools/apikey/handlers.js +53 -0
- package/dist/tools/apikey/index.d.ts +41 -0
- package/dist/tools/apikey/index.js +38 -0
- package/dist/tools/apikey/schemas.d.ts +31 -0
- package/dist/tools/apikey/schemas.js +15 -0
- package/dist/tools/audit/handlers.d.ts +20 -0
- package/dist/tools/audit/handlers.js +82 -0
- package/dist/tools/audit/index.d.ts +36 -0
- package/dist/tools/audit/index.js +28 -0
- package/dist/tools/audit/schemas.d.ts +62 -0
- package/dist/tools/audit/schemas.js +18 -0
- package/dist/tools/badge/handlers.d.ts +45 -0
- package/dist/tools/badge/handlers.js +135 -0
- package/dist/tools/badge/index.d.ts +68 -0
- package/dist/tools/badge/index.js +47 -0
- package/dist/tools/badge/schemas.d.ts +37 -0
- package/dist/tools/badge/schemas.js +31 -0
- package/dist/tools/campaign/handlers.js +61 -0
- package/dist/tools/campaign/index.d.ts +12 -0
- package/dist/tools/campaign/index.js +20 -1
- package/dist/tools/campaign/member-handlers.js +37 -1
- package/dist/tools/campaign/schemas.js +16 -14
- package/dist/tools/custom-event/handlers.d.ts +98 -0
- package/dist/tools/custom-event/handlers.js +238 -0
- package/dist/tools/custom-event/index.d.ts +139 -0
- package/dist/tools/custom-event/index.js +78 -0
- package/dist/tools/custom-event/schemas.d.ts +87 -0
- package/dist/tools/custom-event/schemas.js +59 -0
- package/dist/tools/export/handlers.d.ts +29 -0
- package/dist/tools/export/handlers.js +128 -0
- package/dist/tools/export/index.d.ts +56 -0
- package/dist/tools/export/index.js +46 -0
- package/dist/tools/export/schemas.d.ts +42 -0
- package/dist/tools/export/schemas.js +41 -0
- package/dist/tools/import/handlers.d.ts +22 -0
- package/dist/tools/import/handlers.js +123 -0
- package/dist/tools/import/index.d.ts +45 -0
- package/dist/tools/import/index.js +41 -0
- package/dist/tools/import/schemas.d.ts +57 -0
- package/dist/tools/import/schemas.js +39 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +11 -11
- package/dist/tools/member/handlers.js +30 -0
- package/dist/tools/member/index.d.ts +10 -0
- package/dist/tools/member/index.js +10 -0
- package/dist/tools/member/schemas.js +13 -13
- package/dist/tools/points/handlers.js +73 -0
- package/dist/tools/points/index.d.ts +6 -0
- package/dist/tools/points/index.js +6 -0
- package/dist/tools/points/schemas.js +1 -1
- package/dist/tools/referral/index.d.ts +3 -0
- package/dist/tools/referral/index.js +3 -0
- package/dist/tools/reward/handlers.js +21 -13
- package/dist/tools/reward/index.d.ts +9 -0
- package/dist/tools/reward/index.js +12 -1
- package/dist/tools/reward/schemas.js +2 -2
- package/dist/tools/role/handlers.d.ts +35 -0
- package/dist/tools/role/handlers.js +127 -0
- package/dist/tools/role/index.d.ts +99 -0
- package/dist/tools/role/index.js +65 -0
- package/dist/tools/role/schemas.d.ts +56 -0
- package/dist/tools/role/schemas.js +35 -0
- package/dist/tools/segment/handlers.js +68 -1
- package/dist/tools/segment/index.d.ts +9 -0
- package/dist/tools/segment/index.js +13 -0
- package/dist/tools/segment/schemas.js +8 -5
- package/dist/tools/store/handlers.d.ts +25 -0
- package/dist/tools/store/handlers.js +89 -0
- package/dist/tools/store/index.d.ts +55 -0
- package/dist/tools/store/index.js +46 -0
- package/dist/tools/store/schemas.d.ts +38 -0
- package/dist/tools/store/schemas.js +23 -0
- package/dist/tools/tierset/handlers.js +92 -1
- package/dist/tools/tierset/index.d.ts +6 -0
- package/dist/tools/tierset/index.js +8 -1
- package/dist/tools/transaction/handlers.js +40 -0
- package/dist/tools/transaction/index.d.ts +4 -0
- package/dist/tools/transaction/index.js +4 -0
- package/dist/tools/transaction/schemas.js +3 -3
- package/dist/tools/wallet-type/index.d.ts +4 -0
- package/dist/tools/wallet-type/index.js +5 -1
- package/dist/tools/webhook/handlers.d.ts +34 -0
- package/dist/tools/webhook/handlers.js +147 -0
- package/dist/tools/webhook/index.d.ts +97 -0
- package/dist/tools/webhook/index.js +65 -0
- package/dist/tools/webhook/schemas.d.ts +72 -0
- package/dist/tools/{webhook.js → webhook/schemas.js} +0 -140
- package/dist/types/schemas/tierset.js +3 -1
- package/package.json +1 -1
- package/dist/tools/admin.d.ts +0 -165
- package/dist/tools/admin.js +0 -205
- package/dist/tools/analytics.d.ts +0 -180
- package/dist/tools/analytics.js +0 -255
- package/dist/tools/apikey.d.ts +0 -79
- package/dist/tools/apikey.js +0 -85
- package/dist/tools/audit.d.ts +0 -111
- package/dist/tools/audit.js +0 -94
- package/dist/tools/badge.d.ts +0 -143
- package/dist/tools/badge.js +0 -174
- package/dist/tools/custom-event.d.ts +0 -315
- package/dist/tools/custom-event.js +0 -271
- package/dist/tools/export.d.ts +0 -118
- package/dist/tools/export.js +0 -152
- package/dist/tools/import.d.ts +0 -116
- package/dist/tools/import.js +0 -143
- package/dist/tools/role.d.ts +0 -180
- package/dist/tools/role.js +0 -173
- package/dist/tools/store.d.ts +0 -109
- package/dist/tools/store.js +0 -125
- package/dist/tools/webhook.d.ts +0 -192
package/dist/tools/import.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { apiGet } from "../client/http.js";
|
|
3
|
-
import { formatApiError } from "../utils/errors.js";
|
|
4
|
-
import { getConfig, getStoreCode } from "../config.js";
|
|
5
|
-
import axios from "axios";
|
|
6
|
-
import FormDataNode from "form-data";
|
|
7
|
-
// Input Schemas
|
|
8
|
-
export const ImportCreateInputSchema = {
|
|
9
|
-
storeCode: z.string().optional().describe("INTERNAL: Auto-configured from server settings. NEVER ask the user for this value. Only set if the user explicitly requests a different store."),
|
|
10
|
-
type: z.enum([
|
|
11
|
-
"member",
|
|
12
|
-
"groupValue",
|
|
13
|
-
"segmentMembers",
|
|
14
|
-
"unitTransferAdding",
|
|
15
|
-
"unitTransferSpending",
|
|
16
|
-
"transaction",
|
|
17
|
-
"campaignCode",
|
|
18
|
-
"rewardCoupon",
|
|
19
|
-
]).describe("Import type. Options: member, groupValue, segmentMembers, unitTransferAdding, unitTransferSpending, transaction, campaignCode, rewardCoupon."),
|
|
20
|
-
fileContent: z.string().describe("File content as plain text (not base64 encoded). Accepts CSV (comma-separated rows) or XML format. " +
|
|
21
|
-
"For member imports, XML is the standard format. Auto-detected based on content or fileName extension."),
|
|
22
|
-
fileName: z.string().optional().describe("Optional file name for the import (default: import.xml). Use .xml extension for XML content, .csv for CSV content."),
|
|
23
|
-
};
|
|
24
|
-
export const ImportListInputSchema = {
|
|
25
|
-
storeCode: z.string().optional().describe("INTERNAL: Auto-configured from server settings. NEVER ask the user for this value. Only set if the user explicitly requests a different store."),
|
|
26
|
-
page: z.number().optional().describe("Page number (default: 1)."),
|
|
27
|
-
perPage: z.number().optional().describe("Items per page (default: 25)."),
|
|
28
|
-
importId: z.string().optional().describe("Filter by import ID."),
|
|
29
|
-
type: z.enum([
|
|
30
|
-
"member",
|
|
31
|
-
"groupValue",
|
|
32
|
-
"segmentMembers",
|
|
33
|
-
"unitTransferAdding",
|
|
34
|
-
"unitTransferSpending",
|
|
35
|
-
"transaction",
|
|
36
|
-
"campaignCode",
|
|
37
|
-
"rewardCoupon",
|
|
38
|
-
]).optional().describe("Filter by import type."),
|
|
39
|
-
};
|
|
40
|
-
export const ImportGetInputSchema = {
|
|
41
|
-
storeCode: z.string().optional().describe("INTERNAL: Auto-configured from server settings. NEVER ask the user for this value. Only set if the user explicitly requests a different store."),
|
|
42
|
-
importId: z.string().describe("The import ID (UUID) to retrieve."),
|
|
43
|
-
page: z.number().optional().describe("Page number for import items (default: 1)."),
|
|
44
|
-
perPage: z.number().optional().describe("Items per page for import items (default: 25)."),
|
|
45
|
-
};
|
|
46
|
-
// Handler functions
|
|
47
|
-
export async function importCreate(input) {
|
|
48
|
-
const config = getConfig();
|
|
49
|
-
const storeCode = getStoreCode(input.storeCode);
|
|
50
|
-
// Determine file extension and content type
|
|
51
|
-
// API accepts: application/xml, text/xml for member imports; text/csv for others
|
|
52
|
-
const fileName = input.fileName || "import.xml";
|
|
53
|
-
const isXml = fileName.endsWith('.xml') || input.fileContent.trim().startsWith('<?xml') || input.fileContent.trim().startsWith('<');
|
|
54
|
-
const contentType = isXml ? "application/xml" : "text/csv";
|
|
55
|
-
// Create form data for multipart upload using Node.js form-data package
|
|
56
|
-
// API expects field name "import[file]" per documentation
|
|
57
|
-
const formData = new FormDataNode();
|
|
58
|
-
formData.append("import[file]", Buffer.from(input.fileContent), {
|
|
59
|
-
filename: fileName,
|
|
60
|
-
contentType: contentType,
|
|
61
|
-
});
|
|
62
|
-
try {
|
|
63
|
-
const response = await axios.post(`${config.apiUrl}/${storeCode}/import/${input.type}`, formData, {
|
|
64
|
-
headers: {
|
|
65
|
-
"X-AUTH-TOKEN": config.apiToken,
|
|
66
|
-
...formData.getHeaders(),
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
return response.data;
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
throw formatApiError(error, "ol_import_create");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
export async function importList(input) {
|
|
76
|
-
const storeCode = getStoreCode(input.storeCode);
|
|
77
|
-
const params = new URLSearchParams();
|
|
78
|
-
if (input.page)
|
|
79
|
-
params.append("_page", String(input.page));
|
|
80
|
-
if (input.perPage)
|
|
81
|
-
params.append("_itemsOnPage", String(input.perPage));
|
|
82
|
-
if (input.importId)
|
|
83
|
-
params.append("importId", input.importId);
|
|
84
|
-
if (input.type)
|
|
85
|
-
params.append("type", input.type);
|
|
86
|
-
const queryString = params.toString();
|
|
87
|
-
const url = `/${storeCode}/import${queryString ? `?${queryString}` : ""}`;
|
|
88
|
-
try {
|
|
89
|
-
const response = await apiGet(url);
|
|
90
|
-
return response;
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
throw formatApiError(error, "ol_import_list");
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export async function importGet(input) {
|
|
97
|
-
const storeCode = getStoreCode(input.storeCode);
|
|
98
|
-
const params = new URLSearchParams();
|
|
99
|
-
if (input.page)
|
|
100
|
-
params.append("_page", String(input.page));
|
|
101
|
-
if (input.perPage)
|
|
102
|
-
params.append("_itemsOnPage", String(input.perPage));
|
|
103
|
-
const queryString = params.toString();
|
|
104
|
-
const url = `/${storeCode}/import/${input.importId}${queryString ? `?${queryString}` : ""}`;
|
|
105
|
-
try {
|
|
106
|
-
const response = await apiGet(url);
|
|
107
|
-
return response;
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
throw formatApiError(error, "ol_import_get");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
// Tool definitions
|
|
114
|
-
export const importToolDefinitions = [
|
|
115
|
-
{
|
|
116
|
-
name: "ol_import_create",
|
|
117
|
-
title: "Create Bulk Import",
|
|
118
|
-
description: "Create a new bulk import from file content (CSV or XML). Returns importId for async tracking. " +
|
|
119
|
-
"Import types: member (member data - typically XML), groupValue (group values), segmentMembers (segment membership), " +
|
|
120
|
-
"unitTransferAdding (add points), unitTransferSpending (spend points), transaction (transactions), " +
|
|
121
|
-
"campaignCode (campaign codes), rewardCoupon (reward coupons). " +
|
|
122
|
-
"Provide plain text file content (CSV or XML). Format is auto-detected from content or fileName extension.",
|
|
123
|
-
readOnly: false,
|
|
124
|
-
inputSchema: ImportCreateInputSchema,
|
|
125
|
-
handler: importCreate,
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: "ol_import_list",
|
|
129
|
-
title: "List Imports",
|
|
130
|
-
description: "List imports with optional filtering. Returns paginated list of imports with importId, type, uploadedDate, fileName, and status information.",
|
|
131
|
-
readOnly: true,
|
|
132
|
-
inputSchema: ImportListInputSchema,
|
|
133
|
-
handler: importList,
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: "ol_import_get",
|
|
137
|
-
title: "Get Import Details",
|
|
138
|
-
description: "Get import details and individual item statuses. Returns paginated list of import items with their success/failure status and error messages.",
|
|
139
|
-
readOnly: true,
|
|
140
|
-
inputSchema: ImportGetInputSchema,
|
|
141
|
-
handler: importGet,
|
|
142
|
-
},
|
|
143
|
-
];
|
package/dist/tools/role.d.ts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { Role, RoleListItem, ACLResource } from "../types/schemas/role.js";
|
|
3
|
-
interface RolePermissionInput {
|
|
4
|
-
resource: string;
|
|
5
|
-
access: string;
|
|
6
|
-
filterQuery?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const RoleListInputSchema: {
|
|
9
|
-
page: z.ZodOptional<z.ZodNumber>;
|
|
10
|
-
perPage: z.ZodOptional<z.ZodNumber>;
|
|
11
|
-
name: z.ZodOptional<z.ZodString>;
|
|
12
|
-
master: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
-
default: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
-
};
|
|
15
|
-
export declare const RoleCreateInputSchema: {
|
|
16
|
-
name: z.ZodString;
|
|
17
|
-
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
18
|
-
resource: z.ZodString;
|
|
19
|
-
access: z.ZodString;
|
|
20
|
-
filterQuery: z.ZodOptional<z.ZodString>;
|
|
21
|
-
}, "strip", z.ZodTypeAny, {
|
|
22
|
-
resource: string;
|
|
23
|
-
access: string;
|
|
24
|
-
filterQuery?: string | undefined;
|
|
25
|
-
}, {
|
|
26
|
-
resource: string;
|
|
27
|
-
access: string;
|
|
28
|
-
filterQuery?: string | undefined;
|
|
29
|
-
}>, "many">>;
|
|
30
|
-
stores: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
31
|
-
default: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
-
};
|
|
33
|
-
export declare const RoleGetInputSchema: {
|
|
34
|
-
roleId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
35
|
-
};
|
|
36
|
-
export declare const RoleUpdateInputSchema: {
|
|
37
|
-
roleId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
38
|
-
name: z.ZodOptional<z.ZodString>;
|
|
39
|
-
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
|
-
resource: z.ZodString;
|
|
41
|
-
access: z.ZodString;
|
|
42
|
-
filterQuery: z.ZodOptional<z.ZodString>;
|
|
43
|
-
}, "strip", z.ZodTypeAny, {
|
|
44
|
-
resource: string;
|
|
45
|
-
access: string;
|
|
46
|
-
filterQuery?: string | undefined;
|
|
47
|
-
}, {
|
|
48
|
-
resource: string;
|
|
49
|
-
access: string;
|
|
50
|
-
filterQuery?: string | undefined;
|
|
51
|
-
}>, "many">>;
|
|
52
|
-
stores: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
53
|
-
default: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
-
};
|
|
55
|
-
export declare const RoleDeleteInputSchema: {
|
|
56
|
-
roleId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
57
|
-
};
|
|
58
|
-
export declare function roleList(input: {
|
|
59
|
-
page?: number;
|
|
60
|
-
perPage?: number;
|
|
61
|
-
name?: string;
|
|
62
|
-
master?: boolean;
|
|
63
|
-
default?: boolean;
|
|
64
|
-
}): Promise<{
|
|
65
|
-
items: RoleListItem[];
|
|
66
|
-
total?: Record<string, unknown>;
|
|
67
|
-
}>;
|
|
68
|
-
export declare function roleCreate(input: {
|
|
69
|
-
name: string;
|
|
70
|
-
permissions?: RolePermissionInput[];
|
|
71
|
-
stores?: string[];
|
|
72
|
-
default?: boolean;
|
|
73
|
-
}): Promise<void>;
|
|
74
|
-
export declare function roleGet(input: {
|
|
75
|
-
roleId: string | number;
|
|
76
|
-
}): Promise<Role>;
|
|
77
|
-
export declare function roleUpdate(input: {
|
|
78
|
-
roleId: string | number;
|
|
79
|
-
name?: string;
|
|
80
|
-
permissions?: RolePermissionInput[];
|
|
81
|
-
stores?: string[];
|
|
82
|
-
default?: boolean;
|
|
83
|
-
}): Promise<void>;
|
|
84
|
-
export declare function roleDelete(input: {
|
|
85
|
-
roleId: string | number;
|
|
86
|
-
}): Promise<void>;
|
|
87
|
-
export declare function aclGetResources(): Promise<{
|
|
88
|
-
items: ACLResource[];
|
|
89
|
-
total?: Record<string, unknown>;
|
|
90
|
-
}>;
|
|
91
|
-
export declare const roleToolDefinitions: readonly [{
|
|
92
|
-
readonly name: "ol_role_list";
|
|
93
|
-
readonly title: "List Roles";
|
|
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;
|
|
96
|
-
readonly inputSchema: {
|
|
97
|
-
page: z.ZodOptional<z.ZodNumber>;
|
|
98
|
-
perPage: z.ZodOptional<z.ZodNumber>;
|
|
99
|
-
name: z.ZodOptional<z.ZodString>;
|
|
100
|
-
master: z.ZodOptional<z.ZodBoolean>;
|
|
101
|
-
default: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
-
};
|
|
103
|
-
readonly handler: typeof roleList;
|
|
104
|
-
}, {
|
|
105
|
-
readonly name: "ol_role_create";
|
|
106
|
-
readonly title: "Create Role";
|
|
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;
|
|
109
|
-
readonly inputSchema: {
|
|
110
|
-
name: z.ZodString;
|
|
111
|
-
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
112
|
-
resource: z.ZodString;
|
|
113
|
-
access: z.ZodString;
|
|
114
|
-
filterQuery: z.ZodOptional<z.ZodString>;
|
|
115
|
-
}, "strip", z.ZodTypeAny, {
|
|
116
|
-
resource: string;
|
|
117
|
-
access: string;
|
|
118
|
-
filterQuery?: string | undefined;
|
|
119
|
-
}, {
|
|
120
|
-
resource: string;
|
|
121
|
-
access: string;
|
|
122
|
-
filterQuery?: string | undefined;
|
|
123
|
-
}>, "many">>;
|
|
124
|
-
stores: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
125
|
-
default: z.ZodOptional<z.ZodBoolean>;
|
|
126
|
-
};
|
|
127
|
-
readonly handler: typeof roleCreate;
|
|
128
|
-
}, {
|
|
129
|
-
readonly name: "ol_role_get";
|
|
130
|
-
readonly title: "Get Role Details";
|
|
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;
|
|
133
|
-
readonly inputSchema: {
|
|
134
|
-
roleId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
135
|
-
};
|
|
136
|
-
readonly handler: typeof roleGet;
|
|
137
|
-
}, {
|
|
138
|
-
readonly name: "ol_role_update";
|
|
139
|
-
readonly title: "Update Role";
|
|
140
|
-
readonly description: "Update a role's name, permissions, or stores. Returns void on success (204 No Content).";
|
|
141
|
-
readonly readOnly: false;
|
|
142
|
-
readonly inputSchema: {
|
|
143
|
-
roleId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
144
|
-
name: z.ZodOptional<z.ZodString>;
|
|
145
|
-
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
146
|
-
resource: z.ZodString;
|
|
147
|
-
access: z.ZodString;
|
|
148
|
-
filterQuery: z.ZodOptional<z.ZodString>;
|
|
149
|
-
}, "strip", z.ZodTypeAny, {
|
|
150
|
-
resource: string;
|
|
151
|
-
access: string;
|
|
152
|
-
filterQuery?: string | undefined;
|
|
153
|
-
}, {
|
|
154
|
-
resource: string;
|
|
155
|
-
access: string;
|
|
156
|
-
filterQuery?: string | undefined;
|
|
157
|
-
}>, "many">>;
|
|
158
|
-
stores: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
159
|
-
default: z.ZodOptional<z.ZodBoolean>;
|
|
160
|
-
};
|
|
161
|
-
readonly handler: typeof roleUpdate;
|
|
162
|
-
}, {
|
|
163
|
-
readonly name: "ol_role_delete";
|
|
164
|
-
readonly title: "Delete Role (Permanent)";
|
|
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;
|
|
168
|
-
readonly inputSchema: {
|
|
169
|
-
roleId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
170
|
-
};
|
|
171
|
-
readonly handler: typeof roleDelete;
|
|
172
|
-
}, {
|
|
173
|
-
readonly name: "ol_acl_get_resources";
|
|
174
|
-
readonly title: "Get ACL Resources";
|
|
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;
|
|
177
|
-
readonly inputSchema: {};
|
|
178
|
-
readonly handler: typeof aclGetResources;
|
|
179
|
-
}];
|
|
180
|
-
export {};
|
package/dist/tools/role.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { apiGet, apiPost, apiPut, apiDelete } from "../client/http.js";
|
|
3
|
-
import { formatApiError } from "../utils/errors.js";
|
|
4
|
-
// Input Schemas
|
|
5
|
-
export const RoleListInputSchema = {
|
|
6
|
-
page: z.number().optional().describe("Page number (default: 1)."),
|
|
7
|
-
perPage: z.number().optional().describe("Items per page (default: 25)."),
|
|
8
|
-
name: z.string().optional().describe("Filter by role name."),
|
|
9
|
-
master: z.boolean().optional().describe("Filter by master role status."),
|
|
10
|
-
default: z.boolean().optional().describe("Filter by default role status."),
|
|
11
|
-
};
|
|
12
|
-
export const RoleCreateInputSchema = {
|
|
13
|
-
name: z.string().describe("Role name (required)."),
|
|
14
|
-
permissions: z.array(z.object({
|
|
15
|
-
resource: z.string().describe("Resource name (e.g., ANALYTICS, EVENTS)."),
|
|
16
|
-
access: z.string().describe("Access level (e.g., VIEW, MODIFY)."),
|
|
17
|
-
filterQuery: z.string().optional().describe("Optional filter query."),
|
|
18
|
-
})).optional().describe("Array of permission definitions."),
|
|
19
|
-
stores: z.array(z.string()).optional().describe("Store codes to assign access (e.g., ['DEFAULT'])."),
|
|
20
|
-
default: z.boolean().optional().describe("Whether this is a default role for new admins."),
|
|
21
|
-
};
|
|
22
|
-
export const RoleGetInputSchema = {
|
|
23
|
-
roleId: z.union([z.string(), z.number()]).describe("The role ID to retrieve."),
|
|
24
|
-
};
|
|
25
|
-
export const RoleUpdateInputSchema = {
|
|
26
|
-
roleId: z.union([z.string(), z.number()]).describe("The role ID to update."),
|
|
27
|
-
name: z.string().optional().describe("Role name."),
|
|
28
|
-
permissions: z.array(z.object({
|
|
29
|
-
resource: z.string().describe("Resource name."),
|
|
30
|
-
access: z.string().describe("Access level."),
|
|
31
|
-
filterQuery: z.string().optional().describe("Optional filter query."),
|
|
32
|
-
})).optional().describe("Array of permission definitions."),
|
|
33
|
-
stores: z.array(z.string()).optional().describe("Store codes to assign access."),
|
|
34
|
-
default: z.boolean().optional().describe("Whether this is a default role."),
|
|
35
|
-
};
|
|
36
|
-
export const RoleDeleteInputSchema = {
|
|
37
|
-
roleId: z.union([z.string(), z.number()]).describe("The role ID to delete."),
|
|
38
|
-
};
|
|
39
|
-
// Handler functions
|
|
40
|
-
export async function roleList(input) {
|
|
41
|
-
const params = new URLSearchParams();
|
|
42
|
-
if (input.page)
|
|
43
|
-
params.append("_page", String(input.page));
|
|
44
|
-
if (input.perPage)
|
|
45
|
-
params.append("_itemsOnPage", String(input.perPage));
|
|
46
|
-
if (input.name)
|
|
47
|
-
params.append("name", input.name);
|
|
48
|
-
if (input.master !== undefined)
|
|
49
|
-
params.append("master", String(input.master));
|
|
50
|
-
if (input.default !== undefined)
|
|
51
|
-
params.append("default", String(input.default));
|
|
52
|
-
const queryString = params.toString();
|
|
53
|
-
const url = `/acl/role${queryString ? `?${queryString}` : ""}`;
|
|
54
|
-
try {
|
|
55
|
-
const response = await apiGet(url);
|
|
56
|
-
return response;
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
throw formatApiError(error, "ol_role_list");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
export async function roleCreate(input) {
|
|
63
|
-
const payload = {
|
|
64
|
-
name: input.name,
|
|
65
|
-
};
|
|
66
|
-
if (input.permissions)
|
|
67
|
-
payload.permissions = input.permissions;
|
|
68
|
-
if (input.stores)
|
|
69
|
-
payload.stores = input.stores;
|
|
70
|
-
if (input.default !== undefined)
|
|
71
|
-
payload.default = input.default;
|
|
72
|
-
try {
|
|
73
|
-
await apiPost("/acl/role", { role: payload });
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
throw formatApiError(error, "ol_role_create");
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
export async function roleGet(input) {
|
|
80
|
-
try {
|
|
81
|
-
const response = await apiGet(`/acl/role/${input.roleId}`);
|
|
82
|
-
return response;
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
throw formatApiError(error, "ol_role_get");
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
export async function roleUpdate(input) {
|
|
89
|
-
const payload = {};
|
|
90
|
-
if (input.name)
|
|
91
|
-
payload.name = input.name;
|
|
92
|
-
if (input.permissions)
|
|
93
|
-
payload.permissions = input.permissions;
|
|
94
|
-
if (input.stores)
|
|
95
|
-
payload.stores = input.stores;
|
|
96
|
-
if (input.default !== undefined)
|
|
97
|
-
payload.default = input.default;
|
|
98
|
-
try {
|
|
99
|
-
await apiPut(`/acl/role/${input.roleId}`, { role: payload });
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
throw formatApiError(error, "ol_role_update");
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
export async function roleDelete(input) {
|
|
106
|
-
try {
|
|
107
|
-
await apiDelete(`/acl/role/${input.roleId}`);
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
throw formatApiError(error, "ol_role_delete");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
export async function aclGetResources() {
|
|
114
|
-
try {
|
|
115
|
-
const response = await apiGet("/acl/resources");
|
|
116
|
-
return response;
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
throw formatApiError(error, "ol_acl_get_resources");
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// Tool definitions
|
|
123
|
-
export const roleToolDefinitions = [
|
|
124
|
-
{
|
|
125
|
-
name: "ol_role_list",
|
|
126
|
-
title: "List Roles",
|
|
127
|
-
description: "List all roles with optional filtering. Returns paginated list of roles with id, name, permissions, master status, and default status.",
|
|
128
|
-
readOnly: true,
|
|
129
|
-
inputSchema: RoleListInputSchema,
|
|
130
|
-
handler: roleList,
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: "ol_role_create",
|
|
134
|
-
title: "Create Role",
|
|
135
|
-
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).",
|
|
136
|
-
readOnly: false,
|
|
137
|
-
inputSchema: RoleCreateInputSchema,
|
|
138
|
-
handler: roleCreate,
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
name: "ol_role_get",
|
|
142
|
-
title: "Get Role Details",
|
|
143
|
-
description: "Get full role details by ID. Returns role with name, permissions array, master status, default status, and stores.",
|
|
144
|
-
readOnly: true,
|
|
145
|
-
inputSchema: RoleGetInputSchema,
|
|
146
|
-
handler: roleGet,
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: "ol_role_update",
|
|
150
|
-
title: "Update Role",
|
|
151
|
-
description: "Update a role's name, permissions, or stores. Returns void on success (204 No Content).",
|
|
152
|
-
readOnly: false,
|
|
153
|
-
inputSchema: RoleUpdateInputSchema,
|
|
154
|
-
handler: roleUpdate,
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: "ol_role_delete",
|
|
158
|
-
title: "Delete Role (Permanent)",
|
|
159
|
-
description: "Delete a role by ID. Returns void on success (204 No Content). Cannot delete roles that are assigned to admin users.",
|
|
160
|
-
readOnly: false,
|
|
161
|
-
destructive: true,
|
|
162
|
-
inputSchema: RoleDeleteInputSchema,
|
|
163
|
-
handler: roleDelete,
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
name: "ol_acl_get_resources",
|
|
167
|
-
title: "Get ACL Resources",
|
|
168
|
-
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.",
|
|
169
|
-
readOnly: true,
|
|
170
|
-
inputSchema: {},
|
|
171
|
-
handler: aclGetResources,
|
|
172
|
-
},
|
|
173
|
-
];
|
package/dist/tools/store.d.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export interface Store {
|
|
3
|
-
storeId: string;
|
|
4
|
-
code: string;
|
|
5
|
-
currency: string;
|
|
6
|
-
name: string;
|
|
7
|
-
active: boolean;
|
|
8
|
-
createdBy?: string;
|
|
9
|
-
createdAt?: string;
|
|
10
|
-
updatedBy?: string;
|
|
11
|
-
updatedAt?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface StoreListResponse {
|
|
14
|
-
items: Store[];
|
|
15
|
-
total?: Record<string, unknown>;
|
|
16
|
-
}
|
|
17
|
-
export declare const StoreListInputSchema: {
|
|
18
|
-
page: z.ZodOptional<z.ZodNumber>;
|
|
19
|
-
perPage: z.ZodOptional<z.ZodNumber>;
|
|
20
|
-
active: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
-
name: z.ZodOptional<z.ZodString>;
|
|
22
|
-
code: z.ZodOptional<z.ZodString>;
|
|
23
|
-
};
|
|
24
|
-
export declare const StoreCreateInputSchema: {
|
|
25
|
-
code: z.ZodString;
|
|
26
|
-
name: z.ZodString;
|
|
27
|
-
currency: z.ZodOptional<z.ZodString>;
|
|
28
|
-
active: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
-
};
|
|
30
|
-
export declare const StoreGetInputSchema: {
|
|
31
|
-
storeId: z.ZodString;
|
|
32
|
-
};
|
|
33
|
-
export declare const StoreUpdateInputSchema: {
|
|
34
|
-
storeId: z.ZodString;
|
|
35
|
-
name: z.ZodOptional<z.ZodString>;
|
|
36
|
-
active: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
-
currency: z.ZodOptional<z.ZodString>;
|
|
38
|
-
};
|
|
39
|
-
export declare function storeList(input: {
|
|
40
|
-
page?: number;
|
|
41
|
-
perPage?: number;
|
|
42
|
-
active?: boolean;
|
|
43
|
-
name?: string;
|
|
44
|
-
code?: string;
|
|
45
|
-
}): Promise<StoreListResponse>;
|
|
46
|
-
export declare function storeCreate(input: {
|
|
47
|
-
code: string;
|
|
48
|
-
name: string;
|
|
49
|
-
currency?: string;
|
|
50
|
-
active?: boolean;
|
|
51
|
-
}): Promise<{
|
|
52
|
-
storeId: string;
|
|
53
|
-
}>;
|
|
54
|
-
export declare function storeGet(input: {
|
|
55
|
-
storeId: string;
|
|
56
|
-
}): Promise<Store>;
|
|
57
|
-
export declare function storeUpdate(input: {
|
|
58
|
-
storeId: string;
|
|
59
|
-
name?: string;
|
|
60
|
-
active?: boolean;
|
|
61
|
-
currency?: string;
|
|
62
|
-
}): Promise<void>;
|
|
63
|
-
export declare const storeToolDefinitions: readonly [{
|
|
64
|
-
readonly name: "ol_store_list";
|
|
65
|
-
readonly title: "List Stores";
|
|
66
|
-
readonly description: "List all stores with optional filtering. Returns paginated list of stores with storeId, code, name, currency, and active status. Stores enable multi-tenant loyalty programs. Each store has independent members, campaigns, and settings.";
|
|
67
|
-
readonly readOnly: true;
|
|
68
|
-
readonly inputSchema: {
|
|
69
|
-
page: z.ZodOptional<z.ZodNumber>;
|
|
70
|
-
perPage: z.ZodOptional<z.ZodNumber>;
|
|
71
|
-
active: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
-
name: z.ZodOptional<z.ZodString>;
|
|
73
|
-
code: z.ZodOptional<z.ZodString>;
|
|
74
|
-
};
|
|
75
|
-
readonly handler: typeof storeList;
|
|
76
|
-
}, {
|
|
77
|
-
readonly name: "ol_store_create";
|
|
78
|
-
readonly title: "Create Store";
|
|
79
|
-
readonly description: "Create a new store for multi-tenant setup. Requires unique code and name. Returns storeId on success.";
|
|
80
|
-
readonly readOnly: false;
|
|
81
|
-
readonly inputSchema: {
|
|
82
|
-
code: z.ZodString;
|
|
83
|
-
name: z.ZodString;
|
|
84
|
-
currency: z.ZodOptional<z.ZodString>;
|
|
85
|
-
active: z.ZodOptional<z.ZodBoolean>;
|
|
86
|
-
};
|
|
87
|
-
readonly handler: typeof storeCreate;
|
|
88
|
-
}, {
|
|
89
|
-
readonly name: "ol_store_get";
|
|
90
|
-
readonly title: "Get Store Details";
|
|
91
|
-
readonly description: "Get full store configuration by ID. Returns storeId, code, name, currency, active status, and timestamps.";
|
|
92
|
-
readonly readOnly: true;
|
|
93
|
-
readonly inputSchema: {
|
|
94
|
-
storeId: z.ZodString;
|
|
95
|
-
};
|
|
96
|
-
readonly handler: typeof storeGet;
|
|
97
|
-
}, {
|
|
98
|
-
readonly name: "ol_store_update";
|
|
99
|
-
readonly title: "Update Store";
|
|
100
|
-
readonly description: "Update store configuration. Can update name, currency, and active status. Returns void on success (204 No Content).";
|
|
101
|
-
readonly readOnly: false;
|
|
102
|
-
readonly inputSchema: {
|
|
103
|
-
storeId: z.ZodString;
|
|
104
|
-
name: z.ZodOptional<z.ZodString>;
|
|
105
|
-
active: z.ZodOptional<z.ZodBoolean>;
|
|
106
|
-
currency: z.ZodOptional<z.ZodString>;
|
|
107
|
-
};
|
|
108
|
-
readonly handler: typeof storeUpdate;
|
|
109
|
-
}];
|