@draftt-io/draftt-mcp 1.0.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.
- package/LICENSE +201 -0
- package/README.md +117 -0
- package/dist/api/client.d.ts +20 -0
- package/dist/api/client.js +93 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/drafttClient.d.ts +20 -0
- package/dist/api/drafttClient.js +90 -0
- package/dist/api/drafttClient.js.map +1 -0
- package/dist/api/responseFormatter.d.ts +13 -0
- package/dist/api/responseFormatter.js +21 -0
- package/dist/api/responseFormatter.js.map +1 -0
- package/dist/drafttClient.d.ts +17 -0
- package/dist/drafttClient.js +187 -0
- package/dist/drafttClient.js.map +1 -0
- package/dist/handlers/componentHandler.d.ts +18 -0
- package/dist/handlers/componentHandler.js +46 -0
- package/dist/handlers/componentHandler.js.map +1 -0
- package/dist/handlers/drafttHandler.d.ts +12 -0
- package/dist/handlers/drafttHandler.js +31 -0
- package/dist/handlers/drafttHandler.js.map +1 -0
- package/dist/handlers/policyHandler.d.ts +31 -0
- package/dist/handlers/policyHandler.js +85 -0
- package/dist/handlers/policyHandler.js.map +1 -0
- package/dist/helpers/constants.d.ts +31 -0
- package/dist/helpers/constants.js +37 -0
- package/dist/helpers/constants.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +121 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/component.d.ts +60 -0
- package/dist/interfaces/component.js +3 -0
- package/dist/interfaces/component.js.map +1 -0
- package/dist/interfaces/draftt.d.ts +3 -0
- package/dist/interfaces/draftt.js +3 -0
- package/dist/interfaces/draftt.js.map +1 -0
- package/dist/interfaces/policy.d.ts +21 -0
- package/dist/interfaces/policy.js +3 -0
- package/dist/interfaces/policy.js.map +1 -0
- package/dist/models/component.d.ts +60 -0
- package/dist/models/component.js +3 -0
- package/dist/models/component.js.map +1 -0
- package/dist/models/draftt.d.ts +3 -0
- package/dist/models/draftt.js +3 -0
- package/dist/models/draftt.js.map +1 -0
- package/dist/models/policy.d.ts +21 -0
- package/dist/models/policy.js +3 -0
- package/dist/models/policy.js.map +1 -0
- package/dist/schemas/componentSchema.d.ts +278 -0
- package/dist/schemas/componentSchema.js +87 -0
- package/dist/schemas/componentSchema.js.map +1 -0
- package/dist/schemas/drafttSchema.d.ts +4 -0
- package/dist/schemas/drafttSchema.js +8 -0
- package/dist/schemas/drafttSchema.js.map +1 -0
- package/dist/schemas/policySchema.d.ts +100 -0
- package/dist/schemas/policySchema.js +33 -0
- package/dist/schemas/policySchema.js.map +1 -0
- package/dist/tools.d.ts +6 -0
- package/dist/tools.js +277 -0
- package/dist/tools.js.map +1 -0
- package/dist/utils/constants.d.ts +31 -0
- package/dist/utils/constants.js +37 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.js +52 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Draftt MCP Server
|
|
2
|
+
|
|
3
|
+
Connect to your Draftt API directly from any MCP Client (like Claude Desktop) using the Model Context Protocol (MCP).
|
|
4
|
+
|
|
5
|
+
This server connects agents to Draftt's component and policy management API through natural language conversations, enabling interaction with:
|
|
6
|
+
|
|
7
|
+
- Component search and management
|
|
8
|
+
- Policy search and management
|
|
9
|
+
- Policy component associations
|
|
10
|
+
- Draftt query functionality
|
|
11
|
+
|
|
12
|
+
## Available Tools
|
|
13
|
+
|
|
14
|
+
* `draftt_component_search`: Search for components with various filters
|
|
15
|
+
* `draftt_component_get`: Get a specific component by ID
|
|
16
|
+
* `draftt_policy_search`: Search for policies with various filters
|
|
17
|
+
* `draftt_policy_get`: Get a specific policy by ID
|
|
18
|
+
* `draftt_component_policy_search`: Search for components within a policy
|
|
19
|
+
* `draftt_component_policy_get`: Get a specific component within a policy
|
|
20
|
+
* `draftt_get`: Get draftts (k8s upgrade guides) for a k8s component
|
|
21
|
+
|
|
22
|
+
## Prerequisites
|
|
23
|
+
|
|
24
|
+
* Draftt API access key
|
|
25
|
+
* MCP Client (e.g. Claude Desktop, Cursor)
|
|
26
|
+
|
|
27
|
+
## Installation & Setup
|
|
28
|
+
|
|
29
|
+
You can use the mcp server in two ways:
|
|
30
|
+
|
|
31
|
+
1. npx
|
|
32
|
+
2. docker
|
|
33
|
+
|
|
34
|
+
we will show the configuration for Claude Desktop for both options.
|
|
35
|
+
|
|
36
|
+
### Using npx
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"mcpServers": {
|
|
41
|
+
"draftt": {
|
|
42
|
+
"command": "npx",
|
|
43
|
+
"args": [
|
|
44
|
+
"-y",
|
|
45
|
+
"@draftt-io/draftt-mcp"
|
|
46
|
+
],
|
|
47
|
+
"env": {
|
|
48
|
+
"DRAFTT_ACCESS_KEY": "YOUR_ACCESS_KEY"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Using docker
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"draftt": {
|
|
62
|
+
"command": "docker",
|
|
63
|
+
"args": [
|
|
64
|
+
"run",
|
|
65
|
+
"-i",
|
|
66
|
+
"--rm",
|
|
67
|
+
"-e",
|
|
68
|
+
"DRAFTT_ACCESS_KEY",
|
|
69
|
+
"draftt-mcp"
|
|
70
|
+
],
|
|
71
|
+
"env": {
|
|
72
|
+
"DRAFTT_ACCESS_KEY": "YOUR_ACCESS_KEY"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Example Questions
|
|
80
|
+
|
|
81
|
+
Here are some natural language queries you can try with your MCP Client:
|
|
82
|
+
|
|
83
|
+
* "Search for all k8s components"
|
|
84
|
+
* "What is the most urgent component to update?"
|
|
85
|
+
* "What is the next recommended version for component XYZ?"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
## Project Structure
|
|
89
|
+
|
|
90
|
+
The server uses a modular architecture:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
src/
|
|
94
|
+
├── api/ # API client layer
|
|
95
|
+
├── handlers/ # Request handlers
|
|
96
|
+
├── models/ # Data models/interfaces
|
|
97
|
+
├── schemas/ # Tool schemas
|
|
98
|
+
├── utils/ # Utility functions
|
|
99
|
+
└── index.ts # Entry point
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
## Security Best Practices
|
|
104
|
+
|
|
105
|
+
Warning
|
|
106
|
+
|
|
107
|
+
Create dedicated API access keys with appropriate permissions. Never share or expose your access keys in code repositories.
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
Apache 2.0
|
|
112
|
+
|
|
113
|
+
## Troubleshooting
|
|
114
|
+
|
|
115
|
+
* Ensure your MCP configuration is correct
|
|
116
|
+
* Verify your Draftt access key is valid
|
|
117
|
+
* Check docker/npx logs for error messages
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class ApiError extends Error {
|
|
2
|
+
code: string;
|
|
3
|
+
details?: any | undefined;
|
|
4
|
+
constructor(code: string, message: string, details?: any | undefined);
|
|
5
|
+
}
|
|
6
|
+
export interface ApiClientOptions {
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
logger: any;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class ApiClient {
|
|
11
|
+
protected baseUrl: string;
|
|
12
|
+
protected logger: any;
|
|
13
|
+
constructor(options: ApiClientOptions);
|
|
14
|
+
protected abstract getHeaders(): Record<string, string>;
|
|
15
|
+
protected logRequestDetails(method: string, path: string, body?: any): void;
|
|
16
|
+
protected get(path: string): Promise<any>;
|
|
17
|
+
protected post(path: string, body?: any): Promise<any>;
|
|
18
|
+
private handleResponse;
|
|
19
|
+
private handleError;
|
|
20
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiClient = exports.ApiError = void 0;
|
|
4
|
+
class ApiError extends Error {
|
|
5
|
+
constructor(code, message, details) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.details = details;
|
|
9
|
+
this.name = "ApiError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.ApiError = ApiError;
|
|
13
|
+
class ApiClient {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.baseUrl = options.baseUrl;
|
|
16
|
+
this.logger = options.logger;
|
|
17
|
+
}
|
|
18
|
+
logRequestDetails(method, path, body) {
|
|
19
|
+
const url = `${this.baseUrl}${path}`;
|
|
20
|
+
const headers = this.getHeaders();
|
|
21
|
+
this.logger.debug('API Request Details:', {
|
|
22
|
+
method,
|
|
23
|
+
url,
|
|
24
|
+
headers,
|
|
25
|
+
body: body ? JSON.stringify(body, null, 2) : undefined
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async get(path) {
|
|
29
|
+
this.logRequestDetails('GET', path);
|
|
30
|
+
try {
|
|
31
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
32
|
+
method: "GET",
|
|
33
|
+
headers: this.getHeaders()
|
|
34
|
+
});
|
|
35
|
+
return this.handleResponse(response);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
this.handleError(error, "GET", path);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async post(path, body) {
|
|
42
|
+
this.logRequestDetails('POST', path, body);
|
|
43
|
+
try {
|
|
44
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: this.getHeaders(),
|
|
47
|
+
body: body ? JSON.stringify(body) : undefined
|
|
48
|
+
});
|
|
49
|
+
return this.handleResponse(response);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
this.handleError(error, "POST", path);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async handleResponse(response) {
|
|
56
|
+
const responseBody = await response.text();
|
|
57
|
+
this.logger.debug('API Response:', {
|
|
58
|
+
status: response.status,
|
|
59
|
+
statusText: response.statusText,
|
|
60
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
61
|
+
body: responseBody ? JSON.parse(responseBody) : undefined
|
|
62
|
+
});
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
if (response.status === 401) {
|
|
65
|
+
throw new ApiError("UNAUTHORIZED", "Unauthorized. Please check your access key and try again.");
|
|
66
|
+
}
|
|
67
|
+
let errorMessage = `Request failed with status ${response.status}`;
|
|
68
|
+
try {
|
|
69
|
+
const errorJson = JSON.parse(responseBody);
|
|
70
|
+
if (errorJson.message) {
|
|
71
|
+
errorMessage = errorJson.message;
|
|
72
|
+
}
|
|
73
|
+
throw new ApiError(`HTTP_${response.status}`, errorMessage, errorJson);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
if (e instanceof ApiError) {
|
|
77
|
+
throw e;
|
|
78
|
+
}
|
|
79
|
+
throw new ApiError(`HTTP_${response.status}`, errorMessage, { text: responseBody });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return JSON.parse(responseBody);
|
|
83
|
+
}
|
|
84
|
+
handleError(error, method, path) {
|
|
85
|
+
if (error instanceof ApiError) {
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
this.logger.error(`Error in ${method} ${path}:`, error);
|
|
89
|
+
throw new ApiError("NETWORK_ERROR", `Network error occurred during ${method} request to ${path}`, { originalError: error.message });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.ApiClient = ApiClient;
|
|
93
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAS,SAAQ,KAAK;IAC/B,YAAmB,IAAY,EAAE,OAAe,EAAS,OAAa;QAClE,KAAK,CAAC,OAAO,CAAC,CAAC;QADA,SAAI,GAAJ,IAAI,CAAQ;QAA0B,YAAO,GAAP,OAAO,CAAM;QAElE,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IAC3B,CAAC;CACJ;AALD,4BAKC;AAOD,MAAsB,SAAS;IAI3B,YAAY,OAAyB;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACjC,CAAC;IAIS,iBAAiB,CAAC,MAAc,EAAE,IAAY,EAAE,IAAU;QAChE,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAElC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE;YACtC,MAAM;YACN,GAAG;YACH,OAAO;YACP,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;SACzD,CAAC,CAAC;IACP,CAAC;IAES,KAAK,CAAC,GAAG,CAAC,IAAY;QAC5B,IAAI,CAAC,iBAAiB,CAAC,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C;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,MAAM,IAAI,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;QACxD,MAAM,IAAI,QAAQ,CACd,eAAe,EACf,iCAAiC,MAAM,eAAe,IAAI,EAAE,EAC5D,EAAE,aAAa,EAAE,KAAK,CAAC,OAAO,EAAE,CACnC,CAAC;IACN,CAAC;CACJ;AApGD,8BAoGC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ApiClient } from "./client";
|
|
2
|
+
import { ComponentGetArgs, ComponentSearchArgs, PolicyComponentGetArgs, PolicyComponentSearchArgs } from "../models/component";
|
|
3
|
+
import { DrafttGetArgs } from "../models/draftt";
|
|
4
|
+
import { PolicyGetArgs, PolicySearchArgs } from "../models/policy";
|
|
5
|
+
export declare class DrafttClient extends ApiClient {
|
|
6
|
+
private accessKey;
|
|
7
|
+
constructor(logger: any, accessKey?: string);
|
|
8
|
+
protected getHeaders(): {
|
|
9
|
+
Authorization: string;
|
|
10
|
+
"Content-Type": string;
|
|
11
|
+
};
|
|
12
|
+
componentSearch(args: ComponentSearchArgs): Promise<any>;
|
|
13
|
+
componentGet(args: ComponentGetArgs): Promise<any>;
|
|
14
|
+
policySearch(args: PolicySearchArgs): Promise<any>;
|
|
15
|
+
policyGet(args: PolicyGetArgs): Promise<any>;
|
|
16
|
+
policyComponentSearch(args: PolicyComponentSearchArgs): Promise<any>;
|
|
17
|
+
policyComponentGet(args: PolicyComponentGetArgs): Promise<any>;
|
|
18
|
+
drafttGet(args: DrafttGetArgs): Promise<any>;
|
|
19
|
+
private buildSearchBody;
|
|
20
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DrafttClient = void 0;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const client_2 = require("./client");
|
|
6
|
+
class DrafttClient extends client_1.ApiClient {
|
|
7
|
+
constructor(logger, accessKey) {
|
|
8
|
+
const apiKey = accessKey || process.env.DRAFTT_ACCESS_KEY;
|
|
9
|
+
if (!apiKey) {
|
|
10
|
+
throw new Error("Access key is required for authentication");
|
|
11
|
+
}
|
|
12
|
+
super({
|
|
13
|
+
baseUrl: "https://api.draftt.io/v1",
|
|
14
|
+
logger
|
|
15
|
+
});
|
|
16
|
+
this.accessKey = apiKey;
|
|
17
|
+
}
|
|
18
|
+
getHeaders() {
|
|
19
|
+
return {
|
|
20
|
+
Authorization: `Bearer ${this.accessKey}`,
|
|
21
|
+
"Content-Type": "application/json",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
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
|
+
async componentGet(args) {
|
|
30
|
+
this.logger.debug("Component get with args:", args);
|
|
31
|
+
if (!args.componentId) {
|
|
32
|
+
throw new client_2.ApiError("MISSING_PARAM", "Missing required parameter: componentId");
|
|
33
|
+
}
|
|
34
|
+
return this.get(`/component/${args.componentId}`);
|
|
35
|
+
}
|
|
36
|
+
async policySearch(args) {
|
|
37
|
+
this.logger.debug("Policy search with args:", args);
|
|
38
|
+
const requestBody = {
|
|
39
|
+
...(args.filter ? { filter: args.filter } : {}),
|
|
40
|
+
...(args.sort ? { sort: args.sort } : {}),
|
|
41
|
+
...(args.nextToken ? { nextToken: args.nextToken } : {}),
|
|
42
|
+
...(args.pageSize ? { pageSize: args.pageSize } : {}),
|
|
43
|
+
};
|
|
44
|
+
return this.post("/policy/search", requestBody);
|
|
45
|
+
}
|
|
46
|
+
async policyGet(args) {
|
|
47
|
+
this.logger.debug("Policy get with args:", args);
|
|
48
|
+
if (!args.policyId) {
|
|
49
|
+
throw new client_2.ApiError("MISSING_PARAM", "Missing required parameter: policyId");
|
|
50
|
+
}
|
|
51
|
+
return this.get(`/policy/${args.policyId}`);
|
|
52
|
+
}
|
|
53
|
+
async policyComponentSearch(args) {
|
|
54
|
+
this.logger.debug("Policy component search with args:", args);
|
|
55
|
+
if (!args.policyId) {
|
|
56
|
+
throw new client_2.ApiError("MISSING_PARAM", "Missing required parameter: policyId");
|
|
57
|
+
}
|
|
58
|
+
const requestBody = this.buildSearchBody(args);
|
|
59
|
+
return this.post(`/policy/${args.policyId}/component/search`, requestBody);
|
|
60
|
+
}
|
|
61
|
+
async policyComponentGet(args) {
|
|
62
|
+
this.logger.debug("Policy component get with args:", args);
|
|
63
|
+
if (!args.policyId) {
|
|
64
|
+
throw new client_2.ApiError("MISSING_PARAM", "Missing required parameter: policyId");
|
|
65
|
+
}
|
|
66
|
+
if (!args.componentId) {
|
|
67
|
+
throw new client_2.ApiError("MISSING_PARAM", "Missing required parameter: componentId");
|
|
68
|
+
}
|
|
69
|
+
return this.get(`/policy/${args.policyId}/component/${args.componentId}`);
|
|
70
|
+
}
|
|
71
|
+
async drafttGet(args) {
|
|
72
|
+
this.logger.debug("Draftt get with args:", args);
|
|
73
|
+
if (!args.componentId) {
|
|
74
|
+
throw new client_2.ApiError("MISSING_PARAM", "Missing required parameter: componentId");
|
|
75
|
+
}
|
|
76
|
+
return this.post(`/draftt/search`, {});
|
|
77
|
+
}
|
|
78
|
+
buildSearchBody(args) {
|
|
79
|
+
const searchBody = {};
|
|
80
|
+
// Skip undefined values to keep the request payload clean
|
|
81
|
+
Object.entries(args).forEach(([key, value]) => {
|
|
82
|
+
if (value !== undefined && key !== 'policyId') { // Skip policyId as it's used in the URL for some endpoints
|
|
83
|
+
searchBody[key] = value;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return searchBody;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.DrafttClient = DrafttClient;
|
|
90
|
+
//# sourceMappingURL=drafttClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drafttClient.js","sourceRoot":"","sources":["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,GAAG,CAAC,GAAG,KAAK,CAAC;YAC5B,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AAnGD,oCAmGC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function formatSuccessResponse(data: any): {
|
|
2
|
+
content: {
|
|
3
|
+
type: string;
|
|
4
|
+
text: string;
|
|
5
|
+
}[];
|
|
6
|
+
};
|
|
7
|
+
export declare function formatErrorResponse(code: string, message: string, details?: any): {
|
|
8
|
+
content: {
|
|
9
|
+
type: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}[];
|
|
12
|
+
isError: boolean;
|
|
13
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatSuccessResponse = formatSuccessResponse;
|
|
4
|
+
exports.formatErrorResponse = formatErrorResponse;
|
|
5
|
+
function formatSuccessResponse(data) {
|
|
6
|
+
return {
|
|
7
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function formatErrorResponse(code, message, details) {
|
|
11
|
+
return {
|
|
12
|
+
content: [{
|
|
13
|
+
type: "text",
|
|
14
|
+
text: JSON.stringify({
|
|
15
|
+
error: { code, message, details }
|
|
16
|
+
})
|
|
17
|
+
}],
|
|
18
|
+
isError: true
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=responseFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseFormatter.js","sourceRoot":"","sources":["../../src/api/responseFormatter.ts"],"names":[],"mappings":";;AAAA,sDAIC;AAED,kDAUC;AAhBD,SAAgB,qBAAqB,CAAC,IAAS;IAC3C,OAAO;QACH,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;KAC1D,CAAC;AACN,CAAC;AAED,SAAgB,mBAAmB,CAAC,IAAY,EAAE,OAAe,EAAE,OAAa;IAC5E,OAAO;QACH,OAAO,EAAE,CAAC;gBACN,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACjB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;iBACpC,CAAC;aACL,CAAC;QACF,OAAO,EAAE,IAAI;KAChB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentGetArgs, ComponentSearchArgs, PolicyComponentGetArgs, PolicyComponentSearchArgs } from "./interfaces/component";
|
|
2
|
+
import { DrafttGetArgs } from "./interfaces/draftt";
|
|
3
|
+
import { PolicyGetArgs, PolicySearchArgs } from "./interfaces/policy";
|
|
4
|
+
export declare class DrafttClient {
|
|
5
|
+
private accessKey?;
|
|
6
|
+
private baseUrl;
|
|
7
|
+
private logger;
|
|
8
|
+
constructor(logger: any, accessKey?: string | undefined);
|
|
9
|
+
private getHeaders;
|
|
10
|
+
componentSearch(args: ComponentSearchArgs): Promise<any>;
|
|
11
|
+
componentGet(args: ComponentGetArgs): Promise<any>;
|
|
12
|
+
policySearch(args: PolicySearchArgs): Promise<any>;
|
|
13
|
+
policyGet(args: PolicyGetArgs): Promise<any>;
|
|
14
|
+
policyComponentSearch(args: PolicyComponentSearchArgs): Promise<any>;
|
|
15
|
+
policyComponentGet(args: PolicyComponentGetArgs): Promise<any>;
|
|
16
|
+
drafttGet(args: DrafttGetArgs): Promise<any>;
|
|
17
|
+
}
|