@salesforce/lds-runtime-webruntime 1.384.0 → 1.386.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.
@@ -91,18 +91,24 @@ let Err$1 = class Err {
91
91
  };
92
92
  const ok$2 = (value) => new Ok$2(value);
93
93
  const err$1 = (err2) => new Err$1(err2);
94
+ function isResult(value) {
95
+ return value != null && typeof value === "object" && "isOk" in value && "isErr" in value && typeof value.isOk === "function" && typeof value.isErr === "function" && (value.isOk() === true && value.isErr() === false && "value" in value || value.isOk() === false && value.isErr() === true && "error" in value);
96
+ }
97
+ function isSubscribable(obj) {
98
+ return typeof obj === "object" && obj !== null && "subscribe" in obj && typeof obj.subscribe === "function" && "refresh" in obj && typeof obj.refresh === "function";
99
+ }
94
100
  function isSubscribableResult(x) {
95
- if (typeof x !== "object" || x === null) {
101
+ if (!isResult(x)) {
96
102
  return false;
97
103
  }
98
- if ("isOk" in x && typeof x.isOk === "function") {
99
- if (x.isOk()) {
100
- return "value" in x && typeof x.value === "object" && x.value !== null && "subscribe" in x.value && typeof x.value.subscribe === "function" && "refresh" in x.value && typeof x.value.refresh === "function";
101
- } else {
102
- return "error" in x;
103
- }
104
+ return isSubscribable(x.isOk() ? x.value : x.error);
105
+ }
106
+ function buildSubscribableResult$1(result, subscribe, refresh) {
107
+ if (result.isOk()) {
108
+ return ok$2({ data: result.value, subscribe, refresh });
109
+ } else {
110
+ return err$1({ failure: result.error, subscribe, refresh });
104
111
  }
105
- return false;
106
112
  }
107
113
  function resolvedPromiseLike$3(result) {
108
114
  if (isPromiseLike$3(result)) {
@@ -234,35 +240,27 @@ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
234
240
  }
235
241
  fetchSubscribableResult(res) {
236
242
  return res.then((networkResult) => {
237
- if (networkResult.isErr()) {
238
- return err$1(networkResult.error);
239
- } else {
240
- const data = networkResult.value;
241
- return ok$2({
242
- data,
243
- subscribe: (cb) => {
244
- this.subscriptions.push(cb);
245
- return () => {
246
- this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
247
- };
248
- },
249
- refresh: () => this.refresh()
250
- });
251
- }
243
+ return buildSubscribableResult$1(
244
+ networkResult,
245
+ (cb) => {
246
+ this.subscriptions.push(cb);
247
+ return () => {
248
+ this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
249
+ };
250
+ },
251
+ () => this.refresh()
252
+ );
252
253
  });
253
254
  }
254
255
  refresh() {
255
256
  return this.execute().then((newResult) => {
256
- if (newResult.isOk()) {
257
- if (isSubscribableResult(newResult)) {
258
- const value = newResult.value;
259
- this.subscriptions.forEach((cb) => {
260
- cb(ok$2(value.data));
261
- });
262
- }
263
- return ok$2(void 0);
257
+ if (isSubscribableResult(newResult)) {
258
+ const value = newResult.isOk() ? ok$2(newResult.value.data) : err$1(newResult.error.failure);
259
+ this.subscriptions.forEach((cb) => {
260
+ cb(value);
261
+ });
264
262
  }
265
- return err$1(newResult.error);
263
+ return ok$2(void 0);
266
264
  });
267
265
  }
268
266
  async afterRequestHooks(_options) {
@@ -413,6 +411,13 @@ class Err {
413
411
  }
414
412
  const ok$1 = (value) => new Ok$1(value);
415
413
  const err = (err2) => new Err(err2);
414
+ function buildSubscribableResult(result, subscribe, refresh) {
415
+ if (result.isOk()) {
416
+ return ok$1({ data: result.value, subscribe, refresh });
417
+ } else {
418
+ return err({ failure: result.error, subscribe, refresh });
419
+ }
420
+ }
416
421
  function resolvedPromiseLike$2(result) {
417
422
  if (isPromiseLike$2(result)) {
418
423
  return result.then((nextResult) => nextResult);
@@ -512,7 +517,7 @@ class CacheControlRequestRunner {
512
517
  const resultPromise = this.readFromCacheInternal(cache);
513
518
  return resultPromise.then((result) => {
514
519
  if (result.isErr()) {
515
- return err(result.error);
520
+ return err(result.error.failure);
516
521
  }
517
522
  this.returnData = result;
518
523
  return ok$1(void 0);
@@ -541,7 +546,7 @@ class CacheControlCommand extends BaseCommand {
541
546
  this.keysUsed = /* @__PURE__ */ new Set();
542
547
  this.keysUpdated = void 0;
543
548
  this.operationType = "query";
544
- this.lastEmittedData = void 0;
549
+ this.lastResult = void 0;
545
550
  this.unsubscribeFromKeysImpl = () => void 0;
546
551
  this.subscriptions = [];
547
552
  this.instantiationTime = Date.now() / 1e3;
@@ -558,32 +563,54 @@ class CacheControlCommand extends BaseCommand {
558
563
  instrumentationAttributes: this.instrumentationAttributes
559
564
  });
560
565
  return resultPromise.then((result) => {
561
- return this.handleCacheControllerResult(result, requestRunner);
566
+ return this.handleCacheControllerResult(result, requestRunner).then((result2) => {
567
+ if (this.lastResult === void 0) {
568
+ if (result2.isErr()) {
569
+ this.lastResult = { type: "error", error: result2.error.failure };
570
+ } else {
571
+ this.lastResult = { type: "data", data: result2.value.data };
572
+ }
573
+ }
574
+ return result2;
575
+ });
562
576
  });
563
577
  }
564
578
  handleCacheControllerResult(result, requestRunner) {
565
579
  const { networkError, networkData, returnData } = requestRunner;
566
580
  return this.publishUpdatedKeys().then(() => {
567
581
  if (networkError) {
568
- return networkError;
582
+ return buildSubscribableResult(
583
+ networkError,
584
+ this.buildSubscribe(),
585
+ () => this.refresh()
586
+ );
569
587
  }
570
588
  if (result.isErr()) {
571
589
  if (networkData) {
572
- return this.constructSubscribableResult(networkData.value);
590
+ return buildSubscribableResult(
591
+ networkData,
592
+ this.buildSubscribe(),
593
+ () => this.refresh()
594
+ );
573
595
  }
574
- return err(result.error);
596
+ return buildSubscribableResult(result, this.buildSubscribe(), () => this.refresh());
575
597
  }
576
598
  if (this.subscriptions.length > 0) {
577
599
  this.subscribeToKeysUsed();
578
600
  }
579
601
  if (returnData === void 0) {
580
602
  if (networkData) {
581
- return this.constructSubscribableResult(networkData.value);
603
+ return buildSubscribableResult(
604
+ networkData,
605
+ this.buildSubscribe(),
606
+ () => this.refresh()
607
+ );
582
608
  }
583
- return err(new Error("Cache miss after fetching from network"));
584
- }
585
- if (returnData.isOk() && this.lastEmittedData === void 0) {
586
- this.lastEmittedData = returnData.value.data;
609
+ return buildSubscribableResult(
610
+ err(new Error("Cache miss after fetching from network")),
611
+ this.buildSubscribe(),
612
+ () => this.refresh()
613
+ );
587
614
  }
588
615
  return returnData;
589
616
  });
@@ -643,7 +670,7 @@ class CacheControlCommand extends BaseCommand {
643
670
  refresh() {
644
671
  return this.rerun({ cacheControlConfig: { type: "no-cache" } }).then((result) => {
645
672
  if (result.isErr()) {
646
- return err(result.error);
673
+ return err(result.error.failure);
647
674
  }
648
675
  return ok$1(void 0);
649
676
  });
@@ -661,22 +688,22 @@ class CacheControlCommand extends BaseCommand {
661
688
  const result = this.readFromCache(recordableCache);
662
689
  return result.then((readResult) => {
663
690
  if (readResult.isErr()) {
664
- return err(readResult.error);
691
+ return buildSubscribableResult(
692
+ readResult,
693
+ this.buildSubscribe(),
694
+ () => this.refresh()
695
+ );
665
696
  } else {
666
697
  const data = readResult.value;
667
698
  this.keysUsed = recordableCache.keysRead;
668
- return this.constructSubscribableResult(data);
699
+ return buildSubscribableResult(
700
+ ok$1(data),
701
+ this.buildSubscribe(),
702
+ () => this.refresh()
703
+ );
669
704
  }
670
705
  });
671
706
  }
672
- constructSubscribableResult(data) {
673
- return ok$1({
674
- data,
675
- // this cast is in case we need to return Network data as a fallback for caching errors
676
- subscribe: this.buildSubscribe(),
677
- refresh: () => this.refresh()
678
- });
679
- }
680
707
  /**
681
708
  * Builds a function that subscribes to cache changes via the pubsub service. Whenever
682
709
  * relevant cache updates occur, it re-reads the data and compares it against
@@ -703,11 +730,12 @@ class CacheControlCommand extends BaseCommand {
703
730
  rerun(overrides) {
704
731
  return this.execute(overrides).then((result) => {
705
732
  if (result.isErr()) {
706
- this.invokeConsumerCallbacks(result);
733
+ this.lastResult = { type: "error", error: result.error.failure };
734
+ this.invokeConsumerCallbacks(err(result.error.failure));
707
735
  return result;
708
736
  }
709
- if (!this.equals(this.lastEmittedData, result.value.data)) {
710
- this.lastEmittedData = result.value.data;
737
+ if (this.lastResult === void 0 || this.lastResult.type === "error" || !this.equals(this.lastResult.data, result.value.data)) {
738
+ this.lastResult = { type: "data", data: result.value.data };
711
739
  this.invokeConsumerCallbacks(ok$1(result.value.data));
712
740
  }
713
741
  return result;
@@ -1139,35 +1167,27 @@ class NetworkCommand extends BaseCommand {
1139
1167
  }
1140
1168
  fetchSubscribableResult(res) {
1141
1169
  return res.then((networkResult) => {
1142
- if (networkResult.isErr()) {
1143
- return err$1(networkResult.error);
1144
- } else {
1145
- const data = networkResult.value;
1146
- return ok$2({
1147
- data,
1148
- subscribe: (cb) => {
1149
- this.subscriptions.push(cb);
1150
- return () => {
1151
- this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
1152
- };
1153
- },
1154
- refresh: () => this.refresh()
1155
- });
1156
- }
1170
+ return buildSubscribableResult$1(
1171
+ networkResult,
1172
+ (cb) => {
1173
+ this.subscriptions.push(cb);
1174
+ return () => {
1175
+ this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
1176
+ };
1177
+ },
1178
+ () => this.refresh()
1179
+ );
1157
1180
  });
1158
1181
  }
1159
1182
  refresh() {
1160
1183
  return this.execute().then((newResult) => {
1161
- if (newResult.isOk()) {
1162
- if (isSubscribableResult(newResult)) {
1163
- const value = newResult.value;
1164
- this.subscriptions.forEach((cb) => {
1165
- cb(ok$2(value.data));
1166
- });
1167
- }
1168
- return ok$2(void 0);
1184
+ if (isSubscribableResult(newResult)) {
1185
+ const value = newResult.isOk() ? ok$2(newResult.value.data) : err$1(newResult.error.failure);
1186
+ this.subscriptions.forEach((cb) => {
1187
+ cb(value);
1188
+ });
1169
1189
  }
1170
- return err$1(newResult.error);
1190
+ return ok$2(void 0);
1171
1191
  });
1172
1192
  }
1173
1193
  async afterRequestHooks(_options) {
@@ -3432,22 +3452,22 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
3432
3452
  ),
3433
3453
  (errs) => this.coerceError(errs)
3434
3454
  ).then((result) => {
3435
- if (result.isOk()) {
3436
- return this.constructSubscribableResult(result.value);
3437
- }
3438
- return result;
3455
+ return buildSubscribableResult$1(result, this.buildSubscribe(), () => this.refresh());
3439
3456
  });
3440
3457
  } else if (this.shouldUseFetch()) {
3441
3458
  return this.convertFetchResponseToData(
3442
3459
  this.services.fetch(...this.originalFetchParams)
3443
3460
  ).then((result) => {
3444
- if (result.isOk()) {
3445
- return this.constructSubscribableResult(result.value);
3446
- }
3447
- return result;
3461
+ return buildSubscribableResult$1(result, this.buildSubscribe(), () => this.refresh());
3448
3462
  });
3449
3463
  }
3450
- return resolvedPromiseLike$3(err$1(toError("Aura/Fetch network services not found")));
3464
+ return resolvedPromiseLike$3(
3465
+ buildSubscribableResult$1(
3466
+ err$1(toError("Aura/Fetch network services not found")),
3467
+ this.buildSubscribe(),
3468
+ () => this.refresh()
3469
+ )
3470
+ );
3451
3471
  }
3452
3472
  buildRequestQuery() {
3453
3473
  const augmentedQueryResult = this.documentRootType.buildAugmentedQuery(this.config);
@@ -3476,9 +3496,6 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
3476
3496
  if (this.subscriptions.length > 0) {
3477
3497
  this.subscribeToKeysUsed();
3478
3498
  }
3479
- if (this.lastEmittedData === void 0) {
3480
- this.lastEmittedData = returnData.value.data;
3481
- }
3482
3499
  return returnData;
3483
3500
  });
3484
3501
  }
@@ -3570,10 +3587,7 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
3570
3587
  return this.convertFetchResponseToData(
3571
3588
  this.services.fetch(...this.originalFetchParams)
3572
3589
  ).then((result) => {
3573
- if (result.isOk()) {
3574
- return this.constructSubscribableResult(result.value);
3575
- }
3576
- return result;
3590
+ return buildSubscribableResult$1(result, this.buildSubscribe(), () => this.refresh());
3577
3591
  });
3578
3592
  }
3579
3593
  // Any changes to this method should most likely be duplicated in the aura command as well
@@ -3586,9 +3600,6 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
3586
3600
  if (this.subscriptions.length > 0) {
3587
3601
  this.subscribeToKeysUsed();
3588
3602
  }
3589
- if (this.lastEmittedData === void 0) {
3590
- this.lastEmittedData = returnData.value.data;
3591
- }
3592
3603
  return returnData;
3593
3604
  });
3594
3605
  }
@@ -3706,7 +3717,7 @@ function buildServiceDescriptor$2(luvio) {
3706
3717
  },
3707
3718
  };
3708
3719
  }
3709
- // version: 1.384.0-835fd13f44
3720
+ // version: 1.386.0-521094e838
3710
3721
 
3711
3722
  /**
3712
3723
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3732,7 +3743,7 @@ function buildServiceDescriptor$1(notifyRecordUpdateAvailable, getNormalizedLuvi
3732
3743
  },
3733
3744
  };
3734
3745
  }
3735
- // version: 1.384.0-835fd13f44
3746
+ // version: 1.386.0-521094e838
3736
3747
 
3737
3748
  /*!
3738
3749
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -4352,4 +4363,4 @@ const services = [
4352
4363
  buildServiceDescriptor$1({}, {}),
4353
4364
  ];
4354
4365
  setServices(services);
4355
- // version: 1.384.0-cb845692ac
4366
+ // version: 1.386.0-667e615528
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-webruntime",
3
- "version": "1.384.0",
3
+ "version": "1.386.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS engine for Webruntime runtime",
6
6
  "main": "dist/ldsWebruntimeOneStoreInit.js",
@@ -35,35 +35,35 @@
35
35
  "ready": "yarn build && jest --collectCoverage && yarn test:size && yarn release:corejar"
36
36
  },
37
37
  "devDependencies": {
38
- "@luvio/service-provisioner": "5.58.4",
39
- "@luvio/tools-core": "5.58.4",
38
+ "@luvio/service-provisioner": "5.59.0",
39
+ "@luvio/tools-core": "5.59.0",
40
40
  "jwt-encode": "1.0.1"
41
41
  },
42
42
  "dependencies": {
43
- "@luvio/command-aura-network": "5.58.4",
44
- "@luvio/command-aura-normalized-cache-control": "5.58.4",
45
- "@luvio/command-aura-resource-cache-control": "5.58.4",
46
- "@luvio/command-fetch-network": "5.58.4",
47
- "@luvio/command-http-normalized-cache-control": "5.58.4",
48
- "@luvio/command-ndjson": "5.58.4",
49
- "@luvio/command-network": "5.58.4",
50
- "@luvio/command-sse": "5.58.4",
51
- "@luvio/command-streaming": "5.58.4",
52
- "@luvio/jwt-manager": "5.58.4",
43
+ "@luvio/command-aura-network": "5.59.0",
44
+ "@luvio/command-aura-normalized-cache-control": "5.59.0",
45
+ "@luvio/command-aura-resource-cache-control": "5.59.0",
46
+ "@luvio/command-fetch-network": "5.59.0",
47
+ "@luvio/command-http-normalized-cache-control": "5.59.0",
48
+ "@luvio/command-ndjson": "5.59.0",
49
+ "@luvio/command-network": "5.59.0",
50
+ "@luvio/command-sse": "5.59.0",
51
+ "@luvio/command-streaming": "5.59.0",
52
+ "@luvio/jwt-manager": "5.59.0",
53
53
  "@luvio/network-adapter-composable": "0.158.7",
54
54
  "@luvio/network-adapter-fetch": "0.158.7",
55
- "@luvio/service-aura-network": "5.58.4",
56
- "@luvio/service-cache": "5.58.4",
57
- "@luvio/service-cache-control": "5.58.4",
58
- "@luvio/service-cache-inclusion-policy": "5.58.4",
59
- "@luvio/service-fetch-network": "5.58.4",
60
- "@luvio/service-instrument-command": "5.58.4",
61
- "@luvio/service-pubsub": "5.58.4",
62
- "@luvio/service-store": "5.58.4",
63
- "@luvio/utils": "5.58.4",
64
- "@salesforce/lds-adapters-uiapi-lex": "^1.384.0",
65
- "@salesforce/lds-luvio-service": "^1.384.0",
66
- "@salesforce/lds-luvio-uiapi-records-service": "^1.384.0"
55
+ "@luvio/service-aura-network": "5.59.0",
56
+ "@luvio/service-cache": "5.59.0",
57
+ "@luvio/service-cache-control": "5.59.0",
58
+ "@luvio/service-cache-inclusion-policy": "5.59.0",
59
+ "@luvio/service-fetch-network": "5.59.0",
60
+ "@luvio/service-instrument-command": "5.59.0",
61
+ "@luvio/service-pubsub": "5.59.0",
62
+ "@luvio/service-store": "5.59.0",
63
+ "@luvio/utils": "5.59.0",
64
+ "@salesforce/lds-adapters-uiapi-lex": "^1.386.0",
65
+ "@salesforce/lds-luvio-service": "^1.386.0",
66
+ "@salesforce/lds-luvio-uiapi-records-service": "^1.386.0"
67
67
  },
68
68
  "luvioBundlesize": [
69
69
  {