@smartbear/mcp 0.10.0 → 0.12.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/README.md +10 -8
- package/dist/bugsnag/client/api/Error.js +1 -1
- package/dist/bugsnag/client/api/Project.js +152 -0
- package/dist/bugsnag/client/api/api.js +130 -3
- package/dist/bugsnag/client/api/base.js +19 -0
- package/dist/bugsnag/client/api/index.js +2 -0
- package/dist/bugsnag/client/filters.js +0 -6
- package/dist/bugsnag/client.js +739 -378
- package/dist/bugsnag/input-schemas.js +59 -0
- package/dist/collaborator/client.js +18 -5
- package/dist/common/cache.js +63 -0
- package/dist/common/client-registry.js +128 -0
- package/dist/common/register-clients.js +31 -0
- package/dist/common/server.js +30 -9
- package/dist/common/transport-http.js +377 -0
- package/dist/common/transport-stdio.js +48 -0
- package/dist/index.js +20 -70
- package/dist/pactflow/client.js +39 -19
- package/dist/qmetry/client/auto-resolve.js +10 -0
- package/dist/qmetry/client/automation.js +171 -0
- package/dist/qmetry/client/handlers.js +9 -2
- package/dist/qmetry/client/project.js +87 -1
- package/dist/qmetry/client/testsuite.js +37 -1
- package/dist/qmetry/client/tools/automation-tools.js +290 -0
- package/dist/qmetry/client/tools/index.js +3 -0
- package/dist/qmetry/client/tools/issue-tools.js +1 -1
- package/dist/qmetry/client/tools/project-tools.js +311 -1
- package/dist/qmetry/client/tools/requirement-tools.js +1 -1
- package/dist/qmetry/client/tools/testcase-tools.js +311 -39
- package/dist/qmetry/client/tools/testsuite-tools.js +337 -23
- package/dist/qmetry/client.js +24 -9
- package/dist/qmetry/config/constants.js +6 -0
- package/dist/qmetry/config/rest-endpoints.js +8 -0
- package/dist/qmetry/types/automation.js +8 -0
- package/dist/qmetry/types/common.js +299 -4
- package/dist/qmetry/types/issues.js +5 -0
- package/dist/qmetry/types/project.js +13 -0
- package/dist/qmetry/types/requirements.js +5 -0
- package/dist/qmetry/types/testcase.js +5 -0
- package/dist/qmetry/types/testsuite.js +9 -0
- package/dist/reflect/client.js +10 -4
- package/dist/{api-hub → swagger}/client/api.js +94 -37
- package/dist/{api-hub → swagger}/client/configuration.js +4 -2
- package/dist/{api-hub → swagger}/client/index.js +2 -2
- package/dist/{api-hub → swagger}/client/portal-types.js +7 -6
- package/dist/{api-hub → swagger}/client/registry-types.js +26 -0
- package/dist/{api-hub → swagger}/client/tools.js +19 -20
- package/dist/{api-hub → swagger}/client.js +51 -39
- package/dist/swagger/config-utils.js +18 -0
- package/dist/tests/unit/bugsnag/utils/factories.js +86 -0
- package/dist/zephyr/client.js +44 -8
- package/dist/zephyr/common/rest-api-schemas.js +79 -78
- package/dist/zephyr/tool/environment/get-environments.js +68 -0
- package/dist/zephyr/tool/priority/get-priorities.js +43 -0
- package/dist/zephyr/tool/status/get-statuses.js +49 -0
- package/dist/zephyr/tool/test-case/get-test-case.js +39 -0
- package/dist/zephyr/tool/test-case/get-test-cases.js +64 -0
- package/dist/zephyr/tool/test-cycle/get-test-cycle.js +39 -0
- package/dist/zephyr/tool/test-cycle/get-test-cycles.js +2 -2
- package/dist/zephyr/tool/test-execution/get-test-execution.js +39 -0
- package/dist/zephyr/tool/test-execution/get-test-executions.js +45 -0
- package/package.json +4 -3
- /package/dist/{api-hub → swagger}/client/user-management-types.js +0 -0
|
@@ -89,7 +89,8 @@ export const CreateTableOfContentsArgsSchema = z.object({
|
|
|
89
89
|
.describe("Content configuration for the table of contents item")
|
|
90
90
|
.refine((content) => {
|
|
91
91
|
if (content?.type === "apiUrl") {
|
|
92
|
-
return content.url?.endsWith("/swagger.json")
|
|
92
|
+
return (content.url?.endsWith("/swagger.json") ||
|
|
93
|
+
content.url?.endsWith("/swagger.yaml"));
|
|
93
94
|
}
|
|
94
95
|
return true;
|
|
95
96
|
}, {
|
|
@@ -171,6 +172,11 @@ export const CreateProductArgsSchema = PortalArgsSchema.extend({
|
|
|
171
172
|
type: z
|
|
172
173
|
.string()
|
|
173
174
|
.describe("Product creation type - 'new' to create from scratch or 'copy' to duplicate an existing product"),
|
|
175
|
+
productId: z
|
|
176
|
+
.string()
|
|
177
|
+
.uuid()
|
|
178
|
+
.optional()
|
|
179
|
+
.describe("Source product UUID to copy from - required when type is 'copy', specifies which existing product to duplicate. Omit when type is 'new'"),
|
|
174
180
|
name: z
|
|
175
181
|
.string()
|
|
176
182
|
.describe("Product display name - will be shown to users in the portal navigation and product listings (3-40 characters)"),
|
|
@@ -241,11 +247,6 @@ export const UpdateDocumentArgsSchema = z.object({
|
|
|
241
247
|
.optional()
|
|
242
248
|
.describe("Content type - 'html' for HTML content or 'markdown' for Markdown content"),
|
|
243
249
|
});
|
|
244
|
-
export const DeleteDocumentArgsSchema = z.object({
|
|
245
|
-
documentId: z
|
|
246
|
-
.string()
|
|
247
|
-
.describe("Document UUID - unique identifier for the document to delete"),
|
|
248
|
-
});
|
|
249
250
|
export const DeleteTableOfContentsArgsSchema = z.object({
|
|
250
251
|
tableOfContentsId: z
|
|
251
252
|
.string()
|
|
@@ -75,3 +75,29 @@ export const ScanStandardizationParamsSchema = z.object({
|
|
|
75
75
|
.string()
|
|
76
76
|
.describe("API definition content (OpenAPI/AsyncAPI specification in JSON or YAML format) to scan for standardization errors"),
|
|
77
77
|
});
|
|
78
|
+
export const CreateApiFromPromptParamsSchema = z.object({
|
|
79
|
+
owner: z
|
|
80
|
+
.string()
|
|
81
|
+
.describe("API owner (organization or user, case-sensitive)"),
|
|
82
|
+
apiName: z.string().describe("API name"),
|
|
83
|
+
prompt: z
|
|
84
|
+
.string()
|
|
85
|
+
.describe("The prompt describing the desired API functionality (e.g., 'Create a RESTful API for managing a pet store with endpoints for pets, orders, and inventory')"),
|
|
86
|
+
specType: z
|
|
87
|
+
.enum([
|
|
88
|
+
"openapi20",
|
|
89
|
+
"openapi30x",
|
|
90
|
+
"openapi31x",
|
|
91
|
+
"asyncapi2xx",
|
|
92
|
+
"asyncapi30x",
|
|
93
|
+
])
|
|
94
|
+
.default("openapi30x")
|
|
95
|
+
.describe("Specification type for the generated API definition. Use: 'openapi20' for OpenAPI 2.0, 'openapi30x' for OpenAPI 3.0.x (default), 'openapi31x' for OpenAPI 3.1.x, 'asyncapi2xx' for AsyncAPI 2.x, 'asyncapi30x' for AsyncAPI 3.0.x"),
|
|
96
|
+
});
|
|
97
|
+
export const StandardizeApiParamsSchema = z.object({
|
|
98
|
+
owner: z
|
|
99
|
+
.string()
|
|
100
|
+
.describe("API owner (organization or user, case-sensitive)"),
|
|
101
|
+
api: z.string().describe("API name (case-sensitive)"),
|
|
102
|
+
version: z.string().describe("Version identifier"),
|
|
103
|
+
});
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TOOLS
|
|
3
3
|
*
|
|
4
|
-
* Defines tool configurations for
|
|
4
|
+
* Defines tool configurations for Swagger operations.
|
|
5
5
|
* Each tool includes parameters, descriptions, and handler method names.
|
|
6
6
|
* This follows the pattern established in the pactflow module.
|
|
7
7
|
*/
|
|
8
|
-
import { CreatePortalArgsSchema, CreateProductArgsSchema, CreateTableOfContentsArgsSchema,
|
|
9
|
-
import { ApiDefinitionParamsSchema, ApiSearchParamsSchema, CreateApiFromTemplateParamsSchema, CreateApiParamsSchema, ScanStandardizationParamsSchema, } from "./registry-types.js";
|
|
8
|
+
import { CreatePortalArgsSchema, CreateProductArgsSchema, CreateTableOfContentsArgsSchema, DeleteTableOfContentsArgsSchema, GetDocumentArgsSchema, GetProductSectionsArgsSchema, GetTableOfContentsArgsSchema, PortalArgsSchema, ProductArgsSchema, PublishProductArgsSchema, UpdateDocumentArgsSchema, UpdatePortalArgsSchema, UpdateProductArgsSchema, } from "./portal-types.js";
|
|
9
|
+
import { ApiDefinitionParamsSchema, ApiSearchParamsSchema, CreateApiFromPromptParamsSchema, CreateApiFromTemplateParamsSchema, CreateApiParamsSchema, ScanStandardizationParamsSchema, StandardizeApiParamsSchema, } from "./registry-types.js";
|
|
10
10
|
import { OrganizationsQuerySchema } from "./user-management-types.js";
|
|
11
11
|
export const TOOLS = [
|
|
12
12
|
{
|
|
13
13
|
title: "List Portals",
|
|
14
|
-
summary: "Search for available portals within
|
|
14
|
+
summary: "Search for available portals within Swagger. Only portals where you have at least a designer role, either at the product level or organization level, are returned.",
|
|
15
15
|
parameters: [],
|
|
16
16
|
handler: "getPortals",
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
title: "Create Portal",
|
|
20
|
-
summary: "Create a new portal within
|
|
20
|
+
summary: "Create a new portal within Swagger.",
|
|
21
21
|
inputSchema: CreatePortalArgsSchema,
|
|
22
22
|
handler: "createPortal",
|
|
23
23
|
},
|
|
@@ -27,13 +27,6 @@ export const TOOLS = [
|
|
|
27
27
|
inputSchema: PortalArgsSchema,
|
|
28
28
|
handler: "getPortal",
|
|
29
29
|
},
|
|
30
|
-
{
|
|
31
|
-
title: "Delete Portal",
|
|
32
|
-
summary: "Delete a specific portal.",
|
|
33
|
-
inputSchema: PortalArgsSchema,
|
|
34
|
-
handler: "deletePortal",
|
|
35
|
-
formatResponse: () => "Portal deleted successfully.",
|
|
36
|
-
},
|
|
37
30
|
{
|
|
38
31
|
title: "Update Portal",
|
|
39
32
|
summary: "Update a specific portal's configuration.",
|
|
@@ -114,12 +107,6 @@ export const TOOLS = [
|
|
|
114
107
|
inputSchema: UpdateDocumentArgsSchema,
|
|
115
108
|
handler: "updateDocument",
|
|
116
109
|
},
|
|
117
|
-
{
|
|
118
|
-
title: "Delete Document",
|
|
119
|
-
summary: "Delete a document by its ID. This will permanently remove the document content.",
|
|
120
|
-
inputSchema: DeleteDocumentArgsSchema,
|
|
121
|
-
handler: "deleteDocument",
|
|
122
|
-
},
|
|
123
110
|
// Registry API tools for SwaggerHub Design functionality
|
|
124
111
|
{
|
|
125
112
|
title: "Search APIs and Domains",
|
|
@@ -135,7 +122,7 @@ export const TOOLS = [
|
|
|
135
122
|
},
|
|
136
123
|
{
|
|
137
124
|
title: "Create or Update API",
|
|
138
|
-
summary: "Create a new API or update an existing API in SwaggerHub Registry for
|
|
125
|
+
summary: "Create a new API or update an existing API in SwaggerHub Registry for Swagger Studio. The API specification type (OpenAPI, AsyncAPI) is automatically detected from the definition content. APIs are always created with fixed values: version 1.0.0, private visibility, and automock disabled (these values cannot be changed). Returns HTTP 201 for creation, HTTP 200 for update. Response includes 'operation' field indicating whether it was a 'create' or 'update' operation along with API details and SwaggerHub URL.",
|
|
139
126
|
inputSchema: CreateApiParamsSchema,
|
|
140
127
|
handler: "createOrUpdateApi",
|
|
141
128
|
},
|
|
@@ -154,8 +141,20 @@ export const TOOLS = [
|
|
|
154
141
|
},
|
|
155
142
|
{
|
|
156
143
|
title: "Scan API Standardization",
|
|
157
|
-
summary: "Run a standardization scan against an API definition using the organization's standardization
|
|
144
|
+
summary: "Run a standardization scan against an API definition using the organization's governance and standardization rules. Accepts a YAML or JSON OpenAPI/AsyncAPI definition and returns a list of standardization errors and validation issues. Use this tool when users ask to validate, scan, or check API governance or standardization.",
|
|
158
145
|
inputSchema: ScanStandardizationParamsSchema,
|
|
159
146
|
handler: "scanStandardization",
|
|
160
147
|
},
|
|
148
|
+
{
|
|
149
|
+
title: "Create API from Prompt using SmartBear AI",
|
|
150
|
+
summary: "Generate and save an API definition based on a prompt using SmartBear AI. This tool automatically applies organization governance and standardization rules during API generation. The specType parameter determines the format of the generated definition. Use: 'openapi20' for OpenAPI 2.0, 'openapi30x' for OpenAPI 3.0.x, 'openapi31x' for OpenAPI 3.1.x, 'asyncapi2xx' for AsyncAPI 2.x, 'asyncapi30x' for AsyncAPI 3.0.x. Use this tool when creating APIs that comply with governance policies or when generating APIs from natural language descriptions. Use this tool when users ask to create, generate, or design APIs with governance or standardization requirements. Returns HTTP 201 for creation, HTTP 200 for update. Response includes 'operation' field indicating whether it was a 'create' or 'update' operation along with API details and SwaggerHub URL.",
|
|
151
|
+
inputSchema: CreateApiFromPromptParamsSchema,
|
|
152
|
+
handler: "createApiFromPrompt",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
title: "Standardize API",
|
|
156
|
+
summary: "Standardize and fix an API definition using AI to ensure compliance with governance policies. Scans the API definition for standardization errors and automatically fixes them using SmartBear AI. If errors are found, they will be sent to SmartBear AI to generate a corrected definition, which is then saved back to the registry. Returns the number of errors found and the fixed definition if successful. Use this tool when users ask to standardize, fix, govern, or ensure governance compliance of APIs.",
|
|
157
|
+
inputSchema: StandardizeApiParamsSchema,
|
|
158
|
+
handler: "standardizeApi",
|
|
159
|
+
},
|
|
161
160
|
];
|
|
@@ -1,95 +1,107 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { MCP_SERVER_NAME, MCP_SERVER_VERSION } from "../common/info.js";
|
|
2
|
-
|
|
3
|
+
// Apply backward compatibility for API_HUB_API_KEY
|
|
4
|
+
import "./config-utils.js";
|
|
5
|
+
import { SwaggerAPI, SwaggerConfiguration, TOOLS, } from "./client/index.js";
|
|
6
|
+
const ConfigurationSchema = z.object({
|
|
7
|
+
api_key: z.string().describe("Swagger API key for authentication"),
|
|
8
|
+
});
|
|
3
9
|
// Tool definitions for API Hub API client
|
|
4
|
-
export class
|
|
5
|
-
config;
|
|
10
|
+
export class SwaggerClient {
|
|
6
11
|
api;
|
|
7
|
-
name = "
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
name = "Swagger";
|
|
13
|
+
toolPrefix = "swagger";
|
|
14
|
+
configPrefix = "Swagger";
|
|
15
|
+
config = ConfigurationSchema;
|
|
16
|
+
async configure(_server, config, _cache) {
|
|
17
|
+
this.api = new SwaggerAPI(new SwaggerConfiguration({ token: config.api_key }), `${MCP_SERVER_NAME}/${MCP_SERVER_VERSION}`);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
getApi() {
|
|
21
|
+
if (!this.api)
|
|
22
|
+
throw new Error("Client not configured");
|
|
23
|
+
return this.api;
|
|
24
|
+
}
|
|
25
|
+
// Delegate API methods to the SwaggerAPI instance
|
|
14
26
|
async getPortals() {
|
|
15
|
-
return this.
|
|
27
|
+
return this.getApi().getPortals();
|
|
16
28
|
}
|
|
17
29
|
async createPortal(body) {
|
|
18
|
-
return this.
|
|
30
|
+
return this.getApi().createPortal(body);
|
|
19
31
|
}
|
|
20
32
|
async getPortal(args) {
|
|
21
|
-
return this.
|
|
22
|
-
}
|
|
23
|
-
async deletePortal(args) {
|
|
24
|
-
return this.api.deletePortal(args.portalId);
|
|
33
|
+
return this.getApi().getPortal(args.portalId);
|
|
25
34
|
}
|
|
26
35
|
async updatePortal(args) {
|
|
27
36
|
const { portalId, ...body } = args;
|
|
28
|
-
return this.
|
|
37
|
+
return this.getApi().updatePortal(portalId, body);
|
|
29
38
|
}
|
|
30
39
|
async getPortalProducts(args) {
|
|
31
|
-
return this.
|
|
40
|
+
return this.getApi().getPortalProducts(args.portalId);
|
|
32
41
|
}
|
|
33
42
|
async createPortalProduct(args) {
|
|
34
43
|
const { portalId, ...body } = args;
|
|
35
|
-
return this.
|
|
44
|
+
return this.getApi().createPortalProduct(portalId, body);
|
|
36
45
|
}
|
|
37
46
|
async getPortalProduct(args) {
|
|
38
|
-
return this.
|
|
47
|
+
return this.getApi().getPortalProduct(args.productId);
|
|
39
48
|
}
|
|
40
49
|
async deletePortalProduct(args) {
|
|
41
|
-
return this.
|
|
50
|
+
return this.getApi().deletePortalProduct(args.productId);
|
|
42
51
|
}
|
|
43
52
|
async updatePortalProduct(args) {
|
|
44
53
|
const { productId, ...body } = args;
|
|
45
|
-
return this.
|
|
54
|
+
return this.getApi().updatePortalProduct(productId, body);
|
|
46
55
|
}
|
|
47
56
|
async publishPortalProduct(args) {
|
|
48
57
|
const { productId, preview } = args;
|
|
49
|
-
return this.
|
|
58
|
+
return this.getApi().publishPortalProduct(productId, preview);
|
|
50
59
|
}
|
|
51
60
|
async getPortalProductSections(args) {
|
|
52
61
|
const { productId, ...params } = args;
|
|
53
|
-
return this.
|
|
62
|
+
return this.getApi().getPortalProductSections(productId, params);
|
|
54
63
|
}
|
|
55
64
|
async createTableOfContents(args) {
|
|
56
65
|
const { sectionId, ...body } = args;
|
|
57
|
-
return this.
|
|
66
|
+
return this.getApi().createTableOfContents(sectionId, body);
|
|
58
67
|
}
|
|
59
68
|
async getTableOfContents(args) {
|
|
60
|
-
return this.
|
|
69
|
+
return this.getApi().getTableOfContents(args);
|
|
61
70
|
}
|
|
62
71
|
async getDocument(args) {
|
|
63
|
-
return this.
|
|
72
|
+
return this.getApi().getDocument(args);
|
|
64
73
|
}
|
|
65
74
|
async updateDocument(args) {
|
|
66
|
-
return this.
|
|
67
|
-
}
|
|
68
|
-
async deleteDocument(args) {
|
|
69
|
-
return this.api.deleteDocument(args);
|
|
75
|
+
return this.getApi().updateDocument(args);
|
|
70
76
|
}
|
|
71
77
|
async deleteTableOfContents(args) {
|
|
72
|
-
return this.
|
|
78
|
+
return this.getApi().deleteTableOfContents(args);
|
|
73
79
|
}
|
|
74
80
|
// Registry API methods for SwaggerHub Design functionality
|
|
75
81
|
async searchApis(args = {}) {
|
|
76
|
-
return this.
|
|
82
|
+
return this.getApi().searchApis(args);
|
|
77
83
|
}
|
|
78
84
|
async getApiDefinition(args) {
|
|
79
|
-
return this.
|
|
85
|
+
return this.getApi().getApiDefinition(args);
|
|
80
86
|
}
|
|
81
87
|
async createOrUpdateApi(args) {
|
|
82
|
-
return this.
|
|
88
|
+
return this.getApi().createOrUpdateApi(args);
|
|
83
89
|
}
|
|
84
90
|
async createApiFromTemplate(args) {
|
|
85
|
-
return this.
|
|
91
|
+
return this.getApi().createApiFromTemplate(args);
|
|
86
92
|
}
|
|
87
93
|
// User Management API methods
|
|
88
94
|
async getOrganizations(args) {
|
|
89
|
-
return this.
|
|
95
|
+
return this.getApi().getOrganizations(args);
|
|
96
|
+
}
|
|
97
|
+
async createApiFromPrompt(args) {
|
|
98
|
+
return this.getApi().createApiFromPrompt(args);
|
|
90
99
|
}
|
|
91
100
|
async scanStandardization(args) {
|
|
92
|
-
return this.
|
|
101
|
+
return this.getApi().scanStandardization(args);
|
|
102
|
+
}
|
|
103
|
+
async standardizeApi(args) {
|
|
104
|
+
return this.getApi().standardizeApi(args);
|
|
93
105
|
}
|
|
94
106
|
registerTools(register, _getInput) {
|
|
95
107
|
TOOLS.forEach((tool) => {
|
|
@@ -99,7 +111,7 @@ export class ApiHubClient {
|
|
|
99
111
|
// Dynamic method invocation
|
|
100
112
|
const handlerFn = this[handler];
|
|
101
113
|
if (typeof handlerFn !== "function") {
|
|
102
|
-
throw new Error(`Handler '${handler}' not found on
|
|
114
|
+
throw new Error(`Handler '${handler}' not found on SwaggerClient`);
|
|
103
115
|
}
|
|
104
116
|
const result = await handlerFn.call(this, args);
|
|
105
117
|
// Use custom formatter if available, otherwise return JSON
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration utilities for Swagger client
|
|
3
|
+
* Handles backward compatibility with legacy environment variables
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Apply API_HUB_API_KEY fallback to SWAGGER_API_KEY if needed
|
|
7
|
+
* This modifies process.env to enable backward compatibility
|
|
8
|
+
* @deprecated API_HUB_API_KEY support - TODO: Remove after migration period (May 2026)
|
|
9
|
+
*/
|
|
10
|
+
export function applySwaggerApiKeyFallback() {
|
|
11
|
+
// If SWAGGER_API_KEY is not set but API_HUB_API_KEY is, use the legacy variable
|
|
12
|
+
if (!process.env.SWAGGER_API_KEY && process.env.API_HUB_API_KEY) {
|
|
13
|
+
console.warn("[Swagger] API_HUB_API_KEY is deprecated. Please use SWAGGER_API_KEY instead.");
|
|
14
|
+
process.env.SWAGGER_API_KEY = process.env.API_HUB_API_KEY;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// Apply the fallback immediately when this module is imported
|
|
18
|
+
applySwaggerApiKeyFallback();
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export function getMockOrganization(id, name, slug, extra = {}) {
|
|
2
|
+
return {
|
|
3
|
+
id,
|
|
4
|
+
name,
|
|
5
|
+
slug: slug ?? name.toLowerCase().replace(/\s+/g, "-"),
|
|
6
|
+
updatedAt: new Date(),
|
|
7
|
+
createdAt: new Date(),
|
|
8
|
+
autoUpgrade: false,
|
|
9
|
+
managedByPlatformServices: false,
|
|
10
|
+
...extra,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function getMockProject(id, name, apiKey, extra = {}) {
|
|
14
|
+
return { id, name, apiKey, ...extra };
|
|
15
|
+
}
|
|
16
|
+
export function getMockEventField(displayId, extra = {}) {
|
|
17
|
+
return {
|
|
18
|
+
displayId: displayId,
|
|
19
|
+
custom: false,
|
|
20
|
+
filterOptions: { name: "filter" },
|
|
21
|
+
pivotOptions: {},
|
|
22
|
+
...extra,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function getMockError(id, extra = {}) {
|
|
26
|
+
return { id, ...extra };
|
|
27
|
+
}
|
|
28
|
+
export function getMockEvent(id, extra = {}) {
|
|
29
|
+
return { id, ...extra };
|
|
30
|
+
}
|
|
31
|
+
export function getMockReleaseGroup(id, extra = {}) {
|
|
32
|
+
return {
|
|
33
|
+
id,
|
|
34
|
+
projectId: "proj-1",
|
|
35
|
+
releaseStageName: "production",
|
|
36
|
+
appVersion: "1.0.0",
|
|
37
|
+
firstReleasedAt: new Date().toISOString(),
|
|
38
|
+
firstReleaseId: "release-1",
|
|
39
|
+
releasesCount: 1,
|
|
40
|
+
hasSecondaryVersions: false,
|
|
41
|
+
totalSessionsCount: 0,
|
|
42
|
+
topReleaseGroup: false,
|
|
43
|
+
visible: true,
|
|
44
|
+
...extra,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function getMockRelease(id, extra = {}) {
|
|
48
|
+
return { id, ...extra };
|
|
49
|
+
}
|
|
50
|
+
export function getMockSpanGroup(id, name, category, extra = {}) {
|
|
51
|
+
return {
|
|
52
|
+
id: `span-group-${id}`,
|
|
53
|
+
name: `span-name-${name}`,
|
|
54
|
+
displayName: name,
|
|
55
|
+
category: category,
|
|
56
|
+
...extra,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function getMockSpan(traceId, id, name, category, isFirstClass = true, extra = {}) {
|
|
60
|
+
return {
|
|
61
|
+
traceId,
|
|
62
|
+
id: `span-${id}`,
|
|
63
|
+
name: `span-name-${name}`,
|
|
64
|
+
displayName: name,
|
|
65
|
+
category: category,
|
|
66
|
+
isFirstClass: isFirstClass,
|
|
67
|
+
duration: Math.round(Math.random() * 1000),
|
|
68
|
+
timestamp: new Date(Date.now()).toISOString(),
|
|
69
|
+
startTime: new Date(Date.now() - 1000).toISOString(),
|
|
70
|
+
timeAdjustmentType: "unadjusted",
|
|
71
|
+
...extra,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function getMockTrace(name, type) {
|
|
75
|
+
return {
|
|
76
|
+
displayId: name,
|
|
77
|
+
fieldType: type,
|
|
78
|
+
filterOptions: {
|
|
79
|
+
name: name,
|
|
80
|
+
description: "Cached field",
|
|
81
|
+
searchable: true,
|
|
82
|
+
matchTypes: ["eq"],
|
|
83
|
+
},
|
|
84
|
+
custom: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
package/dist/zephyr/client.js
CHANGED
|
@@ -1,22 +1,58 @@
|
|
|
1
|
+
import z from "zod";
|
|
1
2
|
import { ApiClient } from "./common/api-client.js";
|
|
3
|
+
import { GetEnvironments } from "./tool/environment/get-environments.js";
|
|
4
|
+
import { GetPriorities } from "./tool/priority/get-priorities.js";
|
|
2
5
|
import { GetProject } from "./tool/project/get-project.js";
|
|
3
6
|
import { GetProjects } from "./tool/project/get-projects.js";
|
|
7
|
+
import { GetStatuses } from "./tool/status/get-statuses.js";
|
|
8
|
+
import { GetTestCase } from "./tool/test-case/get-test-case.js";
|
|
9
|
+
import { GetTestCases } from "./tool/test-case/get-test-cases.js";
|
|
10
|
+
import { GetTestCycle } from "./tool/test-cycle/get-test-cycle.js";
|
|
4
11
|
import { GetTestCycles } from "./tool/test-cycle/get-test-cycles.js";
|
|
12
|
+
import { GetTestExecution } from "./tool/test-execution/get-test-execution.js";
|
|
13
|
+
import { GetTestExecutions } from "./tool/test-execution/get-test-executions.js";
|
|
14
|
+
const BASE_URL_DEFAULT = "https://api.zephyrscale.smartbear.com/v2";
|
|
15
|
+
const ConfigurationSchema = z.object({
|
|
16
|
+
api_token: z.string().describe("Zephyr Scale API token for authentication"),
|
|
17
|
+
base_url: z
|
|
18
|
+
.string()
|
|
19
|
+
.url()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Zephyr Scale API base URL")
|
|
22
|
+
.default(BASE_URL_DEFAULT),
|
|
23
|
+
});
|
|
5
24
|
export class ZephyrClient {
|
|
6
25
|
apiClient;
|
|
7
26
|
name = "Zephyr";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
27
|
+
toolPrefix = "zephyr";
|
|
28
|
+
configPrefix = "Zephyr";
|
|
29
|
+
config = ConfigurationSchema;
|
|
30
|
+
async configure(_server, config, _cache) {
|
|
31
|
+
this.apiClient = new ApiClient(config.api_token, config.base_url || BASE_URL_DEFAULT);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
getApiClient() {
|
|
35
|
+
if (!this.apiClient)
|
|
36
|
+
throw new Error("Client not configured");
|
|
37
|
+
return this.apiClient;
|
|
11
38
|
}
|
|
12
39
|
registerTools(register, _getInput) {
|
|
40
|
+
const apiClient = this.getApiClient();
|
|
13
41
|
const tools = [
|
|
14
|
-
new GetProjects(
|
|
15
|
-
new GetProject(
|
|
16
|
-
new GetTestCycles(
|
|
42
|
+
new GetProjects(apiClient),
|
|
43
|
+
new GetProject(apiClient),
|
|
44
|
+
new GetTestCycles(apiClient),
|
|
45
|
+
new GetTestCycle(apiClient),
|
|
46
|
+
new GetPriorities(apiClient),
|
|
47
|
+
new GetStatuses(apiClient),
|
|
48
|
+
new GetTestCases(apiClient),
|
|
49
|
+
new GetEnvironments(apiClient),
|
|
50
|
+
new GetTestCase(apiClient),
|
|
51
|
+
new GetTestExecution(apiClient),
|
|
52
|
+
new GetTestExecutions(apiClient),
|
|
17
53
|
];
|
|
18
|
-
|
|
54
|
+
for (const tool of tools) {
|
|
19
55
|
register(tool.specification, tool.handle);
|
|
20
|
-
}
|
|
56
|
+
}
|
|
21
57
|
}
|
|
22
58
|
}
|