@salesforce/lds-worker-api 1.248.0 → 1.249.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.
@@ -778,142 +778,6 @@ function removeEventHandler(session, handler) {
778
778
  }
779
779
  }
780
780
 
781
- /**
782
- * Copyright (c) 2022, Salesforce, Inc.,
783
- * All rights reserved.
784
- * For full license text, see the LICENSE.txt file
785
- */
786
-
787
-
788
- var DraftActionStatus;
789
- (function (DraftActionStatus) {
790
- DraftActionStatus["Pending"] = "pending";
791
- DraftActionStatus["Uploading"] = "uploading";
792
- DraftActionStatus["Error"] = "error";
793
- DraftActionStatus["Completed"] = "completed";
794
- })(DraftActionStatus || (DraftActionStatus = {}));
795
- var ProcessActionResult;
796
- (function (ProcessActionResult) {
797
- // non-2xx network error, requires user intervention
798
- ProcessActionResult["ACTION_ERRORED"] = "ERROR";
799
- // upload succeeded
800
- ProcessActionResult["ACTION_SUCCEEDED"] = "SUCCESS";
801
- // queue is empty
802
- ProcessActionResult["NO_ACTION_TO_PROCESS"] = "NO_ACTION_TO_PROCESS";
803
- // network request is in flight
804
- ProcessActionResult["ACTION_ALREADY_PROCESSING"] = "ACTION_ALREADY_PROCESSING";
805
- // network call failed (offline)
806
- ProcessActionResult["NETWORK_ERROR"] = "NETWORK_ERROR";
807
- // queue is blocked on an error that requires user intervention
808
- ProcessActionResult["BLOCKED_ON_ERROR"] = "BLOCKED_ON_ERROR";
809
- //waiting for user to execute custom action
810
- ProcessActionResult["CUSTOM_ACTION_WAITING"] = "CUSTOM_ACTION_WAITING";
811
- })(ProcessActionResult || (ProcessActionResult = {}));
812
- var DraftQueueState;
813
- (function (DraftQueueState) {
814
- /** Currently processing an item in the queue or queue is empty and waiting to process the next item. */
815
- DraftQueueState["Started"] = "started";
816
- /**
817
- * The queue is stopped and will not attempt to upload any drafts until startDraftQueue() is called.
818
- * This is the initial state when the DraftQueue gets instantiated.
819
- */
820
- DraftQueueState["Stopped"] = "stopped";
821
- /**
822
- * The queue is stopped due to a blocking error from the last upload attempt.
823
- * The queue will not run again until startDraftQueue() is called.
824
- */
825
- DraftQueueState["Error"] = "error";
826
- /**
827
- * There was a network error and the queue will attempt to upload again shortly.
828
- * To attempt to force an upload now call startDraftQueue().
829
- */
830
- DraftQueueState["Waiting"] = "waiting";
831
- })(DraftQueueState || (DraftQueueState = {}));
832
- var DraftQueueEventType;
833
- (function (DraftQueueEventType) {
834
- /**
835
- * Triggered after an action had been added to the queue
836
- */
837
- DraftQueueEventType["ActionAdded"] = "added";
838
- /**
839
- * Triggered when starting to upload and process an action
840
- */
841
- DraftQueueEventType["ActionUploading"] = "uploading";
842
- /**
843
- * Triggered once an action failed
844
- */
845
- DraftQueueEventType["ActionFailed"] = "failed";
846
- /**
847
- * Triggered after an action has been deleted from the queue
848
- */
849
- DraftQueueEventType["ActionDeleted"] = "deleted";
850
- /**
851
- * Triggered after an action has been completed and after it has been removed from the queue
852
- */
853
- DraftQueueEventType["ActionCompleted"] = "completed";
854
- /**
855
- * Triggered after an action has been updated by the updateAction API
856
- */
857
- DraftQueueEventType["ActionUpdated"] = "updated";
858
- /**
859
- * Triggered after the Draft Queue state changes
860
- */
861
- DraftQueueEventType["QueueStateChanged"] = "state";
862
- })(DraftQueueEventType || (DraftQueueEventType = {}));
863
- var QueueOperationType;
864
- (function (QueueOperationType) {
865
- QueueOperationType["Add"] = "add";
866
- QueueOperationType["Delete"] = "delete";
867
- QueueOperationType["Update"] = "update";
868
- })(QueueOperationType || (QueueOperationType = {}));
869
- /**
870
- Use Math.random to generate v4 RFC4122 compliant uuid
871
- */
872
- function uuidv4() {
873
- const uuid = [];
874
- for (let i = 0; i < 32; i++) {
875
- const random = (Math.random() * 16) | 0;
876
- if (i === 8 || i === 12 || i === 16 || i === 20) {
877
- uuid.push('-');
878
- }
879
- uuid.push((i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16));
880
- }
881
- return uuid.join('');
882
- }
883
-
884
- var CustomActionResultType;
885
- (function (CustomActionResultType) {
886
- CustomActionResultType["SUCCESS"] = "SUCCESS";
887
- CustomActionResultType["FAILURE"] = "FAILURE";
888
- })(CustomActionResultType || (CustomActionResultType = {}));
889
- var CustomActionErrorType;
890
- (function (CustomActionErrorType) {
891
- CustomActionErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";
892
- CustomActionErrorType["CLIENT_ERROR"] = "CLIENT_ERROR";
893
- })(CustomActionErrorType || (CustomActionErrorType = {}));
894
-
895
- /**
896
- * Denotes what kind of operation a DraftQueueItem represents.
897
- */
898
- var DraftActionOperationType;
899
- (function (DraftActionOperationType) {
900
- DraftActionOperationType["Create"] = "create";
901
- DraftActionOperationType["Update"] = "update";
902
- DraftActionOperationType["Delete"] = "delete";
903
- DraftActionOperationType["Custom"] = "custom";
904
- })(DraftActionOperationType || (DraftActionOperationType = {}));
905
- var DraftQueueOperationType;
906
- (function (DraftQueueOperationType) {
907
- DraftQueueOperationType["ItemAdded"] = "added";
908
- DraftQueueOperationType["ItemUploading"] = "uploading";
909
- DraftQueueOperationType["ItemDeleted"] = "deleted";
910
- DraftQueueOperationType["ItemCompleted"] = "completed";
911
- DraftQueueOperationType["ItemFailed"] = "failed";
912
- DraftQueueOperationType["ItemUpdated"] = "updated";
913
- DraftQueueOperationType["QueueStarted"] = "started";
914
- DraftQueueOperationType["QueueStopped"] = "stopped";
915
- })(DraftQueueOperationType || (DraftQueueOperationType = {}));
916
-
917
781
  var EvictStatus;
