@niledatabase/server 3.0.0-alpha.34 → 3.0.0-alpha.36

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.
@@ -482,8 +482,12 @@ var getDatabaseId = function getDatabaseId(cfg) {
482
482
  return String(config == null ? void 0 : config.databaseId);
483
483
  }
484
484
  if (process.env.NILEDB_POSTGRES_URL) {
485
- var pgUrl = new URL(process.env.NILEDB_POSTGRES_URL);
486
- return pgUrl.pathname.substring(1);
485
+ try {
486
+ var pgUrl = new URL(process.env.NILEDB_POSTGRES_URL);
487
+ return pgUrl.pathname.substring(1);
488
+ } catch (e) {
489
+ // ok to fail
490
+ }
487
491
  }
488
492
  logger && info(logger + "[NILEDB_ID] " + process.env.NILEDB_ID);
489
493
  return process.env.NILEDB_ID;
@@ -546,6 +550,14 @@ var getDatabaseName = function getDatabaseName(cfg) {
546
550
  logger && info(logger + "[NILEDB_NAME] " + process.env.NILEDB_NAME);
547
551
  return process.env.NILEDB_NAME;
548
552
  }
553
+ if (process.env.NILEDB_POSTGRES_URL) {
554
+ try {
555
+ var pgUrl = new URL(process.env.NILEDB_POSTGRES_URL);
556
+ return pgUrl.pathname.substring(1);
557
+ } catch (e) {
558
+ // ok to fail
559
+ }
560
+ }
549
561
  return null;
550
562
  };
551
563
  var getTenantId = function getTenantId(cfg) {
@@ -573,7 +585,8 @@ var getBasePath = function getBasePath(cfg) {
573
585
  logger = cfg.logger;
574
586
  var _Logger7 = Logger(config, '[basePath]'),
575
587
  warn = _Logger7.warn,
576
- info = _Logger7.info;
588
+ info = _Logger7.info,
589
+ error = _Logger7.error;
577
590
  var basePath = config == null || (_config$api4 = config.api) == null ? void 0 : _config$api4.basePath;
578
591
  if (basePath) {
579
592
  logger && info(logger + "[config] " + basePath);
@@ -581,8 +594,14 @@ var getBasePath = function getBasePath(cfg) {
581
594
  }
582
595
  if (process.env.NILEDB_API_URL) {
583
596
  logger && info(logger + "[NILEDB_API_URL] " + process.env.NILEDB_API_URL);
584
- var apiUrl = new URL(process.env.NILEDB_API_URL);
585
- return apiUrl.href;
597
+ try {
598
+ var apiUrl = new URL(process.env.NILEDB_API_URL);
599
+ return apiUrl.href;
600
+ } catch (e) {
601
+ if (e instanceof Error) {
602
+ error(e.stack);
603
+ }
604
+ }
586
605
  }
587
606
  warn('not set. Must run auto-configuration');
588
607
  return undefined;
@@ -617,9 +636,13 @@ function getDbHost(cfg) {
617
636
  return config.db.host;
618
637
  }
619
638
  if (process.env.NILEDB_POSTGRES_URL) {
620
- var pgUrl = new URL(process.env.NILEDB_POSTGRES_URL);
621
- logger && info(logger + "[NILEDB_POSTGRES_URL] " + pgUrl.hostname);
622
- return pgUrl.hostname;
639
+ try {
640
+ var pgUrl = new URL(process.env.NILEDB_POSTGRES_URL);
641
+ logger && info(logger + "[NILEDB_POSTGRES_URL] " + pgUrl.hostname);
642
+ return pgUrl.hostname;
643
+ } catch (e) {
644
+ // ok to fail
645
+ }
623
646
  }
624
647
  if (process.env.NILEDB_HOST) {
625
648
  logger && info(logger + "[NILEDB_HOST] " + process.env.NILEDB_HOST);
@@ -643,6 +666,16 @@ function getDbPort(cfg) {
643
666
  logger && info(logger + "[NILEDB_PORT] " + process.env.NILEDB_PORT);
644
667
  return Number(process.env.NILEDB_PORT);
645
668
  }
669
+ if (process.env.NILEDB_POSTGRES_URL) {
670
+ try {
671
+ var pgUrl = new URL(process.env.NILEDB_POSTGRES_URL);
672
+ if (pgUrl.port) {
673
+ return Number(pgUrl.port);
674
+ }
675
+ } catch (e) {
676
+ // ok to fail
677
+ }
678
+ }
646
679
  logger && info(logger + "[default] 5432");
647
680
  return 5432;
648
681
  }
@@ -3588,7 +3621,7 @@ var Requester = /*#__PURE__*/function (_Config) {
3588
3621
  }();
3589
3622
  _proto.post = /*#__PURE__*/function () {
3590
3623
  var _post = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(req, url, init) {
3591
- var response;
3624
+ var response, cloned;
3592
3625
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3593
3626
  while (1) switch (_context3.prev = _context3.next) {
3594
3627
  case 0:
@@ -3597,17 +3630,25 @@ var Requester = /*#__PURE__*/function (_Config) {
3597
3630
  case 2:
3598
3631
  response = _context3.sent;
3599
3632
  if (!(response && response.status >= 200 && response.status < 300)) {
3600
- _context3.next = 5;
3633
+ _context3.next = 13;
3601
3634
  break;
3602
3635
  }
3603
- return _context3.abrupt("return", response.json());
3604
- case 5:
3636
+ cloned = response.clone();
3637
+ _context3.prev = 5;
3638
+ _context3.next = 8;
3639
+ return cloned.json();
3640
+ case 8:
3641
+ return _context3.abrupt("return", _context3.sent);
3642
+ case 11:
3643
+ _context3.prev = 11;
3644
+ _context3.t0 = _context3["catch"](5);
3645
+ case 13:
3605
3646
  return _context3.abrupt("return", response);
3606
- case 6:
3647
+ case 14:
3607
3648
  case "end":
3608
3649
  return _context3.stop();
3609
3650
  }
3610
- }, _callee3, this);
3651
+ }, _callee3, this, [[5, 11]]);
3611
3652
  }));
