ebay-mcp 1.8.8 → 1.8.9

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 (73) hide show
  1. package/build/api/client-trading.js +11 -7
  2. package/build/api/client.js +2 -1
  3. package/build/api/communication/negotiation.js +1 -1
  4. package/build/api/communication/notification.js +62 -191
  5. package/build/api/communication/shared.js +4 -15
  6. package/build/api/listing-management/inventory.js +94 -387
  7. package/build/api/listing-metadata/metadata.js +42 -306
  8. package/build/api/other/compliance.js +1 -1
  9. package/build/api/shared/query-params.js +8 -22
  10. package/build/api/shared/request.js +140 -0
  11. package/build/api/trading/trading.js +30 -4
  12. package/build/auth/credential-session.js +166 -0
  13. package/build/auth/oauth.js +35 -93
  14. package/build/auth/token-verifier.js +3 -0
  15. package/build/config/environment.js +9 -0
  16. package/build/index.js +8 -52
  17. package/build/schemas/account-management/account.js +90 -0
  18. package/build/schemas/communication/messages.js +84 -0
  19. package/build/schemas/fulfillment/orders.js +36 -0
  20. package/build/schemas/inventory-management/inventory.js +96 -4
  21. package/build/schemas/marketing/marketing.js +462 -0
  22. package/build/schemas/metadata/metadata.js +213 -0
  23. package/build/scripts/auto-setup.js +3 -6
  24. package/build/scripts/dev-sync.js +12 -3
  25. package/build/scripts/download-specs.js +1 -8
  26. package/build/scripts/setup.js +80 -27
  27. package/build/server-http.d.ts +1 -8
  28. package/build/server-http.js +48 -348
  29. package/build/tools/contracts.js +69 -0
  30. package/build/tools/definitions/account.js +1 -0
  31. package/build/tools/definitions/analytics.js +1 -0
  32. package/build/tools/definitions/communication.js +1 -0
  33. package/build/tools/definitions/developer.js +1 -0
  34. package/build/tools/definitions/fulfillment.js +1 -0
  35. package/build/tools/definitions/index.js +1 -1
  36. package/build/tools/definitions/inventory.js +1 -0
  37. package/build/tools/definitions/marketing.js +9 -1
  38. package/build/tools/definitions/metadata.js +1 -0
  39. package/build/tools/definitions/other.js +2 -0
  40. package/build/tools/definitions/taxonomy.js +1 -0
  41. package/build/tools/definitions/token-management.js +1 -0
  42. package/build/tools/definitions/trading.js +3 -7
  43. package/build/tools/index.js +4 -1200
  44. package/build/tools/registry.js +82 -0
  45. package/build/tools/schemas.js +47 -0
  46. package/build/tools/tool-definitions.js +11 -0
  47. package/build/tools/tool-handlers/account.js +123 -0
  48. package/build/tools/tool-handlers/analytics.js +15 -0
  49. package/build/tools/tool-handlers/chat.js +76 -0
  50. package/build/tools/tool-handlers/communication.js +161 -0
  51. package/build/tools/tool-handlers/developer.js +40 -0
  52. package/build/tools/tool-handlers/fulfillment.js +54 -0
  53. package/build/tools/tool-handlers/index.js +29 -0
  54. package/build/tools/tool-handlers/inventory.js +111 -0
  55. package/build/tools/tool-handlers/marketing.js +384 -0
  56. package/build/tools/tool-handlers/metadata.js +72 -0
  57. package/build/tools/tool-handlers/other.js +120 -0
  58. package/build/tools/tool-handlers/taxonomy.js +15 -0
  59. package/build/tools/tool-handlers/token-management.js +246 -0
  60. package/build/tools/tool-handlers/trading.js +21 -0
  61. package/build/tools/tool-handlers/types.js +1 -0
  62. package/build/types/ebay.js +6 -0
  63. package/build/utils/account-management/account.js +0 -7
  64. package/build/utils/api-status-feed.js +1 -3
  65. package/build/utils/date-converter.js +3 -0
  66. package/build/utils/llm-client-detector.js +1 -1
  67. package/build/utils/logger.js +9 -1
  68. package/build/utils/security-checker.js +1 -1
  69. package/build/utils/setup-wizard.js +17 -2
  70. package/build/utils/token-utils.js +9 -0
  71. package/build/utils/version.js +15 -0
  72. package/package.json +2 -4
  73. package/build/tools/definitions/account-with-schemas.js +0 -170
