@browserstack/mcp-server 1.0.15 → 1.1.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 (53) hide show
  1. package/dist/config.js +6 -2
  2. package/dist/index.js +34 -29
  3. package/dist/lib/api.js +9 -3
  4. package/dist/lib/constants.js +6 -3
  5. package/dist/lib/device-cache.js +21 -14
  6. package/dist/lib/error.js +6 -3
  7. package/dist/lib/fuzzy.js +4 -1
  8. package/dist/lib/inmemory-store.js +4 -1
  9. package/dist/lib/instrumentation.js +18 -12
  10. package/dist/lib/local.js +35 -27
  11. package/dist/lib/utils.js +15 -6
  12. package/dist/logger.js +6 -4
  13. package/dist/tools/accessibility.js +16 -13
  14. package/dist/tools/accessiblity-utils/report-fetcher.js +14 -7
  15. package/dist/tools/accessiblity-utils/report-parser.js +11 -5
  16. package/dist/tools/accessiblity-utils/scanner.js +16 -9
  17. package/dist/tools/appautomate-utils/appautomate.js +27 -17
  18. package/dist/tools/appautomate.js +35 -29
  19. package/dist/tools/applive-utils/fuzzy-search.js +6 -3
  20. package/dist/tools/applive-utils/start-session.js +20 -14
  21. package/dist/tools/applive-utils/upload-app.js +51 -12
  22. package/dist/tools/applive.js +25 -18
  23. package/dist/tools/automate-utils/fetch-screenshots.js +14 -8
  24. package/dist/tools/automate.js +21 -14
  25. package/dist/tools/bstack-sdk.js +18 -14
  26. package/dist/tools/failurelogs-utils/app-automate.js +26 -15
  27. package/dist/tools/failurelogs-utils/automate.js +23 -13
  28. package/dist/tools/getFailureLogs.js +49 -42
  29. package/dist/tools/live-utils/desktop-filter.js +11 -8
  30. package/dist/tools/live-utils/mobile-filter.js +10 -7
  31. package/dist/tools/live-utils/start-session.js +23 -17
  32. package/dist/tools/live-utils/types.js +5 -2
  33. package/dist/tools/live-utils/version-resolver.js +4 -1
  34. package/dist/tools/live.js +29 -23
  35. package/dist/tools/observability.js +19 -12
  36. package/dist/tools/sdk-utils/constants.js +9 -3
  37. package/dist/tools/sdk-utils/instructions.js +9 -4
  38. package/dist/tools/sdk-utils/types.js +2 -1
  39. package/dist/tools/testmanagement-utils/TCG-utils/api.js +38 -26
  40. package/dist/tools/testmanagement-utils/TCG-utils/config.js +10 -5
  41. package/dist/tools/testmanagement-utils/TCG-utils/helpers.js +8 -3
  42. package/dist/tools/testmanagement-utils/TCG-utils/types.js +8 -5
  43. package/dist/tools/testmanagement-utils/add-test-result.js +24 -17
  44. package/dist/tools/testmanagement-utils/create-project-folder.js +28 -21
  45. package/dist/tools/testmanagement-utils/create-testcase.js +38 -30
  46. package/dist/tools/testmanagement-utils/create-testrun.js +30 -23
  47. package/dist/tools/testmanagement-utils/list-testcases.js +22 -15
  48. package/dist/tools/testmanagement-utils/list-testruns.js +19 -12
  49. package/dist/tools/testmanagement-utils/testcase-from-file.js +22 -16
  50. package/dist/tools/testmanagement-utils/update-testrun.js +22 -15
  51. package/dist/tools/testmanagement-utils/upload-file.js +29 -22
  52. package/dist/tools/testmanagement.js +76 -61
  53. package/package.json +1 -1
