@sp-api-sdk/product-type-definitions-api-2020-09-01 1.8.3 → 1.9.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
@@ -66,6 +66,29 @@ const client = new ProductTypeDefinitionsApiClient({
66
66
 
67
67
  The rate limits used for each route are specified in the [API documentation](https://developer-docs.amazon.com/sp-api/docs).
68
68
 
69
+ ## Logging
70
+
71
+ You can enable logging for both SP-API requests and responses by configuring the `logging.request` and `logging.response` properties.
72
+
73
+ ```javascript
74
+ const client = new ProductTypeDefinitionsApiClient({
75
+ auth,
76
+ region: 'eu',
77
+ logging: {
78
+ request: {
79
+ logger: console.debug
80
+ },
81
+ response: {
82
+ logger: console.debug
83
+ }
84
+ },
85
+ })
86
+ ```
87
+
88
+ Specifying `true` will use the default options, specifying an object will allow you to override the default options.
89
+ This uses [axios-logger](https://github.com/hg-pyun/axios-logger) under the hood.
90
+
91
+
69
92
  ## License
70
93
 
71
94
  MIT
package/dist/cjs/index.js CHANGED
@@ -2,5 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./src/client"), exports);
5
- tslib_1.__exportStar(require("./src/error"), exports);
6
5
  tslib_1.__exportStar(require("./src/api-model/models"), exports);
@@ -1,44 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProductTypeDefinitionsApiClient = exports.clientRateLimits = void 0;
4
- /* eslint-disable prefer-regex-literals */
5
4
  const common_1 = require("@sp-api-sdk/common");
6
5
  const api_model_1 = require("./api-model");
7
- const error_1 = require("./error");
8
6
  exports.clientRateLimits = [
9
7
  {
10
8
  method: 'get',
9
+ // eslint-disable-next-line prefer-regex-literals
11
10
  urlRegex: new RegExp('^/definitions/2020-09-01/productTypes$'),
12
11
  rate: 5,
13
12
  burst: 10,
14
13
  },
15
14
  {
16
15
  method: 'get',
16
+ // eslint-disable-next-line prefer-regex-literals
17
17
  urlRegex: new RegExp('^/definitions/2020-09-01/productTypes/[^/]*$'),
18
18
  rate: 5,
19
19
  burst: 10,
20
20
  },
21
21
  ];
22
22
  class ProductTypeDefinitionsApiClient extends api_model_1.DefinitionsApi {
23
- constructor(parameters) {
24
- const config = common_1.sellingPartnerRegions[parameters.region];
25
- if (!config) {
26
- throw new error_1.ProductTypeDefinitionsApiError(`Unknown region: ${parameters.region}`);
27
- }
28
- const { rateLimiting, ...clientParameters } = parameters;
29
- const axiosParameters = {
30
- ...clientParameters,
31
- region: config.awsRegion,
32
- };
33
- if (rateLimiting?.retry) {
34
- axiosParameters.rateLimits = exports.clientRateLimits;
35
- axiosParameters.onRetry = rateLimiting.onRetry;
36
- }
37
- const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
38
- const configuration = new api_model_1.Configuration();
39
- const environment = parameters.sandbox ? 'sandbox' : 'production';
40
- const endpoint = config.endpoints[environment];
41
- super(configuration, endpoint, axiosInstance);
23
+ constructor(configuration) {
24
+ const { axios, endpoint } = (0, common_1.createAxiosInstance)(configuration, exports.clientRateLimits);
25
+ super(new api_model_1.Configuration(), endpoint, axios);
42
26
  }
43
27
  }
44
28
  exports.ProductTypeDefinitionsApiClient = ProductTypeDefinitionsApiClient;
package/dist/es/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from './src/client';
2
- export * from './src/error';
3
2
  export * from './src/api-model/models';
@@ -1,40 +1,24 @@
1
- /* eslint-disable prefer-regex-literals */
2
- import { sellingPartnerRegions, createAxiosInstance } from '@sp-api-sdk/common';
1
+ import { createAxiosInstance } from '@sp-api-sdk/common';
3
2
  import { Configuration, DefinitionsApi } from './api-model';
4
- import { ProductTypeDefinitionsApiError } from './error';
5
3
  export const clientRateLimits = [
6
4
  {
7
5
  method: 'get',
6
+ // eslint-disable-next-line prefer-regex-literals
8
7
  urlRegex: new RegExp('^/definitions/2020-09-01/productTypes$'),
9
8
  rate: 5,
10
9
  burst: 10,
11
10
  },
12
11
  {
13
12
  method: 'get',
13
+ // eslint-disable-next-line prefer-regex-literals
14
14
  urlRegex: new RegExp('^/definitions/2020-09-01/productTypes/[^/]*$'),
15
15
  rate: 5,
16
16
  burst: 10,
17
17
  },
18
18
  ];
19
19
  export class ProductTypeDefinitionsApiClient extends DefinitionsApi {
20
- constructor(parameters) {
21
- const config = sellingPartnerRegions[parameters.region];
22
- if (!config) {
23
- throw new ProductTypeDefinitionsApiError(`Unknown region: ${parameters.region}`);
24
- }
25
- const { rateLimiting, ...clientParameters } = parameters;
26
- const axiosParameters = {
27
- ...clientParameters,
28
- region: config.awsRegion,
29
- };
30
- if (rateLimiting?.retry) {
31
- axiosParameters.rateLimits = clientRateLimits;
32
- axiosParameters.onRetry = rateLimiting.onRetry;
33
- }
34
- const axiosInstance = createAxiosInstance(axiosParameters);
35
- const configuration = new Configuration();
36
- const environment = parameters.sandbox ? 'sandbox' : 'production';
37
- const endpoint = config.endpoints[environment];
38
- super(configuration, endpoint, axiosInstance);
20
+ constructor(configuration) {
21
+ const { axios, endpoint } = createAxiosInstance(configuration, clientRateLimits);
22
+ super(new Configuration(), endpoint, axios);
39
23
  }
40
24
  }
@@ -1,3 +1,2 @@
1
1
  export * from './src/client';
2
- export * from './src/error';
3
2
  export * from './src/api-model/models';
@@ -1,13 +1,6 @@
1
- import type { ClientConfiguration, SellingPartnerRegion, RateLimit, OnRetryHandler } from '@sp-api-sdk/common';
1
+ import { type ClientConfiguration, type RateLimit } from '@sp-api-sdk/common';
2
2
  import { DefinitionsApi } from './api-model';
3
3
  export declare const clientRateLimits: RateLimit[];
4
- export interface ClientParameters extends Omit<ClientConfiguration, 'rateLimits' | 'onRetry'> {
5
- region: SellingPartnerRegion;
6
- rateLimiting?: {
7
- retry: boolean;
8
- onRetry?: OnRetryHandler;
9
- };
10
- }
11
4
  export declare class ProductTypeDefinitionsApiClient extends DefinitionsApi {
12
- constructor(parameters: ClientParameters);
5
+ constructor(configuration: ClientConfiguration);
13
6
  }
package/package.json CHANGED
@@ -2,10 +2,11 @@
2
2
  "name": "@sp-api-sdk/product-type-definitions-api-2020-09-01",
3
3
  "author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
4
4
  "description": "The Selling Partner API for Product Type Definitions provides programmatic access to attribute and data requirements for product types in the Amazon catalog. Use this API to return the JSON Schema for a product type that you can then use with other Selling Partner APIs, such as the Selling Partner API for Listings Items, the Selling Partner API for Catalog Items, and the Selling Partner API for Feeds (for JSON-based listing feeds). For more information, see the Product Type Definitions API Use Case Guide.",
5
- "version": "1.8.3",
5
+ "version": "1.9.0",
6
6
  "main": "dist/cjs/index.js",
7
7
  "module": "dist/es/index.js",
8
8
  "types": "dist/types/index.d.ts",
9
+ "typedocMain": "./index.ts",
9
10
  "license": "MIT",
10
11
  "publishConfig": {
11
12
  "access": "public"
@@ -26,8 +27,8 @@
26
27
  "test": "NODE_ENV='test' yarn jest"
27
28
  },
28
29
  "dependencies": {
29
- "@sp-api-sdk/auth": "^1.9.12",
30
- "@sp-api-sdk/common": "^1.7.14",
30
+ "@sp-api-sdk/auth": "^1.9.13",
31
+ "@sp-api-sdk/common": "^1.8.0",
31
32
  "axios": "^0.27.2"
32
33
  },
33
34
  "repository": {
@@ -49,5 +50,5 @@
49
50
  "sp sdk",
50
51
  "product type definitions api"
51
52
  ],
52
- "gitHead": "e6a6c9da0de5a001da60b1d3f34a3796a3adab0d"
53
+ "gitHead": "975705017de9384bf28b85e97d93f866d4d71611"
53
54
  }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProductTypeDefinitionsApiError = void 0;
4
- class ProductTypeDefinitionsApiError extends Error {
5
- constructor(message) {
6
- super(message);
7
- this.name = 'ProductTypeDefinitionsApiError';
8
- }
9
- }
10
- exports.ProductTypeDefinitionsApiError = ProductTypeDefinitionsApiError;
@@ -1,6 +0,0 @@
1
- export class ProductTypeDefinitionsApiError extends Error {
2
- constructor(message) {
3
- super(message);
4
- this.name = 'ProductTypeDefinitionsApiError';
5
- }
6
- }
@@ -1,3 +0,0 @@
1
- export declare class ProductTypeDefinitionsApiError extends Error {
2
- constructor(message: string);
3
- }