@@ -4,6 +4,9 @@ import { apiLogger } from '../utils/logger.js';
4
4
  import { isRecord } from '../utils/type-guards.js';
5
5
  const COMPAT_LEVEL = '1451';
6
6
  const SITE_ID = '0';
7
+ /**
8
+ * XML-based client for eBay Trading API calls that are not covered by REST APIs.
9
+ */
7
10
  export class TradingApiClient {
8
11
  restClient;
9
12
  baseUrl;
@@ -12,10 +15,7 @@ export class TradingApiClient {
12
15
  constructor(restClient) {
13
16
  this.restClient = restClient;
14
17
  const env = restClient.getConfig().environment;
15
- this.baseUrl =
16
- env === 'sandbox'
17
- ? 'https://api.sandbox.ebay.com'
18
- : 'https://api.ebay.com';
18
+ this.baseUrl = env === 'sandbox' ? 'https://api.sandbox.ebay.com' : 'https://api.ebay.com';
19
19
  this.parser = new XMLParser({
20
20
  ignoreAttributes: false,
21
21
  removeNSPrefix: true,
@@ -43,9 +43,15 @@ export class TradingApiClient {
43
43
  suppressEmptyNode: true,
44
44
  });
45
45
  }
46
+ /**
47
+ * Return the Trading API base URL for the configured eBay environment.
48
+ */
46
49
  getTradingBaseUrl() {
47
50
  return this.baseUrl;
48
51
  }
52
+ /**
53
+ * Execute a named Trading API call with XML request/response conversion.
54
+ */
49
55
  async execute(callName, params) {
50
56
  const token = await this.restClient.getOAuthClient().getAccessToken();
51
57
  const requestTag = `${callName}Request`;
@@ -100,9 +106,7 @@ export class TradingApiClient {
100
106
  if (result.Ack === 'Failure' || result.Ack === 'PartialFailure') {
101
107
  const errors = result.Errors;
102
108
  const firstError = Array.isArray(errors) ? errors[0] : errors;
103
- const message = firstError?.ShortMessage ||
104
- firstError?.LongMessage ||
105
- 'Unknown Trading API error';
109
+ const message = firstError?.ShortMessage || firstError?.LongMessage || 'Unknown Trading API error';
106
110
  throw new Error(message);
107
111
  }
108
112
  return result;
@@ -240,8 +240,9 @@ export class EbayApiClient {
240
240
  /**
241
241
  * Set user access and refresh tokens
242
242
  */
243
- async setUserTokens(accessToken, refreshToken, accessTokenExpiry, refreshTokenExpiry) {
243
+ setUserTokens(accessToken, refreshToken, accessTokenExpiry, refreshTokenExpiry) {
244
244
  this.authClient.setUserTokens(accessToken, refreshToken, accessTokenExpiry, refreshTokenExpiry);
245
+ return Promise.resolve();
245
246
  }
246
247
  /**
247
248
  * Get token information for debugging
@@ -62,7 +62,7 @@ export class NegotiationApi {
62
62
  * @throws Error if the request fails
63
63
  */
64
64
  async getOffersForListing(filter, limit, offset) {
65
- return this.getOffersToBuyers(filter, limit, offset);
65
+ return await this.getOffersToBuyers(filter, limit, offset);
66
66
  }
67
67
  /**
68
68
  * Get a specific offer
@@ -1,4 +1,4 @@
1
- import { assertRequiredString, getPathWithContextError } from './shared.js';
1
+ import { buildContinuationParams, deleteWithApiError, getWithApiError, postWithApiError, putWithApiError, requireObject, requireString, } from '../shared/request.js';
2
2
  /**
3
3
  * Notification API - Event notifications and subscriptions
4
4
  * Based on: docs/sell-apps/communication/commerce_notification_v1_oas3.json
@@ -9,53 +9,54 @@ export class NotificationApi {
9
9
  constructor(client) {
10
10
  this.client = client;
11
11
  }
12
+ path(endpoint) {
13
+ return `${this.basePath}${endpoint}`;
14
+ }
15
+ async get(endpoint, failureMessage, params) {
16
+ return await getWithApiError(this.client, this.path(endpoint), failureMessage, params);
17
+ }
18
+ async post(endpoint, failureMessage, body) {
19
+ return await postWithApiError(this.client, this.path(endpoint), failureMessage, body);
20
+ }
21
+ async put(endpoint, failureMessage, body) {
22
+ return await putWithApiError(this.client, this.path(endpoint), failureMessage, body);
23
+ }
24
+ async delete(endpoint, failureMessage) {
25
+ return await deleteWithApiError(this.client, this.path(endpoint), failureMessage);
26
+ }
27
+ async getContinuation(endpoint, failureMessage, limit, continuationToken) {
28
+ return await this.get(endpoint, failureMessage, buildContinuationParams(limit, continuationToken));
29
+ }
12
30
  /**
13
31
  * Get public key for validating notifications
14
32
  * @param publicKeyId Public key identifier.
15
33
  * @throws Error if required parameters are missing or invalid
16
34
  */
17
35
  async getPublicKey(publicKeyId) {
18
- assertRequiredString(publicKeyId, 'publicKeyId');
19
- return await getPathWithContextError(this.client, `${this.basePath}/public_key/${publicKeyId}`, 'Failed to get public key');
36
+ requireString(publicKeyId, 'publicKeyId');
37
+ return await this.get(`/public_key/${publicKeyId}`, 'Failed to get public key');
20
38
  }
21
39
  /**
22
40
  * Get notification config
23
41
  * @throws Error if the request fails
24
42
  */
25
43
  async getConfig() {
26
- return await getPathWithContextError(this.client, `${this.basePath}/config`, 'Failed to get config');
44
+ return await this.get('/config', 'Failed to get config');
27
45
  }
28
46
  /**
29
47
  * Update notification config
30
48
  * @throws Error if required parameters are missing or invalid
31
49
  */
32
50
  async updateConfig(config) {
33
- if (!config || typeof config !== 'object') {
34
- throw new Error('config is required and must be an object');
35
- }
36
- try {
37
- return await this.client.put(`${this.basePath}/config`, config);
38
- }
39
- catch (error) {
40
- throw new Error(`Failed to update config: ${error instanceof Error ? error.message : 'Unknown error'}`);
41
- }
51
+ requireObject(config, 'config');
52
+ return await this.put('/config', 'Failed to update config', config);
42
53
  }
43
54
  /**
44
55
  * Get all destinations (paginated)
45
56
  * @throws Error if the request fails
46
57
  */
47
58
  async getDestinations(limit, continuationToken) {
48
- const params = {};
49
- if (limit !== undefined)
50
- params.limit = String(limit);
51
- if (continuationToken)
52
- params.continuation_token = continuationToken;
53
- try {
54
- return await this.client.get(`${this.basePath}/destination`, params);
55
- }
56
- catch (error) {
57
- throw new Error(`Failed to get destinations: ${error instanceof Error ? error.message : 'Unknown error'}`);
58
- }
59
+ return await this.getContinuation('/destination', 'Failed to get destinations', limit, continuationToken);
59
60
  }
60
61
  /**
61
62
  * Get destination
@@ -63,56 +64,33 @@ export class NotificationApi {
63
64
  * @throws Error if required parameters are missing or invalid
64
65
  */
65
66
  async getDestination(destinationId) {
66
- assertRequiredString(destinationId, 'destinationId');
67
- return await getPathWithContextError(this.client, `${this.basePath}/destination/${destinationId}`, 'Failed to get destination');
67
+ requireString(destinationId, 'destinationId');
68
+ return await this.get(`/destination/${destinationId}`, 'Failed to get destination');
68
69
  }
69
70
  /**
70
71
  * Create destination
71
72
  * @throws Error if required parameters are missing or invalid
72
73
  */
73
74
  async createDestination(destination) {
74
- if (!destination || typeof destination !== 'object') {
75
- throw new Error('destination is required and must be an object');
76
- }
77
- try {
78
- return await this.client.post(`${this.basePath}/destination`, destination);
79
- }
80
- catch (error) {
81
- throw new Error(`Failed to create destination: ${error instanceof Error ? error.message : 'Unknown error'}`);
82
- }
75
+ requireObject(destination, 'destination');
76
+ return await this.post('/destination', 'Failed to create destination', destination);
83
77
  }
84
78
  /**
85
79
  * Update destination
86
80
  * @throws Error if required parameters are missing or invalid
87
81
  */
88
82
  async updateDestination(destinationId, destination) {
89
- if (!destinationId || typeof destinationId !== 'string') {
90
- throw new Error('destinationId is required and must be a string');
91
- }
92
- if (!destination || typeof destination !== 'object') {
93
- throw new Error('destination is required and must be an object');
94
- }
95
- try {
96
- return await this.client.put(`${this.basePath}/destination/${destinationId}`, destination);
97
- }
98
- catch (error) {
99
- throw new Error(`Failed to update destination: ${error instanceof Error ? error.message : 'Unknown error'}`);
100
- }
83
+ requireString(destinationId, 'destinationId');
84
+ requireObject(destination, 'destination');
85
+ return await this.put(`/destination/${destinationId}`, 'Failed to update destination', destination);
101
86
  }
102
87
  /**
103
88
  * Delete destination
104
89
  * @throws Error if required parameters are missing or invalid
105
90
  */
106
91
  async deleteDestination(destinationId) {
107
- if (!destinationId || typeof destinationId !== 'string') {
108
- throw new Error('destinationId is required and must be a string');
109
- }
110
- try {
111
- return await this.client.delete(`${this.basePath}/destination/${destinationId}`);
112
- }
113
- catch (error) {
114
- throw new Error(`Failed to delete destination: ${error instanceof Error ? error.message : 'Unknown error'}`);
115
- }
92
+ requireString(destinationId, 'destinationId');
93
+ return await this.delete(`/destination/${destinationId}`, 'Failed to delete destination');
116
94
  }
117
95
  /**
118
96
  * Get all subscriptions
@@ -120,25 +98,7 @@ export class NotificationApi {
120
98
  * @throws Error if the request fails
121
99
  */
122
100
  async getSubscriptions(limit, continuationToken) {
123
- const params = {};
124
- if (limit !== undefined) {
125
- if (typeof limit !== 'number' || limit < 1) {
126
- throw new Error('limit must be a positive number when provided');
127
- }
128
- params.limit = limit;
129
- }
130
- if (continuationToken !== undefined) {
131
- if (typeof continuationToken !== 'string') {
132
- throw new Error('continuationToken must be a string when provided');
133
- }
134
- params.continuation_token = continuationToken;
135
- }
136
- try {
137
- return await this.client.get(`${this.basePath}/subscription`, params);
138
- }
139
- catch (error) {
140
- throw new Error(`Failed to get subscriptions: ${error instanceof Error ? error.message : 'Unknown error'}`);
141
- }
101
+ return await this.getContinuation('/subscription', 'Failed to get subscriptions', limit, continuationToken);
142
102
  }
143
103
  /**
144
104
  * Create a subscription
@@ -146,15 +106,8 @@ export class NotificationApi {
146
106
  * @throws Error if required parameters are missing or invalid
147
107
  */
148
108
  async createSubscription(subscription) {
149
- if (!subscription || typeof subscription !== 'object') {
150
- throw new Error('subscription is required and must be an object');
151
- }
152
- try {
153
- return await this.client.post(`${this.basePath}/subscription`, subscription);
154
- }
155
- catch (error) {
156
- throw new Error(`Failed to create subscription: ${error instanceof Error ? error.message : 'Unknown error'}`);
157
- }
109
+ requireObject(subscription, 'subscription');
110
+ return await this.post('/subscription', 'Failed to create subscription', subscription);
158
111
  }
159
112
  /**
160
113
  * Get a subscription
@@ -163,8 +116,8 @@ export class NotificationApi {
163
116
  * @throws Error if required parameters are missing or invalid
164
117
  */
165
118
  async getSubscription(subscriptionId) {
166
- assertRequiredString(subscriptionId, 'subscriptionId');
167
- return await getPathWithContextError(this.client, `${this.basePath}/subscription/${subscriptionId}`, 'Failed to get subscription');
119
+ requireString(subscriptionId, 'subscriptionId');
120
+ return await this.get(`/subscription/${subscriptionId}`, 'Failed to get subscription');
168
121
  }
169
122
  /**
170
123
  * Update a subscription
@@ -172,18 +125,9 @@ export class NotificationApi {
172
125
  * @throws Error if required parameters are missing or invalid
173
126
  */
174
127
  async updateSubscription(subscriptionId, subscription) {
175
- if (!subscriptionId || typeof subscriptionId !== 'string') {
176
- throw new Error('subscriptionId is required and must be a string');
177
- }
178
- if (!subscription || typeof subscription !== 'object') {
179
- throw new Error('subscription is required and must be an object');
180
- }
181
- try {
182
- return await this.client.put(`${this.basePath}/subscription/${subscriptionId}`, subscription);
183
- }
184
- catch (error) {
185
- throw new Error(`Failed to update subscription: ${error instanceof Error ? error.message : 'Unknown error'}`);
186
- }
128
+ requireString(subscriptionId, 'subscriptionId');
129
+ requireObject(subscription, 'subscription');
130
+ return await this.put(`/subscription/${subscriptionId}`, 'Failed to update subscription', subscription);
187
131
  }
188
132
  /**
189
133
  * Delete a subscription
@@ -191,15 +135,8 @@ export class NotificationApi {
191
135
  * @throws Error if required parameters are missing or invalid
192
136
  */
193
137
  async deleteSubscription(subscriptionId) {
194
- if (!subscriptionId || typeof subscriptionId !== 'string') {
195
- throw new Error('subscriptionId is required and must be a string');
196
- }
197
- try {
198
- return await this.client.delete(`${this.basePath}/subscription/${subscriptionId}`);
199
- }
200
- catch (error) {
201
- throw new Error(`Failed to delete subscription: ${error instanceof Error ? error.message : 'Unknown error'}`);
202
- }
138
+ requireString(subscriptionId, 'subscriptionId');
139
+ return await this.delete(`/subscription/${subscriptionId}`, 'Failed to delete subscription');
203
140
  }
204
141
  /**
205
142
  * Disable a subscription
@@ -207,15 +144,8 @@ export class NotificationApi {
207
144
  * @throws Error if required parameters are missing or invalid
208
145
  */
209
146
  async disableSubscription(subscriptionId) {
210
- if (!subscriptionId || typeof subscriptionId !== 'string') {
211
- throw new Error('subscriptionId is required and must be a string');
212
- }
213
- try {
214
- return await this.client.post(`${this.basePath}/subscription/${subscriptionId}/disable`, {});
215
- }
216
- catch (error) {
217
- throw new Error(`Failed to disable subscription: ${error instanceof Error ? error.message : 'Unknown error'}`);
218
- }
147
+ requireString(subscriptionId, 'subscriptionId');
148
+ return await this.post(`/subscription/${subscriptionId}/disable`, 'Failed to disable subscription', {});
219
149
  }
220
150
  /**
221
151
  * Enable a subscription
@@ -223,15 +153,8 @@ export class NotificationApi {
223
153
  * @throws Error if required parameters are missing or invalid
224
154
  */
225
155
  async enableSubscription(subscriptionId) {
226
- if (!subscriptionId || typeof subscriptionId !== 'string') {
227
- throw new Error('subscriptionId is required and must be a string');
228
- }
229
- try {
230
- return await this.client.post(`${this.basePath}/subscription/${subscriptionId}/enable`, {});
231
- }
232
- catch (error) {
233
- throw new Error(`Failed to enable subscription: ${error instanceof Error ? error.message : 'Unknown error'}`);
234
- }
156
+ requireString(subscriptionId, 'subscriptionId');
157
+ return await this.post(`/subscription/${subscriptionId}/enable`, 'Failed to enable subscription', {});
235
158
  }
236
159
  /**
237
160
  * Test a subscription
@@ -239,15 +162,8 @@ export class NotificationApi {
239
162
  * @throws Error if required parameters are missing or invalid
240
163
  */
241
164
  async testSubscription(subscriptionId) {
242
- if (!subscriptionId || typeof subscriptionId !== 'string') {
243
- throw new Error('subscriptionId is required and must be a string');
244
- }
245
- try {
246
- return await this.client.post(`${this.basePath}/subscription/${subscriptionId}/test`, {});
247
- }
248
- catch (error) {
249
- throw new Error(`Failed to test subscription: ${error instanceof Error ? error.message : 'Unknown error'}`);
250
- }
165
+ requireString(subscriptionId, 'subscriptionId');
166
+ return await this.post(`/subscription/${subscriptionId}/test`, 'Failed to test subscription', {});
251
167
  }
252
168
  /**
253
169
  * Get a topic
@@ -256,8 +172,8 @@ export class NotificationApi {
256
172
  * @throws Error if required parameters are missing or invalid
257
173
  */
258
174
  async getTopic(topicId) {
259
- assertRequiredString(topicId, 'topicId');
260
- return await getPathWithContextError(this.client, `${this.basePath}/topic/${topicId}`, 'Failed to get topic');
175
+ requireString(topicId, 'topicId');
176
+ return await this.get(`/topic/${topicId}`, 'Failed to get topic');
261
177
  }
262
178
  /**
263
179
  * Get all topics
@@ -265,25 +181,7 @@ export class NotificationApi {
265
181
  * @throws Error if the request fails
266
182
  */
267
183
  async getTopics(limit, continuationToken) {
268
- const params = {};
269
- if (limit !== undefined) {
270
- if (typeof limit !== 'number' || limit < 1) {
271
- throw new Error('limit must be a positive number when provided');
272
- }
273
- params.limit = limit;
274
- }
275
- if (continuationToken !== undefined) {
276
- if (typeof continuationToken !== 'string') {
277
- throw new Error('continuationToken must be a string when provided');
278
- }
279
- params.continuation_token = continuationToken;
280
- }
281
- try {
282
- return await this.client.get(`${this.basePath}/topic`, params);
283
- }
284
- catch (error) {
285
- throw new Error(`Failed to get topics: ${error instanceof Error ? error.message : 'Unknown error'}`);
286
- }
184
+ return await this.getContinuation('/topic', 'Failed to get topics', limit, continuationToken);
287
185
  }
288
186
  /**
289
187
  * Create a subscription filter
@@ -291,18 +189,9 @@ export class NotificationApi {
291
189
  * @throws Error if required parameters are missing or invalid
292
190
  */
293
191
  async createSubscriptionFilter(subscriptionId, filter) {
294
- if (!subscriptionId || typeof subscriptionId !== 'string') {
295
- throw new Error('subscriptionId is required and must be a string');
296
- }
297
- if (!filter || typeof filter !== 'object') {
298
- throw new Error('filter is required and must be an object');
299
- }
300
- try {
301
- return await this.client.post(`${this.basePath}/subscription/${subscriptionId}/filter`, filter);
302
- }
303
- catch (error) {
304
- throw new Error(`Failed to create subscription filter: ${error instanceof Error ? error.message : 'Unknown error'}`);
305
- }
192
+ requireString(subscriptionId, 'subscriptionId');
193
+ requireObject(filter, 'filter');
194
+ return await this.post(`/subscription/${subscriptionId}/filter`, 'Failed to create subscription filter', filter);
306
195
  }
307
196
  /**
308
197
  * Get a subscription filter
@@ -310,18 +199,9 @@ export class NotificationApi {
310
199
  * @throws Error if required parameters are missing or invalid
311
200
  */
312
201
  async getSubscriptionFilter(subscriptionId, filterId) {
313
- if (!subscriptionId || typeof subscriptionId !== 'string') {
314
- throw new Error('subscriptionId is required and must be a string');
315
- }
316
- if (!filterId || typeof filterId !== 'string') {
317
- throw new Error('filterId is required and must be a string');
318
- }
319
- try {
320
- return await this.client.get(`${this.basePath}/subscription/${subscriptionId}/filter/${filterId}`);
321
- }
322
- catch (error) {
323
- throw new Error(`Failed to get subscription filter: ${error instanceof Error ? error.message : 'Unknown error'}`);
324
- }
202
+ requireString(subscriptionId, 'subscriptionId');
203
+ requireString(filterId, 'filterId');
204
+ return await this.get(`/subscription/${subscriptionId}/filter/${filterId}`, 'Failed to get subscription filter');
325
205
  }
326
206
  /**
327
207
  * Delete a subscription filter
@@ -329,17 +209,8 @@ export class NotificationApi {
329
209
  * @throws Error if required parameters are missing or invalid
330
210
  */
331
211
  async deleteSubscriptionFilter(subscriptionId, filterId) {
332
- if (!subscriptionId || typeof subscriptionId !== 'string') {
333
- throw new Error('subscriptionId is required and must be a string');
334
- }
335
- if (!filterId || typeof filterId !== 'string') {
336
- throw new Error('filterId is required and must be a string');
337
- }
338
- try {
339
- return await this.client.delete(`${this.basePath}/subscription/${subscriptionId}/filter/${filterId}`);
340
- }
341
- catch (error) {
342
- throw new Error(`Failed to delete subscription filter: ${error instanceof Error ? error.message : 'Unknown error'}`);
343
- }
212
+ requireString(subscriptionId, 'subscriptionId');
213
+ requireString(filterId, 'filterId');
214
+ return await this.delete(`/subscription/${subscriptionId}/filter/${filterId}`, 'Failed to delete subscription filter');
344
215
  }
345
216
  }
@@ -1,4 +1,5 @@
1
1
  import { buildValidatedPaginatedParams } from '../shared/query-params.js';
2
+ import { getWithApiError, requireString } from '../shared/request.js';
2
3
  /**
3
4
  * Build validated pagination query params.
4
5
  *
@@ -17,9 +18,7 @@ export function buildPaginatedQueryParams(filter, limit, offset) {
17
18
  * @param paramName Parameter name used in error text.
18
19
  */
19
20
  export function assertRequiredString(value, paramName) {
20
- if (!value || typeof value !== 'string') {
21
- throw new Error(`${paramName} is required and must be a string`);
22
- }
21
+ requireString(value, paramName);
23
22
  }
24
23
  /**
25
24
  * Perform a GET request and wrap errors with endpoint-specific context.
@@ -30,12 +29,7 @@ export function assertRequiredString(value, paramName) {
30
29
  * @returns API response payload.
31
30
  */
32
31
  export async function getPathWithContextError(client, path, failureMessage) {
33
- try {
34
- return await client.get(path);
35
- }
36
- catch (error) {
37
- throw new Error(`${failureMessage}: ${error instanceof Error ? error.message : 'Unknown error'}`);
38
- }
32
+ return await getWithApiError(client, path, failureMessage);
39
33
  }
40
34
  /**
41
35
  * Perform a GET request with query params and wrap errors with endpoint-specific context.
@@ -47,12 +41,7 @@ export async function getPathWithContextError(client, path, failureMessage) {
47
41
  * @returns API response payload.
48
42
  */
49
43
  export async function getWithContextError(client, path, params, failureMessage) {
50
- try {
51
- return await client.get(path, params);
52
- }
53
- catch (error) {
54
- throw new Error(`${failureMessage}: ${error instanceof Error ? error.message : 'Unknown error'}`);
55
- }
44
+ return await getWithApiError(client, path, failureMessage, params);
56
45
  }
57
46
  /**
58
47
  * Perform a paginated GET request with validated filter/limit/offset params.