@allthings/sdk 4.7.0 → 5.0.0
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 +17 -5
- package/dist/cli.js +51 -46
- package/dist/lib.cjs.js +51 -46
- package/dist/lib.esm.js +33 -28
- package/dist/lib.umd.min.js +1 -1
- package/dist/src/rest/methods/app.d.ts +2 -0
- package/dist/src/rest/methods/booking.d.ts +15 -0
- package/dist/src/rest/methods/booking.test.d.ts +1 -0
- package/dist/src/rest/types.d.ts +3 -0
- package/dist/test/constants.d.ts +1 -0
- package/package.json +25 -40
package/dist/lib.cjs.js
CHANGED
|
@@ -26,7 +26,7 @@ var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
|
|
|
26
26
|
var url__default = /*#__PURE__*/_interopDefaultLegacy(url);
|
|
27
27
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
28
28
|
|
|
29
|
-
const version = "
|
|
29
|
+
const version = "5.0.0";
|
|
30
30
|
|
|
31
31
|
const REST_API_URL = 'https://api.allthings.me';
|
|
32
32
|
const OAUTH_URL = 'https://accounts.allthings.me';
|
|
@@ -69,7 +69,7 @@ const isEligibleForClientRedirect$1 = (params) => {
|
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
-
const getRedirectUrl$1 = (params) => `${params.oauthUrl}/oauth/authorize?${querystring__default[
|
|
72
|
+
const getRedirectUrl$1 = (params) => `${params.oauthUrl}/oauth/authorize?${querystring__default["default"].stringify(castToAuthorizationRequestParams$1(params))}`;
|
|
73
73
|
const castToTokenRequestParams$2 = (params) => {
|
|
74
74
|
const { authorizationCode, redirectUri, clientId, clientSecret } = params;
|
|
75
75
|
if (!clientId) {
|
|
@@ -96,14 +96,14 @@ const requestToken$3 = (tokenRequester, params) => tokenRequester(castToTokenReq
|
|
|
96
96
|
function createTokenStore(initialToken) {
|
|
97
97
|
const token = new Map(Object.entries(initialToken || {}));
|
|
98
98
|
return {
|
|
99
|
-
get: key => token.get(key),
|
|
99
|
+
get: (key) => token.get(key),
|
|
100
100
|
reset: () => token.clear(),
|
|
101
|
-
set: update => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
|
|
101
|
+
set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const SUBSCRIPTIONS = (process.env.DEBUG &&
|
|
106
|
-
process.env.DEBUG.split(',').map(item => item.trim())) ||
|
|
106
|
+
process.env.DEBUG.split(',').map((item) => item.trim())) ||
|
|
107
107
|
[];
|
|
108
108
|
function makeLogger(name) {
|
|
109
109
|
return ['log', 'info', 'warn', 'error'].reduce((logger, type) => (Object.assign(Object.assign({}, logger), { [type]: function log(...logs) {
|
|
@@ -119,8 +119,8 @@ function makeLogger(name) {
|
|
|
119
119
|
const logger = makeLogger('OAuth Token Request');
|
|
120
120
|
const makeFetchTokenRequester = (url) => async (params) => {
|
|
121
121
|
try {
|
|
122
|
-
const response = await fetch__default[
|
|
123
|
-
body: querystring__default[
|
|
122
|
+
const response = await fetch__default["default"](url, {
|
|
123
|
+
body: querystring__default["default"].stringify(params),
|
|
124
124
|
cache: 'no-cache',
|
|
125
125
|
credentials: 'omit',
|
|
126
126
|
headers: {
|
|
@@ -193,9 +193,7 @@ function fnClearInterval(intervalId) {
|
|
|
193
193
|
function pseudoRandomString(length = 16) {
|
|
194
194
|
let token = '';
|
|
195
195
|
while (token.length < length) {
|
|
196
|
-
token += Math.random()
|
|
197
|
-
.toString(36)
|
|
198
|
-
.substr(2);
|
|
196
|
+
token += Math.random().toString(36).substr(2);
|
|
199
197
|
}
|
|
200
198
|
return token.substr(0, length);
|
|
201
199
|
}
|
|
@@ -371,6 +369,13 @@ async function activeUnitsGetByAppId(client, appId) {
|
|
|
371
369
|
return client.get(`/v1/apps/${appId}/active-units`);
|
|
372
370
|
}
|
|
373
371
|
|
|
372
|
+
async function bookingGetById(client, bookingId) {
|
|
373
|
+
return client.get(`/v1/bookings/${bookingId}`);
|
|
374
|
+
}
|
|
375
|
+
async function bookingUpdateById(client, bookingId, data) {
|
|
376
|
+
return client.patch(`/v1/bookings/${bookingId}`, data);
|
|
377
|
+
}
|
|
378
|
+
|
|
374
379
|
async function bucketGet(client, bucketId) {
|
|
375
380
|
return client.get(`/v1/buckets/${bucketId}`);
|
|
376
381
|
}
|
|
@@ -415,7 +420,7 @@ async function createManyFilesSorted(files, client) {
|
|
|
415
420
|
error: result.filter((item) => item instanceof Error),
|
|
416
421
|
success: result
|
|
417
422
|
.filter((item) => !(item instanceof Error))
|
|
418
|
-
.map(item => item.id),
|
|
423
|
+
.map((item) => item.id),
|
|
419
424
|
};
|
|
420
425
|
}
|
|
421
426
|
|
|
@@ -571,10 +576,10 @@ function remapKeys(input, mapFn) {
|
|
|
571
576
|
}
|
|
572
577
|
|
|
573
578
|
function camelCaseToDash(input) {
|
|
574
|
-
return input.replace(/([A-Z])/g, g => `-${g[0].toLowerCase()}`);
|
|
579
|
+
return input.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`);
|
|
575
580
|
}
|
|
576
581
|
function dashCaseToCamel(input) {
|
|
577
|
-
return input.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
582
|
+
return input.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
578
583
|
}
|
|
579
584
|
|
|
580
585
|
var EnumNotificationSettingsValue;
|
|
@@ -856,7 +861,7 @@ async function put(request, method, body, returnRawResultObject) {
|
|
|
856
861
|
return request('put', method, { body }, returnRawResultObject);
|
|
857
862
|
}
|
|
858
863
|
|
|
859
|
-
var Stream$
|
|
864
|
+
var Stream$2 = stream__default["default"].Stream;
|
|
860
865
|
|
|
861
866
|
|
|
862
867
|
var delayed_stream = DelayedStream;
|
|
@@ -870,7 +875,7 @@ function DelayedStream() {
|
|
|
870
875
|
this._released = false;
|
|
871
876
|
this._bufferedEvents = [];
|
|
872
877
|
}
|
|
873
|
-
util__default[
|
|
878
|
+
util__default["default"].inherits(DelayedStream, Stream$2);
|
|
874
879
|
|
|
875
880
|
DelayedStream.create = function(source, options) {
|
|
876
881
|
var delayedStream = new this();
|
|
@@ -930,7 +935,7 @@ DelayedStream.prototype.release = function() {
|
|
|
930
935
|
};
|
|
931
936
|
|
|
932
937
|
DelayedStream.prototype.pipe = function() {
|
|
933
|
-
var r = Stream$
|
|
938
|
+
var r = Stream$2.prototype.pipe.apply(this, arguments);
|
|
934
939
|
this.resume();
|
|
935
940
|
return r;
|
|
936
941
|
};
|
|
@@ -964,7 +969,7 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
|
|
964
969
|
this.emit('error', new Error(message));
|
|
965
970
|
};
|
|
966
971
|
|
|
967
|
-
var Stream = stream__default[
|
|
972
|
+
var Stream$1 = stream__default["default"].Stream;
|
|
968
973
|
|
|
969
974
|
|
|
970
975
|
var combined_stream = CombinedStream;
|
|
@@ -981,7 +986,7 @@ function CombinedStream() {
|
|
|
981
986
|
this._insideLoop = false;
|
|
982
987
|
this._pendingNext = false;
|
|
983
988
|
}
|
|
984
|
-
util__default[
|
|
989
|
+
util__default["default"].inherits(CombinedStream, Stream$1);
|
|
985
990
|
|
|
986
991
|
CombinedStream.create = function(options) {
|
|
987
992
|
var combinedStream = new this();
|
|
@@ -1027,7 +1032,7 @@ CombinedStream.prototype.append = function(stream) {
|
|
|
1027
1032
|
};
|
|
1028
1033
|
|
|
1029
1034
|
CombinedStream.prototype.pipe = function(dest, options) {
|
|
1030
|
-
Stream.prototype.pipe.call(this, dest, options);
|
|
1035
|
+
Stream$1.prototype.pipe.call(this, dest, options);
|
|
1031
1036
|
this.resume();
|
|
1032
1037
|
return dest;
|
|
1033
1038
|
};
|
|
@@ -10863,7 +10868,7 @@ var mimeTypes = createCommonjsModule(function (module, exports) {
|
|
|
10863
10868
|
*/
|
|
10864
10869
|
|
|
10865
10870
|
|
|
10866
|
-
var extname = path__default[
|
|
10871
|
+
var extname = path__default["default"].extname;
|
|
10867
10872
|
|
|
10868
10873
|
/**
|
|
10869
10874
|
* Module variables.
|
|
@@ -11417,8 +11422,9 @@ var populate = function(dst, src) {
|
|
|
11417
11422
|
return dst;
|
|
11418
11423
|
};
|
|
11419
11424
|
|
|
11420
|
-
var parseUrl = url__default[
|
|
11425
|
+
var parseUrl = url__default["default"].parse;
|
|
11421
11426
|
|
|
11427
|
+
var Stream = stream__default["default"].Stream;
|
|
11422
11428
|
|
|
11423
11429
|
|
|
11424
11430
|
|
|
@@ -11427,7 +11433,7 @@ var parseUrl = url__default['default'].parse;
|
|
|
11427
11433
|
var form_data = FormData;
|
|
11428
11434
|
|
|
11429
11435
|
// make it a Stream
|
|
11430
|
-
util__default[
|
|
11436
|
+
util__default["default"].inherits(FormData, combined_stream);
|
|
11431
11437
|
|
|
11432
11438
|
/**
|
|
11433
11439
|
* Create readable "multipart/form-data" streams.
|
|
@@ -11474,7 +11480,7 @@ FormData.prototype.append = function(field, value, options) {
|
|
|
11474
11480
|
}
|
|
11475
11481
|
|
|
11476
11482
|
// https://github.com/felixge/node-form-data/issues/38
|
|
11477
|
-
if (util__default[
|
|
11483
|
+
if (util__default["default"].isArray(value)) {
|
|
11478
11484
|
// Please convert your array into string
|
|
11479
11485
|
// the way web server expects it
|
|
11480
11486
|
this._error(new Error('Arrays are not supported.'));
|
|
@@ -11514,8 +11520,8 @@ FormData.prototype._trackLength = function(header, value, options) {
|
|
|
11514
11520
|
Buffer.byteLength(header) +
|
|
11515
11521
|
FormData.LINE_BREAK.length;
|
|
11516
11522
|
|
|
11517
|
-
// empty or either doesn't have path or not an http response
|
|
11518
|
-
if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) )) {
|
|
11523
|
+
// empty or either doesn't have path or not an http response or not a stream
|
|
11524
|
+
if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) && !(value instanceof Stream))) {
|
|
11519
11525
|
return;
|
|
11520
11526
|
}
|
|
11521
11527
|
|
|
@@ -11546,7 +11552,7 @@ FormData.prototype._lengthRetriever = function(value, callback) {
|
|
|
11546
11552
|
// not that fast snoopy
|
|
11547
11553
|
} else {
|
|
11548
11554
|
// still need to fetch file size from fs
|
|
11549
|
-
fs__default[
|
|
11555
|
+
fs__default["default"].stat(value.path, function(err, stat) {
|
|
11550
11556
|
|
|
11551
11557
|
var fileSize;
|
|
11552
11558
|
|
|
@@ -11636,15 +11642,15 @@ FormData.prototype._getContentDisposition = function(value, options) {
|
|
|
11636
11642
|
|
|
11637
11643
|
if (typeof options.filepath === 'string') {
|
|
11638
11644
|
// custom filepath for relative paths
|
|
11639
|
-
filename = path__default[
|
|
11645
|
+
filename = path__default["default"].normalize(options.filepath).replace(/\\/g, '/');
|
|
11640
11646
|
} else if (options.filename || value.name || value.path) {
|
|
11641
11647
|
// custom filename take precedence
|
|
11642
11648
|
// formidable and the browser add a name property
|
|
11643
11649
|
// fs- and request- streams have path property
|
|
11644
|
-
filename = path__default[
|
|
11650
|
+
filename = path__default["default"].basename(options.filename || value.name || value.path);
|
|
11645
11651
|
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
|
|
11646
11652
|
// or try http response
|
|
11647
|
-
filename = path__default[
|
|
11653
|
+
filename = path__default["default"].basename(value.client._httpMessage.path || '');
|
|
11648
11654
|
}
|
|
11649
11655
|
|
|
11650
11656
|
if (filename) {
|
|
@@ -11863,20 +11869,22 @@ FormData.prototype.submit = function(params, cb) {
|
|
|
11863
11869
|
|
|
11864
11870
|
// https if specified, fallback to http in any other case
|
|
11865
11871
|
if (options.protocol == 'https:') {
|
|
11866
|
-
request = https__default[
|
|
11872
|
+
request = https__default["default"].request(options);
|
|
11867
11873
|
} else {
|
|
11868
|
-
request = http__default[
|
|
11874
|
+
request = http__default["default"].request(options);
|
|
11869
11875
|
}
|
|
11870
11876
|
|
|
11871
11877
|
// get content length and fire away
|
|
11872
11878
|
this.getLength(function(err, length) {
|
|
11873
|
-
if (err) {
|
|
11879
|
+
if (err && err !== 'Unknown stream') {
|
|
11874
11880
|
this._error(err);
|
|
11875
11881
|
return;
|
|
11876
11882
|
}
|
|
11877
11883
|
|
|
11878
11884
|
// add content length
|
|
11879
|
-
|
|
11885
|
+
if (length) {
|
|
11886
|
+
request.setHeader('Content-Length', length);
|
|
11887
|
+
}
|
|
11880
11888
|
|
|
11881
11889
|
this.pipe(request);
|
|
11882
11890
|
if (cb) {
|
|
@@ -11948,7 +11956,7 @@ const isEligibleForClientRedirect = (params) => {
|
|
|
11948
11956
|
return false;
|
|
11949
11957
|
}
|
|
11950
11958
|
};
|
|
11951
|
-
const getRedirectUrl = (params) => `${params.oauthUrl}/oauth/authorize?${querystring__default[
|
|
11959
|
+
const getRedirectUrl = (params) => `${params.oauthUrl}/oauth/authorize?${querystring__default["default"].stringify(castToAuthorizationRequestParams(params))}`;
|
|
11952
11960
|
|
|
11953
11961
|
const GRANT_TYPE = 'password';
|
|
11954
11962
|
const castToTokenRequestParams = (params) => {
|
|
@@ -11987,7 +11995,7 @@ async function maybeUpdateToken(oauthTokenStore, tokenFetcher, options, mustRefr
|
|
|
11987
11995
|
return oauthTokenStore.set(await requestToken(tokenFetcher, options));
|
|
11988
11996
|
}
|
|
11989
11997
|
if (typeof window !== 'undefined' && options.implicit) {
|
|
11990
|
-
const parsedLocationHash = querystring__default[
|
|
11998
|
+
const parsedLocationHash = querystring__default["default"].parse(window.location.hash);
|
|
11991
11999
|
const accessToken = parsedLocationHash && parsedLocationHash.access_token;
|
|
11992
12000
|
if (accessToken) {
|
|
11993
12001
|
window.history.replaceState({}, '', window.location.href.split('#')[0]);
|
|
@@ -12012,21 +12020,16 @@ async function maybeUpdateToken(oauthTokenStore, tokenFetcher, options, mustRefr
|
|
|
12012
12020
|
}
|
|
12013
12021
|
|
|
12014
12022
|
function sleep(miliseconds) {
|
|
12015
|
-
return new Promise(resolve => setTimeout(() => resolve(true), miliseconds));
|
|
12023
|
+
return new Promise((resolve) => setTimeout(() => resolve(true), miliseconds));
|
|
12016
12024
|
}
|
|
12017
12025
|
|
|
12018
12026
|
const requestLogger = makeLogger('REST API Request');
|
|
12019
12027
|
const responseLogger = makeLogger('REST API Response');
|
|
12020
12028
|
const RETRYABLE_STATUS_CODES = [
|
|
12021
|
-
401,
|
|
12022
|
-
408,
|
|
12023
|
-
429,
|
|
12024
|
-
502,
|
|
12025
|
-
503,
|
|
12026
|
-
504,
|
|
12029
|
+
401, 408, 429, 502, 503, 504,
|
|
12027
12030
|
];
|
|
12028
12031
|
const TOKEN_REFRESH_STATUS_CODES = [401];
|
|
12029
|
-
const queue = new Bottleneck__default[
|
|
12032
|
+
const queue = new Bottleneck__default["default"]({
|
|
12030
12033
|
maxConcurrent: QUEUE_CONCURRENCY,
|
|
12031
12034
|
minTime: QUEUE_DELAY,
|
|
12032
12035
|
reservoir: QUEUE_RESERVOIR,
|
|
@@ -12040,7 +12043,7 @@ function refillReservoir() {
|
|
|
12040
12043
|
const interval = setInterval(async () => {
|
|
12041
12044
|
const reservoir = (await queue.currentReservoir());
|
|
12042
12045
|
if (queue.empty() && (await queue.running()) === 0 && reservoir > 10) {
|
|
12043
|
-
return (queue.incrementReservoir(1) &&
|
|
12046
|
+
return ((await queue.incrementReservoir(1)) &&
|
|
12044
12047
|
fnClearInterval(interval) &&
|
|
12045
12048
|
refillIntervalSet.delete(interval));
|
|
12046
12049
|
}
|
|
@@ -12095,7 +12098,7 @@ function makeApiRequest(oauthTokenStore, oauthTokenRequester, options, httpMetho
|
|
|
12095
12098
|
const method = httpMethod.toUpperCase();
|
|
12096
12099
|
const payloadQuery = payload && payload.query
|
|
12097
12100
|
? (apiMethod.includes('?') ? '&' : '?') +
|
|
12098
|
-
querystring__default[
|
|
12101
|
+
querystring__default["default"].stringify(payload.query)
|
|
12099
12102
|
: '';
|
|
12100
12103
|
const url = `${options.apiUrl}/api${apiMethod}${payloadQuery}`;
|
|
12101
12104
|
const body = payload && payload.body;
|
|
@@ -12114,7 +12117,7 @@ function makeApiRequest(oauthTokenStore, oauthTokenRequester, options, httpMetho
|
|
|
12114
12117
|
const requestBody = {
|
|
12115
12118
|
body: hasForm ? formData : JSON.stringify(body),
|
|
12116
12119
|
};
|
|
12117
|
-
const response = await fetch__default[
|
|
12120
|
+
const response = await fetch__default["default"](url, Object.assign({ cache: 'no-cache', credentials: 'omit', headers,
|
|
12118
12121
|
method, mode: 'cors' }, (hasForm || body ? requestBody : {})));
|
|
12119
12122
|
const result = await makeResultFromResponse(response);
|
|
12120
12123
|
responseLogger.log(method, url, result instanceof Error
|
|
@@ -12211,6 +12214,8 @@ const API_METHODS = [
|
|
|
12211
12214
|
utilisationPeriodCheckInUser,
|
|
12212
12215
|
utilisationPeriodCheckOutUser,
|
|
12213
12216
|
utilisationPeriodAddRegistrationCode,
|
|
12217
|
+
bookingUpdateById,
|
|
12218
|
+
bookingGetById,
|
|
12214
12219
|
];
|
|
12215
12220
|
function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) {
|
|
12216
12221
|
const options = Object.assign(Object.assign({}, DEFAULT_API_WRAPPER_OPTIONS), userOptions);
|
package/dist/lib.esm.js
CHANGED
|
@@ -9,7 +9,7 @@ import https from 'https';
|
|
|
9
9
|
import url from 'url';
|
|
10
10
|
import fs from 'fs';
|
|
11
11
|
|
|
12
|
-
const version = "
|
|
12
|
+
const version = "5.0.0";
|
|
13
13
|
|
|
14
14
|
const REST_API_URL = 'https://api.allthings.me';
|
|
15
15
|
const OAUTH_URL = 'https://accounts.allthings.me';
|
|
@@ -79,14 +79,14 @@ const requestToken$3 = (tokenRequester, params) => tokenRequester(castToTokenReq
|
|
|
79
79
|
function createTokenStore(initialToken) {
|
|
80
80
|
const token = new Map(Object.entries(initialToken || {}));
|
|
81
81
|
return {
|
|
82
|
-
get: key => token.get(key),
|
|
82
|
+
get: (key) => token.get(key),
|
|
83
83
|
reset: () => token.clear(),
|
|
84
|
-
set: update => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
|
|
84
|
+
set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
const SUBSCRIPTIONS = (process.env.DEBUG &&
|
|
89
|
-
process.env.DEBUG.split(',').map(item => item.trim())) ||
|
|
89
|
+
process.env.DEBUG.split(',').map((item) => item.trim())) ||
|
|
90
90
|
[];
|
|
91
91
|
function makeLogger(name) {
|
|
92
92
|
return ['log', 'info', 'warn', 'error'].reduce((logger, type) => (Object.assign(Object.assign({}, logger), { [type]: function log(...logs) {
|
|
@@ -176,9 +176,7 @@ function fnClearInterval(intervalId) {
|
|
|
176
176
|
function pseudoRandomString(length = 16) {
|
|
177
177
|
let token = '';
|
|
178
178
|
while (token.length < length) {
|
|
179
|
-
token += Math.random()
|
|
180
|
-
.toString(36)
|
|
181
|
-
.substr(2);
|
|
179
|
+
token += Math.random().toString(36).substr(2);
|
|
182
180
|
}
|
|
183
181
|
return token.substr(0, length);
|
|
184
182
|
}
|
|
@@ -354,6 +352,13 @@ async function activeUnitsGetByAppId(client, appId) {
|
|
|
354
352
|
return client.get(`/v1/apps/${appId}/active-units`);
|
|
355
353
|
}
|
|
356
354
|
|
|
355
|
+
async function bookingGetById(client, bookingId) {
|
|
356
|
+
return client.get(`/v1/bookings/${bookingId}`);
|
|
357
|
+
}
|
|
358
|
+
async function bookingUpdateById(client, bookingId, data) {
|
|
359
|
+
return client.patch(`/v1/bookings/${bookingId}`, data);
|
|
360
|
+
}
|
|
361
|
+
|
|
357
362
|
async function bucketGet(client, bucketId) {
|
|
358
363
|
return client.get(`/v1/buckets/${bucketId}`);
|
|
359
364
|
}
|
|
@@ -398,7 +403,7 @@ async function createManyFilesSorted(files, client) {
|
|
|
398
403
|
error: result.filter((item) => item instanceof Error),
|
|
399
404
|
success: result
|
|
400
405
|
.filter((item) => !(item instanceof Error))
|
|
401
|
-
.map(item => item.id),
|
|
406
|
+
.map((item) => item.id),
|
|
402
407
|
};
|
|
403
408
|
}
|
|
404
409
|
|
|
@@ -554,10 +559,10 @@ function remapKeys(input, mapFn) {
|
|
|
554
559
|
}
|
|
555
560
|
|
|
556
561
|
function camelCaseToDash(input) {
|
|
557
|
-
return input.replace(/([A-Z])/g, g => `-${g[0].toLowerCase()}`);
|
|
562
|
+
return input.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`);
|
|
558
563
|
}
|
|
559
564
|
function dashCaseToCamel(input) {
|
|
560
|
-
return input.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
565
|
+
return input.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
561
566
|
}
|
|
562
567
|
|
|
563
568
|
var EnumNotificationSettingsValue;
|
|
@@ -839,7 +844,7 @@ async function put(request, method, body, returnRawResultObject) {
|
|
|
839
844
|
return request('put', method, { body }, returnRawResultObject);
|
|
840
845
|
}
|
|
841
846
|
|
|
842
|
-
var Stream$
|
|
847
|
+
var Stream$2 = stream.Stream;
|
|
843
848
|
|
|
844
849
|
|
|
845
850
|
var delayed_stream = DelayedStream;
|
|
@@ -853,7 +858,7 @@ function DelayedStream() {
|
|
|
853
858
|
this._released = false;
|
|
854
859
|
this._bufferedEvents = [];
|
|
855
860
|
}
|
|
856
|
-
util.inherits(DelayedStream, Stream$
|
|
861
|
+
util.inherits(DelayedStream, Stream$2);
|
|
857
862
|
|
|
858
863
|
DelayedStream.create = function(source, options) {
|
|
859
864
|
var delayedStream = new this();
|
|
@@ -913,7 +918,7 @@ DelayedStream.prototype.release = function() {
|
|
|
913
918
|
};
|
|
914
919
|
|
|
915
920
|
DelayedStream.prototype.pipe = function() {
|
|
916
|
-
var r = Stream$
|
|
921
|
+
var r = Stream$2.prototype.pipe.apply(this, arguments);
|
|
917
922
|
this.resume();
|
|
918
923
|
return r;
|
|
919
924
|
};
|
|
@@ -947,7 +952,7 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
|
|
947
952
|
this.emit('error', new Error(message));
|
|
948
953
|
};
|
|
949
954
|
|
|
950
|
-
var Stream = stream.Stream;
|
|
955
|
+
var Stream$1 = stream.Stream;
|
|
951
956
|
|
|
952
957
|
|
|
953
958
|
var combined_stream = CombinedStream;
|
|
@@ -964,7 +969,7 @@ function CombinedStream() {
|
|
|
964
969
|
this._insideLoop = false;
|
|
965
970
|
this._pendingNext = false;
|
|
966
971
|
}
|
|
967
|
-
util.inherits(CombinedStream, Stream);
|
|
972
|
+
util.inherits(CombinedStream, Stream$1);
|
|
968
973
|
|
|
969
974
|
CombinedStream.create = function(options) {
|
|
970
975
|
var combinedStream = new this();
|
|
@@ -1010,7 +1015,7 @@ CombinedStream.prototype.append = function(stream) {
|
|
|
1010
1015
|
};
|
|
1011
1016
|
|
|
1012
1017
|
CombinedStream.prototype.pipe = function(dest, options) {
|
|
1013
|
-
Stream.prototype.pipe.call(this, dest, options);
|
|
1018
|
+
Stream$1.prototype.pipe.call(this, dest, options);
|
|
1014
1019
|
this.resume();
|
|
1015
1020
|
return dest;
|
|
1016
1021
|
};
|
|
@@ -11402,6 +11407,7 @@ var populate = function(dst, src) {
|
|
|
11402
11407
|
|
|
11403
11408
|
var parseUrl = url.parse;
|
|
11404
11409
|
|
|
11410
|
+
var Stream = stream.Stream;
|
|
11405
11411
|
|
|
11406
11412
|
|
|
11407
11413
|
|
|
@@ -11497,8 +11503,8 @@ FormData.prototype._trackLength = function(header, value, options) {
|
|
|
11497
11503
|
Buffer.byteLength(header) +
|
|
11498
11504
|
FormData.LINE_BREAK.length;
|
|
11499
11505
|
|
|
11500
|
-
// empty or either doesn't have path or not an http response
|
|
11501
|
-
if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) )) {
|
|
11506
|
+
// empty or either doesn't have path or not an http response or not a stream
|
|
11507
|
+
if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) && !(value instanceof Stream))) {
|
|
11502
11508
|
return;
|
|
11503
11509
|
}
|
|
11504
11510
|
|
|
@@ -11853,13 +11859,15 @@ FormData.prototype.submit = function(params, cb) {
|
|
|
11853
11859
|
|
|
11854
11860
|
// get content length and fire away
|
|
11855
11861
|
this.getLength(function(err, length) {
|
|
11856
|
-
if (err) {
|
|
11862
|
+
if (err && err !== 'Unknown stream') {
|
|
11857
11863
|
this._error(err);
|
|
11858
11864
|
return;
|
|
11859
11865
|
}
|
|
11860
11866
|
|
|
11861
11867
|
// add content length
|
|
11862
|
-
|
|
11868
|
+
if (length) {
|
|
11869
|
+
request.setHeader('Content-Length', length);
|
|
11870
|
+
}
|
|
11863
11871
|
|
|
11864
11872
|
this.pipe(request);
|
|
11865
11873
|
if (cb) {
|
|
@@ -11995,18 +12003,13 @@ async function maybeUpdateToken(oauthTokenStore, tokenFetcher, options, mustRefr
|
|
|
11995
12003
|
}
|
|
11996
12004
|
|
|
11997
12005
|
function sleep(miliseconds) {
|
|
11998
|
-
return new Promise(resolve => setTimeout(() => resolve(true), miliseconds));
|
|
12006
|
+
return new Promise((resolve) => setTimeout(() => resolve(true), miliseconds));
|
|
11999
12007
|
}
|
|
12000
12008
|
|
|
12001
12009
|
const requestLogger = makeLogger('REST API Request');
|
|
12002
12010
|
const responseLogger = makeLogger('REST API Response');
|
|
12003
12011
|
const RETRYABLE_STATUS_CODES = [
|
|
12004
|
-
401,
|
|
12005
|
-
408,
|
|
12006
|
-
429,
|
|
12007
|
-
502,
|
|
12008
|
-
503,
|
|
12009
|
-
504,
|
|
12012
|
+
401, 408, 429, 502, 503, 504,
|
|
12010
12013
|
];
|
|
12011
12014
|
const TOKEN_REFRESH_STATUS_CODES = [401];
|
|
12012
12015
|
const queue = new Bottleneck({
|
|
@@ -12023,7 +12026,7 @@ function refillReservoir() {
|
|
|
12023
12026
|
const interval = setInterval(async () => {
|
|
12024
12027
|
const reservoir = (await queue.currentReservoir());
|
|
12025
12028
|
if (queue.empty() && (await queue.running()) === 0 && reservoir > 10) {
|
|
12026
|
-
return (queue.incrementReservoir(1) &&
|
|
12029
|
+
return ((await queue.incrementReservoir(1)) &&
|
|
12027
12030
|
fnClearInterval(interval) &&
|
|
12028
12031
|
refillIntervalSet.delete(interval));
|
|
12029
12032
|
}
|
|
@@ -12194,6 +12197,8 @@ const API_METHODS = [
|
|
|
12194
12197
|
utilisationPeriodCheckInUser,
|
|
12195
12198
|
utilisationPeriodCheckOutUser,
|
|
12196
12199
|
utilisationPeriodAddRegistrationCode,
|
|
12200
|
+
bookingUpdateById,
|
|
12201
|
+
bookingGetById,
|
|
12197
12202
|
];
|
|
12198
12203
|
function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) {
|
|
12199
12204
|
const options = Object.assign(Object.assign({}, DEFAULT_API_WRAPPER_OPTIONS), userOptions);
|