@smartbear/mcp 0.3.0 → 0.5.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.
@@ -22,8 +22,9 @@ export const ReopenConditions = [
22
22
  ];
23
23
  // --- API Class ---
24
24
  export class ErrorAPI extends BaseAPI {
25
+ static filterFields = ["url", "project_url", "events_url"];
25
26
  constructor(configuration) {
26
- super(configuration);
27
+ super(configuration, ErrorAPI.filterFields);
27
28
  }
28
29
  /**
29
30
  * View an Error on a Project
@@ -95,9 +96,41 @@ export class ErrorAPI extends BaseAPI {
95
96
  * GET /projects/{project_id}/errors
96
97
  */
97
98
  async listProjectErrors(projectId, options = {}) {
98
- const url = options.filters
99
- ? `/projects/${projectId}/errors?${toQueryString(options.filters)}`
100
- : `/projects/${projectId}/errors`;
99
+ let url = `/projects/${projectId}/errors`;
100
+ // Next links need to be used as-is to ensure results are consistent, so only the page size can be modified
101
+ if (options.next !== undefined) {
102
+ const nextUrl = new URL(options.next);
103
+ if (options.per_page !== undefined) {
104
+ nextUrl.searchParams.set('per_page', options.per_page.toString());
105
+ }
106
+ url = nextUrl.toString();
107
+ }
108
+ else {
109
+ const params = new URLSearchParams();
110
+ // Add filter parameters
111
+ if (options.filters) {
112
+ const filterParams = new URLSearchParams(toQueryString(options.filters));
113
+ filterParams.forEach((value, key) => {
114
+ params.append(key, value);
115
+ });
116
+ }
117
+ // Add pagination and sorting parameters
118
+ if (options.base !== undefined) {
119
+ params.append('base', options.base);
120
+ }
121
+ if (options.sort !== undefined) {
122
+ params.append('sort', options.sort);
123
+ }
124
+ if (options.direction !== undefined) {
125
+ params.append('direction', options.direction);
126
+ }
127
+ if (options.per_page !== undefined) {
128
+ params.append('per_page', options.per_page.toString());
129
+ }
130
+ if (params.size > 0) {
131
+ url = `/projects/${projectId}/errors?${params}`;
132
+ }
133
+ }
101
134
  return (await this.request({
102
135
  method: 'GET',
103
136
  url,
@@ -1,6 +1,7 @@
1
1
  import { BaseAPI, pickFieldsFromArray } from "./base.js";
2
2
  // --- API Class ---
3
3
  export class ProjectAPI extends BaseAPI {
4
+ static filterFields = ["errors_url", "events_url", "url", "html_url"];
4
5
  static eventFieldFields = [
5
6
  'custom',
6
7
  'display_id',
@@ -8,7 +9,7 @@ export class ProjectAPI extends BaseAPI {
8
9
  'pivot_options'
9
10
  ];
10
11
  constructor(configuration) {
11
- super(configuration);
12
+ super(configuration, ProjectAPI.filterFields);
12
13
  }
13
14
  /**
14
15
  * List the Event Fields for a Project
@@ -14,8 +14,10 @@ export function pickFieldsFromArray(arr, keys) {
14
14
  }
15
15
  export class BaseAPI {
16
16
  configuration;
17
- constructor(configuration) {
17
+ filterFields;
18
+ constructor(configuration, filterFields) {
18
19
  this.configuration = configuration;
20
+ this.filterFields = filterFields || [];
19
21
  }
20
22
  async request(options, paginate = false) {
21
23
  const headers = {
@@ -61,6 +63,21 @@ export class BaseAPI {
61
63
  if (paginate) {
62
64
  apiResponse.body = results;
63
65
  }
66
+ if (Array.isArray(apiResponse.body)) {
67
+ apiResponse.body.forEach(this.sanitizeResponse.bind(this));
68
+ }
69
+ else {
70
+ this.sanitizeResponse(apiResponse.body ?? {});
71
+ }
64
72
  return apiResponse;
65
73
  }
74
+ sanitizeResponse(data) {
75
+ if (!data)
76
+ return;
77
+ for (const key of this.filterFields) {
78
+ if (key in data) {
79
+ delete data[key];
80
+ }
81
+ }
82
+ }
66
83
  }
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Filters utility for Insight Hub API
2
+ * Filters utility for BugSnag API
3
3
  *
4
4
  * This file provides utility functions for creating filter URL parameters
5
- * based on the Insight Hub filtering specification described in the Filtering.md document.
5
+ * based on the BugSnag filtering specification described in the Filtering.md document.
6
6
  */
7
7
  import { z } from "zod";
8
8
  export const FilterValueSchema = z.object({