bruce-models 5.4.3 → 5.4.5

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")) {
@@ -3203,11 +3216,23 @@
3203
3216
  if (!api) {
3204
3217
  api = exports.ENVIRONMENT.Api().GetBruceApi();
3205
3218
  }
3219
+ const cacheKeyData = {
3220
+ expandLocation,
3221
+ expandRelations,
3222
+ expandImports,
3223
+ expandSources,
3224
+ entityTypeId: null,
3225
+ historicFrom: historicFrom,
3226
+ historicKey: historicKey,
3227
+ historicTo: historicTo,
3228
+ historicPoint: historicPoint,
3229
+ schemaId: schemaId
3230
+ };
3206
3231
  const crashRiskReqs = [];
3207
3232
  const reqIds = [];
3208
3233
  for (let i = 0; i < entityIds.length; i++) {
3209
3234
  const entityId = entityIds[i];
3210
- const key = GetCacheKey({ entityId, expandRelations, expandLocation });
3235
+ const key = GetCacheKey(Object.assign(Object.assign({}, cacheKeyData), { entityId }));
3211
3236
  const cache = api.GetCacheItem(key, reqParams);
3212
3237
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
3213
3238
  crashRiskReqs.push(cache.data);
@@ -3272,19 +3297,7 @@
3272
3297
  const req = api.POST(url, reqData, exports.Api.PrepReqParams(reqParams));
3273
3298
  for (let i = 0; i < reqIds.length; i++) {
3274
3299
  const entityId = reqIds[i];
3275
- const key = GetCacheKey({
3276
- entityId,
3277
- expandLocation,
3278
- expandRelations,
3279
- expandImports,
3280
- expandSources,
3281
- entityTypeId: null,
3282
- historicFrom: historicFrom,
3283
- historicKey: historicKey,
3284
- historicTo: historicTo,
3285
- historicPoint: historicPoint,
3286
- schemaId: schemaId
3287
- });
3300
+ const key = GetCacheKey(Object.assign(Object.assign({}, cacheKeyData), { entityId }));
3288
3301
  const prom = new Promise((res) => __awaiter(this, void 0, void 0, function* () {
3289
3302
  try {
3290
3303
  const data = yield req;
@@ -14464,7 +14477,7 @@
14464
14477
  })(exports.DataSource || (exports.DataSource = {}));
14465
14478
 
14466
14479
  // This is updated with the package.json version on build.
14467
- const VERSION = "5.4.3";
14480
+ const VERSION = "5.4.5";
14468
14481
 
14469
14482
  exports.VERSION = VERSION;
14470
14483
  exports.AbstractApi = AbstractApi;