@sp-api-sdk/vendor-direct-fulfillment-orders-api-2021-12-28
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -5,3 +5,2 @@ "use strict"; | ||
tslib_1.__exportStar(require("./src/client"), exports); | ||
tslib_1.__exportStar(require("./src/error"), exports); | ||
tslib_1.__exportStar(require("./src/api-model/models"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VendorDirectFulfillmentOrdersApiClient = exports.clientRateLimits = void 0; | ||
/* eslint-disable prefer-regex-literals */ | ||
const common_1 = require("@sp-api-sdk/common"); | ||
const api_model_1 = require("./api-model"); | ||
const error_1 = require("./error"); | ||
exports.clientRateLimits = [ | ||
{ | ||
method: 'get', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/vendor/directFulfillment/orders/2021-12-28/purchaseOrders$'), | ||
@@ -17,2 +16,3 @@ rate: 10, | ||
method: 'get', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/vendor/directFulfillment/orders/2021-12-28/purchaseOrders/[^/]*$'), | ||
@@ -24,2 +24,3 @@ rate: 10, | ||
method: 'post', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/vendor/directFulfillment/orders/2021-12-28/acknowledgements$'), | ||
@@ -31,23 +32,7 @@ rate: 10, | ||
class VendorDirectFulfillmentOrdersApiClient extends api_model_1.VendorOrdersApi { | ||
constructor(parameters) { | ||
const config = common_1.sellingPartnerRegions[parameters.region]; | ||
if (!config) { | ||
throw new error_1.VendorDirectFulfillmentOrdersApiError(`Unknown region: ${parameters.region}`); | ||
} | ||
const { rateLimiting, ...clientParameters } = parameters; | ||
const axiosParameters = { | ||
...clientParameters, | ||
region: config.awsRegion, | ||
}; | ||
if (rateLimiting?.retry) { | ||
axiosParameters.rateLimits = exports.clientRateLimits; | ||
axiosParameters.onRetry = rateLimiting.onRetry; | ||
} | ||
const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters); | ||
const configuration = new api_model_1.Configuration(); | ||
const environment = parameters.sandbox ? 'sandbox' : 'production'; | ||
const endpoint = config.endpoints[environment]; | ||
super(configuration, endpoint, axiosInstance); | ||
constructor(configuration) { | ||
const { axios, endpoint } = (0, common_1.createAxiosInstance)(configuration, exports.clientRateLimits); | ||
super(new api_model_1.Configuration(), endpoint, axios); | ||
} | ||
} | ||
exports.VendorDirectFulfillmentOrdersApiClient = VendorDirectFulfillmentOrdersApiClient; |
export * from './src/client'; | ||
export * from './src/error'; | ||
export * from './src/api-model/models'; |
@@ -1,8 +0,7 @@ | ||
/* eslint-disable prefer-regex-literals */ | ||
import { sellingPartnerRegions, createAxiosInstance } from '@sp-api-sdk/common'; | ||
import { createAxiosInstance } from '@sp-api-sdk/common'; | ||
import { Configuration, VendorOrdersApi } from './api-model'; | ||
import { VendorDirectFulfillmentOrdersApiError } from './error'; | ||
export const clientRateLimits = [ | ||
{ | ||
method: 'get', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/vendor/directFulfillment/orders/2021-12-28/purchaseOrders$'), | ||
@@ -14,2 +13,3 @@ rate: 10, | ||
method: 'get', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/vendor/directFulfillment/orders/2021-12-28/purchaseOrders/[^/]*$'), | ||
@@ -21,2 +21,3 @@ rate: 10, | ||
method: 'post', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/vendor/directFulfillment/orders/2021-12-28/acknowledgements$'), | ||
@@ -28,22 +29,6 @@ rate: 10, | ||
export class VendorDirectFulfillmentOrdersApiClient extends VendorOrdersApi { | ||
constructor(parameters) { | ||
const config = sellingPartnerRegions[parameters.region]; | ||
if (!config) { | ||
throw new VendorDirectFulfillmentOrdersApiError(`Unknown region: ${parameters.region}`); | ||
} | ||
const { rateLimiting, ...clientParameters } = parameters; | ||
const axiosParameters = { | ||
...clientParameters, | ||
region: config.awsRegion, | ||
}; | ||
if (rateLimiting?.retry) { | ||
axiosParameters.rateLimits = clientRateLimits; | ||
axiosParameters.onRetry = rateLimiting.onRetry; | ||
} | ||
const axiosInstance = createAxiosInstance(axiosParameters); | ||
const configuration = new Configuration(); | ||
const environment = parameters.sandbox ? 'sandbox' : 'production'; | ||
const endpoint = config.endpoints[environment]; | ||
super(configuration, endpoint, axiosInstance); | ||
constructor(configuration) { | ||
const { axios, endpoint } = createAxiosInstance(configuration, clientRateLimits); | ||
super(new Configuration(), endpoint, axios); | ||
} | ||
} |
export * from './src/client'; | ||
export * from './src/error'; | ||
export * from './src/api-model/models'; |
@@ -1,13 +0,6 @@ | ||
import type { ClientConfiguration, SellingPartnerRegion, RateLimit, OnRetryHandler } from '@sp-api-sdk/common'; | ||
import { type ClientConfiguration, type RateLimit } from '@sp-api-sdk/common'; | ||
import { VendorOrdersApi } from './api-model'; | ||
export declare const clientRateLimits: RateLimit[]; | ||
export interface ClientParameters extends Omit<ClientConfiguration, 'rateLimits' | 'onRetry'> { | ||
region: SellingPartnerRegion; | ||
rateLimiting?: { | ||
retry: boolean; | ||
onRetry?: OnRetryHandler; | ||
}; | ||
} | ||
export declare class VendorDirectFulfillmentOrdersApiClient extends VendorOrdersApi { | ||
constructor(parameters: ClientParameters); | ||
constructor(configuration: ClientConfiguration); | ||
} |
@@ -5,6 +5,7 @@ { | ||
"description": "The Selling Partner API for Direct Fulfillment Orders provides programmatic access to a direct fulfillment vendor's order data.", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/es/index.js", | ||
"types": "dist/types/index.d.ts", | ||
"typedocMain": "./index.ts", | ||
"license": "MIT", | ||
@@ -30,4 +31,4 @@ "publishConfig": { | ||
"dependencies": { | ||
"@sp-api-sdk/auth": "^1.9.12", | ||
"@sp-api-sdk/common": "^1.7.14", | ||
"@sp-api-sdk/auth": "^1.9.13", | ||
"@sp-api-sdk/common": "^1.8.0", | ||
"axios": "^0.27.2" | ||
@@ -54,3 +55,3 @@ }, | ||
], | ||
"gitHead": "e6a6c9da0de5a001da60b1d3f34a3796a3adab0d" | ||
"gitHead": "975705017de9384bf28b85e97d93f866d4d71611" | ||
} |
@@ -67,2 +67,25 @@ # `vendor-direct-fulfillment-orders-api-2021-12-28` | ||
## Logging | ||
You can enable logging for both SP-API requests and responses by configuring the `logging.request` and `logging.response` properties. | ||
```javascript | ||
const client = new VendorDirectFulfillmentOrdersApiClient({ | ||
auth, | ||
region: 'eu', | ||
logging: { | ||
request: { | ||
logger: console.debug | ||
}, | ||
response: { | ||
logger: console.debug | ||
} | ||
}, | ||
}) | ||
``` | ||
Specifying `true` will use the default options, specifying an object will allow you to override the default options. | ||
This uses [axios-logger](https://github.com/hg-pyun/axios-logger) under the hood. | ||
## License | ||
@@ -69,0 +92,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105
166700
102
3596
+ Addedaxios@1.7.8(transitive)
- Removedaxios@1.7.7(transitive)
Updated@sp-api-sdk/auth@^1.9.13
Updated@sp-api-sdk/common@^1.8.0