@smartbear/mcp 0.4.0 → 0.6.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.
Files changed (31) hide show
  1. package/README.md +15 -121
  2. package/dist/{insight-hub → bugsnag}/client/api/CurrentUser.js +4 -4
  3. package/dist/{insight-hub → bugsnag}/client/api/Error.js +37 -4
  4. package/dist/bugsnag/client/api/Project.js +163 -0
  5. package/dist/{insight-hub → bugsnag}/client/api/base.js +39 -11
  6. package/dist/{insight-hub → bugsnag}/client/api/filters.js +2 -2
  7. package/dist/{insight-hub → bugsnag}/client.js +511 -29
  8. package/dist/common/info.js +1 -1
  9. package/dist/common/server.js +17 -5
  10. package/dist/index.js +11 -11
  11. package/dist/pactflow/client/ai.js +56 -6
  12. package/dist/pactflow/client/base.js +19 -1
  13. package/dist/pactflow/client/prompt-utils.js +89 -0
  14. package/dist/pactflow/client/prompts.js +133 -0
  15. package/dist/pactflow/client/tools.js +43 -2
  16. package/dist/pactflow/client/utils.js +70 -0
  17. package/dist/pactflow/client.js +192 -13
  18. package/package.json +9 -4
  19. package/dist/insight-hub/client/api/Project.js +0 -46
  20. package/dist/package.json +0 -60
  21. package/dist/tests/unit/common/server.test.js +0 -319
  22. package/dist/tests/unit/insight-hub/api-utilities.test.js +0 -31
  23. package/dist/tests/unit/insight-hub/client.test.js +0 -852
  24. package/dist/tests/unit/insight-hub/filters.test.js +0 -93
  25. package/dist/tests/unit/pactflow/ai.test.js +0 -21
  26. package/dist/tests/unit/pactflow/client.test.js +0 -67
  27. package/dist/tests/unit/pactflow/tools.test.js +0 -34
  28. package/dist/vitest.config.js +0 -57
  29. /package/dist/{insight-hub → bugsnag}/client/api/index.js +0 -0
  30. /package/dist/{insight-hub → bugsnag}/client/configuration.js +0 -0
  31. /package/dist/{insight-hub → bugsnag}/client/index.js +0 -0
