@salesforce/lds-worker-api 1.283.0 → 1.285.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/sfdc/es/ldsWorkerApi.js +60 -48
- package/dist/sfdc/es/types/executeAdapter.d.ts +16 -6
- package/dist/sfdc/es/types/main.d.ts +2 -2
- package/dist/standalone/es/lds-worker-api.js +333 -146
- package/dist/standalone/es/types/executeAdapter.d.ts +16 -6
- package/dist/standalone/es/types/main.d.ts +2 -2
- package/dist/standalone/umd/lds-worker-api.js +333 -145
- package/dist/standalone/umd/types/executeAdapter.d.ts +16 -6
- package/dist/standalone/umd/types/main.d.ts +2 -2
- package/package.json +12 -12
|
@@ -338,63 +338,75 @@ function invokeDmlAdapter(adapter, configObject, onResponse, nativeAdapterReques
|
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
/**
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
341
|
+
* @deprecated There is no situation in which any consumer actually wants to replace the draft.
|
|
342
|
+
* call {@link invokeAdapterWithDraftToMerge} instead`.
|
|
343
|
+
* Keep it for now for app back compatibility.
|
|
344
|
+
* Will be removed in future, ideally 2 releases later.
|
|
345
|
+
*/
|
|
346
|
+
function invokeAdapterWithDraftToReplace(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
|
|
347
|
+
invokeAdapterWithDraftToMerge(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Executes the specified adapter with the given @param dapterId and @param config. Then
|
|
351
|
+
* it merge the draft with the given id with the draft generated by
|
|
352
|
+
* the mutating adapter. Will call onResult callback once with data or error.
|
|
344
353
|
*
|
|
345
354
|
* This function throws an error if the given adapterId cannot be found, or if the
|
|
346
|
-
* adapterId is not a mutating adapter
|
|
347
|
-
* fails to parse the given config string.
|
|
355
|
+
* adapterId is not a mutating adapter if a draft isn't created, or
|
|
356
|
+
* if it fails to parse the given config string.
|
|
357
|
+
*
|
|
358
|
+
* If the @param adapterId is deleteRecod, the invocation of it will generate a delele draft.
|
|
359
|
+
* The newly generated delete draft will replace the draft specified by @param targetDraftId
|
|
348
360
|
*/
|
|
349
|
-
function
|
|
361
|
+
function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onResponse, nativeAdapterRequestContext) {
|
|
362
|
+
const adapter = getDMLAdapterFromName(adapterId);
|
|
363
|
+
if (adapter === undefined) {
|
|
364
|
+
// Check if the adapter is non-mutating adapter and create proper error message.
|
|
365
|
+
const message = getImperativeAdapterFromName(imperativeAdapterKeyBuilder(adapterId)) !== undefined
|
|
366
|
+
? NON_MUTATING_ADAPTER_MESSAGE
|
|
367
|
+
: `adapter ${adapterId} not recognized`;
|
|
368
|
+
onResponse({
|
|
369
|
+
data: undefined,
|
|
370
|
+
error: createNativeFetchErrorResponse(message),
|
|
371
|
+
});
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
// deleteRecord adapter call will generate a delete draft and
|
|
375
|
+
// the newly generate draft will replace the target draft
|
|
376
|
+
if (adapterId === 'deleteRecord') {
|
|
377
|
+
invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, onResponse, nativeAdapterRequestContext);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
350
380
|
draftManager.getQueue().then((draftInfo) => {
|
|
351
381
|
const draftIds = draftInfo.items.map((draft) => draft.id);
|
|
352
|
-
if (draftIds.includes(
|
|
382
|
+
if (draftIds.includes(targetDraftId) === false) {
|
|
353
383
|
onResponse({
|
|
354
384
|
data: undefined,
|
|
355
385
|
error: createNativeFetchErrorResponse(DRAFT_DOESNT_EXIST_MESSAGE),
|
|
356
386
|
});
|
|
357
387
|
return;
|
|
358
388
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
389
|
+
invokeDmlAdapter(adapter, parse(config), (responseValue) => {
|
|
390
|
+
const draftIds = draftIdsForResponseValue(responseValue);
|
|
391
|
+
if (responseValue.error === undefined &&
|
|
392
|
+
draftIds !== undefined &&
|
|
393
|
+
draftIds.length > 0) {
|
|
394
|
+
const draftId = draftIds[draftIds.length - 1];
|
|
395
|
+
draftManager
|
|
396
|
+
.mergeActions(targetDraftId, draftId)
|
|
397
|
+
.then(() => {
|
|
398
|
+
onResponse(responseValue);
|
|
399
|
+
})
|
|
400
|
+
.catch((error) => {
|
|
401
|
+
onResponse(convertErrorIntoNativeFetchError(error, `Unknown error merging draft`));
|
|
367
402
|
});
|
|
368
|
-
return;
|
|
369
403
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
invokeDmlAdapter(adapter, parse(config), (responseValue) => {
|
|
377
|
-
const draftIds = draftIdsForResponseValue(responseValue);
|
|
378
|
-
if (responseValue.error === undefined &&
|
|
379
|
-
draftIds !== undefined &&
|
|
380
|
-
draftIds.length > 0) {
|
|
381
|
-
const draftId = draftIds[draftIds.length - 1];
|
|
382
|
-
draftManager
|
|
383
|
-
.replaceAction(draftIdToReplace, draftId)
|
|
384
|
-
.then(() => {
|
|
385
|
-
onResponse(responseValue);
|
|
386
|
-
})
|
|
387
|
-
.catch((error) => {
|
|
388
|
-
onResponse(convertErrorIntoNativeFetchError(error, 'Unknown error replacing draft'));
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
let response = responseValue;
|
|
393
|
-
response.error = createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE);
|
|
394
|
-
onResponse(response);
|
|
395
|
-
}
|
|
396
|
-
}, nativeAdapterRequestContext);
|
|
397
|
-
}
|
|
404
|
+
else {
|
|
405
|
+
let response = responseValue;
|
|
406
|
+
response.error = createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE);
|
|
407
|
+
onResponse(response);
|
|
408
|
+
}
|
|
409
|
+
}, nativeAdapterRequestContext);
|
|
398
410
|
});
|
|
399
411
|
}
|
|
400
412
|
/**
|
|
@@ -502,11 +514,11 @@ function invokeAdapterWithMetadataDeleteRecord(adapter, config, metadata, onResp
|
|
|
502
514
|
}
|
|
503
515
|
/*
|
|
504
516
|
//TODO W-10284305: Remove this function in 238
|
|
505
|
-
This is a special case version of the
|
|
517
|
+
This is a special case version of the invokeAdapterWithDraftToMerge function
|
|
506
518
|
which should only be used for the deleteRecord wire adapter, since it does not
|
|
507
519
|
contain record data in the result and has to do special querying of the draft queue
|
|
508
520
|
*/
|
|
509
|
-
function
|
|
521
|
+
function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
|
|
510
522
|
const targetedRecordId = parse(config);
|
|
511
523
|
let priorDraftIds;
|
|
512
524
|
draftManager.getQueue().then((draftState) => {
|
|
@@ -1061,5 +1073,5 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1061
1073
|
});
|
|
1062
1074
|
}
|
|
1063
1075
|
|
|
1064
|
-
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
1065
|
-
// version: 1.
|
|
1076
|
+
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
1077
|
+
// version: 1.285.0-67d4d6869
|
|
@@ -47,15 +47,25 @@ export declare function buildAdapterRequestContext(nativeRequestContext: NativeA
|
|
|
47
47
|
*/
|
|
48
48
|
export declare function subscribeToAdapter(adapterId: string, config: string, onSnapshot: NativeOnSnapshot, nativeAdapterRequestContext?: NativeAdapterRequestContext): Unsubscribe;
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* @deprecated There is no situation in which any consumer actually wants to replace the draft.
|
|
51
|
+
* call {@link invokeAdapterWithDraftToMerge} instead`.
|
|
52
|
+
* Keep it for now for app back compatibility.
|
|
53
|
+
* Will be removed in future, ideally 2 releases later.
|
|
54
|
+
*/
|
|
55
|
+
export declare function invokeAdapterWithDraftToReplace(adapterId: string, config: string, draftIdToReplace: string, onResponse: NativeOnResponse, nativeAdapterRequestContext?: NativeAdapterRequestContext): void;
|
|
56
|
+
/**
|
|
57
|
+
* Executes the specified adapter with the given @param dapterId and @param config. Then
|
|
58
|
+
* it merge the draft with the given id with the draft generated by
|
|
59
|
+
* the mutating adapter. Will call onResult callback once with data or error.
|
|
53
60
|
*
|
|
54
61
|
* This function throws an error if the given adapterId cannot be found, or if the
|
|
55
|
-
* adapterId is not a mutating adapter
|
|
56
|
-
* fails to parse the given config string.
|
|
62
|
+
* adapterId is not a mutating adapter if a draft isn't created, or
|
|
63
|
+
* if it fails to parse the given config string.
|
|
64
|
+
*
|
|
65
|
+
* If the @param adapterId is deleteRecod, the invocation of it will generate a delele draft.
|
|
66
|
+
* The newly generated delete draft will replace the draft specified by @param targetDraftId
|
|
57
67
|
*/
|
|
58
|
-
export declare function
|
|
68
|
+
export declare function invokeAdapterWithDraftToMerge(adapterId: string, config: string, targetDraftId: string, onResponse: NativeOnResponse, nativeAdapterRequestContext?: NativeAdapterRequestContext): void;
|
|
59
69
|
/**
|
|
60
70
|
* Executes the specified adapter with the given adapterId and config. Then
|
|
61
71
|
* it sets the given metadata on the draft created by the mutating adapter. Will call
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, executeAdapter, executeMutatingAdapter } from './executeAdapter';
|
|
1
|
+
import { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, executeAdapter, executeMutatingAdapter } from './executeAdapter';
|
|
2
2
|
import { getImperativeAdapterNames } from './lightningAdapterApi';
|
|
3
3
|
import { nimbusDraftQueue } from './nimbusDraftQueue';
|
|
4
4
|
import { draftQueue, draftManager } from './draftQueueImplementation';
|
|
@@ -6,4 +6,4 @@ import { setUiApiRecordTTL, setMetadataTTL } from './ttl';
|
|
|
6
6
|
import { registerReportObserver } from '@salesforce/lds-runtime-mobile';
|
|
7
7
|
import { createPrimingSession } from './primingApi';
|
|
8
8
|
import { evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction } from './cachePurging';
|
|
9
|
-
export { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, executeAdapter, executeMutatingAdapter, nimbusDraftQueue, draftQueue, draftManager, setUiApiRecordTTL, setMetadataTTL, registerReportObserver, getImperativeAdapterNames, createPrimingSession, evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction, };
|
|
9
|
+
export { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, executeAdapter, executeMutatingAdapter, nimbusDraftQueue, draftQueue, draftManager, setUiApiRecordTTL, setMetadataTTL, registerReportObserver, getImperativeAdapterNames, createPrimingSession, evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction, };
|