@salesforce/lds-runtime-bridge 1.227.0 → 1.227.2
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/main.js +55 -1
- package/package.json +1 -1
- package/sfdc/main.js +55 -1
package/dist/main.js
CHANGED
|
@@ -38,6 +38,8 @@ function isDeprecatedDurableStoreEntry(durableRecord) {
|
|
|
38
38
|
}
|
|
39
39
|
const DefaultDurableSegment = 'DEFAULT';
|
|
40
40
|
const RedirectDurableSegment = 'REDIRECT_KEYS';
|
|
41
|
+
const MessagingDurableSegment = 'MESSAGING';
|
|
42
|
+
const MessageNotifyStoreUpdateAvailable = 'notifyStoreUpdateAvailable';
|
|
41
43
|
|
|
42
44
|
const { keys: keys$2, create: create$2, assign: assign$2, freeze: freeze$1 } = Object;
|
|
43
45
|
|
|
@@ -476,6 +478,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
476
478
|
const defaultSegmentKeys = [];
|
|
477
479
|
const adapterContextSegmentKeys = [];
|
|
478
480
|
const redirectSegmentKeys = [];
|
|
481
|
+
const messagingSegmentKeys = [];
|
|
479
482
|
let shouldBroadcast = false;
|
|
480
483
|
for (let i = 0, len = changes.length; i < len; i++) {
|
|
481
484
|
const change = changes[i];
|
|
@@ -490,6 +493,9 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
490
493
|
else if (change.segment === RedirectDurableSegment) {
|
|
491
494
|
redirectSegmentKeys.push(...change.ids);
|
|
492
495
|
}
|
|
496
|
+
else if (change.segment === MessagingDurableSegment) {
|
|
497
|
+
messagingSegmentKeys.push(...change.ids);
|
|
498
|
+
}
|
|
493
499
|
}
|
|
494
500
|
if (redirectSegmentKeys.length > 0) {
|
|
495
501
|
const redirectEntries = await durableStore.getEntries(redirectSegmentKeys, RedirectDurableSegment);
|
|
@@ -549,6 +555,20 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
549
555
|
if (shouldBroadcast) {
|
|
550
556
|
await environment.storeBroadcast(rebuildSnapshot, environment.snapshotAvailable);
|
|
551
557
|
}
|
|
558
|
+
// if having notifyStoreUpdateAvailable msg, then pull the message body out from store
|
|
559
|
+
// and call environment.notifyStoreUpdateAvailable
|
|
560
|
+
if (messagingSegmentKeys.includes(MessageNotifyStoreUpdateAvailable)) {
|
|
561
|
+
const entries = await durableStore.getEntries([MessageNotifyStoreUpdateAvailable], MessagingDurableSegment);
|
|
562
|
+
if (entries !== undefined) {
|
|
563
|
+
const notifyEntry = entries[MessageNotifyStoreUpdateAvailable];
|
|
564
|
+
if (notifyEntry !== undefined) {
|
|
565
|
+
const keys = notifyEntry.data;
|
|
566
|
+
if (keys.length > 0) {
|
|
567
|
+
environment.notifyStoreUpdateAvailable(keys);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
552
572
|
});
|
|
553
573
|
const dispose = function () {
|
|
554
574
|
validateNotDisposed();
|
|
@@ -884,6 +904,39 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
884
904
|
return entries;
|
|
885
905
|
});
|
|
886
906
|
};
|
|
907
|
+
// flag entries specified by keys in durable store as expired.
|
|
908
|
+
// send a notifyStoreUpdateAvailable message through durable store set entries to
|
|
909
|
+
// indirectly triggers all js environments to refresh snapshots if overlapping with keys.
|
|
910
|
+
const notifyStoreUpdateAvailable = async function (keys$1) {
|
|
911
|
+
validateNotDisposed();
|
|
912
|
+
const entryKeys = keys$1.map(serializeStructuredKey);
|
|
913
|
+
const entries = await durableStore.getEntries(entryKeys, DefaultDurableSegment);
|
|
914
|
+
if (entries === undefined || keys$2(entries).length === 0) {
|
|
915
|
+
return environment.notifyStoreUpdateAvailable(keys$1);
|
|
916
|
+
}
|
|
917
|
+
const now = Date.now();
|
|
918
|
+
let needWriteBack = false;
|
|
919
|
+
for (let i = 0; i < entryKeys.length; i++) {
|
|
920
|
+
const key = entryKeys[i];
|
|
921
|
+
const entry = entries[key];
|
|
922
|
+
if (entry !== undefined) {
|
|
923
|
+
const storeEntry = entry;
|
|
924
|
+
if (storeEntry.metadata !== undefined) {
|
|
925
|
+
storeEntry.metadata = {
|
|
926
|
+
...storeEntry.metadata,
|
|
927
|
+
expirationTimestamp: now,
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
needWriteBack = true;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
if (needWriteBack) {
|
|
934
|
+
await durableStore.setEntries(entries, DefaultDurableSegment);
|
|
935
|
+
}
|
|
936
|
+
// push a notifyStoreUpdateAvailable message with entryKeys as data into messaging segment
|
|
937
|
+
await durableStore.setEntries({ notifyStoreUpdateAvailable: { data: entryKeys } }, MessagingDurableSegment);
|
|
938
|
+
return Promise.resolve(undefined);
|
|
939
|
+
};
|
|
887
940
|
// set the default cache policy of the base environment
|
|
888
941
|
environment.setDefaultCachePolicy({
|
|
889
942
|
type: 'stale-while-revalidate',
|
|
@@ -914,6 +967,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
914
967
|
handleSuccessResponse: { value: handleSuccessResponse },
|
|
915
968
|
handleErrorResponse: { value: handleErrorResponse },
|
|
916
969
|
getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
|
|
970
|
+
notifyStoreUpdateAvailable: { value: notifyStoreUpdateAvailable },
|
|
917
971
|
});
|
|
918
972
|
}
|
|
919
973
|
|
|
@@ -6513,4 +6567,4 @@ function ldsRuntimeBridge() {
|
|
|
6513
6567
|
}
|
|
6514
6568
|
|
|
6515
6569
|
export { ldsRuntimeBridge as default };
|
|
6516
|
-
// version: 1.227.
|
|
6570
|
+
// version: 1.227.2-daae2b505
|
package/package.json
CHANGED
package/sfdc/main.js
CHANGED
|
@@ -38,6 +38,8 @@ function isDeprecatedDurableStoreEntry(durableRecord) {
|
|
|
38
38
|
}
|
|
39
39
|
const DefaultDurableSegment = 'DEFAULT';
|
|
40
40
|
const RedirectDurableSegment = 'REDIRECT_KEYS';
|
|
41
|
+
const MessagingDurableSegment = 'MESSAGING';
|
|
42
|
+
const MessageNotifyStoreUpdateAvailable = 'notifyStoreUpdateAvailable';
|
|
41
43
|
|
|
42
44
|
const { keys: keys$2, create: create$2, assign: assign$2, freeze: freeze$1 } = Object;
|
|
43
45
|
|
|
@@ -476,6 +478,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
476
478
|
const defaultSegmentKeys = [];
|
|
477
479
|
const adapterContextSegmentKeys = [];
|
|
478
480
|
const redirectSegmentKeys = [];
|
|
481
|
+
const messagingSegmentKeys = [];
|
|
479
482
|
let shouldBroadcast = false;
|
|
480
483
|
for (let i = 0, len = changes.length; i < len; i++) {
|
|
481
484
|
const change = changes[i];
|
|
@@ -490,6 +493,9 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
490
493
|
else if (change.segment === RedirectDurableSegment) {
|
|
491
494
|
redirectSegmentKeys.push(...change.ids);
|
|
492
495
|
}
|
|
496
|
+
else if (change.segment === MessagingDurableSegment) {
|
|
497
|
+
messagingSegmentKeys.push(...change.ids);
|
|
498
|
+
}
|
|
493
499
|
}
|
|
494
500
|
if (redirectSegmentKeys.length > 0) {
|
|
495
501
|
const redirectEntries = await durableStore.getEntries(redirectSegmentKeys, RedirectDurableSegment);
|
|
@@ -549,6 +555,20 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
549
555
|
if (shouldBroadcast) {
|
|
550
556
|
await environment.storeBroadcast(rebuildSnapshot, environment.snapshotAvailable);
|
|
551
557
|
}
|
|
558
|
+
// if having notifyStoreUpdateAvailable msg, then pull the message body out from store
|
|
559
|
+
// and call environment.notifyStoreUpdateAvailable
|
|
560
|
+
if (messagingSegmentKeys.includes(MessageNotifyStoreUpdateAvailable)) {
|
|
561
|
+
const entries = await durableStore.getEntries([MessageNotifyStoreUpdateAvailable], MessagingDurableSegment);
|
|
562
|
+
if (entries !== undefined) {
|
|
563
|
+
const notifyEntry = entries[MessageNotifyStoreUpdateAvailable];
|
|
564
|
+
if (notifyEntry !== undefined) {
|
|
565
|
+
const keys = notifyEntry.data;
|
|
566
|
+
if (keys.length > 0) {
|
|
567
|
+
environment.notifyStoreUpdateAvailable(keys);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
552
572
|
});
|
|
553
573
|
const dispose = function () {
|
|
554
574
|
validateNotDisposed();
|
|
@@ -884,6 +904,39 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
884
904
|
return entries;
|
|
885
905
|
});
|
|
886
906
|
};
|
|
907
|
+
// flag entries specified by keys in durable store as expired.
|
|
908
|
+
// send a notifyStoreUpdateAvailable message through durable store set entries to
|
|
909
|
+
// indirectly triggers all js environments to refresh snapshots if overlapping with keys.
|
|
910
|
+
const notifyStoreUpdateAvailable = async function (keys$1) {
|
|
911
|
+
validateNotDisposed();
|
|
912
|
+
const entryKeys = keys$1.map(serializeStructuredKey);
|
|
913
|
+
const entries = await durableStore.getEntries(entryKeys, DefaultDurableSegment);
|
|
914
|
+
if (entries === undefined || keys$2(entries).length === 0) {
|
|
915
|
+
return environment.notifyStoreUpdateAvailable(keys$1);
|
|
916
|
+
}
|
|
917
|
+
const now = Date.now();
|
|
918
|
+
let needWriteBack = false;
|
|
919
|
+
for (let i = 0; i < entryKeys.length; i++) {
|
|
920
|
+
const key = entryKeys[i];
|
|
921
|
+
const entry = entries[key];
|
|
922
|
+
if (entry !== undefined) {
|
|
923
|
+
const storeEntry = entry;
|
|
924
|
+
if (storeEntry.metadata !== undefined) {
|
|
925
|
+
storeEntry.metadata = {
|
|
926
|
+
...storeEntry.metadata,
|
|
927
|
+
expirationTimestamp: now,
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
needWriteBack = true;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
if (needWriteBack) {
|
|
934
|
+
await durableStore.setEntries(entries, DefaultDurableSegment);
|
|
935
|
+
}
|
|
936
|
+
// push a notifyStoreUpdateAvailable message with entryKeys as data into messaging segment
|
|
937
|
+
await durableStore.setEntries({ notifyStoreUpdateAvailable: { data: entryKeys } }, MessagingDurableSegment);
|
|
938
|
+
return Promise.resolve(undefined);
|
|
939
|
+
};
|
|
887
940
|
// set the default cache policy of the base environment
|
|
888
941
|
environment.setDefaultCachePolicy({
|
|
889
942
|
type: 'stale-while-revalidate',
|
|
@@ -914,6 +967,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
914
967
|
handleSuccessResponse: { value: handleSuccessResponse },
|
|
915
968
|
handleErrorResponse: { value: handleErrorResponse },
|
|
916
969
|
getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
|
|
970
|
+
notifyStoreUpdateAvailable: { value: notifyStoreUpdateAvailable },
|
|
917
971
|
});
|
|
918
972
|
}
|
|
919
973
|
|
|
@@ -6513,4 +6567,4 @@ function ldsRuntimeBridge() {
|
|
|
6513
6567
|
}
|
|
6514
6568
|
|
|
6515
6569
|
export { ldsRuntimeBridge as default };
|
|
6516
|
-
// version: 1.227.
|
|
6570
|
+
// version: 1.227.2-daae2b505
|