@@ -1,93 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { equals, notEquals, empty, relativeTime, isoTime, toUrlSearchParams } from '../../../insight-hub/client/api/filters.js';
3
- describe('Filter Utilities', () => {
4
- describe('equals', () => {
5
- it('should create eq filter for string value', () => {
6
- const result = equals('test-value');
7
- expect(result).toEqual({ type: 'eq', value: 'test-value' });
8
- });
9
- it('should create eq filter for number value', () => {
10
- const result = equals(42);
11
- expect(result).toEqual({ type: 'eq', value: 42 });
12
- });
13
- });
14
- describe('notEquals', () => {
15
- it('should create ne filter for string value', () => {
16
- const result = notEquals('test-value');
17
- expect(result).toEqual({ type: 'ne', value: 'test-value' });
18
- });
19
- it('should create ne filter for number value', () => {
20
- const result = notEquals(42);
21
- expect(result).toEqual({ type: 'ne', value: 42 });
22
- });
23
- });
24
- describe('empty', () => {
25
- it('should create empty filter for true', () => {
26
- const result = empty(true);
27
- expect(result).toEqual({ type: 'empty', value: 'true' });
28
- });
29
- it('should create empty filter for false', () => {
30
- const result = empty(false);
31
- expect(result).toEqual({ type: 'empty', value: 'false' });
32
- });
33
- });
34
- describe('relativeTime', () => {
35
- it('should create relative time filter with hours', () => {
36
- const result = relativeTime(24, 'h');
37
- expect(result).toEqual({ type: 'eq', value: '24h' });
38
- });
39
- it('should create relative time filter with days', () => {
40
- const result = relativeTime(7, 'd');
41
- expect(result).toEqual({ type: 'eq', value: '7d' });
42
- });
43
- });
44
- describe('isoTime', () => {
45
- it('should create ISO time filter from date', () => {
46
- const date = new Date('2023-01-01T12:00:00.000Z');
47
- const result = isoTime(date);
48
- expect(result).toEqual({ type: 'eq', value: '2023-01-01T12:00:00.000Z' });
49
- });
50
- });
51
- describe('toUrlSearchParams', () => {
52
- it('should convert simple filter object to URL params', () => {
53
- const filters = {
54
- 'error.status': [{ type: 'eq', value: 'open' }],
55
- 'user.email': [{ type: 'ne', value: 'test@example.com' }]
56
- };
57
- const result = toUrlSearchParams(filters);
58
- expect(result.get('filters[error.status][][type]')).toBe('eq');
59
- expect(result.get('filters[error.status][][value]')).toBe('open');
60
- expect(result.get('filters[user.email][][type]')).toBe('ne');
61
- expect(result.get('filters[user.email][][value]')).toBe('test@example.com');
62
- });
63
- it('should handle multiple filters for same field', () => {
64
- const filters = {
65
- 'error.status': [
66
- { type: 'eq', value: 'open' },
67
- { type: 'eq', value: 'in_progress' }
68
- ]
69
- };
70
- const result = toUrlSearchParams(filters);
71
- const allEntries = Array.from(result.entries());
72
- // Should have entries for both filter values
73
- const statusFilters = allEntries.filter(([key]) => key.includes('error.status'));
74
- expect(statusFilters.length).toBeGreaterThan(2); // type and value for each filter
75
- });
76
- it('should handle empty filter object', () => {
77
- const filters = {};
78
- const result = toUrlSearchParams(filters);
79
- expect(result.toString()).toBe('');
80
- });
81
- it('should handle complex filter scenarios', () => {
82
- const filters = {
83
- 'event.since': [{ type: 'eq', value: '7d' }],
84
- 'error.status': [{ type: 'ne', value: 'resolved' }],
85
- 'user.id': [{ type: 'empty', value: 'false' }]
86
- };
87
- const result = toUrlSearchParams(filters);
88
- expect(result.get('filters[event.since][][value]')).toBe('7d');
89
- expect(result.get('filters[error.status][][value]')).toBe('resolved');
90
- expect(result.get('filters[user.id][][value]')).toBe('false');
91
- });
92
- });
93
- });
@@ -1,21 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { RefineInputSchema } from "../../../pactflow/client/ai.js";
3
- describe("AI zod schemas validation tests", () => {
4
- it("Parses RefineInputSchema with partial input", () => {
5
- const result = RefineInputSchema.safeParse({
6
- pactTests: {
7
- filename: "test.js",
8
- language: "javascript",
9
- body: "describe('API', () => { it('works', () => { }); });"
10
- }
11
- });
12
- expect(result.success).toBe(true);
13
- expect(result.data).toEqual({
14
- pactTests: {
15
- filename: "test.js",
16
- language: "javascript",
17
- body: "describe('API', () => { it('works', () => { }); });"
18
- }
19
- });
20
- });
21
- });
@@ -1,67 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { PactflowClient } from "../../../pactflow/client.js";
3
- import * as toolsModule from "../../../pactflow/client/tools.js";
4
- describe("PactflowClient.registerTools", () => {
5
- const mockRegister = vi.fn();
6
- const mockGetInput = vi.fn();
7
- beforeEach(() => {
8
- vi.resetAllMocks();
9
- });
10
- it("registers only tools matching the given clientType", () => {
11
- // Arrange — mock TOOLS with multiple client types
12
- const fakeTools = [
13
- {
14
- title: "tool1",
15
- summary: "summary1",
16
- purpose: "purpose1",
17
- parameters: [],
18
- handler: "generate",
19
- clients: ["pactflow"], // should be registered
20
- },
21
- {
22
- title: "tool2",
23
- summary: "summary2",
24
- purpose: "purpose2",
25
- parameters: [],
26
- handler: "generate",
27
- clients: ["pact_broker"], // should NOT be registered
28
- },
29
- ];
30
- vi.spyOn(toolsModule, "TOOLS", "get").mockReturnValue(fakeTools);
31
- const client = new PactflowClient("token", "https://example.com", "pactflow");
32
- client.registerTools(mockRegister, mockGetInput);
33
- expect(mockRegister).toHaveBeenCalledTimes(1);
34
- expect(mockRegister.mock.calls[0][0].title).toBe("tool1");
35
- expect(mockRegister.mock.calls[0][0].summary).toBe("summary1");
36
- });
37
- it("registers no tools if none match the clientType", () => {
38
- const fakeTools = [
39
- {
40
- title: "tool2",
41
- summary: "summary2",
42
- purpose: "purpose2",
43
- parameters: [],
44
- handler: "generate",
45
- clients: ["pact_broker"],
46
- },
47
- ];
48
- vi.spyOn(toolsModule, "TOOLS", "get").mockReturnValue(fakeTools);
49
- const client = new PactflowClient("token", "https://example.com", "pactflow");
50
- client.registerTools(mockRegister, mockGetInput);
51
- expect(mockRegister).not.toHaveBeenCalled();
52
- });
53
- it("sets correct headers for pactflow", () => {
54
- const client = new PactflowClient("my-token", "https://example.com", "pactflow");
55
- expect(client["headers"]).toEqual(expect.objectContaining({
56
- Authorization: expect.stringContaining("Bearer my-token"),
57
- "Content-Type": expect.stringContaining("application/json"),
58
- }));
59
- });
60
- it("sets correct headers for pact_broker", () => {
61
- const client = new PactflowClient({ username: "user", password: "pass" }, "https://example.com", "pact_broker");
62
- expect(client["headers"]).toEqual(expect.objectContaining({
63
- Authorization: expect.stringContaining(`Basic ${Buffer.from("user:pass").toString("base64")}`),
64
- "Content-Type": expect.stringContaining("application/json"),
65
- }));
66
- });
67
- });
@@ -1,34 +0,0 @@
1
- import { TOOLS } from "../../../pactflow/client/tools.js";
2
- import { describe, it, expect } from 'vitest';
3
- describe("TOOLS definition for 'Generate Pact Tests'", () => {
4
- it("defines the generate pact tests tool with correct metadata", () => {
5
- const tool = TOOLS.find((t) => t.title === "Generate Pact Tests");
6
- expect(tool).toBeDefined();
7
- expect(tool?.summary).toMatch(/Generate Pact tests using PactFlow AI/);
8
- expect(tool?.clients).toEqual(["pactflow"]);
9
- expect(tool?.handler).toBe("generate");
10
- });
11
- it("enforces presence of matcher when openapi input is provided", () => {
12
- const tool = TOOLS.find((t) => t.title === "Generate Pact Tests");
13
- const schema = tool?.zodSchema;
14
- const openapiSchema = schema.shape["openapi"];
15
- expect(openapiSchema).toBeDefined();
16
- const invalidOpenapi = {
17
- openapi: {
18
- document: {
19
- openapi: "3.0.0",
20
- paths: {},
21
- },
22
- },
23
- };
24
- expect(() => openapiSchema?.parse(invalidOpenapi.openapi)).toThrow(/matcher/);
25
- });
26
- it("rejects unsupported language values in the language field", () => {
27
- const tool = TOOLS.find((t) => t.title === "Generate Pact Tests");
28
- const schema = tool?.zodSchema;
29
- const languageSchema = schema.shape["language"];
30
- expect(languageSchema).toBeDefined();
31
- const invalidData = "ruby"; // not in enum
32
- expect(() => languageSchema?.parse(invalidData)).toThrow(/Invalid enum value/);
33
- });
34
- });
@@ -1,57 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
- export default defineConfig({
3
- test: {
4
- globals: true,
5
- environment: 'node',
6
- coverage: {
7
- provider: 'v8',
8
- reporter: ['text', 'json', 'json-summary', 'html', 'lcov'],
9
- exclude: [
10
- 'dist/**',
11
- 'node_modules/**',
12
- 'tests/**',
13
- '*.config.*',
14
- '**/*.d.ts',
15
- // Auto-generated API client files
16
- 'insight-hub/client/api/*.ts',
17
- 'insight-hub/client/index.ts',
18
- 'insight-hub/client/configuration.ts',
19
- // Main entry point (tested via integration)
20
- 'index.ts',
21
- // Other client implementations (not currently tested)
22
- 'api-hub/client.ts',
23
- 'reflect/client.ts',
24
- // Utility modules
25
- 'common/bugsnag.ts',
26
- 'common/types.ts'
27
- ],
28
- // Coverage thresholds for business logic only
29
- thresholds: {
30
- lines: 75,
31
- functions: 75,
32
- branches: 85,
33
- statements: 75,
34
- // Per-file thresholds for core files
35
- perFile: false
36
- },
37
- // Generate more detailed reports
38
- reportOnFailure: true,
39
- all: true,
40
- // Clean coverage directory before tests
41
- clean: true,
42
- // Include source map support
43
- reportsDirectory: './coverage'
44
- },
45
- // Include TypeScript files
46
- include: ['tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
47
- // Setup files
48
- // Placeholder for future setup files. Remove if not needed.
49
- setupFiles: []
50
- },
51
- // Resolve imports correctly for ESM
52
- resolve: {
53
- alias: {
54
- '@': new URL('./src', import.meta.url).pathname
55
- }
56
- }
57
- });
File without changes