@sp-api-sdk/services-api-v1 1.6.20 → 1.6.21
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 +3 -0
- package/dist/cjs/src/client.js +12 -9
- package/dist/es/src/client.js +12 -9
- package/dist/types/src/client.d.ts +3 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
With the Services API, you can build applications that help service providers get and modify their service orders.
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@sp-api-sdk/services-api-v1)
|
|
6
|
+
[](https://github.com/xojs/xo)
|
|
7
|
+
|
|
5
8
|
## Documentation
|
|
6
9
|
|
|
7
10
|
Learn more about this Selling Partner API by visiting the [official documentation](https://github.com/amzn/selling-partner-api-docs/tree/main/references/services-api/services.md).
|
package/dist/cjs/src/client.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServicesApiClient = exports.
|
|
3
|
+
exports.ServicesApiClient = exports.clientRateLimits = void 0;
|
|
4
4
|
/* eslint-disable prefer-regex-literals */
|
|
5
5
|
const common_1 = require("@sp-api-sdk/common");
|
|
6
6
|
const api_model_1 = require("./api-model");
|
|
7
7
|
const error_1 = require("./error");
|
|
8
|
-
exports.
|
|
8
|
+
exports.clientRateLimits = [
|
|
9
9
|
{
|
|
10
10
|
method: 'get',
|
|
11
11
|
urlRegex: new RegExp('^/service/v1/serviceJobs/[^/]*$'),
|
|
@@ -45,20 +45,23 @@ exports.RATE_LIMITS = [
|
|
|
45
45
|
];
|
|
46
46
|
class ServicesApiClient extends api_model_1.ServiceApi {
|
|
47
47
|
constructor(parameters) {
|
|
48
|
-
const
|
|
48
|
+
const config = common_1.sellingPartnerRegions[parameters.region];
|
|
49
|
+
if (!config) {
|
|
50
|
+
throw new error_1.ServicesApiError(`Unknown region: ${parameters.region}`);
|
|
51
|
+
}
|
|
49
52
|
const { rateLimiting, ...clientParameters } = parameters;
|
|
50
|
-
const axiosParameters = {
|
|
53
|
+
const axiosParameters = {
|
|
54
|
+
...clientParameters,
|
|
55
|
+
region: config.awsRegion,
|
|
56
|
+
};
|
|
51
57
|
if (rateLimiting?.retry) {
|
|
52
|
-
axiosParameters.rateLimits = exports.
|
|
58
|
+
axiosParameters.rateLimits = exports.clientRateLimits;
|
|
53
59
|
axiosParameters.onRetry = rateLimiting.onRetry;
|
|
54
60
|
}
|
|
55
61
|
const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
|
|
56
62
|
const configuration = new api_model_1.Configuration();
|
|
57
63
|
const environment = parameters.sandbox ? 'sandbox' : 'production';
|
|
58
|
-
const endpoint =
|
|
59
|
-
if (!endpoint) {
|
|
60
|
-
throw new error_1.ServicesApiError(`Unknown region : ${region}`);
|
|
61
|
-
}
|
|
64
|
+
const endpoint = config.endpoints[environment];
|
|
62
65
|
super(configuration, endpoint, axiosInstance);
|
|
63
66
|
}
|
|
64
67
|
}
|
package/dist/es/src/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable prefer-regex-literals */
|
|
2
|
-
import {
|
|
2
|
+
import { sellingPartnerRegions, createAxiosInstance } from '@sp-api-sdk/common';
|
|
3
3
|
import { Configuration, ServiceApi } from './api-model';
|
|
4
4
|
import { ServicesApiError } from './error';
|
|
5
|
-
export const
|
|
5
|
+
export const clientRateLimits = [
|
|
6
6
|
{
|
|
7
7
|
method: 'get',
|
|
8
8
|
urlRegex: new RegExp('^/service/v1/serviceJobs/[^/]*$'),
|
|
@@ -42,20 +42,23 @@ export const RATE_LIMITS = [
|
|
|
42
42
|
];
|
|
43
43
|
export class ServicesApiClient extends ServiceApi {
|
|
44
44
|
constructor(parameters) {
|
|
45
|
-
const
|
|
45
|
+
const config = sellingPartnerRegions[parameters.region];
|
|
46
|
+
if (!config) {
|
|
47
|
+
throw new ServicesApiError(`Unknown region: ${parameters.region}`);
|
|
48
|
+
}
|
|
46
49
|
const { rateLimiting, ...clientParameters } = parameters;
|
|
47
|
-
const axiosParameters = {
|
|
50
|
+
const axiosParameters = {
|
|
51
|
+
...clientParameters,
|
|
52
|
+
region: config.awsRegion,
|
|
53
|
+
};
|
|
48
54
|
if (rateLimiting?.retry) {
|
|
49
|
-
axiosParameters.rateLimits =
|
|
55
|
+
axiosParameters.rateLimits = clientRateLimits;
|
|
50
56
|
axiosParameters.onRetry = rateLimiting.onRetry;
|
|
51
57
|
}
|
|
52
58
|
const axiosInstance = createAxiosInstance(axiosParameters);
|
|
53
59
|
const configuration = new Configuration();
|
|
54
60
|
const environment = parameters.sandbox ? 'sandbox' : 'production';
|
|
55
|
-
const endpoint = endpoints[environment]
|
|
56
|
-
if (!endpoint) {
|
|
57
|
-
throw new ServicesApiError(`Unknown region : ${region}`);
|
|
58
|
-
}
|
|
61
|
+
const endpoint = config.endpoints[environment];
|
|
59
62
|
super(configuration, endpoint, axiosInstance);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ClientConfiguration, RateLimit, OnRetryHandler } from '@sp-api-sdk/common';
|
|
1
|
+
import type { ClientConfiguration, SellingPartnerRegion, RateLimit, OnRetryHandler } from '@sp-api-sdk/common';
|
|
2
2
|
import { ServiceApi } from './api-model';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const clientRateLimits: RateLimit[];
|
|
4
4
|
export interface ClientParameters extends Omit<ClientConfiguration, 'rateLimits' | 'onRetry'> {
|
|
5
|
+
region: SellingPartnerRegion;
|
|
5
6
|
rateLimiting?: {
|
|
6
7
|
retry: boolean;
|
|
7
8
|
onRetry?: OnRetryHandler;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sp-api-sdk/services-api-v1",
|
|
3
3
|
"author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
|
|
4
4
|
"description": "With the Services API, you can build applications that help service providers get and modify their service orders.",
|
|
5
|
-
"version": "1.6.
|
|
5
|
+
"version": "1.6.21",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
7
|
"module": "dist/es/index.js",
|
|
8
8
|
"types": "dist/types/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"test": "NODE_ENV='test' yarn jest"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@sp-api-sdk/auth": "^1.9.
|
|
29
|
-
"@sp-api-sdk/common": "^1.7.
|
|
28
|
+
"@sp-api-sdk/auth": "^1.9.6",
|
|
29
|
+
"@sp-api-sdk/common": "^1.7.8",
|
|
30
30
|
"axios": "^0.24.0"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"sp sdk",
|
|
49
49
|
"services api"
|
|
50
50
|
],
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "f21b5cb511abd110bf1f07843558719993f36187"
|
|
52
52
|
}
|