@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
package/dist/pactflow/client.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import zod__default from "zod";
|
|
2
2
|
import { getUserAgent } from "../common/info.js";
|
|
3
|
-
import { isSamplingPolyfillResult } from "../common/pollyfills.js";
|
|
4
3
|
import { getRequestHeader } from "../common/request-context.js";
|
|
5
4
|
import { ToolError } from "../common/tools.js";
|
|
5
|
+
import { AdminApi } from "./client/admin-api.js";
|
|
6
|
+
import { AIApi } from "./client/ai-api.js";
|
|
7
|
+
import { ContractApi } from "./client/contract-api.js";
|
|
8
|
+
import { EnvironmentApi } from "./client/environment-api.js";
|
|
9
|
+
import { HttpClient } from "./client/http-client.js";
|
|
10
|
+
import { PacticipantApi } from "./client/pacticipant-api.js";
|
|
6
11
|
import { withPagination } from "./client/pagination.js";
|
|
7
|
-
import { getOADMatcherRecommendations, getUserMatcherSelection } from "./client/prompt-utils.js";
|
|
8
12
|
import { PROMPTS } from "./client/prompts.js";
|
|
9
13
|
import { TOOLS } from "./client/tools.js";
|
|
14
|
+
import { WebhookApi } from "./client/webhook-api.js";
|
|
10
15
|
const ConfigurationSchema = zod__default.object({
|
|
11
16
|
base_url: zod__default.url().describe("Pact Broker or PactFlow base URL"),
|
|
12
17
|
token: zod__default.string().optional().describe(
|
|
@@ -23,24 +28,15 @@ class PactflowClient {
|
|
|
23
28
|
token;
|
|
24
29
|
username;
|
|
25
30
|
password;
|
|
26
|
-
aiBaseUrl;
|
|
27
|
-
baseUrl;
|
|
28
31
|
_clientType;
|
|
29
32
|
_server;
|
|
30
33
|
cache;
|
|
31
|
-
|
|
34
|
+
http;
|
|
35
|
+
handlerMap;
|
|
32
36
|
get server() {
|
|
33
37
|
if (!this._server) throw new Error("Server not configured");
|
|
34
38
|
return this._server;
|
|
35
39
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Initialises the client with auth credentials and the MCP server reference.
|
|
38
|
-
* Accepts either a Bearer token (PactFlow) or username/password (Pact Broker).
|
|
39
|
-
* Does nothing if neither is supplied.
|
|
40
|
-
*
|
|
41
|
-
* @param server - The MCP server instance to bind to.
|
|
42
|
-
* @param config - Connection config (base_url + token OR username/password).
|
|
43
|
-
*/
|
|
44
40
|
async configure(server, config) {
|
|
45
41
|
this.token = config.token;
|
|
46
42
|
this.username = config.username;
|
|
@@ -52,122 +48,23 @@ class PactflowClient {
|
|
|
52
48
|
} else {
|
|
53
49
|
this._clientType = "pactflow";
|
|
54
50
|
}
|
|
55
|
-
this.baseUrl = config.base_url;
|
|
56
|
-
this.aiBaseUrl = `${this.baseUrl}/api/ai`;
|
|
57
51
|
this._server = server;
|
|
58
52
|
this.cache = server.getCache();
|
|
53
|
+
this.http = new HttpClient(config.base_url, () => this.requestHeaders);
|
|
54
|
+
const aiBaseUrl = `${config.base_url}/api/ai`;
|
|
55
|
+
this.handlerMap = {
|
|
56
|
+
...new PacticipantApi(this.http).handlers,
|
|
57
|
+
...new EnvironmentApi(this.http).handlers,
|
|
58
|
+
...new ContractApi(this.http).handlers,
|
|
59
|
+
...new WebhookApi(this.http).handlers,
|
|
60
|
+
...new AdminApi(this.http).handlers,
|
|
61
|
+
...new AIApi(this.http, aiBaseUrl).handlers
|
|
62
|
+
};
|
|
63
|
+
Object.assign(this, this.handlerMap);
|
|
59
64
|
}
|
|
60
|
-
/** Returns true if the client has been configured with a base URL and credentials. */
|
|
61
65
|
isConfigured() {
|
|
62
|
-
return this.
|
|
63
|
-
}
|
|
64
|
-
// PactFlow AI client methods
|
|
65
|
-
/**
|
|
66
|
-
* Generate new Pact tests based on the provided input.
|
|
67
|
-
*
|
|
68
|
-
* @param toolInput The input data for the generation process.
|
|
69
|
-
* @param getInput Function to get additional input from the user if needed.
|
|
70
|
-
* @returns The result of the generation process or a polyfill result requiring prompt execution.
|
|
71
|
-
* @throws Error if the HTTP request fails or the operation times out.
|
|
72
|
-
*/
|
|
73
|
-
async generate(toolInput, getInput) {
|
|
74
|
-
if (toolInput.openapi?.document && (!toolInput.openapi?.matcher || Object.keys(toolInput.openapi.matcher).length === 0)) {
|
|
75
|
-
const matcherResponse = await getOADMatcherRecommendations(
|
|
76
|
-
toolInput.openapi.document,
|
|
77
|
-
this.server
|
|
78
|
-
);
|
|
79
|
-
if (isSamplingPolyfillResult(matcherResponse)) {
|
|
80
|
-
return matcherResponse;
|
|
81
|
-
}
|
|
82
|
-
const userSelection = await getUserMatcherSelection(
|
|
83
|
-
matcherResponse,
|
|
84
|
-
getInput
|
|
85
|
-
);
|
|
86
|
-
if (isSamplingPolyfillResult(userSelection)) {
|
|
87
|
-
return userSelection;
|
|
88
|
-
}
|
|
89
|
-
toolInput.openapi.matcher = userSelection;
|
|
90
|
-
}
|
|
91
|
-
const status_response = await this.submitHttpCallback(
|
|
92
|
-
"/generate",
|
|
93
|
-
toolInput
|
|
94
|
-
);
|
|
95
|
-
return await this.pollForCompletion(
|
|
96
|
-
status_response,
|
|
97
|
-
"Generation"
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Review the provided Pact tests and suggest improvements.
|
|
102
|
-
*
|
|
103
|
-
* @param toolInput The input data for the review process.
|
|
104
|
-
* @param getInput Function to get additional input from the user if needed.
|
|
105
|
-
* @returns The result of the review process or a polyfill result requiring prompt execution.
|
|
106
|
-
* @throws Error if the HTTP request fails or the operation times out.
|
|
107
|
-
*/
|
|
108
|
-
async review(toolInput, getInput) {
|
|
109
|
-
if (toolInput.openapi?.document && (!toolInput.openapi?.matcher || Object.keys(toolInput.openapi.matcher).length === 0)) {
|
|
110
|
-
const matcherResponse = await getOADMatcherRecommendations(
|
|
111
|
-
toolInput.openapi.document,
|
|
112
|
-
this.server
|
|
113
|
-
);
|
|
114
|
-
if (isSamplingPolyfillResult(matcherResponse)) {
|
|
115
|
-
return matcherResponse;
|
|
116
|
-
}
|
|
117
|
-
const userSelection = await getUserMatcherSelection(
|
|
118
|
-
matcherResponse,
|
|
119
|
-
getInput
|
|
120
|
-
);
|
|
121
|
-
if (isSamplingPolyfillResult(userSelection)) {
|
|
122
|
-
return userSelection;
|
|
123
|
-
}
|
|
124
|
-
toolInput.openapi.matcher = userSelection;
|
|
125
|
-
}
|
|
126
|
-
const status_response = await this.submitHttpCallback("/review", toolInput);
|
|
127
|
-
return await this.pollForCompletion(
|
|
128
|
-
status_response,
|
|
129
|
-
"Review Pacts"
|
|
130
|
-
);
|
|
66
|
+
return this.http !== void 0;
|
|
131
67
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Retrieve PactFlow AI entitlement information for the current user
|
|
134
|
-
* and organization when encountering 401 unauthorized errors.
|
|
135
|
-
* Use this to check AI entitlements and credits when AI operations fail.
|
|
136
|
-
*
|
|
137
|
-
* @returns Entitlement containing permissions, organization
|
|
138
|
-
* entitlements, and user entitlements.
|
|
139
|
-
* @throws Error if the request fails or returns a non-OK response.
|
|
140
|
-
*/
|
|
141
|
-
async checkAIEntitlements() {
|
|
142
|
-
if (this.aiBaseUrl) {
|
|
143
|
-
return await this.fetchJson(
|
|
144
|
-
`${this.aiBaseUrl}/entitlement`,
|
|
145
|
-
{
|
|
146
|
-
method: "GET",
|
|
147
|
-
errorContext: "PactFlow AI Entitlements Request"
|
|
148
|
-
}
|
|
149
|
-
);
|
|
150
|
-
} else {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Polls the given status URL with a HEAD request to check operation progress.
|
|
156
|
-
*
|
|
157
|
-
* @param statusUrl - The URL returned by the async AI operation.
|
|
158
|
-
* @returns HTTP status code and whether the operation has completed (status 200).
|
|
159
|
-
*/
|
|
160
|
-
async getStatus(statusUrl) {
|
|
161
|
-
const response = await fetch(statusUrl, {
|
|
162
|
-
method: "HEAD",
|
|
163
|
-
headers: this.requestHeaders
|
|
164
|
-
});
|
|
165
|
-
return {
|
|
166
|
-
status: response.status,
|
|
167
|
-
isComplete: response.status === 200
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
/** Returns the current auth/content-type headers used for all requests. */
|
|
171
68
|
get requestHeaders() {
|
|
172
69
|
let contextToken = getRequestHeader("Pact-Token") || getRequestHeader("Authorization");
|
|
173
70
|
if (Array.isArray(contextToken)) {
|
|
@@ -204,1872 +101,11 @@ class PactflowClient {
|
|
|
204
101
|
}
|
|
205
102
|
return void 0;
|
|
206
103
|
}
|
|
207
|
-
/**
|
|
208
|
-
* Fetches the final result of a completed async operation.
|
|
209
|
-
*
|
|
210
|
-
* @param resultUrl - The result URL returned by the async AI operation.
|
|
211
|
-
* @returns The parsed JSON result of type T.
|
|
212
|
-
* @throws ToolError if the response is not OK.
|
|
213
|
-
*/
|
|
214
|
-
async getResult(resultUrl) {
|
|
215
|
-
const response = await fetch(resultUrl, {
|
|
216
|
-
method: "GET",
|
|
217
|
-
headers: this.requestHeaders
|
|
218
|
-
});
|
|
219
|
-
if (!response.ok) {
|
|
220
|
-
throw new ToolError(`HTTP error! status: ${response.status}`);
|
|
221
|
-
}
|
|
222
|
-
return response.json();
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Polls status_url every second until the operation completes or times out (120s).
|
|
226
|
-
*
|
|
227
|
-
* @param status_response - URLs returned by the initial async submission.
|
|
228
|
-
* @param operationName - Human-readable name used in error messages.
|
|
229
|
-
* @returns The parsed result of type T on success.
|
|
230
|
-
* @throws ToolError on non-202 status or timeout.
|
|
231
|
-
*/
|
|
232
|
-
async pollForCompletion(status_response, operationName) {
|
|
233
|
-
const startTime = Date.now();
|
|
234
|
-
const timeout = 12e4;
|
|
235
|
-
const pollInterval = 1e3;
|
|
236
|
-
while (Date.now() - startTime < timeout) {
|
|
237
|
-
const statusCheck = await this.getStatus(status_response.status_url);
|
|
238
|
-
if (statusCheck.isComplete) {
|
|
239
|
-
return await this.getResult(status_response.result_url);
|
|
240
|
-
}
|
|
241
|
-
if (statusCheck.status !== 202) {
|
|
242
|
-
throw new ToolError(
|
|
243
|
-
`${operationName} failed with status: ${statusCheck.status}`
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
247
|
-
}
|
|
248
|
-
throw new ToolError(
|
|
249
|
-
`${operationName} timed out after ${timeout / 1e3} seconds`
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Helper method to fetch JSON data from an API endpoint.
|
|
254
|
-
*
|
|
255
|
-
* @param url The full URL to fetch from.
|
|
256
|
-
* @param options Options including method, body, and error context.
|
|
257
|
-
* @returns The parsed JSON response.
|
|
258
|
-
* @throws ToolError if the request fails.
|
|
259
|
-
*/
|
|
260
|
-
async fetchJson(url, options) {
|
|
261
|
-
const { method, body, errorContext = "Request" } = options;
|
|
262
|
-
try {
|
|
263
|
-
const response = await fetch(url, {
|
|
264
|
-
method,
|
|
265
|
-
headers: this.requestHeaders,
|
|
266
|
-
...body && { body: JSON.stringify(body) }
|
|
267
|
-
});
|
|
268
|
-
if (!response.ok) {
|
|
269
|
-
const errorText = await response.text().catch(() => "");
|
|
270
|
-
throw new ToolError(
|
|
271
|
-
`${errorContext} Failed - status: ${response.status} ${response.statusText}${errorText ? ` - ${errorText}` : ""}`,
|
|
272
|
-
void 0,
|
|
273
|
-
/* @__PURE__ */ new Map([["responseStatus", response.status]])
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
if (response.status === 204) {
|
|
277
|
-
return void 0;
|
|
278
|
-
}
|
|
279
|
-
return await response.json();
|
|
280
|
-
} catch (error) {
|
|
281
|
-
if (error instanceof ToolError) {
|
|
282
|
-
throw error;
|
|
283
|
-
}
|
|
284
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
285
|
-
console.error(`[${errorContext}] Unexpected error: ${error}
|
|
286
|
-
`);
|
|
287
|
-
throw new ToolError(
|
|
288
|
-
`${errorContext} Failed - ${errorMessage}`,
|
|
289
|
-
void 0,
|
|
290
|
-
/* @__PURE__ */ new Map([["responseStatus", 500]])
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Submits an HTTP callback request to the PactFlow AI API.
|
|
296
|
-
* @param endpoint The AI API endpoint (relative to aiBaseUrl), e.g., '/generate' or '/review'.
|
|
297
|
-
* @param body The request body specific to the AI operation.
|
|
298
|
-
* @returns StatusResponse with status_url for polling and result_url for fetching results.
|
|
299
|
-
* @throws ToolError if the request fails.
|
|
300
|
-
*/
|
|
301
|
-
async submitHttpCallback(endpoint, body) {
|
|
302
|
-
return await this.fetchJson(
|
|
303
|
-
`${this.aiBaseUrl}${endpoint}`,
|
|
304
|
-
{
|
|
305
|
-
method: "POST",
|
|
306
|
-
body,
|
|
307
|
-
errorContext: `HTTP callback submission to ${endpoint}`
|
|
308
|
-
}
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
// PactFlow / Pact_Broker client methods
|
|
312
|
-
/**
|
|
313
|
-
* Retrieves all provider states declared by a provider's pact tests.
|
|
314
|
-
*
|
|
315
|
-
* @param params - `provider`: The name of the provider.
|
|
316
|
-
* @returns List of provider state strings the provider supports.
|
|
317
|
-
* @throws ToolError if the request fails.
|
|
318
|
-
*/
|
|
319
|
-
async getProviderStates({
|
|
320
|
-
provider
|
|
321
|
-
}) {
|
|
322
|
-
const uri_encoded_provider_name = encodeURIComponent(provider);
|
|
323
|
-
return await this.fetchJson(
|
|
324
|
-
`${this.baseUrl}/pacts/provider/${uri_encoded_provider_name}/provider-states`,
|
|
325
|
-
{
|
|
326
|
-
method: "GET",
|
|
327
|
-
errorContext: "Get Provider States"
|
|
328
|
-
}
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Checks if a given pacticipant version is safe to deploy
|
|
333
|
-
* to a specified environment.
|
|
334
|
-
*
|
|
335
|
-
* @param body - Input containing:
|
|
336
|
-
* - `pacticipant`: The name of the service (pacticipant).
|
|
337
|
-
* - `version`: The version of the pacticipant being evaluated for deployment.
|
|
338
|
-
* - `environment`: The target environment (e.g., staging, production).
|
|
339
|
-
* @returns CanIDeployResponse containing deployment decision and verification results.
|
|
340
|
-
* @throws Error if the request fails or returns a non-OK response.
|
|
341
|
-
*/
|
|
342
|
-
async canIDeploy(body) {
|
|
343
|
-
const { pacticipant, version, environment } = body;
|
|
344
|
-
const queryParams = new URLSearchParams({
|
|
345
|
-
pacticipant,
|
|
346
|
-
version,
|
|
347
|
-
environment
|
|
348
|
-
});
|
|
349
|
-
const url = `${this.baseUrl}/can-i-deploy?${queryParams.toString()}`;
|
|
350
|
-
return await this.fetchJson(url, {
|
|
351
|
-
method: "GET",
|
|
352
|
-
errorContext: "Can-I-Deploy Request"
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Retrieves the matrix of pact verification results for the specified pacticipants.
|
|
357
|
-
* This allows you to see which consumer/provider combinations have been verified
|
|
358
|
-
* and make deployment decisions based on contract test results.
|
|
359
|
-
*
|
|
360
|
-
* @param body - Matrix query parameters including pacticipants, versions, environments, etc.
|
|
361
|
-
* @returns MatrixResponse containing the verification matrix, notices, and summary
|
|
362
|
-
* @throws Error if the request fails or returns a non-OK response
|
|
363
|
-
*/
|
|
364
|
-
async getMatrix(body) {
|
|
365
|
-
const { q, latestby, limit } = body;
|
|
366
|
-
const queryParts = [];
|
|
367
|
-
if (latestby) {
|
|
368
|
-
queryParts.push(`latestby=${encodeURIComponent(latestby)}`);
|
|
369
|
-
}
|
|
370
|
-
if (limit !== void 0) {
|
|
371
|
-
queryParts.push(`limit=${limit}`);
|
|
372
|
-
}
|
|
373
|
-
q.forEach((selector) => {
|
|
374
|
-
queryParts.push(
|
|
375
|
-
`q[]pacticipant=${encodeURIComponent(selector.pacticipant)}`
|
|
376
|
-
);
|
|
377
|
-
if (selector.version) {
|
|
378
|
-
queryParts.push(`q[]version=${encodeURIComponent(selector.version)}`);
|
|
379
|
-
}
|
|
380
|
-
if (selector.branch) {
|
|
381
|
-
queryParts.push(`q[]branch=${encodeURIComponent(selector.branch)}`);
|
|
382
|
-
}
|
|
383
|
-
if (selector.environment) {
|
|
384
|
-
queryParts.push(
|
|
385
|
-
`q[]environment=${encodeURIComponent(selector.environment)}`
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
if (selector.latest !== void 0) {
|
|
389
|
-
queryParts.push(`q[]latest=${selector.latest}`);
|
|
390
|
-
}
|
|
391
|
-
if (selector.tag) {
|
|
392
|
-
queryParts.push(`q[]tag=${encodeURIComponent(selector.tag)}`);
|
|
393
|
-
}
|
|
394
|
-
if (selector.mainBranch !== void 0) {
|
|
395
|
-
queryParts.push(`q[]mainBranch=${selector.mainBranch}`);
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
const url = `${this.baseUrl}/matrix?${queryParts.join("&")}`;
|
|
399
|
-
return await this.fetchJson(url, {
|
|
400
|
-
method: "GET",
|
|
401
|
-
errorContext: "Matrix Request"
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Retrieves metrics across the workspace.
|
|
406
|
-
*
|
|
407
|
-
* @returns MetricsResponse containing workspace-wide metrics
|
|
408
|
-
* @throws Error if the request fails or returns a non-OK response
|
|
409
|
-
*/
|
|
410
|
-
async getMetrics() {
|
|
411
|
-
const url = `${this.baseUrl}/metrics`;
|
|
412
|
-
try {
|
|
413
|
-
const response = await fetch(url, {
|
|
414
|
-
method: "GET",
|
|
415
|
-
headers: this.requestHeaders
|
|
416
|
-
});
|
|
417
|
-
if (!response.ok) {
|
|
418
|
-
const errorText = await response.text().catch(() => "");
|
|
419
|
-
throw new ToolError(
|
|
420
|
-
`Metrics Request Failed - status: ${response.status} ${response.statusText}${errorText ? ` - ${errorText}` : ""}`
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
return await response.json();
|
|
424
|
-
} catch (error) {
|
|
425
|
-
console.error("[GetMetrics] Unexpected error:", error);
|
|
426
|
-
throw error;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Retrieves metrics for all teams.
|
|
431
|
-
*
|
|
432
|
-
* @returns TeamMetricsResponse containing metrics for all teams
|
|
433
|
-
* @throws Error if the request fails or returns a non-OK response
|
|
434
|
-
*/
|
|
435
|
-
async getTeamMetrics() {
|
|
436
|
-
const url = `${this.baseUrl}/metrics/teams`;
|
|
437
|
-
try {
|
|
438
|
-
const response = await fetch(url, {
|
|
439
|
-
method: "GET",
|
|
440
|
-
headers: this.requestHeaders
|
|
441
|
-
});
|
|
442
|
-
if (!response.ok) {
|
|
443
|
-
const errorText = await response.text().catch(() => "");
|
|
444
|
-
throw new ToolError(
|
|
445
|
-
`Team Metrics Request Failed - status: ${response.status} ${response.statusText}${errorText ? ` - ${errorText}` : ""}`
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
return await response.json();
|
|
449
|
-
} catch (error) {
|
|
450
|
-
console.error("[GetTeamMetrics] Unexpected error:", error);
|
|
451
|
-
throw error;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Retrieves all pacticipants (applications/services) registered in the workspace,
|
|
456
|
-
* with optional pagination.
|
|
457
|
-
*
|
|
458
|
-
* @param params - Optional pagination parameters (`pageNumber`, `pageSize`).
|
|
459
|
-
* @returns List of pacticipants with their metadata.
|
|
460
|
-
* @throws ToolError if the request fails.
|
|
461
|
-
*/
|
|
462
|
-
async listPacticipants(params) {
|
|
463
|
-
const queryParams = new URLSearchParams();
|
|
464
|
-
if (params?.pageNumber) queryParams.set("page", String(params.pageNumber));
|
|
465
|
-
if (params?.pageSize) queryParams.set("size", String(params.pageSize));
|
|
466
|
-
const qs = queryParams.toString();
|
|
467
|
-
return await this.fetchJson(
|
|
468
|
-
`${this.baseUrl}/pacticipants${qs ? `?${qs}` : ""}`,
|
|
469
|
-
{ method: "GET", errorContext: "List Pacticipants" }
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Retrieves metadata for a specific pacticipant by name.
|
|
474
|
-
*
|
|
475
|
-
* @param params - `pacticipantName`: The name of the pacticipant to fetch.
|
|
476
|
-
* @returns Pacticipant metadata including display name, main branch, and repository URL.
|
|
477
|
-
* @throws ToolError if the pacticipant is not found or the request fails.
|
|
478
|
-
*/
|
|
479
|
-
async getPacticipant({ pacticipantName }) {
|
|
480
|
-
return await this.fetchJson(
|
|
481
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}`,
|
|
482
|
-
{ method: "GET", errorContext: "Get Pacticipant" }
|
|
483
|
-
);
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Retrieves all branches for a given pacticipant, with optional name filtering
|
|
487
|
-
* and pagination.
|
|
488
|
-
*
|
|
489
|
-
* @param params - `pacticipantName`, optional `q` (name filter), `pageNumber`, `pageSize`.
|
|
490
|
-
* @returns List of branches for the pacticipant.
|
|
491
|
-
* @throws ToolError if the request fails.
|
|
492
|
-
*/
|
|
493
|
-
async listBranches({
|
|
494
|
-
pacticipantName,
|
|
495
|
-
q,
|
|
496
|
-
pageNumber,
|
|
497
|
-
pageSize
|
|
498
|
-
}) {
|
|
499
|
-
const queryParams = new URLSearchParams();
|
|
500
|
-
if (q) queryParams.set("q", q);
|
|
501
|
-
if (pageNumber) queryParams.set("pageNumber", String(pageNumber));
|
|
502
|
-
if (pageSize) queryParams.set("pageSize", String(pageSize));
|
|
503
|
-
const qs = queryParams.toString();
|
|
504
|
-
return await this.fetchJson(
|
|
505
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/branches${qs ? `?${qs}` : ""}`,
|
|
506
|
-
{ method: "GET", errorContext: "List Branches" }
|
|
507
|
-
);
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Retrieves all published versions for a given pacticipant, with optional pagination.
|
|
511
|
-
*
|
|
512
|
-
* @param params - `pacticipantName`, optional `pageNumber` and `pageSize`.
|
|
513
|
-
* @returns List of versions with their branch and tag associations.
|
|
514
|
-
* @throws ToolError if the request fails.
|
|
515
|
-
*/
|
|
516
|
-
async listVersions({
|
|
517
|
-
pacticipantName,
|
|
518
|
-
pageNumber,
|
|
519
|
-
pageSize
|
|
520
|
-
}) {
|
|
521
|
-
const queryParams = new URLSearchParams();
|
|
522
|
-
if (pageNumber) queryParams.set("page", String(pageNumber));
|
|
523
|
-
if (pageSize) queryParams.set("size", String(pageSize));
|
|
524
|
-
const qs = queryParams.toString();
|
|
525
|
-
return await this.fetchJson(
|
|
526
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions${qs ? `?${qs}` : ""}`,
|
|
527
|
-
{ method: "GET", errorContext: "List Versions" }
|
|
528
|
-
);
|
|
529
|
-
}
|
|
530
|
-
/**
|
|
531
|
-
* Retrieves metadata for a specific version of a pacticipant.
|
|
532
|
-
*
|
|
533
|
-
* @param params - `pacticipantName` and `versionNumber` to retrieve.
|
|
534
|
-
* @returns Version metadata including branches, tags, and build URL.
|
|
535
|
-
* @throws ToolError if the version is not found or the request fails.
|
|
536
|
-
*/
|
|
537
|
-
async getVersion({
|
|
538
|
-
pacticipantName,
|
|
539
|
-
versionNumber
|
|
540
|
-
}) {
|
|
541
|
-
return await this.fetchJson(
|
|
542
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}`,
|
|
543
|
-
{ method: "GET", errorContext: "Get Version" }
|
|
544
|
-
);
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Retrieves the latest version of a pacticipant, optionally filtered by tag.
|
|
548
|
-
*
|
|
549
|
-
* @param params - `pacticipantName` and optional `tag` to filter by.
|
|
550
|
-
* @returns The latest matching version.
|
|
551
|
-
* @throws ToolError if the request fails.
|
|
552
|
-
*/
|
|
553
|
-
async getLatestVersion({
|
|
554
|
-
pacticipantName,
|
|
555
|
-
tag
|
|
556
|
-
}) {
|
|
557
|
-
const path = tag ? `/pacticipants/${encodeURIComponent(pacticipantName)}/latest-version/${encodeURIComponent(tag)}` : `/pacticipants/${encodeURIComponent(pacticipantName)}/latest-version`;
|
|
558
|
-
return await this.fetchJson(`${this.baseUrl}${path}`, {
|
|
559
|
-
method: "GET",
|
|
560
|
-
errorContext: "Get Latest Version"
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
/**
|
|
564
|
-
* Retrieves all environments configured in the workspace.
|
|
565
|
-
*
|
|
566
|
-
* @returns List of environments with their UUIDs, names, and production flags.
|
|
567
|
-
* @throws ToolError if the request fails.
|
|
568
|
-
*/
|
|
569
|
-
async listEnvironments() {
|
|
570
|
-
return await this.fetchJson(`${this.baseUrl}/environments`, {
|
|
571
|
-
method: "GET",
|
|
572
|
-
errorContext: "List Environments"
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Retrieves metadata for a specific environment by UUID.
|
|
577
|
-
*
|
|
578
|
-
* @param params - `environmentId`: The UUID of the environment.
|
|
579
|
-
* @returns Environment metadata including name, display name, and production flag.
|
|
580
|
-
* @throws ToolError if the environment is not found or the request fails.
|
|
581
|
-
*/
|
|
582
|
-
async getEnvironment({ environmentId }) {
|
|
583
|
-
return await this.fetchJson(
|
|
584
|
-
`${this.baseUrl}/environments/${encodeURIComponent(environmentId)}`,
|
|
585
|
-
{ method: "GET", errorContext: "Get Environment" }
|
|
586
|
-
);
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* Records that a specific version of a pacticipant has been deployed to an environment.
|
|
590
|
-
*
|
|
591
|
-
* @param params - `pacticipantName`, `versionNumber`, `environmentId`, and optional
|
|
592
|
-
* `applicationInstance` (for blue/green or multi-instance deployments).
|
|
593
|
-
* @returns The created deployment record.
|
|
594
|
-
* @throws ToolError if the request fails.
|
|
595
|
-
*/
|
|
596
|
-
async recordDeployment({
|
|
597
|
-
pacticipantName,
|
|
598
|
-
versionNumber,
|
|
599
|
-
environmentId,
|
|
600
|
-
applicationInstance
|
|
601
|
-
}) {
|
|
602
|
-
return await this.fetchJson(
|
|
603
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}/deployed-versions/environment/${encodeURIComponent(environmentId)}`,
|
|
604
|
-
{
|
|
605
|
-
method: "POST",
|
|
606
|
-
body: applicationInstance ? { applicationInstance } : {},
|
|
607
|
-
errorContext: "Record Deployment"
|
|
608
|
-
}
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
/**
|
|
612
|
-
* Retrieves all versions currently deployed to a given environment.
|
|
613
|
-
*
|
|
614
|
-
* @param params - `environmentId`: The UUID of the environment to query.
|
|
615
|
-
* @returns List of currently deployed versions across all pacticipants.
|
|
616
|
-
* @throws ToolError if the request fails.
|
|
617
|
-
*/
|
|
618
|
-
async getCurrentlyDeployed({
|
|
619
|
-
environmentId
|
|
620
|
-
}) {
|
|
621
|
-
return await this.fetchJson(
|
|
622
|
-
`${this.baseUrl}/environments/${encodeURIComponent(environmentId)}/deployed-versions/currently-deployed`,
|
|
623
|
-
{ method: "GET", errorContext: "Get Currently Deployed" }
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* Records that a version of a pacticipant has been released to an environment.
|
|
628
|
-
* Used for mobile/library workflows where multiple versions coexist simultaneously.
|
|
629
|
-
*
|
|
630
|
-
* @param params - `pacticipantName`, `versionNumber`, and `environmentId`.
|
|
631
|
-
* @returns The created release record.
|
|
632
|
-
* @throws ToolError if the request fails.
|
|
633
|
-
*/
|
|
634
|
-
async recordRelease({
|
|
635
|
-
pacticipantName,
|
|
636
|
-
versionNumber,
|
|
637
|
-
environmentId
|
|
638
|
-
}) {
|
|
639
|
-
return await this.fetchJson(
|
|
640
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}/released-versions/environment/${encodeURIComponent(environmentId)}`,
|
|
641
|
-
{ method: "POST", body: {}, errorContext: "Record Release" }
|
|
642
|
-
);
|
|
643
|
-
}
|
|
644
|
-
/**
|
|
645
|
-
* Retrieves all versions currently released and supported in a given environment.
|
|
646
|
-
*
|
|
647
|
-
* @param params - `environmentId`: The UUID of the environment to query.
|
|
648
|
-
* @returns List of currently supported released versions.
|
|
649
|
-
* @throws ToolError if the request fails.
|
|
650
|
-
*/
|
|
651
|
-
async getCurrentlySupported({
|
|
652
|
-
environmentId
|
|
653
|
-
}) {
|
|
654
|
-
return await this.fetchJson(
|
|
655
|
-
`${this.baseUrl}/environments/${encodeURIComponent(environmentId)}/released-versions/currently-supported`,
|
|
656
|
-
{ method: "GET", errorContext: "Get Currently Supported" }
|
|
657
|
-
);
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* Publishes one or more consumer Pact contracts to the Pact Broker or PactFlow.
|
|
661
|
-
*
|
|
662
|
-
* @param body - Consumer name, version number, contract files (base64-encoded),
|
|
663
|
-
* and optional branch/tag metadata.
|
|
664
|
-
* @returns Publication result including the pacticipant version number.
|
|
665
|
-
* @throws ToolError if the request fails.
|
|
666
|
-
*/
|
|
667
|
-
async publishContracts(body) {
|
|
668
|
-
return await this.fetchJson(`${this.baseUrl}/contracts/publish`, {
|
|
669
|
-
method: "POST",
|
|
670
|
-
body,
|
|
671
|
-
errorContext: "Publish Consumer Contracts"
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* Publishes a provider OpenAPI or AsyncAPI contract and its self-verification results
|
|
676
|
-
* to PactFlow for use in Bi-Directional Contract Testing.
|
|
677
|
-
*
|
|
678
|
-
* @param params - `providerName`, version number, base64-encoded OpenAPI/AsyncAPI spec,
|
|
679
|
-
* content type, and self-verification results.
|
|
680
|
-
* @returns Publication result.
|
|
681
|
-
* @throws ToolError if the request fails.
|
|
682
|
-
*/
|
|
683
|
-
async publishProviderContract({
|
|
684
|
-
providerName,
|
|
685
|
-
...body
|
|
686
|
-
}) {
|
|
687
|
-
return await this.fetchJson(
|
|
688
|
-
`${this.baseUrl}/provider-contracts/provider/${encodeURIComponent(providerName)}/publish`,
|
|
689
|
-
{ method: "POST", body, errorContext: "Publish Provider Contract" }
|
|
690
|
-
);
|
|
691
|
-
}
|
|
692
|
-
/**
|
|
693
|
-
* Retrieves the set of consumer pacts a provider should verify in its current CI run,
|
|
694
|
-
* based on consumer version selectors and WIP/pending pact configuration.
|
|
695
|
-
*
|
|
696
|
-
* @param params - `providerName`, consumer version selectors, pending/WIP flags,
|
|
697
|
-
* and optional provider branch/tag context.
|
|
698
|
-
* @returns List of pact URLs and metadata the provider must verify.
|
|
699
|
-
* @throws ToolError if the request fails.
|
|
700
|
-
*/
|
|
701
|
-
async getPactsForVerification({
|
|
702
|
-
providerName,
|
|
703
|
-
...body
|
|
704
|
-
}) {
|
|
705
|
-
return await this.fetchJson(
|
|
706
|
-
`${this.baseUrl}/pacts/provider/${encodeURIComponent(providerName)}/for-verification`,
|
|
707
|
-
{ method: "POST", body, errorContext: "Get Pacts for Verification" }
|
|
708
|
-
);
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* Fetches the provider OpenAPI contract for a given provider version in BDCT.
|
|
712
|
-
*
|
|
713
|
-
* @param params - `providerName` and `providerVersionNumber`.
|
|
714
|
-
* @returns The published OpenAPI spec and its verification status.
|
|
715
|
-
* @throws ToolError if the request fails.
|
|
716
|
-
*/
|
|
717
|
-
async getBiDirectionalProviderContract({
|
|
718
|
-
providerName,
|
|
719
|
-
providerVersionNumber
|
|
720
|
-
}) {
|
|
721
|
-
return await this.fetchJson(
|
|
722
|
-
`${this.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/provider-contract`,
|
|
723
|
-
{ method: "GET", errorContext: "Get BDCT Provider Contract" }
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* Fetches the self-verification results for a provider contract version in BDCT.
|
|
728
|
-
*
|
|
729
|
-
* @param params - `providerName` and `providerVersionNumber`.
|
|
730
|
-
* @returns The results of the tool (e.g. Dredd, Schemathesis) that verified the provider.
|
|
731
|
-
* @throws ToolError if the request fails.
|
|
732
|
-
*/
|
|
733
|
-
async getBiDirectionalProviderContractVerificationResults({
|
|
734
|
-
providerName,
|
|
735
|
-
providerVersionNumber
|
|
736
|
-
}) {
|
|
737
|
-
return await this.fetchJson(
|
|
738
|
-
`${this.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/provider-contract-verification-results`,
|
|
739
|
-
{
|
|
740
|
-
method: "GET",
|
|
741
|
-
errorContext: "Get BDCT Provider Contract Verification Results"
|
|
742
|
-
}
|
|
743
|
-
);
|
|
744
|
-
}
|
|
745
|
-
/**
|
|
746
|
-
* Fetches all consumer Pact contracts relevant to a given provider version in BDCT.
|
|
747
|
-
*
|
|
748
|
-
* @param params - `providerName` and `providerVersionNumber`.
|
|
749
|
-
* @returns Consumer contracts compared against the provider's OpenAPI spec.
|
|
750
|
-
* @throws ToolError if the request fails.
|
|
751
|
-
*/
|
|
752
|
-
async getBiDirectionalConsumerContract({
|
|
753
|
-
providerName,
|
|
754
|
-
providerVersionNumber
|
|
755
|
-
}) {
|
|
756
|
-
return await this.fetchJson(
|
|
757
|
-
`${this.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer-contract`,
|
|
758
|
-
{ method: "GET", errorContext: "Get BDCT Consumer Contract" }
|
|
759
|
-
);
|
|
760
|
-
}
|
|
761
|
-
/**
|
|
762
|
-
* Fetches the consumer contract verification results for a given provider version in BDCT.
|
|
763
|
-
*
|
|
764
|
-
* @param params - `providerName` and `providerVersionNumber`.
|
|
765
|
-
* @returns Results of comparing all consumer pacts against the provider's OpenAPI spec.
|
|
766
|
-
* @throws ToolError if the request fails.
|
|
767
|
-
*/
|
|
768
|
-
async getBiDirectionalConsumerContractVerificationResults({
|
|
769
|
-
providerName,
|
|
770
|
-
providerVersionNumber
|
|
771
|
-
}) {
|
|
772
|
-
return await this.fetchJson(
|
|
773
|
-
`${this.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer-contract-verification-results`,
|
|
774
|
-
{
|
|
775
|
-
method: "GET",
|
|
776
|
-
errorContext: "Get BDCT Consumer Contract Verification Results"
|
|
777
|
-
}
|
|
778
|
-
);
|
|
779
|
-
}
|
|
780
|
-
/**
|
|
781
|
-
* Fetches the cross-contract verification results for a given provider version in BDCT.
|
|
782
|
-
*
|
|
783
|
-
* @param params - `providerName` and `providerVersionNumber`.
|
|
784
|
-
* @returns Combined outcome of PactFlow's automated comparison of the provider spec
|
|
785
|
-
* against all relevant consumer pacts.
|
|
786
|
-
* @throws ToolError if the request fails.
|
|
787
|
-
*/
|
|
788
|
-
async getBiDirectionalCrossContractVerificationResults({
|
|
789
|
-
providerName,
|
|
790
|
-
providerVersionNumber
|
|
791
|
-
}) {
|
|
792
|
-
return await this.fetchJson(
|
|
793
|
-
`${this.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/cross-contract-verification-results`,
|
|
794
|
-
{
|
|
795
|
-
method: "GET",
|
|
796
|
-
errorContext: "Get BDCT Cross-Contract Verification Results"
|
|
797
|
-
}
|
|
798
|
-
);
|
|
799
|
-
}
|
|
800
|
-
/**
|
|
801
|
-
* Fetches the consumer Pact contract for a specific consumer-provider version pair in BDCT.
|
|
802
|
-
*
|
|
803
|
-
* @param params - `providerName`, `providerVersionNumber`, `consumerName`,
|
|
804
|
-
* and `consumerVersionNumber`.
|
|
805
|
-
* @returns The Pact contract published by the specified consumer version.
|
|
806
|
-
* @throws ToolError if the request fails.
|
|
807
|
-
*/
|
|
808
|
-
async getBiDirectionalConsumerContractByConsumer({
|
|
809
|
-
providerName,
|
|
810
|
-
providerVersionNumber,
|
|
811
|
-
consumerName,
|
|
812
|
-
consumerVersionNumber
|
|
813
|
-
}) {
|
|
814
|
-
return await this.fetchJson(
|
|
815
|
-
`${this.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer/${encodeURIComponent(consumerName)}/version/${encodeURIComponent(consumerVersionNumber)}/consumer-contract`,
|
|
816
|
-
{
|
|
817
|
-
method: "GET",
|
|
818
|
-
errorContext: "Get BDCT Consumer Contract (by consumer version)"
|
|
819
|
-
}
|
|
820
|
-
);
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* Fetches the provider OpenAPI contract for a specific consumer-provider version pair in BDCT.
|
|
824
|
-
*
|
|
825
|
-
* @param params - `providerName`, `providerVersionNumber`, `consumerName`,
|
|
826
|
-
* and `consumerVersionNumber`.
|
|
827
|
-
* @returns The provider's OpenAPI spec in the context of the given consumer version.
|
|
828
|
-
* @throws ToolError if the request fails.
|
|
829
|
-
*/
|
|
830
|
-
async getBiDirectionalProviderContractByConsumer({
|
|
831
|
-
providerName,
|
|
832
|
-
providerVersionNumber,
|
|
833
|
-
consumerName,
|
|
834
|
-
consumerVersionNumber
|
|
835
|
-
}) {
|
|
836
|
-
return await this.fetchJson(
|
|
837
|
-
`${this.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer/${encodeURIComponent(consumerName)}/version/${encodeURIComponent(consumerVersionNumber)}/provider-contract`,
|
|
838
|
-
{
|
|
839
|
-
method: "GET",
|
|
840
|
-
errorContext: "Get BDCT Provider Contract (by consumer version)"
|
|
841
|
-
}
|
|
842
|
-
);
|
|
843
|
-
}
|
|
844
|
-
/**
|
|
845
|
-
* Fetches the provider contract self-verification results for a specific
|
|
846
|
-
* consumer-provider version pair in BDCT.
|
|
847
|
-
*
|
|
848
|
-
* @param params - `providerName`, `providerVersionNumber`, `consumerName`,
|
|
849
|
-
* and `consumerVersionNumber`.
|
|
850
|
-
* @returns Provider self-verification results scoped to the given consumer version.
|
|
851
|
-
* @throws ToolError if the request fails.
|
|
852
|
-
*/
|
|
853
|
-
async getBiDirectionalProviderContractVerificationResultsByConsumer({
|
|
854
|
-
providerName,
|
|
855
|
-
providerVersionNumber,
|
|
856
|
-
consumerName,
|
|
857
|
-
consumerVersionNumber
|
|
858
|
-
}) {
|
|
859
|
-
return await this.fetchJson(
|
|
860
|
-
`${this.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer/${encodeURIComponent(consumerName)}/version/${encodeURIComponent(consumerVersionNumber)}/provider-contract-verification-results`,
|
|
861
|
-
{
|
|
862
|
-
method: "GET",
|
|
863
|
-
errorContext: "Get BDCT Provider Contract Verification Results (by consumer version)"
|
|
864
|
-
}
|
|
865
|
-
);
|
|
866
|
-
}
|
|
867
|
-
/**
|
|
868
|
-
* Fetches the consumer contract verification results for a specific
|
|
869
|
-
* consumer-provider version pair in BDCT.
|
|
870
|
-
*
|
|
871
|
-
* @param params - `providerName`, `providerVersionNumber`, `consumerName`,
|
|
872
|
-
* and `consumerVersionNumber`.
|
|
873
|
-
* @returns Results of comparing the specific consumer pact against the provider's OpenAPI spec.
|
|
874
|
-
* @throws ToolError if the request fails.
|
|
875
|
-
*/
|
|
876
|
-
async getBiDirectionalConsumerContractVerificationResultsByConsumer({
|
|
877
|
-
providerName,
|
|
878
|
-
providerVersionNumber,
|
|
879
|
-
consumerName,
|
|
880
|
-
consumerVersionNumber
|
|
881
|
-
}) {
|
|
882
|
-
return await this.fetchJson(
|
|
883
|
-
`${this.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer/${encodeURIComponent(consumerName)}/version/${encodeURIComponent(consumerVersionNumber)}/consumer-contract-verification-results`,
|
|
884
|
-
{
|
|
885
|
-
method: "GET",
|
|
886
|
-
errorContext: "Get BDCT Consumer Contract Verification Results (by consumer version)"
|
|
887
|
-
}
|
|
888
|
-
);
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
* Fetches the cross-contract verification results for a specific
|
|
892
|
-
* consumer-provider version pair in BDCT.
|
|
893
|
-
*
|
|
894
|
-
* @param params - `providerName`, `providerVersionNumber`, `consumerName`,
|
|
895
|
-
* and `consumerVersionNumber`.
|
|
896
|
-
* @returns The precise cross-contract comparison outcome for the given pairing.
|
|
897
|
-
* @throws ToolError if the request fails.
|
|
898
|
-
*/
|
|
899
|
-
async getBiDirectionalCrossContractVerificationResultsByConsumer({
|
|
900
|
-
providerName,
|
|
901
|
-
providerVersionNumber,
|
|
902
|
-
consumerName,
|
|
903
|
-
consumerVersionNumber
|
|
904
|
-
}) {
|
|
905
|
-
return await this.fetchJson(
|
|
906
|
-
`${this.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer/${encodeURIComponent(consumerName)}/version/${encodeURIComponent(consumerVersionNumber)}/cross-contract-verification-results`,
|
|
907
|
-
{
|
|
908
|
-
method: "GET",
|
|
909
|
-
errorContext: "Get BDCT Cross-Contract Verification Results (by consumer version)"
|
|
910
|
-
}
|
|
911
|
-
);
|
|
912
|
-
}
|
|
913
|
-
/**
|
|
914
|
-
* Retrieves all consumer-provider integrations registered in the workspace.
|
|
915
|
-
*
|
|
916
|
-
* @returns List of all consumer-provider pairings that have pacts published.
|
|
917
|
-
* @throws ToolError if the request fails.
|
|
918
|
-
*/
|
|
919
|
-
async listIntegrations() {
|
|
920
|
-
return await this.fetchJson(`${this.baseUrl}/integrations`, {
|
|
921
|
-
method: "GET",
|
|
922
|
-
errorContext: "List Integrations"
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
/**
|
|
926
|
-
* Retrieves the integration network graph for a specific pacticipant,
|
|
927
|
-
* showing all services it consumes and all consumers that depend on it.
|
|
928
|
-
*
|
|
929
|
-
* @param params - `pacticipantName`: The name of the pacticipant.
|
|
930
|
-
* @returns Network graph of consumer-provider relationships for the pacticipant.
|
|
931
|
-
* @throws ToolError if the request fails.
|
|
932
|
-
*/
|
|
933
|
-
async getPacticipantNetwork({
|
|
934
|
-
pacticipantName
|
|
935
|
-
}) {
|
|
936
|
-
return await this.fetchJson(
|
|
937
|
-
`${this.baseUrl}/pacticipant/${encodeURIComponent(pacticipantName)}/network`,
|
|
938
|
-
{ method: "GET", errorContext: "Get Pacticipant Network" }
|
|
939
|
-
);
|
|
940
|
-
}
|
|
941
|
-
/**
|
|
942
|
-
* Retrieves all labels used across the workspace, with optional pagination.
|
|
943
|
-
*
|
|
944
|
-
* @param params - Optional `pageNumber` and `pageSize`.
|
|
945
|
-
* @returns List of every label applied to any pacticipant.
|
|
946
|
-
* @throws ToolError if the request fails.
|
|
947
|
-
*/
|
|
948
|
-
async listLabels(params) {
|
|
949
|
-
const queryParams = new URLSearchParams();
|
|
950
|
-
if (params?.pageNumber) queryParams.set("page", String(params.pageNumber));
|
|
951
|
-
if (params?.pageSize) queryParams.set("size", String(params.pageSize));
|
|
952
|
-
const qs = queryParams.toString();
|
|
953
|
-
return await this.fetchJson(
|
|
954
|
-
`${this.baseUrl}/labels${qs ? `?${qs}` : ""}`,
|
|
955
|
-
{ method: "GET", errorContext: "List Labels" }
|
|
956
|
-
);
|
|
957
|
-
}
|
|
958
|
-
/**
|
|
959
|
-
* Checks whether a specific label is applied to a pacticipant.
|
|
960
|
-
*
|
|
961
|
-
* @param params - `pacticipantName` and `labelName`.
|
|
962
|
-
* @returns The label resource if it exists (404 if not applied).
|
|
963
|
-
* @throws ToolError if the request fails.
|
|
964
|
-
*/
|
|
965
|
-
async getPacticipantLabel({
|
|
966
|
-
pacticipantName,
|
|
967
|
-
labelName
|
|
968
|
-
}) {
|
|
969
|
-
return await this.fetchJson(
|
|
970
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/labels/${encodeURIComponent(labelName)}`,
|
|
971
|
-
{ method: "GET", errorContext: "Get Pacticipant Label" }
|
|
972
|
-
);
|
|
973
|
-
}
|
|
974
|
-
/**
|
|
975
|
-
* Retrieves all pacticipants that have a specific label applied.
|
|
976
|
-
*
|
|
977
|
-
* @param params - `labelName`: The label to filter by.
|
|
978
|
-
* @returns List of pacticipants with the given label.
|
|
979
|
-
* @throws ToolError if the request fails.
|
|
980
|
-
*/
|
|
981
|
-
async listPacticipantsByLabel({ labelName }) {
|
|
982
|
-
return await this.fetchJson(
|
|
983
|
-
`${this.baseUrl}/pacticipants/label/${encodeURIComponent(labelName)}`,
|
|
984
|
-
{ method: "GET", errorContext: "List Pacticipants by Label" }
|
|
985
|
-
);
|
|
986
|
-
}
|
|
987
|
-
/**
|
|
988
|
-
* Fully replaces a pacticipant's metadata. All fields not provided are cleared.
|
|
989
|
-
*
|
|
990
|
-
* @param params - `pacticipantName` plus optional metadata fields
|
|
991
|
-
* (displayName, mainBranch, repositoryUrl, etc.).
|
|
992
|
-
* @returns The updated pacticipant resource.
|
|
993
|
-
* @throws ToolError if the request fails.
|
|
994
|
-
*/
|
|
995
|
-
async updatePacticipant({
|
|
996
|
-
pacticipantName,
|
|
997
|
-
...body
|
|
998
|
-
}) {
|
|
999
|
-
return await this.fetchJson(
|
|
1000
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}`,
|
|
1001
|
-
{ method: "PUT", body, errorContext: "Update Pacticipant" }
|
|
1002
|
-
);
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Partially updates a pacticipant's metadata — only the fields provided are changed.
|
|
1006
|
-
*
|
|
1007
|
-
* @param params - `pacticipantName` plus the specific fields to update.
|
|
1008
|
-
* @returns The updated pacticipant resource.
|
|
1009
|
-
* @throws ToolError if the request fails.
|
|
1010
|
-
*/
|
|
1011
|
-
async patchPacticipant({
|
|
1012
|
-
pacticipantName,
|
|
1013
|
-
...body
|
|
1014
|
-
}) {
|
|
1015
|
-
return await this.fetchJson(
|
|
1016
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}`,
|
|
1017
|
-
{ method: "PATCH", body, errorContext: "Patch Pacticipant" }
|
|
1018
|
-
);
|
|
1019
|
-
}
|
|
1020
|
-
/**
|
|
1021
|
-
* Updates metadata for a specific pacticipant version (e.g. sets the build URL).
|
|
1022
|
-
*
|
|
1023
|
-
* @param params - `pacticipantName`, `versionNumber`, and optional `buildUrl`.
|
|
1024
|
-
* @returns The updated version resource.
|
|
1025
|
-
* @throws ToolError if the request fails.
|
|
1026
|
-
*/
|
|
1027
|
-
async updateVersion({
|
|
1028
|
-
pacticipantName,
|
|
1029
|
-
versionNumber,
|
|
1030
|
-
...body
|
|
1031
|
-
}) {
|
|
1032
|
-
return await this.fetchJson(
|
|
1033
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}`,
|
|
1034
|
-
{ method: "PUT", body, errorContext: "Update Version" }
|
|
1035
|
-
);
|
|
1036
|
-
}
|
|
1037
|
-
/**
|
|
1038
|
-
* Retrieves all versions published from a specific branch of a pacticipant.
|
|
1039
|
-
*
|
|
1040
|
-
* @param params - `pacticipantName`, `branchName`, optional `pageNumber` and `pageSize`.
|
|
1041
|
-
* @returns List of versions created on the given branch.
|
|
1042
|
-
* @throws ToolError if the request fails.
|
|
1043
|
-
*/
|
|
1044
|
-
async getBranchVersions({
|
|
1045
|
-
pacticipantName,
|
|
1046
|
-
branchName,
|
|
1047
|
-
pageNumber,
|
|
1048
|
-
pageSize
|
|
1049
|
-
}) {
|
|
1050
|
-
const queryParams = new URLSearchParams();
|
|
1051
|
-
if (pageNumber) queryParams.set("page", String(pageNumber));
|
|
1052
|
-
if (pageSize) queryParams.set("size", String(pageSize));
|
|
1053
|
-
const qs = queryParams.toString();
|
|
1054
|
-
return await this.fetchJson(
|
|
1055
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/branches/${encodeURIComponent(branchName)}/versions${qs ? `?${qs}` : ""}`,
|
|
1056
|
-
{ method: "GET", errorContext: "Get Branch Versions" }
|
|
1057
|
-
);
|
|
1058
|
-
}
|
|
1059
|
-
/**
|
|
1060
|
-
* Retrieves deployment records for a specific pacticipant version in a given environment.
|
|
1061
|
-
*
|
|
1062
|
-
* @param params - `pacticipantName`, `versionNumber`, and `environmentId`.
|
|
1063
|
-
* @returns All deployment records for the version, including whether each is currently active.
|
|
1064
|
-
* @throws ToolError if the request fails.
|
|
1065
|
-
*/
|
|
1066
|
-
async getDeployedVersions({
|
|
1067
|
-
pacticipantName,
|
|
1068
|
-
versionNumber,
|
|
1069
|
-
environmentId
|
|
1070
|
-
}) {
|
|
1071
|
-
return await this.fetchJson(
|
|
1072
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}/deployed-versions/environment/${encodeURIComponent(environmentId)}`,
|
|
1073
|
-
{ method: "GET", errorContext: "Get Deployed Versions" }
|
|
1074
|
-
);
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Retrieves release records for a specific pacticipant version in a given environment.
|
|
1078
|
-
*
|
|
1079
|
-
* @param params - `pacticipantName`, `versionNumber`, and `environmentId`.
|
|
1080
|
-
* @returns All release records for the version in the environment.
|
|
1081
|
-
* @throws ToolError if the request fails.
|
|
1082
|
-
*/
|
|
1083
|
-
async getReleasedVersions({
|
|
1084
|
-
pacticipantName,
|
|
1085
|
-
versionNumber,
|
|
1086
|
-
environmentId
|
|
1087
|
-
}) {
|
|
1088
|
-
return await this.fetchJson(
|
|
1089
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}/released-versions/environment/${encodeURIComponent(environmentId)}`,
|
|
1090
|
-
{ method: "GET", errorContext: "Get Released Versions" }
|
|
1091
|
-
);
|
|
1092
|
-
}
|
|
1093
|
-
/**
|
|
1094
|
-
* Creates a new deployment environment in the workspace.
|
|
1095
|
-
*
|
|
1096
|
-
* @param body - Environment name, display name, and whether it is a production environment.
|
|
1097
|
-
* @returns The created environment resource.
|
|
1098
|
-
* @throws ToolError if the request fails.
|
|
1099
|
-
*/
|
|
1100
|
-
async createEnvironment({
|
|
1101
|
-
...body
|
|
1102
|
-
}) {
|
|
1103
|
-
return await this.fetchJson(`${this.baseUrl}/environments`, {
|
|
1104
|
-
method: "POST",
|
|
1105
|
-
body,
|
|
1106
|
-
errorContext: "Create Environment"
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
/**
|
|
1110
|
-
* Fully replaces an environment's configuration.
|
|
1111
|
-
*
|
|
1112
|
-
* @param params - `environmentId` (UUID) plus updated name, display name, and production flag.
|
|
1113
|
-
* @returns The updated environment resource.
|
|
1114
|
-
* @throws ToolError if the environment is not found or the request fails.
|
|
1115
|
-
*/
|
|
1116
|
-
async updateEnvironment({
|
|
1117
|
-
environmentId,
|
|
1118
|
-
...body
|
|
1119
|
-
}) {
|
|
1120
|
-
return await this.fetchJson(
|
|
1121
|
-
`${this.baseUrl}/environments/${encodeURIComponent(environmentId)}`,
|
|
1122
|
-
{
|
|
1123
|
-
method: "PUT",
|
|
1124
|
-
body,
|
|
1125
|
-
errorContext: "Update Environment"
|
|
1126
|
-
}
|
|
1127
|
-
);
|
|
1128
|
-
}
|
|
1129
|
-
/**
|
|
1130
|
-
* Deletes a deployment environment from the workspace.
|
|
1131
|
-
*
|
|
1132
|
-
* @param params - `environmentId`: UUID of the environment to delete.
|
|
1133
|
-
* @throws ToolError if the environment is not found or the request fails.
|
|
1134
|
-
*/
|
|
1135
|
-
async deleteEnvironment({
|
|
1136
|
-
environmentId
|
|
1137
|
-
}) {
|
|
1138
|
-
return await this.fetchJson(
|
|
1139
|
-
`${this.baseUrl}/environments/${encodeURIComponent(environmentId)}`,
|
|
1140
|
-
{
|
|
1141
|
-
method: "DELETE",
|
|
1142
|
-
errorContext: "Delete Environment"
|
|
1143
|
-
}
|
|
1144
|
-
);
|
|
1145
|
-
}
|
|
1146
|
-
/**
|
|
1147
|
-
* Registers a new pacticipant (application/service) in the workspace.
|
|
1148
|
-
*
|
|
1149
|
-
* @param body - Name, optional display name, main branch, and repository URL.
|
|
1150
|
-
* @returns The created pacticipant resource.
|
|
1151
|
-
* @throws ToolError if the request fails.
|
|
1152
|
-
*/
|
|
1153
|
-
async createPacticipant({
|
|
1154
|
-
...body
|
|
1155
|
-
}) {
|
|
1156
|
-
return await this.fetchJson(`${this.baseUrl}/pacticipants`, {
|
|
1157
|
-
method: "POST",
|
|
1158
|
-
body,
|
|
1159
|
-
errorContext: "Create Pacticipant"
|
|
1160
|
-
});
|
|
1161
|
-
}
|
|
1162
|
-
/**
|
|
1163
|
-
* Permanently removes a pacticipant and all its associated data from the workspace.
|
|
1164
|
-
*
|
|
1165
|
-
* @param params - `pacticipantName`: The name of the pacticipant to delete.
|
|
1166
|
-
* @throws ToolError if the request fails.
|
|
1167
|
-
*/
|
|
1168
|
-
async deletePacticipant({
|
|
1169
|
-
pacticipantName
|
|
1170
|
-
}) {
|
|
1171
|
-
return await this.fetchJson(
|
|
1172
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}`,
|
|
1173
|
-
{
|
|
1174
|
-
method: "DELETE",
|
|
1175
|
-
errorContext: "Delete Pacticipant"
|
|
1176
|
-
}
|
|
1177
|
-
);
|
|
1178
|
-
}
|
|
1179
|
-
/**
|
|
1180
|
-
* Retrieves metadata for a specific branch of a pacticipant.
|
|
1181
|
-
*
|
|
1182
|
-
* @param params - `pacticipantName` and `branchName`.
|
|
1183
|
-
* @returns Branch metadata including its versions.
|
|
1184
|
-
* @throws ToolError if the branch is not found or the request fails.
|
|
1185
|
-
*/
|
|
1186
|
-
async getBranch({
|
|
1187
|
-
pacticipantName,
|
|
1188
|
-
branchName
|
|
1189
|
-
}) {
|
|
1190
|
-
return await this.fetchJson(
|
|
1191
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/branches/${encodeURIComponent(branchName)}`,
|
|
1192
|
-
{ method: "GET", errorContext: "Get Branch" }
|
|
1193
|
-
);
|
|
1194
|
-
}
|
|
1195
|
-
/**
|
|
1196
|
-
* Deletes a branch and its version associations from a pacticipant.
|
|
1197
|
-
*
|
|
1198
|
-
* @param params - `pacticipantName` and `branchName`.
|
|
1199
|
-
* @throws ToolError if the branch is not found or the request fails.
|
|
1200
|
-
*/
|
|
1201
|
-
async deleteBranch({
|
|
1202
|
-
pacticipantName,
|
|
1203
|
-
branchName
|
|
1204
|
-
}) {
|
|
1205
|
-
return await this.fetchJson(
|
|
1206
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/branches/${encodeURIComponent(branchName)}`,
|
|
1207
|
-
{ method: "DELETE", errorContext: "Delete Branch" }
|
|
1208
|
-
);
|
|
1209
|
-
}
|
|
1210
|
-
/**
|
|
1211
|
-
* Applies a label to a pacticipant.
|
|
1212
|
-
*
|
|
1213
|
-
* @param params - `pacticipantName` and `labelName` to apply.
|
|
1214
|
-
* @returns The created label resource.
|
|
1215
|
-
* @throws ToolError if the request fails.
|
|
1216
|
-
*/
|
|
1217
|
-
async addLabel({
|
|
1218
|
-
pacticipantName,
|
|
1219
|
-
labelName
|
|
1220
|
-
}) {
|
|
1221
|
-
return await this.fetchJson(
|
|
1222
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/labels/${encodeURIComponent(labelName)}`,
|
|
1223
|
-
{ method: "PUT", body: {}, errorContext: "Add Label" }
|
|
1224
|
-
);
|
|
1225
|
-
}
|
|
1226
|
-
/**
|
|
1227
|
-
* Removes a label from a pacticipant.
|
|
1228
|
-
*
|
|
1229
|
-
* @param params - `pacticipantName` and `labelName` to remove.
|
|
1230
|
-
* @throws ToolError if the label or pacticipant is not found, or the request fails.
|
|
1231
|
-
*/
|
|
1232
|
-
async removeLabel({
|
|
1233
|
-
pacticipantName,
|
|
1234
|
-
labelName
|
|
1235
|
-
}) {
|
|
1236
|
-
return await this.fetchJson(
|
|
1237
|
-
`${this.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/labels/${encodeURIComponent(labelName)}`,
|
|
1238
|
-
{ method: "DELETE", errorContext: "Remove Label" }
|
|
1239
|
-
);
|
|
1240
|
-
}
|
|
1241
|
-
/**
|
|
1242
|
-
* Retrieves all consumer-provider integrations assigned to a specific team.
|
|
1243
|
-
*
|
|
1244
|
-
* @param params - `teamId`: UUID of the team.
|
|
1245
|
-
* @returns List of integrations associated with the team.
|
|
1246
|
-
* @throws ToolError if the request fails.
|
|
1247
|
-
*/
|
|
1248
|
-
async getIntegrationsByTeam({
|
|
1249
|
-
teamId
|
|
1250
|
-
}) {
|
|
1251
|
-
return await this.fetchJson(
|
|
1252
|
-
`${this.baseUrl}/integrations/team/${encodeURIComponent(teamId)}`,
|
|
1253
|
-
{
|
|
1254
|
-
method: "GET",
|
|
1255
|
-
errorContext: "Get Integrations by Team"
|
|
1256
|
-
}
|
|
1257
|
-
);
|
|
1258
|
-
}
|
|
1259
|
-
/**
|
|
1260
|
-
* Deletes the integration (pact relationship) between a specific consumer and provider.
|
|
1261
|
-
*
|
|
1262
|
-
* @param params - `providerName` and `consumerName`.
|
|
1263
|
-
* @throws ToolError if the integration is not found or the request fails.
|
|
1264
|
-
*/
|
|
1265
|
-
async deleteIntegration({
|
|
1266
|
-
providerName,
|
|
1267
|
-
consumerName
|
|
1268
|
-
}) {
|
|
1269
|
-
return await this.fetchJson(
|
|
1270
|
-
`${this.baseUrl}/integrations/provider/${encodeURIComponent(providerName)}/consumer/${encodeURIComponent(consumerName)}`,
|
|
1271
|
-
{ method: "DELETE", errorContext: "Delete Integration" }
|
|
1272
|
-
);
|
|
1273
|
-
}
|
|
1274
|
-
/**
|
|
1275
|
-
* Deletes all consumer-provider integrations in the workspace. Use with caution.
|
|
1276
|
-
*
|
|
1277
|
-
* @throws ToolError if the request fails.
|
|
1278
|
-
*/
|
|
1279
|
-
async deleteAllIntegrations() {
|
|
1280
|
-
return await this.fetchJson(`${this.baseUrl}/integrations`, {
|
|
1281
|
-
method: "DELETE",
|
|
1282
|
-
errorContext: "Delete All Integrations"
|
|
1283
|
-
});
|
|
1284
|
-
}
|
|
1285
|
-
/**
|
|
1286
|
-
* Retrieves all webhooks configured in the workspace.
|
|
1287
|
-
*
|
|
1288
|
-
* @returns List of webhook definitions and their trigger configurations.
|
|
1289
|
-
* @throws ToolError if the request fails.
|
|
1290
|
-
*/
|
|
1291
|
-
async listWebhooks() {
|
|
1292
|
-
return await this.fetchJson(`${this.baseUrl}/webhooks`, {
|
|
1293
|
-
method: "GET",
|
|
1294
|
-
errorContext: "List Webhooks"
|
|
1295
|
-
});
|
|
1296
|
-
}
|
|
1297
|
-
/**
|
|
1298
|
-
* Retrieves the configuration for a specific webhook by UUID.
|
|
1299
|
-
*
|
|
1300
|
-
* @param params - `webhookId`: UUID of the webhook.
|
|
1301
|
-
* @returns Webhook definition including its URL, events, and consumer/provider filters.
|
|
1302
|
-
* @throws ToolError if the webhook is not found or the request fails.
|
|
1303
|
-
*/
|
|
1304
|
-
async getWebhook({
|
|
1305
|
-
webhookId
|
|
1306
|
-
}) {
|
|
1307
|
-
return await this.fetchJson(
|
|
1308
|
-
`${this.baseUrl}/webhooks/${encodeURIComponent(webhookId)}`,
|
|
1309
|
-
{
|
|
1310
|
-
method: "GET",
|
|
1311
|
-
errorContext: "Get Webhook"
|
|
1312
|
-
}
|
|
1313
|
-
);
|
|
1314
|
-
}
|
|
1315
|
-
/**
|
|
1316
|
-
* Creates a new webhook triggered by pact publication or verification events.
|
|
1317
|
-
*
|
|
1318
|
-
* @param body - Webhook URL, HTTP method, headers, body, events, and optional
|
|
1319
|
-
* consumer/provider filters.
|
|
1320
|
-
* @returns The created webhook resource.
|
|
1321
|
-
* @throws ToolError if the request fails.
|
|
1322
|
-
*/
|
|
1323
|
-
async createWebhook({
|
|
1324
|
-
...body
|
|
1325
|
-
}) {
|
|
1326
|
-
return await this.fetchJson(`${this.baseUrl}/webhooks`, {
|
|
1327
|
-
method: "POST",
|
|
1328
|
-
body,
|
|
1329
|
-
errorContext: "Create Webhook"
|
|
1330
|
-
});
|
|
1331
|
-
}
|
|
1332
|
-
/**
|
|
1333
|
-
* Replaces the configuration of an existing webhook.
|
|
1334
|
-
*
|
|
1335
|
-
* @param params - `webhookId` (UUID) plus the full updated webhook definition.
|
|
1336
|
-
* @returns The updated webhook resource.
|
|
1337
|
-
* @throws ToolError if the webhook is not found or the request fails.
|
|
1338
|
-
*/
|
|
1339
|
-
async updateWebhook({
|
|
1340
|
-
webhookId,
|
|
1341
|
-
...body
|
|
1342
|
-
}) {
|
|
1343
|
-
return await this.fetchJson(
|
|
1344
|
-
`${this.baseUrl}/webhooks/${encodeURIComponent(webhookId)}`,
|
|
1345
|
-
{
|
|
1346
|
-
method: "PUT",
|
|
1347
|
-
body,
|
|
1348
|
-
errorContext: "Update Webhook"
|
|
1349
|
-
}
|
|
1350
|
-
);
|
|
1351
|
-
}
|
|
1352
|
-
/**
|
|
1353
|
-
* Deletes a webhook by UUID.
|
|
1354
|
-
*
|
|
1355
|
-
* @param params - `webhookId`: UUID of the webhook to delete.
|
|
1356
|
-
* @throws ToolError if the webhook is not found or the request fails.
|
|
1357
|
-
*/
|
|
1358
|
-
async deleteWebhook({
|
|
1359
|
-
webhookId
|
|
1360
|
-
}) {
|
|
1361
|
-
return await this.fetchJson(
|
|
1362
|
-
`${this.baseUrl}/webhooks/${encodeURIComponent(webhookId)}`,
|
|
1363
|
-
{
|
|
1364
|
-
method: "DELETE",
|
|
1365
|
-
errorContext: "Delete Webhook"
|
|
1366
|
-
}
|
|
1367
|
-
);
|
|
1368
|
-
}
|
|
1369
|
-
/**
|
|
1370
|
-
* Fires all webhooks in the workspace as a test, regardless of their trigger conditions.
|
|
1371
|
-
*
|
|
1372
|
-
* @throws ToolError if the request fails.
|
|
1373
|
-
*/
|
|
1374
|
-
async executeWebhooks() {
|
|
1375
|
-
return await this.fetchJson(`${this.baseUrl}/webhooks/execute`, {
|
|
1376
|
-
method: "POST",
|
|
1377
|
-
body: {},
|
|
1378
|
-
errorContext: "Execute Webhooks"
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
/**
|
|
1382
|
-
* Fires a specific webhook as a test, regardless of its trigger conditions.
|
|
1383
|
-
*
|
|
1384
|
-
* @param params - `webhookId`: UUID of the webhook to execute.
|
|
1385
|
-
* @throws ToolError if the webhook is not found or the request fails.
|
|
1386
|
-
*/
|
|
1387
|
-
async executeWebhook({
|
|
1388
|
-
webhookId
|
|
1389
|
-
}) {
|
|
1390
|
-
return await this.fetchJson(
|
|
1391
|
-
`${this.baseUrl}/webhooks/${encodeURIComponent(webhookId)}/execute`,
|
|
1392
|
-
{
|
|
1393
|
-
method: "POST",
|
|
1394
|
-
body: {},
|
|
1395
|
-
errorContext: "Execute Webhook"
|
|
1396
|
-
}
|
|
1397
|
-
);
|
|
1398
|
-
}
|
|
1399
|
-
/**
|
|
1400
|
-
* Retrieves all secrets stored in the workspace (names only, not values).
|
|
1401
|
-
*
|
|
1402
|
-
* @returns List of secret metadata.
|
|
1403
|
-
* @throws ToolError if the request fails.
|
|
1404
|
-
*/
|
|
1405
|
-
async listSecrets() {
|
|
1406
|
-
return await this.fetchJson(`${this.baseUrl}/secrets`, {
|
|
1407
|
-
method: "GET",
|
|
1408
|
-
errorContext: "List Secrets"
|
|
1409
|
-
});
|
|
1410
|
-
}
|
|
1411
|
-
/**
|
|
1412
|
-
* Retrieves metadata for a specific secret by UUID (value is not returned).
|
|
1413
|
-
*
|
|
1414
|
-
* @param params - `secretId`: UUID of the secret.
|
|
1415
|
-
* @throws ToolError if the secret is not found or the request fails.
|
|
1416
|
-
*/
|
|
1417
|
-
async getSecret({
|
|
1418
|
-
secretId
|
|
1419
|
-
}) {
|
|
1420
|
-
return await this.fetchJson(
|
|
1421
|
-
`${this.baseUrl}/secrets/${encodeURIComponent(secretId)}`,
|
|
1422
|
-
{
|
|
1423
|
-
method: "GET",
|
|
1424
|
-
errorContext: "Get Secret"
|
|
1425
|
-
}
|
|
1426
|
-
);
|
|
1427
|
-
}
|
|
1428
|
-
/**
|
|
1429
|
-
* Creates a new secret for use in webhook configurations.
|
|
1430
|
-
*
|
|
1431
|
-
* @param body - Secret name, description, and value.
|
|
1432
|
-
* @returns The created secret resource (value is not echoed back).
|
|
1433
|
-
* @throws ToolError if the request fails.
|
|
1434
|
-
*/
|
|
1435
|
-
async createSecret({
|
|
1436
|
-
...body
|
|
1437
|
-
}) {
|
|
1438
|
-
return await this.fetchJson(`${this.baseUrl}/secrets`, {
|
|
1439
|
-
method: "POST",
|
|
1440
|
-
body,
|
|
1441
|
-
errorContext: "Create Secret"
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
/**
|
|
1445
|
-
* Replaces the value and/or description of an existing secret.
|
|
1446
|
-
*
|
|
1447
|
-
* @param params - `secretId` (UUID) plus updated name, description, and/or value.
|
|
1448
|
-
* @throws ToolError if the secret is not found or the request fails.
|
|
1449
|
-
*/
|
|
1450
|
-
async updateSecret({
|
|
1451
|
-
secretId,
|
|
1452
|
-
...body
|
|
1453
|
-
}) {
|
|
1454
|
-
return await this.fetchJson(
|
|
1455
|
-
`${this.baseUrl}/secrets/${encodeURIComponent(secretId)}`,
|
|
1456
|
-
{
|
|
1457
|
-
method: "PUT",
|
|
1458
|
-
body,
|
|
1459
|
-
errorContext: "Update Secret"
|
|
1460
|
-
}
|
|
1461
|
-
);
|
|
1462
|
-
}
|
|
1463
|
-
/**
|
|
1464
|
-
* Permanently deletes a secret from the workspace.
|
|
1465
|
-
*
|
|
1466
|
-
* @param params - `secretId`: UUID of the secret to delete.
|
|
1467
|
-
* @throws ToolError if the secret is not found or the request fails.
|
|
1468
|
-
*/
|
|
1469
|
-
async deleteSecret({
|
|
1470
|
-
secretId
|
|
1471
|
-
}) {
|
|
1472
|
-
return await this.fetchJson(
|
|
1473
|
-
`${this.baseUrl}/secrets/${encodeURIComponent(secretId)}`,
|
|
1474
|
-
{
|
|
1475
|
-
method: "DELETE",
|
|
1476
|
-
errorContext: "Delete Secret"
|
|
1477
|
-
}
|
|
1478
|
-
);
|
|
1479
|
-
}
|
|
1480
|
-
/**
|
|
1481
|
-
* Retrieves the profile of the currently authenticated user.
|
|
1482
|
-
*
|
|
1483
|
-
* @returns Current user's name, email, roles, and active status.
|
|
1484
|
-
* @throws ToolError if the request fails.
|
|
1485
|
-
*/
|
|
1486
|
-
async getCurrentUser() {
|
|
1487
|
-
return await this.fetchJson(`${this.baseUrl}/user`, {
|
|
1488
|
-
method: "GET",
|
|
1489
|
-
errorContext: "Get Current User"
|
|
1490
|
-
});
|
|
1491
|
-
}
|
|
1492
|
-
/**
|
|
1493
|
-
* Lists all API tokens associated with the current user's account.
|
|
1494
|
-
*
|
|
1495
|
-
* @returns Token metadata (IDs, descriptions) — values are not returned.
|
|
1496
|
-
* @throws ToolError if the request fails.
|
|
1497
|
-
*/
|
|
1498
|
-
async listTokens() {
|
|
1499
|
-
return await this.fetchJson(`${this.baseUrl}/settings/tokens`, {
|
|
1500
|
-
method: "GET",
|
|
1501
|
-
errorContext: "List Tokens"
|
|
1502
|
-
});
|
|
1503
|
-
}
|
|
1504
|
-
/**
|
|
1505
|
-
* Regenerates (rotates) an API token, invalidating the previous value.
|
|
1506
|
-
*
|
|
1507
|
-
* @param params - `tokenId`: The identifier of the token to regenerate.
|
|
1508
|
-
* @returns The new token value.
|
|
1509
|
-
* @throws ToolError if the token is not found or the request fails.
|
|
1510
|
-
*/
|
|
1511
|
-
async regenerateToken({
|
|
1512
|
-
tokenId
|
|
1513
|
-
}) {
|
|
1514
|
-
return await this.fetchJson(
|
|
1515
|
-
`${this.baseUrl}/settings/tokens/${encodeURIComponent(tokenId)}/regenerate`,
|
|
1516
|
-
{
|
|
1517
|
-
method: "POST",
|
|
1518
|
-
body: {},
|
|
1519
|
-
errorContext: "Regenerate Token"
|
|
1520
|
-
}
|
|
1521
|
-
);
|
|
1522
|
-
}
|
|
1523
|
-
/**
|
|
1524
|
-
* Retrieves UI and notification preferences for the currently authenticated user.
|
|
1525
|
-
*
|
|
1526
|
-
* @returns User preference settings.
|
|
1527
|
-
* @throws ToolError if the request fails.
|
|
1528
|
-
*/
|
|
1529
|
-
async getUserPreferences() {
|
|
1530
|
-
return await this.fetchJson(
|
|
1531
|
-
`${this.baseUrl}/preferences/current-user`,
|
|
1532
|
-
{
|
|
1533
|
-
method: "GET",
|
|
1534
|
-
errorContext: "Get User Preferences"
|
|
1535
|
-
}
|
|
1536
|
-
);
|
|
1537
|
-
}
|
|
1538
|
-
/**
|
|
1539
|
-
* Retrieves workspace-level system preferences and configuration.
|
|
1540
|
-
*
|
|
1541
|
-
* @returns System preference settings.
|
|
1542
|
-
* @throws ToolError if the request fails.
|
|
1543
|
-
*/
|
|
1544
|
-
async getSystemPreferences() {
|
|
1545
|
-
return await this.fetchJson(`${this.baseUrl}/preferences/system`, {
|
|
1546
|
-
method: "GET",
|
|
1547
|
-
errorContext: "Get System Preferences"
|
|
1548
|
-
});
|
|
1549
|
-
}
|
|
1550
|
-
/**
|
|
1551
|
-
* Retrieves the workspace audit log with optional filtering and pagination.
|
|
1552
|
-
*
|
|
1553
|
-
* @param params - Optional filters: `since` (ISO date), `userUuid`, `type`,
|
|
1554
|
-
* `sort`, `from` cursor, `pageNumber`, and `pageSize`.
|
|
1555
|
-
* @returns Paginated list of audit events.
|
|
1556
|
-
* @throws ToolError if the request fails.
|
|
1557
|
-
*/
|
|
1558
|
-
async getAuditLog(params) {
|
|
1559
|
-
const queryParams = new URLSearchParams();
|
|
1560
|
-
if (params.since) queryParams.set("since", params.since);
|
|
1561
|
-
if (params.userUuid) queryParams.set("userUuid", params.userUuid);
|
|
1562
|
-
if (params.type) queryParams.set("type", params.type);
|
|
1563
|
-
if (params.sort) queryParams.set("sort", params.sort);
|
|
1564
|
-
if (params.from) queryParams.set("from", params.from);
|
|
1565
|
-
if (params.pageNumber)
|
|
1566
|
-
queryParams.set("pageNumber", String(params.pageNumber));
|
|
1567
|
-
if (params.pageSize) queryParams.set("pageSize", String(params.pageSize));
|
|
1568
|
-
const qs = queryParams.toString();
|
|
1569
|
-
return await this.fetchJson(
|
|
1570
|
-
`${this.baseUrl}/audit${qs ? `?${qs}` : ""}`,
|
|
1571
|
-
{
|
|
1572
|
-
method: "GET",
|
|
1573
|
-
errorContext: "Get Audit Log"
|
|
1574
|
-
}
|
|
1575
|
-
);
|
|
1576
|
-
}
|
|
1577
|
-
/**
|
|
1578
|
-
* Lists all users in the workspace with optional filtering and pagination (admin).
|
|
1579
|
-
*
|
|
1580
|
-
* @param params - Optional `active` flag, `q` (name/email search), `userType`,
|
|
1581
|
-
* `page`, and `size`.
|
|
1582
|
-
* @returns Paginated list of user accounts.
|
|
1583
|
-
* @throws ToolError if the request fails.
|
|
1584
|
-
*/
|
|
1585
|
-
async listAdminUsers(params) {
|
|
1586
|
-
const queryParams = new URLSearchParams();
|
|
1587
|
-
if (params.active !== void 0)
|
|
1588
|
-
queryParams.set("active", String(params.active));
|
|
1589
|
-
if (params.q) queryParams.set("q", params.q);
|
|
1590
|
-
if (params.userType !== void 0)
|
|
1591
|
-
queryParams.set("userType", String(params.userType));
|
|
1592
|
-
if (params.page) queryParams.set("page", String(params.page));
|
|
1593
|
-
if (params.size) queryParams.set("size", String(params.size));
|
|
1594
|
-
const qs = queryParams.toString();
|
|
1595
|
-
return await this.fetchJson(
|
|
1596
|
-
`${this.baseUrl}/admin/users${qs ? `?${qs}` : ""}`,
|
|
1597
|
-
{
|
|
1598
|
-
method: "GET",
|
|
1599
|
-
errorContext: "List Admin Users"
|
|
1600
|
-
}
|
|
1601
|
-
);
|
|
1602
|
-
}
|
|
1603
|
-
/**
|
|
1604
|
-
* Retrieves a user's full profile by UUID (admin).
|
|
1605
|
-
*
|
|
1606
|
-
* @param params - `userId`: UUID of the user.
|
|
1607
|
-
* @returns User profile including roles and active status.
|
|
1608
|
-
* @throws ToolError if the user is not found or the request fails.
|
|
1609
|
-
*/
|
|
1610
|
-
async getAdminUser({
|
|
1611
|
-
userId
|
|
1612
|
-
}) {
|
|
1613
|
-
return await this.fetchJson(
|
|
1614
|
-
`${this.baseUrl}/admin/users/${encodeURIComponent(userId)}`,
|
|
1615
|
-
{
|
|
1616
|
-
method: "GET",
|
|
1617
|
-
errorContext: "Get Admin User"
|
|
1618
|
-
}
|
|
1619
|
-
);
|
|
1620
|
-
}
|
|
1621
|
-
/**
|
|
1622
|
-
* Creates a new user account in the workspace (admin).
|
|
1623
|
-
*
|
|
1624
|
-
* @param body - User name, email, and optional SSO identity fields.
|
|
1625
|
-
* @returns The created user resource.
|
|
1626
|
-
* @throws ToolError if the request fails.
|
|
1627
|
-
*/
|
|
1628
|
-
async createAdminUser({
|
|
1629
|
-
...body
|
|
1630
|
-
}) {
|
|
1631
|
-
return await this.fetchJson(`${this.baseUrl}/admin/users`, {
|
|
1632
|
-
method: "POST",
|
|
1633
|
-
body,
|
|
1634
|
-
errorContext: "Create Admin User"
|
|
1635
|
-
});
|
|
1636
|
-
}
|
|
1637
|
-
/**
|
|
1638
|
-
* Replaces a user's profile (admin). Can also deactivate the user.
|
|
1639
|
-
*
|
|
1640
|
-
* @param params - `userId` (UUID) plus updated name, email, active flag, and SSO fields.
|
|
1641
|
-
* @returns The updated user resource.
|
|
1642
|
-
* @throws ToolError if the user is not found or the request fails.
|
|
1643
|
-
*/
|
|
1644
|
-
async updateAdminUser({
|
|
1645
|
-
userId,
|
|
1646
|
-
...body
|
|
1647
|
-
}) {
|
|
1648
|
-
return await this.fetchJson(
|
|
1649
|
-
`${this.baseUrl}/admin/users/${encodeURIComponent(userId)}`,
|
|
1650
|
-
{
|
|
1651
|
-
method: "PUT",
|
|
1652
|
-
body,
|
|
1653
|
-
errorContext: "Update Admin User"
|
|
1654
|
-
}
|
|
1655
|
-
);
|
|
1656
|
-
}
|
|
1657
|
-
/**
|
|
1658
|
-
* Permanently deletes a user account from the workspace (admin).
|
|
1659
|
-
*
|
|
1660
|
-
* @param params - `userId`: UUID of the user to delete.
|
|
1661
|
-
* @throws ToolError if the user is not found or the request fails.
|
|
1662
|
-
*/
|
|
1663
|
-
async deleteAdminUser({
|
|
1664
|
-
userId
|
|
1665
|
-
}) {
|
|
1666
|
-
return await this.fetchJson(
|
|
1667
|
-
`${this.baseUrl}/admin/users/${encodeURIComponent(userId)}`,
|
|
1668
|
-
{
|
|
1669
|
-
method: "DELETE",
|
|
1670
|
-
errorContext: "Delete Admin User"
|
|
1671
|
-
}
|
|
1672
|
-
);
|
|
1673
|
-
}
|
|
1674
|
-
/**
|
|
1675
|
-
* Sends invitation emails to one or more new users (admin).
|
|
1676
|
-
*
|
|
1677
|
-
* @param params - `users`: Array of objects with email and optional name.
|
|
1678
|
-
* @throws ToolError if the request fails.
|
|
1679
|
-
*/
|
|
1680
|
-
async inviteUsers({
|
|
1681
|
-
users
|
|
1682
|
-
}) {
|
|
1683
|
-
return await this.fetchJson(
|
|
1684
|
-
`${this.baseUrl}/admin/users/invite-users`,
|
|
1685
|
-
{
|
|
1686
|
-
method: "POST",
|
|
1687
|
-
body: { users },
|
|
1688
|
-
errorContext: "Invite Users"
|
|
1689
|
-
}
|
|
1690
|
-
);
|
|
1691
|
-
}
|
|
1692
|
-
/**
|
|
1693
|
-
* Fully replaces the roles assigned to a user (admin).
|
|
1694
|
-
* All existing roles are removed; the provided list becomes the new set.
|
|
1695
|
-
*
|
|
1696
|
-
* @param params - `userId` (UUID) and `roles` array of role UUIDs.
|
|
1697
|
-
* @throws ToolError if the user is not found or the request fails.
|
|
1698
|
-
*/
|
|
1699
|
-
async setUserRoles({
|
|
1700
|
-
userId,
|
|
1701
|
-
roles
|
|
1702
|
-
}) {
|
|
1703
|
-
return await this.fetchJson(
|
|
1704
|
-
`${this.baseUrl}/admin/users/${encodeURIComponent(userId)}/roles`,
|
|
1705
|
-
{
|
|
1706
|
-
method: "PUT",
|
|
1707
|
-
body: { roles },
|
|
1708
|
-
errorContext: "Set User Roles"
|
|
1709
|
-
}
|
|
1710
|
-
);
|
|
1711
|
-
}
|
|
1712
|
-
/**
|
|
1713
|
-
* Grants a single additional role to a user without affecting their existing roles (admin).
|
|
1714
|
-
*
|
|
1715
|
-
* @param params - `userId` and `roleId` UUIDs.
|
|
1716
|
-
* @throws ToolError if the user or role is not found, or the request fails.
|
|
1717
|
-
*/
|
|
1718
|
-
async addRoleToUser({
|
|
1719
|
-
userId,
|
|
1720
|
-
roleId
|
|
1721
|
-
}) {
|
|
1722
|
-
return await this.fetchJson(
|
|
1723
|
-
`${this.baseUrl}/admin/users/${encodeURIComponent(userId)}/roles/${encodeURIComponent(roleId)}`,
|
|
1724
|
-
{ method: "PUT", body: {}, errorContext: "Add Role to User" }
|
|
1725
|
-
);
|
|
1726
|
-
}
|
|
1727
|
-
/**
|
|
1728
|
-
* Revokes a specific role from a user without affecting their other roles (admin).
|
|
1729
|
-
*
|
|
1730
|
-
* @param params - `userId` and `roleId` UUIDs.
|
|
1731
|
-
* @throws ToolError if the user or role is not found, or the request fails.
|
|
1732
|
-
*/
|
|
1733
|
-
async removeRoleFromUser({
|
|
1734
|
-
userId,
|
|
1735
|
-
roleId
|
|
1736
|
-
}) {
|
|
1737
|
-
return await this.fetchJson(
|
|
1738
|
-
`${this.baseUrl}/admin/users/${encodeURIComponent(userId)}/roles/${encodeURIComponent(roleId)}`,
|
|
1739
|
-
{ method: "DELETE", errorContext: "Remove Role from User" }
|
|
1740
|
-
);
|
|
1741
|
-
}
|
|
1742
|
-
/**
|
|
1743
|
-
* Lists all teams in the workspace with optional name filtering and pagination (admin).
|
|
1744
|
-
*
|
|
1745
|
-
* @param params - Optional `q` (name search), `page`, and `size`.
|
|
1746
|
-
* @returns Paginated list of teams.
|
|
1747
|
-
* @throws ToolError if the request fails.
|
|
1748
|
-
*/
|
|
1749
|
-
async listAdminTeams(params) {
|
|
1750
|
-
const queryParams = new URLSearchParams();
|
|
1751
|
-
if (params.q) queryParams.set("q", params.q);
|
|
1752
|
-
if (params.page) queryParams.set("page", String(params.page));
|
|
1753
|
-
if (params.size) queryParams.set("size", String(params.size));
|
|
1754
|
-
const qs = queryParams.toString();
|
|
1755
|
-
return await this.fetchJson(
|
|
1756
|
-
`${this.baseUrl}/admin/teams${qs ? `?${qs}` : ""}`,
|
|
1757
|
-
{
|
|
1758
|
-
method: "GET",
|
|
1759
|
-
errorContext: "List Admin Teams"
|
|
1760
|
-
}
|
|
1761
|
-
);
|
|
1762
|
-
}
|
|
1763
|
-
/**
|
|
1764
|
-
* Retrieves the full configuration of a team by UUID (admin).
|
|
1765
|
-
*
|
|
1766
|
-
* @param params - `teamId`: UUID of the team.
|
|
1767
|
-
* @returns Team details including name, members, environments, and pacticipants.
|
|
1768
|
-
* @throws ToolError if the team is not found or the request fails.
|
|
1769
|
-
*/
|
|
1770
|
-
async getAdminTeam({
|
|
1771
|
-
teamId
|
|
1772
|
-
}) {
|
|
1773
|
-
return await this.fetchJson(
|
|
1774
|
-
`${this.baseUrl}/admin/teams/${encodeURIComponent(teamId)}`,
|
|
1775
|
-
{
|
|
1776
|
-
method: "GET",
|
|
1777
|
-
errorContext: "Get Admin Team"
|
|
1778
|
-
}
|
|
1779
|
-
);
|
|
1780
|
-
}
|
|
1781
|
-
/**
|
|
1782
|
-
* Creates a new team in the workspace (admin).
|
|
1783
|
-
*
|
|
1784
|
-
* @param body - Team name and optional administrators, environments, and pacticipants.
|
|
1785
|
-
* @returns The created team resource.
|
|
1786
|
-
* @throws ToolError if the request fails.
|
|
1787
|
-
*/
|
|
1788
|
-
async createAdminTeam({
|
|
1789
|
-
...body
|
|
1790
|
-
}) {
|
|
1791
|
-
return await this.fetchJson(`${this.baseUrl}/admin/teams`, {
|
|
1792
|
-
method: "POST",
|
|
1793
|
-
body,
|
|
1794
|
-
errorContext: "Create Admin Team"
|
|
1795
|
-
});
|
|
1796
|
-
}
|
|
1797
|
-
/**
|
|
1798
|
-
* Fully replaces a team's configuration (admin).
|
|
1799
|
-
*
|
|
1800
|
-
* @param params - `teamId` (UUID) plus updated name, administrators, environments,
|
|
1801
|
-
* and pacticipant assignments.
|
|
1802
|
-
* @throws ToolError if the team is not found or the request fails.
|
|
1803
|
-
*/
|
|
1804
|
-
async updateAdminTeam({
|
|
1805
|
-
teamId,
|
|
1806
|
-
...body
|
|
1807
|
-
}) {
|
|
1808
|
-
return await this.fetchJson(
|
|
1809
|
-
`${this.baseUrl}/admin/teams/${encodeURIComponent(teamId)}`,
|
|
1810
|
-
{
|
|
1811
|
-
method: "PUT",
|
|
1812
|
-
body,
|
|
1813
|
-
errorContext: "Update Admin Team"
|
|
1814
|
-
}
|
|
1815
|
-
);
|
|
1816
|
-
}
|
|
1817
|
-
/**
|
|
1818
|
-
* Permanently deletes a team from the workspace (admin). Members are not deleted.
|
|
1819
|
-
*
|
|
1820
|
-
* @param params - `teamId`: UUID of the team to delete.
|
|
1821
|
-
* @throws ToolError if the team is not found or the request fails.
|
|
1822
|
-
*/
|
|
1823
|
-
async deleteAdminTeam({
|
|
1824
|
-
teamId
|
|
1825
|
-
}) {
|
|
1826
|
-
return await this.fetchJson(
|
|
1827
|
-
`${this.baseUrl}/admin/teams/${encodeURIComponent(teamId)}`,
|
|
1828
|
-
{
|
|
1829
|
-
method: "DELETE",
|
|
1830
|
-
errorContext: "Delete Admin Team"
|
|
1831
|
-
}
|
|
1832
|
-
);
|
|
1833
|
-
}
|
|
1834
|
-
/**
|
|
1835
|
-
* Lists all user members of a specific team (admin).
|
|
1836
|
-
*
|
|
1837
|
-
* @param params - `teamId`: UUID of the team.
|
|
1838
|
-
* @returns List of users in the team.
|
|
1839
|
-
* @throws ToolError if the team is not found or the request fails.
|
|
1840
|
-
*/
|
|
1841
|
-
async listTeamUsers({
|
|
1842
|
-
teamId
|
|
1843
|
-
}) {
|
|
1844
|
-
return await this.fetchJson(
|
|
1845
|
-
`${this.baseUrl}/admin/teams/${encodeURIComponent(teamId)}/users`,
|
|
1846
|
-
{
|
|
1847
|
-
method: "GET",
|
|
1848
|
-
errorContext: "List Team Users"
|
|
1849
|
-
}
|
|
1850
|
-
);
|
|
1851
|
-
}
|
|
1852
|
-
/**
|
|
1853
|
-
* Verifies whether a specific user is a member of a team (admin).
|
|
1854
|
-
* Returns 404 if the user is not in the team.
|
|
1855
|
-
*
|
|
1856
|
-
* @param params - `teamId` and `userId` UUIDs.
|
|
1857
|
-
* @throws ToolError if not found or the request fails.
|
|
1858
|
-
*/
|
|
1859
|
-
async getTeamUser({
|
|
1860
|
-
teamId,
|
|
1861
|
-
userId
|
|
1862
|
-
}) {
|
|
1863
|
-
return await this.fetchJson(
|
|
1864
|
-
`${this.baseUrl}/admin/teams/${encodeURIComponent(teamId)}/users/${encodeURIComponent(userId)}`,
|
|
1865
|
-
{ method: "GET", errorContext: "Get Team User" }
|
|
1866
|
-
);
|
|
1867
|
-
}
|
|
1868
|
-
/**
|
|
1869
|
-
* Fully replaces the members of a team (admin).
|
|
1870
|
-
* All existing members are removed; the provided UUID list becomes the new membership.
|
|
1871
|
-
*
|
|
1872
|
-
* @param params - `teamId` (UUID) and `uuids` array of user UUIDs.
|
|
1873
|
-
* @throws ToolError if the team is not found or the request fails.
|
|
1874
|
-
*/
|
|
1875
|
-
async setTeamUsers({
|
|
1876
|
-
teamId,
|
|
1877
|
-
uuids
|
|
1878
|
-
}) {
|
|
1879
|
-
return await this.fetchJson(
|
|
1880
|
-
`${this.baseUrl}/admin/teams/${encodeURIComponent(teamId)}/users`,
|
|
1881
|
-
{
|
|
1882
|
-
method: "PUT",
|
|
1883
|
-
body: { users: uuids },
|
|
1884
|
-
errorContext: "Set Team Users"
|
|
1885
|
-
}
|
|
1886
|
-
);
|
|
1887
|
-
}
|
|
1888
|
-
/**
|
|
1889
|
-
* Adds or removes individual users from a team using JSON Patch semantics (admin).
|
|
1890
|
-
*
|
|
1891
|
-
* @param params - `teamId` (UUID) and `operations` array of JSON Patch ops (add/remove).
|
|
1892
|
-
* @throws ToolError if the team is not found or the request fails.
|
|
1893
|
-
*/
|
|
1894
|
-
async patchTeamUsers({
|
|
1895
|
-
teamId,
|
|
1896
|
-
operations
|
|
1897
|
-
}) {
|
|
1898
|
-
return await this.fetchJson(
|
|
1899
|
-
`${this.baseUrl}/admin/teams/${encodeURIComponent(teamId)}/users`,
|
|
1900
|
-
{
|
|
1901
|
-
method: "PATCH",
|
|
1902
|
-
body: operations,
|
|
1903
|
-
errorContext: "Patch Team Users"
|
|
1904
|
-
}
|
|
1905
|
-
);
|
|
1906
|
-
}
|
|
1907
|
-
/**
|
|
1908
|
-
* Removes a specific user from a team (admin).
|
|
1909
|
-
*
|
|
1910
|
-
* @param params - `teamId` and `userId` UUIDs.
|
|
1911
|
-
* @throws ToolError if not found or the request fails.
|
|
1912
|
-
*/
|
|
1913
|
-
async removeUserFromTeam({
|
|
1914
|
-
teamId,
|
|
1915
|
-
userId
|
|
1916
|
-
}) {
|
|
1917
|
-
return await this.fetchJson(
|
|
1918
|
-
`${this.baseUrl}/admin/teams/${encodeURIComponent(teamId)}/users/${encodeURIComponent(userId)}`,
|
|
1919
|
-
{ method: "DELETE", errorContext: "Remove User from Team" }
|
|
1920
|
-
);
|
|
1921
|
-
}
|
|
1922
|
-
/**
|
|
1923
|
-
* Lists all roles defined in the workspace (admin).
|
|
1924
|
-
*
|
|
1925
|
-
* @returns All role definitions and their associated permission scopes.
|
|
1926
|
-
* @throws ToolError if the request fails.
|
|
1927
|
-
*/
|
|
1928
|
-
async listAdminRoles() {
|
|
1929
|
-
return await this.fetchJson(`${this.baseUrl}/admin/roles`, {
|
|
1930
|
-
method: "GET",
|
|
1931
|
-
errorContext: "List Admin Roles"
|
|
1932
|
-
});
|
|
1933
|
-
}
|
|
1934
|
-
/**
|
|
1935
|
-
* Retrieves a role's name, description, and full permission set by UUID (admin).
|
|
1936
|
-
*
|
|
1937
|
-
* @param params - `roleId`: UUID of the role.
|
|
1938
|
-
* @throws ToolError if the role is not found or the request fails.
|
|
1939
|
-
*/
|
|
1940
|
-
async getAdminRole({
|
|
1941
|
-
roleId
|
|
1942
|
-
}) {
|
|
1943
|
-
return await this.fetchJson(
|
|
1944
|
-
`${this.baseUrl}/admin/roles/${encodeURIComponent(roleId)}`,
|
|
1945
|
-
{
|
|
1946
|
-
method: "GET",
|
|
1947
|
-
errorContext: "Get Admin Role"
|
|
1948
|
-
}
|
|
1949
|
-
);
|
|
1950
|
-
}
|
|
1951
|
-
/**
|
|
1952
|
-
* Creates a custom role with a tailored set of permission scopes (admin).
|
|
1953
|
-
*
|
|
1954
|
-
* @param body - Role name, optional description, and array of permission scope strings.
|
|
1955
|
-
* @returns The created role resource.
|
|
1956
|
-
* @throws ToolError if the request fails.
|
|
1957
|
-
*/
|
|
1958
|
-
async createAdminRole({
|
|
1959
|
-
...body
|
|
1960
|
-
}) {
|
|
1961
|
-
return await this.fetchJson(`${this.baseUrl}/admin/roles`, {
|
|
1962
|
-
method: "POST",
|
|
1963
|
-
body,
|
|
1964
|
-
errorContext: "Create Admin Role"
|
|
1965
|
-
});
|
|
1966
|
-
}
|
|
1967
|
-
/**
|
|
1968
|
-
* Updates an existing role's name and/or permission set (admin).
|
|
1969
|
-
* Changes affect all users currently assigned the role.
|
|
1970
|
-
*
|
|
1971
|
-
* @param params - `roleId` (UUID) plus updated name, description, and permissions.
|
|
1972
|
-
* @throws ToolError if the role is not found or the request fails.
|
|
1973
|
-
*/
|
|
1974
|
-
async updateAdminRole({
|
|
1975
|
-
roleId,
|
|
1976
|
-
...body
|
|
1977
|
-
}) {
|
|
1978
|
-
return await this.fetchJson(
|
|
1979
|
-
`${this.baseUrl}/admin/roles/${encodeURIComponent(roleId)}`,
|
|
1980
|
-
{
|
|
1981
|
-
method: "PUT",
|
|
1982
|
-
body,
|
|
1983
|
-
errorContext: "Update Admin Role"
|
|
1984
|
-
}
|
|
1985
|
-
);
|
|
1986
|
-
}
|
|
1987
|
-
/**
|
|
1988
|
-
* Permanently deletes a role (admin). Users assigned this role will lose its permissions.
|
|
1989
|
-
*
|
|
1990
|
-
* @param params - `roleId`: UUID of the role to delete.
|
|
1991
|
-
* @throws ToolError if the role is not found or the request fails.
|
|
1992
|
-
*/
|
|
1993
|
-
async deleteAdminRole({
|
|
1994
|
-
roleId
|
|
1995
|
-
}) {
|
|
1996
|
-
return await this.fetchJson(
|
|
1997
|
-
`${this.baseUrl}/admin/roles/${encodeURIComponent(roleId)}`,
|
|
1998
|
-
{
|
|
1999
|
-
method: "DELETE",
|
|
2000
|
-
errorContext: "Delete Admin Role"
|
|
2001
|
-
}
|
|
2002
|
-
);
|
|
2003
|
-
}
|
|
2004
|
-
/**
|
|
2005
|
-
* Resets all roles to factory defaults (admin).
|
|
2006
|
-
* Custom roles are removed; built-in roles are restored to their original permissions.
|
|
2007
|
-
*
|
|
2008
|
-
* @throws ToolError if the request fails.
|
|
2009
|
-
*/
|
|
2010
|
-
async resetAdminRoles() {
|
|
2011
|
-
return await this.fetchJson(`${this.baseUrl}/admin/roles/reset`, {
|
|
2012
|
-
method: "POST",
|
|
2013
|
-
body: {},
|
|
2014
|
-
errorContext: "Reset Admin Roles"
|
|
2015
|
-
});
|
|
2016
|
-
}
|
|
2017
|
-
/**
|
|
2018
|
-
* Lists all permission scopes available to assign to roles (admin).
|
|
2019
|
-
*
|
|
2020
|
-
* @returns All permission scope definitions.
|
|
2021
|
-
* @throws ToolError if the request fails.
|
|
2022
|
-
*/
|
|
2023
|
-
async listAdminPermissions() {
|
|
2024
|
-
return await this.fetchJson(`${this.baseUrl}/admin/permissions`, {
|
|
2025
|
-
method: "GET",
|
|
2026
|
-
errorContext: "List Admin Permissions"
|
|
2027
|
-
});
|
|
2028
|
-
}
|
|
2029
|
-
/**
|
|
2030
|
-
* Creates a machine/service account that authenticates via API token (admin).
|
|
2031
|
-
*
|
|
2032
|
-
* @param body - Account name and optional description.
|
|
2033
|
-
* @returns The created system account resource.
|
|
2034
|
-
* @throws ToolError if the request fails.
|
|
2035
|
-
*/
|
|
2036
|
-
async createSystemAccount({
|
|
2037
|
-
...body
|
|
2038
|
-
}) {
|
|
2039
|
-
return await this.fetchJson(`${this.baseUrl}/admin/system-accounts`, {
|
|
2040
|
-
method: "POST",
|
|
2041
|
-
body,
|
|
2042
|
-
errorContext: "Create System Account"
|
|
2043
|
-
});
|
|
2044
|
-
}
|
|
2045
|
-
/**
|
|
2046
|
-
* Retrieves the API tokens associated with a system account (admin).
|
|
2047
|
-
*
|
|
2048
|
-
* @param params - `accountId`: UUID of the system account.
|
|
2049
|
-
* @returns Token list for use in CI/CD pipelines.
|
|
2050
|
-
* @throws ToolError if the account is not found or the request fails.
|
|
2051
|
-
*/
|
|
2052
|
-
async getSystemAccountTokens({
|
|
2053
|
-
accountId
|
|
2054
|
-
}) {
|
|
2055
|
-
return await this.fetchJson(
|
|
2056
|
-
`${this.baseUrl}/admin/system-accounts/${encodeURIComponent(accountId)}/tokens`,
|
|
2057
|
-
{
|
|
2058
|
-
method: "GET",
|
|
2059
|
-
errorContext: "Get System Account Tokens"
|
|
2060
|
-
}
|
|
2061
|
-
);
|
|
2062
|
-
}
|
|
2063
|
-
/**
|
|
2064
|
-
* Registers tools with the provided register function.
|
|
2065
|
-
*
|
|
2066
|
-
* @param register - The function used to register tools.
|
|
2067
|
-
* @param getInput - The function used to get input for tools.
|
|
2068
|
-
*/
|
|
2069
104
|
async registerTools(register, getInput) {
|
|
2070
105
|
let disablePactflowAItools = false;
|
|
2071
106
|
try {
|
|
2072
|
-
const
|
|
107
|
+
const aiApi = new AIApi(this.http, `${this.http.baseUrl}/api/ai`);
|
|
108
|
+
const entitlement = await aiApi.checkAIEntitlements();
|
|
2073
109
|
if (entitlement && !entitlement.aiEnabled) {
|
|
2074
110
|
disablePactflowAItools = true;
|
|
2075
111
|
}
|
|
@@ -2086,26 +122,26 @@ class PactflowClient {
|
|
|
2086
122
|
}
|
|
2087
123
|
const { handler, clients: _, formatResponse, ...toolParams } = tool;
|
|
2088
124
|
register(toolParams, async (args, _ctx) => {
|
|
2089
|
-
const handler_fn = this[handler];
|
|
125
|
+
const handler_fn = this.handlerMap[handler];
|
|
2090
126
|
if (typeof handler_fn !== "function") {
|
|
2091
127
|
throw new Error(`Handler '${handler}' not found on PactClient`);
|
|
2092
128
|
}
|
|
2093
129
|
let result;
|
|
2094
130
|
if (tool.paginated) {
|
|
2095
|
-
if (!this.
|
|
131
|
+
if (!this.http || !this.cache) {
|
|
2096
132
|
throw new ToolError(
|
|
2097
133
|
"PactflowClient must be configured before registering paginated tools"
|
|
2098
134
|
);
|
|
2099
135
|
}
|
|
2100
|
-
result = await withPagination(handler_fn
|
|
2101
|
-
baseUrl: this.baseUrl,
|
|
136
|
+
result = await withPagination(handler_fn, handler, args, {
|
|
137
|
+
baseUrl: this.http.baseUrl,
|
|
2102
138
|
authToken: this.requestHeaders?.Authorization,
|
|
2103
139
|
cache: this.cache
|
|
2104
140
|
});
|
|
2105
141
|
} else if (tool.enableElicitation) {
|
|
2106
|
-
result = await handler_fn
|
|
142
|
+
result = await handler_fn(args, getInput);
|
|
2107
143
|
} else {
|
|
2108
|
-
result = await handler_fn
|
|
144
|
+
result = await handler_fn(args);
|
|
2109
145
|
}
|
|
2110
146
|
if (formatResponse) {
|
|
2111
147
|
return formatResponse(result);
|
|
@@ -2116,11 +152,6 @@ class PactflowClient {
|
|
|
2116
152
|
});
|
|
2117
153
|
}
|
|
2118
154
|
}
|
|
2119
|
-
/**
|
|
2120
|
-
* Registers prompts with the provided register function.
|
|
2121
|
-
*
|
|
2122
|
-
* @param register - The function used to register prompts.
|
|
2123
|
-
*/
|
|
2124
155
|
async registerPrompts(register) {
|
|
2125
156
|
for (const prompt of PROMPTS) {
|
|
2126
157
|
register(
|