@salesforce/lds-runtime-mobile 1.131.0-dev10 → 1.131.0-dev11

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.
Files changed (3) hide show
  1. package/dist/main.js +107 -98
  2. package/package.json +15 -15
  3. package/sfdc/main.js +107 -98
package/dist/main.js CHANGED
@@ -11014,6 +11014,14 @@ function getRecordKeyFromRecordRequest(luvio, resourceRequest) {
11014
11014
  function getRecordKeyForId(luvio, recordId) {
11015
11015
  return keyBuilderRecord(luvio, { recordId });
11016
11016
  }
11017
+ /**
11018
+ * Drafts are stored with denormalized fields and normalized field links. This method
11019
+ * filters out the field links and returns a flattened record representation.
11020
+ *
11021
+ * Note that reference field links get re-applied during draft record ingestion
11022
+ * @param record draft record representation
11023
+ * @returns flattened record representation
11024
+ */
11017
11025
  function filterOutReferenceFieldsAndLinks(record) {
11018
11026
  const filteredFields = {};
11019
11027
  const fieldNames = keys$2(record.fields);
@@ -11032,32 +11040,6 @@ function filterOutReferenceFieldsAndLinks(record) {
11032
11040
  delete filteredRecords.links;
11033
11041
  return filteredRecords;
11034
11042
  }
11035
- async function resolveReferencesOneLevelDeep(record, getRecordFromKey) {
11036
- const fieldNames = keys$2(record.fields);
11037
- const resolvedFields = {};
11038
- for (const fieldName of fieldNames) {
11039
- const field = record.fields[fieldName];
11040
- if (isFieldLink(field)) {
11041
- const denormalizedRecord = await getRecordFromKey(field.value.__ref);
11042
- if (denormalizedRecord !== undefined) {
11043
- resolvedFields[fieldName] = {
11044
- value: filterOutReferenceFieldsAndLinks(denormalizedRecord),
11045
- displayValue: null,
11046
- };
11047
- }
11048
- else {
11049
- resolvedFields[fieldName] = {
11050
- value: null,
11051
- displayValue: null,
11052
- };
11053
- }
11054
- }
11055
- else {
11056
- resolvedFields[fieldName] = field;
11057
- }
11058
- }
11059
- return { ...record, fields: resolvedFields };
11060
- }
11061
11043
 
11062
11044
  /**
11063
11045
  * Checks if a resource request is a GET method on the record endpoint
@@ -11354,11 +11336,15 @@ const DEFAULT_FIELD_RECORD_TYPE_ID = 'RecordTypeId';
11354
11336
  */
11355
11337
  function replayDraftsOnRecord(record, draftMetadata) {
11356
11338
  let objectInfo;
11339
+ let luvio;
11357
11340
  if (record && draftMetadata) {
11358
11341
  objectInfo = draftMetadata.objectInfos.get(record.apiName);
11359
11342
  }
11343
+ if (draftMetadata) {
11344
+ luvio = draftMetadata.luvio;
11345
+ }
11360
11346
  // remove drafts before reapply
11361
- const baseRecord = record === undefined ? undefined : removeDrafts(record, objectInfo);
11347
+ const baseRecord = record === undefined ? undefined : removeDrafts(record, luvio, objectInfo);
11362
11348
  // record is a draft create
11363
11349
  if (baseRecord === undefined) {
11364
11350
  if (draftMetadata === undefined) {
@@ -11481,7 +11467,7 @@ function recursivelyApplyDraftsToRecord(record, draftMetadata, recordOperations)
11481
11467
  * @param record record with drafts applied
11482
11468
  * @returns
11483
11469
  */
11484
- function removeDrafts(record, objectInfo) {
11470
+ function removeDrafts(record, luvio, objectInfo) {
11485
11471
  const { drafts, fields } = record;
11486
11472
  if (drafts === undefined) {
11487
11473
  return record;
@@ -11497,6 +11483,12 @@ function removeDrafts(record, objectInfo) {
11497
11483
  const originalField = drafts.serverValues[fieldName];
11498
11484
  if (originalField !== undefined) {
11499
11485
  updatedFields[fieldName] = originalField;
11486
+ if (objectInfo && luvio) {
11487
+ const reference = getReferenceInfoForKey(fieldName, originalField, luvio, objectInfo);
11488
+ if (reference) {
11489
+ updatedFields[reference.referenceFieldName] = reference.field;
11490
+ }
11491
+ }
11500
11492
  // restore the record type id on the root of the record
11501
11493
  if (fieldName === DEFAULT_FIELD_RECORD_TYPE_ID) {
11502
11494
  const originalRecordTypeId = originalField.value;
@@ -11534,7 +11526,6 @@ function removeDrafts(record, objectInfo) {
11534
11526
  * @param fields List of draft record fields
11535
11527
  */
11536
11528
  function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fields, objectInfos, referencedRecords, formatDisplayValue) {
11537
- var _a;
11538
11529
  const fieldNames = keys$2(fields);
11539
11530
  const recordFields = {};
11540
11531
  const objectInfo = objectInfos.get(apiName);
@@ -11548,7 +11539,7 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
11548
11539
  if (objectInfo !== undefined) {
11549
11540
  const fieldInfo = objectInfo.fields[fieldName];
11550
11541
  if (fieldInfo !== undefined) {
11551
- const { dataType, relationshipName, referenceToInfos } = fieldInfo;
11542
+ const { dataType } = fieldInfo;
11552
11543
  recordFields[fieldName].displayValue = formatDisplayValue(draftField, dataType);
11553
11544
  if (dataType === 'DateTime' &&
11554
11545
  draftField !== null &&
@@ -11560,46 +11551,6 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
11560
11551
  throw Error('date field value not valid');
11561
11552
  }
11562
11553
  }
11563
- if (dataType === 'Reference' && relationshipName !== null && draftField !== null) {
11564
- if (typeof draftField !== 'string') {
11565
- throw Error('reference field value is not a string');
11566
- }
11567
- const key = getRecordKeyForId(luvio, draftField);
11568
- const referencedRecord = referencedRecords.get(key);
11569
- if (referencedRecord) {
11570
- recordFields[relationshipName] = {
11571
- displayValue: null,
11572
- value: createLink(key),
11573
- };
11574
- }
11575
- else {
11576
- recordFields[relationshipName] = {
11577
- displayValue: null,
11578
- value: null,
11579
- };
11580
- }
11581
- // for custom objects, we select the 'Name' field
11582
- // otherwise we check the object info for name fields.
11583
- //if there are multiple we select 'Name' if it exists, otherwise the first one
11584
- if (referencedRecord !== undefined && referenceToInfos.length > 0) {
11585
- let nameField;
11586
- const referenceToInfo = referenceToInfos[0];
11587
- const nameFields = referenceToInfo.nameFields;
11588
- if (nameFields.length !== 0) {
11589
- nameField = nameFields.find((x) => x === 'Name');
11590
- if (nameField === undefined) {
11591
- nameField = nameFields[0];
11592
- }
11593
- }
11594
- if (nameField !== undefined) {
11595
- const nameFieldRef = referencedRecord.fields[nameField];
11596
- if (nameFieldRef) {
11597
- recordFields[relationshipName].displayValue =
11598
- (_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
11599
- }
11600
- }
11601
- }
11602
- }
11603
11554
  }
11604
11555
  }
11605
11556
  }
@@ -11673,9 +11624,78 @@ function buildSyntheticRecordRepresentation(luvio, createOperation, userId, obje
11673
11624
  },
11674
11625
  };
11675
11626
  }
11627
+ function applyReferenceLinksToDraft(record, draftMetadata) {
11628
+ var _a;
11629
+ const { objectInfos, referencedRecords, luvio } = draftMetadata;
11630
+ const objectInfo = objectInfos.get(record.apiName);
11631
+ if (objectInfo === undefined) {
11632
+ return record;
11633
+ }
11634
+ let fieldNames = Object.keys(record.fields);
11635
+ const recordFields = { ...record.fields };
11636
+ for (const draftField of fieldNames) {
11637
+ const fieldInfo = objectInfo.fields[draftField];
11638
+ if (fieldInfo === undefined) {
11639
+ continue;
11640
+ }
11641
+ const { dataType, relationshipName, referenceToInfos } = fieldInfo;
11642
+ const draftFieldValue = record.fields[draftField].value;
11643
+ if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
11644
+ if (typeof draftFieldValue !== 'string') {
11645
+ throw Error('reference field value is not a string');
11646
+ }
11647
+ const key = getRecordKeyForId(luvio, draftFieldValue);
11648
+ const referencedRecord = referencedRecords.get(key);
11649
+ recordFields[relationshipName] = {
11650
+ displayValue: null,
11651
+ value: createLink(key),
11652
+ };
11653
+ // for custom objects, we select the 'Name' field
11654
+ // otherwise we check the object info for name fields.
11655
+ //if there are multiple we select 'Name' if it exists, otherwise the first one
11656
+ if (referencedRecord !== undefined && referenceToInfos.length > 0) {
11657
+ let nameField;
11658
+ const referenceToInfo = referenceToInfos[0];
11659
+ const nameFields = referenceToInfo.nameFields;
11660
+ if (nameFields.length !== 0) {
11661
+ nameField = nameFields.find((x) => x === 'Name');
11662
+ if (nameField === undefined) {
11663
+ nameField = nameFields[0];
11664
+ }
11665
+ }
11666
+ if (nameField !== undefined) {
11667
+ const nameFieldRef = referencedRecord.fields[nameField];
11668
+ if (nameFieldRef) {
11669
+ recordFields[relationshipName].displayValue =
11670
+ (_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
11671
+ }
11672
+ }
11673
+ }
11674
+ }
11675
+ }
11676
+ return { ...record, fields: recordFields };
11677
+ }
11676
11678
  function createLink(key) {
11677
11679
  return { __ref: key };
11678
11680
  }
11681
+ function getReferenceInfoForKey(fieldName, field, luvio, objectInfo) {
11682
+ const { dataType, relationshipName } = objectInfo.fields[fieldName];
11683
+ const draftFieldValue = field.value;
11684
+ if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
11685
+ if (typeof draftFieldValue !== 'string') {
11686
+ throw Error('reference field value is not a string');
11687
+ }
11688
+ const key = getRecordKeyForId(luvio, draftFieldValue);
11689
+ return {
11690
+ referenceFieldName: relationshipName,
11691
+ field: {
11692
+ displayValue: null,
11693
+ value: createLink(key),
11694
+ },
11695
+ };
11696
+ }
11697
+ return undefined;
11698
+ }
11679
11699
 
11680
11700
  async function getAdapterData(adapter, config) {
11681
11701
  const snapshot = await adapter(config);
@@ -11820,8 +11840,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11820
11840
  *
11821
11841
  * @param action The draft action related to this record
11822
11842
  * @param _queue The draft queue
11823
- * @returns The record with the updated draft queue applied. This record is resolved with references one-level
11824
- * deep to ensure that reference links are properly established during ingestion to it
11843
+ * @returns The record with the updated draft queue applied. References are not included and must be applied at ingest.
11825
11844
  *
11826
11845
  * or
11827
11846
  *
@@ -11845,7 +11864,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11845
11864
  if (recordWithDrafts === undefined) {
11846
11865
  return undefined;
11847
11866
  }
11848
- return resolveReferencesOneLevelDeep(recordWithDrafts, this.durableStore.getDenormalizedRecord.bind(this.durableStore));
11867
+ return filterOutReferenceFieldsAndLinks(recordWithDrafts);
11849
11868
  }
11850
11869
  const record = await this.durableStore.getDenormalizedRecord(key);
11851
11870
  if (record === undefined) {
@@ -11856,7 +11875,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11856
11875
  if (recordWithDrafts === undefined) {
11857
11876
  return recordWithDrafts;
11858
11877
  }
11859
- return resolveReferencesOneLevelDeep(recordWithDrafts, this.durableStore.getDenormalizedRecord.bind(this.durableStore));
11878
+ return filterOutReferenceFieldsAndLinks(recordWithDrafts);
11860
11879
  }
11861
11880
  applyDraftsToIncomingData(key, data, draftMetadata, publishData) {
11862
11881
  if (isField(key)) {
@@ -11883,19 +11902,26 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11883
11902
  }
11884
11903
  }
11885
11904
  const recordWithDrafts = replayDraftsOnRecord(partialRecord, draftMetadata);
11905
+ const recordWithSpanningRefLinks = applyReferenceLinksToDraft(recordWithDrafts, draftMetadata);
11886
11906
  // publish the normalized fields
11887
11907
  const normalizedRecord = {
11888
- ...recordWithDrafts,
11908
+ ...recordWithSpanningRefLinks,
11889
11909
  ...data,
11890
11910
  fields: { ...data.fields },
11891
11911
  };
11892
- for (const fieldName of recordFieldNames) {
11912
+ for (const fieldName of keys$2(recordWithSpanningRefLinks.fields)) {
11893
11913
  const fieldKey = buildRecordFieldStoreKey(key, fieldName);
11894
11914
  if (this.collectedFields[fieldKey] !== undefined) {
11895
- const fieldData = recordWithDrafts.fields[fieldName];
11915
+ const fieldData = recordWithSpanningRefLinks.fields[fieldName];
11896
11916
  normalizedRecord.fields[fieldName] = { __ref: fieldKey };
11897
11917
  publishData(fieldKey, fieldData);
11898
11918
  }
11919
+ else if (recordWithSpanningRefLinks.fields[fieldName] &&
11920
+ recordWithSpanningRefLinks.fields[fieldName].value &&
11921
+ recordWithSpanningRefLinks.fields[fieldName].value.__ref !== undefined) {
11922
+ normalizedRecord.fields[fieldName] = { __ref: fieldKey };
11923
+ publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
11924
+ }
11899
11925
  }
11900
11926
  // publish the normalized record
11901
11927
  publishData(key, normalizedRecord);
@@ -13069,27 +13095,10 @@ class ContentDocumentCompositeRepresentationActionHandler extends AbstractResour
13069
13095
  if (contentVersion === undefined) {
13070
13096
  return undefined;
13071
13097
  }
13072
- // this lambda can be shared across the calls to resolveReferencesOneLevelDeep
13073
- const luvio = this.getLuvio();
13074
- const contentDocumentKey = getRecordKeyForId(luvio, contentDocumentId);
13075
- const contentDocumentLinkKey = getRecordKeyForId(luvio, contentDocumentLinkId);
13076
- const contentVersionKey = getRecordKeyForId(luvio, contentVersionId);
13077
- const getRecordFromKey = async (key) => {
13078
- if (key === contentDocumentKey) {
13079
- return contentDocRecord;
13080
- }
13081
- if (key === contentDocumentLinkKey) {
13082
- return contentDocLink;
13083
- }
13084
- if (key === contentVersionKey) {
13085
- return contentVersion;
13086
- }
13087
- return this.durableStore.getDenormalizedRecord(key);
13088
- };
13089
13098
  // finally we resolve all references for each record
13090
- const contentDocResolved = await resolveReferencesOneLevelDeep(contentDocRecord, getRecordFromKey);
13091
- const contentDocLinkResolved = await resolveReferencesOneLevelDeep(contentDocLink, getRecordFromKey);
13092
- const contentVersionResolved = await resolveReferencesOneLevelDeep(contentVersion, getRecordFromKey);
13099
+ const contentDocResolved = await filterOutReferenceFieldsAndLinks(contentDocRecord);
13100
+ const contentDocLinkResolved = await filterOutReferenceFieldsAndLinks(contentDocLink);
13101
+ const contentVersionResolved = await filterOutReferenceFieldsAndLinks(contentVersion);
13093
13102
  return {
13094
13103
  contentDocument: contentDocResolved,
13095
13104
  contentDocumentLinks: [contentDocLinkResolved],
@@ -16191,4 +16200,4 @@ register({
16191
16200
  });
16192
16201
 
16193
16202
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
16194
- // version: 1.131.0-dev10-b950ecbb3
16203
+ // version: 1.131.0-dev11-b15472a13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.131.0-dev10",
3
+ "version": "1.131.0-dev11",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -32,24 +32,24 @@
32
32
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-mobile"
33
33
  },
34
34
  "dependencies": {
35
- "@salesforce/lds-adapters-uiapi": "1.131.0-dev10",
36
- "@salesforce/lds-bindings": "1.131.0-dev10",
37
- "@salesforce/lds-instrumentation": "1.131.0-dev10",
38
- "@salesforce/lds-priming": "1.131.0-dev10",
35
+ "@salesforce/lds-adapters-uiapi": "1.131.0-dev11",
36
+ "@salesforce/lds-bindings": "1.131.0-dev11",
37
+ "@salesforce/lds-instrumentation": "1.131.0-dev11",
38
+ "@salesforce/lds-priming": "1.131.0-dev11",
39
39
  "@salesforce/user": "0.0.12",
40
40
  "o11y": "244.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-graphql": "1.131.0-dev10",
44
- "@salesforce/lds-drafts": "1.131.0-dev10",
45
- "@salesforce/lds-drafts-adapters-uiapi": "1.131.0-dev10",
46
- "@salesforce/lds-graphql-eval": "1.131.0-dev10",
47
- "@salesforce/lds-network-adapter": "1.131.0-dev10",
48
- "@salesforce/lds-network-nimbus": "1.131.0-dev10",
49
- "@salesforce/lds-store-binary": "1.131.0-dev10",
50
- "@salesforce/lds-store-sql": "1.131.0-dev10",
51
- "@salesforce/lds-utils-adapters": "1.131.0-dev10",
52
- "@salesforce/nimbus-plugin-lds": "1.131.0-dev10",
43
+ "@salesforce/lds-adapters-graphql": "1.131.0-dev11",
44
+ "@salesforce/lds-drafts": "1.131.0-dev11",
45
+ "@salesforce/lds-drafts-adapters-uiapi": "1.131.0-dev11",
46
+ "@salesforce/lds-graphql-eval": "1.131.0-dev11",
47
+ "@salesforce/lds-network-adapter": "1.131.0-dev11",
48
+ "@salesforce/lds-network-nimbus": "1.131.0-dev11",
49
+ "@salesforce/lds-store-binary": "1.131.0-dev11",
50
+ "@salesforce/lds-store-sql": "1.131.0-dev11",
51
+ "@salesforce/lds-utils-adapters": "1.131.0-dev11",
52
+ "@salesforce/nimbus-plugin-lds": "1.131.0-dev11",
53
53
  "babel-plugin-dynamic-import-node": "^2.3.3",
54
54
  "wait-for-expect": "^3.0.2"
55
55
  },
package/sfdc/main.js CHANGED
@@ -11014,6 +11014,14 @@ function getRecordKeyFromRecordRequest(luvio, resourceRequest) {
11014
11014
  function getRecordKeyForId(luvio, recordId) {
11015
11015
  return keyBuilderRecord(luvio, { recordId });
11016
11016
  }
11017
+ /**
11018
+ * Drafts are stored with denormalized fields and normalized field links. This method
11019
+ * filters out the field links and returns a flattened record representation.
11020
+ *
11021
+ * Note that reference field links get re-applied during draft record ingestion
11022
+ * @param record draft record representation
11023
+ * @returns flattened record representation
11024
+ */
11017
11025
  function filterOutReferenceFieldsAndLinks(record) {
11018
11026
  const filteredFields = {};
11019
11027
  const fieldNames = keys$2(record.fields);
@@ -11032,32 +11040,6 @@ function filterOutReferenceFieldsAndLinks(record) {
11032
11040
  delete filteredRecords.links;
11033
11041
  return filteredRecords;
11034
11042
  }
11035
- async function resolveReferencesOneLevelDeep(record, getRecordFromKey) {
11036
- const fieldNames = keys$2(record.fields);
11037
- const resolvedFields = {};
11038
- for (const fieldName of fieldNames) {
11039
- const field = record.fields[fieldName];
11040
- if (isFieldLink(field)) {
11041
- const denormalizedRecord = await getRecordFromKey(field.value.__ref);
11042
- if (denormalizedRecord !== undefined) {
11043
- resolvedFields[fieldName] = {
11044
- value: filterOutReferenceFieldsAndLinks(denormalizedRecord),
11045
- displayValue: null,
11046
- };
11047
- }
11048
- else {
11049
- resolvedFields[fieldName] = {
11050
- value: null,
11051
- displayValue: null,
11052
- };
11053
- }
11054
- }
11055
- else {
11056
- resolvedFields[fieldName] = field;
11057
- }
11058
- }
11059
- return { ...record, fields: resolvedFields };
11060
- }
11061
11043
 
11062
11044
  /**
11063
11045
  * Checks if a resource request is a GET method on the record endpoint
@@ -11354,11 +11336,15 @@ const DEFAULT_FIELD_RECORD_TYPE_ID = 'RecordTypeId';
11354
11336
  */
11355
11337
  function replayDraftsOnRecord(record, draftMetadata) {
11356
11338
  let objectInfo;
11339
+ let luvio;
11357
11340
  if (record && draftMetadata) {
11358
11341
  objectInfo = draftMetadata.objectInfos.get(record.apiName);
11359
11342
  }
11343
+ if (draftMetadata) {
11344
+ luvio = draftMetadata.luvio;
11345
+ }
11360
11346
  // remove drafts before reapply
11361
- const baseRecord = record === undefined ? undefined : removeDrafts(record, objectInfo);
11347
+ const baseRecord = record === undefined ? undefined : removeDrafts(record, luvio, objectInfo);
11362
11348
  // record is a draft create
11363
11349
  if (baseRecord === undefined) {
11364
11350
  if (draftMetadata === undefined) {
@@ -11481,7 +11467,7 @@ function recursivelyApplyDraftsToRecord(record, draftMetadata, recordOperations)
11481
11467
  * @param record record with drafts applied
11482
11468
  * @returns
11483
11469
  */
11484
- function removeDrafts(record, objectInfo) {
11470
+ function removeDrafts(record, luvio, objectInfo) {
11485
11471
  const { drafts, fields } = record;
11486
11472
  if (drafts === undefined) {
11487
11473
  return record;
@@ -11497,6 +11483,12 @@ function removeDrafts(record, objectInfo) {
11497
11483
  const originalField = drafts.serverValues[fieldName];
11498
11484
  if (originalField !== undefined) {
11499
11485
  updatedFields[fieldName] = originalField;
11486
+ if (objectInfo && luvio) {
11487
+ const reference = getReferenceInfoForKey(fieldName, originalField, luvio, objectInfo);
11488
+ if (reference) {
11489
+ updatedFields[reference.referenceFieldName] = reference.field;
11490
+ }
11491
+ }
11500
11492
  // restore the record type id on the root of the record
11501
11493
  if (fieldName === DEFAULT_FIELD_RECORD_TYPE_ID) {
11502
11494
  const originalRecordTypeId = originalField.value;
@@ -11534,7 +11526,6 @@ function removeDrafts(record, objectInfo) {
11534
11526
  * @param fields List of draft record fields
11535
11527
  */
11536
11528
  function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fields, objectInfos, referencedRecords, formatDisplayValue) {
11537
- var _a;
11538
11529
  const fieldNames = keys$2(fields);
11539
11530
  const recordFields = {};
11540
11531
  const objectInfo = objectInfos.get(apiName);
@@ -11548,7 +11539,7 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
11548
11539
  if (objectInfo !== undefined) {
11549
11540
  const fieldInfo = objectInfo.fields[fieldName];
11550
11541
  if (fieldInfo !== undefined) {
11551
- const { dataType, relationshipName, referenceToInfos } = fieldInfo;
11542
+ const { dataType } = fieldInfo;
11552
11543
  recordFields[fieldName].displayValue = formatDisplayValue(draftField, dataType);
11553
11544
  if (dataType === 'DateTime' &&
11554
11545
  draftField !== null &&
@@ -11560,46 +11551,6 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
11560
11551
  throw Error('date field value not valid');
11561
11552
  }
11562
11553
  }
11563
- if (dataType === 'Reference' && relationshipName !== null && draftField !== null) {
11564
- if (typeof draftField !== 'string') {
11565
- throw Error('reference field value is not a string');
11566
- }
11567
- const key = getRecordKeyForId(luvio, draftField);
11568
- const referencedRecord = referencedRecords.get(key);
11569
- if (referencedRecord) {
11570
- recordFields[relationshipName] = {
11571
- displayValue: null,
11572
- value: createLink(key),
11573
- };
11574
- }
11575
- else {
11576
- recordFields[relationshipName] = {
11577
- displayValue: null,
11578
- value: null,
11579
- };
11580
- }
11581
- // for custom objects, we select the 'Name' field
11582
- // otherwise we check the object info for name fields.
11583
- //if there are multiple we select 'Name' if it exists, otherwise the first one
11584
- if (referencedRecord !== undefined && referenceToInfos.length > 0) {
11585
- let nameField;
11586
- const referenceToInfo = referenceToInfos[0];
11587
- const nameFields = referenceToInfo.nameFields;
11588
- if (nameFields.length !== 0) {
11589
- nameField = nameFields.find((x) => x === 'Name');
11590
- if (nameField === undefined) {
11591
- nameField = nameFields[0];
11592
- }
11593
- }
11594
- if (nameField !== undefined) {
11595
- const nameFieldRef = referencedRecord.fields[nameField];
11596
- if (nameFieldRef) {
11597
- recordFields[relationshipName].displayValue =
11598
- (_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
11599
- }
11600
- }
11601
- }
11602
- }
11603
11554
  }
11604
11555
  }
11605
11556
  }
@@ -11673,9 +11624,78 @@ function buildSyntheticRecordRepresentation(luvio, createOperation, userId, obje
11673
11624
  },
11674
11625
  };
11675
11626
  }
11627
+ function applyReferenceLinksToDraft(record, draftMetadata) {
11628
+ var _a;
11629
+ const { objectInfos, referencedRecords, luvio } = draftMetadata;
11630
+ const objectInfo = objectInfos.get(record.apiName);
11631
+ if (objectInfo === undefined) {
11632
+ return record;
11633
+ }
11634
+ let fieldNames = Object.keys(record.fields);
11635
+ const recordFields = { ...record.fields };
11636
+ for (const draftField of fieldNames) {
11637
+ const fieldInfo = objectInfo.fields[draftField];
11638
+ if (fieldInfo === undefined) {
11639
+ continue;
11640
+ }
11641
+ const { dataType, relationshipName, referenceToInfos } = fieldInfo;
11642
+ const draftFieldValue = record.fields[draftField].value;
11643
+ if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
11644
+ if (typeof draftFieldValue !== 'string') {
11645
+ throw Error('reference field value is not a string');
11646
+ }
11647
+ const key = getRecordKeyForId(luvio, draftFieldValue);
11648
+ const referencedRecord = referencedRecords.get(key);
11649
+ recordFields[relationshipName] = {
11650
+ displayValue: null,
11651
+ value: createLink(key),
11652
+ };
11653
+ // for custom objects, we select the 'Name' field
11654
+ // otherwise we check the object info for name fields.
11655
+ //if there are multiple we select 'Name' if it exists, otherwise the first one
11656
+ if (referencedRecord !== undefined && referenceToInfos.length > 0) {
11657
+ let nameField;
11658
+ const referenceToInfo = referenceToInfos[0];
11659
+ const nameFields = referenceToInfo.nameFields;
11660
+ if (nameFields.length !== 0) {
11661
+ nameField = nameFields.find((x) => x === 'Name');
11662
+ if (nameField === undefined) {
11663
+ nameField = nameFields[0];
11664
+ }
11665
+ }
11666
+ if (nameField !== undefined) {
11667
+ const nameFieldRef = referencedRecord.fields[nameField];
11668
+ if (nameFieldRef) {
11669
+ recordFields[relationshipName].displayValue =
11670
+ (_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
11671
+ }
11672
+ }
11673
+ }
11674
+ }
11675
+ }
11676
+ return { ...record, fields: recordFields };
11677
+ }
11676
11678
  function createLink(key) {
11677
11679
  return { __ref: key };
11678
11680
  }
11681
+ function getReferenceInfoForKey(fieldName, field, luvio, objectInfo) {
11682
+ const { dataType, relationshipName } = objectInfo.fields[fieldName];
11683
+ const draftFieldValue = field.value;
11684
+ if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
11685
+ if (typeof draftFieldValue !== 'string') {
11686
+ throw Error('reference field value is not a string');
11687
+ }
11688
+ const key = getRecordKeyForId(luvio, draftFieldValue);
11689
+ return {
11690
+ referenceFieldName: relationshipName,
11691
+ field: {
11692
+ displayValue: null,
11693
+ value: createLink(key),
11694
+ },
11695
+ };
11696
+ }
11697
+ return undefined;
11698
+ }
11679
11699
 
11680
11700
  async function getAdapterData(adapter, config) {
11681
11701
  const snapshot = await adapter(config);
@@ -11820,8 +11840,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11820
11840
  *
11821
11841
  * @param action The draft action related to this record
11822
11842
  * @param _queue The draft queue
11823
- * @returns The record with the updated draft queue applied. This record is resolved with references one-level
11824
- * deep to ensure that reference links are properly established during ingestion to it
11843
+ * @returns The record with the updated draft queue applied. References are not included and must be applied at ingest.
11825
11844
  *
11826
11845
  * or
11827
11846
  *
@@ -11845,7 +11864,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11845
11864
  if (recordWithDrafts === undefined) {
11846
11865
  return undefined;
11847
11866
  }
11848
- return resolveReferencesOneLevelDeep(recordWithDrafts, this.durableStore.getDenormalizedRecord.bind(this.durableStore));
11867
+ return filterOutReferenceFieldsAndLinks(recordWithDrafts);
11849
11868
  }
11850
11869
  const record = await this.durableStore.getDenormalizedRecord(key);
11851
11870
  if (record === undefined) {
@@ -11856,7 +11875,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11856
11875
  if (recordWithDrafts === undefined) {
11857
11876
  return recordWithDrafts;
11858
11877
  }
11859
- return resolveReferencesOneLevelDeep(recordWithDrafts, this.durableStore.getDenormalizedRecord.bind(this.durableStore));
11878
+ return filterOutReferenceFieldsAndLinks(recordWithDrafts);
11860
11879
  }
11861
11880
  applyDraftsToIncomingData(key, data, draftMetadata, publishData) {
11862
11881
  if (isField(key)) {
@@ -11883,19 +11902,26 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11883
11902
  }
11884
11903
  }
11885
11904
  const recordWithDrafts = replayDraftsOnRecord(partialRecord, draftMetadata);
11905
+ const recordWithSpanningRefLinks = applyReferenceLinksToDraft(recordWithDrafts, draftMetadata);
11886
11906
  // publish the normalized fields
11887
11907
  const normalizedRecord = {
11888
- ...recordWithDrafts,
11908
+ ...recordWithSpanningRefLinks,
11889
11909
  ...data,
11890
11910
  fields: { ...data.fields },
11891
11911
  };
11892
- for (const fieldName of recordFieldNames) {
11912
+ for (const fieldName of keys$2(recordWithSpanningRefLinks.fields)) {
11893
11913
  const fieldKey = buildRecordFieldStoreKey(key, fieldName);
11894
11914
  if (this.collectedFields[fieldKey] !== undefined) {
11895
- const fieldData = recordWithDrafts.fields[fieldName];
11915
+ const fieldData = recordWithSpanningRefLinks.fields[fieldName];
11896
11916
  normalizedRecord.fields[fieldName] = { __ref: fieldKey };
11897
11917
  publishData(fieldKey, fieldData);
11898
11918
  }
11919
+ else if (recordWithSpanningRefLinks.fields[fieldName] &&
11920
+ recordWithSpanningRefLinks.fields[fieldName].value &&
11921
+ recordWithSpanningRefLinks.fields[fieldName].value.__ref !== undefined) {
11922
+ normalizedRecord.fields[fieldName] = { __ref: fieldKey };
11923
+ publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
11924
+ }
11899
11925
  }
11900
11926
  // publish the normalized record
11901
11927
  publishData(key, normalizedRecord);
@@ -13069,27 +13095,10 @@ class ContentDocumentCompositeRepresentationActionHandler extends AbstractResour
13069
13095
  if (contentVersion === undefined) {
13070
13096
  return undefined;
13071
13097
  }
13072
- // this lambda can be shared across the calls to resolveReferencesOneLevelDeep
13073
- const luvio = this.getLuvio();
13074
- const contentDocumentKey = getRecordKeyForId(luvio, contentDocumentId);
13075
- const contentDocumentLinkKey = getRecordKeyForId(luvio, contentDocumentLinkId);
13076
- const contentVersionKey = getRecordKeyForId(luvio, contentVersionId);
13077
- const getRecordFromKey = async (key) => {
13078
- if (key === contentDocumentKey) {
13079
- return contentDocRecord;
13080
- }
13081
- if (key === contentDocumentLinkKey) {
13082
- return contentDocLink;
13083
- }
13084
- if (key === contentVersionKey) {
13085
- return contentVersion;
13086
- }
13087
- return this.durableStore.getDenormalizedRecord(key);
13088
- };
13089
13098
  // finally we resolve all references for each record
13090
- const contentDocResolved = await resolveReferencesOneLevelDeep(contentDocRecord, getRecordFromKey);
13091
- const contentDocLinkResolved = await resolveReferencesOneLevelDeep(contentDocLink, getRecordFromKey);
13092
- const contentVersionResolved = await resolveReferencesOneLevelDeep(contentVersion, getRecordFromKey);
13099
+ const contentDocResolved = await filterOutReferenceFieldsAndLinks(contentDocRecord);
13100
+ const contentDocLinkResolved = await filterOutReferenceFieldsAndLinks(contentDocLink);
13101
+ const contentVersionResolved = await filterOutReferenceFieldsAndLinks(contentVersion);
13093
13102
  return {
13094
13103
  contentDocument: contentDocResolved,
13095
13104
  contentDocumentLinks: [contentDocLinkResolved],
@@ -16191,4 +16200,4 @@ register({
16191
16200
  });
16192
16201
 
16193
16202
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
16194
- // version: 1.131.0-dev10-b950ecbb3
16203
+ // version: 1.131.0-dev11-b15472a13