3612
3653
  function post(_x9, _x10, _x11) {
3613
3654
  return _post.apply(this, arguments);
@@ -3616,7 +3657,7 @@ var Requester = /*#__PURE__*/function (_Config) {
3616
3657
  }();
3617
3658
  _proto.get = /*#__PURE__*/function () {
3618
3659
  var _get = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(req, url, init) {
3619
- var response;
3660
+ var response, cloned;
3620
3661
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3621
3662
  while (1) switch (_context4.prev = _context4.next) {
3622
3663
  case 0:
@@ -3625,17 +3666,25 @@ var Requester = /*#__PURE__*/function (_Config) {
3625
3666
  case 2:
3626
3667
  response = _context4.sent;
3627
3668
  if (!(response && response.status >= 200 && response.status < 300)) {
3628
- _context4.next = 5;
3669
+ _context4.next = 13;
3629
3670
  break;
3630
3671
  }
3631
- return _context4.abrupt("return", response.json());
3632
- case 5:
3672
+ cloned = response.clone();
3673
+ _context4.prev = 5;
3674
+ _context4.next = 8;
3675
+ return cloned.json();
3676
+ case 8:
3677
+ return _context4.abrupt("return", _context4.sent);
3678
+ case 11:
3679
+ _context4.prev = 11;
3680
+ _context4.t0 = _context4["catch"](5);
3681
+ case 13:
3633
3682
  return _context4.abrupt("return", response);
3634
- case 6:
3683
+ case 14:
3635
3684
  case "end":
3636
3685
  return _context4.stop();
3637
3686
  }
3638
- }, _callee4, this);
3687
+ }, _callee4, this, [[5, 11]]);
3639
3688
  }));
