@salesforce/lds-worker-api 1.163.1 → 1.163.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.
|
@@ -770,4 +770,4 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
770
770
|
}
|
|
771
771
|
|
|
772
772
|
export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
|
|
773
|
-
// version: 1.163.
|
|
773
|
+
// version: 1.163.2-1950176a9
|
|
@@ -3799,7 +3799,7 @@ function withDefaultLuvio(callback) {
|
|
|
3799
3799
|
}
|
|
3800
3800
|
callbacks.push(callback);
|
|
3801
3801
|
}
|
|
3802
|
-
// version: 1.163.
|
|
3802
|
+
// version: 1.163.2-1950176a9
|
|
3803
3803
|
|
|
3804
3804
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
3805
3805
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -15232,7 +15232,7 @@ function parseAndVisit(source) {
|
|
|
15232
15232
|
updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
|
|
15233
15233
|
return luvioDocumentNode;
|
|
15234
15234
|
}
|
|
15235
|
-
// version: 1.163.
|
|
15235
|
+
// version: 1.163.2-1950176a9
|
|
15236
15236
|
|
|
15237
15237
|
function unwrap(data) {
|
|
15238
15238
|
// The lwc-luvio bindings import a function from lwc called "unwrap".
|
|
@@ -16145,7 +16145,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
|
|
|
16145
16145
|
const { apiFamily, name } = metadata;
|
|
16146
16146
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
16147
16147
|
}
|
|
16148
|
-
// version: 1.163.
|
|
16148
|
+
// version: 1.163.2-1950176a9
|
|
16149
16149
|
|
|
16150
16150
|
/**
|
|
16151
16151
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -44016,7 +44016,7 @@ withDefaultLuvio((luvio) => {
|
|
|
44016
44016
|
dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
|
|
44017
44017
|
});
|
|
44018
44018
|
});
|
|
44019
|
-
// version: 1.163.
|
|
44019
|
+
// version: 1.163.2-2fcc92bea
|
|
44020
44020
|
|
|
44021
44021
|
var caseSensitiveUserId = '005B0000000GR4OIAW';
|
|
44022
44022
|
|
|
@@ -54877,6 +54877,14 @@ function getRecordKeyFromRecordRequest(luvio, resourceRequest) {
|
|
|
54877
54877
|
function getRecordKeyForId(luvio, recordId) {
|
|
54878
54878
|
return keyBuilder$1R(luvio, { recordId });
|
|
54879
54879
|
}
|
|
54880
|
+
/**
|
|
54881
|
+
* Drafts are stored with denormalized fields and normalized field links. This method
|
|
54882
|
+
* filters out the field links and returns a flattened record representation.
|
|
54883
|
+
*
|
|
54884
|
+
* Note that reference field links get re-applied during draft record ingestion
|
|
54885
|
+
* @param record draft record representation
|
|
54886
|
+
* @returns flattened record representation
|
|
54887
|
+
*/
|
|
54880
54888
|
function filterOutReferenceFieldsAndLinks(record) {
|
|
54881
54889
|
const filteredFields = {};
|
|
54882
54890
|
const fieldNames = keys$2$1(record.fields);
|
|
@@ -54895,32 +54903,6 @@ function filterOutReferenceFieldsAndLinks(record) {
|
|
|
54895
54903
|
delete filteredRecords.links;
|
|
54896
54904
|
return filteredRecords;
|
|
54897
54905
|
}
|
|
54898
|
-
async function resolveReferencesOneLevelDeep(record, getRecordFromKey) {
|
|
54899
|
-
const fieldNames = keys$2$1(record.fields);
|
|
54900
|
-
const resolvedFields = {};
|
|
54901
|
-
for (const fieldName of fieldNames) {
|
|
54902
|
-
const field = record.fields[fieldName];
|
|
54903
|
-
if (isFieldLink(field)) {
|
|
54904
|
-
const denormalizedRecord = await getRecordFromKey(field.value.__ref);
|
|
54905
|
-
if (denormalizedRecord !== undefined) {
|
|
54906
|
-
resolvedFields[fieldName] = {
|
|
54907
|
-
value: filterOutReferenceFieldsAndLinks(denormalizedRecord),
|
|
54908
|
-
displayValue: null,
|
|
54909
|
-
};
|
|
54910
|
-
}
|
|
54911
|
-
else {
|
|
54912
|
-
resolvedFields[fieldName] = {
|
|
54913
|
-
value: null,
|
|
54914
|
-
displayValue: null,
|
|
54915
|
-
};
|
|
54916
|
-
}
|
|
54917
|
-
}
|
|
54918
|
-
else {
|
|
54919
|
-
resolvedFields[fieldName] = field;
|
|
54920
|
-
}
|
|
54921
|
-
}
|
|
54922
|
-
return { ...record, fields: resolvedFields };
|
|
54923
|
-
}
|
|
54924
54906
|
|
|
54925
54907
|
/**
|
|
54926
54908
|
* Checks if a resource request is a GET method on the record endpoint
|
|
@@ -55217,11 +55199,15 @@ const DEFAULT_FIELD_RECORD_TYPE_ID = 'RecordTypeId';
|
|
|
55217
55199
|
*/
|
|
55218
55200
|
function replayDraftsOnRecord(record, draftMetadata) {
|
|
55219
55201
|
let objectInfo;
|
|
55202
|
+
let luvio;
|
|
55220
55203
|
if (record && draftMetadata) {
|
|
55221
55204
|
objectInfo = draftMetadata.objectInfos.get(record.apiName);
|
|
55222
55205
|
}
|
|
55206
|
+
if (draftMetadata) {
|
|
55207
|
+
luvio = draftMetadata.luvio;
|
|
55208
|
+
}
|
|
55223
55209
|
// remove drafts before reapply
|
|
55224
|
-
const baseRecord = record === undefined ? undefined : removeDrafts(record, objectInfo);
|
|
55210
|
+
const baseRecord = record === undefined ? undefined : removeDrafts(record, luvio, objectInfo);
|
|
55225
55211
|
// record is a draft create
|
|
55226
55212
|
if (baseRecord === undefined) {
|
|
55227
55213
|
if (draftMetadata === undefined) {
|
|
@@ -55344,7 +55330,7 @@ function recursivelyApplyDraftsToRecord(record, draftMetadata, recordOperations)
|
|
|
55344
55330
|
* @param record record with drafts applied
|
|
55345
55331
|
* @returns
|
|
55346
55332
|
*/
|
|
55347
|
-
function removeDrafts(record, objectInfo) {
|
|
55333
|
+
function removeDrafts(record, luvio, objectInfo) {
|
|
55348
55334
|
const { drafts, fields } = record;
|
|
55349
55335
|
if (drafts === undefined) {
|
|
55350
55336
|
return record;
|
|
@@ -55360,6 +55346,12 @@ function removeDrafts(record, objectInfo) {
|
|
|
55360
55346
|
const originalField = drafts.serverValues[fieldName];
|
|
55361
55347
|
if (originalField !== undefined) {
|
|
55362
55348
|
updatedFields[fieldName] = originalField;
|
|
55349
|
+
if (objectInfo && luvio) {
|
|
55350
|
+
const reference = getReferenceInfoForKey(fieldName, originalField, luvio, objectInfo);
|
|
55351
|
+
if (reference) {
|
|
55352
|
+
updatedFields[reference.referenceFieldName] = reference.field;
|
|
55353
|
+
}
|
|
55354
|
+
}
|
|
55363
55355
|
// restore the record type id on the root of the record
|
|
55364
55356
|
if (fieldName === DEFAULT_FIELD_RECORD_TYPE_ID) {
|
|
55365
55357
|
const originalRecordTypeId = originalField.value;
|
|
@@ -55397,7 +55389,6 @@ function removeDrafts(record, objectInfo) {
|
|
|
55397
55389
|
* @param fields List of draft record fields
|
|
55398
55390
|
*/
|
|
55399
55391
|
function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fields, objectInfos, referencedRecords, formatDisplayValue) {
|
|
55400
|
-
var _a;
|
|
55401
55392
|
const fieldNames = keys$2$1(fields);
|
|
55402
55393
|
const recordFields = {};
|
|
55403
55394
|
const objectInfo = objectInfos.get(apiName);
|
|
@@ -55411,7 +55402,7 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
|
|
|
55411
55402
|
if (objectInfo !== undefined) {
|
|
55412
55403
|
const fieldInfo = objectInfo.fields[fieldName];
|
|
55413
55404
|
if (fieldInfo !== undefined) {
|
|
55414
|
-
const { dataType
|
|
55405
|
+
const { dataType } = fieldInfo;
|
|
55415
55406
|
recordFields[fieldName].displayValue = formatDisplayValue(draftField, dataType);
|
|
55416
55407
|
if (dataType === 'DateTime' &&
|
|
55417
55408
|
draftField !== null &&
|
|
@@ -55423,46 +55414,6 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
|
|
|
55423
55414
|
throw Error('date field value not valid');
|
|
55424
55415
|
}
|
|
55425
55416
|
}
|
|
55426
|
-
if (dataType === 'Reference' && relationshipName !== null && draftField !== null) {
|
|
55427
|
-
if (typeof draftField !== 'string') {
|
|
55428
|
-
throw Error('reference field value is not a string');
|
|
55429
|
-
}
|
|
55430
|
-
const key = getRecordKeyForId(luvio, draftField);
|
|
55431
|
-
const referencedRecord = referencedRecords.get(key);
|
|
55432
|
-
if (referencedRecord) {
|
|
55433
|
-
recordFields[relationshipName] = {
|
|
55434
|
-
displayValue: null,
|
|
55435
|
-
value: createLink$2(key),
|
|
55436
|
-
};
|
|
55437
|
-
}
|
|
55438
|
-
else {
|
|
55439
|
-
recordFields[relationshipName] = {
|
|
55440
|
-
displayValue: null,
|
|
55441
|
-
value: null,
|
|
55442
|
-
};
|
|
55443
|
-
}
|
|
55444
|
-
// for custom objects, we select the 'Name' field
|
|
55445
|
-
// otherwise we check the object info for name fields.
|
|
55446
|
-
//if there are multiple we select 'Name' if it exists, otherwise the first one
|
|
55447
|
-
if (referencedRecord !== undefined && referenceToInfos.length > 0) {
|
|
55448
|
-
let nameField;
|
|
55449
|
-
const referenceToInfo = referenceToInfos[0];
|
|
55450
|
-
const nameFields = referenceToInfo.nameFields;
|
|
55451
|
-
if (nameFields.length !== 0) {
|
|
55452
|
-
nameField = nameFields.find((x) => x === 'Name');
|
|
55453
|
-
if (nameField === undefined) {
|
|
55454
|
-
nameField = nameFields[0];
|
|
55455
|
-
}
|
|
55456
|
-
}
|
|
55457
|
-
if (nameField !== undefined) {
|
|
55458
|
-
const nameFieldRef = referencedRecord.fields[nameField];
|
|
55459
|
-
if (nameFieldRef) {
|
|
55460
|
-
recordFields[relationshipName].displayValue =
|
|
55461
|
-
(_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
|
|
55462
|
-
}
|
|
55463
|
-
}
|
|
55464
|
-
}
|
|
55465
|
-
}
|
|
55466
55417
|
}
|
|
55467
55418
|
}
|
|
55468
55419
|
}
|
|
@@ -55536,9 +55487,78 @@ function buildSyntheticRecordRepresentation(luvio, createOperation, userId, obje
|
|
|
55536
55487
|
},
|
|
55537
55488
|
};
|
|
55538
55489
|
}
|
|
55490
|
+
function applyReferenceLinksToDraft(record, draftMetadata) {
|
|
55491
|
+
var _a;
|
|
55492
|
+
const { objectInfos, referencedRecords, luvio } = draftMetadata;
|
|
55493
|
+
const objectInfo = objectInfos.get(record.apiName);
|
|
55494
|
+
if (objectInfo === undefined) {
|
|
55495
|
+
return record;
|
|
55496
|
+
}
|
|
55497
|
+
let fieldNames = Object.keys(record.fields);
|
|
55498
|
+
const recordFields = { ...record.fields };
|
|
55499
|
+
for (const draftField of fieldNames) {
|
|
55500
|
+
const fieldInfo = objectInfo.fields[draftField];
|
|
55501
|
+
if (fieldInfo === undefined) {
|
|
55502
|
+
continue;
|
|
55503
|
+
}
|
|
55504
|
+
const { dataType, relationshipName, referenceToInfos } = fieldInfo;
|
|
55505
|
+
const draftFieldValue = record.fields[draftField].value;
|
|
55506
|
+
if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
|
|
55507
|
+
if (typeof draftFieldValue !== 'string') {
|
|
55508
|
+
throw Error('reference field value is not a string');
|
|
55509
|
+
}
|
|
55510
|
+
const key = getRecordKeyForId(luvio, draftFieldValue);
|
|
55511
|
+
const referencedRecord = referencedRecords.get(key);
|
|
55512
|
+
recordFields[relationshipName] = {
|
|
55513
|
+
displayValue: null,
|
|
55514
|
+
value: createLink$2(key),
|
|
55515
|
+
};
|
|
55516
|
+
// for custom objects, we select the 'Name' field
|
|
55517
|
+
// otherwise we check the object info for name fields.
|
|
55518
|
+
//if there are multiple we select 'Name' if it exists, otherwise the first one
|
|
55519
|
+
if (referencedRecord !== undefined && referenceToInfos.length > 0) {
|
|
55520
|
+
let nameField;
|
|
55521
|
+
const referenceToInfo = referenceToInfos[0];
|
|
55522
|
+
const nameFields = referenceToInfo.nameFields;
|
|
55523
|
+
if (nameFields.length !== 0) {
|
|
55524
|
+
nameField = nameFields.find((x) => x === 'Name');
|
|
55525
|
+
if (nameField === undefined) {
|
|
55526
|
+
nameField = nameFields[0];
|
|
55527
|
+
}
|
|
55528
|
+
}
|
|
55529
|
+
if (nameField !== undefined) {
|
|
55530
|
+
const nameFieldRef = referencedRecord.fields[nameField];
|
|
55531
|
+
if (nameFieldRef) {
|
|
55532
|
+
recordFields[relationshipName].displayValue =
|
|
55533
|
+
(_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
|
|
55534
|
+
}
|
|
55535
|
+
}
|
|
55536
|
+
}
|
|
55537
|
+
}
|
|
55538
|
+
}
|
|
55539
|
+
return { ...record, fields: recordFields };
|
|
55540
|
+
}
|
|
55539
55541
|
function createLink$2(key) {
|
|
55540
55542
|
return { __ref: key };
|
|
55541
55543
|
}
|
|
55544
|
+
function getReferenceInfoForKey(fieldName, field, luvio, objectInfo) {
|
|
55545
|
+
const { dataType, relationshipName } = objectInfo.fields[fieldName];
|
|
55546
|
+
const draftFieldValue = field.value;
|
|
55547
|
+
if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
|
|
55548
|
+
if (typeof draftFieldValue !== 'string') {
|
|
55549
|
+
throw Error('reference field value is not a string');
|
|
55550
|
+
}
|
|
55551
|
+
const key = getRecordKeyForId(luvio, draftFieldValue);
|
|
55552
|
+
return {
|
|
55553
|
+
referenceFieldName: relationshipName,
|
|
55554
|
+
field: {
|
|
55555
|
+
displayValue: null,
|
|
55556
|
+
value: createLink$2(key),
|
|
55557
|
+
},
|
|
55558
|
+
};
|
|
55559
|
+
}
|
|
55560
|
+
return undefined;
|
|
55561
|
+
}
|
|
55542
55562
|
|
|
55543
55563
|
async function getAdapterData(adapter, config) {
|
|
55544
55564
|
const snapshot = await adapter(config);
|
|
@@ -55730,8 +55750,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
55730
55750
|
*
|
|
55731
55751
|
* @param action The draft action related to this record
|
|
55732
55752
|
* @param _queue The draft queue
|
|
55733
|
-
* @returns The record with the updated draft queue applied.
|
|
55734
|
-
* deep to ensure that reference links are properly established during ingestion to it
|
|
55753
|
+
* @returns The record with the updated draft queue applied. References are not included and must be applied at ingest.
|
|
55735
55754
|
*
|
|
55736
55755
|
* or
|
|
55737
55756
|
*
|
|
@@ -55755,7 +55774,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
55755
55774
|
if (recordWithDrafts === undefined) {
|
|
55756
55775
|
return undefined;
|
|
55757
55776
|
}
|
|
55758
|
-
return
|
|
55777
|
+
return filterOutReferenceFieldsAndLinks(recordWithDrafts);
|
|
55759
55778
|
}
|
|
55760
55779
|
const record = await this.durableStore.getDenormalizedRecord(key);
|
|
55761
55780
|
if (record === undefined) {
|
|
@@ -55766,7 +55785,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
55766
55785
|
if (recordWithDrafts === undefined) {
|
|
55767
55786
|
return recordWithDrafts;
|
|
55768
55787
|
}
|
|
55769
|
-
return
|
|
55788
|
+
return filterOutReferenceFieldsAndLinks(recordWithDrafts);
|
|
55770
55789
|
}
|
|
55771
55790
|
applyDraftsToIncomingData(key, data, draftMetadata, publishData) {
|
|
55772
55791
|
if (isField(key)) {
|
|
@@ -55793,19 +55812,26 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
55793
55812
|
}
|
|
55794
55813
|
}
|
|
55795
55814
|
const recordWithDrafts = replayDraftsOnRecord(partialRecord, draftMetadata);
|
|
55815
|
+
const recordWithSpanningRefLinks = applyReferenceLinksToDraft(recordWithDrafts, draftMetadata);
|
|
55796
55816
|
// publish the normalized fields
|
|
55797
55817
|
const normalizedRecord = {
|
|
55798
|
-
...
|
|
55818
|
+
...recordWithSpanningRefLinks,
|
|
55799
55819
|
...data,
|
|
55800
55820
|
fields: { ...data.fields },
|
|
55801
55821
|
};
|
|
55802
|
-
for (const fieldName of
|
|
55822
|
+
for (const fieldName of keys$2$1(recordWithSpanningRefLinks.fields)) {
|
|
55803
55823
|
const fieldKey = buildRecordFieldStoreKey(key, fieldName);
|
|
55804
55824
|
if (this.collectedFields[fieldKey] !== undefined) {
|
|
55805
|
-
const fieldData =
|
|
55825
|
+
const fieldData = recordWithSpanningRefLinks.fields[fieldName];
|
|
55806
55826
|
normalizedRecord.fields[fieldName] = { __ref: fieldKey };
|
|
55807
55827
|
publishData(fieldKey, fieldData);
|
|
55808
55828
|
}
|
|
55829
|
+
else if (recordWithSpanningRefLinks.fields[fieldName] &&
|
|
55830
|
+
recordWithSpanningRefLinks.fields[fieldName].value &&
|
|
55831
|
+
recordWithSpanningRefLinks.fields[fieldName].value.__ref !== undefined) {
|
|
55832
|
+
normalizedRecord.fields[fieldName] = { __ref: fieldKey };
|
|
55833
|
+
publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
|
|
55834
|
+
}
|
|
55809
55835
|
}
|
|
55810
55836
|
// publish the normalized record
|
|
55811
55837
|
publishData(key, normalizedRecord);
|
|
@@ -56983,27 +57009,10 @@ class ContentDocumentCompositeRepresentationActionHandler extends AbstractResour
|
|
|
56983
57009
|
if (contentVersion === undefined) {
|
|
56984
57010
|
return undefined;
|
|
56985
57011
|
}
|
|
56986
|
-
// this lambda can be shared across the calls to resolveReferencesOneLevelDeep
|
|
56987
|
-
const luvio = this.getLuvio();
|
|
56988
|
-
const contentDocumentKey = getRecordKeyForId(luvio, contentDocumentId);
|
|
56989
|
-
const contentDocumentLinkKey = getRecordKeyForId(luvio, contentDocumentLinkId);
|
|
56990
|
-
const contentVersionKey = getRecordKeyForId(luvio, contentVersionId);
|
|
56991
|
-
const getRecordFromKey = async (key) => {
|
|
56992
|
-
if (key === contentDocumentKey) {
|
|
56993
|
-
return contentDocRecord;
|
|
56994
|
-
}
|
|
56995
|
-
if (key === contentDocumentLinkKey) {
|
|
56996
|
-
return contentDocLink;
|
|
56997
|
-
}
|
|
56998
|
-
if (key === contentVersionKey) {
|
|
56999
|
-
return contentVersion;
|
|
57000
|
-
}
|
|
57001
|
-
return this.durableStore.getDenormalizedRecord(key);
|
|
57002
|
-
};
|
|
57003
57012
|
// finally we resolve all references for each record
|
|
57004
|
-
const contentDocResolved = await
|
|
57005
|
-
const contentDocLinkResolved = await
|
|
57006
|
-
const contentVersionResolved = await
|
|
57013
|
+
const contentDocResolved = await filterOutReferenceFieldsAndLinks(contentDocRecord);
|
|
57014
|
+
const contentDocLinkResolved = await filterOutReferenceFieldsAndLinks(contentDocLink);
|
|
57015
|
+
const contentVersionResolved = await filterOutReferenceFieldsAndLinks(contentVersion);
|
|
57007
57016
|
return {
|
|
57008
57017
|
contentDocument: contentDocResolved,
|
|
57009
57018
|
contentDocumentLinks: [contentDocLinkResolved],
|
|
@@ -60106,7 +60115,7 @@ register({
|
|
|
60106
60115
|
id: '@salesforce/lds-network-adapter',
|
|
60107
60116
|
instrument: instrument$1,
|
|
60108
60117
|
});
|
|
60109
|
-
// version: 1.163.
|
|
60118
|
+
// version: 1.163.2-1950176a9
|
|
60110
60119
|
|
|
60111
60120
|
const { create: create$2, keys: keys$2 } = Object;
|
|
60112
60121
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -77588,7 +77597,7 @@ register({
|
|
|
77588
77597
|
configuration: { ...configurationForGraphQLAdapters },
|
|
77589
77598
|
instrument,
|
|
77590
77599
|
});
|
|
77591
|
-
// version: 1.163.
|
|
77600
|
+
// version: 1.163.2-2fcc92bea
|
|
77592
77601
|
|
|
77593
77602
|
// On core the unstable adapters are re-exported with different names,
|
|
77594
77603
|
|
|
@@ -79835,7 +79844,7 @@ withDefaultLuvio((luvio) => {
|
|
|
79835
79844
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
79836
79845
|
graphQLImperative = ldsAdapter;
|
|
79837
79846
|
});
|
|
79838
|
-
// version: 1.163.
|
|
79847
|
+
// version: 1.163.2-2fcc92bea
|
|
79839
79848
|
|
|
79840
79849
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
79841
79850
|
__proto__: null,
|
|
@@ -80524,4 +80533,4 @@ const { luvio } = getRuntime();
|
|
|
80524
80533
|
setDefaultLuvio({ luvio });
|
|
80525
80534
|
|
|
80526
80535
|
export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
|
|
80527
|
-
// version: 1.163.
|
|
80536
|
+
// version: 1.163.2-1950176a9
|
|
@@ -3805,7 +3805,7 @@
|
|
|
3805
3805
|
}
|
|
3806
3806
|
callbacks.push(callback);
|
|
3807
3807
|
}
|
|
3808
|
-
// version: 1.163.
|
|
3808
|
+
// version: 1.163.2-1950176a9
|
|
3809
3809
|
|
|
3810
3810
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
3811
3811
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -15238,7 +15238,7 @@
|
|
|
15238
15238
|
updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
|
|
15239
15239
|
return luvioDocumentNode;
|
|
15240
15240
|
}
|
|
15241
|
-
// version: 1.163.
|
|
15241
|
+
// version: 1.163.2-1950176a9
|
|
15242
15242
|
|
|
15243
15243
|
function unwrap(data) {
|
|
15244
15244
|
// The lwc-luvio bindings import a function from lwc called "unwrap".
|
|
@@ -16151,7 +16151,7 @@
|
|
|
16151
16151
|
const { apiFamily, name } = metadata;
|
|
16152
16152
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
16153
16153
|
}
|
|
16154
|
-
// version: 1.163.
|
|
16154
|
+
// version: 1.163.2-1950176a9
|
|
16155
16155
|
|
|
16156
16156
|
/**
|
|
16157
16157
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -44022,7 +44022,7 @@
|
|
|
44022
44022
|
dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
|
|
44023
44023
|
});
|
|
44024
44024
|
});
|
|
44025
|
-
// version: 1.163.
|
|
44025
|
+
// version: 1.163.2-2fcc92bea
|
|
44026
44026
|
|
|
44027
44027
|
var caseSensitiveUserId = '005B0000000GR4OIAW';
|
|
44028
44028
|
|
|
@@ -54883,6 +54883,14 @@
|
|
|
54883
54883
|
function getRecordKeyForId(luvio, recordId) {
|
|
54884
54884
|
return keyBuilder$1R(luvio, { recordId });
|
|
54885
54885
|
}
|
|
54886
|
+
/**
|
|
54887
|
+
* Drafts are stored with denormalized fields and normalized field links. This method
|
|
54888
|
+
* filters out the field links and returns a flattened record representation.
|
|
54889
|
+
*
|
|
54890
|
+
* Note that reference field links get re-applied during draft record ingestion
|
|
54891
|
+
* @param record draft record representation
|
|
54892
|
+
* @returns flattened record representation
|
|
54893
|
+
*/
|
|
54886
54894
|
function filterOutReferenceFieldsAndLinks(record) {
|
|
54887
54895
|
const filteredFields = {};
|
|
54888
54896
|
const fieldNames = keys$2$1(record.fields);
|
|
@@ -54901,32 +54909,6 @@
|
|
|
54901
54909
|
delete filteredRecords.links;
|
|
54902
54910
|
return filteredRecords;
|
|
54903
54911
|
}
|
|
54904
|
-
async function resolveReferencesOneLevelDeep(record, getRecordFromKey) {
|
|
54905
|
-
const fieldNames = keys$2$1(record.fields);
|
|
54906
|
-
const resolvedFields = {};
|
|
54907
|
-
for (const fieldName of fieldNames) {
|
|
54908
|
-
const field = record.fields[fieldName];
|
|
54909
|
-
if (isFieldLink(field)) {
|
|
54910
|
-
const denormalizedRecord = await getRecordFromKey(field.value.__ref);
|
|
54911
|
-
if (denormalizedRecord !== undefined) {
|
|
54912
|
-
resolvedFields[fieldName] = {
|
|
54913
|
-
value: filterOutReferenceFieldsAndLinks(denormalizedRecord),
|
|
54914
|
-
displayValue: null,
|
|
54915
|
-
};
|
|
54916
|
-
}
|
|
54917
|
-
else {
|
|
54918
|
-
resolvedFields[fieldName] = {
|
|
54919
|
-
value: null,
|
|
54920
|
-
displayValue: null,
|
|
54921
|
-
};
|
|
54922
|
-
}
|
|
54923
|
-
}
|
|
54924
|
-
else {
|
|
54925
|
-
resolvedFields[fieldName] = field;
|
|
54926
|
-
}
|
|
54927
|
-
}
|
|
54928
|
-
return { ...record, fields: resolvedFields };
|
|
54929
|
-
}
|
|
54930
54912
|
|
|
54931
54913
|
/**
|
|
54932
54914
|
* Checks if a resource request is a GET method on the record endpoint
|
|
@@ -55223,11 +55205,15 @@
|
|
|
55223
55205
|
*/
|
|
55224
55206
|
function replayDraftsOnRecord(record, draftMetadata) {
|
|
55225
55207
|
let objectInfo;
|
|
55208
|
+
let luvio;
|
|
55226
55209
|
if (record && draftMetadata) {
|
|
55227
55210
|
objectInfo = draftMetadata.objectInfos.get(record.apiName);
|
|
55228
55211
|
}
|
|
55212
|
+
if (draftMetadata) {
|
|
55213
|
+
luvio = draftMetadata.luvio;
|
|
55214
|
+
}
|
|
55229
55215
|
// remove drafts before reapply
|
|
55230
|
-
const baseRecord = record === undefined ? undefined : removeDrafts(record, objectInfo);
|
|
55216
|
+
const baseRecord = record === undefined ? undefined : removeDrafts(record, luvio, objectInfo);
|
|
55231
55217
|
// record is a draft create
|
|
55232
55218
|
if (baseRecord === undefined) {
|
|
55233
55219
|
if (draftMetadata === undefined) {
|
|
@@ -55350,7 +55336,7 @@
|
|
|
55350
55336
|
* @param record record with drafts applied
|
|
55351
55337
|
* @returns
|
|
55352
55338
|
*/
|
|
55353
|
-
function removeDrafts(record, objectInfo) {
|
|
55339
|
+
function removeDrafts(record, luvio, objectInfo) {
|
|
55354
55340
|
const { drafts, fields } = record;
|
|
55355
55341
|
if (drafts === undefined) {
|
|
55356
55342
|
return record;
|
|
@@ -55366,6 +55352,12 @@
|
|
|
55366
55352
|
const originalField = drafts.serverValues[fieldName];
|
|
55367
55353
|
if (originalField !== undefined) {
|
|
55368
55354
|
updatedFields[fieldName] = originalField;
|
|
55355
|
+
if (objectInfo && luvio) {
|
|
55356
|
+
const reference = getReferenceInfoForKey(fieldName, originalField, luvio, objectInfo);
|
|
55357
|
+
if (reference) {
|
|
55358
|
+
updatedFields[reference.referenceFieldName] = reference.field;
|
|
55359
|
+
}
|
|
55360
|
+
}
|
|
55369
55361
|
// restore the record type id on the root of the record
|
|
55370
55362
|
if (fieldName === DEFAULT_FIELD_RECORD_TYPE_ID) {
|
|
55371
55363
|
const originalRecordTypeId = originalField.value;
|
|
@@ -55403,7 +55395,6 @@
|
|
|
55403
55395
|
* @param fields List of draft record fields
|
|
55404
55396
|
*/
|
|
55405
55397
|
function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fields, objectInfos, referencedRecords, formatDisplayValue) {
|
|
55406
|
-
var _a;
|
|
55407
55398
|
const fieldNames = keys$2$1(fields);
|
|
55408
55399
|
const recordFields = {};
|
|
55409
55400
|
const objectInfo = objectInfos.get(apiName);
|
|
@@ -55417,7 +55408,7 @@
|
|
|
55417
55408
|
if (objectInfo !== undefined) {
|
|
55418
55409
|
const fieldInfo = objectInfo.fields[fieldName];
|
|
55419
55410
|
if (fieldInfo !== undefined) {
|
|
55420
|
-
const { dataType
|
|
55411
|
+
const { dataType } = fieldInfo;
|
|
55421
55412
|
recordFields[fieldName].displayValue = formatDisplayValue(draftField, dataType);
|
|
55422
55413
|
if (dataType === 'DateTime' &&
|
|
55423
55414
|
draftField !== null &&
|
|
@@ -55429,46 +55420,6 @@
|
|
|
55429
55420
|
throw Error('date field value not valid');
|
|
55430
55421
|
}
|
|
55431
55422
|
}
|
|
55432
|
-
if (dataType === 'Reference' && relationshipName !== null && draftField !== null) {
|
|
55433
|
-
if (typeof draftField !== 'string') {
|
|
55434
|
-
throw Error('reference field value is not a string');
|
|
55435
|
-
}
|
|
55436
|
-
const key = getRecordKeyForId(luvio, draftField);
|
|
55437
|
-
const referencedRecord = referencedRecords.get(key);
|
|
55438
|
-
if (referencedRecord) {
|
|
55439
|
-
recordFields[relationshipName] = {
|
|
55440
|
-
displayValue: null,
|
|
55441
|
-
value: createLink$2(key),
|
|
55442
|
-
};
|
|
55443
|
-
}
|
|
55444
|
-
else {
|
|
55445
|
-
recordFields[relationshipName] = {
|
|
55446
|
-
displayValue: null,
|
|
55447
|
-
value: null,
|
|
55448
|
-
};
|
|
55449
|
-
}
|
|
55450
|
-
// for custom objects, we select the 'Name' field
|
|
55451
|
-
// otherwise we check the object info for name fields.
|
|
55452
|
-
//if there are multiple we select 'Name' if it exists, otherwise the first one
|
|
55453
|
-
if (referencedRecord !== undefined && referenceToInfos.length > 0) {
|
|
55454
|
-
let nameField;
|
|
55455
|
-
const referenceToInfo = referenceToInfos[0];
|
|
55456
|
-
const nameFields = referenceToInfo.nameFields;
|
|
55457
|
-
if (nameFields.length !== 0) {
|
|
55458
|
-
nameField = nameFields.find((x) => x === 'Name');
|
|
55459
|
-
if (nameField === undefined) {
|
|
55460
|
-
nameField = nameFields[0];
|
|
55461
|
-
}
|
|
55462
|
-
}
|
|
55463
|
-
if (nameField !== undefined) {
|
|
55464
|
-
const nameFieldRef = referencedRecord.fields[nameField];
|
|
55465
|
-
if (nameFieldRef) {
|
|
55466
|
-
recordFields[relationshipName].displayValue =
|
|
55467
|
-
(_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
|
|
55468
|
-
}
|
|
55469
|
-
}
|
|
55470
|
-
}
|
|
55471
|
-
}
|
|
55472
55423
|
}
|
|
55473
55424
|
}
|
|
55474
55425
|
}
|
|
@@ -55542,9 +55493,78 @@
|
|
|
55542
55493
|
},
|
|
55543
55494
|
};
|
|
55544
55495
|
}
|
|
55496
|
+
function applyReferenceLinksToDraft(record, draftMetadata) {
|
|
55497
|
+
var _a;
|
|
55498
|
+
const { objectInfos, referencedRecords, luvio } = draftMetadata;
|
|
55499
|
+
const objectInfo = objectInfos.get(record.apiName);
|
|
55500
|
+
if (objectInfo === undefined) {
|
|
55501
|
+
return record;
|
|
55502
|
+
}
|
|
55503
|
+
let fieldNames = Object.keys(record.fields);
|
|
55504
|
+
const recordFields = { ...record.fields };
|
|
55505
|
+
for (const draftField of fieldNames) {
|
|
55506
|
+
const fieldInfo = objectInfo.fields[draftField];
|
|
55507
|
+
if (fieldInfo === undefined) {
|
|
55508
|
+
continue;
|
|
55509
|
+
}
|
|
55510
|
+
const { dataType, relationshipName, referenceToInfos } = fieldInfo;
|
|
55511
|
+
const draftFieldValue = record.fields[draftField].value;
|
|
55512
|
+
if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
|
|
55513
|
+
if (typeof draftFieldValue !== 'string') {
|
|
55514
|
+
throw Error('reference field value is not a string');
|
|
55515
|
+
}
|
|
55516
|
+
const key = getRecordKeyForId(luvio, draftFieldValue);
|
|
55517
|
+
const referencedRecord = referencedRecords.get(key);
|
|
55518
|
+
recordFields[relationshipName] = {
|
|
55519
|
+
displayValue: null,
|
|
55520
|
+
value: createLink$2(key),
|
|
55521
|
+
};
|
|
55522
|
+
// for custom objects, we select the 'Name' field
|
|
55523
|
+
// otherwise we check the object info for name fields.
|
|
55524
|
+
//if there are multiple we select 'Name' if it exists, otherwise the first one
|
|
55525
|
+
if (referencedRecord !== undefined && referenceToInfos.length > 0) {
|
|
55526
|
+
let nameField;
|
|
55527
|
+
const referenceToInfo = referenceToInfos[0];
|
|
55528
|
+
const nameFields = referenceToInfo.nameFields;
|
|
55529
|
+
if (nameFields.length !== 0) {
|
|
55530
|
+
nameField = nameFields.find((x) => x === 'Name');
|
|
55531
|
+
if (nameField === undefined) {
|
|
55532
|
+
nameField = nameFields[0];
|
|
55533
|
+
}
|
|
55534
|
+
}
|
|
55535
|
+
if (nameField !== undefined) {
|
|
55536
|
+
const nameFieldRef = referencedRecord.fields[nameField];
|
|
55537
|
+
if (nameFieldRef) {
|
|
55538
|
+
recordFields[relationshipName].displayValue =
|
|
55539
|
+
(_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
|
|
55540
|
+
}
|
|
55541
|
+
}
|
|
55542
|
+
}
|
|
55543
|
+
}
|
|
55544
|
+
}
|
|
55545
|
+
return { ...record, fields: recordFields };
|
|
55546
|
+
}
|
|
55545
55547
|
function createLink$2(key) {
|
|
55546
55548
|
return { __ref: key };
|
|
55547
55549
|
}
|
|
55550
|
+
function getReferenceInfoForKey(fieldName, field, luvio, objectInfo) {
|
|
55551
|
+
const { dataType, relationshipName } = objectInfo.fields[fieldName];
|
|
55552
|
+
const draftFieldValue = field.value;
|
|
55553
|
+
if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
|
|
55554
|
+
if (typeof draftFieldValue !== 'string') {
|
|
55555
|
+
throw Error('reference field value is not a string');
|
|
55556
|
+
}
|
|
55557
|
+
const key = getRecordKeyForId(luvio, draftFieldValue);
|
|
55558
|
+
return {
|
|
55559
|
+
referenceFieldName: relationshipName,
|
|
55560
|
+
field: {
|
|
55561
|
+
displayValue: null,
|
|
55562
|
+
value: createLink$2(key),
|
|
55563
|
+
},
|
|
55564
|
+
};
|
|
55565
|
+
}
|
|
55566
|
+
return undefined;
|
|
55567
|
+
}
|
|
55548
55568
|
|
|
55549
55569
|
async function getAdapterData(adapter, config) {
|
|
55550
55570
|
const snapshot = await adapter(config);
|
|
@@ -55736,8 +55756,7 @@
|
|
|
55736
55756
|
*
|
|
55737
55757
|
* @param action The draft action related to this record
|
|
55738
55758
|
* @param _queue The draft queue
|
|
55739
|
-
* @returns The record with the updated draft queue applied.
|
|
55740
|
-
* deep to ensure that reference links are properly established during ingestion to it
|
|
55759
|
+
* @returns The record with the updated draft queue applied. References are not included and must be applied at ingest.
|
|
55741
55760
|
*
|
|
55742
55761
|
* or
|
|
55743
55762
|
*
|
|
@@ -55761,7 +55780,7 @@
|
|
|
55761
55780
|
if (recordWithDrafts === undefined) {
|
|
55762
55781
|
return undefined;
|
|
55763
55782
|
}
|
|
55764
|
-
return
|
|
55783
|
+
return filterOutReferenceFieldsAndLinks(recordWithDrafts);
|
|
55765
55784
|
}
|
|
55766
55785
|
const record = await this.durableStore.getDenormalizedRecord(key);
|
|
55767
55786
|
if (record === undefined) {
|
|
@@ -55772,7 +55791,7 @@
|
|
|
55772
55791
|
if (recordWithDrafts === undefined) {
|
|
55773
55792
|
return recordWithDrafts;
|
|
55774
55793
|
}
|
|
55775
|
-
return
|
|
55794
|
+
return filterOutReferenceFieldsAndLinks(recordWithDrafts);
|
|
55776
55795
|
}
|
|
55777
55796
|
applyDraftsToIncomingData(key, data, draftMetadata, publishData) {
|
|
55778
55797
|
if (isField(key)) {
|
|
@@ -55799,19 +55818,26 @@
|
|
|
55799
55818
|
}
|
|
55800
55819
|
}
|
|
55801
55820
|
const recordWithDrafts = replayDraftsOnRecord(partialRecord, draftMetadata);
|
|
55821
|
+
const recordWithSpanningRefLinks = applyReferenceLinksToDraft(recordWithDrafts, draftMetadata);
|
|
55802
55822
|
// publish the normalized fields
|
|
55803
55823
|
const normalizedRecord = {
|
|
55804
|
-
...
|
|
55824
|
+
...recordWithSpanningRefLinks,
|
|
55805
55825
|
...data,
|
|
55806
55826
|
fields: { ...data.fields },
|
|
55807
55827
|
};
|
|
55808
|
-
for (const fieldName of
|
|
55828
|
+
for (const fieldName of keys$2$1(recordWithSpanningRefLinks.fields)) {
|
|
55809
55829
|
const fieldKey = buildRecordFieldStoreKey(key, fieldName);
|
|
55810
55830
|
if (this.collectedFields[fieldKey] !== undefined) {
|
|
55811
|
-
const fieldData =
|
|
55831
|
+
const fieldData = recordWithSpanningRefLinks.fields[fieldName];
|
|
55812
55832
|
normalizedRecord.fields[fieldName] = { __ref: fieldKey };
|
|
55813
55833
|
publishData(fieldKey, fieldData);
|
|
55814
55834
|
}
|
|
55835
|
+
else if (recordWithSpanningRefLinks.fields[fieldName] &&
|
|
55836
|
+
recordWithSpanningRefLinks.fields[fieldName].value &&
|
|
55837
|
+
recordWithSpanningRefLinks.fields[fieldName].value.__ref !== undefined) {
|
|
55838
|
+
normalizedRecord.fields[fieldName] = { __ref: fieldKey };
|
|
55839
|
+
publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
|
|
55840
|
+
}
|
|
55815
55841
|
}
|
|
55816
55842
|
// publish the normalized record
|
|
55817
55843
|
publishData(key, normalizedRecord);
|
|
@@ -56989,27 +57015,10 @@
|
|
|
56989
57015
|
if (contentVersion === undefined) {
|
|
56990
57016
|
return undefined;
|
|
56991
57017
|
}
|
|
56992
|
-
// this lambda can be shared across the calls to resolveReferencesOneLevelDeep
|
|
56993
|
-
const luvio = this.getLuvio();
|
|
56994
|
-
const contentDocumentKey = getRecordKeyForId(luvio, contentDocumentId);
|
|
56995
|
-
const contentDocumentLinkKey = getRecordKeyForId(luvio, contentDocumentLinkId);
|
|
56996
|
-
const contentVersionKey = getRecordKeyForId(luvio, contentVersionId);
|
|
56997
|
-
const getRecordFromKey = async (key) => {
|
|
56998
|
-
if (key === contentDocumentKey) {
|
|
56999
|
-
return contentDocRecord;
|
|
57000
|
-
}
|
|
57001
|
-
if (key === contentDocumentLinkKey) {
|
|
57002
|
-
return contentDocLink;
|
|
57003
|
-
}
|
|
57004
|
-
if (key === contentVersionKey) {
|
|
57005
|
-
return contentVersion;
|
|
57006
|
-
}
|
|
57007
|
-
return this.durableStore.getDenormalizedRecord(key);
|
|
57008
|
-
};
|
|
57009
57018
|
// finally we resolve all references for each record
|
|
57010
|
-
const contentDocResolved = await
|
|
57011
|
-
const contentDocLinkResolved = await
|
|
57012
|
-
const contentVersionResolved = await
|
|
57019
|
+
const contentDocResolved = await filterOutReferenceFieldsAndLinks(contentDocRecord);
|
|
57020
|
+
const contentDocLinkResolved = await filterOutReferenceFieldsAndLinks(contentDocLink);
|
|
57021
|
+
const contentVersionResolved = await filterOutReferenceFieldsAndLinks(contentVersion);
|
|
57013
57022
|
return {
|
|
57014
57023
|
contentDocument: contentDocResolved,
|
|
57015
57024
|
contentDocumentLinks: [contentDocLinkResolved],
|
|
@@ -60112,7 +60121,7 @@
|
|
|
60112
60121
|
id: '@salesforce/lds-network-adapter',
|
|
60113
60122
|
instrument: instrument$1,
|
|
60114
60123
|
});
|
|
60115
|
-
// version: 1.163.
|
|
60124
|
+
// version: 1.163.2-1950176a9
|
|
60116
60125
|
|
|
60117
60126
|
const { create: create$2, keys: keys$2 } = Object;
|
|
60118
60127
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -77594,7 +77603,7 @@
|
|
|
77594
77603
|
configuration: { ...configurationForGraphQLAdapters },
|
|
77595
77604
|
instrument,
|
|
77596
77605
|
});
|
|
77597
|
-
// version: 1.163.
|
|
77606
|
+
// version: 1.163.2-2fcc92bea
|
|
77598
77607
|
|
|
77599
77608
|
// On core the unstable adapters are re-exported with different names,
|
|
77600
77609
|
|
|
@@ -79841,7 +79850,7 @@
|
|
|
79841
79850
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
79842
79851
|
graphQLImperative = ldsAdapter;
|
|
79843
79852
|
});
|
|
79844
|
-
// version: 1.163.
|
|
79853
|
+
// version: 1.163.2-2fcc92bea
|
|
79845
79854
|
|
|
79846
79855
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
79847
79856
|
__proto__: null,
|
|
@@ -80547,4 +80556,4 @@
|
|
|
80547
80556
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
80548
80557
|
|
|
80549
80558
|
}));
|
|
80550
|
-
// version: 1.163.
|
|
80559
|
+
// version: 1.163.2-1950176a9
|