@smartbear/mcp 0.38.0 → 0.40.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/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/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/webhook-api.js +113 -0
- package/dist/pactflow/client.js +29 -1967
- package/dist/qmetry/client/auto-resolve.js +7 -0
- package/dist/qmetry/client/handlers.js +5 -2
- package/dist/qmetry/client/issues.js +8 -1
- package/dist/qmetry/client/project.js +103 -2
- package/dist/qmetry/client/requirement.js +99 -3
- package/dist/qmetry/client/testcase.js +51 -2
- package/dist/qmetry/client/testsuite.js +7 -1
- package/dist/qmetry/client/tools/issue-tools.js +1 -15
- package/dist/qmetry/client/tools/project-tools.js +2 -2
- package/dist/qmetry/client/tools/requirement-tools.js +124 -11
- package/dist/qmetry/client/tools/testcase-tools.js +116 -56
- package/dist/qmetry/client/tools/testsuite-tools.js +1 -19
- package/dist/qmetry/client/tools/udf-tools.js +15 -4
- package/dist/qmetry/client/udf.js +2 -2
- package/dist/qmetry/client.js +19 -11
- package/dist/qmetry/config/constants.js +3 -0
- package/dist/qmetry/config/rest-endpoints.js +4 -2
- package/dist/qmetry/types/ai-agent.js +8 -4
- package/dist/qmetry/types/common.js +69 -43
- package/dist/qmetry/types/requirements.js +7 -1
- package/dist/qmetry/types/testcase.js +2 -1
- package/dist/qmetry/types/udf.js +5 -12
- package/dist/swagger/client/api.js +29 -4
- package/dist/swagger/client/functional-testing-api.js +56 -27
- package/dist/swagger/client/functional-testing-tools.js +5 -5
- package/dist/swagger/client/functional-testing-types.js +75 -9
- package/dist/swagger/client/functional-testing-url-utils.js +110 -0
- package/dist/swagger/client/registry-types.js +2 -2
- package/dist/swagger/client/tools.js +2 -2
- package/dist/zephyr/client.js +2 -0
- package/dist/zephyr/common/rest-api-schemas.js +345 -4
- package/dist/zephyr/tool/folder/get-folders.js +69 -0
- package/package.json +1 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
class ContractApi {
|
|
2
|
+
constructor(http) {
|
|
3
|
+
this.http = http;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves all provider states declared by a provider's pact tests.
|
|
7
|
+
*/
|
|
8
|
+
async getProviderStates({
|
|
9
|
+
provider
|
|
10
|
+
}) {
|
|
11
|
+
const uri_encoded_provider_name = encodeURIComponent(provider);
|
|
12
|
+
return await this.http.fetch(
|
|
13
|
+
`${this.http.baseUrl}/pacts/provider/${uri_encoded_provider_name}/provider-states`,
|
|
14
|
+
{
|
|
15
|
+
method: "GET",
|
|
16
|
+
errorContext: "Get Provider States"
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Checks if a given pacticipant version is safe to deploy to a specified environment.
|
|
22
|
+
*/
|
|
23
|
+
async canIDeploy(body) {
|
|
24
|
+
const { pacticipant, version, environment } = body;
|
|
25
|
+
const queryParams = new URLSearchParams({
|
|
26
|
+
pacticipant,
|
|
27
|
+
version,
|
|
28
|
+
environment
|
|
29
|
+
});
|
|
30
|
+
const url = `${this.http.baseUrl}/can-i-deploy?${queryParams.toString()}`;
|
|
31
|
+
return await this.http.fetch(url, {
|
|
32
|
+
method: "GET",
|
|
33
|
+
errorContext: "Can-I-Deploy Request"
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves the matrix of pact verification results for the specified pacticipants.
|
|
38
|
+
*/
|
|
39
|
+
async getMatrix(body) {
|
|
40
|
+
const { q, latestby, limit } = body;
|
|
41
|
+
const queryParts = [];
|
|
42
|
+
if (latestby) {
|
|
43
|
+
queryParts.push(`latestby=${encodeURIComponent(latestby)}`);
|
|
44
|
+
}
|
|
45
|
+
if (limit !== void 0) {
|
|
46
|
+
queryParts.push(`limit=${limit}`);
|
|
47
|
+
}
|
|
48
|
+
q.forEach((selector) => {
|
|
49
|
+
queryParts.push(
|
|
50
|
+
`q[]pacticipant=${encodeURIComponent(selector.pacticipant)}`
|
|
51
|
+
);
|
|
52
|
+
if (selector.version) {
|
|
53
|
+
queryParts.push(`q[]version=${encodeURIComponent(selector.version)}`);
|
|
54
|
+
}
|
|
55
|
+
if (selector.branch) {
|
|
56
|
+
queryParts.push(`q[]branch=${encodeURIComponent(selector.branch)}`);
|
|
57
|
+
}
|
|
58
|
+
if (selector.environment) {
|
|
59
|
+
queryParts.push(
|
|
60
|
+
`q[]environment=${encodeURIComponent(selector.environment)}`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
if (selector.latest !== void 0) {
|
|
64
|
+
queryParts.push(`q[]latest=${selector.latest}`);
|
|
65
|
+
}
|
|
66
|
+
if (selector.tag) {
|
|
67
|
+
queryParts.push(`q[]tag=${encodeURIComponent(selector.tag)}`);
|
|
68
|
+
}
|
|
69
|
+
if (selector.mainBranch !== void 0) {
|
|
70
|
+
queryParts.push(`q[]mainBranch=${selector.mainBranch}`);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const url = `${this.http.baseUrl}/matrix?${queryParts.join("&")}`;
|
|
74
|
+
return await this.http.fetch(url, {
|
|
75
|
+
method: "GET",
|
|
76
|
+
errorContext: "Matrix Request"
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Publishes consumer contracts (pacts) to PactFlow.
|
|
81
|
+
*/
|
|
82
|
+
async publishContracts(body) {
|
|
83
|
+
return await this.http.fetch(
|
|
84
|
+
`${this.http.baseUrl}/contracts/publish`,
|
|
85
|
+
{
|
|
86
|
+
method: "POST",
|
|
87
|
+
body,
|
|
88
|
+
errorContext: "Publish Consumer Contracts"
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Publishes a provider OpenAPI or AsyncAPI contract and its self-verification results
|
|
94
|
+
* to PactFlow for use in Bi-Directional Contract Testing.
|
|
95
|
+
*/
|
|
96
|
+
async publishProviderContract({
|
|
97
|
+
providerName,
|
|
98
|
+
...body
|
|
99
|
+
}) {
|
|
100
|
+
return await this.http.fetch(
|
|
101
|
+
`${this.http.baseUrl}/provider-contracts/provider/${encodeURIComponent(providerName)}/publish`,
|
|
102
|
+
{ method: "POST", body, errorContext: "Publish Provider Contract" }
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Retrieves the set of consumer pacts a provider should verify in its current CI run.
|
|
107
|
+
*/
|
|
108
|
+
async getPactsForVerification({
|
|
109
|
+
providerName,
|
|
110
|
+
...body
|
|
111
|
+
}) {
|
|
112
|
+
return await this.http.fetch(
|
|
113
|
+
`${this.http.baseUrl}/pacts/provider/${encodeURIComponent(providerName)}/for-verification`,
|
|
114
|
+
{ method: "POST", body, errorContext: "Get Pacts for Verification" }
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Fetches the provider OpenAPI contract for a given provider version in BDCT.
|
|
119
|
+
*/
|
|
120
|
+
async getBiDirectionalProviderContract({
|
|
121
|
+
providerName,
|
|
122
|
+
providerVersionNumber
|
|
123
|
+
}) {
|
|
124
|
+
return await this.http.fetch(
|
|
125
|
+
`${this.http.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/provider-contract`,
|
|
126
|
+
{ method: "GET", errorContext: "Get BDCT Provider Contract" }
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Fetches the self-verification results for a provider contract version in BDCT.
|
|
131
|
+
*/
|
|
132
|
+
async getBiDirectionalProviderContractVerificationResults({
|
|
133
|
+
providerName,
|
|
134
|
+
providerVersionNumber
|
|
135
|
+
}) {
|
|
136
|
+
return await this.http.fetch(
|
|
137
|
+
`${this.http.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/provider-contract-verification-results`,
|
|
138
|
+
{
|
|
139
|
+
method: "GET",
|
|
140
|
+
errorContext: "Get BDCT Provider Contract Verification Results"
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Fetches all consumer Pact contracts relevant to a given provider version in BDCT.
|
|
146
|
+
*/
|
|
147
|
+
async getBiDirectionalConsumerContract({
|
|
148
|
+
providerName,
|
|
149
|
+
providerVersionNumber
|
|
150
|
+
}) {
|
|
151
|
+
return await this.http.fetch(
|
|
152
|
+
`${this.http.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer-contract`,
|
|
153
|
+
{ method: "GET", errorContext: "Get BDCT Consumer Contract" }
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Fetches the consumer contract verification results for a given provider version in BDCT.
|
|
158
|
+
*/
|
|
159
|
+
async getBiDirectionalConsumerContractVerificationResults({
|
|
160
|
+
providerName,
|
|
161
|
+
providerVersionNumber
|
|
162
|
+
}) {
|
|
163
|
+
return await this.http.fetch(
|
|
164
|
+
`${this.http.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer-contract-verification-results`,
|
|
165
|
+
{
|
|
166
|
+
method: "GET",
|
|
167
|
+
errorContext: "Get BDCT Consumer Contract Verification Results"
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Fetches the cross-contract verification results for a given provider version in BDCT.
|
|
173
|
+
*/
|
|
174
|
+
async getBiDirectionalCrossContractVerificationResults({
|
|
175
|
+
providerName,
|
|
176
|
+
providerVersionNumber
|
|
177
|
+
}) {
|
|
178
|
+
return await this.http.fetch(
|
|
179
|
+
`${this.http.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/cross-contract-verification-results`,
|
|
180
|
+
{
|
|
181
|
+
method: "GET",
|
|
182
|
+
errorContext: "Get BDCT Cross-Contract Verification Results"
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Fetches the consumer Pact contract for a specific consumer-provider version pair in BDCT.
|
|
188
|
+
*/
|
|
189
|
+
async getBiDirectionalConsumerContractByConsumer({
|
|
190
|
+
providerName,
|
|
191
|
+
providerVersionNumber,
|
|
192
|
+
consumerName,
|
|
193
|
+
consumerVersionNumber
|
|
194
|
+
}) {
|
|
195
|
+
return await this.http.fetch(
|
|
196
|
+
`${this.http.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer/${encodeURIComponent(consumerName)}/version/${encodeURIComponent(consumerVersionNumber)}/consumer-contract`,
|
|
197
|
+
{
|
|
198
|
+
method: "GET",
|
|
199
|
+
errorContext: "Get BDCT Consumer Contract (by consumer version)"
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Fetches the provider OpenAPI contract for a specific consumer-provider version pair in BDCT.
|
|
205
|
+
*/
|
|
206
|
+
async getBiDirectionalProviderContractByConsumer({
|
|
207
|
+
providerName,
|
|
208
|
+
providerVersionNumber,
|
|
209
|
+
consumerName,
|
|
210
|
+
consumerVersionNumber
|
|
211
|
+
}) {
|
|
212
|
+
return await this.http.fetch(
|
|
213
|
+
`${this.http.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer/${encodeURIComponent(consumerName)}/version/${encodeURIComponent(consumerVersionNumber)}/provider-contract`,
|
|
214
|
+
{
|
|
215
|
+
method: "GET",
|
|
216
|
+
errorContext: "Get BDCT Provider Contract (by consumer version)"
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Fetches the provider contract self-verification results for a specific
|
|
222
|
+
* consumer-provider version pair in BDCT.
|
|
223
|
+
*/
|
|
224
|
+
async getBiDirectionalProviderContractVerificationResultsByConsumer({
|
|
225
|
+
providerName,
|
|
226
|
+
providerVersionNumber,
|
|
227
|
+
consumerName,
|
|
228
|
+
consumerVersionNumber
|
|
229
|
+
}) {
|
|
230
|
+
return await this.http.fetch(
|
|
231
|
+
`${this.http.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer/${encodeURIComponent(consumerName)}/version/${encodeURIComponent(consumerVersionNumber)}/provider-contract-verification-results`,
|
|
232
|
+
{
|
|
233
|
+
method: "GET",
|
|
234
|
+
errorContext: "Get BDCT Provider Contract Verification Results (by consumer version)"
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Fetches the consumer contract verification results for a specific
|
|
240
|
+
* consumer-provider version pair in BDCT.
|
|
241
|
+
*/
|
|
242
|
+
async getBiDirectionalConsumerContractVerificationResultsByConsumer({
|
|
243
|
+
providerName,
|
|
244
|
+
providerVersionNumber,
|
|
245
|
+
consumerName,
|
|
246
|
+
consumerVersionNumber
|
|
247
|
+
}) {
|
|
248
|
+
return await this.http.fetch(
|
|
249
|
+
`${this.http.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer/${encodeURIComponent(consumerName)}/version/${encodeURIComponent(consumerVersionNumber)}/consumer-contract-verification-results`,
|
|
250
|
+
{
|
|
251
|
+
method: "GET",
|
|
252
|
+
errorContext: "Get BDCT Consumer Contract Verification Results (by consumer version)"
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Fetches the cross-contract verification results for a specific
|
|
258
|
+
* consumer-provider version pair in BDCT.
|
|
259
|
+
*/
|
|
260
|
+
async getBiDirectionalCrossContractVerificationResultsByConsumer({
|
|
261
|
+
providerName,
|
|
262
|
+
providerVersionNumber,
|
|
263
|
+
consumerName,
|
|
264
|
+
consumerVersionNumber
|
|
265
|
+
}) {
|
|
266
|
+
return await this.http.fetch(
|
|
267
|
+
`${this.http.baseUrl}/contracts/bi-directional/provider/${encodeURIComponent(providerName)}/version/${encodeURIComponent(providerVersionNumber)}/consumer/${encodeURIComponent(consumerName)}/version/${encodeURIComponent(consumerVersionNumber)}/cross-contract-verification-results`,
|
|
268
|
+
{
|
|
269
|
+
method: "GET",
|
|
270
|
+
errorContext: "Get BDCT Cross-Contract Verification Results (by consumer version)"
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Retrieves all consumer-provider integrations registered in the workspace.
|
|
276
|
+
*/
|
|
277
|
+
async listIntegrations() {
|
|
278
|
+
return await this.http.fetch(
|
|
279
|
+
`${this.http.baseUrl}/integrations`,
|
|
280
|
+
{
|
|
281
|
+
method: "GET",
|
|
282
|
+
errorContext: "List Integrations"
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Retrieves the integration network graph for a specific pacticipant.
|
|
288
|
+
*/
|
|
289
|
+
async getPacticipantNetwork({
|
|
290
|
+
pacticipantName
|
|
291
|
+
}) {
|
|
292
|
+
return await this.http.fetch(
|
|
293
|
+
`${this.http.baseUrl}/pacticipant/${encodeURIComponent(pacticipantName)}/network`,
|
|
294
|
+
{ method: "GET", errorContext: "Get Pacticipant Network" }
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Retrieves all integrations associated with a team.
|
|
299
|
+
*/
|
|
300
|
+
async getIntegrationsByTeam({
|
|
301
|
+
teamId
|
|
302
|
+
}) {
|
|
303
|
+
return await this.http.fetch(
|
|
304
|
+
`${this.http.baseUrl}/integrations/team/${encodeURIComponent(teamId)}`,
|
|
305
|
+
{
|
|
306
|
+
method: "GET",
|
|
307
|
+
errorContext: "Get Integrations by Team"
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Deletes the integration (pact relationship) between a specific consumer and provider.
|
|
313
|
+
*/
|
|
314
|
+
async deleteIntegration({
|
|
315
|
+
providerName,
|
|
316
|
+
consumerName
|
|
317
|
+
}) {
|
|
318
|
+
return await this.http.fetch(
|
|
319
|
+
`${this.http.baseUrl}/integrations/provider/${encodeURIComponent(providerName)}/consumer/${encodeURIComponent(consumerName)}`,
|
|
320
|
+
{ method: "DELETE", errorContext: "Delete Integration" }
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Deletes all consumer-provider integrations in the workspace. Use with caution.
|
|
325
|
+
*/
|
|
326
|
+
async deleteAllIntegrations() {
|
|
327
|
+
return await this.http.fetch(`${this.http.baseUrl}/integrations`, {
|
|
328
|
+
method: "DELETE",
|
|
329
|
+
errorContext: "Delete All Integrations"
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
get handlers() {
|
|
333
|
+
return {
|
|
334
|
+
getProviderStates: this.getProviderStates.bind(this),
|
|
335
|
+
canIDeploy: this.canIDeploy.bind(this),
|
|
336
|
+
getMatrix: this.getMatrix.bind(this),
|
|
337
|
+
publishContracts: this.publishContracts.bind(this),
|
|
338
|
+
publishProviderContract: this.publishProviderContract.bind(this),
|
|
339
|
+
getPactsForVerification: this.getPactsForVerification.bind(this),
|
|
340
|
+
getBiDirectionalProviderContract: this.getBiDirectionalProviderContract.bind(this),
|
|
341
|
+
getBiDirectionalProviderContractVerificationResults: this.getBiDirectionalProviderContractVerificationResults.bind(this),
|
|
342
|
+
getBiDirectionalConsumerContract: this.getBiDirectionalConsumerContract.bind(this),
|
|
343
|
+
getBiDirectionalConsumerContractVerificationResults: this.getBiDirectionalConsumerContractVerificationResults.bind(this),
|
|
344
|
+
getBiDirectionalCrossContractVerificationResults: this.getBiDirectionalCrossContractVerificationResults.bind(this),
|
|
345
|
+
getBiDirectionalConsumerContractByConsumer: this.getBiDirectionalConsumerContractByConsumer.bind(this),
|
|
346
|
+
getBiDirectionalProviderContractByConsumer: this.getBiDirectionalProviderContractByConsumer.bind(this),
|
|
347
|
+
getBiDirectionalProviderContractVerificationResultsByConsumer: this.getBiDirectionalProviderContractVerificationResultsByConsumer.bind(
|
|
348
|
+
this
|
|
349
|
+
),
|
|
350
|
+
getBiDirectionalConsumerContractVerificationResultsByConsumer: this.getBiDirectionalConsumerContractVerificationResultsByConsumer.bind(
|
|
351
|
+
this
|
|
352
|
+
),
|
|
353
|
+
getBiDirectionalCrossContractVerificationResultsByConsumer: this.getBiDirectionalCrossContractVerificationResultsByConsumer.bind(
|
|
354
|
+
this
|
|
355
|
+
),
|
|
356
|
+
listIntegrations: this.listIntegrations.bind(this),
|
|
357
|
+
getPacticipantNetwork: this.getPacticipantNetwork.bind(this),
|
|
358
|
+
getIntegrationsByTeam: this.getIntegrationsByTeam.bind(this),
|
|
359
|
+
deleteIntegration: this.deleteIntegration.bind(this),
|
|
360
|
+
deleteAllIntegrations: this.deleteAllIntegrations.bind(this)
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
export {
|
|
365
|
+
ContractApi
|
|
366
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
class EnvironmentApi {
|
|
2
|
+
constructor(http) {
|
|
3
|
+
this.http = http;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves all environments configured in the workspace.
|
|
7
|
+
*/
|
|
8
|
+
async listEnvironments() {
|
|
9
|
+
return await this.http.fetch(
|
|
10
|
+
`${this.http.baseUrl}/environments`,
|
|
11
|
+
{ method: "GET", errorContext: "List Environments" }
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves metadata for a specific environment by UUID.
|
|
16
|
+
*/
|
|
17
|
+
async getEnvironment({
|
|
18
|
+
environmentId
|
|
19
|
+
}) {
|
|
20
|
+
return await this.http.fetch(
|
|
21
|
+
`${this.http.baseUrl}/environments/${encodeURIComponent(environmentId)}`,
|
|
22
|
+
{ method: "GET", errorContext: "Get Environment" }
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Records that a specific version of a pacticipant has been deployed to an environment.
|
|
27
|
+
*/
|
|
28
|
+
async recordDeployment({
|
|
29
|
+
pacticipantName,
|
|
30
|
+
versionNumber,
|
|
31
|
+
environmentId,
|
|
32
|
+
applicationInstance
|
|
33
|
+
}) {
|
|
34
|
+
return await this.http.fetch(
|
|
35
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}/deployed-versions/environment/${encodeURIComponent(environmentId)}`,
|
|
36
|
+
{
|
|
37
|
+
method: "POST",
|
|
38
|
+
body: applicationInstance ? { applicationInstance } : {},
|
|
39
|
+
errorContext: "Record Deployment"
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves all versions currently deployed to a given environment.
|
|
45
|
+
*/
|
|
46
|
+
async getCurrentlyDeployed({
|
|
47
|
+
environmentId
|
|
48
|
+
}) {
|
|
49
|
+
return await this.http.fetch(
|
|
50
|
+
`${this.http.baseUrl}/environments/${encodeURIComponent(environmentId)}/deployed-versions/currently-deployed`,
|
|
51
|
+
{ method: "GET", errorContext: "Get Currently Deployed" }
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Records that a version of a pacticipant has been released to an environment.
|
|
56
|
+
*/
|
|
57
|
+
async recordRelease({
|
|
58
|
+
pacticipantName,
|
|
59
|
+
versionNumber,
|
|
60
|
+
environmentId
|
|
61
|
+
}) {
|
|
62
|
+
return await this.http.fetch(
|
|
63
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}/released-versions/environment/${encodeURIComponent(environmentId)}`,
|
|
64
|
+
{ method: "POST", body: {}, errorContext: "Record Release" }
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves all versions currently released and supported in a given environment.
|
|
69
|
+
*/
|
|
70
|
+
async getCurrentlySupported({
|
|
71
|
+
environmentId
|
|
72
|
+
}) {
|
|
73
|
+
return await this.http.fetch(
|
|
74
|
+
`${this.http.baseUrl}/environments/${encodeURIComponent(environmentId)}/released-versions/currently-supported`,
|
|
75
|
+
{ method: "GET", errorContext: "Get Currently Supported" }
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new deployment environment in the workspace.
|
|
80
|
+
*/
|
|
81
|
+
async createEnvironment({
|
|
82
|
+
...body
|
|
83
|
+
}) {
|
|
84
|
+
return await this.http.fetch(
|
|
85
|
+
`${this.http.baseUrl}/environments`,
|
|
86
|
+
{ method: "POST", body, errorContext: "Create Environment" }
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Fully replaces an environment's configuration.
|
|
91
|
+
*/
|
|
92
|
+
async updateEnvironment({
|
|
93
|
+
environmentId,
|
|
94
|
+
...body
|
|
95
|
+
}) {
|
|
96
|
+
return await this.http.fetch(
|
|
97
|
+
`${this.http.baseUrl}/environments/${encodeURIComponent(environmentId)}`,
|
|
98
|
+
{ method: "PUT", body, errorContext: "Update Environment" }
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Deletes a deployment environment from the workspace.
|
|
103
|
+
*/
|
|
104
|
+
async deleteEnvironment({
|
|
105
|
+
environmentId
|
|
106
|
+
}) {
|
|
107
|
+
return await this.http.fetch(
|
|
108
|
+
`${this.http.baseUrl}/environments/${encodeURIComponent(environmentId)}`,
|
|
109
|
+
{ method: "DELETE", errorContext: "Delete Environment" }
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Retrieves deployment records for a specific pacticipant version in a given environment.
|
|
114
|
+
*/
|
|
115
|
+
async getDeployedVersions({
|
|
116
|
+
pacticipantName,
|
|
117
|
+
versionNumber,
|
|
118
|
+
environmentId
|
|
119
|
+
}) {
|
|
120
|
+
return await this.http.fetch(
|
|
121
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}/deployed-versions/environment/${encodeURIComponent(environmentId)}`,
|
|
122
|
+
{ method: "GET", errorContext: "Get Deployed Versions" }
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Retrieves release records for a specific pacticipant version in a given environment.
|
|
127
|
+
*/
|
|
128
|
+
async getReleasedVersions({
|
|
129
|
+
pacticipantName,
|
|
130
|
+
versionNumber,
|
|
131
|
+
environmentId
|
|
132
|
+
}) {
|
|
133
|
+
return await this.http.fetch(
|
|
134
|
+
`${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/versions/${encodeURIComponent(versionNumber)}/released-versions/environment/${encodeURIComponent(environmentId)}`,
|
|
135
|
+
{ method: "GET", errorContext: "Get Released Versions" }
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
get handlers() {
|
|
139
|
+
return {
|
|
140
|
+
listEnvironments: this.listEnvironments.bind(this),
|
|
141
|
+
getEnvironment: this.getEnvironment.bind(this),
|
|
142
|
+
recordDeployment: this.recordDeployment.bind(this),
|
|
143
|
+
getCurrentlyDeployed: this.getCurrentlyDeployed.bind(this),
|
|
144
|
+
recordRelease: this.recordRelease.bind(this),
|
|
145
|
+
getCurrentlySupported: this.getCurrentlySupported.bind(this),
|
|
146
|
+
createEnvironment: this.createEnvironment.bind(this),
|
|
147
|
+
updateEnvironment: this.updateEnvironment.bind(this),
|
|
148
|
+
deleteEnvironment: this.deleteEnvironment.bind(this),
|
|
149
|
+
getDeployedVersions: this.getDeployedVersions.bind(this),
|
|
150
|
+
getReleasedVersions: this.getReleasedVersions.bind(this)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
EnvironmentApi
|
|
156
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ToolError } from "../../common/tools.js";
|
|
2
|
+
class HttpClient {
|
|
3
|
+
constructor(baseUrl, getHeaders) {
|
|
4
|
+
this.baseUrl = baseUrl;
|
|
5
|
+
this.getHeaders = getHeaders;
|
|
6
|
+
}
|
|
7
|
+
async fetch(url, options) {
|
|
8
|
+
const { method = "GET", body, errorContext = "Request" } = options ?? {};
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch(url, {
|
|
11
|
+
method,
|
|
12
|
+
headers: this.getHeaders(),
|
|
13
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
14
|
+
});
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
const errorText = await response.text().catch(() => "");
|
|
17
|
+
throw new ToolError(
|
|
18
|
+
`${errorContext} Failed - status: ${response.status} ${response.statusText}${errorText ? ` - ${errorText}` : ""}`,
|
|
19
|
+
void 0,
|
|
20
|
+
/* @__PURE__ */ new Map([["responseStatus", response.status]])
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
if (response.status === 204) {
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
26
|
+
return await response.json();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (error instanceof ToolError) {
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
32
|
+
console.error(`[${errorContext}] Unexpected error: ${error}
|
|
33
|
+
`);
|
|
34
|
+
throw new ToolError(
|
|
35
|
+
`${errorContext} Failed - ${errorMessage}`,
|
|
36
|
+
void 0,
|
|
37
|
+
/* @__PURE__ */ new Map([["responseStatus", 500]])
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async fetchRaw(url, options) {
|
|
42
|
+
return fetch(url, { headers: this.getHeaders(), ...options });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
HttpClient
|
|
47
|
+
};
|