3640
3689
  function get(_x12, _x13, _x14) {
3641
3690
  return _get.apply(this, arguments);
@@ -3644,7 +3693,7 @@ var Requester = /*#__PURE__*/function (_Config) {
3644
3693
  }();
3645
3694
  _proto.put = /*#__PURE__*/function () {
3646
3695
  var _put = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(req, url, init) {
3647
- var response;
3696
+ var response, cloned;
3648
3697
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3649
3698
  while (1) switch (_context5.prev = _context5.next) {
3650
3699
  case 0:
@@ -3653,17 +3702,25 @@ var Requester = /*#__PURE__*/function (_Config) {
3653
3702
  case 2:
3654
3703
  response = _context5.sent;
3655
3704
  if (!(response && response.status >= 200 && response.status < 300)) {
3656
- _context5.next = 5;
3705
+ _context5.next = 13;
3657
3706
  break;
3658
3707
  }
3659
- return _context5.abrupt("return", response.json());
3660
- case 5:
3708
+ cloned = response.clone();
3709
+ _context5.prev = 5;
3710
+ _context5.next = 8;
3711
+ return cloned.json();
3712
+ case 8:
3713
+ return _context5.abrupt("return", _context5.sent);
3714
+ case 11:
3715
+ _context5.prev = 11;
3716
+ _context5.t0 = _context5["catch"](5);
3717
+ case 13:
3661
3718
  return _context5.abrupt("return", response);
3662
- case 6:
3719
+ case 14:
3663
3720
  case "end":
3664
3721
  return _context5.stop();
3665
3722
  }
3666
- }, _callee5, this);
3723
+ }, _callee5, this, [[5, 11]]);
3667
3724
  }));
3668
3725
  function put(_x15, _x16, _x17) {
3669
3726
  return _put.apply(this, arguments);
@@ -3680,14 +3737,8 @@ var Requester = /*#__PURE__*/function (_Config) {
3680
3737
  return this.request('DELETE', url, req, init);
3681
3738
  case 2:
3682
3739
  response = _context6.sent;
3683
- if (!(response && response.status >= 200 && response.status < 300)) {
3684
- _context6.next = 5;
3685
- break;
3686
- }
3687
- return _context6.abrupt("return", response.json());
3688
- case 5:
3689
3740
  return _context6.abrupt("return", response);
3690
- case 6:
3741
+ case 4:
3691
3742
  case "end":
3692
3743
  return _context6.stop();
3693
3744
  }
@@ -4003,6 +4054,55 @@ var Tenants = /*#__PURE__*/function (_Config) {
4003
4054
  return _ref3.apply(this, arguments);
4004
4055
  };
4005
4056
  }();
4057
+ _this.deleteTenant = /*#__PURE__*/function () {
4058
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(req, init) {
4059
+ var _requester, _init;
4060
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
4061
+ while (1) switch (_context4.prev = _context4.next) {
4062
+ case 0:
4063
+ if (typeof req === 'string') {
4064
+ _this.tenantId = req;
4065
+ }
4066
+ _requester = new Requester(_this);
4067
+ _init = _this.handleHeaders(init);
4068
+ return _context4.abrupt("return", _requester["delete"](req, _this.tenantUrl, _init));
4069
+ case 4:
4070
+ case "end":
4071
+ return _context4.stop();
4072
+ }
4073
+ }, _callee4);
4074
+ }));
4075
+ return function (_x7, _x8) {
4076
+ return _ref4.apply(this, arguments);
4077
+ };
4078
+ }();
4079
+ _this.updateTenant = /*#__PURE__*/function () {
4080
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(req, init) {
4081
+ var _req, _requester, _init;
4082
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
4083
+ while (1) switch (_context5.prev = _context5.next) {
4084
+ case 0:
4085
+ if (req && 'name' in req) {
4086
+ _req = new Request("" + _this.api.basePath + _this.tenantUrl, {
4087
+ body: JSON.stringify(req),
4088
+ method: 'PUT'
4089
+ });
4090
+ } else {
4091
+ _req = req;
4092
+ }
4093
+ _requester = new Requester(_this);
4094
+ _init = _this.handleHeaders(init);
4095
+ return _context5.abrupt("return", _requester.put(_req, _this.tenantUrl, _init));
4096
+ case 4:
4097
+ case "end":
4098
+ return _context5.stop();
4099
+ }
4100
+ }, _callee5);
4101
+ }));
4102
+ return function (_x9, _x10) {
4103
+ return _ref5.apply(this, arguments);
4104
+ };
4105
+ }();
4006
4106
  _this.headers = headers;
