@voucherify/sdk 2.2.5 → 2.2.6
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/CHANGELOG.md +6 -0
- package/README.md +2 -0
- package/dist/RequestController.d.ts +3 -1
- package/dist/VoucherifyClientSide.d.ts +4 -0
- package/dist/VoucherifyServerSide.d.ts +4 -0
- package/dist/voucherifysdk.esm.js +20 -11
- package/dist/voucherifysdk.esm.js.map +1 -1
- package/dist/voucherifysdk.umd.development.js +20 -11
- package/dist/voucherifysdk.umd.development.js.map +1 -1
- package/dist/voucherifysdk.umd.production.min.js +1 -1
- package/dist/voucherifysdk.umd.production.min.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @voucherify/sdk
|
|
2
2
|
|
|
3
|
+
## 2.2.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a266c2a`](https://github.com/voucherifyio/voucherify-js-sdk/commit/a266c2a9a4a1942e2b6d8ef54021e04d36ddb02c) [#223](https://github.com/voucherifyio/voucherify-js-sdk/pull/223) Thanks [@darekg11](https://github.com/darekg11)! - Add optional timeoutMs option to VoucherifyServerSide and VoucherifyClientSide classes defiing timeout in miliseconds after which Axios is going to abort the request. By default this is equal to 0 meaining that there is no timeout beside default Voucherify's Load balancer timeout which is set to 3 minutes
|
|
8
|
+
|
|
3
9
|
## 2.2.5
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -131,6 +131,7 @@ const client = VoucherifyServerSide({
|
|
|
131
131
|
apiVersion: 'v2018-08-01', // optional
|
|
132
132
|
channel: 'e-commerce', // optional
|
|
133
133
|
customHeaders: { "MY_CUSTOM_HEADER": "my_value" } // optional
|
|
134
|
+
timeoutMs: 10000 // optional
|
|
134
135
|
})
|
|
135
136
|
```
|
|
136
137
|
|
|
@@ -1214,6 +1215,7 @@ const client = VoucherifyClientSide({
|
|
|
1214
1215
|
apiUrl: 'https://<region>.api.voucherify.io', // optional
|
|
1215
1216
|
origin: 'example.com', // read more below
|
|
1216
1217
|
customHeaders: { "MY_CUSTOM_HEADER": "my_value" } // optional
|
|
1218
|
+
timeoutMs: 10000 // optional
|
|
1217
1219
|
})
|
|
1218
1220
|
```
|
|
1219
1221
|
|
|
@@ -3,6 +3,7 @@ export interface RequestControllerOptions {
|
|
|
3
3
|
basePath: string;
|
|
4
4
|
headers: Record<string, any>;
|
|
5
5
|
exposeErrorCause: boolean;
|
|
6
|
+
timeoutMs: number;
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* @internal
|
|
@@ -15,7 +16,8 @@ export declare class RequestController {
|
|
|
15
16
|
private lastResponseHeaders;
|
|
16
17
|
private isLastResponseHeadersSet;
|
|
17
18
|
private exposeErrorCause;
|
|
18
|
-
|
|
19
|
+
private timeoutMs;
|
|
20
|
+
constructor({ basePath, baseURL, headers, exposeErrorCause, timeoutMs }: RequestControllerOptions);
|
|
19
21
|
isLastReponseHeadersSet(): boolean;
|
|
20
22
|
getLastResponseHeaders(): Record<string, string>;
|
|
21
23
|
private setLastResponseHeaders;
|
|
@@ -78,5 +78,9 @@ export interface VoucherifyClientSideOptions {
|
|
|
78
78
|
* The original Axios error will be included in cause property of VoucherifyError
|
|
79
79
|
*/
|
|
80
80
|
exposeErrorCause?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Optionally, you can set timeout in miliseconds. After this time request will be aborted. By default Voucherify's API has timeout value of 3 minutes.
|
|
83
|
+
*/
|
|
84
|
+
timeoutMs?: number;
|
|
81
85
|
}
|
|
82
86
|
export declare function VoucherifyClientSide(options: VoucherifyClientSideOptions): ClientSide;
|
|
@@ -98,6 +98,10 @@ export interface VoucherifyServerSideOptions {
|
|
|
98
98
|
* The original Axios error will be included in cause property of VoucherifyError
|
|
99
99
|
*/
|
|
100
100
|
exposeErrorCause?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Optionally, you can set timeout in miliseconds. After this time request will be aborted. By default Voucherify's API has timeout value of 3 minutes.
|
|
103
|
+
*/
|
|
104
|
+
timeoutMs?: number;
|
|
101
105
|
}
|
|
102
106
|
export declare function VoucherifyServerSide(options: VoucherifyServerSideOptions): {
|
|
103
107
|
vouchers: Vouchers;
|
|
@@ -58,7 +58,8 @@ class RequestController {
|
|
|
58
58
|
basePath,
|
|
59
59
|
baseURL,
|
|
60
60
|
headers,
|
|
61
|
-
exposeErrorCause
|
|
61
|
+
exposeErrorCause,
|
|
62
|
+
timeoutMs
|
|
62
63
|
}) {
|
|
63
64
|
this.baseURL = void 0;
|
|
64
65
|
this.basePath = void 0;
|
|
@@ -67,12 +68,14 @@ class RequestController {
|
|
|
67
68
|
this.lastResponseHeaders = void 0;
|
|
68
69
|
this.isLastResponseHeadersSet = void 0;
|
|
69
70
|
this.exposeErrorCause = void 0;
|
|
71
|
+
this.timeoutMs = void 0;
|
|
70
72
|
this.basePath = basePath;
|
|
71
73
|
this.baseURL = baseURL;
|
|
72
74
|
this.headers = headers;
|
|
73
75
|
this.exposeErrorCause = exposeErrorCause;
|
|
74
76
|
this.lastResponseHeaders = {};
|
|
75
77
|
this.isLastResponseHeadersSet = false;
|
|
78
|
+
this.timeoutMs = timeoutMs;
|
|
76
79
|
this.request = axios.create({
|
|
77
80
|
baseURL: `${this.baseURL}/${this.basePath}/`,
|
|
78
81
|
headers: this.headers,
|
|
@@ -115,7 +118,8 @@ class RequestController {
|
|
|
115
118
|
params,
|
|
116
119
|
paramsSerializer: function (params) {
|
|
117
120
|
return Qs.stringify(params);
|
|
118
|
-
}
|
|
121
|
+
},
|
|
122
|
+
timeout: this.timeoutMs
|
|
119
123
|
});
|
|
120
124
|
this.setLastResponseHeaders(response.headers);
|
|
121
125
|
return response.data;
|
|
@@ -127,7 +131,8 @@ class RequestController {
|
|
|
127
131
|
paramsSerializer: function (params) {
|
|
128
132
|
return Qs.stringify(params);
|
|
129
133
|
},
|
|
130
|
-
headers
|
|
134
|
+
headers,
|
|
135
|
+
timeout: this.timeoutMs
|
|
131
136
|
});
|
|
132
137
|
this.setLastResponseHeaders(response.headers);
|
|
133
138
|
return response.data;
|
|
@@ -135,7 +140,8 @@ class RequestController {
|
|
|
135
140
|
|
|
136
141
|
async put(path, body, params) {
|
|
137
142
|
const response = await this.request.put(path, body, {
|
|
138
|
-
params
|
|
143
|
+
params,
|
|
144
|
+
timeout: this.timeoutMs
|
|
139
145
|
});
|
|
140
146
|
this.setLastResponseHeaders(response.headers);
|
|
141
147
|
return response.data;
|
|
@@ -143,7 +149,8 @@ class RequestController {
|
|
|
143
149
|
|
|
144
150
|
async delete(path, params) {
|
|
145
151
|
const response = await this.request.delete(path, {
|
|
146
|
-
params
|
|
152
|
+
params,
|
|
153
|
+
timeout: this.timeoutMs
|
|
147
154
|
});
|
|
148
155
|
this.setLastResponseHeaders(response.headers);
|
|
149
156
|
return response.data;
|
|
@@ -1447,7 +1454,7 @@ class MetadataSchemas {
|
|
|
1447
1454
|
// }
|
|
1448
1455
|
|
|
1449
1456
|
function VoucherifyServerSide(options) {
|
|
1450
|
-
var _options$apiUrl, _options$exposeErrorC;
|
|
1457
|
+
var _options$apiUrl, _options$exposeErrorC, _options$timeoutMs;
|
|
1451
1458
|
|
|
1452
1459
|
assert(isObject(options), 'VoucherifyServerSide: the "options" argument must be an object');
|
|
1453
1460
|
assert(isString(options.applicationId), 'VoucherifyServerSide: "options.applicationId" is required');
|
|
@@ -1457,7 +1464,7 @@ function VoucherifyServerSide(options) {
|
|
|
1457
1464
|
let headers = {
|
|
1458
1465
|
'X-App-Id': options.applicationId,
|
|
1459
1466
|
'X-App-Token': options.secretKey,
|
|
1460
|
-
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.2.
|
|
1467
|
+
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.2.6"}`,
|
|
1461
1468
|
'Content-Type': 'application/json'
|
|
1462
1469
|
};
|
|
1463
1470
|
|
|
@@ -1483,7 +1490,8 @@ function VoucherifyServerSide(options) {
|
|
|
1483
1490
|
basePath: 'v1',
|
|
1484
1491
|
baseURL: (_options$apiUrl = options.apiUrl) != null ? _options$apiUrl : 'https://api.voucherify.io',
|
|
1485
1492
|
headers,
|
|
1486
|
-
exposeErrorCause: (_options$exposeErrorC = options.exposeErrorCause) != null ? _options$exposeErrorC : false
|
|
1493
|
+
exposeErrorCause: (_options$exposeErrorC = options.exposeErrorCause) != null ? _options$exposeErrorC : false,
|
|
1494
|
+
timeoutMs: (_options$timeoutMs = options.timeoutMs) != null ? _options$timeoutMs : 0
|
|
1487
1495
|
});
|
|
1488
1496
|
const asyncActions = new AsyncActions(client);
|
|
1489
1497
|
const balance = new Balance(client);
|
|
@@ -1697,7 +1705,7 @@ class ClientSide {
|
|
|
1697
1705
|
}
|
|
1698
1706
|
|
|
1699
1707
|
function VoucherifyClientSide(options) {
|
|
1700
|
-
var _options$apiUrl, _options$exposeErrorC;
|
|
1708
|
+
var _options$apiUrl, _options$exposeErrorC, _options$timeoutMs;
|
|
1701
1709
|
|
|
1702
1710
|
assert(isObject(options), 'VoucherifyCustomer: expected "options" argument to be an object');
|
|
1703
1711
|
assert(isString(options.clientApplicationId), 'VoucherifyCustomer: "options.clientApplicationId" is required');
|
|
@@ -1707,7 +1715,7 @@ function VoucherifyClientSide(options) {
|
|
|
1707
1715
|
let headers = {
|
|
1708
1716
|
'X-Client-Application-Id': options.clientApplicationId,
|
|
1709
1717
|
'X-Client-Token': options.clientSecretKey,
|
|
1710
|
-
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.2.
|
|
1718
|
+
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.2.6"}`
|
|
1711
1719
|
};
|
|
1712
1720
|
|
|
1713
1721
|
if (environment().startsWith('Node')) {
|
|
@@ -1723,7 +1731,8 @@ function VoucherifyClientSide(options) {
|
|
|
1723
1731
|
basePath: 'client/v1',
|
|
1724
1732
|
baseURL: (_options$apiUrl = options.apiUrl) != null ? _options$apiUrl : 'https://api.voucherify.io',
|
|
1725
1733
|
headers,
|
|
1726
|
-
exposeErrorCause: (_options$exposeErrorC = options.exposeErrorCause) != null ? _options$exposeErrorC : false
|
|
1734
|
+
exposeErrorCause: (_options$exposeErrorC = options.exposeErrorCause) != null ? _options$exposeErrorC : false,
|
|
1735
|
+
timeoutMs: (_options$timeoutMs = options.timeoutMs) != null ? _options$timeoutMs : 0
|
|
1727
1736
|
});
|
|
1728
1737
|
return new ClientSide(client, options.trackingId);
|
|
1729
1738
|
}
|