amazon-creators-api 1.2.0 → 1.2.2
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 +5 -5
- package/dist/ApiClient.d.ts +107 -84
- package/dist/ApiClient.js +455 -304
- package/dist/auth/OAuth2TokenManager.d.ts +19 -0
- package/dist/auth/OAuth2TokenManager.js +55 -35
- package/package.json +2 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Amazon Creators API Node.js SDK
|
|
2
2
|
|
|
3
|
-
   
|
|
3
|
+
   
|
|
4
4
|
|
|
5
5
|
This is an **unofficial TypeScript wrapper** for the [Amazon Creators API Node.js SDK](https://affiliate-program.amazon.com/creatorsapi/docs/en-us/get-started/using-sdk).
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ This package implements a thin TypeScript wrapper around Amazon's JS runtime int
|
|
|
11
11
|
|
|
12
12
|
## Prerequisites
|
|
13
13
|
|
|
14
|
-
- Node.js version
|
|
14
|
+
- Node.js version 18 or higher
|
|
15
15
|
- [Register](https://affiliate-program.amazon.com/creatorsapi/docs/en-us/onboarding/register-for-creators-api) for the Creators API
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
@@ -22,7 +22,7 @@ npm install amazon-creators-api
|
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
|
-
See the [examples](examples) directory for usage examples.
|
|
25
|
+
See the [examples](https://github.com/ryanschiang/amazon-creators-api/tree/main/examples) directory for usage examples.
|
|
26
26
|
|
|
27
27
|
### Get Items
|
|
28
28
|
|
|
@@ -95,8 +95,8 @@ Contributions are welcome! Please open an [issue](https://github.com/ryanschiang
|
|
|
95
95
|
|
|
96
96
|
## License
|
|
97
97
|
|
|
98
|
-
Licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for details.
|
|
98
|
+
Licensed under the Apache License, Version 2.0. See the [https://github.com/ryanschiang/amazon-creators-api/blob/main/LICENSE.txt](LICENSE) file for details.
|
|
99
99
|
|
|
100
|
-
Original authorship belongs to Amazon.com, Inc. or its affiliates. See the [NOTICE](NOTICE.txt) file for details.
|
|
100
|
+
Original authorship belongs to Amazon.com, Inc. or its affiliates. See the [https://github.com/ryanschiang/amazon-creators-api/blob/main/NOTICE.txt](NOTICE.txt) file for details.
|
|
101
101
|
|
|
102
102
|
Modifications copyright (c) 2026 Ryan Chiang.
|
package/dist/ApiClient.d.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
export default ApiClient;
|
|
2
2
|
/**
|
|
3
|
-
* @module ApiClient
|
|
4
|
-
* @version 1.2.0
|
|
5
|
-
*/
|
|
3
|
+
* @module ApiClient
|
|
4
|
+
* @version 1.2.0
|
|
5
|
+
*/
|
|
6
6
|
/**
|
|
7
|
-
* Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
|
|
8
|
-
* application to use this class directly - the *Api and model classes provide the public API for the service. The
|
|
9
|
-
* contents of this file should be regarded as internal but are documented for completeness.
|
|
10
|
-
* @alias module:ApiClient
|
|
11
|
-
* @class
|
|
12
|
-
*/
|
|
7
|
+
* Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
|
|
8
|
+
* application to use this class directly - the *Api and model classes provide the public API for the service. The
|
|
9
|
+
* contents of this file should be regarded as internal but are documented for completeness.
|
|
10
|
+
* @alias module:ApiClient
|
|
11
|
+
* @class
|
|
12
|
+
*/
|
|
13
13
|
declare class ApiClient {
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
* Returns a boolean indicating if the parameter could be JSON.stringified
|
|
16
|
+
* @param param The actual parameter
|
|
17
|
+
* @returns {Boolean} Flag indicating if <code>param</code> can be JSON.stringified
|
|
18
|
+
*/
|
|
19
19
|
static canBeJsonified(str: any): boolean;
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
* Parses an ISO-8601 string representation or epoch representation of a date value.
|
|
22
|
+
* @param {String} str The date value as a string.
|
|
23
|
+
* @returns {Date} The parsed date object.
|
|
24
|
+
*/
|
|
25
25
|
static parseDate(str: string): Date;
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
* Converts a value to the specified type.
|
|
28
|
+
* @param {(String|Object)} data The data to convert, as a string or object.
|
|
29
|
+
* @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types
|
|
30
|
+
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
|
|
31
|
+
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
|
|
32
|
+
* all properties on <code>data<code> will be converted to this type.
|
|
33
|
+
* @returns An instance of the specified type or null or undefined if data is null or undefined.
|
|
34
|
+
*/
|
|
35
35
|
static convertToType(data: (string | any), type: (string | Array<string> | any | Function)): any;
|
|
36
36
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
* Constructs a new map or array model from REST data.
|
|
38
|
+
* @param data {Object|Array} The REST data.
|
|
39
|
+
* @param obj {Object|Array} The target object or array.
|
|
40
|
+
*/
|
|
41
41
|
static constructFromObject(data: any | any[], obj: any | any[], itemType: any): void;
|
|
42
42
|
/**
|
|
43
43
|
* The base URL against which to resolve every API call's (relative) path.
|
|
@@ -57,10 +57,10 @@ declare class ApiClient {
|
|
|
57
57
|
*/
|
|
58
58
|
authentications: Array<string>;
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
* The default HTTP headers to be included for all API calls.
|
|
61
|
+
* @type {Array.<String>}
|
|
62
|
+
* @default {}
|
|
63
|
+
*/
|
|
64
64
|
defaultHeaders: Array<string>;
|
|
65
65
|
/**
|
|
66
66
|
* The default HTTP timeout for all API calls.
|
|
@@ -76,14 +76,12 @@ declare class ApiClient {
|
|
|
76
76
|
*/
|
|
77
77
|
cache: boolean;
|
|
78
78
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
* If set to true, the client will save the cookies from each server
|
|
80
|
+
* response, and return them in the next request.
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
83
|
enableCookies: boolean;
|
|
84
|
-
agent: any;
|
|
85
84
|
requestAgent: any;
|
|
86
|
-
plugins: any;
|
|
87
85
|
/**
|
|
88
86
|
* OAuth2 credential ID
|
|
89
87
|
* @type {String}
|
|
@@ -155,10 +153,10 @@ declare class ApiClient {
|
|
|
155
153
|
*/
|
|
156
154
|
getAuthEndpoint(): string;
|
|
157
155
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
156
|
+
* Returns a string representation for an actual parameter.
|
|
157
|
+
* @param param The actual parameter.
|
|
158
|
+
* @returns {String} The string representation of <code>param</code>.
|
|
159
|
+
*/
|
|
162
160
|
paramToString(param: any): string;
|
|
163
161
|
/**
|
|
164
162
|
* Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values.
|
|
@@ -170,54 +168,79 @@ declare class ApiClient {
|
|
|
170
168
|
*/
|
|
171
169
|
buildUrl(path: string, pathParams: any, apiBasePath: string): string;
|
|
172
170
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
171
|
+
* Checks whether the given content type represents JSON.<br>
|
|
172
|
+
* JSON content type examples:<br>
|
|
173
|
+
* <ul>
|
|
174
|
+
* <li>application/json</li>
|
|
175
|
+
* <li>application/json; charset=UTF8</li>
|
|
176
|
+
* <li>APPLICATION/JSON</li>
|
|
177
|
+
* </ul>
|
|
178
|
+
* @param {String} contentType The MIME content type to check.
|
|
179
|
+
* @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>.
|
|
180
|
+
*/
|
|
183
181
|
isJsonMime(contentType: string): boolean;
|
|
184
182
|
/**
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
183
|
+
* Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
|
|
184
|
+
* @param {Array.<String>} contentTypes
|
|
185
|
+
* @returns {String} The chosen content type, preferring JSON.
|
|
186
|
+
*/
|
|
189
187
|
jsonPreferredMime(contentTypes: Array<string>): string;
|
|
190
188
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
* Checks whether the given parameter value represents file-like content.
|
|
190
|
+
* @param param The parameter to check.
|
|
191
|
+
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
|
|
192
|
+
*/
|
|
195
193
|
isFileParam(param: any): boolean;
|
|
196
194
|
/**
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
195
|
+
* Normalizes parameter values:
|
|
196
|
+
* <ul>
|
|
197
|
+
* <li>remove nils</li>
|
|
198
|
+
* <li>keep files and arrays</li>
|
|
199
|
+
* <li>format to string with `paramToString` for other cases</li>
|
|
200
|
+
* </ul>
|
|
201
|
+
* @param {Object.<String, Object>} params The parameters as object properties.
|
|
202
|
+
* @returns {Object.<String, Object>} normalized parameters.
|
|
203
|
+
*/
|
|
206
204
|
normalizeParams(params: any): any;
|
|
207
205
|
/**
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
206
|
+
* Builds a string representation of an array-type actual parameter, according to the given collection format.
|
|
207
|
+
* @param {Array} param An array parameter.
|
|
208
|
+
* @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
|
|
209
|
+
* @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
|
|
210
|
+
* <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
|
|
211
|
+
*/
|
|
214
212
|
buildCollectionParam(param: any[], collectionFormat: any): string | any[];
|
|
215
213
|
/**
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
applyAuthToRequest(
|
|
214
|
+
* Applies authentication values to request headers/query.
|
|
215
|
+
* @param {{headers: Object.<String, Object>, query: Object.<String, Object>}} requestContext
|
|
216
|
+
* @param {Array.<String>} authNames An array of authentication method names.
|
|
217
|
+
*/
|
|
218
|
+
applyAuthToRequest(requestContext: {
|
|
219
|
+
headers: any;
|
|
220
|
+
query: any;
|
|
221
|
+
}, authNames: Array<string>): void;
|
|
222
|
+
/**
|
|
223
|
+
* Builds URL query string.
|
|
224
|
+
* @param {Object.<String, Object>} params
|
|
225
|
+
* @returns {String}
|
|
226
|
+
*/
|
|
227
|
+
buildQueryString(params: any): string;
|
|
228
|
+
/**
|
|
229
|
+
* Appends form fields/files to a FormData instance.
|
|
230
|
+
* @param {FormData} form
|
|
231
|
+
* @param {Object.<String, Object>} formParams
|
|
232
|
+
*/
|
|
233
|
+
appendFormData(form: FormData, formParams: any): void;
|
|
234
|
+
/**
|
|
235
|
+
* Reads and normalizes fetch response body.
|
|
236
|
+
* @param {Response} response
|
|
237
|
+
* @param {*} returnType
|
|
238
|
+
* @returns {Promise<{body: *, text: (String|null)}>}
|
|
239
|
+
*/
|
|
240
|
+
parseFetchResponse(response: Response, returnType: any): Promise<{
|
|
241
|
+
body: any;
|
|
242
|
+
text: (string | null);
|
|
243
|
+
}>;
|
|
221
244
|
/**
|
|
222
245
|
* Deserializes an HTTP response body into a value of the specified type.
|
|
223
246
|
* @param {Object} response A SuperAgent response object.
|
|
@@ -247,9 +270,9 @@ declare class ApiClient {
|
|
|
247
270
|
*/
|
|
248
271
|
callApi(path: string, httpMethod: string, pathParams: any, queryParams: any, headerParams: any, formParams: any, bodyParam: any, authNames: Array<string>, contentTypes: Array<string>, accepts: Array<string>, returnType: (string | any[] | ObjectFunction), apiBasePath: string): Promise<any>;
|
|
249
272
|
/**
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
273
|
+
* Gets an array of host settings
|
|
274
|
+
* @returns An array of host settings
|
|
275
|
+
*/
|
|
253
276
|
hostSettings(): {
|
|
254
277
|
url: string;
|
|
255
278
|
description: string;
|