@draftt-io/draftt-mcp 1.0.2 → 1.1.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 -201
- package/README.md +88 -19
- package/dist/api/client.d.ts +16 -7
- package/dist/api/client.js +42 -12
- package/dist/api/client.js.map +1 -1
- package/dist/api/drafttClient.d.ts +14 -11
- package/dist/api/drafttClient.js +39 -16
- package/dist/api/drafttClient.js.map +1 -1
- package/dist/api/responseFormatter.d.ts +6 -6
- package/dist/api/responseFormatter.js +160 -7
- package/dist/api/responseFormatter.js.map +1 -1
- package/dist/handlers/componentHandler.d.ts +4 -2
- package/dist/handlers/componentHandler.js +10 -8
- package/dist/handlers/componentHandler.js.map +1 -1
- package/dist/handlers/drafttHandler.d.ts +10 -2
- package/dist/handlers/drafttHandler.js +24 -4
- package/dist/handlers/drafttHandler.js.map +1 -1
- package/dist/handlers/policyHandler.d.ts +10 -6
- package/dist/handlers/policyHandler.js +25 -21
- package/dist/handlers/policyHandler.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +138 -56
- package/dist/index.js.map +1 -1
- package/dist/mcp-server-sse.d.ts +2 -0
- package/dist/mcp-server-sse.js +151 -0
- package/dist/mcp-server-sse.js.map +1 -0
- package/dist/models/component.d.ts +44 -42
- package/dist/models/draftt.d.ts +5 -0
- package/dist/models/policy.d.ts +29 -0
- package/dist/schemas/componentSchema.d.ts +376 -203
- package/dist/schemas/componentSchema.js +154 -46
- package/dist/schemas/componentSchema.js.map +1 -1
- package/dist/schemas/drafttSchema.d.ts +18 -1
- package/dist/schemas/drafttSchema.js +16 -2
- package/dist/schemas/drafttSchema.js.map +1 -1
- package/dist/schemas/policySchema.d.ts +189 -4
- package/dist/schemas/policySchema.js +68 -9
- package/dist/schemas/policySchema.js.map +1 -1
- package/dist/utils/constants.d.ts +31 -3
- package/dist/utils/constants.js +103 -24
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/json.d.ts +37 -0
- package/dist/utils/json.js +102 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.js +2 -2
- package/package.json +9 -4
package/dist/api/drafttClient.js
CHANGED
|
@@ -4,14 +4,16 @@ exports.DrafttClient = void 0;
|
|
|
4
4
|
const client_1 = require("./client");
|
|
5
5
|
const client_2 = require("./client");
|
|
6
6
|
class DrafttClient extends client_1.ApiClient {
|
|
7
|
-
constructor(logger, accessKey) {
|
|
7
|
+
constructor(logger, accessKey, timeout) {
|
|
8
8
|
const apiKey = accessKey || process.env.DRAFTT_ACCESS_KEY;
|
|
9
9
|
if (!apiKey) {
|
|
10
10
|
throw new Error("Access key is required for authentication");
|
|
11
11
|
}
|
|
12
|
+
const baseUrl = process.env.DRAFTT_API_BASE_URL || "https://api.draftt.io/v1";
|
|
12
13
|
super({
|
|
13
|
-
baseUrl
|
|
14
|
-
logger
|
|
14
|
+
baseUrl,
|
|
15
|
+
logger,
|
|
16
|
+
timeout: timeout || 30000,
|
|
15
17
|
});
|
|
16
18
|
this.accessKey = apiKey;
|
|
17
19
|
}
|
|
@@ -19,13 +21,9 @@ class DrafttClient extends client_1.ApiClient {
|
|
|
19
21
|
return {
|
|
20
22
|
Authorization: `Bearer ${this.accessKey}`,
|
|
21
23
|
"Content-Type": "application/json",
|
|
24
|
+
"Request-Source": "draftt-mcp",
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
|
-
async componentSearch(args) {
|
|
25
|
-
this.logger.debug("Component search with args:", args);
|
|
26
|
-
const requestBody = this.buildSearchBody(args);
|
|
27
|
-
return this.post("/component/search", requestBody);
|
|
28
|
-
}
|
|
29
27
|
async componentGet(args) {
|
|
30
28
|
this.logger.debug("Component get with args:", args);
|
|
31
29
|
if (!args.componentId) {
|
|
@@ -33,10 +31,10 @@ class DrafttClient extends client_1.ApiClient {
|
|
|
33
31
|
}
|
|
34
32
|
return this.get(`/component/${args.componentId}`);
|
|
35
33
|
}
|
|
36
|
-
async
|
|
37
|
-
this.logger.debug("
|
|
34
|
+
async componentSearch(args) {
|
|
35
|
+
this.logger.debug("Component search with args:", args);
|
|
38
36
|
const requestBody = this.buildSearchBody(args);
|
|
39
|
-
return this.post("/
|
|
37
|
+
return this.post("/component/search", requestBody);
|
|
40
38
|
}
|
|
41
39
|
async policyGet(args) {
|
|
42
40
|
this.logger.debug("Policy get with args:", args);
|
|
@@ -45,13 +43,18 @@ class DrafttClient extends client_1.ApiClient {
|
|
|
45
43
|
}
|
|
46
44
|
return this.get(`/policy/${args.policyId}`);
|
|
47
45
|
}
|
|
48
|
-
async
|
|
49
|
-
this.logger.debug("Policy
|
|
46
|
+
async policySearch(args) {
|
|
47
|
+
this.logger.debug("Policy search with args:", args);
|
|
48
|
+
const requestBody = this.buildSearchBody(args);
|
|
49
|
+
return this.post("/policy/search", requestBody);
|
|
50
|
+
}
|
|
51
|
+
async policyComponentQuery(args) {
|
|
52
|
+
this.logger.debug("Policy component query with args:", args);
|
|
50
53
|
if (!args.policyId) {
|
|
51
54
|
throw new client_2.ApiError("MISSING_PARAM", "Missing required parameter: policyId");
|
|
52
55
|
}
|
|
53
|
-
const requestBody = this.
|
|
54
|
-
return this.post(`/policy/${args.policyId}/component/
|
|
56
|
+
const requestBody = this.buildQueryBody(args);
|
|
57
|
+
return this.post(`/policy/${args.policyId}/component/query`, requestBody);
|
|
55
58
|
}
|
|
56
59
|
async policyComponentGet(args) {
|
|
57
60
|
this.logger.debug("Policy component get with args:", args);
|
|
@@ -67,16 +70,36 @@ class DrafttClient extends client_1.ApiClient {
|
|
|
67
70
|
this.logger.debug("Draftt get with args:", args);
|
|
68
71
|
return this.post(`/draftt/search`, {});
|
|
69
72
|
}
|
|
73
|
+
async drafttQuery(args) {
|
|
74
|
+
this.logger.debug("Draftt query with args:", args);
|
|
75
|
+
if (!args.componentId) {
|
|
76
|
+
throw new client_2.ApiError("MISSING_PARAM", "Missing required parameter: componentId");
|
|
77
|
+
}
|
|
78
|
+
const requestBody = this.buildQueryBody(args);
|
|
79
|
+
return this.post(`/component/${args.componentId}/draftt/query`, requestBody);
|
|
80
|
+
}
|
|
70
81
|
buildSearchBody(args) {
|
|
71
82
|
const searchBody = {};
|
|
72
83
|
// Skip undefined values to keep the request payload clean
|
|
73
84
|
Object.entries(args).forEach(([key, value]) => {
|
|
74
|
-
if (value !== undefined && key !==
|
|
85
|
+
if (value !== undefined && key !== "policyId") {
|
|
86
|
+
// Skip policyId as it's used in the URL for some endpoints
|
|
75
87
|
searchBody[key] = value;
|
|
76
88
|
}
|
|
77
89
|
});
|
|
78
90
|
return searchBody;
|
|
79
91
|
}
|
|
92
|
+
buildQueryBody(args) {
|
|
93
|
+
const queryBody = {};
|
|
94
|
+
// Skip undefined values and URL parameters
|
|
95
|
+
Object.entries(args).forEach(([key, value]) => {
|
|
96
|
+
if (value !== undefined && key !== "policyId" && key !== "componentId") {
|
|
97
|
+
// Skip policyId and componentId as they're used in the URL
|
|
98
|
+
queryBody[key] = value;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return queryBody;
|
|
102
|
+
}
|
|
80
103
|
}
|
|
81
104
|
exports.DrafttClient = DrafttClient;
|
|
82
105
|
//# sourceMappingURL=drafttClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drafttClient.js","sourceRoot":"","sources":["../../src/api/drafttClient.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"drafttClient.js","sourceRoot":"","sources":["../../src/api/drafttClient.ts"],"names":[],"mappings":";;;AAAA,qCAA6C;AAS7C,qCAAoC;AAEpC,MAAa,YAAa,SAAQ,kBAAS;IAGvC,YAAY,MAAc,EAAE,SAAkB,EAAE,OAAgB;QAC5D,MAAM,MAAM,GAAG,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QAE1D,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,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AAI,GAAG,KAAK,aAAa,EAAE,CAAC;gBACrE,2DAA2D;gBAC3D,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YAC3B,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AA1HD,oCA0HC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
1
|
+
export declare function formatComponentSummary(component: any): string;
|
|
2
|
+
export declare function formatPolicyComponentSummary(policyComponent: any): string;
|
|
3
|
+
export declare function formatSuccessResponse(data: any, options?: {
|
|
4
|
+
useSummary?: boolean;
|
|
5
|
+
toolName?: string;
|
|
6
|
+
}): any;
|
|
7
7
|
export declare function formatErrorResponse(code: string, message: string, details?: any): {
|
|
8
8
|
content: {
|
|
9
9
|
type: string;
|
|
@@ -1,21 +1,174 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatComponentSummary = formatComponentSummary;
|
|
4
|
+
exports.formatPolicyComponentSummary = formatPolicyComponentSummary;
|
|
3
5
|
exports.formatSuccessResponse = formatSuccessResponse;
|
|
4
6
|
exports.formatErrorResponse = formatErrorResponse;
|
|
5
|
-
function
|
|
7
|
+
function formatComponentSummary(component) {
|
|
8
|
+
if (!component || typeof component !== "object") {
|
|
9
|
+
return JSON.stringify(component, null, 2);
|
|
10
|
+
}
|
|
11
|
+
const summary = {
|
|
12
|
+
id: component.id || component.componentId,
|
|
13
|
+
name: component.name,
|
|
14
|
+
type: component.type,
|
|
15
|
+
technology: component.technology,
|
|
16
|
+
currentVersion: component.version || component.currentVersion,
|
|
17
|
+
region: component.region,
|
|
18
|
+
status: component.status,
|
|
19
|
+
tags: component.tags,
|
|
20
|
+
};
|
|
21
|
+
let formattedSummary = `## Component Summary\n`;
|
|
22
|
+
if (summary.name)
|
|
23
|
+
formattedSummary += `**Name:** ${summary.name}\n`;
|
|
24
|
+
if (summary.type)
|
|
25
|
+
formattedSummary += `**Type:** ${summary.type}\n`;
|
|
26
|
+
if (summary.technology)
|
|
27
|
+
formattedSummary += `**Technology:** ${summary.technology}\n`;
|
|
28
|
+
if (summary.currentVersion)
|
|
29
|
+
formattedSummary += `**Current Version:** ${summary.currentVersion}\n`;
|
|
30
|
+
if (summary.region)
|
|
31
|
+
formattedSummary += `**Region:** ${summary.region}\n`;
|
|
32
|
+
if (summary.status)
|
|
33
|
+
formattedSummary += `**Status:** ${summary.status}\n`;
|
|
34
|
+
if (summary.tags && Object.keys(summary.tags).length > 0) {
|
|
35
|
+
formattedSummary += `**Tags:** ${Object.entries(summary.tags)
|
|
36
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
37
|
+
.join(", ")}\n`;
|
|
38
|
+
}
|
|
39
|
+
return formattedSummary;
|
|
40
|
+
}
|
|
41
|
+
function formatPolicyComponentSummary(policyComponent) {
|
|
42
|
+
if (!policyComponent || typeof policyComponent !== "object") {
|
|
43
|
+
return JSON.stringify(policyComponent, null, 2);
|
|
44
|
+
}
|
|
45
|
+
const summary = {
|
|
46
|
+
id: policyComponent.id || policyComponent.componentId,
|
|
47
|
+
name: policyComponent.name,
|
|
48
|
+
type: policyComponent.type,
|
|
49
|
+
technology: policyComponent.technology,
|
|
50
|
+
currentVersion: policyComponent.version || policyComponent.currentVersion,
|
|
51
|
+
region: policyComponent.region,
|
|
52
|
+
isCompliant: policyComponent.isCompliant,
|
|
53
|
+
recommendedVersion: policyComponent.recommendedVersion,
|
|
54
|
+
requiredVersion: policyComponent.requiredVersion,
|
|
55
|
+
desiredVersion: policyComponent.desiredVersion,
|
|
56
|
+
dueDate: policyComponent.dueDate,
|
|
57
|
+
urgency: policyComponent.urgency,
|
|
58
|
+
priority: policyComponent.priority,
|
|
59
|
+
tags: policyComponent.tags,
|
|
60
|
+
};
|
|
61
|
+
let formattedSummary = `## Policy Component Summary\n`;
|
|
62
|
+
if (summary.name)
|
|
63
|
+
formattedSummary += `**Component:** ${summary.name}\n`;
|
|
64
|
+
if (summary.type)
|
|
65
|
+
formattedSummary += `**Type:** ${summary.type}\n`;
|
|
66
|
+
if (summary.technology)
|
|
67
|
+
formattedSummary += `**Technology:** ${summary.technology}\n`;
|
|
68
|
+
if (summary.currentVersion)
|
|
69
|
+
formattedSummary += `**Current Version:** ${summary.currentVersion}\n`;
|
|
70
|
+
if (summary.isCompliant !== undefined) {
|
|
71
|
+
formattedSummary += `**Compliance Status:** ${summary.isCompliant ? "✅ Compliant" : "❌ Non-Compliant"}\n`;
|
|
72
|
+
}
|
|
73
|
+
if (summary.recommendedVersion)
|
|
74
|
+
formattedSummary += `**Recommended Version:** ${summary.recommendedVersion}\n`;
|
|
75
|
+
if (summary.requiredVersion)
|
|
76
|
+
formattedSummary += `**Required Version:** ${summary.requiredVersion}\n`;
|
|
77
|
+
if (summary.desiredVersion)
|
|
78
|
+
formattedSummary += `**Desired Version:** ${summary.desiredVersion}\n`;
|
|
79
|
+
if (summary.dueDate)
|
|
80
|
+
formattedSummary += `**Due Date:** ${summary.dueDate}\n`;
|
|
81
|
+
if (summary.urgency !== undefined)
|
|
82
|
+
formattedSummary += `**Urgency:** ${summary.urgency}\n`;
|
|
83
|
+
if (summary.priority !== undefined)
|
|
84
|
+
formattedSummary += `**Priority:** ${summary.priority}\n`;
|
|
85
|
+
if (summary.region)
|
|
86
|
+
formattedSummary += `**Region:** ${summary.region}\n`;
|
|
87
|
+
return formattedSummary;
|
|
88
|
+
}
|
|
89
|
+
function detectLargeJsonBlob(data) {
|
|
90
|
+
const jsonString = JSON.stringify(data);
|
|
91
|
+
return jsonString.length > 1000 || (Array.isArray(data) && data.length > 5);
|
|
92
|
+
}
|
|
93
|
+
function shouldSummarize(data, toolName) {
|
|
94
|
+
if (!toolName)
|
|
95
|
+
return false;
|
|
96
|
+
return (toolName.includes("component") &&
|
|
97
|
+
(detectLargeJsonBlob(data) || (typeof data === "object" && data !== null)));
|
|
98
|
+
}
|
|
99
|
+
function formatSuccessResponse(data, options) {
|
|
100
|
+
const { useSummary = true, toolName } = options || {};
|
|
101
|
+
if (!useSummary || !shouldSummarize(data, toolName)) {
|
|
102
|
+
return {
|
|
103
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (Array.isArray(data)) {
|
|
107
|
+
if (toolName?.includes("component_search") ||
|
|
108
|
+
toolName?.includes("policy_component_search")) {
|
|
109
|
+
const summaries = data
|
|
110
|
+
.map((item, index) => {
|
|
111
|
+
if (toolName.includes("policy_component")) {
|
|
112
|
+
return `### Component ${index + 1}\n${formatPolicyComponentSummary(item)}`;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return `### Component ${index + 1}\n${formatComponentSummary(item)}`;
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
.join("\n---\n");
|
|
119
|
+
const totalCount = data.length;
|
|
120
|
+
const header = `# Search Results (${totalCount} found)\n\n`;
|
|
121
|
+
return {
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
type: "text",
|
|
125
|
+
text: header +
|
|
126
|
+
summaries +
|
|
127
|
+
`\n\n*Note: Use raw JSON format if you need complete details.*`,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (typeof data === "object" && data !== null) {
|
|
134
|
+
if (toolName?.includes("component_get")) {
|
|
135
|
+
return {
|
|
136
|
+
content: [
|
|
137
|
+
{
|
|
138
|
+
type: "text",
|
|
139
|
+
text: formatComponentSummary(data) +
|
|
140
|
+
`\n\n*Use raw JSON format if you need complete details.*`,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
else if (toolName?.includes("policy_component_get")) {
|
|
146
|
+
return {
|
|
147
|
+
content: [
|
|
148
|
+
{
|
|
149
|
+
type: "text",
|
|
150
|
+
text: formatPolicyComponentSummary(data) +
|
|
151
|
+
`\n\n*Use raw JSON format if you need complete details.*`,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
6
157
|
return {
|
|
7
|
-
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
158
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
8
159
|
};
|
|
9
160
|
}
|
|
10
161
|
function formatErrorResponse(code, message, details) {
|
|
11
162
|
return {
|
|
12
|
-
content: [
|
|
163
|
+
content: [
|
|
164
|
+
{
|
|
13
165
|
type: "text",
|
|
14
166
|
text: JSON.stringify({
|
|
15
|
-
error: { code, message, details }
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
167
|
+
error: { code, message, details },
|
|
168
|
+
}, null, 2),
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
isError: true,
|
|
19
172
|
};
|
|
20
173
|
}
|
|
21
174
|
//# sourceMappingURL=responseFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responseFormatter.js","sourceRoot":"","sources":["../../src/api/responseFormatter.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"responseFormatter.js","sourceRoot":"","sources":["../../src/api/responseFormatter.ts"],"names":[],"mappings":";;AAqBA,wDAiCC;AAED,oEA+CC;AAgBD,sDA0EC;AAED,kDAgBC;AA9LD,SAAgB,sBAAsB,CAAC,SAAc;IACjD,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,OAAO,GAAqB;QAC9B,EAAE,EAAE,SAAS,CAAC,EAAE,IAAI,SAAS,CAAC,WAAW;QACzC,IAAI,EAAE,SAAS,CAAC,IAA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|
6
6
|
search(args: ComponentSearchArgs): Promise<{
|
|
7
|
+
isError?: boolean | undefined;
|
|
7
8
|
content: {
|
|
8
|
-
type:
|
|
9
|
+
type: "text";
|
|
9
10
|
text: string;
|
|
10
11
|
}[];
|
|
11
12
|
}>;
|
|
12
13
|
get(args: ComponentGetArgs): Promise<{
|
|
14
|
+
isError?: boolean | undefined;
|
|
13
15
|
content: {
|
|
14
|
-
type:
|
|
16
|
+
type: "text";
|
|
15
17
|
text: string;
|
|
16
18
|
}[];
|
|
17
19
|
}>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ComponentHandler = void 0;
|
|
4
4
|
const client_1 = require("../api/client");
|
|
5
|
-
const responseFormatter_1 = require("../api/responseFormatter");
|
|
6
5
|
const logger_1 = require("../utils/logger");
|
|
6
|
+
const json_1 = require("../utils/json");
|
|
7
7
|
class ComponentHandler {
|
|
8
8
|
constructor(client) {
|
|
9
9
|
this.client = client;
|
|
@@ -13,14 +13,15 @@ class ComponentHandler {
|
|
|
13
13
|
try {
|
|
14
14
|
logger.debug("Processing component search with args:", args);
|
|
15
15
|
const result = await this.client.componentSearch(args);
|
|
16
|
-
return (0,
|
|
16
|
+
return (0, json_1.createSafeResponse)(result);
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
19
|
logger.error("Error in component search:", error);
|
|
20
20
|
if (error instanceof client_1.ApiError) {
|
|
21
|
-
return (0,
|
|
21
|
+
return (0, json_1.createSafeResponse)({ error: { code: error.code, message: error.message, details: error.details } }, true);
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
24
|
+
return (0, json_1.createSafeResponse)({ error: { code: "INTERNAL_ERROR", message: `Unexpected error during component search: ${errorMessage}` } }, true);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
async get(args) {
|
|
@@ -28,17 +29,18 @@ class ComponentHandler {
|
|
|
28
29
|
try {
|
|
29
30
|
logger.debug("Processing component get with args:", args);
|
|
30
31
|
if (!args.componentId) {
|
|
31
|
-
return (0,
|
|
32
|
+
return (0, json_1.createSafeResponse)({ error: { code: "MISSING_PARAM", message: "Missing required parameter: componentId" } }, true);
|
|
32
33
|
}
|
|
33
34
|
const result = await this.client.componentGet(args);
|
|
34
|
-
return (0,
|
|
35
|
+
return (0, json_1.createSafeResponse)(result);
|
|
35
36
|
}
|
|
36
37
|
catch (error) {
|
|
37
38
|
logger.error("Error in component get:", error);
|
|
38
39
|
if (error instanceof client_1.ApiError) {
|
|
39
|
-
return (0,
|
|
40
|
+
return (0, json_1.createSafeResponse)({ error: { code: error.code, message: error.message, details: error.details } }, true);
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
43
|
+
return (0, json_1.createSafeResponse)({ error: { code: "INTERNAL_ERROR", message: `Unexpected error during component get: ${errorMessage}` } }, true);
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentHandler.js","sourceRoot":"","sources":["../../src/handlers/componentHandler.ts"],"names":[],"mappings":";;;AACA,0CAAyC;
|
|
1
|
+
{"version":3,"file":"componentHandler.js","sourceRoot":"","sources":["../../src/handlers/componentHandler.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AAEzC,4CAA4C;AAC5C,wCAAmD;AAEnD,MAAa,gBAAgB;IACzB,YAAoB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE5C,KAAK,CAAC,MAAM,CAAC,IAAyB;QAClC,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAE3B,IAAI,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,IAAI,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI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AC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAC/C,IAAI,KAAK,YAAY,iBAAQ,EAAE,CAAC;gBAC5B,OAAO,IAAA,yBAAkB,EACrB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAC/E,IAAI,CACP,CAAC;YACN,CAAC;YACD,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,IAAA,yBAAkB,EACrB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,0CAA0C,YAAY,EAAE,EAAE,EAAE,EACxG,IAAI,CACP,CAAC;QACN,CAAC;IACL,CAAC;CAEJ;AAzDD,4CAyDC"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { DrafttClient } from "../api/drafttClient";
|
|
2
|
-
import { DrafttGetArgs } from "../models/draftt";
|
|
2
|
+
import { DrafttGetArgs, DrafttQueryArgs } from "../models/draftt";
|
|
3
3
|
export declare class DrafttHandler {
|
|
4
4
|
private client;
|
|
5
5
|
constructor(client: DrafttClient);
|
|
6
6
|
get(args: DrafttGetArgs): Promise<{
|
|
7
|
+
isError?: boolean | undefined;
|
|
7
8
|
content: {
|
|
8
|
-
type:
|
|
9
|
+
type: "text";
|
|
10
|
+
text: string;
|
|
11
|
+
}[];
|
|
12
|
+
}>;
|
|
13
|
+
query(args: DrafttQueryArgs): Promise<{
|
|
14
|
+
isError?: boolean | undefined;
|
|
15
|
+
content: {
|
|
16
|
+
type: "text";
|
|
9
17
|
text: string;
|
|
10
18
|
}[];
|
|
11
19
|
}>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DrafttHandler = void 0;
|
|
4
4
|
const client_1 = require("../api/client");
|
|
5
|
-
const responseFormatter_1 = require("../api/responseFormatter");
|
|
6
5
|
const logger_1 = require("../utils/logger");
|
|
6
|
+
const json_1 = require("../utils/json");
|
|
7
7
|
class DrafttHandler {
|
|
8
8
|
constructor(client) {
|
|
9
9
|
this.client = client;
|
|
@@ -13,14 +13,34 @@ class DrafttHandler {
|
|
|
13
13
|
try {
|
|
14
14
|
logger.debug("Processing draftt get with args:", args);
|
|
15
15
|
const result = await this.client.drafttGet(args);
|
|
16
|
-
return (0,
|
|
16
|
+
return (0, json_1.createSafeResponse)(result);
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
19
|
logger.error("Error in draftt get:", error);
|
|
20
20
|
if (error instanceof client_1.ApiError) {
|
|
21
|
-
return (0,
|
|
21
|
+
return (0, json_1.createSafeResponse)({ error: { code: error.code, message: error.message, details: error.details } }, true);
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
24
|
+
return (0, json_1.createSafeResponse)({ error: { code: "INTERNAL_ERROR", message: `Unexpected error during draftt get: ${errorMessage}` } }, true);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async query(args) {
|
|
28
|
+
const logger = (0, logger_1.getLogger)();
|
|
29
|
+
try {
|
|
30
|
+
logger.debug("Processing draftt query with args:", args);
|
|
31
|
+
if (!args.componentId) {
|
|
32
|
+
return (0, json_1.createSafeResponse)({ error: { code: "MISSING_PARAM", message: "Missing required parameter: componentId" } }, true);
|
|
33
|
+
}
|
|
34
|
+
const result = await this.client.drafttQuery(args);
|
|
35
|
+
return (0, json_1.createSafeResponse)(result);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
logger.error("Error in draftt query:", error);
|
|
39
|
+
if (error instanceof client_1.ApiError) {
|
|
40
|
+
return (0, json_1.createSafeResponse)({ error: { code: error.code, message: error.message, details: error.details } }, true);
|
|
41
|
+
}
|
|
42
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
43
|
+
return (0, json_1.createSafeResponse)({ error: { code: "INTERNAL_ERROR", message: `Unexpected error during draftt query: ${errorMessage}` } }, true);
|
|
24
44
|
}
|
|
25
45
|
}
|
|
26
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drafttHandler.js","sourceRoot":"","sources":["../../src/handlers/drafttHandler.ts"],"names":[],"mappings":";;;AACA,0CAAyC;
|
|
1
|
+
{"version":3,"file":"drafttHandler.js","sourceRoot":"","sources":["../../src/handlers/drafttHandler.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AAEzC,4CAA4C;AAC5C,wCAAmD;AAEnD,MAAa,aAAa;IACtB,YAAoB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE5C,KAAK,CAAC,GAAG,CAAC,IAAmB;QACzB,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAE3B,IAAI,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAC;YAEvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACjD,OAAO,IAAA,yBAAkB,EAAC,MAAM,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;YAC5C,IAAI,KAAK,YAAY,iBAAQ,EAAE,CAAC;gBAC5B,OAAO,IAAA,yBAAkB,EACrB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAC/E,IAAI,CAC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KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,IAAA,yBAAkB,EACrB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,yCAAyC,YAAY,EAAE,EAAE,EAAE,EACvG,IAAI,CACP,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AAzDD,sCAyDC"}
|
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import { DrafttClient } from "../api/drafttClient";
|
|
2
|
-
import { PolicyComponentGetArgs,
|
|
2
|
+
import { PolicyComponentGetArgs, PolicyComponentQueryArgs } from "../models/component";
|
|
3
3
|
import { PolicyGetArgs, PolicySearchArgs } from "../models/policy";
|
|
4
4
|
export declare class PolicyHandler {
|
|
5
5
|
private client;
|
|
6
6
|
constructor(client: DrafttClient);
|
|
7
7
|
search(args: PolicySearchArgs): Promise<{
|
|
8
|
+
isError?: boolean | undefined;
|
|
8
9
|
content: {
|
|
9
|
-
type:
|
|
10
|
+
type: "text";
|
|
10
11
|
text: string;
|
|
11
12
|
}[];
|
|
12
13
|
}>;
|
|
13
14
|
get(args: PolicyGetArgs): Promise<{
|
|
15
|
+
isError?: boolean | undefined;
|
|
14
16
|
content: {
|
|
15
|
-
type:
|
|
17
|
+
type: "text";
|
|
16
18
|
text: string;
|
|
17
19
|
}[];
|
|
18
20
|
}>;
|
|
19
|
-
|
|
21
|
+
componentQuery(args: PolicyComponentQueryArgs): Promise<{
|
|
22
|
+
isError?: boolean | undefined;
|
|
20
23
|
content: {
|
|
21
|
-
type:
|
|
24
|
+
type: "text";
|
|
22
25
|
text: string;
|
|
23
26
|
}[];
|
|
24
27
|
}>;
|
|
25
28
|
componentGet(args: PolicyComponentGetArgs): Promise<{
|
|
29
|
+
isError?: boolean | undefined;
|
|
26
30
|
content: {
|
|
27
|
-
type:
|
|
31
|
+
type: "text";
|
|
28
32
|
text: string;
|
|
29
33
|
}[];
|
|
30
34
|
}>;
|