@salesforce/lwc-adapters-uiapi 1.213.1 → 1.213.2
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/main.js +46 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -51526,9 +51526,54 @@ function selectType$6(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
51526
51526
|
return sink;
|
|
51527
51527
|
}
|
|
51528
51528
|
|
|
51529
|
+
/**
|
|
51530
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
51531
|
+
* All rights reserved.
|
|
51532
|
+
* For full license text, see the LICENSE.txt file
|
|
51533
|
+
*/
|
|
51534
|
+
|
|
51535
|
+
const API_NAMESPACE = 'UiApi';
|
|
51536
|
+
const RECORD_REPRESENTATION_NAME = 'RecordRepresentation';
|
|
51537
|
+
const RECORD_VIEW_ENTITY_REPRESENTATION_NAME = 'RecordViewEntityRepresentation';
|
|
51538
|
+
const RECORD_ID_PREFIX = `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME}:`;
|
|
51539
|
+
const RECORD_VIEW_ENTITY_ID_PREFIX = `${API_NAMESPACE}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME}:Name:`;
|
|
51540
|
+
const RECORD_FIELDS_KEY_JUNCTION = '__fields__';
|
|
51541
|
+
function isStoreKeyRecordViewEntity(key) {
|
|
51542
|
+
return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) > -1 &&
|
|
51543
|
+
key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1);
|
|
51544
|
+
}
|
|
51545
|
+
function extractRecordIdFromStoreKey(key) {
|
|
51546
|
+
if (key === undefined ||
|
|
51547
|
+
(key.indexOf(RECORD_ID_PREFIX) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) === -1)) {
|
|
51548
|
+
return undefined;
|
|
51549
|
+
}
|
|
51550
|
+
const parts = key.split(':');
|
|
51551
|
+
return parts[parts.length - 1].split('_')[0];
|
|
51552
|
+
}
|
|
51553
|
+
function buildRecordRepKeyFromId(recordId) {
|
|
51554
|
+
return `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME}:${recordId}`;
|
|
51555
|
+
}
|
|
51556
|
+
|
|
51529
51557
|
function attachMappedData(source, reader) {
|
|
51530
|
-
|
|
51558
|
+
let linkedRecordId = source.__link && source.__link.__ref;
|
|
51531
51559
|
if (linkedRecordId !== undefined) {
|
|
51560
|
+
// Discovered with: W-13612372
|
|
51561
|
+
// We get wrong apiName for polymorphic parents when using getRecord
|
|
51562
|
+
// this breaks store links as it essentially creates wrong keys
|
|
51563
|
+
// also worth noting that polymorphic parents from REST are stored in RecordViewEntityRepresentation
|
|
51564
|
+
// while polymorphic parents from graphql are just another RecordRepresentation
|
|
51565
|
+
// Here, if we see a RecordViewEntityRepresentation key then we point it to
|
|
51566
|
+
// corresponding RecordRepresentation key that graphql adapter can understand
|
|
51567
|
+
// this essentially also means that polymorphic parent Records can be inconsistent
|
|
51568
|
+
// across graphql and getRecord snapshots and subsequent requests from getRecord
|
|
51569
|
+
// to fetch the referenced parent record directly
|
|
51570
|
+
// This behavior is at parity with getRecord wire adapter
|
|
51571
|
+
if (isStoreKeyRecordViewEntity(linkedRecordId)) {
|
|
51572
|
+
const recordId = extractRecordIdFromStoreKey(linkedRecordId);
|
|
51573
|
+
if (recordId) {
|
|
51574
|
+
linkedRecordId = buildRecordRepKeyFromId(recordId);
|
|
51575
|
+
}
|
|
51576
|
+
}
|
|
51532
51577
|
reader.markSeenId(linkedRecordId);
|
|
51533
51578
|
const linkedData = reader.read({
|
|
51534
51579
|
recordId: linkedRecordId,
|