@salesforce/lds-drafts 1.124.2 → 1.124.3

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.
@@ -1,233 +1,233 @@
1
- import type { FetchResponse } from '@luvio/engine';
2
- import type { ActionHandler } from './actionHandlers/ActionHandler';
3
- import type { CustomActionExecutor } from './actionHandlers/CustomActionHandler';
4
- export declare enum DraftActionStatus {
5
- Pending = "pending",
6
- Uploading = "uploading",
7
- Error = "error",
8
- Completed = "completed"
9
- }
10
- export type DraftActionMetadata = {
11
- [key: string]: string;
12
- };
13
- interface BaseDraftAction<Data> {
14
- status: DraftActionStatus;
15
- id: string;
16
- /** Timestamp as unix epoch time */
17
- timestamp: number;
18
- metadata: DraftActionMetadata;
19
- /** typically the cache key */
20
- targetId: string;
21
- /** typically the unique record ID */
22
- tag: string;
23
- /** the handlerId */
24
- handler: string;
25
- /** the data being enqueued */
26
- data: Data;
27
- version: '242.0.0';
28
- }
29
- export interface CompletedDraftAction<Data, Response> extends BaseDraftAction<Data> {
30
- status: DraftActionStatus.Completed;
31
- response: FetchResponse<Response>;
32
- }
33
- export interface PendingDraftAction<Data> extends BaseDraftAction<Data> {
34
- status: DraftActionStatus.Pending;
35
- }
36
- export interface ErrorDraftAction<Data> extends BaseDraftAction<Data> {
37
- status: DraftActionStatus.Error;
38
- error: any;
39
- }
40
- export interface UploadingDraftAction<Data> extends BaseDraftAction<Data> {
41
- status: DraftActionStatus.Uploading;
42
- }
43
- export declare function isDraftCompleted<Data, Response>(draft: BaseDraftAction<Data>): draft is CompletedDraftAction<Data, Response>;
44
- export declare function isDraftError<Data>(draft: BaseDraftAction<Data>): draft is ErrorDraftAction<Data>;
45
- export declare function isDraftQueueStateChangeEvent(event: DraftQueueEvent): event is DraftQueueStateChangedEvent;
46
- export type DraftAction<Data, Response> = CompletedDraftAction<Data, Response> | PendingDraftAction<Data> | ErrorDraftAction<Data> | UploadingDraftAction<Data>;
47
- export type DraftQueueChangeListener = (event: DraftQueueEvent) => Promise<void>;
48
- export declare enum ProcessActionResult {
49
- ACTION_ERRORED = "ERROR",
50
- ACTION_SUCCEEDED = "SUCCESS",
51
- NO_ACTION_TO_PROCESS = "NO_ACTION_TO_PROCESS",
52
- ACTION_ALREADY_PROCESSING = "ACTION_ALREADY_PROCESSING",
53
- NETWORK_ERROR = "NETWORK_ERROR",
54
- BLOCKED_ON_ERROR = "BLOCKED_ON_ERROR",
55
- CUSTOM_ACTION_WAITING = "CUSTOM_ACTION_WAITING"
56
- }
57
- export declare enum DraftQueueState {
58
- /** Currently processing an item in the queue or queue is empty and waiting to process the next item. */
59
- Started = "started",
60
- /**
61
- * The queue is stopped and will not attempt to upload any drafts until startDraftQueue() is called.
62
- * This is the initial state when the DraftQueue gets instantiated.
63
- */
64
- Stopped = "stopped",
65
- /**
66
- * The queue is stopped due to a blocking error from the last upload attempt.
67
- * The queue will not run again until startDraftQueue() is called.
68
- */
69
- Error = "error",
70
- /**
71
- * There was a network error and the queue will attempt to upload again shortly.
72
- * To attempt to force an upload now call startDraftQueue().
73
- */
74
- Waiting = "waiting"
75
- }
76
- export declare enum DraftQueueEventType {
77
- /**
78
- * Triggered after an action had been added to the queue
79
- */
80
- ActionAdded = "added",
81
- /**
82
- * Triggered once an action failed
83
- */
84
- ActionFailed = "failed",
85
- /**
86
- * Triggered after an action has been deleted from the queue
87
- */
88
- ActionDeleted = "deleted",
89
- /**
90
- * Triggered after an action has been completed and after it has been removed from the queue
91
- */
92
- ActionCompleted = "completed",
93
- /**
94
- * Triggered after an action has been updated by the updateAction API
95
- */
96
- ActionUpdated = "updated",
97
- /**
98
- * Triggered after the Draft Queue state changes
99
- */
100
- QueueStateChanged = "state"
101
- }
102
- export interface DraftQueueAddEvent {
103
- type: DraftQueueEventType.ActionAdded;
104
- action: PendingDraftAction<unknown>;
105
- }
106
- export interface DraftQueueDeleteEvent {
107
- type: DraftQueueEventType.ActionDeleted;
108
- action: DraftAction<unknown, unknown>;
109
- }
110
- export interface DraftQueueCompleteEvent {
111
- type: DraftQueueEventType.ActionCompleted;
112
- action: CompletedDraftAction<unknown, unknown>;
113
- }
114
- export interface DraftQueueActionFailedEvent {
115
- type: DraftQueueEventType.ActionFailed;
116
- action: ErrorDraftAction<unknown>;
117
- }
118
- export interface DraftQueueActionUpdatedEvent {
119
- type: DraftQueueEventType.ActionUpdated;
120
- action: DraftAction<unknown, unknown>;
121
- }
122
- export interface DraftQueueStateChangedEvent {
123
- type: DraftQueueEventType.QueueStateChanged;
124
- state: DraftQueueState;
125
- }
126
- export type DraftQueueItemEvent = DraftQueueAddEvent | DraftQueueCompleteEvent | DraftQueueDeleteEvent | DraftQueueActionFailedEvent | DraftQueueActionUpdatedEvent;
127
- export type DraftQueueEvent = DraftQueueStateChangedEvent | DraftQueueItemEvent;
128
- export declare enum QueueOperationType {
129
- Add = "add",
130
- Delete = "delete",
131
- Update = "update"
132
- }
133
- export interface AddQueueOperation {
134
- type: QueueOperationType.Add;
135
- action: DraftAction<unknown, unknown>;
136
- }
137
- export interface DeleteQueueOperation {
138
- type: QueueOperationType.Delete;
139
- id: string;
140
- }
141
- export interface UpdateQueueOperation {
142
- type: QueueOperationType.Update;
143
- id: string;
144
- action: DraftAction<unknown, unknown>;
145
- }
146
- export type QueueOperation = UpdateQueueOperation | AddQueueOperation | DeleteQueueOperation;
147
- export interface EnqueueResult<Data, Response> {
148
- action: PendingDraftAction<Data>;
149
- data: Response;
150
- }
151
- export interface DraftQueue {
152
- /**
153
- * Enqueues a draft action into the DraftQueue
154
- * @param handlerId the id of the handler associated with the data
155
- * @param data the data the handler will use to create the draft action with
156
- * @returns A promise including the pending action created for the request and the data associated with the action
157
- * @throws {Error} An error when a proper action handler is not found or conditions are not met to enqueue the action
158
- */
159
- enqueue<Data, Response>(handlerId: string, data: Data): Promise<EnqueueResult<Data, Response>>;
160
- /**
161
- * add a new handler to the draft queue to process the data in the actions
162
- * @param id identifier to the handler
163
- * @param handler ActionHandler to process action
164
- */
165
- addHandler<Data, Type>(handler: ActionHandler<Data, unknown, Type>): Promise<void>;
166
- /**
167
- * Creates a ActionHandler<CustomActionData> with a callback to let the DraftQueue know when it has been processed
168
- * @param id identifier of the handler
169
- * @param executor callback to inform DraftQueue it is complete
170
- */
171
- addCustomHandler(id: string, executor: CustomActionExecutor): Promise<void>;
172
- /**
173
- * Removes an added ActionHandler
174
- * @param id identifier of the handler
175
- */
176
- removeHandler(id: string): Promise<void>;
177
- /**
178
- * Registers a listener to be notified when the Draft Queue changes
179
- * @param listener Listener to notify when the draft queue changes, with an optional parameter
180
- * for a completed DraftAction that triggered the change.
181
- */
182
- registerOnChangedListener(listener: DraftQueueChangeListener): () => Promise<void>;
183
- /**
184
- * Processes the next action in the draft queue
185
- */
186
- processNextAction(): Promise<ProcessActionResult>;
187
- /**
188
- * Get the current list of draft actions in queue
189
- */
190
- getQueueActions(): Promise<DraftAction<unknown, unknown>[]>;
191
- /** The current state of the DraftQueue */
192
- getQueueState(): DraftQueueState;
193
- /**
194
- * Removes the draft action identified by actionId from the draft queue.
195
- *
196
- * @param actionId The action identifier
197
- */
198
- removeDraftAction(actionId: string): Promise<void>;
199
- /**
200
- * Replaces the resource request of `withActionId` for the resource request
201
- * of `actionId`. Action ids cannot be equal. Both actions must be acting
202
- * on the same target object, and neither can currently be in progress.
203
- *
204
- * @param actionId The id of the draft action to replace
205
- * @param withActionId The id of the draft action that will replace the other
206
- */
207
- replaceAction(actionId: string, withActionId: string): Promise<DraftAction<unknown, unknown>>;
208
- /**
209
- * Merges two actions into a single target action. The target action maintains
210
- * its position in the queue, while the source action is removed from the queue.
211
- * Action ids cannot be equal. Both actions must be acting on the same target
212
- * object, and neither can currently be in progress.
213
- *
214
- * @param targetActionId The draft action id of the target action. This action
215
- * will be replaced with the merged result.
216
- * @param sourceActionId The draft action id to merge onto the target. This
217
- * action will be removed after the merge.
218
- */
219
- mergeActions<Data, Response>(targetActionId: string, sourceActionId: string): Promise<DraftAction<Data, Response>>;
220
- /** Set the draft queue state to Started and process the next item */
221
- startQueue(): Promise<void>;
222
- /** Set the draft queue state to Stopped and don't let another item begin */
223
- stopQueue(): Promise<void>;
224
- /**
225
- * Sets the metadata object of the specified action to the
226
- * provided metadata
227
- *
228
- * @param actionId The id of the draft action to set metadata on
229
- * @param metadata The metadata to set on the specified action
230
- */
231
- setMetadata(actionId: string, metadata: DraftActionMetadata): Promise<DraftAction<unknown, unknown>>;
232
- }
233
- export {};
1
+ import type { FetchResponse } from '@luvio/engine';
2
+ import type { ActionHandler } from './actionHandlers/ActionHandler';
3
+ import type { CustomActionExecutor } from './actionHandlers/CustomActionHandler';
4
+ export declare enum DraftActionStatus {
5
+ Pending = "pending",
6
+ Uploading = "uploading",
7
+ Error = "error",
8
+ Completed = "completed"
9
+ }
10
+ export type DraftActionMetadata = {
11
+ [key: string]: string;
12
+ };
13
+ interface BaseDraftAction<Data> {
14
+ status: DraftActionStatus;
15
+ id: string;
16
+ /** Timestamp as unix epoch time */
17
+ timestamp: number;
18
+ metadata: DraftActionMetadata;
19
+ /** typically the cache key */
20
+ targetId: string;
21
+ /** typically the unique record ID */
22
+ tag: string;
23
+ /** the handlerId */
24
+ handler: string;
25
+ /** the data being enqueued */
26
+ data: Data;
27
+ version: '242.0.0';
28
+ }
29
+ export interface CompletedDraftAction<Data, Response> extends BaseDraftAction<Data> {
30
+ status: DraftActionStatus.Completed;
31
+ response: FetchResponse<Response>;
32
+ }
33
+ export interface PendingDraftAction<Data> extends BaseDraftAction<Data> {
34
+ status: DraftActionStatus.Pending;
35
+ }
36
+ export interface ErrorDraftAction<Data> extends BaseDraftAction<Data> {
37
+ status: DraftActionStatus.Error;
38
+ error: any;
39
+ }
40
+ export interface UploadingDraftAction<Data> extends BaseDraftAction<Data> {
41
+ status: DraftActionStatus.Uploading;
42
+ }
43
+ export declare function isDraftCompleted<Data, Response>(draft: BaseDraftAction<Data>): draft is CompletedDraftAction<Data, Response>;
44
+ export declare function isDraftError<Data>(draft: BaseDraftAction<Data>): draft is ErrorDraftAction<Data>;
45
+ export declare function isDraftQueueStateChangeEvent(event: DraftQueueEvent): event is DraftQueueStateChangedEvent;
46
+ export type DraftAction<Data, Response> = CompletedDraftAction<Data, Response> | PendingDraftAction<Data> | ErrorDraftAction<Data> | UploadingDraftAction<Data>;
47
+ export type DraftQueueChangeListener = (event: DraftQueueEvent) => Promise<void>;
48
+ export declare enum ProcessActionResult {
49
+ ACTION_ERRORED = "ERROR",
50
+ ACTION_SUCCEEDED = "SUCCESS",
51
+ NO_ACTION_TO_PROCESS = "NO_ACTION_TO_PROCESS",
52
+ ACTION_ALREADY_PROCESSING = "ACTION_ALREADY_PROCESSING",
53
+ NETWORK_ERROR = "NETWORK_ERROR",
54
+ BLOCKED_ON_ERROR = "BLOCKED_ON_ERROR",
55
+ CUSTOM_ACTION_WAITING = "CUSTOM_ACTION_WAITING"
56
+ }
57
+ export declare enum DraftQueueState {
58
+ /** Currently processing an item in the queue or queue is empty and waiting to process the next item. */
59
+ Started = "started",
60
+ /**
61
+ * The queue is stopped and will not attempt to upload any drafts until startDraftQueue() is called.
62
+ * This is the initial state when the DraftQueue gets instantiated.
63
+ */
64
+ Stopped = "stopped",
65
+ /**
66
+ * The queue is stopped due to a blocking error from the last upload attempt.
67
+ * The queue will not run again until startDraftQueue() is called.
68
+ */
69
+ Error = "error",
70
+ /**
71
+ * There was a network error and the queue will attempt to upload again shortly.
72
+ * To attempt to force an upload now call startDraftQueue().
73
+ */
74
+ Waiting = "waiting"
75
+ }
76
+ export declare enum DraftQueueEventType {
77
+ /**
78
+ * Triggered after an action had been added to the queue
79
+ */
80
+ ActionAdded = "added",
81
+ /**
82
+ * Triggered once an action failed
83
+ */
84
+ ActionFailed = "failed",
85
+ /**
86
+ * Triggered after an action has been deleted from the queue
87
+ */
88
+ ActionDeleted = "deleted",
89
+ /**
90
+ * Triggered after an action has been completed and after it has been removed from the queue
91
+ */
92
+ ActionCompleted = "completed",
93
+ /**
94
+ * Triggered after an action has been updated by the updateAction API
95
+ */
96
+ ActionUpdated = "updated",
97
+ /**
98
+ * Triggered after the Draft Queue state changes
99
+ */
100
+ QueueStateChanged = "state"
101
+ }
102
+ export interface DraftQueueAddEvent {
103
+ type: DraftQueueEventType.ActionAdded;
104
+ action: PendingDraftAction<unknown>;
105
+ }
106
+ export interface DraftQueueDeleteEvent {
107
+ type: DraftQueueEventType.ActionDeleted;
108
+ action: DraftAction<unknown, unknown>;
109
+ }
110
+ export interface DraftQueueCompleteEvent {
111
+ type: DraftQueueEventType.ActionCompleted;
112
+ action: CompletedDraftAction<unknown, unknown>;
113
+ }
114
+ export interface DraftQueueActionFailedEvent {
115
+ type: DraftQueueEventType.ActionFailed;
116
+ action: ErrorDraftAction<unknown>;
117
+ }
118
+ export interface DraftQueueActionUpdatedEvent {
119
+ type: DraftQueueEventType.ActionUpdated;
120
+ action: DraftAction<unknown, unknown>;
121
+ }
122
+ export interface DraftQueueStateChangedEvent {
123
+ type: DraftQueueEventType.QueueStateChanged;
124
+ state: DraftQueueState;
125
+ }
126
+ export type DraftQueueItemEvent = DraftQueueAddEvent | DraftQueueCompleteEvent | DraftQueueDeleteEvent | DraftQueueActionFailedEvent | DraftQueueActionUpdatedEvent;
127
+ export type DraftQueueEvent = DraftQueueStateChangedEvent | DraftQueueItemEvent;
128
+ export declare enum QueueOperationType {
129
+ Add = "add",
130
+ Delete = "delete",
131
+ Update = "update"
132
+ }
133
+ export interface AddQueueOperation {
134
+ type: QueueOperationType.Add;
135
+ action: DraftAction<unknown, unknown>;
136
+ }
137
+ export interface DeleteQueueOperation {
138
+ type: QueueOperationType.Delete;
139
+ id: string;
140
+ }
141
+ export interface UpdateQueueOperation {
142
+ type: QueueOperationType.Update;
143
+ id: string;
144
+ action: DraftAction<unknown, unknown>;
145
+ }
146
+ export type QueueOperation = UpdateQueueOperation | AddQueueOperation | DeleteQueueOperation;
147
+ export interface EnqueueResult<Data, Response> {
148
+ action: PendingDraftAction<Data>;
149
+ data: Response;
150
+ }
151
+ export interface DraftQueue {
152
+ /**
153
+ * Enqueues a draft action into the DraftQueue
154
+ * @param handlerId the id of the handler associated with the data
155
+ * @param data the data the handler will use to create the draft action with
156
+ * @returns A promise including the pending action created for the request and the data associated with the action
157
+ * @throws {Error} An error when a proper action handler is not found or conditions are not met to enqueue the action
158
+ */
159
+ enqueue<Data, Response>(handlerId: string, data: Data): Promise<EnqueueResult<Data, Response>>;
160
+ /**
161
+ * add a new handler to the draft queue to process the data in the actions
162
+ * @param id identifier to the handler
163
+ * @param handler ActionHandler to process action
164
+ */
165
+ addHandler<Data, Type>(handler: ActionHandler<Data, unknown, Type>): Promise<void>;
166
+ /**
167
+ * Creates a ActionHandler<CustomActionData> with a callback to let the DraftQueue know when it has been processed
168
+ * @param id identifier of the handler
169
+ * @param executor callback to inform DraftQueue it is complete
170
+ */
171
+ addCustomHandler(id: string, executor: CustomActionExecutor): Promise<void>;
172
+ /**
173
+ * Removes an added ActionHandler
174
+ * @param id identifier of the handler
175
+ */
176
+ removeHandler(id: string): Promise<void>;
177
+ /**
178
+ * Registers a listener to be notified when the Draft Queue changes
179
+ * @param listener Listener to notify when the draft queue changes, with an optional parameter
180
+ * for a completed DraftAction that triggered the change.
181
+ */
182
+ registerOnChangedListener(listener: DraftQueueChangeListener): () => Promise<void>;
183
+ /**
184
+ * Processes the next action in the draft queue
185
+ */
186
+ processNextAction(): Promise<ProcessActionResult>;
187
+ /**
188
+ * Get the current list of draft actions in queue
189
+ */
190
+ getQueueActions(): Promise<DraftAction<unknown, unknown>[]>;
191
+ /** The current state of the DraftQueue */
192
+ getQueueState(): DraftQueueState;
193
+ /**
194
+ * Removes the draft action identified by actionId from the draft queue.
195
+ *
196
+ * @param actionId The action identifier
197
+ */
198
+ removeDraftAction(actionId: string): Promise<void>;
199
+ /**
200
+ * Replaces the resource request of `withActionId` for the resource request
201
+ * of `actionId`. Action ids cannot be equal. Both actions must be acting
202
+ * on the same target object, and neither can currently be in progress.
203
+ *
204
+ * @param actionId The id of the draft action to replace
205
+ * @param withActionId The id of the draft action that will replace the other
206
+ */
207
+ replaceAction(actionId: string, withActionId: string): Promise<DraftAction<unknown, unknown>>;
208
+ /**
209
+ * Merges two actions into a single target action. The target action maintains
210
+ * its position in the queue, while the source action is removed from the queue.
211
+ * Action ids cannot be equal. Both actions must be acting on the same target
212
+ * object, and neither can currently be in progress.
213
+ *
214
+ * @param targetActionId The draft action id of the target action. This action
215
+ * will be replaced with the merged result.
216
+ * @param sourceActionId The draft action id to merge onto the target. This
217
+ * action will be removed after the merge.
218
+ */
219
+ mergeActions<Data, Response>(targetActionId: string, sourceActionId: string): Promise<DraftAction<Data, Response>>;
220
+ /** Set the draft queue state to Started and process the next item */
221
+ startQueue(): Promise<void>;
222
+ /** Set the draft queue state to Stopped and don't let another item begin */
223
+ stopQueue(): Promise<void>;
224
+ /**
225
+ * Sets the metadata object of the specified action to the
226
+ * provided metadata
227
+ *
228
+ * @param actionId The id of the draft action to set metadata on
229
+ * @param metadata The metadata to set on the specified action
230
+ */
231
+ setMetadata(actionId: string, metadata: DraftActionMetadata): Promise<DraftAction<unknown, unknown>>;
232
+ }
233
+ export {};
@@ -1,12 +1,12 @@
1
- import type { DraftAction, QueueOperation } from './DraftQueue';
2
- import type { DraftKeyMapping } from './DraftIdMapping';
3
- /**
4
- * Defines the store where drafts are persisted
5
- */
6
- export interface DraftStore {
7
- writeAction(action: DraftAction<unknown, unknown>): Promise<void>;
8
- getAllDrafts(): Promise<DraftAction<unknown, unknown>[]>;
9
- deleteDraft(actionId: string): Promise<void>;
10
- deleteByTag(tag: string): Promise<void>;
11
- completeAction(queueOperations: QueueOperation[], mappings: DraftKeyMapping[] | undefined): Promise<void>;
12
- }
1
+ import type { DraftAction, QueueOperation } from './DraftQueue';
2
+ import type { DraftKeyMapping } from './DraftIdMapping';
3
+ /**
4
+ * Defines the store where drafts are persisted
5
+ */
6
+ export interface DraftStore {
7
+ writeAction(action: DraftAction<unknown, unknown>): Promise<void>;
8
+ getAllDrafts(): Promise<DraftAction<unknown, unknown>[]>;
9
+ deleteDraft(actionId: string): Promise<void>;
10
+ deleteByTag(tag: string): Promise<void>;
11
+ completeAction(queueOperations: QueueOperation[], mappings: DraftKeyMapping[] | undefined): Promise<void>;
12
+ }
@@ -1,6 +1,6 @@
1
- export type DraftSynthesisErrorType = 'MISSING_ID' | 'OBJECT_INFO_MISSING' | 'REFERENCED_RECORDS_MISSING' | 'UNEXPECTED_FIELDS' | 'RECORD_NOT_CACHED' | 'UNKNOWN';
2
- export declare class DraftSynthesisError<T> extends Error {
3
- errorType: T;
4
- constructor(message: string, errorType: T);
5
- }
6
- export declare function isDraftSynthesisError<T>(error: Error): error is DraftSynthesisError<T>;
1
+ export type DraftSynthesisErrorType = 'MISSING_ID' | 'OBJECT_INFO_MISSING' | 'REFERENCED_RECORDS_MISSING' | 'UNEXPECTED_FIELDS' | 'RECORD_NOT_CACHED' | 'UNKNOWN';
2
+ export declare class DraftSynthesisError<T> extends Error {
3
+ errorType: T;
4
+ constructor(message: string, errorType: T);
5
+ }
6
+ export declare function isDraftSynthesisError<T>(error: Error): error is DraftSynthesisError<T>;
@@ -1,52 +1,52 @@
1
- import type { DraftQueue, DraftAction, CompletedDraftAction, DraftQueueChangeListener, DraftActionMetadata, EnqueueResult } from './DraftQueue';
2
- import { ProcessActionResult, DraftQueueState } from './DraftQueue';
3
- import type { CustomActionExecutor } from './actionHandlers/CustomActionHandler';
4
- import type { ActionHandler } from './actionHandlers/ActionHandler';
5
- import type { DraftStore } from './DraftStore';
6
- export declare const DRAFT_SEGMENT = "DRAFT";
7
- export declare class DurableDraftQueue implements DraftQueue {
8
- private retryIntervalMilliseconds;
9
- private minimumRetryInterval;
10
- private maximumRetryInterval;
11
- private draftStore;
12
- private draftQueueChangedListeners;
13
- private state;
14
- private userState;
15
- private processingAction?;
16
- private replacingAction?;
17
- private uploadingActionId?;
18
- private timeoutHandler;
19
- private workerPool;
20
- private handlers;
21
- private getHandler;
22
- constructor(draftStore: DraftStore);
23
- addHandler<Data>(handler: ActionHandler<Data, unknown, unknown>): Promise<void>;
24
- removeHandler(id: string): Promise<void>;
25
- addCustomHandler(id: string, executor: CustomActionExecutor): Promise<void>;
26
- getQueueState(): DraftQueueState;
27
- startQueue(): Promise<void>;
28
- stopQueue(): Promise<void>;
29
- /**
30
- * Used to stop the queue within DraftQueue without user interaction
31
- */
32
- private stopQueueManually;
33
- getQueueActions<Data = unknown, Response = unknown>(): Promise<DraftAction<Data, Response>[]>;
34
- enqueue<Data, Response>(handlerId: string, data: unknown): Promise<EnqueueResult<Data, Response>>;
35
- registerOnChangedListener(listener: DraftQueueChangeListener): () => Promise<void>;
36
- actionCompleted(action: CompletedDraftAction<unknown, unknown>): Promise<void>;
37
- actionFailed(action: DraftAction<unknown, unknown>, retry: boolean): Promise<void>;
38
- handle(action: DraftAction<unknown, unknown>): Promise<ProcessActionResult>;
39
- processNextAction(): Promise<ProcessActionResult>;
40
- private handleServerError;
41
- private notifyChangedListeners;
42
- /**
43
- * only starts the queue if user state is "Started" and if queue not already
44
- * started
45
- */
46
- private startQueueSafe;
47
- removeDraftAction(actionId: string): Promise<void>;
48
- replaceAction(actionId: string, withActionId: string): Promise<DraftAction<unknown, unknown>>;
49
- mergeActions<Data, Response>(targetActionId: string, sourceActionId: string): Promise<DraftAction<Data, Response>>;
50
- setMetadata(actionId: string, metadata: DraftActionMetadata): Promise<DraftAction<unknown, unknown>>;
51
- private scheduleRetry;
52
- }
1
+ import type { DraftQueue, DraftAction, CompletedDraftAction, DraftQueueChangeListener, DraftActionMetadata, EnqueueResult } from './DraftQueue';
2
+ import { ProcessActionResult, DraftQueueState } from './DraftQueue';
3
+ import type { CustomActionExecutor } from './actionHandlers/CustomActionHandler';
4
+ import type { ActionHandler } from './actionHandlers/ActionHandler';
5
+ import type { DraftStore } from './DraftStore';
6
+ export declare const DRAFT_SEGMENT = "DRAFT";
7
+ export declare class DurableDraftQueue implements DraftQueue {
8
+ private retryIntervalMilliseconds;
9
+ private minimumRetryInterval;
10
+ private maximumRetryInterval;
11
+ private draftStore;
12
+ private draftQueueChangedListeners;
13
+ private state;
14
+ private userState;
15
+ private processingAction?;
16
+ private replacingAction?;
17
+ private uploadingActionId?;
18
+ private timeoutHandler;
19
+ private workerPool;
20
+ private handlers;
21
+ private getHandler;
22
+ constructor(draftStore: DraftStore);
23
+ addHandler<Data>(handler: ActionHandler<Data, unknown, unknown>): Promise<void>;
24
+ removeHandler(id: string): Promise<void>;
25
+ addCustomHandler(id: string, executor: CustomActionExecutor): Promise<void>;
26
+ getQueueState(): DraftQueueState;
27
+ startQueue(): Promise<void>;
28
+ stopQueue(): Promise<void>;
29
+ /**
30
+ * Used to stop the queue within DraftQueue without user interaction
31
+ */
32
+ private stopQueueManually;
33
+ getQueueActions<Data = unknown, Response = unknown>(): Promise<DraftAction<Data, Response>[]>;
34
+ enqueue<Data, Response>(handlerId: string, data: unknown): Promise<EnqueueResult<Data, Response>>;
35
+ registerOnChangedListener(listener: DraftQueueChangeListener): () => Promise<void>;
36
+ actionCompleted(action: CompletedDraftAction<unknown, unknown>): Promise<void>;
37
+ actionFailed(action: DraftAction<unknown, unknown>, retry: boolean): Promise<void>;
38
+ handle(action: DraftAction<unknown, unknown>): Promise<ProcessActionResult>;
39
+ processNextAction(): Promise<ProcessActionResult>;
40
+ private handleServerError;
41
+ private notifyChangedListeners;
42
+ /**
43
+ * only starts the queue if user state is "Started" and if queue not already
44
+ * started
45
+ */
46
+ private startQueueSafe;
47
+ removeDraftAction(actionId: string): Promise<void>;
48
+ replaceAction(actionId: string, withActionId: string): Promise<DraftAction<unknown, unknown>>;
49
+ mergeActions<Data, Response>(targetActionId: string, sourceActionId: string): Promise<DraftAction<Data, Response>>;
50
+ setMetadata(actionId: string, metadata: DraftActionMetadata): Promise<DraftAction<unknown, unknown>>;
51
+ private scheduleRetry;
52
+ }