bruce-models 5.4.1 → 5.4.4

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.
@@ -312,6 +312,19 @@
312
312
  return text;
313
313
  });
314
314
  }
315
+ /**
316
+ * Ensuring obvious faults in our session ID storage don't waste DB time.
317
+ * @param ssid
318
+ * @returns
319
+ */
320
+ const prepSessionId = (ssid) => {
321
+ let tmp = ssid;
322
+ if (!tmp || "null" == tmp || "undefined" == tmp) {
323
+ tmp = "";
324
+ }
325
+ // Anonymous SSID will mean Guardian doesn't bother touching the DB.
326
+ return tmp ? tmp : "anonymous";
327
+ };
315
328
  /**
316
329
  * This is a base class for communication with an arbitrary Nextspace API.
317
330
  */
@@ -387,14 +400,14 @@
387
400
  * @returns
388
401
  */
389
402
  GetSessionId() {
390
- return this.ssid;
403
+ return prepSessionId(this.ssid);
391
404
  }
392
405
  /**
393
406
  * Sets the session ID.
394
407
  * @param value
395
408
  */
396
409
  SetSessionId(value) {
397
- this.ssid = value;
410
+ this.ssid = prepSessionId(value);
398
411
  }
399
412
  /**
400
413
  * Returns the session header.
@@ -424,8 +437,8 @@
424
437
  }
425
438
  params.headers = params.headers || {};
426
439
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
427
- if (this.ssidHeader && this.ssid) {
428
- params.headers[this.ssidHeader] = this.ssid;
440
+ if (this.ssidHeader) {
441
+ params.headers[this.ssidHeader] = this.GetSessionId();
429
442
  }
430
443
  const res = yield fetch(url, {
431
444
  headers: params.headers,
@@ -448,8 +461,8 @@
448
461
  }
449
462
  params.headers = params.headers || {};
450
463
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
451
- if (this.ssidHeader && this.ssid) {
452
- params.headers[this.ssidHeader] = this.ssid;
464
+ if (this.ssidHeader) {
465
+ params.headers[this.ssidHeader] = this.GetSessionId();
453
466
  }
454
467
  const res = yield fetch(url, {
455
468
  headers: params.headers,
@@ -474,8 +487,8 @@
474
487
  }
475
488
  params.headers = params.headers || {};
476
489
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
477
- if (this.ssidHeader && this.ssid) {
478
- params.headers[this.ssidHeader] = this.ssid;
490
+ if (this.ssidHeader) {
491
+ params.headers[this.ssidHeader] = this.GetSessionId();
479
492
  }
480
493
  if (!data) {
481
494
  data = {};
@@ -507,8 +520,8 @@
507
520
  }
508
521
  params.headers = params.headers || {};
509
522
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
510
- if (this.ssidHeader && this.ssid) {
511
- params.headers[this.ssidHeader] = this.ssid;
523
+ if (this.ssidHeader) {
524
+ params.headers[this.ssidHeader] = this.GetSessionId();
512
525
  }
513
526
  if (!data) {
514
527
  data = {};
@@ -539,8 +552,8 @@
539
552
  params = {};
540
553
  }
541
554
  params.headers = Object.assign({}, params.headers);
542
- if (this.ssidHeader && this.ssid) {
543
- params.headers[this.ssidHeader] = this.ssid;
555
+ if (this.ssidHeader) {
556
+ params.headers[this.ssidHeader] = this.GetSessionId();
544
557
  }
545
558
  const formData = params.formData instanceof FormData ? params.formData : new FormData();
546
559
  if (formData.has("file")) {
@@ -745,7 +758,8 @@
745
758
  url += ".host/";
746
759
  break;
747
760
  default:
748
- throw ("Specified Environment is not valid. SuppliedEnv=" + env);
761
+ console.warn("Supplied environment does not match default options. You will need to set the base url manually. SuppliedEnv=" + env);
762
+ return;
749
763
  }
750
764
  this.baseUrl = url;
751
765
  }
@@ -851,6 +865,9 @@
851
865
  this.loadCancelled = false;
852
866
  // Indicates if loading the regional configuration was already called.
853
867
  this.configLoadAttempted = false;
868
+ // Indicates if the init process has finished loading.
869
+ // While this is not resolved requests will be in a pending state.
870
+ this.loadProm = Promise.resolve();
854
871
  let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy } = params;
855
872
  this.accountId = accountId;
856
873
  this.env = env !== null && env !== void 0 ? env : exports.Api.EEnv.PROD;
@@ -14460,7 +14477,7 @@
14460
14477
  })(exports.DataSource || (exports.DataSource = {}));
14461
14478
 
14462
14479
  // This is updated with the package.json version on build.
14463
- const VERSION = "5.4.1";
14480
+ const VERSION = "5.4.4";
14464
14481
 
14465
14482
  exports.VERSION = VERSION;
14466
14483
  exports.AbstractApi = AbstractApi;