@allthings/sdk 4.5.0 → 4.8.1

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/dist/cli.js CHANGED
@@ -3,20 +3,31 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
7
-
8
- var querystring = _interopDefault(require('query-string'));
9
- var fetch = _interopDefault(require('cross-fetch'));
10
- var Bottleneck = _interopDefault(require('bottleneck'));
11
- var util = _interopDefault(require('util'));
12
- var stream = _interopDefault(require('stream'));
13
- var path = _interopDefault(require('path'));
14
- var http = _interopDefault(require('http'));
15
- var https = _interopDefault(require('https'));
16
- var url = _interopDefault(require('url'));
17
- var fs = _interopDefault(require('fs'));
18
-
19
- const version = "4.5.0";
6
+ var querystring = require('query-string');
7
+ var fetch = require('cross-fetch');
8
+ var Bottleneck = require('bottleneck');
9
+ var util = require('util');
10
+ var stream = require('stream');
11
+ var path = require('path');
12
+ var http = require('http');
13
+ var https = require('https');
14
+ var url = require('url');
15
+ var fs = require('fs');
16
+
17
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
+
19
+ var querystring__default = /*#__PURE__*/_interopDefaultLegacy(querystring);
20
+ var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
21
+ var Bottleneck__default = /*#__PURE__*/_interopDefaultLegacy(Bottleneck);
22
+ var util__default = /*#__PURE__*/_interopDefaultLegacy(util);
23
+ var stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
24
+ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
25
+ var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
26
+ var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
27
+ var url__default = /*#__PURE__*/_interopDefaultLegacy(url);
28
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
29
+
30
+ const version = "4.8.1";
20
31
 
21
32
  const REST_API_URL = 'https://api.allthings.me';
22
33
  const OAUTH_URL = 'https://accounts.allthings.me';
@@ -39,9 +50,9 @@ const DEFAULT_API_WRAPPER_OPTIONS = {
39
50
  };
40
51
  const USER_AGENT = `Allthings Node SDK REST Client/${version}`;
41
52
 
