@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
package/dist/package.json.js
CHANGED
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
class AdminApi {
|
|
2
|
+
constructor(http) {
|
|
3
|
+
this.http = http;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves workspace-wide metrics.
|
|
7
|
+
*/
|
|
8
|
+
async getMetrics() {
|
|
9
|
+
return await this.http.fetch(
|
|
10
|
+
`${this.http.baseUrl}/metrics`,
|
|
11
|
+
{ method: "GET", errorContext: "Get Metrics" }
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves metrics for all teams.
|
|
16
|
+
*/
|
|
17
|
+
async getTeamMetrics() {
|
|
18
|
+
return await this.http.fetch(
|
|
19
|
+
`${this.http.baseUrl}/metrics/teams`,
|
|
20
|
+
{ method: "GET", errorContext: "Get Team Metrics" }
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Lists all secrets in the workspace.
|
|
25
|
+
*/
|
|
26
|
+
async listSecrets() {
|
|
27
|
+
return await this.http.fetch(
|
|
28
|
+
`${this.http.baseUrl}/secrets`,
|
|
29
|
+
{ method: "GET", errorContext: "List Secrets" }
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves metadata for a specific secret by UUID (value is not returned).
|
|
34
|
+
*/
|
|
35
|
+
async getSecret({ secretId }) {
|
|
36
|
+
return await this.http.fetch(
|
|
37
|
+
`${this.http.baseUrl}/secrets/${encodeURIComponent(secretId)}`,
|
|
38
|
+
{ method: "GET", errorContext: "Get Secret" }
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new secret for use in webhook configurations.
|
|
43
|
+
*/
|
|
44
|
+
async createSecret({ ...body }) {
|
|
45
|
+
return await this.http.fetch(
|
|
46
|
+
`${this.http.baseUrl}/secrets`,
|
|
47
|
+
{ method: "POST", body, errorContext: "Create Secret" }
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Replaces the value and/or description of an existing secret.
|
|
52
|
+
*/
|
|
53
|
+
async updateSecret({
|
|
54
|
+
secretId,
|
|
55
|
+
...body
|
|
56
|
+
}) {
|
|
57
|
+
return await this.http.fetch(
|
|
58
|
+
`${this.http.baseUrl}/secrets/${encodeURIComponent(secretId)}`,
|
|
59
|
+
{ method: "PUT", body, errorContext: "Update Secret" }
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Permanently deletes a secret from the workspace.
|
|
64
|
+
*/
|
|
65
|
+
async deleteSecret({ secretId }) {
|
|
66
|
+
return await this.http.fetch(
|
|
67
|
+
`${this.http.baseUrl}/secrets/${encodeURIComponent(secretId)}`,
|
|
68
|
+
{ method: "DELETE", errorContext: "Delete Secret" }
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves the profile of the currently authenticated user.
|
|
73
|
+
*/
|
|
74
|
+
async getCurrentUser() {
|
|
75
|
+
return await this.http.fetch(
|
|
76
|
+
`${this.http.baseUrl}/user`,
|
|
77
|
+
{ method: "GET", errorContext: "Get Current User" }
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Lists all API tokens associated with the current user's account.
|
|
82
|
+
*/
|
|
83
|
+
async listTokens() {
|
|
84
|
+
return await this.http.fetch(
|
|
85
|
+
`${this.http.baseUrl}/settings/tokens`,
|
|
86
|
+
{ method: "GET", errorContext: "List Tokens" }
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Regenerates (rotates) an API token, invalidating the previous value.
|
|
91
|
+
*/
|
|
92
|
+
async regenerateToken({
|
|
93
|
+
tokenId
|
|
94
|
+
}) {
|
|
95
|
+
return await this.http.fetch(
|
|
96
|
+
`${this.http.baseUrl}/settings/tokens/${encodeURIComponent(tokenId)}/regenerate`,
|
|
97
|
+
{ method: "POST", body: {}, errorContext: "Regenerate Token" }
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Retrieves UI and notification preferences for the currently authenticated user.
|
|
102
|
+
*/
|
|
103
|
+
async getUserPreferences() {
|
|
104
|
+
return await this.http.fetch(
|
|
105
|
+
`${this.http.baseUrl}/preferences/current-user`,
|
|
106
|
+
{ method: "GET", errorContext: "Get User Preferences" }
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves workspace-level system preferences and configuration.
|
|
111
|
+
*/
|
|
112
|
+
async getSystemPreferences() {
|
|
113
|
+
return await this.http.fetch(
|
|
114
|
+
`${this.http.baseUrl}/preferences/system`,
|
|
115
|
+
{ method: "GET", errorContext: "Get System Preferences" }
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves the workspace audit log with optional filtering and pagination.
|
|
120
|
+
*/
|
|
121
|
+
async getAuditLog(params) {
|
|
122
|
+
const queryParams = new URLSearchParams();
|
|
123
|
+
if (params.since) queryParams.set("since", params.since);
|
|
124
|
+
if (params.userUuid) queryParams.set("userUuid", params.userUuid);
|
|
125
|
+
if (params.type) queryParams.set("type", params.type);
|
|
126
|
+
if (params.sort) queryParams.set("sort", params.sort);
|
|
127
|
+
if (params.from) queryParams.set("from", params.from);
|
|
128
|
+
if (params.pageNumber)
|
|
129
|
+
queryParams.set("pageNumber", String(params.pageNumber));
|
|
130
|
+
if (params.pageSize) queryParams.set("pageSize", String(params.pageSize));
|
|
131
|
+
const qs = queryParams.toString();
|
|
132
|
+
return await this.http.fetch(
|
|
133
|
+
`${this.http.baseUrl}/audit${qs ? `?${qs}` : ""}`,
|
|
134
|
+
{ method: "GET", errorContext: "Get Audit Log" }
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Lists all users in the workspace with optional filtering and pagination (admin).
|
|
139
|
+
*/
|
|
140
|
+
async listAdminUsers(params) {
|
|
141
|
+
const queryParams = new URLSearchParams();
|
|
142
|
+
if (params.active !== void 0)
|
|
143
|
+
queryParams.set("active", String(params.active));
|
|
144
|
+
if (params.q) queryParams.set("q", params.q);
|
|
145
|
+
if (params.userType !== void 0)
|
|
146
|
+
queryParams.set("userType", String(params.userType));
|
|
147
|
+
if (params.page) queryParams.set("page", String(params.page));
|
|
148
|
+
if (params.size) queryParams.set("size", String(params.size));
|
|
149
|
+
const qs = queryParams.toString();
|
|
150
|
+
return await this.http.fetch(
|
|
151
|
+
`${this.http.baseUrl}/admin/users${qs ? `?${qs}` : ""}`,
|
|
152
|
+
{ method: "GET", errorContext: "List Admin Users" }
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Retrieves a user's full profile by UUID (admin).
|
|
157
|
+
*/
|
|
158
|
+
async getAdminUser({ userId }) {
|
|
159
|
+
return await this.http.fetch(
|
|
160
|
+
`${this.http.baseUrl}/admin/users/${encodeURIComponent(userId)}`,
|
|
161
|
+
{ method: "GET", errorContext: "Get Admin User" }
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Creates a new user account in the workspace (admin).
|
|
166
|
+
*/
|
|
167
|
+
async createAdminUser({
|
|
168
|
+
...body
|
|
169
|
+
}) {
|
|
170
|
+
return await this.http.fetch(
|
|
171
|
+
`${this.http.baseUrl}/admin/users`,
|
|
172
|
+
{ method: "POST", body, errorContext: "Create Admin User" }
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Replaces a user's profile (admin).
|
|
177
|
+
*/
|
|
178
|
+
async updateAdminUser({
|
|
179
|
+
userId,
|
|
180
|
+
...body
|
|
181
|
+
}) {
|
|
182
|
+
return await this.http.fetch(
|
|
183
|
+
`${this.http.baseUrl}/admin/users/${encodeURIComponent(userId)}`,
|
|
184
|
+
{ method: "PUT", body, errorContext: "Update Admin User" }
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Permanently deletes a user account from the workspace (admin).
|
|
189
|
+
*/
|
|
190
|
+
async deleteAdminUser({ userId }) {
|
|
191
|
+
return await this.http.fetch(
|
|
192
|
+
`${this.http.baseUrl}/admin/users/${encodeURIComponent(userId)}`,
|
|
193
|
+
{ method: "DELETE", errorContext: "Delete Admin User" }
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Sends invitation emails to one or more new users (admin).
|
|
198
|
+
*/
|
|
199
|
+
async inviteUsers({ users }) {
|
|
200
|
+
return await this.http.fetch(
|
|
201
|
+
`${this.http.baseUrl}/admin/users/invite-users`,
|
|
202
|
+
{ method: "POST", body: { users }, errorContext: "Invite Users" }
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Fully replaces the roles assigned to a user (admin).
|
|
207
|
+
*/
|
|
208
|
+
async setUserRoles({
|
|
209
|
+
userId,
|
|
210
|
+
roles
|
|
211
|
+
}) {
|
|
212
|
+
return await this.http.fetch(
|
|
213
|
+
`${this.http.baseUrl}/admin/users/${encodeURIComponent(userId)}/roles`,
|
|
214
|
+
{ method: "PUT", body: { roles }, errorContext: "Set User Roles" }
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Grants a single additional role to a user without affecting their existing roles (admin).
|
|
219
|
+
*/
|
|
220
|
+
async addRoleToUser({
|
|
221
|
+
userId,
|
|
222
|
+
roleId
|
|
223
|
+
}) {
|
|
224
|
+
return await this.http.fetch(
|
|
225
|
+
`${this.http.baseUrl}/admin/users/${encodeURIComponent(userId)}/roles/${encodeURIComponent(roleId)}`,
|
|
226
|
+
{ method: "PUT", body: {}, errorContext: "Add Role to User" }
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Revokes a specific role from a user without affecting their other roles (admin).
|
|
231
|
+
*/
|
|
232
|
+
async removeRoleFromUser({ userId, roleId }) {
|
|
233
|
+
return await this.http.fetch(
|
|
234
|
+
`${this.http.baseUrl}/admin/users/${encodeURIComponent(userId)}/roles/${encodeURIComponent(roleId)}`,
|
|
235
|
+
{ method: "DELETE", errorContext: "Remove Role from User" }
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Lists all teams in the workspace with optional name filtering and pagination (admin).
|
|
240
|
+
*/
|
|
241
|
+
async listAdminTeams(params) {
|
|
242
|
+
const queryParams = new URLSearchParams();
|
|
243
|
+
if (params.q) queryParams.set("q", params.q);
|
|
244
|
+
if (params.page) queryParams.set("page", String(params.page));
|
|
245
|
+
if (params.size) queryParams.set("size", String(params.size));
|
|
246
|
+
const qs = queryParams.toString();
|
|
247
|
+
return await this.http.fetch(
|
|
248
|
+
`${this.http.baseUrl}/admin/teams${qs ? `?${qs}` : ""}`,
|
|
249
|
+
{ method: "GET", errorContext: "List Admin Teams" }
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Retrieves the full configuration of a team by UUID (admin).
|
|
254
|
+
*/
|
|
255
|
+
async getAdminTeam({ teamId }) {
|
|
256
|
+
return await this.http.fetch(
|
|
257
|
+
`${this.http.baseUrl}/admin/teams/${encodeURIComponent(teamId)}`,
|
|
258
|
+
{ method: "GET", errorContext: "Get Admin Team" }
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Creates a new team in the workspace (admin).
|
|
263
|
+
*/
|
|
264
|
+
async createAdminTeam({
|
|
265
|
+
...body
|
|
266
|
+
}) {
|
|
267
|
+
return await this.http.fetch(
|
|
268
|
+
`${this.http.baseUrl}/admin/teams`,
|
|
269
|
+
{ method: "POST", body, errorContext: "Create Admin Team" }
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Fully replaces a team's configuration (admin).
|
|
274
|
+
*/
|
|
275
|
+
async updateAdminTeam({
|
|
276
|
+
teamId,
|
|
277
|
+
...body
|
|
278
|
+
}) {
|
|
279
|
+
return await this.http.fetch(
|
|
280
|
+
`${this.http.baseUrl}/admin/teams/${encodeURIComponent(teamId)}`,
|
|
281
|
+
{ method: "PUT", body, errorContext: "Update Admin Team" }
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Permanently deletes a team from the workspace (admin).
|
|
286
|
+
*/
|
|
287
|
+
async deleteAdminTeam({ teamId }) {
|
|
288
|
+
return await this.http.fetch(
|
|
289
|
+
`${this.http.baseUrl}/admin/teams/${encodeURIComponent(teamId)}`,
|
|
290
|
+
{ method: "DELETE", errorContext: "Delete Admin Team" }
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Lists all user members of a specific team (admin).
|
|
295
|
+
*/
|
|
296
|
+
async listTeamUsers({
|
|
297
|
+
teamId
|
|
298
|
+
}) {
|
|
299
|
+
return await this.http.fetch(
|
|
300
|
+
`${this.http.baseUrl}/admin/teams/${encodeURIComponent(teamId)}/users`,
|
|
301
|
+
{ method: "GET", errorContext: "List Team Users" }
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Verifies whether a specific user is a member of a team (admin).
|
|
306
|
+
*/
|
|
307
|
+
async getTeamUser({
|
|
308
|
+
teamId,
|
|
309
|
+
userId
|
|
310
|
+
}) {
|
|
311
|
+
return await this.http.fetch(
|
|
312
|
+
`${this.http.baseUrl}/admin/teams/${encodeURIComponent(teamId)}/users/${encodeURIComponent(userId)}`,
|
|
313
|
+
{ method: "GET", errorContext: "Get Team User" }
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Fully replaces the members of a team (admin).
|
|
318
|
+
*/
|
|
319
|
+
async setTeamUsers({
|
|
320
|
+
teamId,
|
|
321
|
+
uuids
|
|
322
|
+
}) {
|
|
323
|
+
return await this.http.fetch(
|
|
324
|
+
`${this.http.baseUrl}/admin/teams/${encodeURIComponent(teamId)}/users`,
|
|
325
|
+
{ method: "PUT", body: { users: uuids }, errorContext: "Set Team Users" }
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Adds or removes individual users from a team using JSON Patch semantics (admin).
|
|
330
|
+
*/
|
|
331
|
+
async patchTeamUsers({
|
|
332
|
+
teamId,
|
|
333
|
+
operations
|
|
334
|
+
}) {
|
|
335
|
+
return await this.http.fetch(
|
|
336
|
+
`${this.http.baseUrl}/admin/teams/${encodeURIComponent(teamId)}/users`,
|
|
337
|
+
{
|
|
338
|
+
method: "PATCH",
|
|
339
|
+
body: operations,
|
|
340
|
+
errorContext: "Patch Team Users"
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Removes a specific user from a team (admin).
|
|
346
|
+
*/
|
|
347
|
+
async removeUserFromTeam({ teamId, userId }) {
|
|
348
|
+
return await this.http.fetch(
|
|
349
|
+
`${this.http.baseUrl}/admin/teams/${encodeURIComponent(teamId)}/users/${encodeURIComponent(userId)}`,
|
|
350
|
+
{ method: "DELETE", errorContext: "Remove User from Team" }
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Lists all roles defined in the workspace (admin).
|
|
355
|
+
*/
|
|
356
|
+
async listAdminRoles() {
|
|
357
|
+
return await this.http.fetch(
|
|
358
|
+
`${this.http.baseUrl}/admin/roles`,
|
|
359
|
+
{ method: "GET", errorContext: "List Admin Roles" }
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Retrieves a role's name, description, and full permission set by UUID (admin).
|
|
364
|
+
*/
|
|
365
|
+
async getAdminRole({ roleId }) {
|
|
366
|
+
return await this.http.fetch(
|
|
367
|
+
`${this.http.baseUrl}/admin/roles/${encodeURIComponent(roleId)}`,
|
|
368
|
+
{ method: "GET", errorContext: "Get Admin Role" }
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Creates a custom role with a tailored set of permission scopes (admin).
|
|
373
|
+
*/
|
|
374
|
+
async createAdminRole({
|
|
375
|
+
...body
|
|
376
|
+
}) {
|
|
377
|
+
return await this.http.fetch(
|
|
378
|
+
`${this.http.baseUrl}/admin/roles`,
|
|
379
|
+
{ method: "POST", body, errorContext: "Create Admin Role" }
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Updates an existing role's name and/or permission set (admin).
|
|
384
|
+
*/
|
|
385
|
+
async updateAdminRole({
|
|
386
|
+
roleId,
|
|
387
|
+
...body
|
|
388
|
+
}) {
|
|
389
|
+
return await this.http.fetch(
|
|
390
|
+
`${this.http.baseUrl}/admin/roles/${encodeURIComponent(roleId)}`,
|
|
391
|
+
{ method: "PUT", body, errorContext: "Update Admin Role" }
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Permanently deletes a role (admin).
|
|
396
|
+
*/
|
|
397
|
+
async deleteAdminRole({ roleId }) {
|
|
398
|
+
return await this.http.fetch(
|
|
399
|
+
`${this.http.baseUrl}/admin/roles/${encodeURIComponent(roleId)}`,
|
|
400
|
+
{ method: "DELETE", errorContext: "Delete Admin Role" }
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Resets all roles to factory defaults (admin).
|
|
405
|
+
*/
|
|
406
|
+
async resetAdminRoles() {
|
|
407
|
+
return await this.http.fetch(
|
|
408
|
+
`${this.http.baseUrl}/admin/roles/reset`,
|
|
409
|
+
{ method: "POST", body: {}, errorContext: "Reset Admin Roles" }
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Lists all permission scopes available to assign to roles (admin).
|
|
414
|
+
*/
|
|
415
|
+
async listAdminPermissions() {
|
|
416
|
+
return await this.http.fetch(
|
|
417
|
+
`${this.http.baseUrl}/admin/permissions`,
|
|
418
|
+
{ method: "GET", errorContext: "List Admin Permissions" }
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Creates a machine/service account that authenticates via API token (admin).
|
|
423
|
+
*/
|
|
424
|
+
async createSystemAccount({
|
|
425
|
+
...body
|
|
426
|
+
}) {
|
|
427
|
+
return await this.http.fetch(
|
|
428
|
+
`${this.http.baseUrl}/admin/system-accounts`,
|
|
429
|
+
{ method: "POST", body, errorContext: "Create System Account" }
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Retrieves the API tokens associated with a system account (admin).
|
|
434
|
+
*/
|
|
435
|
+
async getSystemAccountTokens({
|
|
436
|
+
accountId
|
|
437
|
+
}) {
|
|
438
|
+
return await this.http.fetch(
|
|
439
|
+
`${this.http.baseUrl}/admin/system-accounts/${encodeURIComponent(accountId)}/tokens`,
|
|
440
|
+
{ method: "GET", errorContext: "Get System Account Tokens" }
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
get handlers() {
|
|
444
|
+
return {
|
|
445
|
+
getMetrics: this.getMetrics.bind(this),
|
|
446
|
+
getTeamMetrics: this.getTeamMetrics.bind(this),
|
|
447
|
+
listSecrets: this.listSecrets.bind(this),
|
|
448
|
+
getSecret: this.getSecret.bind(this),
|
|
449
|
+
createSecret: this.createSecret.bind(this),
|
|
450
|
+
updateSecret: this.updateSecret.bind(this),
|
|
451
|
+
deleteSecret: this.deleteSecret.bind(this),
|
|
452
|
+
getCurrentUser: this.getCurrentUser.bind(this),
|
|
453
|
+
listTokens: this.listTokens.bind(this),
|
|
454
|
+
regenerateToken: this.regenerateToken.bind(this),
|
|
455
|
+
getUserPreferences: this.getUserPreferences.bind(this),
|
|
456
|
+
getSystemPreferences: this.getSystemPreferences.bind(this),
|
|
457
|
+
getAuditLog: this.getAuditLog.bind(this),
|
|
458
|
+
listAdminUsers: this.listAdminUsers.bind(this),
|
|
459
|
+
getAdminUser: this.getAdminUser.bind(this),
|
|
460
|
+
createAdminUser: this.createAdminUser.bind(this),
|
|
461
|
+
updateAdminUser: this.updateAdminUser.bind(this),
|
|
462
|
+
deleteAdminUser: this.deleteAdminUser.bind(this),
|
|
463
|
+
inviteUsers: this.inviteUsers.bind(this),
|
|
464
|
+
setUserRoles: this.setUserRoles.bind(this),
|
|
465
|
+
addRoleToUser: this.addRoleToUser.bind(this),
|
|
466
|
+
removeRoleFromUser: this.removeRoleFromUser.bind(this),
|
|
467
|
+
listAdminTeams: this.listAdminTeams.bind(this),
|
|
468
|
+
getAdminTeam: this.getAdminTeam.bind(this),
|
|
469
|
+
createAdminTeam: this.createAdminTeam.bind(this),
|
|
470
|
+
updateAdminTeam: this.updateAdminTeam.bind(this),
|
|
471
|
+
deleteAdminTeam: this.deleteAdminTeam.bind(this),
|
|
472
|
+
listTeamUsers: this.listTeamUsers.bind(this),
|
|
473
|
+
getTeamUser: this.getTeamUser.bind(this),
|
|
474
|
+
setTeamUsers: this.setTeamUsers.bind(this),
|
|
475
|
+
patchTeamUsers: this.patchTeamUsers.bind(this),
|
|
476
|
+
removeUserFromTeam: this.removeUserFromTeam.bind(this),
|
|
477
|
+
listAdminRoles: this.listAdminRoles.bind(this),
|
|
478
|
+
getAdminRole: this.getAdminRole.bind(this),
|
|
479
|
+
createAdminRole: this.createAdminRole.bind(this),
|
|
480
|
+
updateAdminRole: this.updateAdminRole.bind(this),
|
|
481
|
+
deleteAdminRole: this.deleteAdminRole.bind(this),
|
|
482
|
+
resetAdminRoles: this.resetAdminRoles.bind(this),
|
|
483
|
+
listAdminPermissions: this.listAdminPermissions.bind(this),
|
|
484
|
+
createSystemAccount: this.createSystemAccount.bind(this),
|
|
485
|
+
getSystemAccountTokens: this.getSystemAccountTokens.bind(this)
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
export {
|
|
490
|
+
AdminApi
|
|
491
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { getOADMatcherRecommendations } from "./prompt-utils.js";
|
|
2
|
+
class AIApi {
|
|
3
|
+
constructor(http, aiBaseUrl) {
|
|
4
|
+
this.http = http;
|
|
5
|
+
this.aiBaseUrl = aiBaseUrl;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generate new Pact tests based on the provided input.
|
|
9
|
+
*
|
|
10
|
+
* @param toolInput The input data for the generation process.
|
|
11
|
+
* @returns The result of the generation process or a result requiring prompt execution.
|
|
12
|
+
* @throws Error if the HTTP request fails or the operation times out.
|
|
13
|
+
*/
|
|
14
|
+
async generate(toolInput, _getInput) {
|
|
15
|
+
if (toolInput.openapi?.document && (!toolInput.openapi?.matcher || Object.keys(toolInput.openapi.matcher).length === 0)) {
|
|
16
|
+
return getOADMatcherRecommendations(toolInput.openapi.document);
|
|
17
|
+
}
|
|
18
|
+
const status_response = await this.submitHttpCallback(
|
|
19
|
+
"/generate",
|
|
20
|
+
toolInput
|
|
21
|
+
);
|
|
22
|
+
return await this.pollForCompletion(
|
|
23
|
+
status_response,
|
|
24
|
+
"Generation"
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Review the provided Pact tests and suggest improvements.
|
|
29
|
+
*
|
|
30
|
+
* @param toolInput The input data for the review process.
|
|
31
|
+
* @returns The result of the review process or a result requiring prompt execution.
|
|
32
|
+
* @throws Error if the HTTP request fails or the operation times out.
|
|
33
|
+
*/
|
|
34
|
+
async review(toolInput, _getInput) {
|
|
35
|
+
if (toolInput.openapi?.document && (!toolInput.openapi?.matcher || Object.keys(toolInput.openapi.matcher).length === 0)) {
|
|
36
|
+
return getOADMatcherRecommendations(toolInput.openapi.document);
|
|
37
|
+
}
|
|
38
|
+
const status_response = await this.submitHttpCallback("/review", toolInput);
|
|
39
|
+
return await this.pollForCompletion(
|
|
40
|
+
status_response,
|
|
41
|
+
"Review Pacts"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Retrieve PactFlow AI entitlement information for the current user
|
|
46
|
+
* and organization when encountering 401 unauthorized errors.
|
|
47
|
+
* Use this to check AI entitlements and credits when AI operations fail.
|
|
48
|
+
*
|
|
49
|
+
* @returns Entitlement containing permissions, organization
|
|
50
|
+
* entitlements, and user entitlements.
|
|
51
|
+
* @throws Error if the request fails or returns a non-OK response.
|
|
52
|
+
*/
|
|
53
|
+
async checkAIEntitlements() {
|
|
54
|
+
if (this.aiBaseUrl) {
|
|
55
|
+
return await this.http.fetch(
|
|
56
|
+
`${this.aiBaseUrl}/entitlement`,
|
|
57
|
+
{
|
|
58
|
+
method: "GET",
|
|
59
|
+
errorContext: "PactFlow AI Entitlements Request"
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
} else {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Polls the given status URL with a HEAD request to check operation progress.
|
|
68
|
+
*
|
|
69
|
+
* @param statusUrl - The URL returned by the async AI operation.
|
|
70
|
+
* @returns HTTP status code and whether the operation has completed (status 200).
|
|
71
|
+
*/
|
|
72
|
+
async getStatus(statusUrl) {
|
|
73
|
+
const response = await this.http.fetchRaw(statusUrl, { method: "HEAD" });
|
|
74
|
+
return { status: response.status, isComplete: response.status === 200 };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Fetches the final result of a completed async operation.
|
|
78
|
+
*
|
|
79
|
+
* @param resultUrl - The result URL returned by the async AI operation.
|
|
80
|
+
* @returns The parsed JSON result of type T.
|
|
81
|
+
*/
|
|
82
|
+
async getResult(resultUrl) {
|
|
83
|
+
return await this.http.fetch(resultUrl);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Polls status_url every second until the operation completes or times out (120s).
|
|
87
|
+
*
|
|
88
|
+
* @param status_response - URLs returned by the initial async submission.
|
|
89
|
+
* @param operationName - Human-readable name used in error messages.
|
|
90
|
+
* @returns The parsed result of type T on success.
|
|
91
|
+
* @throws Error on non-202 status or timeout.
|
|
92
|
+
*/
|
|
93
|
+
async pollForCompletion(status_response, operationName) {
|
|
94
|
+
const startTime = Date.now();
|
|
95
|
+
const timeout = 12e4;
|
|
96
|
+
const pollInterval = 1e3;
|
|
97
|
+
while (Date.now() - startTime < timeout) {
|
|
98
|
+
const statusCheck = await this.getStatus(status_response.status_url);
|
|
99
|
+
if (statusCheck.isComplete) {
|
|
100
|
+
return await this.getResult(status_response.result_url);
|
|
101
|
+
}
|
|
102
|
+
if (statusCheck.status !== 202) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`${operationName} failed with status: ${statusCheck.status}`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
108
|
+
}
|
|
109
|
+
throw new Error(
|
|
110
|
+
`${operationName} timed out after ${timeout / 1e3} seconds`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Submits an HTTP callback request to the PactFlow AI API.
|
|
115
|
+
* @param endpoint The AI API endpoint (relative to aiBaseUrl), e.g., '/generate' or '/review'.
|
|
116
|
+
* @param body The request body specific to the AI operation.
|
|
117
|
+
* @returns StatusResponse with status_url for polling and result_url for fetching results.
|
|
118
|
+
*/
|
|
119
|
+
async submitHttpCallback(endpoint, body) {
|
|
120
|
+
return await this.http.fetch(
|
|
121
|
+
`${this.aiBaseUrl}${endpoint}`,
|
|
122
|
+
{
|
|
123
|
+
method: "POST",
|
|
124
|
+
body,
|
|
125
|
+
errorContext: `HTTP callback submission to ${endpoint}`
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
get handlers() {
|
|
130
|
+
return {
|
|
131
|
+
generate: this.generate.bind(this),
|
|
132
|
+
review: this.review.bind(this),
|
|
133
|
+
checkAIEntitlements: this.checkAIEntitlements.bind(this)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
AIApi
|
|
139
|
+
};
|