@salesforce/lds-runtime-webruntime 1.368.0 → 1.370.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.
- package/dist/ldsWebruntimeOneStoreInit.js +76 -49
- package/package.json +25 -25
|
@@ -483,6 +483,38 @@ function setOverlaps(setA, setB) {
|
|
|
483
483
|
}
|
|
484
484
|
return false;
|
|
485
485
|
}
|
|
486
|
+
class CacheControlRequestRunner {
|
|
487
|
+
constructor(readFromCache, requestFromNetwork, writeToCache) {
|
|
488
|
+
this.readFromCacheInternal = readFromCache;
|
|
489
|
+
this.requestFromNetworkInternal = requestFromNetwork;
|
|
490
|
+
this.writeToCacheInternal = writeToCache;
|
|
491
|
+
}
|
|
492
|
+
readFromCache(cache) {
|
|
493
|
+
const resultPromise = this.readFromCacheInternal(cache);
|
|
494
|
+
return resultPromise.then((result) => {
|
|
495
|
+
if (result.isErr()) {
|
|
496
|
+
return err(result.error);
|
|
497
|
+
}
|
|
498
|
+
this.returnData = result;
|
|
499
|
+
return ok$1(void 0);
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
requestFromNetwork() {
|
|
503
|
+
const that = this;
|
|
504
|
+
return async function* () {
|
|
505
|
+
const result = await that.requestFromNetworkInternal();
|
|
506
|
+
if (result.isErr()) {
|
|
507
|
+
that.networkError = result;
|
|
508
|
+
} else {
|
|
509
|
+
that.networkData = result;
|
|
510
|
+
}
|
|
511
|
+
yield result;
|
|
512
|
+
}();
|
|
513
|
+
}
|
|
514
|
+
writeToCache(cache, networkResult) {
|
|
515
|
+
return this.writeToCacheInternal(cache, networkResult);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
486
518
|
class CacheControlCommand extends BaseCommand {
|
|
487
519
|
constructor(services) {
|
|
488
520
|
super();
|
|
@@ -502,57 +534,48 @@ class CacheControlCommand extends BaseCommand {
|
|
|
502
534
|
this.cacheControlStrategyConfig,
|
|
503
535
|
overrides
|
|
504
536
|
);
|
|
505
|
-
|
|
506
|
-
let returnError;
|
|
507
|
-
const requestRunner = {
|
|
508
|
-
readFromCache: (cache) => {
|
|
509
|
-
const resultPromise2 = this.buildResultWithSubscribe(cache);
|
|
510
|
-
return resultPromise2.then((result) => {
|
|
511
|
-
if (result.isErr()) {
|
|
512
|
-
return err(result.error);
|
|
513
|
-
}
|
|
514
|
-
returnData = result;
|
|
515
|
-
return ok$1(void 0);
|
|
516
|
-
});
|
|
517
|
-
},
|
|
518
|
-
requestFromNetwork: () => {
|
|
519
|
-
const that = this;
|
|
520
|
-
return async function* () {
|
|
521
|
-
const result = await that.requestFromNetwork();
|
|
522
|
-
if (result.isErr()) {
|
|
523
|
-
returnError = result;
|
|
524
|
-
}
|
|
525
|
-
yield result;
|
|
526
|
-
}();
|
|
527
|
-
},
|
|
528
|
-
writeToCache: (cache, networkResult) => {
|
|
529
|
-
return this.writeToCacheAndRecordKeys(cache, networkResult);
|
|
530
|
-
}
|
|
531
|
-
};
|
|
537
|
+
const requestRunner = this.buildRequestRunner();
|
|
532
538
|
const resultPromise = this.services.cacheController.execute(mergedCacheControlConfig, requestRunner, {
|
|
533
539
|
instrumentationAttributes: this.instrumentationAttributes
|
|
534
540
|
});
|
|
535
541
|
return resultPromise.then((result) => {
|
|
536
|
-
return this.
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
if (
|
|
547
|
-
return
|
|
542
|
+
return this.handleCacheControllerResult(result, requestRunner);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
handleCacheControllerResult(result, requestRunner) {
|
|
546
|
+
const { networkError, networkData, returnData } = requestRunner;
|
|
547
|
+
return this.publishUpdatedKeys().then(() => {
|
|
548
|
+
if (networkError) {
|
|
549
|
+
return networkError;
|
|
550
|
+
}
|
|
551
|
+
if (result.isErr()) {
|
|
552
|
+
if (networkData) {
|
|
553
|
+
return this.constructSubscribableResult(networkData.value);
|
|
548
554
|
}
|
|
549
|
-
|
|
550
|
-
|
|
555
|
+
return err(result.error);
|
|
556
|
+
}
|
|
557
|
+
if (this.subscriptions.length > 0) {
|
|
558
|
+
this.subscribeToKeysUsed();
|
|
559
|
+
}
|
|
560
|
+
if (returnData === void 0) {
|
|
561
|
+
if (networkData) {
|
|
562
|
+
return this.constructSubscribableResult(networkData.value);
|
|
551
563
|
}
|
|
552
|
-
return
|
|
553
|
-
}
|
|
564
|
+
return err(new Error("Cache miss after fetching from network"));
|
|
565
|
+
}
|
|
566
|
+
if (returnData.isOk() && this.lastEmittedData === void 0) {
|
|
567
|
+
this.lastEmittedData = returnData.value.data;
|
|
568
|
+
}
|
|
569
|
+
return returnData;
|
|
554
570
|
});
|
|
555
571
|
}
|
|
572
|
+
buildRequestRunner() {
|
|
573
|
+
return new CacheControlRequestRunner(
|
|
574
|
+
(cache) => this.buildResultWithSubscribe(cache),
|
|
575
|
+
() => this.requestFromNetwork(),
|
|
576
|
+
(cache, networkResult) => this.writeToCacheAndRecordKeys(cache, networkResult)
|
|
577
|
+
);
|
|
578
|
+
}
|
|
556
579
|
publishUpdatedKeys() {
|
|
557
580
|
if (this.services.pubSub) {
|
|
558
581
|
if (this.keysUpdated !== void 0 && this.keysUpdated.size > 0) {
|
|
@@ -623,14 +646,18 @@ class CacheControlCommand extends BaseCommand {
|
|
|
623
646
|
} else {
|
|
624
647
|
const data = readResult.value;
|
|
625
648
|
this.keysUsed = recordableCache.keysRead;
|
|
626
|
-
return
|
|
627
|
-
data,
|
|
628
|
-
subscribe: this.buildSubscribe(),
|
|
629
|
-
refresh: () => this.refresh()
|
|
630
|
-
});
|
|
649
|
+
return this.constructSubscribableResult(data);
|
|
631
650
|
}
|
|
632
651
|
});
|
|
633
652
|
}
|
|
653
|
+
constructSubscribableResult(data) {
|
|
654
|
+
return ok$1({
|
|
655
|
+
data,
|
|
656
|
+
// this cast is in case we need to return Network data as a fallback for caching errors
|
|
657
|
+
subscribe: this.buildSubscribe(),
|
|
658
|
+
refresh: () => this.refresh()
|
|
659
|
+
});
|
|
660
|
+
}
|
|
634
661
|
/**
|
|
635
662
|
* Builds a function that subscribes to cache changes via the pubsub service. Whenever
|
|
636
663
|
* relevant cache updates occur, it re-reads the data and compares it against
|
|
@@ -2911,4 +2938,4 @@ const services = [
|
|
|
2911
2938
|
buildServiceDescriptor$2(),
|
|
2912
2939
|
];
|
|
2913
2940
|
setServices(services);
|
|
2914
|
-
// version: 1.
|
|
2941
|
+
// version: 1.370.0-3ec6ffba72
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-runtime-webruntime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.370.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "LDS engine for Webruntime runtime",
|
|
6
6
|
"main": "dist/ldsWebruntimeOneStoreInit.js",
|
|
@@ -35,33 +35,33 @@
|
|
|
35
35
|
"ready": "yarn build && jest --collectCoverage && yarn test:size && yarn release:corejar"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@luvio/service-provisioner": "5.
|
|
39
|
-
"@luvio/tools-core": "5.
|
|
38
|
+
"@luvio/service-provisioner": "5.44.0",
|
|
39
|
+
"@luvio/tools-core": "5.44.0",
|
|
40
40
|
"jwt-encode": "1.0.1"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@luvio/command-aura-network": "5.
|
|
44
|
-
"@luvio/command-aura-normalized-cache-control": "5.
|
|
45
|
-
"@luvio/command-aura-resource-cache-control": "5.
|
|
46
|
-
"@luvio/command-fetch-network": "5.
|
|
47
|
-
"@luvio/command-http-normalized-cache-control": "5.
|
|
48
|
-
"@luvio/command-ndjson": "5.
|
|
49
|
-
"@luvio/command-network": "5.
|
|
50
|
-
"@luvio/command-sse": "5.
|
|
51
|
-
"@luvio/command-streaming": "5.
|
|
52
|
-
"@luvio/jwt-manager": "5.
|
|
53
|
-
"@luvio/network-adapter-composable": "0.158.
|
|
54
|
-
"@luvio/network-adapter-fetch": "0.158.
|
|
55
|
-
"@luvio/service-aura-network": "5.
|
|
56
|
-
"@luvio/service-cache": "5.
|
|
57
|
-
"@luvio/service-cache-control": "5.
|
|
58
|
-
"@luvio/service-cache-inclusion-policy": "5.
|
|
59
|
-
"@luvio/service-fetch-network": "5.
|
|
60
|
-
"@luvio/service-instrument-command": "5.
|
|
61
|
-
"@luvio/service-pubsub": "5.
|
|
62
|
-
"@luvio/service-store": "5.
|
|
63
|
-
"@luvio/utils": "5.
|
|
64
|
-
"@salesforce/lds-adapters-uiapi-lex": "^1.
|
|
43
|
+
"@luvio/command-aura-network": "5.44.0",
|
|
44
|
+
"@luvio/command-aura-normalized-cache-control": "5.44.0",
|
|
45
|
+
"@luvio/command-aura-resource-cache-control": "5.44.0",
|
|
46
|
+
"@luvio/command-fetch-network": "5.44.0",
|
|
47
|
+
"@luvio/command-http-normalized-cache-control": "5.44.0",
|
|
48
|
+
"@luvio/command-ndjson": "5.44.0",
|
|
49
|
+
"@luvio/command-network": "5.44.0",
|
|
50
|
+
"@luvio/command-sse": "5.44.0",
|
|
51
|
+
"@luvio/command-streaming": "5.44.0",
|
|
52
|
+
"@luvio/jwt-manager": "5.44.0",
|
|
53
|
+
"@luvio/network-adapter-composable": "0.158.7",
|
|
54
|
+
"@luvio/network-adapter-fetch": "0.158.7",
|
|
55
|
+
"@luvio/service-aura-network": "5.44.0",
|
|
56
|
+
"@luvio/service-cache": "5.44.0",
|
|
57
|
+
"@luvio/service-cache-control": "5.44.0",
|
|
58
|
+
"@luvio/service-cache-inclusion-policy": "5.44.0",
|
|
59
|
+
"@luvio/service-fetch-network": "5.44.0",
|
|
60
|
+
"@luvio/service-instrument-command": "5.44.0",
|
|
61
|
+
"@luvio/service-pubsub": "5.44.0",
|
|
62
|
+
"@luvio/service-store": "5.44.0",
|
|
63
|
+
"@luvio/utils": "5.44.0",
|
|
64
|
+
"@salesforce/lds-adapters-uiapi-lex": "^1.370.0"
|
|
65
65
|
},
|
|
66
66
|
"luvioBundlesize": [
|
|
67
67
|
{
|