4007
4107
  return _this;
4008
4108
  }
@@ -4070,8 +4170,8 @@ var Users = /*#__PURE__*/function (_Config) {
4070
4170
  return _ref.apply(this, arguments);
4071
4171
  };
4072
4172
  }();
4073
- _this.updateUser = /*#__PURE__*/function () {
4074
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(userId, req, init) {
4173
+ _this.createTenantUser = /*#__PURE__*/function () {
4174
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req, init) {
4075
4175
  var _requester, _init;
4076
4176
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4077
4177
  while (1) switch (_context2.prev = _context2.next) {
@@ -4079,7 +4179,7 @@ var Users = /*#__PURE__*/function (_Config) {
4079
4179
  _requester = new Requester(_this);
4080
4180
  _init = _this.handleHeaders(init);
4081
4181
  _context2.next = 4;
4082
- return _requester.put(req, _this.usersUrl + "/" + userId, _init);
4182
+ return _requester.post(req, _this.tenantUsersUrl, _init);
4083
4183
  case 4:
4084
4184
  return _context2.abrupt("return", _context2.sent);
4085
4185
  case 5:
@@ -4088,33 +4188,42 @@ var Users = /*#__PURE__*/function (_Config) {
4088
4188
  }
4089
4189
  }, _callee2);
4090
4190
  }));
4091
- return function (_x3, _x4, _x5) {
4191
+ return function (_x3, _x4) {
4092
4192
  return _ref2.apply(this, arguments);
4093
4193
  };
4094
4194
  }();
4095
- _this.listUsers = /*#__PURE__*/function () {
4195
+ _this.updateUser = /*#__PURE__*/function () {
4096
4196
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(req, init) {
4097
- var _requester, _init;
4197
+ var _req, _requester, _init;
4098
4198
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
4099
4199
  while (1) switch (_context3.prev = _context3.next) {
4100
4200
  case 0:
4201
+ if (req && 'id' in req) {
4202
+ _req = new Request("" + _this.api.basePath + _this.tenantUserUrl, {
4203
+ body: JSON.stringify(req),
4204
+ method: 'PUT'
4205
+ });
4206
+ _this.userId = String(req.id);
4207
+ } else {
4208
+ _req = req;
4209
+ }
4101
4210
  _requester = new Requester(_this);
4102
4211
  _init = _this.handleHeaders(init);
4103
- _context3.next = 4;
4104
- return _requester.get(req, _this.tenantUsersUrl, _init);
4105
- case 4:
4106
- return _context3.abrupt("return", _context3.sent);
4212
+ _context3.next = 5;
4213
+ return _requester.put(_req, _this.tenantUserUrl, _init);
4107
4214
  case 5:
4215
+ return _context3.abrupt("return", _context3.sent);
4216
+ case 6:
4108
4217
  case "end":
4109
4218
  return _context3.stop();
4110
4219
  }
4111
4220
  }, _callee3);
4112
4221
  }));
4113
- return function (_x6, _x7) {
4222
+ return function (_x5, _x6) {
4114
4223
  return _ref3.apply(this, arguments);
4115
4224
  };
4116
4225
  }();
