@sp-api-sdk/vendor-direct-fulfillment-orders-api-v1 1.7.2 → 1.8.1

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
@@ -64,6 +64,31 @@ const client = new VendorDirectFulfillmentOrdersApiClient({
64
64
 
65
65
  The rate limits used for each route are specified in the [API documentation](https://developer-docs.amazon.com/sp-api/docs).
66
66
 
67
+ ## Logging
68
+
69
+ You can enable logging for both SP-API requests and responses by configuring the `logging.request` and `logging.response` properties.
70
+
71
+ ```javascript
72
+ const client = new VendorDirectFulfillmentOrdersApiClient({
73
+ auth,
74
+ region: 'eu',
75
+ logging: {
76
+ request: {
77
+ logger: console.debug
78
+ },
79
+ response: {
80
+ logger: console.debug
81
+ },
82
+ error: true,
83
+ },
84
+ })
85
+ ```
86
+
87
+ Specifying `true` will use the default options, specifying an object will allow you to override the default options.
88
+ This uses [axios-logger](https://github.com/hg-pyun/axios-logger) under the hood.
89
+ By default, if enabled, the `request` and `response` loggers will use `console.info` and the `error` logger will use `console.error`.
90
+
91
+
67
92
  ## License
68
93
 
69
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,50 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VendorDirectFulfillmentOrdersApiClient = 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('^/vendor/directFulfillment/orders/v1/purchaseOrders$'),
12
11
  rate: 10,
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('^/vendor/directFulfillment/orders/v1/purchaseOrders/[^/]*$'),
18
18
  rate: 10,
19
19
  burst: 10,
20
20
  },
21
21
  {
22
22
  method: 'post',
23
+ // eslint-disable-next-line prefer-regex-literals
23
24
  urlRegex: new RegExp('^/vendor/directFulfillment/orders/v1/acknowledgements$'),
24
25
  rate: 10,
25
26
  burst: 10,
26
27
  },
27
28
  ];
28
29
  class VendorDirectFulfillmentOrdersApiClient extends api_model_1.VendorOrdersApi {
29
- constructor(parameters) {
30
- const config = common_1.sellingPartnerRegions[parameters.region];
31
- if (!config) {
32
- throw new error_1.VendorDirectFulfillmentOrdersApiError(`Unknown region: ${parameters.region}`);
33
- }
34
- const { rateLimiting, ...clientParameters } = parameters;
35
- const axiosParameters = {
36
- ...clientParameters,
37
- region: config.awsRegion,
38
- };
39
- if (rateLimiting?.retry) {
40
- axiosParameters.rateLimits = exports.clientRateLimits;
41
- axiosParameters.onRetry = rateLimiting.onRetry;
42
- }
43
- const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
44
- const configuration = new api_model_1.Configuration();
45
- const environment = parameters.sandbox ? 'sandbox' : 'production';
46
- const endpoint = config.endpoints[environment];
47
- super(configuration, endpoint, axiosInstance);
30
+ constructor(configuration) {
31
+ const { axios, endpoint } = (0, common_1.createAxiosInstance)(configuration, exports.clientRateLimits);
32
+ super(new api_model_1.Configuration(), endpoint, axios);
48
33
  }
49
34
  }
50
35
  exports.VendorDirectFulfillmentOrdersApiClient = VendorDirectFulfillmentOrdersApiClient;
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,46 +1,31 @@
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, VendorOrdersApi } from './api-model';
4
- import { VendorDirectFulfillmentOrdersApiError } 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('^/vendor/directFulfillment/orders/v1/purchaseOrders$'),
9
8
  rate: 10,
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('^/vendor/directFulfillment/orders/v1/purchaseOrders/[^/]*$'),
15
15
  rate: 10,
16
16
  burst: 10,
17
17
  },
18
18
  {
19
19
  method: 'post',
20
+ // eslint-disable-next-line prefer-regex-literals
20
21
  urlRegex: new RegExp('^/vendor/directFulfillment/orders/v1/acknowledgements$'),
21
22
  rate: 10,
22
23
  burst: 10,
23
24
  },
24
25
  ];
25
26
  export class VendorDirectFulfillmentOrdersApiClient extends VendorOrdersApi {
26
- constructor(parameters) {
27
- const config = sellingPartnerRegions[parameters.region];
28
- if (!config) {
29
- throw new VendorDirectFulfillmentOrdersApiError(`Unknown region: ${parameters.region}`);
30
- }
31
- const { rateLimiting, ...clientParameters } = parameters;
32
- const axiosParameters = {
33
- ...clientParameters,
34
- region: config.awsRegion,
35
- };
36
- if (rateLimiting?.retry) {
37
- axiosParameters.rateLimits = clientRateLimits;
38
- axiosParameters.onRetry = rateLimiting.onRetry;
39
- }
40
- const axiosInstance = createAxiosInstance(axiosParameters);
41
- const configuration = new Configuration();
42
- const environment = parameters.sandbox ? 'sandbox' : 'production';
43
- const endpoint = config.endpoints[environment];
44
- super(configuration, endpoint, axiosInstance);
27
+ constructor(configuration) {
28
+ const { axios, endpoint } = createAxiosInstance(configuration, clientRateLimits);
29
+ super(new Configuration(), endpoint, axios);
45
30
  }
46
31
  }
@@ -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 { VendorOrdersApi } 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 VendorDirectFulfillmentOrdersApiClient extends VendorOrdersApi {
12
- constructor(parameters: ClientParameters);
5
+ constructor(configuration: ClientConfiguration);
13
6
  }
package/package.json CHANGED
@@ -2,10 +2,11 @@
2
2
  "name": "@sp-api-sdk/vendor-direct-fulfillment-orders-api-v1",
3
3
  "author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
4
4
  "description": "The Selling Partner API for Direct Fulfillment Orders provides programmatic access to a direct fulfillment vendor's order data.",
5
- "version": "1.7.2",
5
+ "version": "1.8.1",
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,9 +27,9 @@
26
27
  "test": "NODE_ENV='test' yarn jest"
27
28
  },
28
29
  "dependencies": {
29
- "@sp-api-sdk/auth": "^1.9.11",
30
- "@sp-api-sdk/common": "^1.7.13",
31
- "axios": "^0.26.1"
30
+ "@sp-api-sdk/auth": "^1.9.14",
31
+ "@sp-api-sdk/common": "^1.9.0",
32
+ "axios": "^0.27.2"
32
33
  },
33
34
  "repository": {
34
35
  "type": "git",
@@ -49,5 +50,5 @@
49
50
  "sp sdk",
50
51
  "vendor direct fulfillment orders api"
51
52
  ],
52
- "gitHead": "61adb3dd4480de30ba48c20a1da60cebf9d4f0ac"
53
+ "gitHead": "15c172555c85ce89731cebb62eb7e23f550f9506"
53
54
  }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VendorDirectFulfillmentOrdersApiError = void 0;
4
- class VendorDirectFulfillmentOrdersApiError extends Error {
5
- constructor(message) {
6
- super(message);
7
- this.name = 'VendorDirectFulfillmentOrdersApiError';
8
- }
9
- }
10
- exports.VendorDirectFulfillmentOrdersApiError = VendorDirectFulfillmentOrdersApiError;
@@ -1,6 +0,0 @@
1
- export class VendorDirectFulfillmentOrdersApiError extends Error {
2
- constructor(message) {
3
- super(message);
4
- this.name = 'VendorDirectFulfillmentOrdersApiError';
5
- }
6
- }
@@ -1,3 +0,0 @@
1
- export declare class VendorDirectFulfillmentOrdersApiError extends Error {
2
- constructor(message: string);
3
- }