42
- const RESPONSE_TYPE = 'code';
43
- const GRANT_TYPE = 'authorization_code';
44
- const castToAuthorizationRequestParams = (params) => {
53
+ const RESPONSE_TYPE$1 = 'code';
54
+ const GRANT_TYPE$3 = 'authorization_code';
55
+ const castToAuthorizationRequestParams$1 = (params) => {
45
56
  const { redirectUri, clientId, scope, state } = params;
46
57
  if (!clientId) {
47
58
  throw new Error('Missing required "clientId" parameter to perform authorization code grant redirect');
@@ -49,18 +60,18 @@ const castToAuthorizationRequestParams = (params) => {
49
60
  if (!redirectUri) {
50
61
  throw new Error('Missing required "redirectUri" parameter to perform authorization code grant redirect');
51
62
  }
52
- return Object.assign(Object.assign({ client_id: clientId, redirect_uri: redirectUri, response_type: RESPONSE_TYPE }, (scope ? { scope } : {})), (state ? { state } : {}));
63
+ return Object.assign(Object.assign({ client_id: clientId, redirect_uri: redirectUri, response_type: RESPONSE_TYPE$1 }, (scope ? { scope } : {})), (state ? { state } : {}));
53
64
  };
54
- const isEligibleForClientRedirect = (params) => {
65
+ const isEligibleForClientRedirect$1 = (params) => {
55
66
  try {
56
- return !!castToAuthorizationRequestParams(params);
67
+ return !!castToAuthorizationRequestParams$1(params);
57
68
  }
58
69
  catch (_a) {
59
70
  return false;
60
71
  }
61
72
  };
62
- const getRedirectUrl = (params) => `${params.oauthUrl}/oauth/authorize?${querystring.stringify(castToAuthorizationRequestParams(params))}`;
63
- const castToTokenRequestParams = (params) => {
73
+ const getRedirectUrl$1 = (params) => `${params.oauthUrl}/oauth/authorize?${querystring__default["default"].stringify(castToAuthorizationRequestParams$1(params))}`;
74
+ const castToTokenRequestParams$2 = (params) => {
64
75
  const { authorizationCode, redirectUri, clientId, clientSecret } = params;
65
76
  if (!clientId) {
66
77
  throw new Error('Missing required "clientId" parameter to perform authorization code grant');
@@ -71,17 +82,17 @@ const castToTokenRequestParams = (params) => {
71
82
  if (!authorizationCode) {
72
83
  throw new Error('Missing required "authorizationCode" parameter to perform authorization code grant');
73
84
  }
74
- return Object.assign({ client_id: clientId, code: authorizationCode, grant_type: GRANT_TYPE, redirect_uri: redirectUri }, (clientSecret ? { client_secret: clientSecret } : {}));
85
+ return Object.assign({ client_id: clientId, code: authorizationCode, grant_type: GRANT_TYPE$3, redirect_uri: redirectUri }, (clientSecret ? { client_secret: clientSecret } : {}));
75
86
  };
76
- const isEligible = (params) => {
87
+ const isEligible$3 = (params) => {
77
88
  try {
78
- return !!castToTokenRequestParams(params);
89
+ return !!castToTokenRequestParams$2(params);
79
90
  }
80
91
  catch (_a) {
81
92
  return false;
82
93
  }
83
94
  };
84
- const requestToken = (tokenRequester, params) => tokenRequester(castToTokenRequestParams(params));
95
+ const requestToken$3 = (tokenRequester, params) => tokenRequester(castToTokenRequestParams$2(params));
85
96
 
86
97
  function createTokenStore(initialToken) {
87
98
  const token = new Map(Object.entries(initialToken || {}));
@@ -109,8 +120,8 @@ function makeLogger(name) {
109
120
  const logger = makeLogger('OAuth Token Request');
110
121
  const makeFetchTokenRequester = (url) => async (params) => {
111
122
  try {
112
- const response = await fetch(url, {
113
- body: querystring.stringify(params),
123
+ const response = await fetch__default["default"](url, {
124
+ body: querystring__default["default"].stringify(params),
114
125
  cache: 'no-cache',
115
126
  credentials: 'omit',
116
127
  headers: {
@@ -141,7 +152,7 @@ const makeFetchTokenRequester = (url) => async (params) => {
141
152
  }
142
153
  };
143
154
 
144
- const GRANT_TYPE$1 = 'refresh_token';
155
+ const GRANT_TYPE$2 = 'refresh_token';
145
156
  const castToTokenRequestParams$1 = (params) => {
146
157
  const { clientId, clientSecret, refreshToken, scope } = params;
147
158
  if (!clientId) {
@@ -150,9 +161,9 @@ const castToTokenRequestParams$1 = (params) => {
150
161
  if (!refreshToken) {
151
162
  throw new Error('Missing required "refreshToken" parameter to perform refresh token grant');
152
163
  }
153
- return Object.assign(Object.assign({ client_id: clientId, grant_type: GRANT_TYPE$1, refresh_token: refreshToken }, (clientSecret ? { client_secret: clientSecret } : {})), (scope ? { scope } : {}));
164
+ return Object.assign(Object.assign({ client_id: clientId, grant_type: GRANT_TYPE$2, refresh_token: refreshToken }, (clientSecret ? { client_secret: clientSecret } : {})), (scope ? { scope } : {}));
154
165
  };
155
- const isEligible$1 = (params) => {
166
+ const isEligible$2 = (params) => {
156
167
  try {
157
168
  return !!castToTokenRequestParams$1(params);
158
169
  }
@@ -160,7 +171,7 @@ const isEligible$1 = (params) => {
160
171
  return false;
161
172
  }
162
173
  };
163
- const requestToken$1 = (tokenRequester, params) => tokenRequester(castToTokenRequestParams$1(params));
174
+ const requestToken$2 = (tokenRequester, params) => tokenRequester(castToTokenRequestParams$1(params));
164
175
 
165
176
  async function requestAndSaveToStore(requester, tokenStore) {
166
177
  const response = await requester();
@@ -198,7 +209,7 @@ async function get(request, method, query, returnRawResultObject) {
198
209
  return request('get', method, { query }, returnRawResultObject);
199
210
  }
200
211
 
201
- var __rest = (undefined && undefined.__rest) || function (s, e) {
212
+ var __rest$4 = (undefined && undefined.__rest) || function (s, e) {
202
213
  var t = {};
203
214
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
204
215
  t[p] = s[p];
@@ -260,7 +271,7 @@ var EnumUserPermissionObjectType;
260
271
  EnumUserPermissionObjectType["unit"] = "Unit";
261
272
  })(EnumUserPermissionObjectType || (EnumUserPermissionObjectType = {}));
262
273
  const remapUserResult = (user) => {
263
- const { tenantIDs: tenantIds } = user, result = __rest(user, ["tenantIDs"]);
274
+ const { tenantIDs: tenantIds } = user, result = __rest$4(user, ["tenantIDs"]);
264
275
  return Object.assign(Object.assign({}, result), { tenantIds });
265
276
  };
266
277
  const remapEmbeddedUser = (embedded) => embedded.users ? embedded.users.map(remapUserResult) : [];
@@ -282,12 +293,12 @@ async function userGetById(client, userId) {
282
293
  return remapUserResult(await client.get(`/v1/users/${userId}`));
283
294
  }
284
295
  async function userUpdateById(client, userId, data) {
285
- const { tenantIds: tenantIDs } = data, rest = __rest(data, ["tenantIds"]);
296
+ const { tenantIds: tenantIDs } = data, rest = __rest$4(data, ["tenantIds"]);
286
297
  return remapUserResult(await client.patch(`/v1/users/${userId}`, Object.assign(Object.assign({}, rest), { tenantIDs })));
287
298
  }
288
299
  async function userCreatePermission(client, userId, data) {
289
- const { objectId: objectID } = data, rest = __rest(data, ["objectId"]);
290
- const _a = await client.post(`/v1/users/${userId}/permissions`, Object.assign(Object.assign({}, rest), { objectID })), { objectID: resultObjectId } = _a, result = __rest(_a, ["objectID"]);
300
+ const { objectId: objectID } = data, rest = __rest$4(data, ["objectId"]);
301
+ const _a = await client.post(`/v1/users/${userId}/permissions`, Object.assign(Object.assign({}, rest), { objectID })), { objectID: resultObjectId } = _a, result = __rest$4(_a, ["objectID"]);
291
302
  return Object.assign(Object.assign({}, result), { objectId: resultObjectId });
292
303
  }
293
304
  async function userCreatePermissionBatch(client, userId, permissions) {
@@ -307,7 +318,7 @@ async function userCreatePermissionBatch(client, userId, permissions) {
307
318
  async function userGetPermissions(client, userId) {
308
319
  const { _embedded: { items: permissions }, } = await client.get(`/v1/users/${userId}/roles?limit=-1`);
309
320
  return permissions.map((_a) => {
310
- var { objectID: objectId } = _a, result = __rest(_a, ["objectID"]);
321
+ var { objectID: objectId } = _a, result = __rest$4(_a, ["objectID"]);
311
322
  return (Object.assign(Object.assign({}, result), { objectId }));
312
323
  });
313
324
  }
@@ -357,6 +368,16 @@ async function appCreate(client, userId, data) {
357
368
  async function appGetById(client, appId) {
358
369
  return client.get(`/v1/apps/${appId}`);
359
370
  }
371
+ async function activeUnitsGetByAppId(client, appId) {
372
+ return client.get(`/v1/apps/${appId}/active-units`);
373
+ }
374
+
375
+ async function bookingGetById(client, bookingId) {
376
+ return client.get(`/v1/bookings/${bookingId}`);
377
+ }
378
+ async function bookingUpdateById(client, bookingId, data) {
379
+ return client.patch(`/v1/bookings/${bookingId}`, data);
380
+ }
360
381
 
361
382
  async function bucketGet(client, bucketId) {
362
383
  return client.get(`/v1/buckets/${bucketId}`);
@@ -445,7 +466,7 @@ async function fileDelete(client, fileId) {
445
466
  return (await client.delete(`/v1/files/${fileId}`)) === '';
446
467
  }
447
468
 
448
- var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
469
+ var __rest$3 = (undefined && undefined.__rest) || function (s, e) {
449
470
  var t = {};
450
471
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
451
472
  t[p] = s[p];
@@ -457,11 +478,11 @@ var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
457
478
  return t;
458
479
  };
459
480
  async function groupCreate(client, propertyId, data) {
460
- const { propertyManagerId } = data, rest = __rest$1(data, ["propertyManagerId"]);
481
+ const { propertyManagerId } = data, rest = __rest$3(data, ["propertyManagerId"]);
461
482
  return client.post(`/v1/properties/${propertyId}/groups`, Object.assign(Object.assign({}, rest), { propertyManagerID: propertyManagerId }));
462
483
  }
463
484
  async function groupGetById(client, groupId) {
464
- const _a = await client.get(`/v1/groups/${groupId}`), { propertyManagerID: propertyManagerId } = _a, result = __rest$1(_a, ["propertyManagerID"]);
485
+ const _a = await client.get(`/v1/groups/${groupId}`), { propertyManagerID: propertyManagerId } = _a, result = __rest$3(_a, ["propertyManagerID"]);
465
486
  return Object.assign(Object.assign({}, result), { propertyManagerId });
466
487
  }
467
488
  async function groupUpdateById(client, groupId, data) {
@@ -600,7 +621,7 @@ async function getProperties(client, page = 1, limit = -1, filter = {}) {
600
621
  return { _embedded: { items: properties }, total };
601
622
  }
602
623
 
603
- var __rest$3 = (undefined && undefined.__rest) || function (s, e) {
624
+ var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
604
625
  var t = {};
605
626
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
606
627
  t[p] = s[p];
@@ -612,11 +633,11 @@ var __rest$3 = (undefined && undefined.__rest) || function (s, e) {
612
633
  return t;
613
634
  };
614
635
  const remapRegistationCodeResult = (registrationCode) => {
615
- const { tenantID: externalId } = registrationCode, result = __rest$3(registrationCode, ["tenantID"]);
636
+ const { tenantID: externalId } = registrationCode, result = __rest$1(registrationCode, ["tenantID"]);
616
637
  return Object.assign(Object.assign({}, result), { externalId });
617
638
  };
618
639
  async function registrationCodeCreate(client, code, utilisationPeriods, options = { permanent: false }) {
619
- const { externalId } = options, moreOptions = __rest$3(options, ["externalId"]);
640
+ const { externalId } = options, moreOptions = __rest$1(options, ["externalId"]);
620
641
  return remapRegistationCodeResult(await client.post('/v1/registration-codes', Object.assign(Object.assign({ code, utilisationPeriods: typeof utilisationPeriods === 'string'
621
642
  ? [utilisationPeriods]
622
643
  : utilisationPeriods }, (externalId ? { tenantID: externalId } : {})), moreOptions)));
@@ -787,7 +808,7 @@ async function userRelationsGetByUser(client, userId) {
787
808
  return client.get(`/v1/users/${userId}/user-relations`);
788
809
  }
789
810
 
790
- var __rest$4 = (undefined && undefined.__rest) || function (s, e) {
811
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
791
812
  var t = {};
792
813
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
793
814
  t[p] = s[p];
@@ -805,15 +826,15 @@ var EnumUtilisationPeriodType;
805
826
  EnumUtilisationPeriodType["vacant"] = "vacant";
806
827
  })(EnumUtilisationPeriodType || (EnumUtilisationPeriodType = {}));
807
828
  async function utilisationPeriodCreate(client, unitId, data) {
808
- const _a = await client.post(`/v1/units/${unitId}/utilisation-periods`, data), { tenantIDs: tenantIds, _embedded } = _a, result = __rest$4(_a, ["tenantIDs", "_embedded"]);
829
+ const _a = await client.post(`/v1/units/${unitId}/utilisation-periods`, data), { tenantIDs: tenantIds, _embedded } = _a, result = __rest(_a, ["tenantIDs", "_embedded"]);
809
830
  return Object.assign(Object.assign({}, result), { invitations: _embedded.invitations.map(remapRegistationCodeResult), tenantIds, users: remapEmbeddedUser(_embedded) });
810
831
  }
811
832
  async function utilisationPeriodGetById(client, utilisationPeriodId) {
812
- const _a = await client.get(`/v1/utilisation-periods/${utilisationPeriodId}`), { tenantIDs: tenantIds, _embedded } = _a, result = __rest$4(_a, ["tenantIDs", "_embedded"]);
833
+ const _a = await client.get(`/v1/utilisation-periods/${utilisationPeriodId}`), { tenantIDs: tenantIds, _embedded } = _a, result = __rest(_a, ["tenantIDs", "_embedded"]);
813
834
  return Object.assign(Object.assign({}, result), { invitations: _embedded.invitations.map(remapRegistationCodeResult), tenantIds, users: remapEmbeddedUser(_embedded) });
814
835
  }
815
836
  async function utilisationPeriodUpdateById(client, utilisationPeriodId, data) {
816
- const _a = await client.patch(`/v1/utilisation-periods/${utilisationPeriodId}`, data), { tenantIDs: tenantIds, _embedded } = _a, result = __rest$4(_a, ["tenantIDs", "_embedded"]);
837
+ const _a = await client.patch(`/v1/utilisation-periods/${utilisationPeriodId}`, data), { tenantIDs: tenantIds, _embedded } = _a, result = __rest(_a, ["tenantIDs", "_embedded"]);
817
838
  return Object.assign(Object.assign({}, result), { invitations: _embedded.invitations.map(remapRegistationCodeResult), tenantIds, users: remapEmbeddedUser(_embedded) });
818
839
  }
819
840
  async function utilisationPeriodDelete(client, utilisationPeriodId) {
@@ -843,7 +864,7 @@ async function put(request, method, body, returnRawResultObject) {
843
864
  return request('put', method, { body }, returnRawResultObject);
844
865
  }
845
866
 
846
- var Stream = stream.Stream;
867
+ var Stream$1 = stream__default["default"].Stream;
847
868
 
848
869
 
849
870
  var delayed_stream = DelayedStream;
@@ -857,7 +878,7 @@ function DelayedStream() {
857
878
  this._released = false;
858
879
  this._bufferedEvents = [];
859
880
  }
860
- util.inherits(DelayedStream, Stream);
881
+ util__default["default"].inherits(DelayedStream, Stream$1);
861
882
 
862
883
  DelayedStream.create = function(source, options) {
863
884
  var delayedStream = new this();
@@ -917,7 +938,7 @@ DelayedStream.prototype.release = function() {
917
938
  };
918
939
 
919
940
  DelayedStream.prototype.pipe = function() {
920
- var r = Stream.prototype.pipe.apply(this, arguments);
941
+ var r = Stream$1.prototype.pipe.apply(this, arguments);
921
942
  this.resume();
922
943
  return r;
923
944
  };
@@ -951,7 +972,7 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
951
972
  this.emit('error', new Error(message));
952
973
  };
953
974
 
954
- var Stream$1 = stream.Stream;
975
+ var Stream = stream__default["default"].Stream;
955
976
 
956
977
 
957
978
  var combined_stream = CombinedStream;
@@ -968,7 +989,7 @@ function CombinedStream() {
968
989
  this._insideLoop = false;
969
990
  this._pendingNext = false;
970
991
  }
971
- util.inherits(CombinedStream, Stream$1);
992
+ util__default["default"].inherits(CombinedStream, Stream);
972
993
 
973
994
  CombinedStream.create = function(options) {
974
995
  var combinedStream = new this();
@@ -1014,7 +1035,7 @@ CombinedStream.prototype.append = function(stream) {
1014
1035
  };
1015
1036
 
1016
1037
  CombinedStream.prototype.pipe = function(dest, options) {
1017
- Stream$1.prototype.pipe.call(this, dest, options);
1038
+ Stream.prototype.pipe.call(this, dest, options);
1018
1039
  this.resume();
1019
1040
  return dest;
1020
1041
  };
@@ -10850,7 +10871,7 @@ var mimeTypes = createCommonjsModule(function (module, exports) {
10850
10871
  */
10851
10872
 
10852
10873
 
10853
- var extname = path.extname;
10874
+ var extname = path__default["default"].extname;
10854
10875
 
10855
10876
  /**
10856
10877
  * Module variables.
@@ -11024,13 +11045,13 @@ function populateMaps (extensions, types) {
11024
11045
  });
11025
11046
  }
11026
11047
  });
11027
- var mimeTypes_1 = mimeTypes.charset;
11028
- var mimeTypes_2 = mimeTypes.charsets;
11029
- var mimeTypes_3 = mimeTypes.contentType;
11030
- var mimeTypes_4 = mimeTypes.extension;
11031
- var mimeTypes_5 = mimeTypes.extensions;
11032
- var mimeTypes_6 = mimeTypes.lookup;
11033
- var mimeTypes_7 = mimeTypes.types;
11048
+ mimeTypes.charset;
11049
+ mimeTypes.charsets;
11050
+ mimeTypes.contentType;
11051
+ mimeTypes.extension;
11052
+ mimeTypes.extensions;
11053
+ mimeTypes.lookup;
11054
+ mimeTypes.types;
11034
11055
 
11035
11056
  var defer_1 = defer;
11036
11057
 
@@ -11404,7 +11425,7 @@ var populate = function(dst, src) {
11404
11425
  return dst;
11405
11426
  };
11406
11427
 
11407
- var parseUrl = url.parse;
11428
+ var parseUrl = url__default["default"].parse;
11408
11429
 
11409
11430
 
11410
11431
 
@@ -11414,7 +11435,7 @@ var parseUrl = url.parse;
11414
11435
  var form_data = FormData;
11415
11436
 
11416
11437
  // make it a Stream
11417
- util.inherits(FormData, combined_stream);
11438
+ util__default["default"].inherits(FormData, combined_stream);
11418
11439
 
11419
11440
  /**
11420
11441
  * Create readable "multipart/form-data" streams.
@@ -11461,7 +11482,7 @@ FormData.prototype.append = function(field, value, options) {
11461
11482
  }
11462
11483
 
11463
11484
  // https://github.com/felixge/node-form-data/issues/38
11464
- if (util.isArray(value)) {
11485
+ if (util__default["default"].isArray(value)) {
11465
11486
  // Please convert your array into string
11466
11487
  // the way web server expects it
11467
11488
  this._error(new Error('Arrays are not supported.'));
@@ -11533,7 +11554,7 @@ FormData.prototype._lengthRetriever = function(value, callback) {
11533
11554
  // not that fast snoopy
11534
11555
  } else {
11535
11556
  // still need to fetch file size from fs
11536
- fs.stat(value.path, function(err, stat) {
11557
+ fs__default["default"].stat(value.path, function(err, stat) {
11537
11558
 
11538
11559
  var fileSize;
11539
11560
 
@@ -11623,15 +11644,15 @@ FormData.prototype._getContentDisposition = function(value, options) {
11623
11644
 
11624
11645
  if (typeof options.filepath === 'string') {
11625
11646
  // custom filepath for relative paths
11626
- filename = path.normalize(options.filepath).replace(/\\/g, '/');
11647
+ filename = path__default["default"].normalize(options.filepath).replace(/\\/g, '/');
11627
11648
  } else if (options.filename || value.name || value.path) {
11628
11649
  // custom filename take precedence
11629
11650
  // formidable and the browser add a name property
11630
11651
  // fs- and request- streams have path property
11631
- filename = path.basename(options.filename || value.name || value.path);
11652
+ filename = path__default["default"].basename(options.filename || value.name || value.path);
11632
11653
  } else if (value.readable && value.hasOwnProperty('httpVersion')) {
11633
11654
  // or try http response
11634
- filename = path.basename(value.client._httpMessage.path || '');
11655
+ filename = path__default["default"].basename(value.client._httpMessage.path || '');
11635
11656
  }
11636
11657
 
11637
11658
  if (filename) {
@@ -11706,6 +11727,10 @@ FormData.prototype.getHeaders = function(userHeaders) {
11706
11727
  return formHeaders;
11707
11728
  };
11708
11729
 
11730
+ FormData.prototype.setBoundary = function(boundary) {
11731
+ this._boundary = boundary;
11732
+ };
11733
+
11709
11734
  FormData.prototype.getBoundary = function() {
11710
11735
  if (!this._boundary) {
11711
11736
  this._generateBoundary();
@@ -11846,9 +11871,9 @@ FormData.prototype.submit = function(params, cb) {
11846
11871
 
11847
11872
  // https if specified, fallback to http in any other case
11848
11873
  if (options.protocol == 'https:') {
11849
- request = https.request(options);
11874
+ request = https__default["default"].request(options);
11850
11875
  } else {
11851
- request = http.request(options);
11876
+ request = http__default["default"].request(options);
11852
11877
  }
11853
11878
 
11854
11879
  // get content length and fire away
@@ -11894,7 +11919,7 @@ FormData.prototype.toString = function () {
11894
11919
  return '[object FormData]';
11895
11920
  };
11896
11921
 
11897
- const GRANT_TYPE$2 = 'client_credentials';
11922
+ const GRANT_TYPE$1 = 'client_credentials';
11898
11923
  const castClientOptionsToRequestParams = (clientOptions) => {
11899
11924
  const { scope, clientId, clientSecret } = clientOptions;
11900
11925
  if (!clientId) {
@@ -11903,9 +11928,9 @@ const castClientOptionsToRequestParams = (clientOptions) => {
11903
11928
  if (!clientSecret) {
11904
11929
  throw new Error('Missing required "clientSecret" parameter to perform client credentials grant');
11905
11930
  }
11906
- return Object.assign({ client_id: clientId, client_secret: clientSecret, grant_type: GRANT_TYPE$2 }, (scope ? { scope } : {}));
11931
+ return Object.assign({ client_id: clientId, client_secret: clientSecret, grant_type: GRANT_TYPE$1 }, (scope ? { scope } : {}));
11907
11932
  };
11908
- const isEligible$2 = (clientOptions) => {
11933
+ const isEligible$1 = (clientOptions) => {
11909
11934
  try {
11910
11935
  return !!castClientOptionsToRequestParams(clientOptions);
11911
11936
  }
@@ -11913,28 +11938,28 @@ const isEligible$2 = (clientOptions) => {
11913
11938
  return false;
11914
11939
  }
11915
11940
  };
11916
- const requestToken$2 = (oauthTokenRequest, clientOptions) => oauthTokenRequest(castClientOptionsToRequestParams(clientOptions));
11941
+ const requestToken$1 = (oauthTokenRequest, clientOptions) => oauthTokenRequest(castClientOptionsToRequestParams(clientOptions));
11917
11942
 
11918
- const RESPONSE_TYPE$1 = 'token';
11919
- const castToAuthorizationRequestParams$1 = (params) => {
11943
+ const RESPONSE_TYPE = 'token';
11944
+ const castToAuthorizationRequestParams = (params) => {
11920
11945
  const { clientId, scope, state, redirectUri } = params;
11921
11946
  if (!clientId) {
11922
11947
  throw new Error('Missing required "clientId" parameter to perform implicit grant');
11923
11948
  }
11924
- return Object.assign(Object.assign({ client_id: clientId, redirect_uri: redirectUri || window.location.href, response_type: RESPONSE_TYPE$1 }, (scope ? { scope } : {})), (state ? { state } : {}));
11949
+ return Object.assign(Object.assign({ client_id: clientId, redirect_uri: redirectUri || window.location.href, response_type: RESPONSE_TYPE }, (scope ? { scope } : {})), (state ? { state } : {}));
11925
11950
  };
11926
- const isEligibleForClientRedirect$1 = (params) => {
11951
+ const isEligibleForClientRedirect = (params) => {
11927
11952
  try {
11928
- return !!castToAuthorizationRequestParams$1(params);
11953
+ return !!castToAuthorizationRequestParams(params);
11929
11954
  }
11930
11955
  catch (_a) {
11931
11956
  return false;
11932
11957
  }
11933
11958
  };
11934
- const getRedirectUrl$1 = (params) => `${params.oauthUrl}/oauth/authorize?${querystring.stringify(castToAuthorizationRequestParams$1(params))}`;
11959
+ const getRedirectUrl = (params) => `${params.oauthUrl}/oauth/authorize?${querystring__default["default"].stringify(castToAuthorizationRequestParams(params))}`;
11935
11960
 
11936
- const GRANT_TYPE$3 = 'password';
11937
- const castToTokenRequestParams$2 = (params) => {
11961
+ const GRANT_TYPE = 'password';
11962
+ const castToTokenRequestParams = (params) => {
11938
11963
  const { username, password, scope, clientId, clientSecret } = params;
11939
11964
  if (!clientId) {
11940
11965
  throw new Error('Missing required "clientId" parameter to perform password grant');
@@ -11945,51 +11970,51 @@ const castToTokenRequestParams$2 = (params) => {
11945
11970
  if (!password) {
11946
11971
  throw new Error('Missing required "password" parameter to perform password grant');
11947
11972
  }
11948
- return Object.assign(Object.assign({ client_id: clientId, grant_type: GRANT_TYPE$3, password,
11973
+ return Object.assign(Object.assign({ client_id: clientId, grant_type: GRANT_TYPE, password,
11949
11974
  username }, (scope ? { scope } : {})), (clientSecret ? { client_secret: clientSecret } : {}));
11950
11975
  };
11951
- const isEligible$3 = (params) => {
11976
+ const isEligible = (params) => {
11952
11977
  try {
11953
- return !!castToTokenRequestParams$2(params);
11978
+ return !!castToTokenRequestParams(params);
11954
11979
  }
11955
11980
  catch (_a) {
11956
11981
  return false;
11957
11982
  }
11958
11983
  };
11959
- const requestToken$3 = (tokenRequester, params) => tokenRequester(castToTokenRequestParams$2(params));
11984
+ const requestToken = (tokenRequester, params) => tokenRequester(castToTokenRequestParams(params));
11960
11985
 
11961
11986
  async function maybeUpdateToken(oauthTokenStore, tokenFetcher, options, mustRefresh = false) {
11962
11987
  if (!mustRefresh && oauthTokenStore.get('accessToken')) {
11963
11988
  return;
11964
11989
  }
11965
11990
  const refreshOptions = Object.assign(Object.assign({}, options), { refreshToken: oauthTokenStore.get('refreshToken') });
11966
- if (isEligible$1(refreshOptions)) {
11967
- return oauthTokenStore.set(await requestToken$1(tokenFetcher, refreshOptions));
11991
+ if (isEligible$2(refreshOptions)) {
11992
+ return oauthTokenStore.set(await requestToken$2(tokenFetcher, refreshOptions));
11968
11993
  }
11969
- if (isEligible$3(options)) {
11970
- return oauthTokenStore.set(await requestToken$3(tokenFetcher, options));
11994
+ if (isEligible(options)) {
11995
+ return oauthTokenStore.set(await requestToken(tokenFetcher, options));
11971
11996
  }
11972
11997
  if (typeof window !== 'undefined' && options.implicit) {
11973
- const parsedLocationHash = querystring.parse(window.location.hash);
11998
+ const parsedLocationHash = querystring__default["default"].parse(window.location.hash);
11974
11999
  const accessToken = parsedLocationHash && parsedLocationHash.access_token;
11975
12000
  if (accessToken) {
11976
12001
  window.history.replaceState({}, '', window.location.href.split('#')[0]);
11977
12002
  return oauthTokenStore.set({ accessToken });
11978
12003
  }
11979
- if (isEligibleForClientRedirect$1(options)) {
11980
- window.location.href = getRedirectUrl$1(options);
12004
+ if (isEligibleForClientRedirect(options)) {
12005
+ window.location.href = getRedirectUrl(options);
11981
12006
  return;
11982
12007
  }
11983
12008
  }
11984
- if (!mustRefresh && isEligible(options)) {
11985
- return oauthTokenStore.set(await requestToken(tokenFetcher, options));
12009
+ if (!mustRefresh && isEligible$3(options)) {
12010
+ return oauthTokenStore.set(await requestToken$3(tokenFetcher, options));
11986
12011
  }
11987
12012
  if (options.authorizationRedirect &&
11988
- isEligibleForClientRedirect(options)) {
11989
- return options.authorizationRedirect(getRedirectUrl(options));
12013
+ isEligibleForClientRedirect$1(options)) {
12014
+ return options.authorizationRedirect(getRedirectUrl$1(options));
11990
12015
  }
11991
- if (isEligible$2(options)) {
11992
- return oauthTokenStore.set(await requestToken$2(tokenFetcher, options));
12016
+ if (isEligible$1(options)) {
12017
+ return oauthTokenStore.set(await requestToken$1(tokenFetcher, options));
11993
12018
  }
11994
12019
  return;
11995
12020
  }
@@ -12009,7 +12034,7 @@ const RETRYABLE_STATUS_CODES = [
12009
12034
  504,
12010
12035
  ];
12011
12036
  const TOKEN_REFRESH_STATUS_CODES = [401];
12012
- const queue = new Bottleneck({
12037
+ const queue = new Bottleneck__default["default"]({
12013
12038
  maxConcurrent: QUEUE_CONCURRENCY,
12014
12039
  minTime: QUEUE_DELAY,
12015
12040
  reservoir: QUEUE_RESERVOIR,
@@ -12078,7 +12103,7 @@ function makeApiRequest(oauthTokenStore, oauthTokenRequester, options, httpMetho
12078
12103
  const method = httpMethod.toUpperCase();
12079
12104
  const payloadQuery = payload && payload.query
12080
12105
  ? (apiMethod.includes('?') ? '&' : '?') +
12081
- querystring.stringify(payload.query)
12106
+ querystring__default["default"].stringify(payload.query)
12082
12107
  : '';
12083
12108
  const url = `${options.apiUrl}/api${apiMethod}${payloadQuery}`;
12084
12109
  const body = payload && payload.body;
@@ -12097,7 +12122,7 @@ function makeApiRequest(oauthTokenStore, oauthTokenRequester, options, httpMetho
12097
12122
  const requestBody = {
12098
12123
  body: hasForm ? formData : JSON.stringify(body),
12099
12124
  };
12100
- const response = await fetch(url, Object.assign({ cache: 'no-cache', credentials: 'omit', headers,
12125
+ const response = await fetch__default["default"](url, Object.assign({ cache: 'no-cache', credentials: 'omit', headers,
12101
12126
  method, mode: 'cors' }, (hasForm || body ? requestBody : {})));
12102
12127
  const result = await makeResultFromResponse(response);
12103
12128
  responseLogger.log(method, url, result instanceof Error
@@ -12131,6 +12156,7 @@ async function request(oauthTokenStore, oauthTokenRequester, options, httpMethod
12131
12156
  const API_METHODS = [
12132
12157
  agentCreate,
12133
12158
  agentCreatePermissions,
12159
+ activeUnitsGetByAppId,
12134
12160
  appCreate,
12135
12161
  appGetById,
12136
12162
  bucketCreate,
@@ -12193,6 +12219,8 @@ const API_METHODS = [
12193
12219
  utilisationPeriodCheckInUser,
12194
12220
  utilisationPeriodCheckOutUser,
12195
12221
  utilisationPeriodAddRegistrationCode,
12222
+ bookingUpdateById,
12223
+ bookingGetById,
12196
12224
  ];
12197
12225
  function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) {
12198
12226
  const options = Object.assign(Object.assign({}, DEFAULT_API_WRAPPER_OPTIONS), userOptions);
@@ -12221,11 +12249,11 @@ function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) {
12221
12249
  const put$1 = partial(put, request$1);
12222
12250
  const oauth = {
12223
12251
  authorizationCode: {
12224
- getUri: (state = options.state || pseudoRandomString()) => partial(getRedirectUrl, Object.assign(Object.assign({}, options), { state }))(),
12225
- requestToken: (authorizationCode) => requestAndSaveToStore(partial(requestToken, tokenRequester, Object.assign(Object.assign({}, options), { authorizationCode: authorizationCode || options.authorizationCode })), tokenStore),
12252
+ getUri: (state = options.state || pseudoRandomString()) => partial(getRedirectUrl$1, Object.assign(Object.assign({}, options), { state }))(),
12253
+ requestToken: (authorizationCode) => requestAndSaveToStore(partial(requestToken$3, tokenRequester, Object.assign(Object.assign({}, options), { authorizationCode: authorizationCode || options.authorizationCode })), tokenStore),
12226
12254
  },
12227
12255
  generateState: pseudoRandomString,
12228
- refreshToken: (refreshToken) => requestAndSaveToStore(partial(requestToken$1, tokenRequester, Object.assign(Object.assign({}, options), { refreshToken: refreshToken || tokenStore.get('refreshToken') })), tokenStore),
12256
+ refreshToken: (refreshToken) => requestAndSaveToStore(partial(requestToken$2, tokenRequester, Object.assign(Object.assign({}, options), { refreshToken: refreshToken || tokenStore.get('refreshToken') })), tokenStore),
12229
12257
  };
12230
12258
  const client = API_METHODS.reduce((methods, method) => (Object.assign(Object.assign({}, methods), { [method.name]: (...args) => method(client, ...args) })), {
12231
12259
  delete: del$1,