4117
- _this.linkUser = /*#__PURE__*/function () {
4226
+ _this.listUsers = /*#__PURE__*/function () {
4118
4227
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(req, init) {
4119
4228
  var _requester, _init;
4120
4229
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -4123,7 +4232,7 @@ var Users = /*#__PURE__*/function (_Config) {
4123
4232
  _requester = new Requester(_this);
4124
4233
  _init = _this.handleHeaders(init);
4125
4234
  _context4.next = 4;
4126
- return _requester.put(req, _this.tenantUsersUrl, _init);
4235
+ return _requester.get(req, _this.tenantUsersUrl, _init);
4127
4236
  case 4:
4128
4237
  return _context4.abrupt("return", _context4.sent);
4129
4238
  case 5:
@@ -4132,68 +4241,65 @@ var Users = /*#__PURE__*/function (_Config) {
4132
4241
  }
4133
4242
  }, _callee4);
4134
4243
  }));
4135
- return function (_x8, _x9) {
4244
+ return function (_x7, _x8) {
4136
4245
  return _ref4.apply(this, arguments);
4137
4246
  };
4138
4247
  }();
4139
- _this.tenantUsersDeleteUrl = function (userId) {
4140
- var _this$tenantId;
4141
- return "/tenants/" + ((_this$tenantId = _this.tenantId) != null ? _this$tenantId : '{tenantId}') + "/users/" + (userId != null ? userId : '{userId}');
4142
- };
4143
- _this.getUserId = /*#__PURE__*/function () {
4144
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(req) {
4145
- var body;
4248
+ _this.linkUser = /*#__PURE__*/function () {
4249
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(req, init) {
4250
+ var _requester, _init;
4146
4251
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
4147
4252
  while (1) switch (_context5.prev = _context5.next) {
4148
4253
  case 0:
4149
- if (!(req instanceof Request)) {
4150
- _context5.next = 6;
4151
- break;
4152
- }
4153
- _context5.next = 3;
4154
- return new Response(req == null ? void 0 : req.body).json();
4155
- case 3:
4156
- body = _context5.sent;
4157
- if (!body) {
4158
- _context5.next = 6;
4159
- break;
4254
+ _requester = new Requester(_this);
4255
+ if (typeof req === 'string') {
4256
+ _this.userId = req;
4257
+ } else {
4258
+ if ('id' in req) {
4259
+ _this.userId = req.id;
4260
+ }
4261
+ if ('tenantId' in req) {
4262
+ _this.tenantId = req.tenantId;
4263
+ }
4160
4264
  }
4161
- return _context5.abrupt("return", body.id);
4265
+ _init = _this.handleHeaders(init);
4266
+ _context5.next = 5;
4267
+ return _requester.put(req, _this.linkUsersUrl, _init);
4268
+ case 5:
4269
+ return _context5.abrupt("return", _context5.sent);
4162
4270
  case 6:
4163
- if (!('id' in req)) {
4164
- _context5.next = 8;
4165
- break;
4166
- }
4167
- return _context5.abrupt("return", req.id);
4168
- case 8:
4169
- return _context5.abrupt("return", null);
4170
- case 9:
4171
4271
  case "end":
4172
4272
  return _context5.stop();
4173
4273
  }
4174
4274
  }, _callee5);
4175
4275
  }));
4176
- return function (_x10) {
4276
+ return function (_x9, _x10) {
4177
4277
  return _ref5.apply(this, arguments);
4178
4278
  };
4179
4279
  }();
