@salesforce/lds-worker-api 1.252.0 → 1.256.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/sfdc/es/ldsWorkerApi.js +69 -35
- package/dist/sfdc/es/types/cachePurging.d.ts +8 -16
- package/dist/standalone/es/lds-worker-api.js +2864 -2807
- package/dist/standalone/es/types/cachePurging.d.ts +8 -16
- package/dist/standalone/umd/lds-worker-api.js +2864 -2807
- package/dist/standalone/umd/types/cachePurging.d.ts +8 -16
- package/package.json +14 -13
|
@@ -33,11 +33,13 @@ import * as unstableLightningRelatedListApi from 'lightning/unstable_uiRelatedLi
|
|
|
33
33
|
import * as lightningGraphQLApi from 'lightning/uiGraphQLApi';
|
|
34
34
|
import { createContentDocumentAndVersion, createContentVersion } from 'force/ldsAdaptersUiapi';
|
|
35
35
|
import * as gqlApi from 'force/ldsAdaptersGraphql';
|
|
36
|
-
import { getRuntime, reportGraphqlQueryParseError } from 'native/ldsRuntimeMobile';
|
|
36
|
+
import { getRuntime, reportGraphqlQueryParseError, O11Y_NAMESPACE_LDS_MOBILE } from 'native/ldsRuntimeMobile';
|
|
37
37
|
export { registerReportObserver } from 'native/ldsRuntimeMobile';
|
|
38
38
|
import { HttpStatusCode } from 'force/luvioEngine';
|
|
39
39
|
import { API_NAMESPACE, RECORD_REPRESENTATION_NAME, keyBuilderRecord } from 'force/ldsAdaptersUiapi';
|
|
40
40
|
import { withDefaultLuvio } from 'native/ldsEngineMobile';
|
|
41
|
+
import { getInstrumentation } from 'o11y/client';
|
|
42
|
+
import { evictCacheRecordsByIdsSchema, evictExpiredEntriesSchema } from 'o11y_schema/sf_lds';
|
|
41
43
|
|
|
42
44
|
const { create, keys } = Object;
|
|
43
45
|
const { stringify, parse } = JSON;
|
|
@@ -778,15 +780,7 @@ function removeEventHandler(session, handler) {
|
|
|
778
780
|
}
|
|
779
781
|
}
|
|
780
782
|
|
|
781
|
-
|
|
782
|
-
(function (EvictStatus) {
|
|
783
|
-
EvictStatus["Started"] = "Started";
|
|
784
|
-
EvictStatus["Running"] = "Running";
|
|
785
|
-
EvictStatus["Evicted"] = "Evicted";
|
|
786
|
-
EvictStatus["Succeeded"] = "Succeeded";
|
|
787
|
-
EvictStatus["Error"] = "Error";
|
|
788
|
-
EvictStatus["Canceled"] = "Canceled";
|
|
789
|
-
})(EvictStatus || (EvictStatus = {}));
|
|
783
|
+
const ldsMobileInstrumentation = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
|
|
790
784
|
const MessagingDurableSegmentName = 'MESSAGING';
|
|
791
785
|
const DEFAULT_MAX_ENTRIES_PER_OPERATION = 500;
|
|
792
786
|
const EVICTION_IN_PROGESS_MESSAGE = `Cache eviction in progress. Can't start another until it is finished or canceled.`;
|
|
@@ -809,18 +803,27 @@ function evictCacheRecordsByIds(recordIds, onProgressUpdate) {
|
|
|
809
803
|
// Send error back if an eviction is going on.
|
|
810
804
|
if (activeEvictionInProgress) {
|
|
811
805
|
return {
|
|
812
|
-
status:
|
|
806
|
+
status: 'Running',
|
|
813
807
|
message: EVICTION_IN_PROGESS_MESSAGE,
|
|
814
808
|
};
|
|
815
809
|
}
|
|
816
810
|
activeEvictionInProgress = true;
|
|
817
811
|
cancelCurrentEviction = false;
|
|
812
|
+
const o11yActivity = ldsMobileInstrumentation.startActivity('evictCacheRecordsByIds');
|
|
813
|
+
const stat = {
|
|
814
|
+
idCount: recordIds.length,
|
|
815
|
+
evictedCount: 0,
|
|
816
|
+
skippedCount: 0,
|
|
817
|
+
};
|
|
818
818
|
const evictAChunk = () => {
|
|
819
|
-
evictChunksOfRecord(recordIds).then(
|
|
819
|
+
evictChunksOfRecord(recordIds).then((progress) => {
|
|
820
|
+
handleInstrumentation(o11yActivity, stat, progress);
|
|
821
|
+
onEvicted(progress);
|
|
822
|
+
});
|
|
820
823
|
};
|
|
821
|
-
const onEvicted = getOnEvictedCallback(onProgressUpdate, evictAChunk);
|
|
824
|
+
const onEvicted = getOnEvictedCallback(o11yActivity, onProgressUpdate, evictAChunk, stat);
|
|
822
825
|
evictAChunk();
|
|
823
|
-
return { status:
|
|
826
|
+
return { status: 'Started' };
|
|
824
827
|
}
|
|
825
828
|
/**
|
|
826
829
|
* Purging the db entries which passed expired time by specified days
|
|
@@ -836,19 +839,28 @@ function evictExpiredCacheEntries(expiredByDays, onProgressUpdate) {
|
|
|
836
839
|
// Send error back if an eviction is going on.
|
|
837
840
|
if (activeEvictionInProgress) {
|
|
838
841
|
return {
|
|
839
|
-
status:
|
|
842
|
+
status: 'Running',
|
|
840
843
|
message: EVICTION_IN_PROGESS_MESSAGE,
|
|
841
844
|
};
|
|
842
845
|
}
|
|
843
846
|
activeEvictionInProgress = true;
|
|
844
847
|
cancelCurrentEviction = false;
|
|
848
|
+
const stat = {
|
|
849
|
+
expiredInDays: expiredByDays,
|
|
850
|
+
evictedCount: 0,
|
|
851
|
+
skippedCount: 0,
|
|
852
|
+
};
|
|
853
|
+
const o11yActivity = ldsMobileInstrumentation.startActivity('evictExpiredCacheEntries');
|
|
845
854
|
const overdueExpirationTimeStamp = Date.now() - expiredByDays * 24 * 3600 * 1000;
|
|
846
855
|
const evictAChunk = () => {
|
|
847
|
-
evictChunkOfOverdueEntries(overdueExpirationTimeStamp).then(
|
|
856
|
+
evictChunkOfOverdueEntries(overdueExpirationTimeStamp).then((progress) => {
|
|
857
|
+
handleInstrumentation(o11yActivity, stat, progress);
|
|
858
|
+
onEvicted(progress);
|
|
859
|
+
});
|
|
848
860
|
};
|
|
849
|
-
const onEvicted = getOnEvictedCallback(onProgressUpdate, evictAChunk);
|
|
861
|
+
const onEvicted = getOnEvictedCallback(o11yActivity, onProgressUpdate, evictAChunk, stat);
|
|
850
862
|
evictAChunk();
|
|
851
|
-
return { status:
|
|
863
|
+
return { status: 'Started' };
|
|
852
864
|
}
|
|
853
865
|
/**
|
|
854
866
|
* Signal to stop current eviction if there's an active eviction going on.
|
|
@@ -864,17 +876,19 @@ function stopEviction() {
|
|
|
864
876
|
* @param evictAChunk
|
|
865
877
|
* @returns a callback to call when a chunk of records or entries are removed.
|
|
866
878
|
*/
|
|
867
|
-
function getOnEvictedCallback(onProgressUpdate, evictAChunk) {
|
|
879
|
+
function getOnEvictedCallback(o11yActivity, onProgressUpdate, evictAChunk, stat) {
|
|
868
880
|
return (progress) => {
|
|
869
881
|
onProgressUpdate(progress);
|
|
870
882
|
const { status } = progress;
|
|
871
|
-
if (status ===
|
|
883
|
+
if (status === 'Succeeded' || status === 'Error') {
|
|
872
884
|
activeEvictionInProgress = false;
|
|
873
885
|
}
|
|
874
|
-
if (status ===
|
|
886
|
+
if (status === 'Evicted') {
|
|
875
887
|
if (cancelCurrentEviction) {
|
|
876
888
|
activeEvictionInProgress = false;
|
|
877
|
-
|
|
889
|
+
const canceledProgress = { status: 'Canceled' };
|
|
890
|
+
onProgressUpdate(canceledProgress);
|
|
891
|
+
handleInstrumentation(o11yActivity, stat, canceledProgress);
|
|
878
892
|
}
|
|
879
893
|
else {
|
|
880
894
|
evictAChunk();
|
|
@@ -890,7 +904,7 @@ function getOnEvictedCallback(onProgressUpdate, evictAChunk) {
|
|
|
890
904
|
function evictChunksOfRecord(ids) {
|
|
891
905
|
const chunk = ids.splice(0, DEFAULT_MAX_ENTRIES_PER_OPERATION);
|
|
892
906
|
if (chunk.length === 0) {
|
|
893
|
-
return Promise.resolve({ status:
|
|
907
|
+
return Promise.resolve({ status: 'Succeeded' });
|
|
894
908
|
}
|
|
895
909
|
return new Promise((resolve) => {
|
|
896
910
|
// evict the chunk
|
|
@@ -911,22 +925,22 @@ function evictChunksOfRecord(ids) {
|
|
|
911
925
|
nimbusSqliteStore.setEntries({ notifyStoreUpdateAvailable: { data: evictedEntries } }, MessagingDurableSegmentName);
|
|
912
926
|
}
|
|
913
927
|
resolve({
|
|
914
|
-
status:
|
|
928
|
+
status: 'Evicted',
|
|
915
929
|
evictedEntries,
|
|
916
930
|
skippedEntries,
|
|
917
931
|
});
|
|
918
932
|
})
|
|
919
933
|
.catch((reason) => {
|
|
920
934
|
resolve({
|
|
921
|
-
status:
|
|
922
|
-
message:
|
|
935
|
+
status: 'Error',
|
|
936
|
+
message: reason.toString(),
|
|
923
937
|
});
|
|
924
938
|
});
|
|
925
939
|
}
|
|
926
940
|
catch (reason) {
|
|
927
941
|
resolve({
|
|
928
|
-
status:
|
|
929
|
-
message:
|
|
942
|
+
status: 'Error',
|
|
943
|
+
message: reason.toString(),
|
|
930
944
|
});
|
|
931
945
|
}
|
|
932
946
|
});
|
|
@@ -965,30 +979,50 @@ function evictChunkOfOverdueEntries(overdueExpirationTimestamp) {
|
|
|
965
979
|
// broadcast entries evicted
|
|
966
980
|
nimbusSqliteStore.setEntries({ notifyStoreUpdateAvailable: { data: evictedEntries } }, MessagingDurableSegmentName);
|
|
967
981
|
resolve({
|
|
968
|
-
status:
|
|
982
|
+
status: 'Evicted',
|
|
969
983
|
evictedEntries,
|
|
970
984
|
skippedEntries: [],
|
|
971
985
|
});
|
|
972
986
|
}
|
|
973
987
|
else {
|
|
974
|
-
resolve({ status:
|
|
988
|
+
resolve({ status: 'Succeeded' });
|
|
975
989
|
}
|
|
976
990
|
})
|
|
977
991
|
.catch((reason) => {
|
|
978
992
|
resolve({
|
|
979
|
-
status:
|
|
980
|
-
message:
|
|
993
|
+
status: 'Error',
|
|
994
|
+
message: reason.toString(),
|
|
981
995
|
});
|
|
982
996
|
});
|
|
983
997
|
}
|
|
984
998
|
catch (reason) {
|
|
985
999
|
resolve({
|
|
986
|
-
status:
|
|
987
|
-
message:
|
|
1000
|
+
status: 'Error',
|
|
1001
|
+
message: reason.toString(),
|
|
988
1002
|
});
|
|
989
1003
|
}
|
|
990
1004
|
});
|
|
991
1005
|
}
|
|
1006
|
+
function handleInstrumentation(activity, stat, progress) {
|
|
1007
|
+
const status = progress.status;
|
|
1008
|
+
if (status === 'Evicted') {
|
|
1009
|
+
const evicted = progress;
|
|
1010
|
+
stat.evictedCount += evicted.evictedEntries.length;
|
|
1011
|
+
stat.skippedCount += evicted.skippedEntries.length;
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
const schema = 'idCount' in stat ? evictCacheRecordsByIdsSchema : evictExpiredEntriesSchema;
|
|
1015
|
+
const userData = {
|
|
1016
|
+
...stat,
|
|
1017
|
+
isCanceled: status === 'Canceled',
|
|
1018
|
+
};
|
|
1019
|
+
if (status === 'Error') {
|
|
1020
|
+
activity.error(progress.message, schema, userData);
|
|
1021
|
+
}
|
|
1022
|
+
else if (status === 'Succeeded' || status === 'Canceled') {
|
|
1023
|
+
activity.stop(schema, userData);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
992
1026
|
|
|
993
1027
|
if (process.env.NODE_ENV !== 'production') {
|
|
994
1028
|
// eslint-disable-next-line no-undef
|
|
@@ -1000,4 +1034,4 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1000
1034
|
}
|
|
1001
1035
|
|
|
1002
1036
|
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
1003
|
-
// version: 1.
|
|
1037
|
+
// version: 1.256.0-ad6a66c18
|
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
declare enum EvictStatus {
|
|
2
|
-
Started = "Started",
|
|
3
|
-
Running = "Running",
|
|
4
|
-
Evicted = "Evicted",
|
|
5
|
-
Succeeded = "Succeeded",
|
|
6
|
-
Error = "Error",
|
|
7
|
-
Canceled = "Canceled"
|
|
8
|
-
}
|
|
9
1
|
interface EvictStarted {
|
|
10
|
-
status:
|
|
2
|
+
status: 'Started';
|
|
11
3
|
}
|
|
12
4
|
interface EvictRunning {
|
|
13
|
-
status:
|
|
5
|
+
status: 'Running';
|
|
14
6
|
message: string;
|
|
15
7
|
}
|
|
16
8
|
interface BatchEvicted {
|
|
17
|
-
status:
|
|
18
|
-
skippedEntries
|
|
19
|
-
evictedEntries
|
|
9
|
+
status: 'Evicted';
|
|
10
|
+
skippedEntries: string[];
|
|
11
|
+
evictedEntries: string[];
|
|
20
12
|
}
|
|
21
13
|
interface EvictSucceeded {
|
|
22
|
-
status:
|
|
14
|
+
status: 'Succeeded';
|
|
23
15
|
}
|
|
24
16
|
interface EvictError {
|
|
25
|
-
status:
|
|
17
|
+
status: 'Error';
|
|
26
18
|
message: string;
|
|
27
19
|
}
|
|
28
20
|
interface EvictCancelled {
|
|
29
|
-
status:
|
|
21
|
+
status: 'Canceled';
|
|
30
22
|
}
|
|
31
23
|
export type EvictProgress = BatchEvicted | EvictSucceeded | EvictError | EvictCancelled;
|
|
32
24
|
export type ProgressUpdateCallback = (progess: EvictProgress) => void;
|