@@ -1,56 +1,64 @@
1
- import axios from "axios";
2
- import config from "../../config.js";
3
- import { z } from "zod";
4
- import { formatAxiosError } from "../../lib/error.js"; // or correct
5
- export const CreateTestCaseSchema = z.object({
6
- project_identifier: z
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CreateTestCaseSchema = void 0;
7
+ exports.sanitizeArgs = sanitizeArgs;
8
+ exports.createTestCase = createTestCase;
9
+ const axios_1 = __importDefault(require("axios"));
10
+ const config_js_1 = __importDefault(require("../../config.js"));
11
+ const zod_1 = require("zod");
12
+ const error_js_1 = require("../../lib/error.js"); // or correct
13
+ exports.CreateTestCaseSchema = zod_1.z.object({
14
+ project_identifier: zod_1.z
7
15
  .string()
8
16
  .describe("The ID of the BrowserStack project where the test case should be created. If no project identifier is provided, ask the user if they would like to create a new project using the createProjectOrFolder tool."),
9
- folder_id: z
17
+ folder_id: zod_1.z
10
18
  .string()
11
19
  .describe("The ID of the folder within the project where the test case should be created. If not provided, ask the user if they would like to create a new folder using the createProjectOrFolder tool."),
12
- name: z.string().describe("Name of the test case."),
13
- description: z
20
+ name: zod_1.z.string().describe("Name of the test case."),
21
+ description: zod_1.z
14
22
  .string()
15
23
  .optional()
16
24
  .describe("Brief description of the test case."),
17
- owner: z
25
+ owner: zod_1.z
18
26
  .string()
19
27
  .email()
20
28
  .describe("Email of the test case owner.")
21
29
  .optional(),
22
- preconditions: z
30
+ preconditions: zod_1.z
23
31
  .string()
24
32
  .optional()
25
33
  .describe("Any preconditions (HTML allowed)."),
26
- test_case_steps: z
27
- .array(z.object({
28
- step: z.string().describe("Action to perform in this step."),
29
- result: z.string().describe("Expected result of this step."),
34
+ test_case_steps: zod_1.z
35
+ .array(zod_1.z.object({
36
+ step: zod_1.z.string().describe("Action to perform in this step."),
37
+ result: zod_1.z.string().describe("Expected result of this step."),
30
38
  }))
31
39
  .describe("List of steps and expected results."),
32
- issues: z
33
- .array(z.string())
40
+ issues: zod_1.z
41
+ .array(zod_1.z.string())
34
42
  .optional()
35
43
  .describe("List of the linked Jira, Asana or Azure issues ID's. This should be strictly in array format not the string of json."),
36
- issue_tracker: z
44
+ issue_tracker: zod_1.z
37
45
  .object({
38
- name: z
46
+ name: zod_1.z
39
47
  .string()
40
48
  .describe("Issue tracker name, For example, use jira for Jira, azure for Azure DevOps, or asana for Asana."),
41
- host: z.string().url().describe("Base URL of the issue tracker."),
49
+ host: zod_1.z.string().url().describe("Base URL of the issue tracker."),
42
50
  })
43
51
  .optional(),
44
- tags: z
45
- .array(z.string())
52
+ tags: zod_1.z
53
+ .array(zod_1.z.string())
46
54
  .optional()
47
55
  .describe("Tags to attach to the test case. This should be strictly in array format not the string of json"),
48
- custom_fields: z
49
- .record(z.string(), z.string())
56
+ custom_fields: zod_1.z
57
+ .record(zod_1.z.string(), zod_1.z.string())
50
58
  .optional()
51
59
  .describe("Map of custom field names to values."),
52
60
  });
53
- export function sanitizeArgs(args) {
61
+ function sanitizeArgs(args) {
54
62
  const cleaned = { ...args };
55
63
  if (cleaned.description === null)
56
64
  delete cleaned.description;
@@ -66,13 +74,13 @@ export function sanitizeArgs(args) {
66
74
  }
67
75
  return cleaned;
68
76
  }
69
- export async function createTestCase(params) {
77
+ async function createTestCase(params) {
70
78
  const body = { test_case: params };
71
79
  try {
72
- const response = await axios.post(`https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(params.project_identifier)}/folders/${encodeURIComponent(params.folder_id)}/test-cases`, body, {
80
+ const response = await axios_1.default.post(`https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(params.project_identifier)}/folders/${encodeURIComponent(params.folder_id)}/test-cases`, body, {
73
81
  auth: {
74
- username: config.browserstackUsername,
75
- password: config.browserstackAccessKey,
82
+ username: config_js_1.default.browserstackUsername,
83
+ password: config_js_1.default.browserstackAccessKey,
76
84
  },
77
85
  headers: { "Content-Type": "application/json" },
78
86
  });
@@ -102,6 +110,6 @@ export async function createTestCase(params) {
102
110
  }
103
111
  catch (err) {
104
112
  // Delegate to our centralized Axios error formatter
105
- return formatAxiosError(err, "Failed to create test case");
113
+ return (0, error_js_1.formatAxiosError)(err, "Failed to create test case");
106
114
  }
107
115
  }
@@ -1,21 +1,28 @@
1
- import axios from "axios";
2
- import config from "../../config.js";
3
- import { z } from "zod";
4
- import { formatAxiosError } from "../../lib/error.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CreateTestRunSchema = void 0;
7
+ exports.createTestRun = createTestRun;
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const config_js_1 = __importDefault(require("../../config.js"));
10
+ const zod_1 = require("zod");
11
+ const error_js_1 = require("../../lib/error.js");
5
12
  /**
6
13
  * Schema for creating a test run.
7
14
  */
8
- export const CreateTestRunSchema = z.object({
9
- project_identifier: z
15
+ exports.CreateTestRunSchema = zod_1.z.object({
16
+ project_identifier: zod_1.z
10
17
  .string()
11
18
  .describe("Identifier of the project in which to create the test run."),
12
- test_run: z.object({
13
- name: z.string().describe("Name of the test run"),
14
- description: z
19
+ test_run: zod_1.z.object({
20
+ name: zod_1.z.string().describe("Name of the test run"),
21
+ description: zod_1.z
15
22
  .string()
16
23
  .optional()
17
24
  .describe("Brief information about the test run"),
18
- run_state: z
25
+ run_state: zod_1.z
19
26
  .enum([
20
27
  "new_run",
21
28
  "in_progress",
@@ -26,17 +33,17 @@ export const CreateTestRunSchema = z.object({
26
33
  ])
27
34
  .optional()
28
35
  .describe("State of the test run. One of new_run, in_progress, under_review, rejected, done, closed"),
29
- issues: z.array(z.string()).optional().describe("Linked issue IDs"),
30
- issue_tracker: z
31
- .object({ name: z.string(), host: z.string().url() })
36
+ issues: zod_1.z.array(zod_1.z.string()).optional().describe("Linked issue IDs"),
37
+ issue_tracker: zod_1.z
38
+ .object({ name: zod_1.z.string(), host: zod_1.z.string().url() })
32
39
  .optional()
33
40
  .describe("Issue tracker configuration"),
34
- test_cases: z
35
- .array(z.string())
41
+ test_cases: zod_1.z
42
+ .array(zod_1.z.string())
36
43
  .optional()
37
44
  .describe("List of test case IDs"),
38
- folder_ids: z
39
- .array(z.number())
45
+ folder_ids: zod_1.z
46
+ .array(zod_1.z.number())
40
47
  .optional()
41
48
  .describe("Folder IDs to include"),
42
49
  }),
@@ -44,7 +51,7 @@ export const CreateTestRunSchema = z.object({
44
51
  /**
45
52
  * Creates a test run via BrowserStack Test Management API.
46
53
  */
47
- export async function createTestRun(rawArgs) {
54
+ async function createTestRun(rawArgs) {
48
55
  try {
49
56
  const inputArgs = {
50
57
  ...rawArgs,
@@ -53,12 +60,12 @@ export async function createTestRun(rawArgs) {
53
60
  include_all: false,
54
61
  },
55
62
  };
56
- const args = CreateTestRunSchema.parse(inputArgs);
63
+ const args = exports.CreateTestRunSchema.parse(inputArgs);
57
64
  const url = `https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(args.project_identifier)}/test-runs`;
58
- const response = await axios.post(url, { test_run: args.test_run }, {
65
+ const response = await axios_1.default.post(url, { test_run: args.test_run }, {
59
66
  auth: {
60
- username: config.browserstackUsername,
61
- password: config.browserstackAccessKey,
67
+ username: config_js_1.default.browserstackUsername,
68
+ password: config_js_1.default.browserstackAccessKey,
62
69
  },
63
70
  headers: { "Content-Type": "application/json" },
64
71
  });
@@ -78,6 +85,6 @@ export async function createTestRun(rawArgs) {
78
85
  };
79
86
  }
80
87
  catch (err) {
81
- return formatAxiosError(err, "Failed to create test run");
88
+ return (0, error_js_1.formatAxiosError)(err, "Failed to create test run");
82
89
  }
83
90
  }
@@ -1,32 +1,39 @@
1
- import axios from "axios";
2
- import config from "../../config.js";
3
- import { z } from "zod";
4
- import { formatAxiosError } from "../../lib/error.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ListTestCasesSchema = void 0;
7
+ exports.listTestCases = listTestCases;
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const config_js_1 = __importDefault(require("../../config.js"));
10
+ const zod_1 = require("zod");
11
+ const error_js_1 = require("../../lib/error.js");
5
12
  /**
6
13
  * Schema for listing test cases with optional filters.
7
14
  */
8
- export const ListTestCasesSchema = z.object({
9
- project_identifier: z
15
+ exports.ListTestCasesSchema = zod_1.z.object({
16
+ project_identifier: zod_1.z
10
17
  .string()
11
18
  .describe("Identifier of the project to fetch test cases from. This id starts with a PR- and is followed by a number."),
12
- folder_id: z
19
+ folder_id: zod_1.z
13
20
  .string()
14
21
  .optional()
15
22
  .describe("If provided, only return cases in this folder."),
16
- case_type: z
23
+ case_type: zod_1.z
17
24
  .string()
18
25
  .optional()
19
26
  .describe("Comma-separated list of case types (e.g. functional,regression)."),
20
- priority: z
27
+ priority: zod_1.z
21
28
  .string()
22
29
  .optional()
23
30
  .describe("Comma-separated list of priorities (e.g. critical,medium,low)."),
24
- p: z.number().optional().describe("Page number."),
31
+ p: zod_1.z.number().optional().describe("Page number."),
25
32
  });
26
33
  /**
27
34
  * Calls BrowserStack Test Management to list test cases with filters.
28
35
  */
29
- export async function listTestCases(args) {
36
+ async function listTestCases(args) {
30
37
  try {
31
38
  // Build query string
32
39
  const params = new URLSearchParams();
@@ -39,10 +46,10 @@ export async function listTestCases(args) {
39
46
  if (args.p !== undefined)
40
47
  params.append("p", args.p.toString());
41
48
  const url = `https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(args.project_identifier)}/test-cases?${params.toString()}`;
42
- const resp = await axios.get(url, {
49
+ const resp = await axios_1.default.get(url, {
43
50
  auth: {
44
- username: config.browserstackUsername,
45
- password: config.browserstackAccessKey,
51
+ username: config_js_1.default.browserstackUsername,
52
+ password: config_js_1.default.browserstackAccessKey,
46
53
  },
47
54
  });
48
55
  const resp_data = resp.data;
@@ -78,6 +85,6 @@ export async function listTestCases(args) {
78
85
  };
79
86
  }
80
87
  catch (err) {
81
- return formatAxiosError(err, "Failed to list test cases");
88
+ return (0, error_js_1.formatAxiosError)(err, "Failed to list test cases");
82
89
  }
83
90
  }
@@ -1,15 +1,22 @@
1
- import axios from "axios";
2
- import config from "../../config.js";
3
- import { z } from "zod";
4
- import { formatAxiosError } from "../../lib/error.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ListTestRunsSchema = void 0;
7
+ exports.listTestRuns = listTestRuns;
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const config_js_1 = __importDefault(require("../../config.js"));
10
+ const zod_1 = require("zod");
11
+ const error_js_1 = require("../../lib/error.js");
5
12
  /**
6
13
  * Schema for listing test runs with optional filters.
7
14
  */
8
- export const ListTestRunsSchema = z.object({
9
- project_identifier: z
15
+ exports.ListTestRunsSchema = zod_1.z.object({
16
+ project_identifier: zod_1.z
10
17
  .string()
11
18
  .describe("Identifier of the project to fetch test runs from (usually starts with PR-)."),
12
- run_state: z
19
+ run_state: zod_1.z
13
20
  .string()
14
21
  .optional()
15
22
  .describe("Return all test runs with this state (comma-separated)"),
@@ -17,17 +24,17 @@ export const ListTestRunsSchema = z.object({
17
24
  /**
18
25
  * Fetches and formats the list of test runs for a project.
19
26
  */
20
- export async function listTestRuns(args) {
27
+ async function listTestRuns(args) {
21
28
  try {
22
29
  const params = new URLSearchParams();
23
30
  if (args.run_state) {
24
31
  params.set("run_state", args.run_state);
25
32
  }
26
33
  const url = `https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(args.project_identifier)}/test-runs?` + params.toString();
27
- const resp = await axios.get(url, {
34
+ const resp = await axios_1.default.get(url, {
28
35
  auth: {
29
- username: config.browserstackUsername,
30
- password: config.browserstackAccessKey,
36
+ username: config_js_1.default.browserstackUsername,
37
+ password: config_js_1.default.browserstackAccessKey,
31
38
  },
32
39
  });
33
40
  const data = resp.data;
@@ -56,6 +63,6 @@ export async function listTestRuns(args) {
56
63
  };
57
64
  }
58
65
  catch (err) {
59
- return formatAxiosError(err, "Failed to list test runs");
66
+ return (0, error_js_1.formatAxiosError)(err, "Failed to list test runs");
60
67
  }
61
68
  }
@@ -1,17 +1,23 @@
1
- import { fetchFormFields, triggerTestCaseGeneration, pollScenariosTestDetails, bulkCreateTestCases, } from "./TCG-utils/api.js";
2
- import { buildDefaultFieldMaps, findBooleanFieldId, } from "./TCG-utils/helpers.js";
3
- import { signedUrlMap } from "../../lib/inmemory-store.js";
4
- import logger from "../../logger.js";
5
- import { projectIdentifierToId } from "./TCG-utils/api.js";
6
- export async function createTestCasesFromFile(args, context) {
7
- logger.info(`createTestCasesFromFile called with projectId: ${args.projectReferenceId}, folderId: ${args.folderId}`);
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createTestCasesFromFile = createTestCasesFromFile;
7
+ const api_js_1 = require("./TCG-utils/api.js");
8
+ const helpers_js_1 = require("./TCG-utils/helpers.js");
9
+ const inmemory_store_js_1 = require("../../lib/inmemory-store.js");
10
+ const logger_js_1 = __importDefault(require("../../logger.js"));
11
+ const api_js_2 = require("./TCG-utils/api.js");
12
+ async function createTestCasesFromFile(args, context) {
13
+ logger_js_1.default.info(`createTestCasesFromFile called with projectId: ${args.projectReferenceId}, folderId: ${args.folderId}`);
8
14
  if (args.projectReferenceId.startsWith("PR-")) {
9
- args.projectReferenceId = await projectIdentifierToId(args.projectReferenceId);
15
+ args.projectReferenceId = await (0, api_js_2.projectIdentifierToId)(args.projectReferenceId);
10
16
  }
11
- const { default_fields, custom_fields } = await fetchFormFields(args.projectReferenceId);
12
- const fieldMaps = buildDefaultFieldMaps(default_fields);
13
- const booleanFieldId = findBooleanFieldId(custom_fields);
14
- const documentObj = signedUrlMap.get(args.documentId);
17
+ const { default_fields, custom_fields } = await (0, api_js_1.fetchFormFields)(args.projectReferenceId);
18
+ const fieldMaps = (0, helpers_js_1.buildDefaultFieldMaps)(default_fields);
19
+ const booleanFieldId = (0, helpers_js_1.findBooleanFieldId)(custom_fields);
20
+ const documentObj = inmemory_store_js_1.signedUrlMap.get(args.documentId);
15
21
  if (!documentObj) {
16
22
  return {
17
23
  content: [
@@ -27,10 +33,10 @@ export async function createTestCasesFromFile(args, context) {
27
33
  const documentId = documentObj.fileId;
28
34
  const document = documentObj.downloadUrl;
29
35
  const source = "jira-on-prem";
30
- const traceId = await triggerTestCaseGeneration(document, documentId, args.folderId, args.projectReferenceId, source);
31
- const scenariosMap = await pollScenariosTestDetails(args, traceId, context, documentId, source);
32
- const resultString = await bulkCreateTestCases(scenariosMap, args.projectReferenceId, args.folderId, fieldMaps, booleanFieldId, traceId, context, documentId);
33
- signedUrlMap.delete(args.documentId);
36
+ const traceId = await (0, api_js_1.triggerTestCaseGeneration)(document, documentId, args.folderId, args.projectReferenceId, source);
37
+ const scenariosMap = await (0, api_js_1.pollScenariosTestDetails)(args, traceId, context, documentId, source);
38
+ const resultString = await (0, api_js_1.bulkCreateTestCases)(scenariosMap, args.projectReferenceId, args.folderId, fieldMaps, booleanFieldId, traceId, context, documentId);
39
+ inmemory_store_js_1.signedUrlMap.delete(args.documentId);
34
40
  return {
35
41
  content: [
36
42
  {
@@ -1,18 +1,25 @@
1
- import axios from "axios";
2
- import config from "../../config.js";
3
- import { z } from "zod";
4
- import { formatAxiosError } from "../../lib/error.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UpdateTestRunSchema = void 0;
7
+ exports.updateTestRun = updateTestRun;
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const config_js_1 = __importDefault(require("../../config.js"));
10
+ const zod_1 = require("zod");
11
+ const error_js_1 = require("../../lib/error.js");
5
12
  /**
6
13
  * Schema for updating a test run with partial fields.
7
14
  */
8
- export const UpdateTestRunSchema = z.object({
9
- project_identifier: z
15
+ exports.UpdateTestRunSchema = zod_1.z.object({
16
+ project_identifier: zod_1.z
10
17
  .string()
11
18
  .describe("Identifier of the project (Starts with 'PR-')"),
12
- test_run_id: z.string().describe("Test run identifier (e.g., TR-678)"),
13
- test_run: z.object({
14
- name: z.string().optional().describe("New name of the test run"),
15
- run_state: z
19
+ test_run_id: zod_1.z.string().describe("Test run identifier (e.g., TR-678)"),
20
+ test_run: zod_1.z.object({
21
+ name: zod_1.z.string().optional().describe("New name of the test run"),
22
+ run_state: zod_1.z
16
23
  .enum([
17
24
  "new_run",
18
25
  "in_progress",
@@ -28,14 +35,14 @@ export const UpdateTestRunSchema = z.object({
28
35
  /**
29
36
  * Partially updates an existing test run.
30
37
  */
31
- export async function updateTestRun(args) {
38
+ async function updateTestRun(args) {
32
39
  try {
33
40
  const body = { test_run: args.test_run };
34
41
  const url = `https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(args.project_identifier)}/test-runs/${encodeURIComponent(args.test_run_id)}/update`;
35
- const resp = await axios.patch(url, body, {
42
+ const resp = await axios_1.default.patch(url, body, {
36
43
  auth: {
37
- username: config.browserstackUsername,
38
- password: config.browserstackAccessKey,
44
+ username: config_js_1.default.browserstackUsername,
45
+ password: config_js_1.default.browserstackAccessKey,
39
46
  },
40
47
  });
41
48
  const data = resp.data;
@@ -62,6 +69,6 @@ export async function updateTestRun(args) {
62
69
  };
63
70
  }
64
71
  catch (err) {
65
- return formatAxiosError(err, "Failed to update test run");
72
+ return (0, error_js_1.formatAxiosError)(err, "Failed to update test run");
66
73
  }
67
74
  }
@@ -1,31 +1,38 @@
1
- import { z } from "zod";
2
- import axios from "axios";
3
- import FormData from "form-data";
4
- import fs from "fs";
5
- import path from "path";
6
- import { v4 as uuidv4 } from "uuid";
7
- import config from "../../config.js";
8
- import { signedUrlMap } from "../../lib/inmemory-store.js";
9
- import { projectIdentifierToId } from "./TCG-utils/api.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UploadFileSchema = void 0;
7
+ exports.uploadFile = uploadFile;
8
+ const zod_1 = require("zod");
9
+ const axios_1 = __importDefault(require("axios"));
10
+ const form_data_1 = __importDefault(require("form-data"));
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const path_1 = __importDefault(require("path"));
13
+ const uuid_1 = require("uuid");
14
+ const config_js_1 = __importDefault(require("../../config.js"));
15
+ const inmemory_store_js_1 = require("../../lib/inmemory-store.js");
16
+ const api_js_1 = require("./TCG-utils/api.js");
10
17
  /**
11
18
  * Schema for the upload file tool
12
19
  */
13
- export const UploadFileSchema = z.object({
14
- project_identifier: z
20
+ exports.UploadFileSchema = zod_1.z.object({
21
+ project_identifier: zod_1.z
15
22
  .string()
16
23
  .describe("ID of the project where the file should be uploaded. Do not assume it, always ask user for it."),
17
- file_path: z
24
+ file_path: zod_1.z
18
25
  .string()
19
26
  .describe("Full path to the file that should be uploaded"),
20
27
  });
21
28
  /**
22
29
  * Uploads a file to BrowserStack Test Management and returns the signed URL.
23
30
  */
24
- export async function uploadFile(args) {
31
+ async function uploadFile(args) {
25
32
  const { project_identifier, file_path } = args;
26
33
  try {
27
34
  // Validate file exists
28
- if (!fs.existsSync(file_path)) {
35
+ if (!fs_1.default.existsSync(file_path)) {
29
36
  return {
30
37
  content: [
31
38
  {
@@ -38,14 +45,14 @@ export async function uploadFile(args) {
38
45
  };
39
46
  }
40
47
  // Get the project ID
41
- const projectIdResponse = await projectIdentifierToId(project_identifier);
42
- const formData = new FormData();
43
- formData.append("attachments[]", fs.createReadStream(file_path));
48
+ const projectIdResponse = await (0, api_js_1.projectIdentifierToId)(project_identifier);
49
+ const formData = new form_data_1.default();
50
+ formData.append("attachments[]", fs_1.default.createReadStream(file_path));
44
51
  const uploadUrl = `https://test-management.browserstack.com/api/v1/projects/${projectIdResponse}/generic/attachments/ai_uploads`;
45
- const response = await axios.post(uploadUrl, formData, {
52
+ const response = await axios_1.default.post(uploadUrl, formData, {
46
53
  headers: {
47
54
  ...formData.getHeaders(),
48
- "API-TOKEN": `${config.browserstackUsername}:${config.browserstackAccessKey}`,
55
+ "API-TOKEN": `${config_js_1.default.browserstackUsername}:${config_js_1.default.browserstackAccessKey}`,
49
56
  accept: "application/json, text/plain, */*",
50
57
  },
51
58
  });
@@ -54,13 +61,13 @@ export async function uploadFile(args) {
54
61
  response.data.generic_attachment) {
55
62
  const attachments = response.data.generic_attachment.map((attachment) => {
56
63
  // Generate a unique ID for each attachment
57
- const fileId = uuidv4();
64
+ const fileId = (0, uuid_1.v4)();
58
65
  // Store the download URL in the signedUrlMap
59
66
  const data = {
60
67
  fileId: attachment.id,
61
68
  downloadUrl: attachment.download_url,
62
69
  };
63
- signedUrlMap.set(fileId, data);
70
+ inmemory_store_js_1.signedUrlMap.set(fileId, data);
64
71
  return {
65
72
  name: attachment.name,
66
73
  documentID: fileId,
@@ -73,7 +80,7 @@ export async function uploadFile(args) {
73
80
  content: [
74
81
  {
75
82
  type: "text",
76
- text: `Successfully uploaded ${path.basename(file_path)} to BrowserStack Test Management.`,
83
+ text: `Successfully uploaded ${path_1.default.basename(file_path)} to BrowserStack Test Management.`,
77
84
  },
78
85
  {
79
86
  type: "text",