ebay-api 9.4.3 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -75,7 +75,7 @@ For more examples, check out the [examples directory](./examples).
75
75
 
76
76
  ## Changelog
77
77
 
78
- * `v9.4.3` is the latest release.
78
+ * `v9.5.0` is the latest release.
79
79
  * See [here](https://github.com/hendt/ebay-api/blob/master/CHANGELOG.md) for the full changelog.
80
80
 
81
81
  ## Implementation status
@@ -187,6 +187,7 @@ The first (required) parameter in eBayApi instance takes an object with followin
187
187
  | autoRefreshToken | Required<pre>Default: `true`</pre> | Auto refresh the token if it's expired. |
188
188
  | siteId<br><i>Traditional</i> | Required<br><pre>Default: `SiteId.EBAY_US`</pre> | eBay site to which you want to send the request (Trading API, Shopping API). |
189
189
  | authToken<br><i>Traditional</i> | Optional | The Auth'N'Auth token. The traditional authentication and authorization technology used by the eBay APIs. |
190
+ | parseOptions<br><i>Traditional</i> | Optional<br><pre>Default: `{ processEntities: { maxTotalExpansions: 10000 } }`</pre> | Global [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) parse options applied to all Traditional API responses. Can be overridden per-call. |
190
191
  | marketplaceId<br><i>RESTful</i> | Required<br><pre>Default: `MarketplaceId.EBAY_US`</pre> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#marketpl) REST HTTP Header. X-EBAY-C-MARKETPLACE-ID identifies the user's business context and is specified using a marketplace ID value. Note that this header does not indicate a language preference or consumer location. |
191
192
  | scope<br><i>RESTful</i> | Conditionally<bre><pre>Default:<br>`['https://api.ebay.com/oauth/api_scope']` </pre> | The scopes assigned to your application allow access to different API resources and functionality. |
192
193
  | endUserCtx<br><i>RESTful</i> | Conditionally recommended<br><i>RESTful</i> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#headers) X-EBAY\_C\_ENDUSERCTX provides various types of information associated with the request. |
@@ -562,12 +563,34 @@ The `errorCode` is extracted from the first error in the API response.
562
563
 
563
564
  ## Controlling Traditional XML request and response
564
565
 
566
+ ### Global parse options (constructor)
567
+
568
+ Pass `parseOptions` in the constructor config to apply [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) options to **all** Traditional API responses:
569
+
570
+ ```typescript
571
+ const eBay = new eBayApi({
572
+ appId: '...',
573
+ certId: '...',
574
+ devId: '...',
575
+ siteId: eBayApi.SiteId.EBAY_DE,
576
+ parseOptions: {
577
+ processEntities: {
578
+ maxTotalExpansions: 20000 // raise limit for stores with rich HTML descriptions (default: 10000)
579
+ }
580
+ }
581
+ });
582
+ ```
583
+
584
+ Per-call `parseOptions` (see below) are merged on top and take precedence.
585
+
586
+ ### Per-call options
587
+
565
588
  The second parameter in the traditional API has the following options:
566
589
 
567
590
  ```typescript
568
591
  export type Options = {
569
592
  raw?: boolean // return raw XML
570
- parseOptions?: X2jOptions // https://github.com/NaturalIntelligence/fast-xml-parser
593
+ parseOptions?: X2jOptions // https://github.com/NaturalIntelligence/fast-xml-parser — merged with global parseOptions
571
594
  xmlBuilderOptions?: XmlBuilderOptions // https://github.com/NaturalIntelligence/fast-xml-parser
572
595
  useIaf?: boolean // use IAF in header instead of Bearer
573
596
  headers?: Headers // additional Headers (key, value)
@@ -22,6 +22,13 @@ export declare const defaultXML2JSONParseOptions: {
22
22
  leadingZeros: boolean;
23
23
  };
24
24
  removeNSPrefix: boolean;
25
+ processEntities: {
26
+ enabled: boolean;
27
+ maxEntitySize: number;
28
+ maxTotalExpansions: number;
29
+ maxExpandedLength: number;
30
+ maxEntityCount: number;
31
+ };
25
32
  isArray: (name: string, jpath: string) => boolean;
26
33
  };
27
34
  export type BodyHeaders = {
@@ -55,7 +62,6 @@ export default class XMLRequest {
55
62
  constructor(callName: string, fields: Fields | null, config: XMLReqConfig, req: IEBayApiRequest);
56
63
  private getResponseWrapper;
57
64
  private getCredentials;
58
- private getParseOptions;
59
65
  private getHeaders;
60
66
  toJSON(xml: string): any;
61
67
  toXML(fields: Fields): string;
@@ -22,6 +22,13 @@ export const defaultXML2JSONParseOptions = {
22
22
  leadingZeros: false
23
23
  },
24
24
  removeNSPrefix: true,
25
+ processEntities: {
26
+ enabled: true,
27
+ maxEntitySize: 10000,
28
+ maxTotalExpansions: 10000,
29
+ maxExpandedLength: 100000,
30
+ maxEntityCount: 100
31
+ },
25
32
  isArray: (name, jpath) => {
26
33
  return /Array$/.test(jpath.slice(0, -name.length - 1));
27
34
  }
@@ -59,12 +66,6 @@ export default class XMLRequest {
59
66
  }
60
67
  } : {};
61
68
  }
62
- getParseOptions() {
63
- return {
64
- ...defaultXML2JSONParseOptions,
65
- ...this.config.parseOptions
66
- };
67
- }
68
69
  getHeaders() {
69
70
  return {
70
71
  ...defaultHeaders,
@@ -72,9 +73,8 @@ export default class XMLRequest {
72
73
  };
73
74
  }
74
75
  toJSON(xml) {
75
- const parseOptions = this.getParseOptions();
76
- log('parseOption', parseOptions);
77
- return new XMLParser(parseOptions).parse(xml);
76
+ log('parseOption', this.config.parseOptions);
77
+ return new XMLParser(this.config.parseOptions).parse(xml);
78
78
  }
79
79
  toXML(fields) {
80
80
  const HEADING = '<?xml version="1.0" encoding="utf-8"?>';
@@ -11,7 +11,20 @@ export default class Traditional extends Api {
11
11
  constructor() {
12
12
  super(...arguments);
13
13
  this.createXMLRequest = (callName, api) => async (fields, opts) => {
14
- const apiConfig = { ...defaultApiConfig, ...opts };
14
+ const apiConfig = {
15
+ ...defaultApiConfig,
16
+ ...opts,
17
+ parseOptions: {
18
+ ...defaultApiConfig.parseOptions,
19
+ ...this.config.parseOptions,
20
+ ...opts?.parseOptions,
21
+ processEntities: {
22
+ ...defaultApiConfig.parseOptions.processEntities,
23
+ ...this.config.parseOptions?.processEntities,
24
+ ...opts?.parseOptions?.processEntities
25
+ }
26
+ }
27
+ };
15
28
  try {
16
29
  return await this.request(apiConfig, api, callName, fields);
17
30
  }