918
782
  (function (EvictStatus) {
919
783
  EvictStatus["Started"] = "Started";
@@ -930,7 +794,7 @@ const EVICTION_IN_PROGESS_MESSAGE = `Cache eviction in progress. Can't start ano
930
794
  * Only one eviction is allowed at a time. running status is return when evictCacheRecordsByIds or
931
795
  * evictExpiredCacheEntries is called if there's already an eviction in progress.
932
796
  */
933
- var currentEvictionId = '';
797
+ var activeEvictionInProgress = false;
934
798
  var cancelCurrentEviction = false;
935
799
  /**
936
800
  * Purging records specified by an array of record id from durable store
@@ -943,13 +807,13 @@ var cancelCurrentEviction = false;
943
807
  */
944
808
  function evictCacheRecordsByIds(recordIds, onProgressUpdate) {
945
809
  // Send error back if an eviction is going on.
946
- if (currentEvictionId) {
810
+ if (activeEvictionInProgress) {
947
811
  return {
948
812
  status: EvictStatus.Running,
949
813
  message: EVICTION_IN_PROGESS_MESSAGE,
950
814
  };
951
815
  }
952
- currentEvictionId = uuidv4();
816
+ activeEvictionInProgress = true;
953
817
  cancelCurrentEviction = false;
954
818
  const evictAChunk = () => {
955
819
  evictChunksOfRecord(recordIds).then(onEvicted);
@@ -970,13 +834,13 @@ function evictCacheRecordsByIds(recordIds, onProgressUpdate) {
970
834
  */
971
835
  function evictExpiredCacheEntries(expiredByDays, onProgressUpdate) {
972
836
  // Send error back if an eviction is going on.
973
- if (currentEvictionId) {
837
+ if (activeEvictionInProgress) {
974
838
  return {
975
839
  status: EvictStatus.Running,
976
840
  message: EVICTION_IN_PROGESS_MESSAGE,
977
841
  };
978
842
  }
979
- currentEvictionId = uuidv4();
843
+ activeEvictionInProgress = true;
980
844
  cancelCurrentEviction = false;
981
845
  const overdueExpirationTimeStamp = Date.now() - expiredByDays * 24 * 3600 * 1000;
982
846
  const evictAChunk = () => {
@@ -990,7 +854,7 @@ function evictExpiredCacheEntries(expiredByDays, onProgressUpdate) {
990
854
  * Signal to stop current eviction if there's an active eviction going on.
991
855
  */
992
856
  function stopEviction() {
993
- if (currentEvictionId) {
857
+ if (activeEvictionInProgress) {
994
858
  cancelCurrentEviction = true;
995
859
  }
996
860
  }
@@ -1005,11 +869,11 @@ function getOnEvictedCallback(onProgressUpdate, evictAChunk) {
1005
869
  onProgressUpdate(progress);
1006
870
  const { status } = progress;
1007
871
  if (status === EvictStatus.Succeeded || status === EvictStatus.Error) {
1008
- currentEvictionId = '';
872
+ activeEvictionInProgress = false;
1009
873
  }
1010
874
  if (status === EvictStatus.Evicted) {
1011
875
  if (cancelCurrentEviction) {
1012
- currentEvictionId = '';
876
+ activeEvictionInProgress = false;
1013
877
  onProgressUpdate({ status: EvictStatus.Canceled });
1014
878
  }
1015
879
  else {
@@ -1085,7 +949,8 @@ function evictChunkOfOverdueEntries(overdueExpirationTimestamp) {
1085
949
  WHERE key NOT LIKE 'UiApi::ObjectInfoRepresentation:%'
1086
950
  AND
1087
951
  (
1088
- key NOT LIKE 'UiApi::RecordRepresentation:%'
952
+ key NOT LIKE 'UiApi::RecordRepresentation:%' AND
953
+ JSON_EXTRACT(metadata, '$.expirationTimestamp') < ${overdueExpirationTimestamp}
1089
954
  OR
1090
955
  key LIKE 'UiApi::RecordRepresentation:%' AND
1091
956
  JSON_EXTRACT(data, '$.drafts') IS NULL AND
@@ -1135,4 +1000,4 @@ if (process.env.NODE_ENV !== 'production') {
1135
1000
  }
1136
1001
 
1137
1002
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
1138
- // version: 1.248.0-1f7f01112
1003
+ // version: 1.249.0-11c3e1ed5