@salesforce/lds-drafts 1.302.0 → 1.303.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 +27 -8
- package/dist/types/DraftManager.d.ts +5 -2
- package/package.json +4 -4
package/dist/ldsDrafts.js
CHANGED
|
@@ -669,7 +669,7 @@ class DurableDraftQueue {
|
|
|
669
669
|
if (status === DraftActionStatus.Error) {
|
|
670
670
|
this.state = DraftQueueState.Error;
|
|
671
671
|
this.processingAction = undefined;
|
|
672
|
-
this.notifyChangedListeners({
|
|
672
|
+
await this.notifyChangedListeners({
|
|
673
673
|
type: DraftQueueEventType.ActionFailed,
|
|
674
674
|
action: action,
|
|
675
675
|
});
|
|
@@ -685,7 +685,7 @@ class DurableDraftQueue {
|
|
|
685
685
|
if (this.state === DraftQueueState.Waiting) {
|
|
686
686
|
this.state = DraftQueueState.Started;
|
|
687
687
|
}
|
|
688
|
-
this.notifyChangedListeners({
|
|
688
|
+
await this.notifyChangedListeners({
|
|
689
689
|
type: DraftQueueEventType.ActionUploading,
|
|
690
690
|
action: { ...action, status: DraftActionStatus.Uploading },
|
|
691
691
|
});
|
|
@@ -792,17 +792,21 @@ class DurableDraftQueue {
|
|
|
792
792
|
});
|
|
793
793
|
return action;
|
|
794
794
|
}
|
|
795
|
-
scheduleRetryWithSpecifiedDelay(retryDelayInMs) {
|
|
795
|
+
async scheduleRetryWithSpecifiedDelay(retryDelayInMs) {
|
|
796
|
+
await this.notifyChangedListeners({
|
|
797
|
+
type: DraftQueueEventType.QueueStateChanged,
|
|
798
|
+
state: DraftQueueState.Waiting,
|
|
799
|
+
});
|
|
796
800
|
this.timeoutHandler = setTimeout(() => {
|
|
797
801
|
if (this.state !== DraftQueueState.Stopped) {
|
|
798
802
|
this.processNextAction();
|
|
799
803
|
}
|
|
800
804
|
}, retryDelayInMs);
|
|
801
805
|
}
|
|
802
|
-
scheduleRetry() {
|
|
806
|
+
async scheduleRetry() {
|
|
803
807
|
const newInterval = this.retryIntervalMilliseconds * 2;
|
|
804
808
|
this.retryIntervalMilliseconds = Math.min(Math.max(newInterval, this.minimumRetryInterval), this.maximumRetryInterval);
|
|
805
|
-
this.scheduleRetryWithSpecifiedDelay(this.retryIntervalMilliseconds);
|
|
809
|
+
return this.scheduleRetryWithSpecifiedDelay(this.retryIntervalMilliseconds);
|
|
806
810
|
}
|
|
807
811
|
async getActionsForReplaceOrMerge(targetActionId, sourceActionId) {
|
|
808
812
|
const actions = await this.getQueueActions();
|
|
@@ -928,7 +932,8 @@ class DurableDraftStore {
|
|
|
928
932
|
const actionArray = [];
|
|
929
933
|
for (let i = 0, len = keys$1.length; i < len; i++) {
|
|
930
934
|
const key = keys$1[i];
|
|
931
|
-
|
|
935
|
+
// clone draft so we don't expose the internal draft store
|
|
936
|
+
actionArray.push(clone(draftStore[key]));
|
|
932
937
|
}
|
|
933
938
|
return actionArray;
|
|
934
939
|
});
|
|
@@ -1577,6 +1582,7 @@ var DraftQueueOperationType;
|
|
|
1577
1582
|
DraftQueueOperationType["ItemUpdated"] = "updated";
|
|
1578
1583
|
DraftQueueOperationType["QueueStarted"] = "started";
|
|
1579
1584
|
DraftQueueOperationType["QueueStopped"] = "stopped";
|
|
1585
|
+
DraftQueueOperationType["QueueWaiting"] = "waiting";
|
|
1580
1586
|
})(DraftQueueOperationType || (DraftQueueOperationType = {}));
|
|
1581
1587
|
/**
|
|
1582
1588
|
* Converts the internal DraftAction's ResourceRequest into
|
|
@@ -1619,6 +1625,16 @@ function toQueueState(queue) {
|
|
|
1619
1625
|
};
|
|
1620
1626
|
}
|
|
1621
1627
|
class DraftManager {
|
|
1628
|
+
shouldEmitEvent(event) {
|
|
1629
|
+
// Waiting events cannot be emitted prior to 252 native clients
|
|
1630
|
+
// TODO [W-16102411]: we can safely remove this backwards compatible code in 256
|
|
1631
|
+
if (isDraftQueueStateChangeEvent(event) &&
|
|
1632
|
+
event.state === DraftQueueState.Waiting &&
|
|
1633
|
+
this.listenerVersion === undefined) {
|
|
1634
|
+
return false;
|
|
1635
|
+
}
|
|
1636
|
+
return this.draftEventsShouldBeEmitted.includes(event.type);
|
|
1637
|
+
}
|
|
1622
1638
|
constructor(draftQueue) {
|
|
1623
1639
|
this.listeners = [];
|
|
1624
1640
|
this.draftEventsShouldBeEmitted = [
|
|
@@ -1632,7 +1648,7 @@ class DraftManager {
|
|
|
1632
1648
|
];
|
|
1633
1649
|
this.draftQueue = draftQueue;
|
|
1634
1650
|
draftQueue.registerOnChangedListener((event) => {
|
|
1635
|
-
if (this.
|
|
1651
|
+
if (this.shouldEmitEvent(event)) {
|
|
1636
1652
|
return this.callListeners(event);
|
|
1637
1653
|
}
|
|
1638
1654
|
return Promise.resolve();
|
|
@@ -1662,6 +1678,8 @@ class DraftManager {
|
|
|
1662
1678
|
return DraftQueueOperationType.QueueStarted;
|
|
1663
1679
|
case DraftQueueState.Stopped:
|
|
1664
1680
|
return DraftQueueOperationType.QueueStopped;
|
|
1681
|
+
case DraftQueueState.Waiting:
|
|
1682
|
+
return DraftQueueOperationType.QueueWaiting;
|
|
1665
1683
|
default:
|
|
1666
1684
|
throw Error('Unsupported event type');
|
|
1667
1685
|
}
|
|
@@ -1719,7 +1737,8 @@ class DraftManager {
|
|
|
1719
1737
|
*
|
|
1720
1738
|
* @param listener The listener closure to subscribe to changes
|
|
1721
1739
|
*/
|
|
1722
|
-
registerDraftQueueChangedListener(listener) {
|
|
1740
|
+
registerDraftQueueChangedListener(listener, version = undefined) {
|
|
1741
|
+
this.listenerVersion = version;
|
|
1723
1742
|
this.listeners.push(listener);
|
|
1724
1743
|
return () => {
|
|
1725
1744
|
this.listeners = this.listeners.filter((l) => {
|
|
@@ -68,7 +68,8 @@ export declare enum DraftQueueOperationType {
|
|
|
68
68
|
ItemFailed = "failed",
|
|
69
69
|
ItemUpdated = "updated",
|
|
70
70
|
QueueStarted = "started",
|
|
71
|
-
QueueStopped = "stopped"
|
|
71
|
+
QueueStopped = "stopped",
|
|
72
|
+
QueueWaiting = "waiting"
|
|
72
73
|
}
|
|
73
74
|
/**
|
|
74
75
|
* A closure that draft queue change listeners pass to
|
|
@@ -78,7 +79,9 @@ export declare type DraftQueueListener = (state: DraftManagerState, operationTyp
|
|
|
78
79
|
export declare class DraftManager {
|
|
79
80
|
private draftQueue;
|
|
80
81
|
private listeners;
|
|
82
|
+
private listenerVersion;
|
|
81
83
|
private draftEventsShouldBeEmitted;
|
|
84
|
+
private shouldEmitEvent;
|
|
82
85
|
constructor(draftQueue: DraftQueue);
|
|
83
86
|
private draftQueueEventTypeToOperationType;
|
|
84
87
|
private draftQueueStateToOperationType;
|
|
@@ -113,7 +116,7 @@ export declare class DraftManager {
|
|
|
113
116
|
*
|
|
114
117
|
* @param listener The listener closure to subscribe to changes
|
|
115
118
|
*/
|
|
116
|
-
registerDraftQueueChangedListener(listener: DraftQueueListener): () => Promise<void>;
|
|
119
|
+
registerDraftQueueChangedListener(listener: DraftQueueListener, version?: 252 | undefined): () => Promise<void>;
|
|
117
120
|
/**
|
|
118
121
|
* Creates a custom action handler for the given handler
|
|
119
122
|
* @param handlerId
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-drafts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.303.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "LDS Drafts",
|
|
6
6
|
"main": "dist/ldsDrafts.js",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"release:corejar": "yarn build && ../core-build/scripts/core.js --adapter=lds-drafts"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@luvio/engine": "0.
|
|
28
|
-
"@luvio/environments": "0.
|
|
29
|
-
"@salesforce/lds-utils-adapters": "^1.
|
|
27
|
+
"@luvio/engine": "0.156.3",
|
|
28
|
+
"@luvio/environments": "0.156.3",
|
|
29
|
+
"@salesforce/lds-utils-adapters": "^1.303.0"
|
|
30
30
|
}
|
|
31
31
|
}
|