@salesforce/lds-drafts 1.304.0 → 1.305.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/ldsDrafts.js CHANGED
@@ -793,6 +793,29 @@ class DurableDraftQueue {
793
793
  mergeActions(targetActionId, sourceActionId) {
794
794
  return this.replaceOrMergeActions(targetActionId, sourceActionId, true);
795
795
  }
796
+ async retryAction(actionId) {
797
+ this.stopQueueManually();
798
+ const actions = await this.getQueueActions();
799
+ const target = actions[0];
800
+ if (!target || target.id !== actionId) {
801
+ throw Error(`Action ${actionId} not found at the head of the draft queue`);
802
+ }
803
+ if (!isDraftError(target)) {
804
+ throw Error(`Action ${actionId} is not in Error state`);
805
+ }
806
+ let pendingAction = {
807
+ ...target,
808
+ status: DraftActionStatus.Pending,
809
+ error: undefined,
810
+ };
811
+ await this.draftStore.writeAction(pendingAction);
812
+ await this.notifyChangedListeners({
813
+ type: DraftQueueEventType.ActionUpdated,
814
+ action: pendingAction,
815
+ });
816
+ await this.startQueueSafe();
817
+ return pendingAction;
818
+ }
796
819
  async setMetadata(actionId, metadata) {
797
820
  const keys$1 = keys(metadata);
798
821
  const compatibleKeys = keys$1.filter((key) => {
@@ -1939,6 +1962,18 @@ class DraftManager {
1939
1962
  return this.buildDraftQueueItem(updatedAction);
1940
1963
  });
1941
1964
  }
1965
+ /**
1966
+ * Retries a draft action that is in error state without any modification.
1967
+ *
1968
+ * @param actionId The id of the draft action that should be retried
1969
+ * @throws If the draft action is not at the front of the draft queue or is not
1970
+ * in error state.
1971
+ */
1972
+ async retryAction(actionId) {
1973
+ return this.draftQueue.retryAction(actionId).then((updatedAction) => {
1974
+ return this.buildDraftQueueItem(updatedAction);
1975
+ });
1976
+ }
1942
1977
  }
1943
1978
 
1944
1979
  function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueue) {
@@ -171,4 +171,12 @@ export declare class DraftManager {
171
171
  * @param metadata The metadata to set on the specified action
172
172
  */
173
173
  setMetadata(actionId: string, metadata: DraftQueueItemMetadata): Promise<DraftQueueItem>;
174
+ /**
175
+ * Retries a draft action that is in error state without any modification.
176
+ *
177
+ * @param actionId The id of the draft action that should be retried
178
+ * @throws If the draft action is not at the front of the draft queue or is not
179
+ * in error state.
180
+ */
181
+ retryAction(actionId: string): Promise<DraftQueueItem>;
174
182
  }
@@ -235,6 +235,14 @@ export interface DraftQueue {
235
235
  * action will be removed after the merge.
236
236
  */
237
237
  mergeActions<Data, Response>(targetActionId: string, sourceActionId: string): Promise<DraftAction<Data, Response>>;
238
+ /**
239
+ * Retries a draft action that is in error state without any modification.
240
+ *
241
+ * @param actionId The id of the draft action that should be retried
242
+ * @throws If the draft action is not at the front of the draft queue or is not
243
+ * in error state.
244
+ */
245
+ retryAction<Data, Response>(actionId: string): Promise<DraftAction<Data, Response>>;
238
246
  /** Set the draft queue state to Started and process the next item */
239
247
  startQueue(): Promise<void>;
240
248
  /** Set the draft queue state to Stopped and don't let another item begin */
@@ -49,6 +49,7 @@ export declare class DurableDraftQueue implements DraftQueue {
49
49
  private statusOfAction;
50
50
  replaceAction<Data, Response>(targetActionId: string, sourceActionId: string): Promise<DraftAction<Data, Response>>;
51
51
  mergeActions<Data, Response>(targetActionId: string, sourceActionId: string): Promise<DraftAction<Data, Response>>;
52
+ retryAction<Data, Response>(actionId: string): Promise<DraftAction<Data, Response>>;
52
53
  setMetadata(actionId: string, metadata: DraftActionMetadata): Promise<DraftAction<unknown, unknown>>;
53
54
  private scheduleRetryWithSpecifiedDelay;
54
55
  private scheduleRetry;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-drafts",
3
- "version": "1.304.0",
3
+ "version": "1.305.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS Drafts",
6
6
  "main": "dist/ldsDrafts.js",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@luvio/engine": "0.156.3",
28
28
  "@luvio/environments": "0.156.3",
29
- "@salesforce/lds-utils-adapters": "^1.304.0"
29
+ "@salesforce/lds-utils-adapters": "^1.305.0"
30
30
  },
31
31
  "volta": {
32
32
  "extends": "../../package.json"