@sp-api-sdk/notifications-api-v1 1.10.2 → 1.11.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
@@ -92,6 +92,31 @@ const client = new NotificationsApiClient({
92
92
 
93
93
  The rate limits used for each route are specified in the [API documentation](https://developer-docs.amazon.com/sp-api/docs).
94
94
 
95
+ ## Logging
96
+
97
+ You can enable logging for both SP-API requests and responses by configuring the `logging.request` and `logging.response` properties.
98
+
99
+ ```javascript
100
+ const client = new NotificationsApiClient({
101
+ auth,
102
+ region: 'eu',
103
+ logging: {
104
+ request: {
105
+ logger: console.debug
106
+ },
107
+ response: {
108
+ logger: console.debug
109
+ },
110
+ error: true,
111
+ },
112
+ })
113
+ ```
114
+
115
+ Specifying `true` will use the default options, specifying an object will allow you to override the default options.
116
+ This uses [axios-logger](https://github.com/hg-pyun/axios-logger) under the hood.
117
+ By default, if enabled, the `request` and `response` loggers will use `console.info` and the `error` logger will use `console.error`.
118
+
119
+
95
120
  ## License
96
121
 
97
122
  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,80 +1,70 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NotificationsApiClient = 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('^/notifications/v1/subscriptions/[^/]*$'),
12
11
  rate: 1,
13
12
  burst: 5,
14
13
  },
15
14
  {
16
15
  method: 'post',
16
+ // eslint-disable-next-line prefer-regex-literals
17
17
  urlRegex: new RegExp('^/notifications/v1/subscriptions/[^/]*$'),
18
18
  rate: 1,
19
19
  burst: 5,
20
20
  },
21
21
  {
22
22
  method: 'get',
23
+ // eslint-disable-next-line prefer-regex-literals
23
24
  urlRegex: new RegExp('^/notifications/v1/subscriptions/[^/]*$'),
24
25
  rate: 1,
25
26
  burst: 5,
26
27
  },
27
28
  {
28
29
  method: 'delete',
30
+ // eslint-disable-next-line prefer-regex-literals
29
31
  urlRegex: new RegExp('^/notifications/v1/subscriptions/[^/]*$'),
30
32
  rate: 1,
31
33
  burst: 5,
32
34
  },
33
35
  {
34
36
  method: 'get',
37
+ // eslint-disable-next-line prefer-regex-literals
35
38
  urlRegex: new RegExp('^/notifications/v1/destinations$'),
36
39
  rate: 1,
37
40
  burst: 5,
38
41
  },
39
42
  {
40
43
  method: 'post',
44
+ // eslint-disable-next-line prefer-regex-literals
41
45
  urlRegex: new RegExp('^/notifications/v1/destinations$'),
42
46
  rate: 1,
43
47
  burst: 5,
44
48
  },
45
49
  {
46
50
  method: 'get',
51
+ // eslint-disable-next-line prefer-regex-literals
47
52
  urlRegex: new RegExp('^/notifications/v1/destinations/[^/]*$'),
48
53
  rate: 1,
49
54
  burst: 5,
50
55
  },
51
56
  {
52
57
  method: 'delete',
58
+ // eslint-disable-next-line prefer-regex-literals
53
59
  urlRegex: new RegExp('^/notifications/v1/destinations/[^/]*$'),
54
60
  rate: 1,
55
61
  burst: 5,
56
62
  },
57
63
  ];
58
64
  class NotificationsApiClient extends api_model_1.NotificationsApi {
59
- constructor(parameters) {
60
- const config = common_1.sellingPartnerRegions[parameters.region];
61
- if (!config) {
62
- throw new error_1.NotificationsApiError(`Unknown region: ${parameters.region}`);
63
- }
64
- const { rateLimiting, ...clientParameters } = parameters;
65
- const axiosParameters = {
66
- ...clientParameters,
67
- region: config.awsRegion,
68
- };
69
- if (rateLimiting?.retry) {
70
- axiosParameters.rateLimits = exports.clientRateLimits;
71
- axiosParameters.onRetry = rateLimiting.onRetry;
72
- }
73
- const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
74
- const configuration = new api_model_1.Configuration();
75
- const environment = parameters.sandbox ? 'sandbox' : 'production';
76
- const endpoint = config.endpoints[environment];
77
- super(configuration, endpoint, axiosInstance);
65
+ constructor(configuration) {
66
+ const { axios, endpoint } = (0, common_1.createAxiosInstance)(configuration, exports.clientRateLimits);
67
+ super(new api_model_1.Configuration(), endpoint, axios);
78
68
  }
79
69
  }
80
70
  exports.NotificationsApiClient = NotificationsApiClient;
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,76 +1,66 @@
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, NotificationsApi } from './api-model';
4
- import { NotificationsApiError } 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('^/notifications/v1/subscriptions/[^/]*$'),
9
8
  rate: 1,
10
9
  burst: 5,
11
10
  },
12
11
  {
13
12
  method: 'post',
13
+ // eslint-disable-next-line prefer-regex-literals
14
14
  urlRegex: new RegExp('^/notifications/v1/subscriptions/[^/]*$'),
15
15
  rate: 1,
16
16
  burst: 5,
17
17
  },
18
18
  {
19
19
  method: 'get',
20
+ // eslint-disable-next-line prefer-regex-literals
20
21
  urlRegex: new RegExp('^/notifications/v1/subscriptions/[^/]*$'),
21
22
  rate: 1,
22
23
  burst: 5,
23
24
  },
24
25
  {
25
26
  method: 'delete',
27
+ // eslint-disable-next-line prefer-regex-literals
26
28
  urlRegex: new RegExp('^/notifications/v1/subscriptions/[^/]*$'),
27
29
  rate: 1,
28
30
  burst: 5,
29
31
  },
30
32
  {
31
33
  method: 'get',
34
+ // eslint-disable-next-line prefer-regex-literals
32
35
  urlRegex: new RegExp('^/notifications/v1/destinations$'),
33
36
  rate: 1,
34
37
  burst: 5,
35
38
  },
36
39
  {
37
40
  method: 'post',
41
+ // eslint-disable-next-line prefer-regex-literals
38
42
  urlRegex: new RegExp('^/notifications/v1/destinations$'),
39
43
  rate: 1,
40
44
  burst: 5,
41
45
  },
42
46
  {
43
47
  method: 'get',
48
+ // eslint-disable-next-line prefer-regex-literals
44
49
  urlRegex: new RegExp('^/notifications/v1/destinations/[^/]*$'),
45
50
  rate: 1,
46
51
  burst: 5,
47
52
  },
48
53
  {
49
54
  method: 'delete',
55
+ // eslint-disable-next-line prefer-regex-literals
50
56
  urlRegex: new RegExp('^/notifications/v1/destinations/[^/]*$'),
51
57
  rate: 1,
52
58
  burst: 5,
53
59
  },
54
60
  ];
