@salesforce/lds-runtime-mobile 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.
- package/dist/main.js +107 -98
- package/package.json +1 -1
- package/sfdc/main.js +107 -98
package/dist/main.js
CHANGED
|
@@ -10796,6 +10796,14 @@ function getRecordKeyFromRecordRequest(luvio, resourceRequest) {
|
|
|
10796
10796
|
function getRecordKeyForId(luvio, recordId) {
|
|
10797
10797
|
return keyBuilderRecord(luvio, { recordId });
|
|
10798
10798
|
}
|
|
10799
|
+
/**
|
|
10800
|
+
* Drafts are stored with denormalized fields and normalized field links. This method
|
|
10801
|
+
* filters out the field links and returns a flattened record representation.
|
|
10802
|
+
*
|
|
10803
|
+
* Note that reference field links get re-applied during draft record ingestion
|
|
10804
|
+
* @param record draft record representation
|
|
10805
|
+
* @returns flattened record representation
|
|
10806
|
+
*/
|
|
10799
10807
|
function filterOutReferenceFieldsAndLinks(record) {
|
|
10800
10808
|
const filteredFields = {};
|
|
10801
10809
|
const fieldNames = keys$2(record.fields);
|
|
@@ -10814,32 +10822,6 @@ function filterOutReferenceFieldsAndLinks(record) {
|
|
|
10814
10822
|
delete filteredRecords.links;
|
|
10815
10823
|
return filteredRecords;
|
|
10816
10824
|
}
|
|
10817
|
-
async function resolveReferencesOneLevelDeep(record, getRecordFromKey) {
|
|
10818
|
-
const fieldNames = keys$2(record.fields);
|
|
10819
|
-
const resolvedFields = {};
|
|
10820
|
-
for (const fieldName of fieldNames) {
|
|
10821
|
-
const field = record.fields[fieldName];
|
|
10822
|
-
if (isFieldLink(field)) {
|
|
10823
|
-
const denormalizedRecord = await getRecordFromKey(field.value.__ref);
|
|
10824
|
-
if (denormalizedRecord !== undefined) {
|
|
10825
|
-
resolvedFields[fieldName] = {
|
|
10826
|
-
value: filterOutReferenceFieldsAndLinks(denormalizedRecord),
|
|
10827
|
-
displayValue: null,
|
|
10828
|
-
};
|
|
10829
|
-
}
|
|
10830
|
-
else {
|
|
10831
|
-
resolvedFields[fieldName] = {
|
|
10832
|
-
value: null,
|
|
10833
|
-
displayValue: null,
|
|
10834
|
-
};
|
|
10835
|
-
}
|
|
10836
|
-
}
|
|
10837
|
-
else {
|
|
10838
|
-
resolvedFields[fieldName] = field;
|
|
10839
|
-
}
|
|
10840
|
-
}
|
|
10841
|
-
return { ...record, fields: resolvedFields };
|
|
10842
|
-
}
|
|
10843
10825
|
|
|
10844
10826
|
/**
|
|
10845
10827
|
* Checks if a resource request is a GET method on the record endpoint
|
|
@@ -11136,11 +11118,15 @@ const DEFAULT_FIELD_RECORD_TYPE_ID = 'RecordTypeId';
|
|
|
11136
11118
|
*/
|
|
11137
11119
|
function replayDraftsOnRecord(record, draftMetadata) {
|
|
11138
11120
|
let objectInfo;
|
|
11121
|
+
let luvio;
|
|
11139
11122
|
if (record && draftMetadata) {
|
|
11140
11123
|
objectInfo = draftMetadata.objectInfos.get(record.apiName);
|
|
11141
11124
|
}
|
|
11125
|
+
if (draftMetadata) {
|
|
11126
|
+
luvio = draftMetadata.luvio;
|
|
11127
|
+
}
|
|
11142
11128
|
// remove drafts before reapply
|
|
11143
|
-
const baseRecord = record === undefined ? undefined : removeDrafts(record, objectInfo);
|
|
11129
|
+
const baseRecord = record === undefined ? undefined : removeDrafts(record, luvio, objectInfo);
|
|
11144
11130
|
// record is a draft create
|
|
11145
11131
|
if (baseRecord === undefined) {
|
|
11146
11132
|
if (draftMetadata === undefined) {
|
|
@@ -11263,7 +11249,7 @@ function recursivelyApplyDraftsToRecord(record, draftMetadata, recordOperations)
|
|
|
11263
11249
|
* @param record record with drafts applied
|
|
11264
11250
|
* @returns
|
|
11265
11251
|
*/
|
|
11266
|
-
function removeDrafts(record, objectInfo) {
|
|
11252
|
+
function removeDrafts(record, luvio, objectInfo) {
|
|
11267
11253
|
const { drafts, fields } = record;
|
|
11268
11254
|
if (drafts === undefined) {
|
|
11269
11255
|
return record;
|
|
@@ -11279,6 +11265,12 @@ function removeDrafts(record, objectInfo) {
|
|
|
11279
11265
|
const originalField = drafts.serverValues[fieldName];
|
|
11280
11266
|
if (originalField !== undefined) {
|
|
11281
11267
|
updatedFields[fieldName] = originalField;
|
|
11268
|
+
if (objectInfo && luvio) {
|
|
11269
|
+
const reference = getReferenceInfoForKey(fieldName, originalField, luvio, objectInfo);
|
|
11270
|
+
if (reference) {
|
|
11271
|
+
updatedFields[reference.referenceFieldName] = reference.field;
|
|
11272
|
+
}
|
|
11273
|
+
}
|
|
11282
11274
|
// restore the record type id on the root of the record
|
|
11283
11275
|
if (fieldName === DEFAULT_FIELD_RECORD_TYPE_ID) {
|
|
11284
11276
|
const originalRecordTypeId = originalField.value;
|
|
@@ -11316,7 +11308,6 @@ function removeDrafts(record, objectInfo) {
|
|
|
11316
11308
|
* @param fields List of draft record fields
|
|
11317
11309
|
*/
|
|
11318
11310
|
function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fields, objectInfos, referencedRecords, formatDisplayValue) {
|
|
11319
|
-
var _a;
|
|
11320
11311
|
const fieldNames = keys$2(fields);
|
|
11321
11312
|
const recordFields = {};
|
|
11322
11313
|
const objectInfo = objectInfos.get(apiName);
|
|
@@ -11330,7 +11321,7 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
|
|
|
11330
11321
|
if (objectInfo !== undefined) {
|
|
11331
11322
|
const fieldInfo = objectInfo.fields[fieldName];
|
|
11332
11323
|
if (fieldInfo !== undefined) {
|
|
11333
|
-
const { dataType
|
|
11324
|
+
const { dataType } = fieldInfo;
|
|
11334
11325
|
recordFields[fieldName].displayValue = formatDisplayValue(draftField, dataType);
|
|
11335
11326
|
if (dataType === 'DateTime' &&
|
|
11336
11327
|
draftField !== null &&
|
|
@@ -11342,46 +11333,6 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
|
|
|
11342
11333
|
throw Error('date field value not valid');
|
|
11343
11334
|
}
|
|
11344
11335
|
}
|
|
11345
|
-
if (dataType === 'Reference' && relationshipName !== null && draftField !== null) {
|
|
11346
|
-
if (typeof draftField !== 'string') {
|
|
11347
|
-
throw Error('reference field value is not a string');
|
|
11348
|
-
}
|
|
11349
|
-
const key = getRecordKeyForId(luvio, draftField);
|
|
11350
|
-
const referencedRecord = referencedRecords.get(key);
|
|
11351
|
-
if (referencedRecord) {
|
|
11352
|
-
recordFields[relationshipName] = {
|
|
11353
|
-
displayValue: null,
|
|
11354
|
-
value: createLink(key),
|
|
11355
|
-
};
|
|
11356
|
-
}
|
|
11357
|
-
else {
|
|
11358
|
-
recordFields[relationshipName] = {
|
|
11359
|
-
displayValue: null,
|
|
11360
|
-
value: null,
|
|
11361
|
-
};
|
|
11362
|
-
}
|
|
11363
|
-
// for custom objects, we select the 'Name' field
|
|
11364
|
-
// otherwise we check the object info for name fields.
|
|
11365
|
-
//if there are multiple we select 'Name' if it exists, otherwise the first one
|
|
11366
|
-
if (referencedRecord !== undefined && referenceToInfos.length > 0) {
|
|
11367
|
-
let nameField;
|
|
11368
|
-
const referenceToInfo = referenceToInfos[0];
|
|
11369
|
-
const nameFields = referenceToInfo.nameFields;
|
|
11370
|
-
if (nameFields.length !== 0) {
|
|
11371
|
-
nameField = nameFields.find((x) => x === 'Name');
|
|
11372
|
-
if (nameField === undefined) {
|
|
11373
|
-
nameField = nameFields[0];
|
|
11374
|
-
}
|
|
11375
|
-
}
|
|
11376
|
-
if (nameField !== undefined) {
|
|
11377
|
-
const nameFieldRef = referencedRecord.fields[nameField];
|
|
11378
|
-
if (nameFieldRef) {
|
|
11379
|
-
recordFields[relationshipName].displayValue =
|
|
11380
|
-
(_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
|
|
11381
|
-
}
|
|
11382
|
-
}
|
|
11383
|
-
}
|
|
11384
|
-
}
|
|
11385
11336
|
}
|
|
11386
11337
|
}
|
|
11387
11338
|
}
|
|
@@ -11455,9 +11406,78 @@ function buildSyntheticRecordRepresentation(luvio, createOperation, userId, obje
|
|
|
11455
11406
|
},
|
|
11456
11407
|
};
|
|
11457
11408
|
}
|
|
11409
|
+
function applyReferenceLinksToDraft(record, draftMetadata) {
|
|
11410
|
+
var _a;
|
|
11411
|
+
const { objectInfos, referencedRecords, luvio } = draftMetadata;
|
|
11412
|
+
const objectInfo = objectInfos.get(record.apiName);
|
|
11413
|
+
if (objectInfo === undefined) {
|
|
11414
|
+
return record;
|
|
11415
|
+
}
|
|
11416
|
+
let fieldNames = Object.keys(record.fields);
|
|
11417
|
+
const recordFields = { ...record.fields };
|
|
11418
|
+
for (const draftField of fieldNames) {
|
|
11419
|
+
const fieldInfo = objectInfo.fields[draftField];
|
|
11420
|
+
if (fieldInfo === undefined) {
|
|
11421
|
+
continue;
|
|
11422
|
+
}
|
|
11423
|
+
const { dataType, relationshipName, referenceToInfos } = fieldInfo;
|
|
11424
|
+
const draftFieldValue = record.fields[draftField].value;
|
|
11425
|
+
if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
|
|
11426
|
+
if (typeof draftFieldValue !== 'string') {
|
|
11427
|
+
throw Error('reference field value is not a string');
|
|
11428
|
+
}
|
|
11429
|
+
const key = getRecordKeyForId(luvio, draftFieldValue);
|
|
11430
|
+
const referencedRecord = referencedRecords.get(key);
|
|
11431
|
+
recordFields[relationshipName] = {
|
|
11432
|
+
displayValue: null,
|
|
11433
|
+
value: createLink(key),
|
|
11434
|
+
};
|
|
11435
|
+
// for custom objects, we select the 'Name' field
|
|
11436
|
+
// otherwise we check the object info for name fields.
|
|
11437
|
+
//if there are multiple we select 'Name' if it exists, otherwise the first one
|
|
11438
|
+
if (referencedRecord !== undefined && referenceToInfos.length > 0) {
|
|
11439
|
+
let nameField;
|
|
11440
|
+
const referenceToInfo = referenceToInfos[0];
|
|
11441
|
+
const nameFields = referenceToInfo.nameFields;
|
|
11442
|
+
if (nameFields.length !== 0) {
|
|
11443
|
+
nameField = nameFields.find((x) => x === 'Name');
|
|
11444
|
+
if (nameField === undefined) {
|
|
11445
|
+
nameField = nameFields[0];
|
|
11446
|
+
}
|
|
11447
|
+
}
|
|
11448
|
+
if (nameField !== undefined) {
|
|
11449
|
+
const nameFieldRef = referencedRecord.fields[nameField];
|
|
11450
|
+
if (nameFieldRef) {
|
|
11451
|
+
recordFields[relationshipName].displayValue =
|
|
11452
|
+
(_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
|
|
11453
|
+
}
|
|
11454
|
+
}
|
|
11455
|
+
}
|
|
11456
|
+
}
|
|
11457
|
+
}
|
|
11458
|
+
return { ...record, fields: recordFields };
|
|
11459
|
+
}
|
|
11458
11460
|
function createLink(key) {
|
|
11459
11461
|
return { __ref: key };
|
|
11460
11462
|
}
|
|
11463
|
+
function getReferenceInfoForKey(fieldName, field, luvio, objectInfo) {
|
|
11464
|
+
const { dataType, relationshipName } = objectInfo.fields[fieldName];
|
|
11465
|
+
const draftFieldValue = field.value;
|
|
11466
|
+
if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
|
|
11467
|
+
if (typeof draftFieldValue !== 'string') {
|
|
11468
|
+
throw Error('reference field value is not a string');
|
|
11469
|
+
}
|
|
11470
|
+
const key = getRecordKeyForId(luvio, draftFieldValue);
|
|
11471
|
+
return {
|
|
11472
|
+
referenceFieldName: relationshipName,
|
|
11473
|
+
field: {
|
|
11474
|
+
displayValue: null,
|
|
11475
|
+
value: createLink(key),
|
|
11476
|
+
},
|
|
11477
|
+
};
|
|
11478
|
+
}
|
|
11479
|
+
return undefined;
|
|
11480
|
+
}
|
|
11461
11481
|
|
|
11462
11482
|
async function getAdapterData(adapter, config) {
|
|
11463
11483
|
const snapshot = await adapter(config);
|
|
@@ -11649,8 +11669,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
11649
11669
|
*
|
|
11650
11670
|
* @param action The draft action related to this record
|
|
11651
11671
|
* @param _queue The draft queue
|
|
11652
|
-
* @returns The record with the updated draft queue applied.
|
|
11653
|
-
* deep to ensure that reference links are properly established during ingestion to it
|
|
11672
|
+
* @returns The record with the updated draft queue applied. References are not included and must be applied at ingest.
|
|
11654
11673
|
*
|
|
11655
11674
|
* or
|
|
11656
11675
|
*
|
|
@@ -11674,7 +11693,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
11674
11693
|
if (recordWithDrafts === undefined) {
|
|
11675
11694
|
return undefined;
|
|
11676
11695
|
}
|
|
11677
|
-
return
|
|
11696
|
+
return filterOutReferenceFieldsAndLinks(recordWithDrafts);
|
|
11678
11697
|
}
|
|
11679
11698
|
const record = await this.durableStore.getDenormalizedRecord(key);
|
|
11680
11699
|
if (record === undefined) {
|
|
@@ -11685,7 +11704,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
11685
11704
|
if (recordWithDrafts === undefined) {
|
|
11686
11705
|
return recordWithDrafts;
|
|
11687
11706
|
}
|
|
11688
|
-
return
|
|
11707
|
+
return filterOutReferenceFieldsAndLinks(recordWithDrafts);
|
|
11689
11708
|
}
|
|
11690
11709
|
applyDraftsToIncomingData(key, data, draftMetadata, publishData) {
|
|
11691
11710
|
if (isField(key)) {
|
|
@@ -11712,19 +11731,26 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
11712
11731
|
}
|
|
11713
11732
|
}
|
|
11714
11733
|
const recordWithDrafts = replayDraftsOnRecord(partialRecord, draftMetadata);
|
|
11734
|
+
const recordWithSpanningRefLinks = applyReferenceLinksToDraft(recordWithDrafts, draftMetadata);
|
|
11715
11735
|
// publish the normalized fields
|
|
11716
11736
|
const normalizedRecord = {
|
|
11717
|
-
...
|
|
11737
|
+
...recordWithSpanningRefLinks,
|
|
11718
11738
|
...data,
|
|
11719
11739
|
fields: { ...data.fields },
|
|
11720
11740
|
};
|
|
11721
|
-
for (const fieldName of
|
|
11741
|
+
for (const fieldName of keys$2(recordWithSpanningRefLinks.fields)) {
|
|
11722
11742
|
const fieldKey = buildRecordFieldStoreKey(key, fieldName);
|
|
11723
11743
|
if (this.collectedFields[fieldKey] !== undefined) {
|
|
11724
|
-
const fieldData =
|
|
11744
|
+
const fieldData = recordWithSpanningRefLinks.fields[fieldName];
|
|
11725
11745
|
normalizedRecord.fields[fieldName] = { __ref: fieldKey };
|
|
11726
11746
|
publishData(fieldKey, fieldData);
|
|
11727
11747
|
}
|
|
11748
|
+
else if (recordWithSpanningRefLinks.fields[fieldName] &&
|
|
11749
|
+
recordWithSpanningRefLinks.fields[fieldName].value &&
|
|
11750
|
+
recordWithSpanningRefLinks.fields[fieldName].value.__ref !== undefined) {
|
|
11751
|
+
normalizedRecord.fields[fieldName] = { __ref: fieldKey };
|
|
11752
|
+
publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
|
|
11753
|
+
}
|
|
11728
11754
|
}
|
|
11729
11755
|
// publish the normalized record
|
|
11730
11756
|
publishData(key, normalizedRecord);
|
|
@@ -12902,27 +12928,10 @@ class ContentDocumentCompositeRepresentationActionHandler extends AbstractResour
|
|
|
12902
12928
|
if (contentVersion === undefined) {
|
|
12903
12929
|
return undefined;
|
|
12904
12930
|
}
|
|
12905
|
-
// this lambda can be shared across the calls to resolveReferencesOneLevelDeep
|
|
12906
|
-
const luvio = this.getLuvio();
|
|
12907
|
-
const contentDocumentKey = getRecordKeyForId(luvio, contentDocumentId);
|
|
12908
|
-
const contentDocumentLinkKey = getRecordKeyForId(luvio, contentDocumentLinkId);
|
|
12909
|
-
const contentVersionKey = getRecordKeyForId(luvio, contentVersionId);
|
|
12910
|
-
const getRecordFromKey = async (key) => {
|
|
12911
|
-
if (key === contentDocumentKey) {
|
|
12912
|
-
return contentDocRecord;
|
|
12913
|
-
}
|
|
12914
|
-
if (key === contentDocumentLinkKey) {
|
|
12915
|
-
return contentDocLink;
|
|
12916
|
-
}
|
|
12917
|
-
if (key === contentVersionKey) {
|
|
12918
|
-
return contentVersion;
|
|
12919
|
-
}
|
|
12920
|
-
return this.durableStore.getDenormalizedRecord(key);
|
|
12921
|
-
};
|
|
12922
12931
|
// finally we resolve all references for each record
|
|
12923
|
-
const contentDocResolved = await
|
|
12924
|
-
const contentDocLinkResolved = await
|
|
12925
|
-
const contentVersionResolved = await
|
|
12932
|
+
const contentDocResolved = await filterOutReferenceFieldsAndLinks(contentDocRecord);
|
|
12933
|
+
const contentDocLinkResolved = await filterOutReferenceFieldsAndLinks(contentDocLink);
|
|
12934
|
+
const contentVersionResolved = await filterOutReferenceFieldsAndLinks(contentVersion);
|
|
12926
12935
|
return {
|
|
12927
12936
|
contentDocument: contentDocResolved,
|
|
12928
12937
|
contentDocumentLinks: [contentDocLinkResolved],
|
|
@@ -16159,4 +16168,4 @@ register({
|
|
|
16159
16168
|
});
|
|
16160
16169
|
|
|
16161
16170
|
export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
|
|
16162
|
-
// version: 1.163.
|
|
16171
|
+
// version: 1.163.2-1950176a9
|
package/package.json
CHANGED
package/sfdc/main.js
CHANGED
|
@@ -10796,6 +10796,14 @@ function getRecordKeyFromRecordRequest(luvio, resourceRequest) {
|
|
|
10796
10796
|
function getRecordKeyForId(luvio, recordId) {
|
|
10797
10797
|
return keyBuilderRecord(luvio, { recordId });
|
|
10798
10798
|
}
|
|
10799
|
+
/**
|
|
10800
|
+
* Drafts are stored with denormalized fields and normalized field links. This method
|
|
10801
|
+
* filters out the field links and returns a flattened record representation.
|
|
10802
|
+
*
|
|
10803
|
+
* Note that reference field links get re-applied during draft record ingestion
|
|
10804
|
+
* @param record draft record representation
|
|
10805
|
+
* @returns flattened record representation
|
|
10806
|
+
*/
|
|
10799
10807
|
function filterOutReferenceFieldsAndLinks(record) {
|
|
10800
10808
|
const filteredFields = {};
|
|
10801
10809
|
const fieldNames = keys$2(record.fields);
|
|
@@ -10814,32 +10822,6 @@ function filterOutReferenceFieldsAndLinks(record) {
|
|
|
10814
10822
|
delete filteredRecords.links;
|
|
10815
10823
|
return filteredRecords;
|
|
10816
10824
|
}
|
|
10817
|
-
async function resolveReferencesOneLevelDeep(record, getRecordFromKey) {
|
|
10818
|
-
const fieldNames = keys$2(record.fields);
|
|
10819
|
-
const resolvedFields = {};
|
|
10820
|
-
for (const fieldName of fieldNames) {
|
|
10821
|
-
const field = record.fields[fieldName];
|
|
10822
|
-
if (isFieldLink(field)) {
|
|
10823
|
-
const denormalizedRecord = await getRecordFromKey(field.value.__ref);
|
|
10824
|
-
if (denormalizedRecord !== undefined) {
|
|
10825
|
-
resolvedFields[fieldName] = {
|
|
10826
|
-
value: filterOutReferenceFieldsAndLinks(denormalizedRecord),
|
|
10827
|
-
displayValue: null,
|
|
10828
|
-
};
|
|
10829
|
-
}
|
|
10830
|
-
else {
|
|
10831
|
-
resolvedFields[fieldName] = {
|
|
10832
|
-
value: null,
|
|
10833
|
-
displayValue: null,
|
|
10834
|
-
};
|
|
10835
|
-
}
|
|
10836
|
-
}
|
|
10837
|
-
else {
|
|
10838
|
-
resolvedFields[fieldName] = field;
|
|
10839
|
-
}
|
|
10840
|
-
}
|
|
10841
|
-
return { ...record, fields: resolvedFields };
|
|
10842
|
-
}
|
|
10843
10825
|
|
|
10844
10826
|
/**
|
|
10845
10827
|
* Checks if a resource request is a GET method on the record endpoint
|
|
@@ -11136,11 +11118,15 @@ const DEFAULT_FIELD_RECORD_TYPE_ID = 'RecordTypeId';
|
|
|
11136
11118
|
*/
|
|
11137
11119
|
function replayDraftsOnRecord(record, draftMetadata) {
|
|
11138
11120
|
let objectInfo;
|
|
11121
|
+
let luvio;
|
|
11139
11122
|
if (record && draftMetadata) {
|
|
11140
11123
|
objectInfo = draftMetadata.objectInfos.get(record.apiName);
|
|
11141
11124
|
}
|
|
11125
|
+
if (draftMetadata) {
|
|
11126
|
+
luvio = draftMetadata.luvio;
|
|
11127
|
+
}
|
|
11142
11128
|
// remove drafts before reapply
|
|
11143
|
-
const baseRecord = record === undefined ? undefined : removeDrafts(record, objectInfo);
|
|
11129
|
+
const baseRecord = record === undefined ? undefined : removeDrafts(record, luvio, objectInfo);
|
|
11144
11130
|
// record is a draft create
|
|
11145
11131
|
if (baseRecord === undefined) {
|
|
11146
11132
|
if (draftMetadata === undefined) {
|
|
@@ -11263,7 +11249,7 @@ function recursivelyApplyDraftsToRecord(record, draftMetadata, recordOperations)
|
|
|
11263
11249
|
* @param record record with drafts applied
|
|
11264
11250
|
* @returns
|
|
11265
11251
|
*/
|
|
11266
|
-
function removeDrafts(record, objectInfo) {
|
|
11252
|
+
function removeDrafts(record, luvio, objectInfo) {
|
|
11267
11253
|
const { drafts, fields } = record;
|
|
11268
11254
|
if (drafts === undefined) {
|
|
11269
11255
|
return record;
|
|
@@ -11279,6 +11265,12 @@ function removeDrafts(record, objectInfo) {
|
|
|
11279
11265
|
const originalField = drafts.serverValues[fieldName];
|
|
11280
11266
|
if (originalField !== undefined) {
|
|
11281
11267
|
updatedFields[fieldName] = originalField;
|
|
11268
|
+
if (objectInfo && luvio) {
|
|
11269
|
+
const reference = getReferenceInfoForKey(fieldName, originalField, luvio, objectInfo);
|
|
11270
|
+
if (reference) {
|
|
11271
|
+
updatedFields[reference.referenceFieldName] = reference.field;
|
|
11272
|
+
}
|
|
11273
|
+
}
|
|
11282
11274
|
// restore the record type id on the root of the record
|
|
11283
11275
|
if (fieldName === DEFAULT_FIELD_RECORD_TYPE_ID) {
|
|
11284
11276
|
const originalRecordTypeId = originalField.value;
|
|
@@ -11316,7 +11308,6 @@ function removeDrafts(record, objectInfo) {
|
|
|
11316
11308
|
* @param fields List of draft record fields
|
|
11317
11309
|
*/
|
|
11318
11310
|
function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fields, objectInfos, referencedRecords, formatDisplayValue) {
|
|
11319
|
-
var _a;
|
|
11320
11311
|
const fieldNames = keys$2(fields);
|
|
11321
11312
|
const recordFields = {};
|
|
11322
11313
|
const objectInfo = objectInfos.get(apiName);
|
|
@@ -11330,7 +11321,7 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
|
|
|
11330
11321
|
if (objectInfo !== undefined) {
|
|
11331
11322
|
const fieldInfo = objectInfo.fields[fieldName];
|
|
11332
11323
|
if (fieldInfo !== undefined) {
|
|
11333
|
-
const { dataType
|
|
11324
|
+
const { dataType } = fieldInfo;
|
|
11334
11325
|
recordFields[fieldName].displayValue = formatDisplayValue(draftField, dataType);
|
|
11335
11326
|
if (dataType === 'DateTime' &&
|
|
11336
11327
|
draftField !== null &&
|
|
@@ -11342,46 +11333,6 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
|
|
|
11342
11333
|
throw Error('date field value not valid');
|
|
11343
11334
|
}
|
|
11344
11335
|
}
|
|
11345
|
-
if (dataType === 'Reference' && relationshipName !== null && draftField !== null) {
|
|
11346
|
-
if (typeof draftField !== 'string') {
|
|
11347
|
-
throw Error('reference field value is not a string');
|
|
11348
|
-
}
|
|
11349
|
-
const key = getRecordKeyForId(luvio, draftField);
|
|
11350
|
-
const referencedRecord = referencedRecords.get(key);
|
|
11351
|
-
if (referencedRecord) {
|
|
11352
|
-
recordFields[relationshipName] = {
|
|
11353
|
-
displayValue: null,
|
|
11354
|
-
value: createLink(key),
|
|
11355
|
-
};
|
|
11356
|
-
}
|
|
11357
|
-
else {
|
|
11358
|
-
recordFields[relationshipName] = {
|
|
11359
|
-
displayValue: null,
|
|
11360
|
-
value: null,
|
|
11361
|
-
};
|
|
11362
|
-
}
|
|
11363
|
-
// for custom objects, we select the 'Name' field
|
|
11364
|
-
// otherwise we check the object info for name fields.
|
|
11365
|
-
//if there are multiple we select 'Name' if it exists, otherwise the first one
|
|
11366
|
-
if (referencedRecord !== undefined && referenceToInfos.length > 0) {
|
|
11367
|
-
let nameField;
|
|
11368
|
-
const referenceToInfo = referenceToInfos[0];
|
|
11369
|
-
const nameFields = referenceToInfo.nameFields;
|
|
11370
|
-
if (nameFields.length !== 0) {
|
|
11371
|
-
nameField = nameFields.find((x) => x === 'Name');
|
|
11372
|
-
if (nameField === undefined) {
|
|
11373
|
-
nameField = nameFields[0];
|
|
11374
|
-
}
|
|
11375
|
-
}
|
|
11376
|
-
if (nameField !== undefined) {
|
|
11377
|
-
const nameFieldRef = referencedRecord.fields[nameField];
|
|
11378
|
-
if (nameFieldRef) {
|
|
11379
|
-
recordFields[relationshipName].displayValue =
|
|
11380
|
-
(_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
|
|
11381
|
-
}
|
|
11382
|
-
}
|
|
11383
|
-
}
|
|
11384
|
-
}
|
|
11385
11336
|
}
|
|
11386
11337
|
}
|
|
11387
11338
|
}
|
|
@@ -11455,9 +11406,78 @@ function buildSyntheticRecordRepresentation(luvio, createOperation, userId, obje
|
|
|
11455
11406
|
},
|
|
11456
11407
|
};
|
|
11457
11408
|
}
|
|
11409
|
+
function applyReferenceLinksToDraft(record, draftMetadata) {
|
|
11410
|
+
var _a;
|
|
11411
|
+
const { objectInfos, referencedRecords, luvio } = draftMetadata;
|
|
11412
|
+
const objectInfo = objectInfos.get(record.apiName);
|
|
11413
|
+
if (objectInfo === undefined) {
|
|
11414
|
+
return record;
|
|
11415
|
+
}
|
|
11416
|
+
let fieldNames = Object.keys(record.fields);
|
|
11417
|
+
const recordFields = { ...record.fields };
|
|
11418
|
+
for (const draftField of fieldNames) {
|
|
11419
|
+
const fieldInfo = objectInfo.fields[draftField];
|
|
11420
|
+
if (fieldInfo === undefined) {
|
|
11421
|
+
continue;
|
|
11422
|
+
}
|
|
11423
|
+
const { dataType, relationshipName, referenceToInfos } = fieldInfo;
|
|
11424
|
+
const draftFieldValue = record.fields[draftField].value;
|
|
11425
|
+
if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
|
|
11426
|
+
if (typeof draftFieldValue !== 'string') {
|
|
11427
|
+
throw Error('reference field value is not a string');
|
|
11428
|
+
}
|
|
11429
|
+
const key = getRecordKeyForId(luvio, draftFieldValue);
|
|
11430
|
+
const referencedRecord = referencedRecords.get(key);
|
|
11431
|
+
recordFields[relationshipName] = {
|
|
11432
|
+
displayValue: null,
|
|
11433
|
+
value: createLink(key),
|
|
11434
|
+
};
|
|
11435
|
+
// for custom objects, we select the 'Name' field
|
|
11436
|
+
// otherwise we check the object info for name fields.
|
|
11437
|
+
//if there are multiple we select 'Name' if it exists, otherwise the first one
|
|
11438
|
+
if (referencedRecord !== undefined && referenceToInfos.length > 0) {
|
|
11439
|
+
let nameField;
|
|
11440
|
+
const referenceToInfo = referenceToInfos[0];
|
|
11441
|
+
const nameFields = referenceToInfo.nameFields;
|
|
11442
|
+
if (nameFields.length !== 0) {
|
|
11443
|
+
nameField = nameFields.find((x) => x === 'Name');
|
|
11444
|
+
if (nameField === undefined) {
|
|
11445
|
+
nameField = nameFields[0];
|
|
11446
|
+
}
|
|
11447
|
+
}
|
|
11448
|
+
if (nameField !== undefined) {
|
|
11449
|
+
const nameFieldRef = referencedRecord.fields[nameField];
|
|
11450
|
+
if (nameFieldRef) {
|
|
11451
|
+
recordFields[relationshipName].displayValue =
|
|
11452
|
+
(_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
|
|
11453
|
+
}
|
|
11454
|
+
}
|
|
11455
|
+
}
|
|
11456
|
+
}
|
|
11457
|
+
}
|
|
11458
|
+
return { ...record, fields: recordFields };
|
|
11459
|
+
}
|
|
11458
11460
|
function createLink(key) {
|
|
11459
11461
|
return { __ref: key };
|
|
11460
11462
|
}
|
|
11463
|
+
function getReferenceInfoForKey(fieldName, field, luvio, objectInfo) {
|
|
11464
|
+
const { dataType, relationshipName } = objectInfo.fields[fieldName];
|
|
11465
|
+
const draftFieldValue = field.value;
|
|
11466
|
+
if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
|
|
11467
|
+
if (typeof draftFieldValue !== 'string') {
|
|
11468
|
+
throw Error('reference field value is not a string');
|
|
11469
|
+
}
|
|
11470
|
+
const key = getRecordKeyForId(luvio, draftFieldValue);
|
|
11471
|
+
return {
|
|
11472
|
+
referenceFieldName: relationshipName,
|
|
11473
|
+
field: {
|
|
11474
|
+
displayValue: null,
|
|
11475
|
+
value: createLink(key),
|
|
11476
|
+
},
|
|
11477
|
+
};
|
|
11478
|
+
}
|
|
11479
|
+
return undefined;
|
|
11480
|
+
}
|
|
11461
11481
|
|
|
11462
11482
|
async function getAdapterData(adapter, config) {
|
|
11463
11483
|
const snapshot = await adapter(config);
|
|
@@ -11649,8 +11669,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
11649
11669
|
*
|
|
11650
11670
|
* @param action The draft action related to this record
|
|
11651
11671
|
* @param _queue The draft queue
|
|
11652
|
-
* @returns The record with the updated draft queue applied.
|
|
11653
|
-
* deep to ensure that reference links are properly established during ingestion to it
|
|
11672
|
+
* @returns The record with the updated draft queue applied. References are not included and must be applied at ingest.
|
|
11654
11673
|
*
|
|
11655
11674
|
* or
|
|
11656
11675
|
*
|
|
@@ -11674,7 +11693,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
11674
11693
|
if (recordWithDrafts === undefined) {
|
|
11675
11694
|
return undefined;
|
|
11676
11695
|
}
|
|
11677
|
-
return
|
|
11696
|
+
return filterOutReferenceFieldsAndLinks(recordWithDrafts);
|
|
11678
11697
|
}
|
|
11679
11698
|
const record = await this.durableStore.getDenormalizedRecord(key);
|
|
11680
11699
|
if (record === undefined) {
|
|
@@ -11685,7 +11704,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
11685
11704
|
if (recordWithDrafts === undefined) {
|
|
11686
11705
|
return recordWithDrafts;
|
|
11687
11706
|
}
|
|
11688
|
-
return
|
|
11707
|
+
return filterOutReferenceFieldsAndLinks(recordWithDrafts);
|
|
11689
11708
|
}
|
|
11690
11709
|
applyDraftsToIncomingData(key, data, draftMetadata, publishData) {
|
|
11691
11710
|
if (isField(key)) {
|
|
@@ -11712,19 +11731,26 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
11712
11731
|
}
|
|
11713
11732
|
}
|
|
11714
11733
|
const recordWithDrafts = replayDraftsOnRecord(partialRecord, draftMetadata);
|
|
11734
|
+
const recordWithSpanningRefLinks = applyReferenceLinksToDraft(recordWithDrafts, draftMetadata);
|
|
11715
11735
|
// publish the normalized fields
|
|
11716
11736
|
const normalizedRecord = {
|
|
11717
|
-
...
|
|
11737
|
+
...recordWithSpanningRefLinks,
|
|
11718
11738
|
...data,
|
|
11719
11739
|
fields: { ...data.fields },
|
|
11720
11740
|
};
|
|
11721
|
-
for (const fieldName of
|
|
11741
|
+
for (const fieldName of keys$2(recordWithSpanningRefLinks.fields)) {
|
|
11722
11742
|
const fieldKey = buildRecordFieldStoreKey(key, fieldName);
|
|
11723
11743
|
if (this.collectedFields[fieldKey] !== undefined) {
|
|
11724
|
-
const fieldData =
|
|
11744
|
+
const fieldData = recordWithSpanningRefLinks.fields[fieldName];
|
|
11725
11745
|
normalizedRecord.fields[fieldName] = { __ref: fieldKey };
|
|
11726
11746
|
publishData(fieldKey, fieldData);
|
|
11727
11747
|
}
|
|
11748
|
+
else if (recordWithSpanningRefLinks.fields[fieldName] &&
|
|
11749
|
+
recordWithSpanningRefLinks.fields[fieldName].value &&
|
|
11750
|
+
recordWithSpanningRefLinks.fields[fieldName].value.__ref !== undefined) {
|
|
11751
|
+
normalizedRecord.fields[fieldName] = { __ref: fieldKey };
|
|
11752
|
+
publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
|
|
11753
|
+
}
|
|
11728
11754
|
}
|
|
11729
11755
|
// publish the normalized record
|
|
11730
11756
|
publishData(key, normalizedRecord);
|
|
@@ -12902,27 +12928,10 @@ class ContentDocumentCompositeRepresentationActionHandler extends AbstractResour
|
|
|
12902
12928
|
if (contentVersion === undefined) {
|
|
12903
12929
|
return undefined;
|
|
12904
12930
|
}
|
|
12905
|
-
// this lambda can be shared across the calls to resolveReferencesOneLevelDeep
|
|
12906
|
-
const luvio = this.getLuvio();
|
|
12907
|
-
const contentDocumentKey = getRecordKeyForId(luvio, contentDocumentId);
|
|
12908
|
-
const contentDocumentLinkKey = getRecordKeyForId(luvio, contentDocumentLinkId);
|
|
12909
|
-
const contentVersionKey = getRecordKeyForId(luvio, contentVersionId);
|
|
12910
|
-
const getRecordFromKey = async (key) => {
|
|
12911
|
-
if (key === contentDocumentKey) {
|
|
12912
|
-
return contentDocRecord;
|
|
12913
|
-
}
|
|
12914
|
-
if (key === contentDocumentLinkKey) {
|
|
12915
|
-
return contentDocLink;
|
|
12916
|
-
}
|
|
12917
|
-
if (key === contentVersionKey) {
|
|
12918
|
-
return contentVersion;
|
|
12919
|
-
}
|
|
12920
|
-
return this.durableStore.getDenormalizedRecord(key);
|
|
12921
|
-
};
|
|
12922
12931
|
// finally we resolve all references for each record
|
|
12923
|
-
const contentDocResolved = await
|
|
12924
|
-
const contentDocLinkResolved = await
|
|
12925
|
-
const contentVersionResolved = await
|
|
12932
|
+
const contentDocResolved = await filterOutReferenceFieldsAndLinks(contentDocRecord);
|
|
12933
|
+
const contentDocLinkResolved = await filterOutReferenceFieldsAndLinks(contentDocLink);
|
|
12934
|
+
const contentVersionResolved = await filterOutReferenceFieldsAndLinks(contentVersion);
|
|
12926
12935
|
return {
|
|
12927
12936
|
contentDocument: contentDocResolved,
|
|
12928
12937
|
contentDocumentLinks: [contentDocLinkResolved],
|
|
@@ -16159,4 +16168,4 @@ register({
|
|
|
16159
16168
|
});
|
|
16160
16169
|
|
|
16161
16170
|
export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
|
|
16162
|
-
// version: 1.163.
|
|
16171
|
+
// version: 1.163.2-1950176a9
|