@salesforce/lds-drafts 1.143.0 → 1.145.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
@@ -63,6 +63,10 @@ var DraftQueueEventType;
63
63
  * Triggered after an action had been added to the queue
64
64
  */
65
65
  DraftQueueEventType["ActionAdded"] = "added";
66
+ /**
67
+ * Triggered when starting to upload and process an action
68
+ */
69
+ DraftQueueEventType["ActionUploading"] = "uploading";
66
70
  /**
67
71
  * Triggered once an action failed
68
72
  */
@@ -620,6 +624,10 @@ class DurableDraftQueue {
620
624
  if (this.state === DraftQueueState.Waiting) {
621
625
  this.state = DraftQueueState.Started;
622
626
  }
627
+ this.notifyChangedListeners({
628
+ type: DraftQueueEventType.ActionUploading,
629
+ action: { ...action, status: DraftActionStatus.Uploading },
630
+ });
623
631
  return this.handle(action);
624
632
  }
625
633
  async handleServerError(action, error) {
@@ -1380,6 +1388,7 @@ var DraftActionOperationType;
1380
1388
  var DraftQueueOperationType;
1381
1389
  (function (DraftQueueOperationType) {
1382
1390
  DraftQueueOperationType["ItemAdded"] = "added";
1391
+ DraftQueueOperationType["ItemUploading"] = "uploading";
1383
1392
  DraftQueueOperationType["ItemDeleted"] = "deleted";
1384
1393
  DraftQueueOperationType["ItemCompleted"] = "completed";
1385
1394
  DraftQueueOperationType["ItemFailed"] = "failed";
@@ -1430,29 +1439,29 @@ function toQueueState(queue) {
1430
1439
  class DraftManager {
1431
1440
  constructor(draftQueue) {
1432
1441
  this.listeners = [];
1433
- this.draftQueue = draftQueue;
1434
- draftQueue.registerOnChangedListener((event) => {
1435
- if (this.shouldEmitDraftEvent(event)) {
1436
- return this.callListeners(event);
1437
- }
1438
- return Promise.resolve();
1439
- });
1440
- }
1441
- shouldEmitDraftEvent(event) {
1442
- const { type } = event;
1443
- return [
1442
+ this.draftEventsShouldBeEmitted = [
1444
1443
  DraftQueueEventType.ActionAdded,
1444
+ DraftQueueEventType.ActionUploading,
1445
1445
  DraftQueueEventType.ActionCompleted,
1446
1446
  DraftQueueEventType.ActionDeleted,
1447
1447
  DraftQueueEventType.ActionFailed,
1448
1448
  DraftQueueEventType.ActionUpdated,
1449
1449
  DraftQueueEventType.QueueStateChanged,
1450
- ].includes(type);
1450
+ ];
1451
+ this.draftQueue = draftQueue;
1452
+ draftQueue.registerOnChangedListener((event) => {
1453
+ if (this.draftEventsShouldBeEmitted.includes(event.type)) {
1454
+ return this.callListeners(event);
1455
+ }
1456
+ return Promise.resolve();
1457
+ });
1451
1458
  }
1452
1459
  draftQueueEventTypeToOperationType(type) {
1453
1460
  switch (type) {
1454
1461
  case DraftQueueEventType.ActionAdded:
1455
1462
  return DraftQueueOperationType.ItemAdded;
1463
+ case DraftQueueEventType.ActionUploading:
1464
+ return DraftQueueOperationType.ItemUploading;
1456
1465
  case DraftQueueEventType.ActionCompleted:
1457
1466
  return DraftQueueOperationType.ItemCompleted;
1458
1467
  case DraftQueueEventType.ActionDeleted:
@@ -62,6 +62,7 @@ export declare enum DraftActionOperationType {
62
62
  }
63
63
  export declare enum DraftQueueOperationType {
64
64
  ItemAdded = "added",
65
+ ItemUploading = "uploading",
65
66
  ItemDeleted = "deleted",
66
67
  ItemCompleted = "completed",
67
68
  ItemFailed = "failed",
@@ -77,8 +78,8 @@ export declare type DraftQueueListener = (state: DraftManagerState, operationTyp
77
78
  export declare class DraftManager {
78
79
  private draftQueue;
79
80
  private listeners;
81
+ private draftEventsShouldBeEmitted;
80
82
  constructor(draftQueue: DraftQueue);
81
- private shouldEmitDraftEvent;
82
83
  private draftQueueEventTypeToOperationType;
83
84
  private draftQueueStateToOperationType;
84
85
  /**
@@ -78,6 +78,10 @@ export declare enum DraftQueueEventType {
78
78
  * Triggered after an action had been added to the queue
79
79
  */
80
80
  ActionAdded = "added",
81
+ /**
82
+ * Triggered when starting to upload and process an action
83
+ */
84
+ ActionUploading = "uploading",
81
85
  /**
82
86
  * Triggered once an action failed
83
87
  */
@@ -103,6 +107,10 @@ export interface DraftQueueAddEvent {
103
107
  type: DraftQueueEventType.ActionAdded;
104
108
  action: PendingDraftAction<unknown>;
105
109
  }
110
+ export interface DraftQueueUploadingEvent {
111
+ type: DraftQueueEventType.ActionUploading;
112
+ action: UploadingDraftAction<unknown>;
113
+ }
106
114
  export interface DraftQueueDeleteEvent {
107
115
  type: DraftQueueEventType.ActionDeleted;
108
116
  action: DraftAction<unknown, unknown>;
@@ -123,7 +131,7 @@ export interface DraftQueueStateChangedEvent {
123
131
  type: DraftQueueEventType.QueueStateChanged;
124
132
  state: DraftQueueState;
125
133
  }
126
- export type DraftQueueItemEvent = DraftQueueAddEvent | DraftQueueCompleteEvent | DraftQueueDeleteEvent | DraftQueueActionFailedEvent | DraftQueueActionUpdatedEvent;
134
+ export type DraftQueueItemEvent = DraftQueueAddEvent | DraftQueueUploadingEvent | DraftQueueCompleteEvent | DraftQueueDeleteEvent | DraftQueueActionFailedEvent | DraftQueueActionUpdatedEvent;
127
135
  export type DraftQueueEvent = DraftQueueStateChangedEvent | DraftQueueItemEvent;
128
136
  export declare enum QueueOperationType {
129
137
  Add = "add",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-drafts",
3
- "version": "1.143.0",
3
+ "version": "1.145.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS Drafts",
6
6
  "main": "dist/ldsDrafts.js",