ebay-mcp 1.16.0 → 1.18.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.de.md +13 -9
- package/README.es.md +13 -9
- package/README.fr.md +13 -9
- package/README.ja.md +13 -9
- package/README.ko.md +13 -9
- package/README.md +116 -18
- package/README.pt-BR.md +13 -9
- package/README.ru.md +13 -9
- package/README.zh-CN.md +13 -9
- package/build/api/account-management/accountV2.js +347 -0
- package/build/api/account-management/finances.js +289 -0
- package/build/api/client.js +53 -2
- package/build/api/index.js +24 -0
- package/build/api/listing-management/feed.js +91 -0
- package/build/api/listing-management/feedReportTasks.js +107 -0
- package/build/api/listing-management/feedRequest.js +91 -0
- package/build/api/listing-management/feedSchedules.js +95 -0
- package/build/api/listing-management/feedTasks.js +91 -0
- package/build/api/listing-management/media.js +26 -0
- package/build/api/listing-management/mediaResources.js +176 -0
- package/build/api/listing-management/stores.js +203 -0
- package/build/api/listing-metadata/charity.js +76 -0
- package/build/api/listing-metadata/metadata.js +21 -1
- package/build/api/listing-metadata/metadataShipping.js +117 -0
- package/build/api/listing-metadata/taxonomy.js +52 -7
- package/build/api/marketing-and-promotions/campaigns.js +2 -2
- package/build/api/marketing-and-promotions/promotions.js +2 -2
- package/build/api/marketing-and-promotions/shared.js +0 -3
- package/build/api/order-management/logistics.js +150 -0
- package/build/api/shared/download.js +79 -0
- package/build/api/shared/location.js +33 -0
- package/build/api/shared/request.js +49 -0
- package/build/auth/scopeUtils.js +46 -2
- package/build/config/environment.js +18 -1
- package/build/config/toolFamilies.js +4 -0
- package/build/mcp/runtime.js +4 -0
- package/build/schemas/account-management/accountV2.js +294 -0
- package/build/schemas/account-management/finances.js +143 -0
- package/build/schemas/fulfillment/logistics.js +115 -0
- package/build/schemas/inventory-management/feed.js +217 -0
- package/build/schemas/inventory-management/mediaDocuments.js +35 -0
- package/build/schemas/inventory-management/stores.js +42 -0
- package/build/schemas/metadata/shipping.js +16 -0
- package/build/schemas/taxonomy/categoryTree.js +8 -0
- package/build/schemas/taxonomy/charity.js +41 -0
- package/build/scripts/devSync.js +15 -2
- package/build/scripts/specRefs.js +55 -0
- package/build/skills/registrySnapshot.js +7 -3
- package/build/tools/categories/accountV2.js +106 -0
- package/build/tools/categories/charity.js +21 -0
- package/build/tools/categories/feed.js +183 -0
- package/build/tools/categories/finances.js +86 -0
- package/build/tools/categories/index.js +12 -2
- package/build/tools/categories/logistics.js +52 -0
- package/build/tools/categories/media.js +75 -0
- package/build/tools/categories/metadata.js +37 -0
- package/build/tools/categories/stores.js +64 -0
- package/build/tools/categories/taxonomy.js +17 -0
- package/build/tools/defineTool.js +10 -0
- package/build/tools/fileResult.js +30 -0
- package/build/utils/http.js +22 -3
- package/build/utils/localFeedFiles.js +61 -0
- package/build/utils/localMedia.js +56 -17
- package/build/utils/logger.js +5 -0
- package/package.json +2 -2
package/build/api/client.js
CHANGED
|
@@ -221,6 +221,7 @@ export class EbayApiClient {
|
|
|
221
221
|
body: options.data,
|
|
222
222
|
timeoutMs: options.timeoutMs ?? this.timeoutMs,
|
|
223
223
|
responseType: options.responseType,
|
|
224
|
+
maxBytes: options.maxBytes,
|
|
224
225
|
}).pipe(Effect.map((response) => {
|
|
225
226
|
logResponse(response.status, response.statusText, response.data, response.headers['x-ebay-c-ratelimit-remaining'], response.headers['x-ebay-c-ratelimit-limit']);
|
|
226
227
|
return response;
|
|
@@ -341,6 +342,22 @@ export class EbayApiClient {
|
|
|
341
342
|
responseType: config?.responseType,
|
|
342
343
|
absolute: config?.absolute,
|
|
343
344
|
timeoutMs: config?.timeoutMs,
|
|
345
|
+
maxBytes: config?.maxBytes,
|
|
346
|
+
tokenType: config?.tokenType,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Make a GET request and keep the status and headers of the successful
|
|
351
|
+
* response — for file downloads whose name and type arrive in headers.
|
|
352
|
+
*/
|
|
353
|
+
async getForResponse(endpoint, params, config) {
|
|
354
|
+
return await this.requestResponse('GET', endpoint, {
|
|
355
|
+
params: { ...params, ...config?.params },
|
|
356
|
+
headers: config?.headers,
|
|
357
|
+
responseType: config?.responseType,
|
|
358
|
+
absolute: config?.absolute,
|
|
359
|
+
timeoutMs: config?.timeoutMs,
|
|
360
|
+
maxBytes: config?.maxBytes,
|
|
344
361
|
tokenType: config?.tokenType,
|
|
345
362
|
});
|
|
346
363
|
}
|
|
@@ -362,6 +379,7 @@ export class EbayApiClient {
|
|
|
362
379
|
responseType: config?.responseType,
|
|
363
380
|
absolute: config?.absolute,
|
|
364
381
|
timeoutMs: config?.timeoutMs,
|
|
382
|
+
maxBytes: config?.maxBytes,
|
|
365
383
|
tokenType: config?.tokenType,
|
|
366
384
|
});
|
|
367
385
|
}
|
|
@@ -369,13 +387,36 @@ export class EbayApiClient {
|
|
|
369
387
|
* Make a PUT request to eBay API
|
|
370
388
|
*/
|
|
371
389
|
async put(endpoint, data, config) {
|
|
372
|
-
return await this.
|
|
390
|
+
return (await this.putForResponse(endpoint, data, config)).data;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Make a PUT request and keep the status and headers of the successful
|
|
394
|
+
* response — for asynchronous updates that return a task `Location` header.
|
|
395
|
+
*/
|
|
396
|
+
async putForResponse(endpoint, data, config) {
|
|
397
|
+
return await this.requestResponse('PUT', endpoint, {
|
|
398
|
+
data,
|
|
399
|
+
params: config?.params,
|
|
400
|
+
headers: config?.headers,
|
|
401
|
+
responseType: config?.responseType,
|
|
402
|
+
absolute: config?.absolute,
|
|
403
|
+
timeoutMs: config?.timeoutMs,
|
|
404
|
+
maxBytes: config?.maxBytes,
|
|
405
|
+
tokenType: config?.tokenType,
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Make a PATCH request to eBay API
|
|
410
|
+
*/
|
|
411
|
+
async patch(endpoint, data, config) {
|
|
412
|
+
return await this.request('PATCH', endpoint, {
|
|
373
413
|
data,
|
|
374
414
|
params: config?.params,
|
|
375
415
|
headers: config?.headers,
|
|
376
416
|
responseType: config?.responseType,
|
|
377
417
|
absolute: config?.absolute,
|
|
378
418
|
timeoutMs: config?.timeoutMs,
|
|
419
|
+
maxBytes: config?.maxBytes,
|
|
379
420
|
tokenType: config?.tokenType,
|
|
380
421
|
});
|
|
381
422
|
}
|
|
@@ -383,12 +424,22 @@ export class EbayApiClient {
|
|
|
383
424
|
* Make a DELETE request to eBay API
|
|
384
425
|
*/
|
|
385
426
|
async delete(endpoint, config) {
|
|
386
|
-
return await this.
|
|
427
|
+
return (await this.deleteForResponse(endpoint, config)).data;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Make a DELETE request and keep the status and headers of the successful
|
|
431
|
+
* response — for asynchronous deletes that return a task `Location` header.
|
|
432
|
+
* `data` is the optional body a few eBay DELETE calls document.
|
|
433
|
+
*/
|
|
434
|
+
async deleteForResponse(endpoint, config, data) {
|
|
435
|
+
return await this.requestResponse('DELETE', endpoint, {
|
|
436
|
+
data,
|
|
387
437
|
params: config?.params,
|
|
388
438
|
headers: config?.headers,
|
|
389
439
|
responseType: config?.responseType,
|
|
390
440
|
absolute: config?.absolute,
|
|
391
441
|
timeoutMs: config?.timeoutMs,
|
|
442
|
+
maxBytes: config?.maxBytes,
|
|
392
443
|
tokenType: config?.tokenType,
|
|
393
444
|
});
|
|
394
445
|
}
|
package/build/api/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { AccountApi } from '../api/account-management/account.js';
|
|
2
|
+
import { AccountV2Api } from '../api/account-management/accountV2.js';
|
|
3
|
+
import { FinancesApi } from '../api/account-management/finances.js';
|
|
2
4
|
import { AnalyticsApi } from '../api/analytics-and-report/analytics.js';
|
|
3
5
|
import { EbayApiClient } from '../api/client.js';
|
|
4
6
|
import { FeedbackApi } from '../api/communication/feedback.js';
|
|
@@ -6,14 +8,18 @@ import { MessageApi } from '../api/communication/message.js';
|
|
|
6
8
|
import { NegotiationApi } from '../api/communication/negotiation.js';
|
|
7
9
|
import { NotificationApi } from '../api/communication/notification.js';
|
|
8
10
|
import { DeveloperApi } from '../api/developer/developer.js';
|
|
11
|
+
import { FeedApi } from '../api/listing-management/feed.js';
|
|
9
12
|
import { InventoryApi } from '../api/listing-management/inventory.js';
|
|
10
13
|
import { MediaApi } from '../api/listing-management/media.js';
|
|
14
|
+
import { StoresApi } from '../api/listing-management/stores.js';
|
|
15
|
+
import { CharityApi } from '../api/listing-metadata/charity.js';
|
|
11
16
|
import { MetadataApi } from '../api/listing-metadata/metadata.js';
|
|
12
17
|
import { TaxonomyApi } from '../api/listing-metadata/taxonomy.js';
|
|
13
18
|
import { MarketingApi } from '../api/marketing-and-promotions/marketing.js';
|
|
14
19
|
import { RecommendationApi } from '../api/marketing-and-promotions/recommendation.js';
|
|
15
20
|
import { DisputeApi } from '../api/order-management/dispute.js';
|
|
16
21
|
import { FulfillmentApi } from '../api/order-management/fulfillment.js';
|
|
22
|
+
import { LogisticsApi } from '../api/order-management/logistics.js';
|
|
17
23
|
import { ComplianceApi } from '../api/other/compliance.js';
|
|
18
24
|
import { EDeliveryApi } from '../api/other/edelivery.js';
|
|
19
25
|
import { BrowseApi } from '../api/other/browse.js';
|
|
@@ -31,15 +37,21 @@ export class EbaySellerApi {
|
|
|
31
37
|
config;
|
|
32
38
|
// API categories
|
|
33
39
|
account;
|
|
40
|
+
accountV2;
|
|
41
|
+
finances;
|
|
34
42
|
inventory;
|
|
35
43
|
media;
|
|
44
|
+
feed;
|
|
45
|
+
stores;
|
|
36
46
|
fulfillment;
|
|
47
|
+
logistics;
|
|
37
48
|
dispute;
|
|
38
49
|
marketing;
|
|
39
50
|
recommendation;
|
|
40
51
|
analytics;
|
|
41
52
|
metadata;
|
|
42
53
|
taxonomy;
|
|
54
|
+
charity;
|
|
43
55
|
negotiation;
|
|
44
56
|
message;
|
|
45
57
|
notification;
|
|
@@ -58,15 +70,21 @@ export class EbaySellerApi {
|
|
|
58
70
|
this.client = new EbayApiClient(config);
|
|
59
71
|
// Initialize API category handlers
|
|
60
72
|
this.account = new AccountApi(this.client);
|
|
73
|
+
this.accountV2 = new AccountV2Api(this.client);
|
|
74
|
+
this.finances = new FinancesApi(this.client);
|
|
61
75
|
this.inventory = new InventoryApi(this.client);
|
|
62
76
|
this.media = new MediaApi(this.client, this.inventory);
|
|
77
|
+
this.feed = new FeedApi(this.client);
|
|
78
|
+
this.stores = new StoresApi(this.client);
|
|
63
79
|
this.fulfillment = new FulfillmentApi(this.client);
|
|
80
|
+
this.logistics = new LogisticsApi(this.client);
|
|
64
81
|
this.dispute = new DisputeApi(this.client);
|
|
65
82
|
this.marketing = new MarketingApi(this.client);
|
|
66
83
|
this.recommendation = new RecommendationApi(this.client);
|
|
67
84
|
this.analytics = new AnalyticsApi(this.client);
|
|
68
85
|
this.metadata = new MetadataApi(this.client);
|
|
69
86
|
this.taxonomy = new TaxonomyApi(this.client);
|
|
87
|
+
this.charity = new CharityApi(this.client);
|
|
70
88
|
this.negotiation = new NegotiationApi(this.client);
|
|
71
89
|
this.message = new MessageApi(this.client);
|
|
72
90
|
this.notification = new NotificationApi(this.client);
|
|
@@ -129,21 +147,27 @@ export class EbaySellerApi {
|
|
|
129
147
|
}
|
|
130
148
|
}
|
|
131
149
|
export * from '../api/account-management/account.js';
|
|
150
|
+
export * from '../api/account-management/accountV2.js';
|
|
151
|
+
export * from '../api/account-management/finances.js';
|
|
132
152
|
export * from '../api/analytics-and-report/analytics.js';
|
|
133
153
|
export * from '../api/client.js';
|
|
134
154
|
export * from '../api/communication/feedback.js';
|
|
135
155
|
export * from '../api/communication/message.js';
|
|
136
156
|
export * from '../api/communication/negotiation.js';
|
|
137
157
|
export * from '../api/communication/notification.js';
|
|
158
|
+
export * from '../api/listing-management/feed.js';
|
|
138
159
|
export * from '../api/listing-management/inventory.js';
|
|
139
160
|
export * from '../api/listing-management/media.js';
|
|
140
161
|
export * from '../api/listing-management/mediaAttach.js';
|
|
162
|
+
export * from '../api/listing-management/stores.js';
|
|
163
|
+
export * from '../api/listing-metadata/charity.js';
|
|
141
164
|
export * from '../api/listing-metadata/metadata.js';
|
|
142
165
|
export * from '../api/listing-metadata/taxonomy.js';
|
|
143
166
|
export * from '../api/marketing-and-promotions/marketing.js';
|
|
144
167
|
export * from '../api/marketing-and-promotions/recommendation.js';
|
|
145
168
|
export * from '../api/order-management/dispute.js';
|
|
146
169
|
export * from '../api/order-management/fulfillment.js';
|
|
170
|
+
export * from '../api/order-management/logistics.js';
|
|
147
171
|
export * from '../api/other/compliance.js';
|
|
148
172
|
export * from '../api/other/edelivery.js';
|
|
149
173
|
export { BrowseApi } from '../api/other/browse.js';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createFeedReportTaskMethods } from './feedReportTasks.js';
|
|
2
|
+
import { createFeedScheduleMethods } from './feedSchedules.js';
|
|
3
|
+
import { createFeedTaskMethods } from './feedTasks.js';
|
|
4
|
+
/**
|
|
5
|
+
* Feed API - asynchronous order, inventory, and customer service metric feed tasks and
|
|
6
|
+
* schedules. Every member is the eBay operation of the same name; the endpoints live in
|
|
7
|
+
* `feedTasks.ts`, `feedReportTasks.ts` and `feedSchedules.ts` by resource.
|
|
8
|
+
*/
|
|
9
|
+
export class FeedApi {
|
|
10
|
+
// task resource: feed tasks without filter criteria, their files and uploads.
|
|
11
|
+
/** Feed API getTasks endpoint; see createFeedTaskMethods. */
|
|
12
|
+
getTasks;
|
|
13
|
+
/** Feed API createTask endpoint; see createFeedTaskMethods. */
|
|
14
|
+
createTask;
|
|
15
|
+
/** Feed API getTask endpoint; see createFeedTaskMethods. */
|
|
16
|
+
getTask;
|
|
17
|
+
/** Feed API getInputFile endpoint; see createFeedTaskMethods. */
|
|
18
|
+
getInputFile;
|
|
19
|
+
/** Feed API getResultFile endpoint; see createFeedTaskMethods. */
|
|
20
|
+
getResultFile;
|
|
21
|
+
/** Feed API uploadFile endpoint; see createFeedTaskMethods. */
|
|
22
|
+
uploadFile;
|
|
23
|
+
// order_task, inventory_task and customer_service_metric_task: filtered report tasks.
|
|
24
|
+
/** Feed API getOrderTasks endpoint; see createFeedReportTaskMethods. */
|
|
25
|
+
getOrderTasks;
|
|
26
|
+
/** Feed API createOrderTask endpoint; see createFeedReportTaskMethods. */
|
|
27
|
+
createOrderTask;
|
|
28
|
+
/** Feed API getOrderTask endpoint; see createFeedReportTaskMethods. */
|
|
29
|
+
getOrderTask;
|
|
30
|
+
/** Feed API getInventoryTasks endpoint; see createFeedReportTaskMethods. */
|
|
31
|
+
getInventoryTasks;
|
|
32
|
+
/** Feed API createInventoryTask endpoint; see createFeedReportTaskMethods. */
|
|
33
|
+
createInventoryTask;
|
|
34
|
+
/** Feed API getInventoryTask endpoint; see createFeedReportTaskMethods. */
|
|
35
|
+
getInventoryTask;
|
|
36
|
+
/** Feed API getCustomerServiceMetricTasks endpoint; see createFeedReportTaskMethods. */
|
|
37
|
+
getCustomerServiceMetricTasks;
|
|
38
|
+
/** Feed API createCustomerServiceMetricTask endpoint; see createFeedReportTaskMethods. */
|
|
39
|
+
createCustomerServiceMetricTask;
|
|
40
|
+
/** Feed API getCustomerServiceMetricTask endpoint; see createFeedReportTaskMethods. */
|
|
41
|
+
getCustomerServiceMetricTask;
|
|
42
|
+
// schedule resource: recurring reports and the templates they subscribe to.
|
|
43
|
+
/** Feed API getSchedules endpoint; see createFeedScheduleMethods. */
|
|
44
|
+
getSchedules;
|
|
45
|
+
/** Feed API createSchedule endpoint; see createFeedScheduleMethods. */
|
|
46
|
+
createSchedule;
|
|
47
|
+
/** Feed API getSchedule endpoint; see createFeedScheduleMethods. */
|
|
48
|
+
getSchedule;
|
|
49
|
+
/** Feed API updateSchedule endpoint; see createFeedScheduleMethods. */
|
|
50
|
+
updateSchedule;
|
|
51
|
+
/** Feed API deleteSchedule endpoint; see createFeedScheduleMethods. */
|
|
52
|
+
deleteSchedule;
|
|
53
|
+
/** Feed API getLatestResultFile endpoint; see createFeedScheduleMethods. */
|
|
54
|
+
getLatestResultFile;
|
|
55
|
+
/** Feed API getScheduleTemplate endpoint; see createFeedScheduleMethods. */
|
|
56
|
+
getScheduleTemplate;
|
|
57
|
+
/** Feed API getScheduleTemplates endpoint; see createFeedScheduleMethods. */
|
|
58
|
+
getScheduleTemplates;
|
|
59
|
+
/**
|
|
60
|
+
* Builds every Feed API endpoint over one shared client.
|
|
61
|
+
* @param client - Shared authenticated HTTP client.
|
|
62
|
+
*/
|
|
63
|
+
constructor(client) {
|
|
64
|
+
const tasks = createFeedTaskMethods(client);
|
|
65
|
+
this.getTasks = tasks.getTasks;
|
|
66
|
+
this.createTask = tasks.createTask;
|
|
67
|
+
this.getTask = tasks.getTask;
|
|
68
|
+
this.getInputFile = tasks.getInputFile;
|
|
69
|
+
this.getResultFile = tasks.getResultFile;
|
|
70
|
+
this.uploadFile = tasks.uploadFile;
|
|
71
|
+
const reports = createFeedReportTaskMethods(client);
|
|
72
|
+
this.getOrderTasks = reports.getOrderTasks;
|
|
73
|
+
this.createOrderTask = reports.createOrderTask;
|
|
74
|
+
this.getOrderTask = reports.getOrderTask;
|
|
75
|
+
this.getInventoryTasks = reports.getInventoryTasks;
|
|
76
|
+
this.createInventoryTask = reports.createInventoryTask;
|
|
77
|
+
this.getInventoryTask = reports.getInventoryTask;
|
|
78
|
+
this.getCustomerServiceMetricTasks = reports.getCustomerServiceMetricTasks;
|
|
79
|
+
this.createCustomerServiceMetricTask = reports.createCustomerServiceMetricTask;
|
|
80
|
+
this.getCustomerServiceMetricTask = reports.getCustomerServiceMetricTask;
|
|
81
|
+
const schedules = createFeedScheduleMethods(client);
|
|
82
|
+
this.getSchedules = schedules.getSchedules;
|
|
83
|
+
this.createSchedule = schedules.createSchedule;
|
|
84
|
+
this.getSchedule = schedules.getSchedule;
|
|
85
|
+
this.updateSchedule = schedules.updateSchedule;
|
|
86
|
+
this.deleteSchedule = schedules.deleteSchedule;
|
|
87
|
+
this.getLatestResultFile = schedules.getLatestResultFile;
|
|
88
|
+
this.getScheduleTemplate = schedules.getScheduleTemplate;
|
|
89
|
+
this.getScheduleTemplates = schedules.getScheduleTemplates;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { decodeEndpointInputEffect, requestGetEffect } from '../../api/shared/request.js';
|
|
2
|
+
import { createCustomerServiceMetricTaskInputSchema, createInventoryTaskInputSchema, createOrderTaskInputSchema, feedTaskIdInputSchema, getCustomerServiceMetricTasksInputSchema, getInventoryTasksInputSchema, getOrderTasksInputSchema, } from '../../schemas/inventory-management/feed.js';
|
|
3
|
+
import { Effect } from 'effect';
|
|
4
|
+
import { exclusiveFeedFilters, FEED_BASE_PATH, feedListParams, feedResourcePath, postFeedTask, } from './feedRequest.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates the Feed API report-task endpoints that take filter criteria: order reports
|
|
7
|
+
* (`order_task`), active inventory reports (`inventory_task`) and customer service metric
|
|
8
|
+
* reports (`customer_service_metric_task`).
|
|
9
|
+
* @param client - Shared authenticated HTTP client.
|
|
10
|
+
* @returns Endpoint Effects composed into FeedApi.
|
|
11
|
+
*/
|
|
12
|
+
export const createFeedReportTaskMethods = (client) => {
|
|
13
|
+
/**
|
|
14
|
+
* Lists order report tasks by feed type or schedule.
|
|
15
|
+
* @param input - feedType or scheduleId (not both), dateRange or lookBackDays, limit, offset.
|
|
16
|
+
* @returns Generated OrderTaskCollection.
|
|
17
|
+
* @example feed.getOrderTasks({ feedType: 'LMS_ORDER_REPORT', lookBackDays: 10 })
|
|
18
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/order_task/methods/getOrderTasks
|
|
19
|
+
*/
|
|
20
|
+
const getOrderTasks = (input = {}) => decodeEndpointInputEffect(getOrderTasksInputSchema, input).pipe(Effect.flatMap(exclusiveFeedFilters), Effect.flatMap((query) => requestGetEffect(client, `${FEED_BASE_PATH}/order_task`, feedListParams(query))));
|
|
21
|
+
/**
|
|
22
|
+
* Creates an LMS_ORDER_REPORT download task; eBay answers 202 with only a Location.
|
|
23
|
+
* @param input - CreateOrderTaskRequest body.
|
|
24
|
+
* @returns The new task ID and Location.
|
|
25
|
+
* @example feed.createOrderTask({ task: { feedType: 'LMS_ORDER_REPORT', schemaVersion: '1235' } })
|
|
26
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/order_task/methods/createOrderTask
|
|
27
|
+
*/
|
|
28
|
+
const createOrderTask = (input) => decodeEndpointInputEffect(createOrderTaskInputSchema, input).pipe(Effect.flatMap(({ task }) => {
|
|
29
|
+
const body = task;
|
|
30
|
+
return postFeedTask(client, '/order_task', body);
|
|
31
|
+
}));
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves one order report task.
|
|
34
|
+
* @param input - Task identifier.
|
|
35
|
+
* @returns Generated OrderTask.
|
|
36
|
+
* @example feed.getOrderTask({ taskId: 'TASK-1' })
|
|
37
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/order_task/methods/getOrderTask
|
|
38
|
+
*/
|
|
39
|
+
const getOrderTask = (input) => decodeEndpointInputEffect(feedTaskIdInputSchema, input).pipe(Effect.flatMap(({ taskId }) => requestGetEffect(client, feedResourcePath('/order_task', taskId))));
|
|
40
|
+
/**
|
|
41
|
+
* Lists active inventory report tasks.
|
|
42
|
+
* @param input - feedType, dateRange or lookBackDays, limit, offset.
|
|
43
|
+
* @returns Generated InventoryTaskCollection.
|
|
44
|
+
* @example feed.getInventoryTasks({ feedType: 'LMS_ACTIVE_INVENTORY_REPORT' })
|
|
45
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/inventory_task/methods/getInventoryTasks
|
|
46
|
+
*/
|
|
47
|
+
const getInventoryTasks = (input = {}) => decodeEndpointInputEffect(getInventoryTasksInputSchema, input).pipe(Effect.flatMap(exclusiveFeedFilters), Effect.flatMap((query) => requestGetEffect(client, `${FEED_BASE_PATH}/inventory_task`, feedListParams(query))));
|
|
48
|
+
/**
|
|
49
|
+
* Creates an LMS_ACTIVE_INVENTORY_REPORT download task; eBay answers 202 with only a Location.
|
|
50
|
+
* @param input - CreateInventoryTaskRequest body.
|
|
51
|
+
* @returns The new task ID and Location.
|
|
52
|
+
* @example feed.createInventoryTask({ task: { feedType: 'LMS_ACTIVE_INVENTORY_REPORT', schemaVersion: '1.0' } })
|
|
53
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/inventory_task/methods/createInventoryTask
|
|
54
|
+
*/
|
|
55
|
+
const createInventoryTask = (input) => decodeEndpointInputEffect(createInventoryTaskInputSchema, input).pipe(Effect.flatMap(({ task }) => {
|
|
56
|
+
const body = task;
|
|
57
|
+
return postFeedTask(client, '/inventory_task', body);
|
|
58
|
+
}));
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves one active inventory report task.
|
|
61
|
+
* @param input - Task identifier.
|
|
62
|
+
* @returns Generated InventoryTask.
|
|
63
|
+
* @example feed.getInventoryTask({ taskId: 'TASK-1' })
|
|
64
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/inventory_task/methods/getInventoryTask
|
|
65
|
+
*/
|
|
66
|
+
const getInventoryTask = (input) => decodeEndpointInputEffect(feedTaskIdInputSchema, input).pipe(Effect.flatMap(({ taskId }) => requestGetEffect(client, feedResourcePath('/inventory_task', taskId))));
|
|
67
|
+
/**
|
|
68
|
+
* Lists customer service metric report tasks.
|
|
69
|
+
* @param input - feedType, dateRange or lookBackDays, limit, offset.
|
|
70
|
+
* @returns Generated CustomerServiceMetricTaskCollection.
|
|
71
|
+
* @example feed.getCustomerServiceMetricTasks({ lookBackDays: 30 })
|
|
72
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/customer_service_metric_task/methods/getCustomerServiceMetricTasks
|
|
73
|
+
*/
|
|
74
|
+
const getCustomerServiceMetricTasks = (input = {}) => decodeEndpointInputEffect(getCustomerServiceMetricTasksInputSchema, input).pipe(Effect.flatMap(exclusiveFeedFilters), Effect.flatMap((query) => requestGetEffect(client, `${FEED_BASE_PATH}/customer_service_metric_task`, feedListParams(query))));
|
|
75
|
+
/**
|
|
76
|
+
* Creates a CUSTOMER_SERVICE_METRICS_REPORT download task; eBay answers 202 with only a
|
|
77
|
+
* Location. Accept-Language is required by eBay and defaults to the configured language.
|
|
78
|
+
* @param input - CreateServiceMetricsTaskRequest body and optional Accept-Language.
|
|
79
|
+
* @returns The new task ID and Location.
|
|
80
|
+
* @example feed.createCustomerServiceMetricTask({ task: { feedType: 'CUSTOMER_SERVICE_METRICS_REPORT', schemaVersion: '1.0', filterCriteria: { customerServiceMetricType: 'ITEM_NOT_RECEIVED', evaluationMarketplaceId: 'EBAY_US' } } })
|
|
81
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/customer_service_metric_task/methods/createCustomerServiceMetricTask
|
|
82
|
+
*/
|
|
83
|
+
const createCustomerServiceMetricTask = (input) => decodeEndpointInputEffect(createCustomerServiceMetricTaskInputSchema, input).pipe(Effect.flatMap(({ task, acceptLanguage }) => {
|
|
84
|
+
const body = task;
|
|
85
|
+
const headers = acceptLanguage ? { 'Accept-Language': acceptLanguage } : undefined;
|
|
86
|
+
return postFeedTask(client, '/customer_service_metric_task', body, headers);
|
|
87
|
+
}));
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves one customer service metric report task.
|
|
90
|
+
* @param input - Task identifier.
|
|
91
|
+
* @returns Generated ServiceMetricsTask.
|
|
92
|
+
* @example feed.getCustomerServiceMetricTask({ taskId: 'TASK-1' })
|
|
93
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/customer_service_metric_task/methods/getCustomerServiceMetricTask
|
|
94
|
+
*/
|
|
95
|
+
const getCustomerServiceMetricTask = (input) => decodeEndpointInputEffect(feedTaskIdInputSchema, input).pipe(Effect.flatMap(({ taskId }) => requestGetEffect(client, feedResourcePath('/customer_service_metric_task', taskId))));
|
|
96
|
+
return {
|
|
97
|
+
getOrderTasks,
|
|
98
|
+
createOrderTask,
|
|
99
|
+
getOrderTask,
|
|
100
|
+
getInventoryTasks,
|
|
101
|
+
createInventoryTask,
|
|
102
|
+
getInventoryTask,
|
|
103
|
+
getCustomerServiceMetricTasks,
|
|
104
|
+
createCustomerServiceMetricTask,
|
|
105
|
+
getCustomerServiceMetricTask,
|
|
106
|
+
};
|
|
107
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { requestDownloadEffect, } from '../../api/shared/download.js';
|
|
2
|
+
import { locatedResourceId } from '../../api/shared/location.js';
|
|
3
|
+
import { buildEndpointParams, EbayApiError, EndpointInputError, } from '../../api/shared/request.js';
|
|
4
|
+
import { Effect } from 'effect';
|
|
5
|
+
/** Feed API base path on the default `api` host. */
|
|
6
|
+
export const FEED_BASE_PATH = '/sell/feed/v1';
|
|
7
|
+
/**
|
|
8
|
+
* Feed API path of one resource, with its ID encoded as a single path segment.
|
|
9
|
+
*
|
|
10
|
+
* @param collection - Collection path below the base path, e.g. `/task`.
|
|
11
|
+
* @param id - Resource ID.
|
|
12
|
+
* @param suffix - Optional sub-path, e.g. `/download_result_file`.
|
|
13
|
+
* @returns The full REST path.
|
|
14
|
+
* @example feedResourcePath('/task', 'TASK-1', '/upload_file')
|
|
15
|
+
*/
|
|
16
|
+
export const feedResourcePath = (collection, id, suffix = '') => `${FEED_BASE_PATH}${collection}/${encodeURIComponent(id)}${suffix}`;
|
|
17
|
+
/**
|
|
18
|
+
* Builds the query of a Feed API list endpoint with eBay's wire names.
|
|
19
|
+
*
|
|
20
|
+
* @param query - Decoded list filters and pagination.
|
|
21
|
+
* @returns Query params, or undefined when every value is omitted.
|
|
22
|
+
* @example feedListParams({ feedType: 'LMS_ORDER_REPORT', limit: 10 })
|
|
23
|
+
*/
|
|
24
|
+
export const feedListParams = (query) => buildEndpointParams({
|
|
25
|
+
feedType: { wireName: 'feed_type', value: query.feedType },
|
|
26
|
+
scheduleId: { wireName: 'schedule_id', value: query.scheduleId },
|
|
27
|
+
dateRange: { wireName: 'date_range', value: query.dateRange },
|
|
28
|
+
lookBackDays: { wireName: 'look_back_days', value: query.lookBackDays },
|
|
29
|
+
limit: { wireName: 'limit', value: query.limit },
|
|
30
|
+
offset: { wireName: 'offset', value: query.offset },
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Rejects the list filter pairs eBay documents as mutually exclusive (feedType with scheduleId,
|
|
34
|
+
* dateRange with lookBackDays) before any request is sent.
|
|
35
|
+
*
|
|
36
|
+
* @param query - Decoded list filters and pagination.
|
|
37
|
+
* @returns An Effect with the same query, or an EndpointInputError naming the conflicting filter.
|
|
38
|
+
* @example exclusiveFeedFilters({ feedType: 'LMS_ORDER_REPORT', lookBackDays: 10 })
|
|
39
|
+
*/
|
|
40
|
+
export const exclusiveFeedFilters = (query) => {
|
|
41
|
+
if (query.feedType !== undefined && query.scheduleId !== undefined) {
|
|
42
|
+
return Effect.fail(new EndpointInputError({
|
|
43
|
+
parameter: 'scheduleId',
|
|
44
|
+
message: 'Pass feedType or scheduleId, not both',
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
if (query.dateRange !== undefined && query.lookBackDays !== undefined) {
|
|
48
|
+
return Effect.fail(new EndpointInputError({
|
|
49
|
+
parameter: 'lookBackDays',
|
|
50
|
+
message: 'Pass dateRange or lookBackDays, not both',
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
return Effect.succeed(query);
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* POSTs a Feed API create request whose new resource ID arrives only in `Location`.
|
|
57
|
+
*
|
|
58
|
+
* @param client - Shared authenticated HTTP client.
|
|
59
|
+
* @param collection - Collection path below the base path, e.g. `/schedule`.
|
|
60
|
+
* @param body - Generated create-request DTO.
|
|
61
|
+
* @param config - Optional per-request headers.
|
|
62
|
+
* @returns An Effect with the decoded ID and Location, or an EbayApiError.
|
|
63
|
+
* @example postFeedResource(client, '/schedule', { feedType: 'LMS_ORDER_REPORT', scheduleTemplateId: 'T-1' })
|
|
64
|
+
*/
|
|
65
|
+
export const postFeedResource = (client, collection, body, config) => {
|
|
66
|
+
const path = `${FEED_BASE_PATH}${collection}`;
|
|
67
|
+
return Effect.tryPromise({
|
|
68
|
+
try: () => client.postForResponse(path, body, config),
|
|
69
|
+
catch: (cause) => new EbayApiError({ method: 'POST', path, cause }), // allow-duplicate
|
|
70
|
+
}).pipe(Effect.flatMap((response) => locatedResourceId(response.headers.location, path)));
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Creates a Feed API task (HTTP 202, no body) and returns the ID from its `Location`.
|
|
74
|
+
*
|
|
75
|
+
* @param client - Shared authenticated HTTP client.
|
|
76
|
+
* @param collection - Task collection path, e.g. `/order_task`.
|
|
77
|
+
* @param body - Generated create-task DTO.
|
|
78
|
+
* @param headers - Optional request headers such as Accept-Language.
|
|
79
|
+
* @returns An Effect with the new task ID and Location, or an EbayApiError.
|
|
80
|
+
* @example postFeedTask(client, '/task', { feedType: 'LMS_ORDER_ACK', schemaVersion: '1235' })
|
|
81
|
+
*/
|
|
82
|
+
export const postFeedTask = (client, collection, body, headers) => postFeedResource(client, collection, body, headers ? { headers } : undefined).pipe(Effect.map(({ id, location }) => ({ taskId: id, location })));
|
|
83
|
+
/**
|
|
84
|
+
* Downloads a Feed API file (input, result or latest schedule report) as raw bytes.
|
|
85
|
+
*
|
|
86
|
+
* @param client - Shared authenticated HTTP client.
|
|
87
|
+
* @param path - Full Feed API download path.
|
|
88
|
+
* @returns An Effect with the bytes, content type and file name.
|
|
89
|
+
* @example downloadFeedFile(client, feedResourcePath('/task', 'TASK-1', '/download_result_file'))
|
|
90
|
+
*/
|
|
91
|
+
export const downloadFeedFile = (client, path) => requestDownloadEffect(client, path, { headers: { Accept: 'application/octet-stream' } });
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { decodeEndpointInputEffect, EndpointInputError, requestDeleteEffect, requestGetEffect, requestPutEffect, } from '../../api/shared/request.js';
|
|
2
|
+
import { createFeedScheduleInputSchema, feedScheduleIdInputSchema, feedScheduleTemplateIdInputSchema, feedTypePageInputSchema, updateFeedScheduleInputSchema, } from '../../schemas/inventory-management/feed.js';
|
|
3
|
+
import { Effect } from 'effect';
|
|
4
|
+
import { downloadFeedFile, FEED_BASE_PATH, feedListParams, feedResourcePath, postFeedResource, } from './feedRequest.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates the Feed API `schedule` resource endpoints: recurring report schedules, their
|
|
7
|
+
* latest result file, and the templates schedules subscribe to.
|
|
8
|
+
* @param client - Shared authenticated HTTP client.
|
|
9
|
+
* @returns Endpoint Effects composed into FeedApi.
|
|
10
|
+
*/
|
|
11
|
+
export const createFeedScheduleMethods = (client) => {
|
|
12
|
+
/**
|
|
13
|
+
* Lists the seller's schedules for a feed type.
|
|
14
|
+
* @param input - feedType (required), limit, offset.
|
|
15
|
+
* @returns Generated UserScheduleCollection.
|
|
16
|
+
* @example feed.getSchedules({ feedType: 'LMS_ORDER_REPORT' })
|
|
17
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/schedule/methods/getSchedules
|
|
18
|
+
*/
|
|
19
|
+
const getSchedules = (input) => decodeEndpointInputEffect(feedTypePageInputSchema, input).pipe(Effect.flatMap((query) => requestGetEffect(client, `${FEED_BASE_PATH}/schedule`, feedListParams(query))));
|
|
20
|
+
/**
|
|
21
|
+
* Subscribes to a schedule template; eBay answers 201 with the new ID only in Location.
|
|
22
|
+
* @param input - CreateUserScheduleRequest body.
|
|
23
|
+
* @returns The new schedule ID and Location.
|
|
24
|
+
* @example feed.createSchedule({ schedule: { feedType: 'LMS_ORDER_REPORT', scheduleTemplateId: 'T-1' } })
|
|
25
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/schedule/methods/createSchedule
|
|
26
|
+
*/
|
|
27
|
+
const createSchedule = (input) => decodeEndpointInputEffect(createFeedScheduleInputSchema, input).pipe(Effect.flatMap(({ schedule }) => {
|
|
28
|
+
const body = schedule;
|
|
29
|
+
return postFeedResource(client, '/schedule', body);
|
|
30
|
+
}), Effect.map(({ id, location }) => ({ scheduleId: id, location })));
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves one schedule's details and status.
|
|
33
|
+
* @param input - Schedule identifier.
|
|
34
|
+
* @returns Generated UserScheduleResponse.
|
|
35
|
+
* @example feed.getSchedule({ scheduleId: 'S-1' })
|
|
36
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/schedule/methods/getSchedule
|
|
37
|
+
*/
|
|
38
|
+
const getSchedule = (input) => decodeEndpointInputEffect(feedScheduleIdInputSchema, input).pipe(Effect.flatMap(({ scheduleId }) => requestGetEffect(client, feedResourcePath('/schedule', scheduleId))));
|
|
39
|
+
/**
|
|
40
|
+
* Updates a schedule; the input is validated against its (possibly changed) template.
|
|
41
|
+
* @param input - Schedule identifier and UpdateUserScheduleRequest body with at least one field.
|
|
42
|
+
* @returns An Effect completing on eBay's empty HTTP 204 response.
|
|
43
|
+
* @example feed.updateSchedule({ scheduleId: 'S-1', schedule: { preferredTriggerHour: '11Z' } })
|
|
44
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/schedule/methods/updateSchedule
|
|
45
|
+
*/
|
|
46
|
+
const updateSchedule = (input) => decodeEndpointInputEffect(updateFeedScheduleInputSchema, input).pipe(Effect.filterOrFail(({ schedule }) => Object.keys(schedule).length > 0, () => new EndpointInputError({
|
|
47
|
+
parameter: 'schedule',
|
|
48
|
+
message: 'Provide at least one schedule field to update',
|
|
49
|
+
})), Effect.flatMap(({ scheduleId, schedule }) => {
|
|
50
|
+
const body = schedule;
|
|
51
|
+
return requestPutEffect(client, feedResourcePath('/schedule', scheduleId), body);
|
|
52
|
+
}));
|
|
53
|
+
/**
|
|
54
|
+
* Deletes a schedule; it stops generating reports.
|
|
55
|
+
* @param input - Schedule identifier.
|
|
56
|
+
* @returns An Effect completing on eBay's empty HTTP 204 response.
|
|
57
|
+
* @example feed.deleteSchedule({ scheduleId: 'S-1' })
|
|
58
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/schedule/methods/deleteSchedule
|
|
59
|
+
*/
|
|
60
|
+
const deleteSchedule = (input) => decodeEndpointInputEffect(feedScheduleIdInputSchema, input).pipe(Effect.flatMap(({ scheduleId }) => requestDeleteEffect(client, feedResourcePath('/schedule', scheduleId))));
|
|
61
|
+
/**
|
|
62
|
+
* Downloads the latest report a schedule generated.
|
|
63
|
+
* @param input - Schedule identifier.
|
|
64
|
+
* @returns File bytes (compressed or plain CSV, XML or JSON) with eBay's type and name.
|
|
65
|
+
* @example feed.getLatestResultFile({ scheduleId: 'S-1' })
|
|
66
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/schedule/methods/getLatestResultFile
|
|
67
|
+
*/
|
|
68
|
+
const getLatestResultFile = (input) => decodeEndpointInputEffect(feedScheduleIdInputSchema, input).pipe(Effect.flatMap(({ scheduleId }) => downloadFeedFile(client, feedResourcePath('/schedule', scheduleId, '/download_result_file'))));
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves one schedule template, including the fields a schedule must supply.
|
|
71
|
+
* @param input - Schedule template identifier.
|
|
72
|
+
* @returns Generated ScheduleTemplateResponse.
|
|
73
|
+
* @example feed.getScheduleTemplate({ scheduleTemplateId: 'T-1' })
|
|
74
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/schedule/methods/getScheduleTemplate
|
|
75
|
+
*/
|
|
76
|
+
const getScheduleTemplate = (input) => decodeEndpointInputEffect(feedScheduleTemplateIdInputSchema, input).pipe(Effect.flatMap(({ scheduleTemplateId }) => requestGetEffect(client, feedResourcePath('/schedule_template', scheduleTemplateId))));
|
|
77
|
+
/**
|
|
78
|
+
* Lists the schedule templates for a feed type.
|
|
79
|
+
* @param input - feedType (required), limit, offset.
|
|
80
|
+
* @returns Generated ScheduleTemplateCollection.
|
|
81
|
+
* @example feed.getScheduleTemplates({ feedType: 'LMS_ORDER_REPORT' })
|
|
82
|
+
* @see https://developer.ebay.com/api-docs/sell/feed/resources/schedule/methods/getScheduleTemplates
|
|
83
|
+
*/
|
|
84
|
+
const getScheduleTemplates = (input) => decodeEndpointInputEffect(feedTypePageInputSchema, input).pipe(Effect.flatMap((query) => requestGetEffect(client, `${FEED_BASE_PATH}/schedule_template`, feedListParams(query))));
|
|
85
|
+
return {
|
|
86
|
+
getSchedules,
|
|
87
|
+
createSchedule,
|
|
88
|
+
getSchedule,
|
|
89
|
+
updateSchedule,
|
|
90
|
+
deleteSchedule,
|
|
91
|
+
getLatestResultFile,
|
|
92
|
+
getScheduleTemplate,
|
|
93
|
+
getScheduleTemplates,
|
|
94
|
+
};
|
|
95
|
+
};
|