@smartbear/mcp 0.37.0 → 0.39.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/bugsnag/client.js +101 -22
- package/dist/common/initialize.js +0 -3
- package/dist/common/pollyfills.js +1 -43
- package/dist/common/server.js +0 -7
- package/dist/package.json.js +1 -1
- package/dist/pactflow/client/admin-api.js +491 -0
- package/dist/pactflow/client/ai-api.js +139 -0
- package/dist/pactflow/client/ai.js +0 -2
- package/dist/pactflow/client/contract-api.js +366 -0
- package/dist/pactflow/client/environment-api.js +156 -0
- package/dist/pactflow/client/http-client.js +47 -0
- package/dist/pactflow/client/pacticipant-api.js +288 -0
- package/dist/pactflow/client/prompt-utils.js +7 -86
- package/dist/pactflow/client/prompts.js +11 -31
- package/dist/pactflow/client/tools.js +0 -2
- package/dist/pactflow/client/webhook-api.js +113 -0
- package/dist/pactflow/client.js +29 -1998
- package/dist/swagger/client/api.js +25 -4
- package/dist/swagger/client/functional-testing-api.js +39 -17
- package/dist/swagger/client/functional-testing-tools.js +4 -4
- package/dist/swagger/client/functional-testing-types.js +10 -7
- package/dist/swagger/client/portal-types.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
class PacticipantApi {
|
|
2
|
+
constructor(http) {
|
|
3
|
+
this.http = http;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves all pacticipants, with optional pagination.
|
|
7
|
+
*/
|
|
8
|
+
async listPacticipants(params) {
|
|
9
|
+
const queryParams = new URLSearchParams();
|
|
10
|
+
if (params?.pageNumber) queryParams.set("page", String(params.pageNumber));
|
|
11
|
+
if (params?.pageSize) queryParams.set("size", String(params.pageSize));
|
|
12
|
+
const qs = queryParams.toString();
|
|
13
|
+
return await this.http.fetch(
|
|
14
|
+
`${this.http.baseUrl}/pacticipants${qs ? `?${qs}` : ""}`,
|
|
15
|
+
{ method: "GET", errorContext: "List Pacticipants" }
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves metadata for a specific pacticipant by name.
|
|
20
|
+
*/
|
|
21
|
+
async getPacticipant({
|
|
22
|
+
pacticipantName
|
|
23
|
+
}) {
|
|
24
|
+
return await this.http.fetch(
|
|
25
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}`,
|
|
26
|
+
{ method: "GET", errorContext: "Get Pacticipant" }
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves all branches for a given pacticipant, with optional name filtering
|
|
31
|
+
* and pagination.
|
|
32
|
+
*/
|
|
33
|
+
async listBranches({
|
|
34
|
+
pacticipantName,
|
|
35
|
+
q,
|
|
36
|
+
pageNumber,
|
|
37
|
+
pageSize
|
|
38
|
+
}) {
|
|
39
|
+
const queryParams = new URLSearchParams();
|
|
40
|
+
if (q) queryParams.set("q", q);
|
|
41
|
+
if (pageNumber) queryParams.set("pageNumber", String(pageNumber));
|
|
42
|
+
if (pageSize) queryParams.set("pageSize", String(pageSize));
|
|
43
|
+
const qs = queryParams.toString();
|
|
44
|
+
return await this.http.fetch(
|
|
45
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/branches${qs ? `?${qs}` : ""}`,
|
|
46
|
+
{ method: "GET", errorContext: "List Branches" }
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves all published versions for a given pacticipant, with optional pagination.
|
|
51
|
+
*/
|
|
52
|
+
async listVersions({
|
|
53
|
+
pacticipantName,
|
|
54
|
+
pageNumber,
|
|
55
|
+
pageSize
|
|
56
|
+
}) {
|
|
57
|
+
const queryParams = new URLSearchParams();
|
|
58
|
+
if (pageNumber) queryParams.set("page", String(pageNumber));
|
|
59
|
+
if (pageSize) queryParams.set("size", String(pageSize));
|
|
60
|
+
const qs = queryParams.toString();
|
|
61
|
+
return await this.http.fetch(
|
|
62
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions${qs ? `?${qs}` : ""}`,
|
|
63
|
+
{ method: "GET", errorContext: "List Versions" }
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves metadata for a specific version of a pacticipant.
|
|
68
|
+
*/
|
|
69
|
+
async getVersion({
|
|
70
|
+
pacticipantName,
|
|
71
|
+
versionNumber
|
|
72
|
+
}) {
|
|
73
|
+
return await this.http.fetch(
|
|
74
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}`,
|
|
75
|
+
{ method: "GET", errorContext: "Get Version" }
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the latest version of a pacticipant, optionally filtered by tag.
|
|
80
|
+
*/
|
|
81
|
+
async getLatestVersion({
|
|
82
|
+
pacticipantName,
|
|
83
|
+
tag
|
|
84
|
+
}) {
|
|
85
|
+
const path = tag ? `/pacticipants/${encodeURIComponent(pacticipantName)}/latest-version/${encodeURIComponent(tag)}` : `/pacticipants/${encodeURIComponent(pacticipantName)}/latest-version`;
|
|
86
|
+
return await this.http.fetch(
|
|
87
|
+
`${this.http.baseUrl}${path}`,
|
|
88
|
+
{
|
|
89
|
+
method: "GET",
|
|
90
|
+
errorContext: "Get Latest Version"
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Fully replaces a pacticipant's metadata.
|
|
96
|
+
*/
|
|
97
|
+
async updatePacticipant({
|
|
98
|
+
pacticipantName,
|
|
99
|
+
...body
|
|
100
|
+
}) {
|
|
101
|
+
return await this.http.fetch(
|
|
102
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}`,
|
|
103
|
+
{ method: "PUT", body, errorContext: "Update Pacticipant" }
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Partially updates a pacticipant's metadata.
|
|
108
|
+
*/
|
|
109
|
+
async patchPacticipant({
|
|
110
|
+
pacticipantName,
|
|
111
|
+
...body
|
|
112
|
+
}) {
|
|
113
|
+
return await this.http.fetch(
|
|
114
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}`,
|
|
115
|
+
{ method: "PATCH", body, errorContext: "Patch Pacticipant" }
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Updates metadata for a specific pacticipant version.
|
|
120
|
+
*/
|
|
121
|
+
async updateVersion({
|
|
122
|
+
pacticipantName,
|
|
123
|
+
versionNumber,
|
|
124
|
+
...body
|
|
125
|
+
}) {
|
|
126
|
+
return await this.http.fetch(
|
|
127
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}`,
|
|
128
|
+
{ method: "PUT", body, errorContext: "Update Version" }
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Retrieves all versions published from a specific branch of a pacticipant.
|
|
133
|
+
*/
|
|
134
|
+
async getBranchVersions({
|
|
135
|
+
pacticipantName,
|
|
136
|
+
branchName,
|
|
137
|
+
pageNumber,
|
|
138
|
+
pageSize
|
|
139
|
+
}) {
|
|
140
|
+
const queryParams = new URLSearchParams();
|
|
141
|
+
if (pageNumber) queryParams.set("page", String(pageNumber));
|
|
142
|
+
if (pageSize) queryParams.set("size", String(pageSize));
|
|
143
|
+
const qs = queryParams.toString();
|
|
144
|
+
return await this.http.fetch(
|
|
145
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/branches/${encodeURIComponent(branchName)}/versions${qs ? `?${qs}` : ""}`,
|
|
146
|
+
{ method: "GET", errorContext: "Get Branch Versions" }
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Registers a new pacticipant in the workspace.
|
|
151
|
+
*/
|
|
152
|
+
async createPacticipant({
|
|
153
|
+
...body
|
|
154
|
+
}) {
|
|
155
|
+
return await this.http.fetch(
|
|
156
|
+
`${this.http.baseUrl}/pacticipants`,
|
|
157
|
+
{
|
|
158
|
+
method: "POST",
|
|
159
|
+
body,
|
|
160
|
+
errorContext: "Create Pacticipant"
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Permanently removes a pacticipant and all its associated data.
|
|
166
|
+
*/
|
|
167
|
+
async deletePacticipant({
|
|
168
|
+
pacticipantName
|
|
169
|
+
}) {
|
|
170
|
+
return await this.http.fetch(
|
|
171
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}`,
|
|
172
|
+
{
|
|
173
|
+
method: "DELETE",
|
|
174
|
+
errorContext: "Delete Pacticipant"
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Retrieves metadata for a specific branch of a pacticipant.
|
|
180
|
+
*/
|
|
181
|
+
async getBranch({
|
|
182
|
+
pacticipantName,
|
|
183
|
+
branchName
|
|
184
|
+
}) {
|
|
185
|
+
return await this.http.fetch(
|
|
186
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/branches/${encodeURIComponent(branchName)}`,
|
|
187
|
+
{ method: "GET", errorContext: "Get Branch" }
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Deletes a branch and its version associations from a pacticipant.
|
|
192
|
+
*/
|
|
193
|
+
async deleteBranch({
|
|
194
|
+
pacticipantName,
|
|
195
|
+
branchName
|
|
196
|
+
}) {
|
|
197
|
+
return await this.http.fetch(
|
|
198
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/branches/${encodeURIComponent(branchName)}`,
|
|
199
|
+
{ method: "DELETE", errorContext: "Delete Branch" }
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Applies a label to a pacticipant.
|
|
204
|
+
*/
|
|
205
|
+
async addLabel({
|
|
206
|
+
pacticipantName,
|
|
207
|
+
labelName
|
|
208
|
+
}) {
|
|
209
|
+
return await this.http.fetch(
|
|
210
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/labels/${encodeURIComponent(labelName)}`,
|
|
211
|
+
{ method: "PUT", body: {}, errorContext: "Add Label" }
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Removes a label from a pacticipant.
|
|
216
|
+
*/
|
|
217
|
+
async removeLabel({
|
|
218
|
+
pacticipantName,
|
|
219
|
+
labelName
|
|
220
|
+
}) {
|
|
221
|
+
return await this.http.fetch(
|
|
222
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/labels/${encodeURIComponent(labelName)}`,
|
|
223
|
+
{ method: "DELETE", errorContext: "Remove Label" }
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Retrieves all labels across all pacticipants.
|
|
228
|
+
*/
|
|
229
|
+
async listLabels(params) {
|
|
230
|
+
const queryParams = new URLSearchParams();
|
|
231
|
+
if (params?.pageNumber) queryParams.set("page", String(params.pageNumber));
|
|
232
|
+
if (params?.pageSize) queryParams.set("size", String(params.pageSize));
|
|
233
|
+
const qs = queryParams.toString();
|
|
234
|
+
return await this.http.fetch(
|
|
235
|
+
`${this.http.baseUrl}/labels${qs ? `?${qs}` : ""}`,
|
|
236
|
+
{ method: "GET", errorContext: "List Labels" }
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Checks whether a specific label is applied to a pacticipant.
|
|
241
|
+
*/
|
|
242
|
+
async getPacticipantLabel({
|
|
243
|
+
pacticipantName,
|
|
244
|
+
labelName
|
|
245
|
+
}) {
|
|
246
|
+
return await this.http.fetch(
|
|
247
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/labels/${encodeURIComponent(labelName)}`,
|
|
248
|
+
{ method: "GET", errorContext: "Get Pacticipant Label" }
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Retrieves all pacticipants that have a specific label applied.
|
|
253
|
+
*/
|
|
254
|
+
async listPacticipantsByLabel({
|
|
255
|
+
labelName
|
|
256
|
+
}) {
|
|
257
|
+
return await this.http.fetch(
|
|
258
|
+
`${this.http.baseUrl}/pacticipants/label/${encodeURIComponent(labelName)}`,
|
|
259
|
+
{ method: "GET", errorContext: "List Pacticipants by Label" }
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
get handlers() {
|
|
263
|
+
return {
|
|
264
|
+
listPacticipants: this.listPacticipants.bind(this),
|
|
265
|
+
getPacticipant: this.getPacticipant.bind(this),
|
|
266
|
+
listBranches: this.listBranches.bind(this),
|
|
267
|
+
listVersions: this.listVersions.bind(this),
|
|
268
|
+
getVersion: this.getVersion.bind(this),
|
|
269
|
+
getLatestVersion: this.getLatestVersion.bind(this),
|
|
270
|
+
updatePacticipant: this.updatePacticipant.bind(this),
|
|
271
|
+
patchPacticipant: this.patchPacticipant.bind(this),
|
|
272
|
+
updateVersion: this.updateVersion.bind(this),
|
|
273
|
+
getBranchVersions: this.getBranchVersions.bind(this),
|
|
274
|
+
createPacticipant: this.createPacticipant.bind(this),
|
|
275
|
+
deletePacticipant: this.deletePacticipant.bind(this),
|
|
276
|
+
getBranch: this.getBranch.bind(this),
|
|
277
|
+
deleteBranch: this.deleteBranch.bind(this),
|
|
278
|
+
addLabel: this.addLabel.bind(this),
|
|
279
|
+
removeLabel: this.removeLabel.bind(this),
|
|
280
|
+
listLabels: this.listLabels.bind(this),
|
|
281
|
+
getPacticipantLabel: this.getPacticipantLabel.bind(this),
|
|
282
|
+
listPacticipantsByLabel: this.listPacticipantsByLabel.bind(this)
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
export {
|
|
287
|
+
PacticipantApi
|
|
288
|
+
};
|
|
@@ -1,90 +1,11 @@
|
|
|
1
|
-
import { executeSamplingOrPolyfill, isSamplingPolyfillResult } from "../../common/pollyfills.js";
|
|
2
|
-
import { ToolError } from "../../common/tools.js";
|
|
3
|
-
import { MatcherRecommendationInputSchema, EndpointMatcherSchema } from "./ai.js";
|
|
4
1
|
import { OADMatcherPrompt } from "./prompts.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
const regex = /```json[c5]?([\s\S]*?)```/i;
|
|
12
|
-
const match = regex.exec(response);
|
|
13
|
-
if (match) {
|
|
14
|
-
const jsonText = match[1].trim();
|
|
15
|
-
const parsed = JSON.parse(jsonText);
|
|
16
|
-
const matcherRecommendations = MatcherRecommendationInputSchema.parse(parsed);
|
|
17
|
-
return matcherRecommendations;
|
|
18
|
-
} else {
|
|
19
|
-
throw new ToolError(
|
|
20
|
-
"Unable to parse recommendations please provide OpenAPI matchers manually."
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async function getUserMatcherSelection(recommendations, getInput) {
|
|
25
|
-
if (isSamplingPolyfillResult(recommendations)) {
|
|
26
|
-
return recommendations;
|
|
27
|
-
}
|
|
28
|
-
const recommendationsMap = /* @__PURE__ */ new Map();
|
|
29
|
-
recommendations.forEach((rec, index) => {
|
|
30
|
-
recommendationsMap.set(`Recommendation ${index + 1}`, JSON.stringify(rec));
|
|
31
|
-
});
|
|
32
|
-
const result = await getInput({
|
|
33
|
-
message: `Select one of the generated matchers you would want to use
|
|
34
|
-
|
|
35
|
-
${recommendations.map(
|
|
36
|
-
(rec, index) => `
|
|
37
|
-
|
|
38
|
-
Recommendation ${index + 1}:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
${JSON.stringify(rec)}`
|
|
42
|
-
).join("\n\n")}`,
|
|
43
|
-
requestedSchema: {
|
|
44
|
-
type: "object",
|
|
45
|
-
properties: {
|
|
46
|
-
generatedMatchers: {
|
|
47
|
-
type: "string",
|
|
48
|
-
title: "Generated Matchers",
|
|
49
|
-
description: "Use the matchers generated for the OpenAPI document",
|
|
50
|
-
enum: recommendations.map(
|
|
51
|
-
(_, index) => `Recommendation ${index + 1}`
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
required: ["generatedMatchers"]
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
if (result.action === "accept") {
|
|
59
|
-
return EndpointMatcherSchema.parse(
|
|
60
|
-
JSON.parse(
|
|
61
|
-
recommendationsMap.get(result.content?.generatedMatchers) || ""
|
|
62
|
-
)
|
|
63
|
-
);
|
|
64
|
-
} else {
|
|
65
|
-
const result2 = await getInput({
|
|
66
|
-
message: "Enter the matchers you would want to use for the OpenAPI document",
|
|
67
|
-
requestedSchema: {
|
|
68
|
-
type: "object",
|
|
69
|
-
properties: {
|
|
70
|
-
enteredMatchers: {
|
|
71
|
-
type: "string",
|
|
72
|
-
title: "Enter the matchers you would want to use for the OpenAPI document",
|
|
73
|
-
description: "Enter the matchers you would want to use for the OpenAPI document"
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
required: ["enteredMatchers"]
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
if (result2.action === "accept") {
|
|
80
|
-
return EndpointMatcherSchema.parse(
|
|
81
|
-
JSON.parse(result2.content?.enteredMatchers)
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
return {};
|
|
85
|
-
}
|
|
2
|
+
function getOADMatcherRecommendations(openAPI) {
|
|
3
|
+
return {
|
|
4
|
+
requiresPromptExecution: true,
|
|
5
|
+
prompt: OADMatcherPrompt.replace("{0}", JSON.stringify(openAPI)),
|
|
6
|
+
instructions: "Please execute the above prompt using your AI capabilities and re-request this tool with the result. Include the prompt result in your next request to continue the operation."
|
|
7
|
+
};
|
|
86
8
|
}
|
|
87
9
|
export {
|
|
88
|
-
getOADMatcherRecommendations
|
|
89
|
-
getUserMatcherSelection
|
|
10
|
+
getOADMatcherRecommendations
|
|
90
11
|
};
|
|
@@ -46,36 +46,16 @@ const OADMatcherPromptOpenAPIDocExample = {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
const OADMatcherPromptRecommendationExample =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
path: "/users/*",
|
|
58
|
-
methods: ["GET"],
|
|
59
|
-
statusCodes: ["2XX"],
|
|
60
|
-
operationId: "*User*"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
path: "/users",
|
|
64
|
-
methods: ["GET"],
|
|
65
|
-
statusCodes: [200],
|
|
66
|
-
operationId: "getAllUsers"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
path: "/users/**",
|
|
70
|
-
methods: ["GET"],
|
|
71
|
-
statusCodes: ["2XX", 404],
|
|
72
|
-
operationId: "get*"
|
|
73
|
-
}
|
|
74
|
-
];
|
|
49
|
+
const OADMatcherPromptRecommendationExample = {
|
|
50
|
+
path: "/users",
|
|
51
|
+
methods: ["GET"],
|
|
52
|
+
statusCodes: [200],
|
|
53
|
+
operationId: "getAllUsers"
|
|
54
|
+
};
|
|
75
55
|
const OADMatcherPrompt = `
|
|
76
56
|
|
|
77
|
-
Generate a
|
|
78
|
-
Zod Schema for the matcher to be generated is provided below in the markdown block of javascript use this to generate the
|
|
57
|
+
Generate a single recommendation in JSON to use with an OpenAPI matcher.
|
|
58
|
+
Zod Schema for the matcher to be generated is provided below in the markdown block of javascript use this to generate the recommendation for the matcher. The recommendation should contain all the fields from the schema and only output the JSON in a markdown formatted block.
|
|
79
59
|
|
|
80
60
|
\`\`\`javascript
|
|
81
61
|
const EndpointMatcherSchema = ${JSON.stringify(EndpointMatcherSchema.toJSONSchema())};
|
|
@@ -89,7 +69,7 @@ if OpenAPI document provided is:-
|
|
|
89
69
|
${JSON.stringify(OADMatcherPromptOpenAPIDocExample, null, 2)}
|
|
90
70
|
\`\`\`
|
|
91
71
|
|
|
92
|
-
Generated
|
|
72
|
+
Generated recommendation is:-
|
|
93
73
|
|
|
94
74
|
\`\`\`json
|
|
95
75
|
${JSON.stringify(OADMatcherPromptRecommendationExample, null, 2)}
|
|
@@ -103,7 +83,7 @@ Now provided the below OpenAPI document:-
|
|
|
103
83
|
{0}
|
|
104
84
|
\`\`\`
|
|
105
85
|
|
|
106
|
-
Give JSON
|
|
86
|
+
Give the JSON recommendation only provide the JSON block in markdown don't include any additional text.
|
|
107
87
|
`;
|
|
108
88
|
const argsSchema = z.object({
|
|
109
89
|
openAPI: z.string().describe("The OpenAPI document to generate matcher recommendations for")
|
|
@@ -111,7 +91,7 @@ const argsSchema = z.object({
|
|
|
111
91
|
const PROMPTS = [
|
|
112
92
|
{
|
|
113
93
|
title: "OpenAPI Matcher recommendations",
|
|
114
|
-
description: "Get OpenAPI matcher
|
|
94
|
+
description: "Get an OpenAPI matcher recommendation",
|
|
115
95
|
argsSchema,
|
|
116
96
|
callback: (args) => {
|
|
117
97
|
const params = argsSchema.parse(args);
|
|
@@ -15,7 +15,6 @@ const TOOLS = [
|
|
|
15
15
|
openWorld: false,
|
|
16
16
|
clients: ["pactflow"],
|
|
17
17
|
// ONLY pactflow
|
|
18
|
-
enableElicitation: true,
|
|
19
18
|
tags: ["pactflow-ai"]
|
|
20
19
|
},
|
|
21
20
|
{
|
|
@@ -30,7 +29,6 @@ const TOOLS = [
|
|
|
30
29
|
idempotent: true,
|
|
31
30
|
openWorld: false,
|
|
32
31
|
clients: ["pactflow"],
|
|
33
|
-
enableElicitation: true,
|
|
34
32
|
tags: ["pactflow-ai"]
|
|
35
33
|
},
|
|
36
34
|
{
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
class WebhookApi {
|
|
2
|
+
constructor(http) {
|
|
3
|
+
this.http = http;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves all webhooks configured in the workspace.
|
|
7
|
+
*
|
|
8
|
+
* @returns List of webhook definitions and their trigger configurations.
|
|
9
|
+
* @throws ToolError if the request fails.
|
|
10
|
+
*/
|
|
11
|
+
async listWebhooks() {
|
|
12
|
+
return await this.http.fetch(
|
|
13
|
+
`${this.http.baseUrl}/webhooks`,
|
|
14
|
+
{ method: "GET", errorContext: "List Webhooks" }
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the configuration for a specific webhook by UUID.
|
|
19
|
+
*
|
|
20
|
+
* @param params - `webhookId`: UUID of the webhook.
|
|
21
|
+
* @returns Webhook definition including its URL, events, and consumer/provider filters.
|
|
22
|
+
* @throws ToolError if the webhook is not found or the request fails.
|
|
23
|
+
*/
|
|
24
|
+
async getWebhook({ webhookId }) {
|
|
25
|
+
return await this.http.fetch(
|
|
26
|
+
`${this.http.baseUrl}/webhooks/${encodeURIComponent(webhookId)}`,
|
|
27
|
+
{ method: "GET", errorContext: "Get Webhook" }
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new webhook triggered by pact publication or verification events.
|
|
32
|
+
*
|
|
33
|
+
* @param body - Webhook URL, HTTP method, headers, body, events, and optional
|
|
34
|
+
* consumer/provider filters.
|
|
35
|
+
* @returns The created webhook resource.
|
|
36
|
+
* @throws ToolError if the request fails.
|
|
37
|
+
*/
|
|
38
|
+
async createWebhook({
|
|
39
|
+
...body
|
|
40
|
+
}) {
|
|
41
|
+
return await this.http.fetch(
|
|
42
|
+
`${this.http.baseUrl}/webhooks`,
|
|
43
|
+
{ method: "POST", body, errorContext: "Create Webhook" }
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Replaces the configuration of an existing webhook.
|
|
48
|
+
*
|
|
49
|
+
* @param params - `webhookId` (UUID) plus the full updated webhook definition.
|
|
50
|
+
* @returns The updated webhook resource.
|
|
51
|
+
* @throws ToolError if the webhook is not found or the request fails.
|
|
52
|
+
*/
|
|
53
|
+
async updateWebhook({
|
|
54
|
+
webhookId,
|
|
55
|
+
...body
|
|
56
|
+
}) {
|
|
57
|
+
return await this.http.fetch(
|
|
58
|
+
`${this.http.baseUrl}/webhooks/${encodeURIComponent(webhookId)}`,
|
|
59
|
+
{ method: "PUT", body, errorContext: "Update Webhook" }
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Deletes a webhook by UUID.
|
|
64
|
+
*
|
|
65
|
+
* @param params - `webhookId`: UUID of the webhook to delete.
|
|
66
|
+
* @throws ToolError if the webhook is not found or the request fails.
|
|
67
|
+
*/
|
|
68
|
+
async deleteWebhook({ webhookId }) {
|
|
69
|
+
return await this.http.fetch(
|
|
70
|
+
`${this.http.baseUrl}/webhooks/${encodeURIComponent(webhookId)}`,
|
|
71
|
+
{ method: "DELETE", errorContext: "Delete Webhook" }
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Fires all webhooks in the workspace as a test, regardless of their trigger conditions.
|
|
76
|
+
*
|
|
77
|
+
* @throws ToolError if the request fails.
|
|
78
|
+
*/
|
|
79
|
+
async executeWebhooks() {
|
|
80
|
+
return await this.http.fetch(
|
|
81
|
+
`${this.http.baseUrl}/webhooks/execute`,
|
|
82
|
+
{ method: "POST", body: {}, errorContext: "Execute Webhooks" }
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Fires a specific webhook as a test, regardless of its trigger conditions.
|
|
87
|
+
*
|
|
88
|
+
* @param params - `webhookId`: UUID of the webhook to execute.
|
|
89
|
+
* @throws ToolError if the webhook is not found or the request fails.
|
|
90
|
+
*/
|
|
91
|
+
async executeWebhook({
|
|
92
|
+
webhookId
|
|
93
|
+
}) {
|
|
94
|
+
return await this.http.fetch(
|
|
95
|
+
`${this.http.baseUrl}/webhooks/${encodeURIComponent(webhookId)}/execute`,
|
|
96
|
+
{ method: "POST", body: {}, errorContext: "Execute Webhook" }
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
get handlers() {
|
|
100
|
+
return {
|
|
101
|
+
listWebhooks: this.listWebhooks.bind(this),
|
|
102
|
+
getWebhook: this.getWebhook.bind(this),
|
|
103
|
+
createWebhook: this.createWebhook.bind(this),
|
|
104
|
+
updateWebhook: this.updateWebhook.bind(this),
|
|
105
|
+
deleteWebhook: this.deleteWebhook.bind(this),
|
|
106
|
+
executeWebhooks: this.executeWebhooks.bind(this),
|
|
107
|
+
executeWebhook: this.executeWebhook.bind(this)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export {
|
|
112
|
+
WebhookApi
|
|
113
|
+
};
|