4180
4280
  _this.unlinkUser = /*#__PURE__*/function () {
4181
4281
  var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(req, init) {
4182
- var _requester, userId, _init;
4282
+ var _requester, _init;
4183
4283
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
4184
4284
  while (1) switch (_context6.prev = _context6.next) {
4185
4285
  case 0:
4286
+ if (typeof req === 'string') {
4287
+ _this.userId = req;
4288
+ } else {
4289
+ if ('id' in req) {
4290
+ _this.userId = req.id;
4291
+ }
4292
+ if ('tenantId' in req) {
4293
+ _this.tenantId = req.tenantId;
4294
+ }
4295
+ }
4186
4296
  _requester = new Requester(_this);
4187
- _context6.next = 3;
4188
- return _this.getUserId(req);
4189
- case 3:
4190
- userId = _context6.sent;
4191
4297
  _init = _this.handleHeaders(init);
4192
- _context6.next = 7;
4193
- return _requester["delete"](req, _this.tenantUsersDeleteUrl(userId), _init);
4194
- case 7:
4298
+ _context6.next = 5;
4299
+ return _requester["delete"](req, _this.linkUsersUrl, _init);
4300
+ case 5:
4195
4301
  return _context6.abrupt("return", _context6.sent);
4196
- case 8:
4302
+ case 6:
4197
4303
  case "end":
4198
4304
  return _context6.stop();
4199
4305
  }
@@ -4225,6 +4331,28 @@ var Users = /*#__PURE__*/function (_Config) {
4225
4331
  return _ref7.apply(this, arguments);
4226
4332
  };
4227
4333
  }();
4334
+ _this.updateMe = /*#__PURE__*/function () {
4335
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(req, init) {
4336
+ var _requester, _init;
4337
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
4338
+ while (1) switch (_context8.prev = _context8.next) {
4339
+ case 0:
4340
+ _requester = new Requester(_this);
4341
+ _init = _this.handleHeaders(init);
4342
+ _context8.next = 4;
4343
+ return _requester.put(req, _this.meUrl, _init);
4344
+ case 4:
4345
+ return _context8.abrupt("return", _context8.sent);
4346
+ case 5:
4347
+ case "end":
4348
+ return _context8.stop();
4349
+ }
4350
+ }, _callee8);
4351
+ }));
4352
+ return function (_x15, _x16) {
4353
+ return _ref8.apply(this, arguments);
4354
+ };
4355
+ }();
4228
4356
  _this.headers = headers;
4229
4357
  return _this;
4230
4358
  }
@@ -4253,8 +4381,20 @@ var Users = /*#__PURE__*/function (_Config) {
4253
4381
  }, {
4254
4382
  key: "tenantUsersUrl",
4255
4383
  get: function get() {
4256
- var _this$tenantId2;
4257
- return "/tenants/" + ((_this$tenantId2 = this.tenantId) != null ? _this$tenantId2 : '{tenantId}') + "/users";
4384
+ var _this$tenantId;
4385
+ return "/tenants/" + ((_this$tenantId = this.tenantId) != null ? _this$tenantId : '{tenantId}') + "/users";
4386
+ }
4387
+ }, {
4388
+ key: "linkUsersUrl",
4389
+ get: function get() {
4390
+ var _this$tenantId2, _this$userId;
4391
+ return "/tenants/" + ((_this$tenantId2 = this.tenantId) != null ? _this$tenantId2 : '{tenantId}') + "/users/" + ((_this$userId = this.userId) != null ? _this$userId : '{userId}') + "/link";
4392
+ }
4393
+ }, {
4394
+ key: "tenantUserUrl",
4395
+ get: function get() {
4396
+ var _this$tenantId3, _this$userId2;
4397
+ return "/tenants/" + ((_this$tenantId3 = this.tenantId) != null ? _this$tenantId3 : '{tenantId}') + "/users/" + ((_this$userId2 = this.userId) != null ? _this$userId2 : '{userId}');
4258
4398
  }
4259
4399
  }, {
4260
4400
  key: "meUrl",
@@ -4372,7 +4512,10 @@ var Server = /*#__PURE__*/function () {
4372
4512
  // propagate special config items
4373
4513
  this.tenantId = updatedConfig.tenantId;
4374
4514
  this.userId = updatedConfig.userId;
4375
- this.token = updatedConfig.api.token;
4515
+ // if we have a token, update it, else use the one that was there
4516
+ if (updatedConfig.api.token) {
4517
+ this.token = updatedConfig.api.token;
4518
+ }
4376
4519
  this.databaseId = updatedConfig.databaseId;
4377
4520
  return this;
4378
4521
  };