@salesforce/lds-drafts 1.253.0 → 1.256.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
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { HttpStatusCode, StoreKeyMap } from '@luvio/engine';
|
|
8
8
|
import { uuidv4, AsyncWorkerPool } from '@salesforce/lds-utils-adapters';
|
|
9
9
|
import ldsIdempotencyWriteDisabled from '@salesforce/gate/lds.idempotencyWriteDisabled';
|
|
10
|
+
import ldsBackdatingEnabled from '@salesforce/gate/lds.backdatingEnabled';
|
|
10
11
|
|
|
11
12
|
var DraftActionStatus;
|
|
12
13
|
(function (DraftActionStatus) {
|
|
@@ -1084,6 +1085,8 @@ class DurableDraftStore {
|
|
|
1084
1085
|
}
|
|
1085
1086
|
}
|
|
1086
1087
|
|
|
1088
|
+
const DEFAULT_FIELD_LAST_MODIFIED_DATE = 'LastModifiedDate';
|
|
1089
|
+
const DEFAULT_FIELD_CREATED_DATE = 'CreatedDate';
|
|
1087
1090
|
class AbstractResourceRequestActionHandler {
|
|
1088
1091
|
constructor(draftQueue, networkAdapter, getLuvio) {
|
|
1089
1092
|
this.draftQueue = draftQueue;
|
|
@@ -1102,6 +1105,7 @@ class AbstractResourceRequestActionHandler {
|
|
|
1102
1105
|
this.isLdsIdempotencyWriteDisabled = ldsIdempotencyWriteDisabled.isOpen({
|
|
1103
1106
|
fallback: false,
|
|
1104
1107
|
});
|
|
1108
|
+
this.isBackdatingEnabled = ldsBackdatingEnabled.isOpen({ fallback: false });
|
|
1105
1109
|
}
|
|
1106
1110
|
enqueue(data) {
|
|
1107
1111
|
return this.draftQueue.enqueue(this.handlerId, data);
|
|
@@ -1172,6 +1176,17 @@ class AbstractResourceRequestActionHandler {
|
|
|
1172
1176
|
}
|
|
1173
1177
|
}
|
|
1174
1178
|
}
|
|
1179
|
+
if (this.isBackdatingEnabled &&
|
|
1180
|
+
response.status === HttpStatusCode.BadRequest &&
|
|
1181
|
+
this.isBackdatingError(response.body, action)) {
|
|
1182
|
+
updatedAction.timestamp = Date.now();
|
|
1183
|
+
updatedAction.data.body.fields = {
|
|
1184
|
+
...updatedAction.data.body.fields,
|
|
1185
|
+
LastModifiedDate: new Date(updatedAction.timestamp).toISOString(),
|
|
1186
|
+
};
|
|
1187
|
+
shouldRetry = true;
|
|
1188
|
+
actionDataChanged = true;
|
|
1189
|
+
}
|
|
1175
1190
|
await actionErrored(shouldRetry
|
|
1176
1191
|
? updatedAction
|
|
1177
1192
|
: {
|
|
@@ -1205,7 +1220,21 @@ class AbstractResourceRequestActionHandler {
|
|
|
1205
1220
|
}
|
|
1206
1221
|
// checks if the body is an array of UiApiError. Sometimes the body has `enhancedErrorType` field as an error indicator(one example is the field validation failure). In such case Action being processed updates to an Error Action.
|
|
1207
1222
|
isUiApiErrors(body) {
|
|
1208
|
-
return body !== undefined &&
|
|
1223
|
+
return body !== undefined && isArray(body) && body.length > 0 && body[0].errorCode;
|
|
1224
|
+
}
|
|
1225
|
+
isBackdatingError(body, action) {
|
|
1226
|
+
if (body.enhancedErrorType &&
|
|
1227
|
+
body.enhancedErrorType === 'RecordError' &&
|
|
1228
|
+
body.output &&
|
|
1229
|
+
body.output.errors &&
|
|
1230
|
+
isArray(body.output.errors) &&
|
|
1231
|
+
body.output.errors.length > 0 &&
|
|
1232
|
+
action.data.body &&
|
|
1233
|
+
action.data.body.fields &&
|
|
1234
|
+
action.data.body.fields[DEFAULT_FIELD_LAST_MODIFIED_DATE]) {
|
|
1235
|
+
return body.output.errors.some((error) => error.errorCode === 'CollisionDetectedException');
|
|
1236
|
+
}
|
|
1237
|
+
return false;
|
|
1209
1238
|
}
|
|
1210
1239
|
async buildPendingAction(request, queue) {
|
|
1211
1240
|
const targetId = await this.getIdFromRequest(request);
|
|
@@ -1891,4 +1920,4 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
|
|
|
1891
1920
|
});
|
|
1892
1921
|
}
|
|
1893
1922
|
|
|
1894
|
-
export { AbstractResourceRequestActionHandler, CustomActionResultType, DRAFT_ERROR_CODE, DRAFT_ID_MAPPINGS_SEGMENT, DRAFT_SEGMENT, DraftActionOperationType, DraftActionStatus, DraftErrorFetchResponse, DraftFetchResponse, DraftManager, DraftQueueEventType, DraftQueueState, DraftSynthesisError, DurableDraftQueue, DurableDraftStore, ProcessActionResult, buildLuvioOverrideForDraftAdapters, createBadRequestResponse, createDeletedResponse, createDraftSynthesisErrorResponse, createInternalErrorResponse, createNotFoundResponse, createOkResponse, generateUniqueDraftActionId, isDraftSynthesisError, makeEnvironmentDraftAware, transformErrorToDraftSynthesisError };
|
|
1923
|
+
export { AbstractResourceRequestActionHandler, CustomActionResultType, DEFAULT_FIELD_CREATED_DATE, DEFAULT_FIELD_LAST_MODIFIED_DATE, DRAFT_ERROR_CODE, DRAFT_ID_MAPPINGS_SEGMENT, DRAFT_SEGMENT, DraftActionOperationType, DraftActionStatus, DraftErrorFetchResponse, DraftFetchResponse, DraftManager, DraftQueueEventType, DraftQueueState, DraftSynthesisError, DurableDraftQueue, DurableDraftStore, ProcessActionResult, buildLuvioOverrideForDraftAdapters, createBadRequestResponse, createDeletedResponse, createDraftSynthesisErrorResponse, createInternalErrorResponse, createNotFoundResponse, createOkResponse, generateUniqueDraftActionId, isDraftSynthesisError, makeEnvironmentDraftAware, transformErrorToDraftSynthesisError };
|
|
@@ -7,6 +7,8 @@ export type ResponseIngestionEntry<T = unknown> = {
|
|
|
7
7
|
synchronousIngest: AbstractResourceRequestActionHandler<T, unknown>['synchronousIngest'];
|
|
8
8
|
buildCacheKeysForResponse: AbstractResourceRequestActionHandler<T, unknown>['buildCacheKeysFromResponse'];
|
|
9
9
|
};
|
|
10
|
+
export declare const DEFAULT_FIELD_LAST_MODIFIED_DATE = "LastModifiedDate";
|
|
11
|
+
export declare const DEFAULT_FIELD_CREATED_DATE = "CreatedDate";
|
|
10
12
|
export declare abstract class AbstractResourceRequestActionHandler<ResponseType, DraftMetadata> implements ActionHandler<ResourceRequest, DraftMetadata, ResponseType> {
|
|
11
13
|
protected readonly draftQueue: DraftQueue;
|
|
12
14
|
protected readonly networkAdapter: NetworkAdapter;
|
|
@@ -16,11 +18,13 @@ export declare abstract class AbstractResourceRequestActionHandler<ResponseType,
|
|
|
16
18
|
};
|
|
17
19
|
isIdempotencySupported: boolean;
|
|
18
20
|
isLdsIdempotencyWriteDisabled: boolean;
|
|
21
|
+
isBackdatingEnabled: boolean;
|
|
19
22
|
constructor(draftQueue: DraftQueue, networkAdapter: NetworkAdapter, getLuvio: () => Luvio);
|
|
20
23
|
enqueue(data: ResourceRequest): Promise<EnqueueResult<ResourceRequest, ResponseType>>;
|
|
21
24
|
handleAction(action: DraftAction<ResourceRequest, ResponseType>, actionCompleted: (action: CompletedDraftAction<ResourceRequest, ResponseType>) => Promise<void>, actionErrored: (action: DraftAction<ResourceRequest, ResponseType>, retry: boolean, retryDelayInMs?: number, actionDataChanged?: boolean) => Promise<void>): Promise<ProcessActionResult>;
|
|
22
25
|
handleIdempotencyServerError(responseBody: any, action: DraftAction<ResourceRequest, ResponseType>, updateIdempotencyKey: boolean, ...targetErrorCodes: string[]): boolean;
|
|
23
26
|
isUiApiErrors(body: any): boolean;
|
|
27
|
+
isBackdatingError(body: any, action: DraftAction<ResourceRequest, ResponseType>): any;
|
|
24
28
|
buildPendingAction(request: ResourceRequest, queue: DraftAction<unknown, unknown>[]): Promise<PendingDraftAction<ResourceRequest>>;
|
|
25
29
|
handleActionEnqueued(action: PendingDraftAction<ResourceRequest>): Promise<void>;
|
|
26
30
|
handleActionRemoved(action: DraftAction<ResourceRequest, ResponseType>): Promise<void>;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { DraftManager, DraftManagerState, DraftActionOperationType, DraftQueueIt
|
|
|
9
9
|
export { ActionHandler, ReplacingActions, DraftIdAndKeyMapping, } from './actionHandlers/ActionHandler';
|
|
10
10
|
export type { CustomActionResult } from './actionHandlers/CustomActionHandler';
|
|
11
11
|
export { CustomActionResultType, CustomActionExecutor } from './actionHandlers/CustomActionHandler';
|
|
12
|
-
export { AbstractResourceRequestActionHandler, ResponseIngestionEntry, } from './actionHandlers/AbstractResourceRequestActionHandler';
|
|
12
|
+
export { AbstractResourceRequestActionHandler, ResponseIngestionEntry, DEFAULT_FIELD_CREATED_DATE, DEFAULT_FIELD_LAST_MODIFIED_DATE, } from './actionHandlers/AbstractResourceRequestActionHandler';
|
|
13
13
|
export { makeEnvironmentDraftAware } from './makeEnvironmentDraftAware';
|
|
14
14
|
export type { DraftAwareEnvironment } from './makeEnvironmentDraftAware';
|
|
15
15
|
export * from './DraftFetchResponse';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-drafts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.256.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": "
|
|
27
|
+
"@luvio/engine": "0.154.3",
|
|
28
|
+
"@luvio/environments": "0.154.3",
|
|
29
|
+
"@salesforce/lds-utils-adapters": "^1.256.0"
|
|
30
30
|
}
|
|
31
31
|
}
|