ebay-mcp 1.13.2 → 1.14.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 +3 -3
- package/README.es.md +3 -3
- package/README.fr.md +3 -3
- package/README.ja.md +3 -3
- package/README.ko.md +3 -3
- package/README.md +163 -41
- package/README.pt-BR.md +3 -3
- package/README.ru.md +3 -3
- package/README.zh-CN.md +3 -3
- package/build/api/account-management/account.js +633 -297
- package/build/api/analytics-and-report/analytics.js +111 -65
- package/build/api/client.js +199 -140
- package/build/api/clientRequestError.js +23 -0
- package/build/api/clientTrading.js +213 -0
- package/build/api/clientTradingError.js +4 -0
- package/build/api/communication/feedback.js +147 -59
- package/build/api/communication/message.js +134 -81
- package/build/api/communication/negotiation.js +65 -53
- package/build/api/communication/notification.js +458 -164
- package/build/api/developer/developer.js +99 -45
- package/build/api/index.js +23 -8
- package/build/api/listing-management/inventory.js +884 -338
- package/build/api/listing-metadata/metadata.js +416 -170
- package/build/api/listing-metadata/taxonomy.js +187 -42
- package/build/api/marketing-and-promotions/marketing.js +1392 -598
- package/build/api/marketing-and-promotions/recommendation.js +49 -24
- package/build/api/order-management/dispute.js +226 -45
- package/build/api/order-management/fulfillment.js +144 -71
- package/build/api/order-management/orderIssueHelpers.js +61 -0
- package/build/api/other/compliance.js +50 -38
- package/build/api/other/edelivery.js +603 -159
- package/build/api/other/finding.js +280 -0
- package/build/api/other/identity.js +30 -15
- package/build/api/other/translation.js +29 -14
- package/build/api/other/vero.js +113 -27
- package/build/api/rateLimitTracker.js +55 -0
- package/build/api/shared/request.js +189 -98
- package/build/api/trading/trading.js +154 -87
- package/build/auth/credentialSession.js +250 -0
- package/build/auth/oauth.js +298 -171
- package/build/auth/{oauth-metadata.js → oauthMetadata.js} +22 -6
- package/build/auth/oauthMiddleware.js +104 -0
- package/build/auth/{scope-utils.js → scopeUtils.js} +101 -28
- package/build/auth/tokenVerifier.js +243 -0
- package/build/auth/tokenVerifierError.js +21 -0
- package/build/config/environment.js +148 -113
- package/build/config/{tool-families.js → toolFamilies.js} +30 -14
- package/build/index.js +25 -19
- package/build/mcp/{http-transport.js → httpTransport.js} +102 -52
- package/build/mcp/readOnlyFilter.js +67 -0
- package/build/mcp/runtime.js +31 -13
- package/build/mcp/{tool-gating.js → toolGating.js} +77 -49
- package/build/mcp/{ui-bridge.js → uiBridge.js} +80 -23
- package/build/schemas/account-management/account.js +144 -6
- package/build/schemas/analytics/analytics.js +33 -19
- package/build/schemas/communication/messages.js +12 -42
- package/build/schemas/developer/developer.js +135 -0
- package/build/schemas/fulfillment/orders.js +183 -21
- package/build/schemas/index.js +27 -19
- package/build/schemas/inventory-management/inventory.js +17 -9
- package/build/schemas/marketing/marketing.js +480 -25
- package/build/schemas/metadata/metadata.js +11 -6
- package/build/schemas/other/finding.js +27 -0
- package/build/schemas/other/otherApis.js +424 -0
- package/build/schemas/taxonomy/taxonomy.js +11 -5
- package/build/scripts/{auto-setup.js → autoSetup.js} +87 -74
- package/build/scripts/{build-ui.js → buildUi.js} +6 -1
- package/build/scripts/{dev-sync.js → devSync.js} +169 -110
- package/build/scripts/diagnostics.js +52 -44
- package/build/scripts/{download-specs.js → downloadSpecs.js} +29 -21
- package/build/scripts/{interactive-setup.js → interactiveSetup.js} +84 -78
- package/build/scripts/setup.js +241 -178
- package/build/scripts/{setup-shared.js → setupShared.js} +29 -7
- package/build/scripts/skills.js +35 -27
- package/build/scripts/updateApiStatusDoc.js +71 -0
- package/build/serverHttp.js +90 -0
- package/build/skills/content.js +124 -118
- package/build/skills/index.js +22 -10
- package/build/skills/install.js +21 -10
- package/build/skills/markers.js +50 -15
- package/build/skills/{registry-snapshot.js → registrySnapshot.js} +8 -2
- package/build/skills/render.js +41 -14
- package/build/skills/targets.js +49 -17
- package/build/tools/categories/account.js +166 -264
- package/build/tools/categories/analytics.js +11 -22
- package/build/tools/categories/browse.js +17 -0
- package/build/tools/categories/communication.js +124 -399
- package/build/tools/categories/connector.js +23 -20
- package/build/tools/categories/developer.js +46 -159
- package/build/tools/categories/fulfillment.js +84 -215
- package/build/tools/categories/index.js +6 -14
- package/build/tools/categories/inventory.js +238 -293
- package/build/tools/categories/marketing.js +677 -39
- package/build/tools/categories/metadata.js +190 -117
- package/build/tools/categories/other.js +81 -208
- package/build/tools/categories/taxonomy.js +29 -20
- package/build/tools/categories/{token-management.js → tokenManagement.js} +187 -192
- package/build/tools/categories/trading.js +16 -47
- package/build/tools/contracts.js +34 -24
- package/build/tools/{define-tool.js → defineTool.js} +44 -29
- package/build/tools/registry.js +87 -29
- package/build/tools/schemas.js +3 -57
- package/build/tools/ui/archetypes.js +1 -0
- package/build/tools/ui/{map-helpers.js → mapHelpers.js} +69 -19
- package/build/tools/ui/maps.js +294 -80
- package/build/types/index.js +1 -1
- package/build/ui/card.html +14 -14
- package/build/ui/chart.html +14 -14
- package/build/ui/stat.html +87 -0
- package/build/ui/table.html +14 -14
- package/build/utils/apiStatusFeed.js +95 -0
- package/build/utils/cliOutput.js +15 -0
- package/build/utils/cliUi.js +108 -0
- package/build/utils/communication/feedback.js +57 -77
- package/build/utils/communication/message.js +69 -98
- package/build/utils/communication/negotiation.js +30 -57
- package/build/utils/communication/notification.js +112 -252
- package/build/utils/{date-converter.js → dateConverter.js} +62 -30
- package/build/utils/effectSchema.js +203 -0
- package/build/utils/effectSchemaAdapter.js +121 -0
- package/build/utils/effectSchemaChainMethods.js +146 -0
- package/build/utils/effectSchemaRefinements.js +104 -0
- package/build/utils/effectSchemaStringMethods.js +63 -0
- package/build/utils/effectSchemaTypes.js +47 -0
- package/build/utils/{env-parser.js → envParser.js} +10 -2
- package/build/utils/errors.js +7 -3
- package/build/utils/http.js +148 -89
- package/build/utils/{llm-client-detector.js → llmClientDetector.js} +295 -274
- package/build/utils/logger.js +127 -51
- package/build/utils/{oauth-helper.js → oauthHelper.js} +127 -90
- package/build/utils/other/compliance.js +18 -38
- package/build/utils/other/identity.js +2 -2
- package/build/utils/other/translation.js +4 -4
- package/build/utils/other/vero.js +36 -20
- package/build/utils/schemaHelpers.js +22 -0
- package/build/utils/scopeHelper.js +270 -0
- package/build/utils/securityChecker.js +316 -0
- package/build/utils/{setup-validator.js → setupValidator.js} +113 -94
- package/build/utils/{setup-wizard.js → setupWizard.js} +57 -46
- package/build/utils/{token-utils.js → tokenUtils.js} +2 -2
- package/build/utils/trading/trading.js +35 -0
- package/build/utils/typeGuards.js +12 -0
- package/build/utils/version.js +65 -29
- package/package.json +10 -8
- package/build/api/client-trading.js +0 -124
- package/build/api/communication/shared.js +0 -59
- package/build/api/shared/query-params.js +0 -16
- package/build/auth/credential-session.js +0 -166
- package/build/auth/oauth-middleware.js +0 -100
- package/build/auth/token-verifier.js +0 -186
- package/build/schemas/other/other-apis.js +0 -390
- package/build/scripts/update-api-status-doc.js +0 -44
- package/build/server-http.js +0 -85
- package/build/tools/definitions/marketing.js +0 -1381
- package/build/tools/tool-handlers/marketing.js +0 -312
- package/build/utils/account-management/account.js +0 -818
- package/build/utils/api-status-feed.js +0 -84
- package/build/utils/cli-ui.js +0 -47
- package/build/utils/order-management/dispute.js +0 -369
- package/build/utils/order-management/fulfillment.js +0 -205
- package/build/utils/other/edelivery.js +0 -235
- package/build/utils/schema-helpers.js +0 -13
- package/build/utils/scope-helper.js +0 -207
- package/build/utils/security-checker.js +0 -248
- package/build/utils/type-guards.js +0 -6
- /package/build/auth/{oauth-types.js → oauthTypes.js} +0 -0
- /package/build/{server-http.d.ts → serverHttp.d.ts} +0 -0
- /package/build/tools/ui/{view-models.js → viewModels.js} +0 -0
- /package/build/types/{ebay-enums.js → ebayEnums.js} +0 -0
|
@@ -1,135 +1,226 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return await operation();
|
|
8
|
-
}
|
|
9
|
-
catch (error) {
|
|
10
|
-
throw new Error(`${failureMessage}: ${getErrorMessage(error)}`);
|
|
1
|
+
import { Data, Effect } from 'effect';
|
|
2
|
+
/** Tagged failure returned by migrated eBay API endpoint Effects. */
|
|
3
|
+
export class EbayApiError extends Data.TaggedError('EbayApiError') {
|
|
4
|
+
get message() {
|
|
5
|
+
const detail = this.cause instanceof Error ? this.cause.message : String(this.cause);
|
|
6
|
+
return `eBay ${this.method} ${this.path} failed: ${detail}`;
|
|
11
7
|
}
|
|
12
8
|
}
|
|
9
|
+
/** Tagged validation failure returned before an endpoint request is sent. */
|
|
10
|
+
export class EndpointInputError extends Data.TaggedError('EndpointInputError') {
|
|
11
|
+
}
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* Builds query params from an endpoint-owned allow-list.
|
|
14
|
+
*
|
|
15
|
+
* @param params - Camel-case local parameter names mapped to their eBay wire names and values.
|
|
16
|
+
* @returns A query object for the request adapter, or undefined when every value is omitted.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const params = buildEndpointParams({
|
|
21
|
+
* policyTypes: { wireName: 'policy_types', value: input.policyTypes },
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
15
24
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
export const buildEndpointParams = (params) => {
|
|
26
|
+
const query = {};
|
|
27
|
+
for (const param of Object.values(params)) {
|
|
28
|
+
if (param.value !== undefined && param.value !== '') {
|
|
29
|
+
query[param.wireName] = param.value;
|
|
30
|
+
}
|
|
19
31
|
}
|
|
20
|
-
|
|
32
|
+
return Object.keys(query).length > 0 ? query : undefined;
|
|
33
|
+
};
|
|
21
34
|
/**
|
|
22
|
-
* Require a tool argument or API
|
|
35
|
+
* Require a tool argument or API field to be a non-empty string inside Effect code.
|
|
36
|
+
*
|
|
37
|
+
* @param value - Unknown value supplied by a caller or transport boundary.
|
|
38
|
+
* @param name - Parameter name used in the validation message.
|
|
39
|
+
* @returns An Effect that succeeds with the string or fails with a tagged input error.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const signingKeyId = yield* requireStringEffect(input.signingKeyId, 'signingKeyId');
|
|
44
|
+
* ```
|
|
23
45
|
*/
|
|
24
|
-
export
|
|
25
|
-
if (!value || typeof value !== '
|
|
26
|
-
|
|
46
|
+
export const requireStringEffect = (value, name) => {
|
|
47
|
+
if (!value || typeof value !== 'string') {
|
|
48
|
+
return Effect.fail(new EndpointInputError({
|
|
49
|
+
parameter: name,
|
|
50
|
+
message: `${name} is required and must be a string`,
|
|
51
|
+
}));
|
|
27
52
|
}
|
|
28
|
-
|
|
53
|
+
return Effect.succeed(value);
|
|
54
|
+
};
|
|
29
55
|
/**
|
|
30
|
-
* Validate an optional string
|
|
56
|
+
* Validate an optional string inside Effect code.
|
|
57
|
+
*
|
|
58
|
+
* @param value - Optional value supplied for an endpoint query parameter.
|
|
59
|
+
* @param name - Parameter name used in the validation message.
|
|
60
|
+
* @returns An Effect that succeeds with the string, undefined, or a tagged input error.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const sort = yield* optionalStringEffect(input.sort, 'sort');
|
|
65
|
+
* ```
|
|
31
66
|
*/
|
|
32
|
-
export
|
|
67
|
+
export const optionalStringEffect = (value, name) => {
|
|
33
68
|
if (value === undefined) {
|
|
34
|
-
return undefined;
|
|
69
|
+
return Effect.succeed(undefined);
|
|
35
70
|
}
|
|
36
71
|
if (typeof value !== 'string') {
|
|
37
|
-
|
|
72
|
+
return Effect.fail(new EndpointInputError({
|
|
73
|
+
parameter: name,
|
|
74
|
+
message: `${name} must be a string when provided`,
|
|
75
|
+
}));
|
|
38
76
|
}
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Build a query object from provided optional string parameters.
|
|
43
|
-
*/
|
|
44
|
-
export function buildOptionalStringParams(params) {
|
|
45
|
-
const query = {};
|
|
46
|
-
for (const [name, value] of Object.entries(params)) {
|
|
47
|
-
const stringValue = optionalStringParam(value, name);
|
|
48
|
-
if (stringValue) {
|
|
49
|
-
query[name] = stringValue;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return query;
|
|
53
|
-
}
|
|
77
|
+
return Effect.succeed(value);
|
|
78
|
+
};
|
|
54
79
|
/**
|
|
55
|
-
* Validate an optional positive numeric query parameter
|
|
80
|
+
* Validate an optional positive numeric query parameter inside Effect code.
|
|
81
|
+
*
|
|
82
|
+
* @param value - Optional value supplied for an endpoint query parameter.
|
|
83
|
+
* @param name - Parameter name used in the validation message.
|
|
84
|
+
* @returns An Effect that succeeds with the number, undefined, or a tagged input error.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const limit = yield* optionalPositiveNumberEffect(input.limit, 'limit');
|
|
89
|
+
* ```
|
|
56
90
|
*/
|
|
57
|
-
export
|
|
91
|
+
export const optionalPositiveNumberEffect = (value, name) => {
|
|
58
92
|
if (value === undefined) {
|
|
59
|
-
return undefined;
|
|
93
|
+
return Effect.succeed(undefined);
|
|
60
94
|
}
|
|
61
95
|
if (typeof value !== 'number' || value < 1) {
|
|
62
|
-
|
|
96
|
+
return Effect.fail(new EndpointInputError({
|
|
97
|
+
parameter: name,
|
|
98
|
+
message: `${name} must be a positive number when provided`,
|
|
99
|
+
}));
|
|
63
100
|
}
|
|
64
|
-
return value;
|
|
65
|
-
}
|
|
101
|
+
return Effect.succeed(value);
|
|
102
|
+
};
|
|
66
103
|
/**
|
|
67
|
-
* Validate an optional non-negative numeric query parameter
|
|
104
|
+
* Validate an optional non-negative numeric query parameter inside Effect code.
|
|
105
|
+
*
|
|
106
|
+
* @param value - Optional value supplied for an endpoint query parameter.
|
|
107
|
+
* @param name - Parameter name used in the validation message.
|
|
108
|
+
* @returns An Effect that succeeds with the number, undefined, or a tagged input error.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const offset = yield* optionalNonNegativeNumberEffect(input.offset, 'offset');
|
|
113
|
+
* ```
|
|
68
114
|
*/
|
|
69
|
-
export
|
|
115
|
+
export const optionalNonNegativeNumberEffect = (value, name) => {
|
|
70
116
|
if (value === undefined) {
|
|
71
|
-
return undefined;
|
|
117
|
+
return Effect.succeed(undefined);
|
|
72
118
|
}
|
|
73
119
|
if (typeof value !== 'number' || value < 0) {
|
|
74
|
-
|
|
120
|
+
return Effect.fail(new EndpointInputError({
|
|
121
|
+
parameter: name,
|
|
122
|
+
message: `${name} must be a non-negative number when provided`,
|
|
123
|
+
}));
|
|
75
124
|
}
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
125
|
+
return Effect.succeed(value);
|
|
126
|
+
};
|
|
78
127
|
/**
|
|
79
|
-
*
|
|
128
|
+
* Require a tool argument or API payload field to be an object inside Effect code.
|
|
129
|
+
*
|
|
130
|
+
* @param value - Unknown value supplied by a caller or transport boundary.
|
|
131
|
+
* @param name - Parameter name used in the validation message.
|
|
132
|
+
* @returns An Effect that succeeds with the expected object shape or fails with a tagged input error.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* const request = yield* requireObjectEffect<CreateOffersRequest>(body, 'offerData');
|
|
137
|
+
* ```
|
|
80
138
|
*/
|
|
81
|
-
export
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
params.filter = validatedFilter;
|
|
88
|
-
}
|
|
89
|
-
if (validatedLimit !== undefined) {
|
|
90
|
-
params.limit = validatedLimit;
|
|
91
|
-
}
|
|
92
|
-
if (validatedOffset !== undefined) {
|
|
93
|
-
params.offset = validatedOffset;
|
|
94
|
-
}
|
|
95
|
-
return params;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Build validated continuation-token query parameters for cursor-based eBay APIs.
|
|
99
|
-
*/
|
|
100
|
-
export function buildContinuationParams(limit, continuationToken) {
|
|
101
|
-
const params = {};
|
|
102
|
-
const validatedLimit = optionalPositiveNumberParam(limit, 'limit');
|
|
103
|
-
const validatedContinuationToken = optionalStringParam(continuationToken, 'continuationToken');
|
|
104
|
-
if (validatedLimit !== undefined) {
|
|
105
|
-
params.limit = validatedLimit;
|
|
106
|
-
}
|
|
107
|
-
if (validatedContinuationToken !== undefined) {
|
|
108
|
-
params.continuation_token = validatedContinuationToken;
|
|
139
|
+
export const requireObjectEffect = (value, name) => {
|
|
140
|
+
if (!value || typeof value !== 'object') {
|
|
141
|
+
return Effect.fail(new EndpointInputError({
|
|
142
|
+
parameter: name,
|
|
143
|
+
message: `${name} is required and must be an object`,
|
|
144
|
+
}));
|
|
109
145
|
}
|
|
110
|
-
return
|
|
111
|
-
}
|
|
146
|
+
return Effect.succeed(value);
|
|
147
|
+
};
|
|
112
148
|
/**
|
|
113
|
-
* Execute a GET request with
|
|
149
|
+
* Execute a GET request as an Effect with typed eBay API errors.
|
|
150
|
+
*
|
|
151
|
+
* @param client - eBay REST client that owns auth and transport details.
|
|
152
|
+
* @param path - eBay REST path to request.
|
|
153
|
+
* @param params - Optional query parameters already mapped to eBay wire names.
|
|
154
|
+
* @param config - Optional per-request headers or params, used for endpoint-specific headers.
|
|
155
|
+
* @returns An Effect that succeeds with the generated eBay response DTO.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const response = await Effect.runPromise(requestGetEffect(client, path, params));
|
|
160
|
+
* ```
|
|
114
161
|
*/
|
|
115
|
-
export
|
|
116
|
-
|
|
117
|
-
|
|
162
|
+
export const requestGetEffect = (client, path, params, config) => Effect.tryPromise({
|
|
163
|
+
try: () => {
|
|
164
|
+
if (config !== undefined) {
|
|
165
|
+
return client.get(path, params, config);
|
|
166
|
+
}
|
|
167
|
+
return params === undefined ? client.get(path) : client.get(path, params);
|
|
168
|
+
},
|
|
169
|
+
catch: (cause) => new EbayApiError({ method: 'GET', path, cause }),
|
|
170
|
+
});
|
|
118
171
|
/**
|
|
119
|
-
* Execute a POST request with
|
|
172
|
+
* Execute a POST request as an Effect with typed eBay API errors.
|
|
173
|
+
*
|
|
174
|
+
* @param client - eBay REST client that owns auth and transport details.
|
|
175
|
+
* @param path - eBay REST path to request.
|
|
176
|
+
* @param body - Optional JSON body to send.
|
|
177
|
+
* @param config - Optional per-request headers or params, used for endpoint-specific headers.
|
|
178
|
+
* @returns An Effect that succeeds with the generated eBay response DTO.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* const response = await Effect.runPromise(requestPostEffect(client, path, body));
|
|
183
|
+
* ```
|
|
120
184
|
*/
|
|
121
|
-
export
|
|
122
|
-
|
|
123
|
-
|
|
185
|
+
export const requestPostEffect = (client, path, body, config) => Effect.tryPromise({
|
|
186
|
+
try: () => {
|
|
187
|
+
if (config !== undefined) {
|
|
188
|
+
return client.post(path, body, config);
|
|
189
|
+
}
|
|
190
|
+
return body === undefined ? client.post(path) : client.post(path, body);
|
|
191
|
+
},
|
|
192
|
+
catch: (cause) => new EbayApiError({ method: 'POST', path, cause }),
|
|
193
|
+
});
|
|
124
194
|
/**
|
|
125
|
-
* Execute a PUT request with
|
|
195
|
+
* Execute a PUT request as an Effect with typed eBay API errors.
|
|
196
|
+
*
|
|
197
|
+
* @param client - eBay REST client that owns auth and transport details.
|
|
198
|
+
* @param path - eBay REST path to request.
|
|
199
|
+
* @param body - Optional JSON body to send.
|
|
200
|
+
* @returns An Effect that succeeds with the generated eBay response DTO.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* const response = await Effect.runPromise(requestPutEffect(client, path, body));
|
|
205
|
+
* ```
|
|
126
206
|
*/
|
|
127
|
-
export
|
|
128
|
-
|
|
129
|
-
}
|
|
207
|
+
export const requestPutEffect = (client, path, body) => Effect.tryPromise({
|
|
208
|
+
try: () => client.put(path, body),
|
|
209
|
+
catch: (cause) => new EbayApiError({ method: 'PUT', path, cause }),
|
|
210
|
+
});
|
|
130
211
|
/**
|
|
131
|
-
* Execute a DELETE request with
|
|
212
|
+
* Execute a DELETE request as an Effect with typed eBay API errors.
|
|
213
|
+
*
|
|
214
|
+
* @param client - eBay REST client that owns auth and transport details.
|
|
215
|
+
* @param path - eBay REST path to request.
|
|
216
|
+
* @returns An Effect that succeeds with the generated eBay response DTO.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* await Effect.runPromise(requestDeleteEffect(client, path));
|
|
221
|
+
* ```
|
|
132
222
|
*/
|
|
133
|
-
export
|
|
134
|
-
|
|
135
|
-
}
|
|
223
|
+
export const requestDeleteEffect = (client, path) => Effect.tryPromise({
|
|
224
|
+
try: () => client.delete(path),
|
|
225
|
+
catch: (cause) => new EbayApiError({ method: 'DELETE', path, cause }),
|
|
226
|
+
});
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function asRecordArray(value) {
|
|
1
|
+
import { optionalPositiveNumberEffect, optionalStringEffect, requireObjectEffect, requireStringEffect, } from '../../api/shared/request.js';
|
|
2
|
+
import { isRecord } from '../../utils/typeGuards.js';
|
|
3
|
+
import { Effect } from 'effect';
|
|
4
|
+
const asRecordArray = (value) => {
|
|
6
5
|
if (!Array.isArray(value)) {
|
|
7
6
|
return [];
|
|
8
7
|
}
|
|
9
|
-
return value.filter(
|
|
10
|
-
}
|
|
11
|
-
function stringValue(value) {
|
|
12
|
-
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'
|
|
13
|
-
? String(value)
|
|
14
|
-
: '';
|
|
15
|
-
}
|
|
8
|
+
return value.filter(isRecord);
|
|
9
|
+
};
|
|
16
10
|
/**
|
|
17
11
|
* High-level wrapper for seller listing operations backed by eBay Trading API calls.
|
|
18
12
|
*/
|
|
@@ -22,96 +16,169 @@ export class TradingApi {
|
|
|
22
16
|
this.client = client;
|
|
23
17
|
}
|
|
24
18
|
/**
|
|
25
|
-
*
|
|
19
|
+
* Fetches active seller listings with Trading API pagination metadata.
|
|
20
|
+
*
|
|
21
|
+
* @param input - Optional page number and entries-per-page values.
|
|
22
|
+
* @returns An Effect that succeeds with the parsed GetMyeBaySelling response payload.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const response = await Effect.runPromise(
|
|
27
|
+
* tradingApi.getActiveListings({ page: 2, entriesPerPage: 25 }),
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see https://developer.ebay.com/devzone/xml/docs/reference/ebay/getmyebayselling.html
|
|
26
32
|
*/
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
getActiveListings = (input = {}) => {
|
|
34
|
+
const tradingClient = this.client;
|
|
35
|
+
return Effect.gen(function* () {
|
|
36
|
+
const request = yield* requireObjectEffect(input, 'input');
|
|
37
|
+
const inputPage = yield* optionalPositiveNumberEffect(request.page, 'page');
|
|
38
|
+
const inputEntriesPerPage = yield* optionalPositiveNumberEffect(request.entriesPerPage, 'entriesPerPage');
|
|
39
|
+
const page = inputPage === undefined ? 1 : inputPage;
|
|
40
|
+
const entriesPerPage = inputEntriesPerPage === undefined ? 50 : inputEntriesPerPage;
|
|
41
|
+
return yield* tradingClient.execute('GetMyeBaySelling', {
|
|
42
|
+
ActiveList: {
|
|
43
|
+
Sort: 'TimeLeft',
|
|
44
|
+
Pagination: {
|
|
45
|
+
EntriesPerPage: entriesPerPage,
|
|
46
|
+
PageNumber: page,
|
|
47
|
+
},
|
|
34
48
|
},
|
|
35
|
-
}
|
|
49
|
+
});
|
|
36
50
|
});
|
|
37
|
-
|
|
38
|
-
const itemArray = asRecord(activeList?.ItemArray);
|
|
39
|
-
const items = asRecordArray(itemArray?.Item);
|
|
40
|
-
const pagination = asRecord(activeList?.PaginationResult);
|
|
41
|
-
const listings = items.map((item) => {
|
|
42
|
-
const sellingStatus = asRecord(item.SellingStatus);
|
|
43
|
-
const currentPriceRaw = sellingStatus?.CurrentPrice;
|
|
44
|
-
const currentPrice = typeof currentPriceRaw === 'number' || isRecord(currentPriceRaw)
|
|
45
|
-
? currentPriceRaw
|
|
46
|
-
: undefined;
|
|
47
|
-
const priceValue = typeof currentPrice === 'object' && currentPrice !== null
|
|
48
|
-
? Number(currentPrice['#text'] || 0)
|
|
49
|
-
: Number(currentPrice || 0);
|
|
50
|
-
return {
|
|
51
|
-
itemId: stringValue(item.ItemID),
|
|
52
|
-
title: stringValue(item.Title),
|
|
53
|
-
sku: stringValue(item.SKU),
|
|
54
|
-
quantity: Number(item.Quantity || 0),
|
|
55
|
-
quantityAvailable: Number(item.QuantityAvailable || 0),
|
|
56
|
-
currentPrice: priceValue,
|
|
57
|
-
watchCount: Number(item.WatchCount || 0),
|
|
58
|
-
listingType: stringValue(item.ListingType),
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
listings,
|
|
63
|
-
total: Number(pagination?.TotalNumberOfEntries || 0),
|
|
64
|
-
totalPages: Number(pagination?.TotalNumberOfPages || 0),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
51
|
+
};
|
|
67
52
|
/**
|
|
68
|
-
*
|
|
53
|
+
* Fetches a single listing by eBay item ID with full Trading API detail.
|
|
54
|
+
*
|
|
55
|
+
* @param input - eBay item identifier.
|
|
56
|
+
* @returns An Effect that succeeds with the parsed Trading API item payload.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const listing = await Effect.runPromise(tradingApi.getListing({ itemId: '12345' }));
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @see https://developer.ebay.com/devzone/xml/docs/reference/ebay/getitem.html
|
|
69
64
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
getListing = (input) => {
|
|
66
|
+
const tradingClient = this.client;
|
|
67
|
+
return Effect.gen(function* () {
|
|
68
|
+
const request = yield* requireObjectEffect(input, 'input');
|
|
69
|
+
const itemId = yield* requireStringEffect(request.itemId, 'itemId');
|
|
70
|
+
const result = yield* tradingClient.execute('GetItem', {
|
|
71
|
+
ItemID: itemId,
|
|
72
|
+
DetailLevel: 'ReturnAll',
|
|
73
|
+
});
|
|
74
|
+
const items = asRecordArray(result.Item);
|
|
75
|
+
return items.length > 0 ? items[0] : result;
|
|
76
76
|
});
|
|
77
|
-
|
|
78
|
-
return items?.[0] || result;
|
|
79
|
-
}
|
|
77
|
+
};
|
|
80
78
|
/**
|
|
81
|
-
*
|
|
79
|
+
* Creates a fixed-price listing using the supplied Trading API item payload.
|
|
80
|
+
*
|
|
81
|
+
* @param input - Trading API Item payload nested under `item`.
|
|
82
|
+
* @returns An Effect that succeeds with the parsed AddFixedPriceItem response.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const listing = await Effect.runPromise(
|
|
87
|
+
* tradingApi.createListing({ item: { Title: 'New item', StartPrice: 9.99 } }),
|
|
88
|
+
* );
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @see https://developer.ebay.com/devzone/xml/docs/reference/ebay/AddFixedPriceItem.html
|
|
82
92
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
93
|
+
createListing = (input) => {
|
|
94
|
+
const tradingClient = this.client;
|
|
95
|
+
return Effect.gen(function* () {
|
|
96
|
+
const request = yield* requireObjectEffect(input, 'input');
|
|
97
|
+
const item = yield* requireObjectEffect(request.item, 'item');
|
|
98
|
+
return yield* tradingClient.execute('AddFixedPriceItem', { Item: item });
|
|
99
|
+
});
|
|
100
|
+
};
|
|
86
101
|
/**
|
|
87
|
-
*
|
|
102
|
+
* Revises a fixed-price listing by merging changes with the eBay item ID.
|
|
103
|
+
*
|
|
104
|
+
* @param input - eBay item identifier plus Trading API Item fields to update.
|
|
105
|
+
* @returns An Effect that succeeds with the parsed ReviseFixedPriceItem response.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const listing = await Effect.runPromise(
|
|
110
|
+
* tradingApi.reviseListing({ itemId: '12345', fields: { Quantity: 10 } }),
|
|
111
|
+
* );
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @see https://developer.ebay.com/devzone/xml/docs/reference/ebay/ReviseFixedPriceItem.html
|
|
88
115
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
116
|
+
reviseListing = (input) => {
|
|
117
|
+
const tradingClient = this.client;
|
|
118
|
+
return Effect.gen(function* () {
|
|
119
|
+
const request = yield* requireObjectEffect(input, 'input');
|
|
120
|
+
const itemId = yield* requireStringEffect(request.itemId, 'itemId');
|
|
121
|
+
const fields = yield* requireObjectEffect(request.fields, 'fields');
|
|
122
|
+
return yield* tradingClient.execute('ReviseFixedPriceItem', {
|
|
123
|
+
Item: { ...fields, ItemID: itemId },
|
|
124
|
+
});
|
|
94
125
|
});
|
|
95
|
-
}
|
|
126
|
+
};
|
|
96
127
|
/**
|
|
97
|
-
*
|
|
128
|
+
* Ends a fixed-price listing with the provided Trading API ending reason.
|
|
129
|
+
*
|
|
130
|
+
* @param input - eBay item identifier plus optional Trading API ending reason.
|
|
131
|
+
* @returns An Effect that succeeds with the parsed EndFixedPriceItem response.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* await Effect.runPromise(
|
|
136
|
+
* tradingApi.endListing({ itemId: '12345', reason: 'NotAvailable' }),
|
|
137
|
+
* );
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @see https://developer.ebay.com/devzone/xml/docs/reference/ebay/endfixedpriceitem.html
|
|
98
141
|
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
142
|
+
endListing = (input) => {
|
|
143
|
+
const tradingClient = this.client;
|
|
144
|
+
return Effect.gen(function* () {
|
|
145
|
+
const request = yield* requireObjectEffect(input, 'input');
|
|
146
|
+
const itemId = yield* requireStringEffect(request.itemId, 'itemId');
|
|
147
|
+
const inputReason = yield* optionalStringEffect(request.reason, 'reason');
|
|
148
|
+
const reason = inputReason === undefined ? 'NotAvailable' : inputReason;
|
|
149
|
+
return yield* tradingClient.execute('EndFixedPriceItem', {
|
|
150
|
+
ItemID: itemId,
|
|
151
|
+
EndingReason: reason,
|
|
152
|
+
});
|
|
105
153
|
});
|
|
106
|
-
}
|
|
154
|
+
};
|
|
107
155
|
/**
|
|
108
|
-
*
|
|
156
|
+
* Relists an ended fixed-price item with optional listing modifications.
|
|
157
|
+
*
|
|
158
|
+
* @param input - eBay item identifier plus optional Trading API Item modifications.
|
|
159
|
+
* @returns An Effect that succeeds with the parsed RelistFixedPriceItem response.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const listing = await Effect.runPromise(
|
|
164
|
+
* tradingApi.relistItem({ itemId: '12345', modifications: { Quantity: 20 } }),
|
|
165
|
+
* );
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @see https://developer.ebay.com/devzone/xml/docs/reference/ebay/relistfixedpriceitem.html
|
|
109
169
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
170
|
+
relistItem = (input) => {
|
|
171
|
+
const tradingClient = this.client;
|
|
172
|
+
return Effect.gen(function* () {
|
|
173
|
+
const request = yield* requireObjectEffect(input, 'input');
|
|
174
|
+
const itemId = yield* requireStringEffect(request.itemId, 'itemId');
|
|
175
|
+
let modifications = {};
|
|
176
|
+
if (request.modifications !== undefined) {
|
|
177
|
+
modifications = yield* requireObjectEffect(request.modifications, 'modifications');
|
|
178
|
+
}
|
|
179
|
+
return yield* tradingClient.execute('RelistFixedPriceItem', {
|
|
180
|
+
Item: { ...modifications, ItemID: itemId },
|
|
181
|
+
});
|
|
115
182
|
});
|
|
116
|
-
}
|
|
183
|
+
};
|
|
117
184
|
}
|