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