55
61
  export class NotificationsApiClient extends NotificationsApi {
56
- constructor(parameters) {
57
- const config = sellingPartnerRegions[parameters.region];
58
- if (!config) {
59
- throw new NotificationsApiError(`Unknown region: ${parameters.region}`);
60
- }
61
- const { rateLimiting, ...clientParameters } = parameters;
62
- const axiosParameters = {
63
- ...clientParameters,
64
- region: config.awsRegion,
65
- };
66
- if (rateLimiting?.retry) {
67
- axiosParameters.rateLimits = clientRateLimits;
68
- axiosParameters.onRetry = rateLimiting.onRetry;
69
- }
70
- const axiosInstance = createAxiosInstance(axiosParameters);
71
- const configuration = new Configuration();
72
- const environment = parameters.sandbox ? 'sandbox' : 'production';
73
- const endpoint = config.endpoints[environment];
74
- super(configuration, endpoint, axiosInstance);
62
+ constructor(configuration) {
63
+ const { axios, endpoint } = createAxiosInstance(configuration, clientRateLimits);
64
+ super(new Configuration(), endpoint, axios);
75
65
  }
76
66
  }
@@ -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 { NotificationsApi } 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 NotificationsApiClient extends NotificationsApi {
12
- constructor(parameters: ClientParameters);
5
+ constructor(configuration: ClientConfiguration);
13
6
  }
package/package.json CHANGED
@@ -2,10 +2,11 @@
2
2
  "name": "@sp-api-sdk/notifications-api-v1",
3
3
  "author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
4
4
  "description": "The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. For more information, see the Notifications Use Case Guide",
5
- "version": "1.10.2",
5
+ "version": "1.11.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
  "notifications 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.NotificationsApiError = void 0;
4
- class NotificationsApiError extends Error {
5
- constructor(message) {
6
- super(message);
7
- this.name = 'NotificationsApiError';
8
- }
9
- }
10
- exports.NotificationsApiError = NotificationsApiError;
@@ -1,6 +0,0 @@
1
- export class NotificationsApiError extends Error {
2
- constructor(message) {
3
- super(message);
4
- this.name = 'NotificationsApiError';
5
- }
6
- }
@@ -1,3 +0,0 @@
1
- export declare class NotificationsApiError extends Error {
2
- constructor(message: string);
3
- }