@sp-api-sdk/tokens-api-2021-03-01 3.0.16 → 3.0.17
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.
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* Do not edit the class manually.
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
|
|
16
|
+
exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.replaceWithSerializableTypeIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
|
|
17
17
|
const base_1 = require("./base");
|
|
18
18
|
exports.DUMMY_BASE_URL = 'https://example.com';
|
|
19
19
|
/**
|
|
@@ -63,7 +63,7 @@ function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
|
|
|
63
63
|
if (parameter == null)
|
|
64
64
|
return;
|
|
65
65
|
if (typeof parameter === "object") {
|
|
66
|
-
if (Array.isArray(parameter)) {
|
|
66
|
+
if (Array.isArray(parameter) || parameter instanceof Set) {
|
|
67
67
|
parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
@@ -85,13 +85,27 @@ const setSearchParams = function (url, ...objects) {
|
|
|
85
85
|
url.search = searchParams.toString();
|
|
86
86
|
};
|
|
87
87
|
exports.setSearchParams = setSearchParams;
|
|
88
|
+
/**
|
|
89
|
+
* JSON serialization helper function which replaces instances of unserializable types with serializable ones.
|
|
90
|
+
* This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
|
|
91
|
+
* Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
|
|
92
|
+
*/
|
|
93
|
+
const replaceWithSerializableTypeIfNeeded = function (key, value) {
|
|
94
|
+
if (value instanceof Set) {
|
|
95
|
+
return Array.from(value);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
exports.replaceWithSerializableTypeIfNeeded = replaceWithSerializableTypeIfNeeded;
|
|
88
102
|
const serializeDataIfNeeded = function (value, requestOptions, configuration) {
|
|
89
103
|
const nonString = typeof value !== 'string';
|
|
90
104
|
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
91
105
|
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
92
106
|
: nonString;
|
|
93
107
|
return needsSerialization
|
|
94
|
-
? JSON.stringify(value !== undefined ? value : {})
|
|
108
|
+
? JSON.stringify(value !== undefined ? value : {}, exports.replaceWithSerializableTypeIfNeeded)
|
|
95
109
|
: (value || "");
|
|
96
110
|
};
|
|
97
111
|
exports.serializeDataIfNeeded = serializeDataIfNeeded;
|
|
@@ -55,7 +55,7 @@ function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
|
|
|
55
55
|
if (parameter == null)
|
|
56
56
|
return;
|
|
57
57
|
if (typeof parameter === "object") {
|
|
58
|
-
if (Array.isArray(parameter)) {
|
|
58
|
+
if (Array.isArray(parameter) || parameter instanceof Set) {
|
|
59
59
|
parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
@@ -76,13 +76,26 @@ export const setSearchParams = function (url, ...objects) {
|
|
|
76
76
|
setFlattenedQueryParams(searchParams, objects);
|
|
77
77
|
url.search = searchParams.toString();
|
|
78
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* JSON serialization helper function which replaces instances of unserializable types with serializable ones.
|
|
81
|
+
* This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
|
|
82
|
+
* Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
|
|
83
|
+
*/
|
|
84
|
+
export const replaceWithSerializableTypeIfNeeded = function (key, value) {
|
|
85
|
+
if (value instanceof Set) {
|
|
86
|
+
return Array.from(value);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
79
92
|
export const serializeDataIfNeeded = function (value, requestOptions, configuration) {
|
|
80
93
|
const nonString = typeof value !== 'string';
|
|
81
94
|
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
82
95
|
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
83
96
|
: nonString;
|
|
84
97
|
return needsSerialization
|
|
85
|
-
? JSON.stringify(value !== undefined ? value : {})
|
|
98
|
+
? JSON.stringify(value !== undefined ? value : {}, replaceWithSerializableTypeIfNeeded)
|
|
86
99
|
: (value || "");
|
|
87
100
|
};
|
|
88
101
|
export const toPathString = function (url) {
|
|
@@ -23,6 +23,12 @@ export declare const setBasicAuthToObject: (object: any, configuration?: Configu
|
|
|
23
23
|
export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
|
|
24
24
|
export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
|
|
25
25
|
export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
|
|
26
|
+
/**
|
|
27
|
+
* JSON serialization helper function which replaces instances of unserializable types with serializable ones.
|
|
28
|
+
* This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
|
|
29
|
+
* Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
|
|
30
|
+
*/
|
|
31
|
+
export declare const replaceWithSerializableTypeIfNeeded: (key: any, value: any) => any;
|
|
26
32
|
export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
|
|
27
33
|
export declare const toPathString: (url: URL) => string;
|
|
28
34
|
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sp-api-sdk/tokens-api-2021-03-01",
|
|
3
3
|
"author": "Bertrand Marron <bertrand@bizon.solutions>",
|
|
4
4
|
"description": "The Selling Partner API for Tokens provides a secure way to access a customer's PII (Personally Identifiable Information). You can call the Tokens API to get a Restricted Data Token (RDT) for one or more restricted resources that you specify. The RDT authorizes subsequent calls to restricted operations that correspond to the restricted resources that you specified. For more information, see the Tokens API Use Case Guide.",
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.17",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
7
|
"module": "dist/es/index.js",
|
|
8
8
|
"types": "dist/types/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dist/**/*.d.ts"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@sp-api-sdk/common": "2.1.
|
|
21
|
+
"@sp-api-sdk/common": "2.1.26",
|
|
22
22
|
"axios": "^1.13.2"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"sp sdk",
|
|
41
41
|
"tokens api"
|
|
42
42
|
],
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "650fb0a15023db11b60d7de2c61a4592c2523d28"
|
|
44
44
|
}
|