@salesforce/lds-drafts 1.114.0 → 1.114.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/DraftManager.d.ts +1 -1
- package/dist/DraftQueue.d.ts +1 -1
- package/dist/DurableDraftQueue.d.ts +1 -1
- package/dist/ldsDrafts.js +38 -23
- package/package.json +2 -2
package/dist/DraftManager.d.ts
CHANGED
|
@@ -150,7 +150,7 @@ export declare class DraftManager {
|
|
|
150
150
|
* @param sourceActionId The draft action id to merge onto the target. This
|
|
151
151
|
* action will be removed after the merge.
|
|
152
152
|
*/
|
|
153
|
-
|
|
153
|
+
mergeActions(targetActionId: string, sourceActionId: string): Promise<DraftQueueItem>;
|
|
154
154
|
/**
|
|
155
155
|
* Sets the metadata object of the specified action to the
|
|
156
156
|
* provided metadata
|
package/dist/DraftQueue.d.ts
CHANGED
|
@@ -216,7 +216,7 @@ export interface DraftQueue {
|
|
|
216
216
|
* @param sourceActionId The draft action id to merge onto the target. This
|
|
217
217
|
* action will be removed after the merge.
|
|
218
218
|
*/
|
|
219
|
-
|
|
219
|
+
mergeActions<Data, Response>(targetActionId: string, sourceActionId: string): Promise<DraftAction<Data, Response>>;
|
|
220
220
|
/** Set the draft queue state to Started and process the next item */
|
|
221
221
|
startQueue(): Promise<void>;
|
|
222
222
|
/** Set the draft queue state to Stopped and don't let another item begin */
|
|
@@ -46,7 +46,7 @@ export declare class DurableDraftQueue implements DraftQueue {
|
|
|
46
46
|
private startQueueSafe;
|
|
47
47
|
removeDraftAction(actionId: string): Promise<void>;
|
|
48
48
|
replaceAction(actionId: string, withActionId: string): Promise<DraftAction<unknown, unknown>>;
|
|
49
|
-
|
|
49
|
+
mergeActions<Data, Response>(targetActionId: string, sourceActionId: string): Promise<DraftAction<Data, Response>>;
|
|
50
50
|
setMetadata(actionId: string, metadata: DraftActionMetadata): Promise<DraftAction<unknown, unknown>>;
|
|
51
51
|
private scheduleRetry;
|
|
52
52
|
}
|
package/dist/ldsDrafts.js
CHANGED
|
@@ -712,23 +712,31 @@ class DurableDraftQueue {
|
|
|
712
712
|
await this.startQueueSafe();
|
|
713
713
|
return Promise.reject('No action to replace');
|
|
714
714
|
}
|
|
715
|
-
|
|
716
|
-
//
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
715
|
+
// put in a try/finally block so we don't leave this.replacingAction
|
|
716
|
+
// indefinitely set
|
|
717
|
+
let actionToReplace;
|
|
718
|
+
try {
|
|
719
|
+
const replaceResult = this.getHandler(first.handler).handleReplaceAction(actionId, withActionId, this.uploadingActionId, actions);
|
|
720
|
+
actionToReplace = replaceResult.actionToReplace;
|
|
721
|
+
// TODO [W-8873834]: Will add batching support to durable store
|
|
722
|
+
// we should use that here to remove and set both actions in one operation
|
|
723
|
+
await this.removeDraftAction(replaceResult.replacingAction.id);
|
|
724
|
+
await this.draftStore.writeAction(actionToReplace);
|
|
725
|
+
await this.notifyChangedListeners({
|
|
726
|
+
type: DraftQueueEventType.ActionUpdated,
|
|
727
|
+
action: actionToReplace,
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
finally {
|
|
731
|
+
this.replacingAction = undefined;
|
|
732
|
+
}
|
|
725
733
|
await this.startQueueSafe();
|
|
726
734
|
return actionToReplace;
|
|
727
735
|
});
|
|
728
736
|
this.replacingAction = replacing;
|
|
729
737
|
return replacing;
|
|
730
738
|
}
|
|
731
|
-
|
|
739
|
+
mergeActions(targetActionId, sourceActionId) {
|
|
732
740
|
// ids must be unique
|
|
733
741
|
if (targetActionId === sourceActionId) {
|
|
734
742
|
return Promise.reject(new Error('target and source action ids cannot be the same'));
|
|
@@ -751,16 +759,23 @@ class DurableDraftQueue {
|
|
|
751
759
|
await this.startQueueSafe();
|
|
752
760
|
throw Error('No action to replace');
|
|
753
761
|
}
|
|
754
|
-
|
|
755
|
-
//
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
762
|
+
// put in a try/finally block so we don't leave this.replacingAction
|
|
763
|
+
// indefinitely set
|
|
764
|
+
let merged;
|
|
765
|
+
try {
|
|
766
|
+
merged = this.getHandler(target.handler).mergeActions(target, source);
|
|
767
|
+
// update the target
|
|
768
|
+
await this.draftStore.writeAction(merged);
|
|
769
|
+
await this.notifyChangedListeners({
|
|
770
|
+
type: DraftQueueEventType.ActionUpdated,
|
|
771
|
+
action: merged,
|
|
772
|
+
});
|
|
773
|
+
// remove the source from queue
|
|
774
|
+
await this.removeDraftAction(sourceActionId);
|
|
775
|
+
}
|
|
776
|
+
finally {
|
|
777
|
+
this.replacingAction = undefined;
|
|
778
|
+
}
|
|
764
779
|
await this.startQueueSafe();
|
|
765
780
|
return merged;
|
|
766
781
|
});
|
|
@@ -1628,8 +1643,8 @@ class DraftManager {
|
|
|
1628
1643
|
* @param sourceActionId The draft action id to merge onto the target. This
|
|
1629
1644
|
* action will be removed after the merge.
|
|
1630
1645
|
*/
|
|
1631
|
-
|
|
1632
|
-
return this.draftQueue.
|
|
1646
|
+
mergeActions(targetActionId, sourceActionId) {
|
|
1647
|
+
return this.draftQueue.mergeActions(targetActionId, sourceActionId).then((merged) => {
|
|
1633
1648
|
return this.buildDraftQueueItem(merged);
|
|
1634
1649
|
});
|
|
1635
1650
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-drafts",
|
|
3
|
-
"version": "1.114.
|
|
3
|
+
"version": "1.114.2",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "LDS Drafts",
|
|
6
6
|
"main": "dist/ldsDrafts.js",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@luvio/engine": "0.137.1",
|
|
28
28
|
"@luvio/environments": "0.137.1",
|
|
29
|
-
"@salesforce/lds-utils-adapters": "^1.114.
|
|
29
|
+
"@salesforce/lds-utils-adapters": "^1.114.2"
|
|
30
30
|
}
|
|
31
31
|
}
|