@salesforce/lds-runtime-mobile 1.147.2 → 1.147.3

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 +82 -31
  2. package/package.json +5 -5
  3. package/sfdc/main.js +82 -31
package/dist/main.js CHANGED
@@ -1782,7 +1782,7 @@ function isFailure(result) {
1782
1782
  function errors(result) {
1783
1783
  return result.error;
1784
1784
  }
1785
- function values$2(result) {
1785
+ function values$3(result) {
1786
1786
  return result.value;
1787
1787
  }
1788
1788
  function flattenResults(results) {
@@ -1790,7 +1790,7 @@ function flattenResults(results) {
1790
1790
  if (fails.length > 0) {
1791
1791
  return failure(fails);
1792
1792
  }
1793
- return success(results.filter(isSuccess).map(values$2));
1793
+ return success(results.filter(isSuccess).map(values$3));
1794
1794
  }
1795
1795
 
1796
1796
  function getFieldInfo(apiName, fieldName, infoMap) {
@@ -2664,7 +2664,7 @@ function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperato
2664
2664
  if (failures.length > 0) {
2665
2665
  return failure(failures);
2666
2666
  }
2667
- const containers = results.filter(isSuccess).map(values$2);
2667
+ const containers = results.filter(isSuccess).map(values$3);
2668
2668
  const predicates = [];
2669
2669
  containers.forEach((c) => {
2670
2670
  if (c.predicate !== undefined) {
@@ -2956,7 +2956,7 @@ function dateFunctions(operatorNode, extract, dataType) {
2956
2956
  if (fails.length > 0) {
2957
2957
  return failure(fails);
2958
2958
  }
2959
- const vals = results.filter(isSuccess).reduce(flatMap(values$2), []);
2959
+ const vals = results.filter(isSuccess).reduce(flatMap(values$3), []);
2960
2960
  return success(vals);
2961
2961
  }
2962
2962
  function isFilterFunction(name) {
@@ -2966,7 +2966,7 @@ function fieldOperators(operatorNode, dataType) {
2966
2966
  const results = Object.entries(operatorNode.fields)
2967
2967
  .filter(([key, _]) => isFilterFunction(key) === false)
2968
2968
  .map(([key, value]) => operatorWithValue(key, value, dataType));
2969
- const _values = results.filter(isSuccess).map(values$2);
2969
+ const _values = results.filter(isSuccess).map(values$3);
2970
2970
  const fails = results.filter(isFailure).reduce(flatMap(errors), []);
2971
2971
  if (fails.length > 0) {
2972
2972
  return failure(fails);
@@ -3887,7 +3887,7 @@ function selectionToQueryField(node, names, parentApiName, parentAlias, input, j
3887
3887
  }
3888
3888
  function recordFields(luvioSelections, names, parentApiName, parentAlias, input, joins) {
3889
3889
  const results = luvioSelections.map((selection) => selectionToQueryField(selection, names, parentApiName, parentAlias, input, joins));
3890
- const fields = results.filter(isSuccess).reduce(flatMap(values$2), []);
3890
+ const fields = results.filter(isSuccess).reduce(flatMap(values$3), []);
3891
3891
  const fails = results.filter(isFailure).reduce(flatMap(errors), []);
3892
3892
  if (fails.length > 0) {
3893
3893
  return failure(fails);
@@ -4092,7 +4092,7 @@ function rootRecordQuery(selection, input) {
4092
4092
  }
4093
4093
  function rootQuery(recordNodes, input) {
4094
4094
  const results = recordNodes.map((record) => rootRecordQuery(record, input));
4095
- const connections = results.filter(isSuccess).map(values$2);
4095
+ const connections = results.filter(isSuccess).map(values$3);
4096
4096
  const fails = results.filter(isFailure).reduce(flatMap(errors), []);
4097
4097
  if (fails.length > 0) {
4098
4098
  return failure(fails);
@@ -4831,7 +4831,7 @@ function createDraftSynthesisErrorResponse(message = 'failed to synthesize draft
4831
4831
  return new DraftErrorFetchResponse(HttpStatusCode.BadRequest, error);
4832
4832
  }
4833
4833
 
4834
- const { keys: keys$4, create: create$4, assign: assign$3, values: values$1 } = Object;
4834
+ const { keys: keys$4, create: create$4, assign: assign$3, values: values$2 } = Object;
4835
4835
  const { stringify: stringify$4, parse: parse$4 } = JSON;
4836
4836
  const { isArray: isArray$3 } = Array;
4837
4837
 
@@ -5206,7 +5206,7 @@ class DurableDraftQueue {
5206
5206
  const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
5207
5207
  // write the queue operations to the store prior to ingesting the result
5208
5208
  await this.draftStore.completeAction(queueOperations);
5209
- await handler.handleActionCompleted(action, queueOperations, values$1(this.handlers));
5209
+ await handler.handleActionCompleted(action, queueOperations, values$2(this.handlers));
5210
5210
  this.retryIntervalMilliseconds = 0;
5211
5211
  this.uploadingActionId = undefined;
5212
5212
  await this.notifyChangedListeners({
@@ -6543,7 +6543,7 @@ function isArrayLike(x) {
6543
6543
  (x.length === 0 || (x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1))));
6544
6544
  }
6545
6545
 
6546
- const { create: create$3, keys: keys$3, values, entries: entries$2 } = Object;
6546
+ const { create: create$3, keys: keys$3, values: values$1, entries: entries$2 } = Object;
6547
6547
  const { stringify: stringify$3, parse: parse$3 } = JSON;
6548
6548
  const { isArray: isArray$2 } = Array;
6549
6549
 
@@ -6876,7 +6876,7 @@ function dateTimePredicate(input, operator, field, alias) {
6876
6876
  return predicate;
6877
6877
  }
6878
6878
  else if (literal !== undefined) {
6879
- const isAvailableLiteral = values(DateLiteral).includes(literal);
6879
+ const isAvailableLiteral = values$1(DateLiteral).includes(literal);
6880
6880
  // eslint-disable-next-line @salesforce/lds/no-error-in-production
6881
6881
  if (!isAvailableLiteral)
6882
6882
  throw new Error(`${literal} is not a valid DateLiteral`);
@@ -7538,7 +7538,7 @@ function dedupeJoins(joins) {
7538
7538
  for (const join of joins) {
7539
7539
  deduped[join.alias + join.to] = join;
7540
7540
  }
7541
- return values(deduped);
7541
+ return values$1(deduped);
7542
7542
  }
7543
7543
  function buildJoins(config) {
7544
7544
  let sql = '';
@@ -8172,7 +8172,7 @@ function flatten(previous, current) {
8172
8172
  return previous.concat(current);
8173
8173
  }
8174
8174
  function findFieldInfo(objectInfo, fieldName) {
8175
- return values(objectInfo.fields).find((field) => field.apiName === fieldName ||
8175
+ return values$1(objectInfo.fields).find((field) => field.apiName === fieldName ||
8176
8176
  (field.dataType === 'Reference' && field.relationshipName === fieldName));
8177
8177
  }
8178
8178
 
@@ -8192,10 +8192,10 @@ function orderByToPredicate(orderBy, recordType, alias, objectInfoMap, joins) {
8192
8192
  for (let i = 0, len = keys$1.length; i < len; i++) {
8193
8193
  const key = keys$1[i];
8194
8194
  const parentFields = objectInfoMap[recordType].fields;
8195
- const fieldInfo = values(parentFields).find(findSpanningField(key));
8195
+ const fieldInfo = values$1(parentFields).find(findSpanningField(key));
8196
8196
  if (fieldInfo && fieldInfo.referenceToInfos.length > 0) {
8197
8197
  const { apiName } = fieldInfo.referenceToInfos[0];
8198
- const parentFieldInfo = values(objectInfoMap[recordType].fields).find(findSpanningField(fieldInfo.apiName));
8198
+ const parentFieldInfo = values$1(objectInfoMap[recordType].fields).find(findSpanningField(fieldInfo.apiName));
8199
8199
  if (parentFieldInfo !== undefined) {
8200
8200
  const path = {
8201
8201
  leftPath: `$.fields.${parentFieldInfo.apiName}.value`,
@@ -8337,7 +8337,7 @@ function addResolversToSchema(schema, polyFields) {
8337
8337
  let baseRecord = undefined;
8338
8338
  // Concrete types for Polymorphic field
8339
8339
  const polyTypes = [];
8340
- for (const type of values(schema.getTypeMap())) {
8340
+ for (const type of values$1(schema.getTypeMap())) {
8341
8341
  if (type.name === 'Record') {
8342
8342
  recordInterface = type;
8343
8343
  }
@@ -8350,7 +8350,7 @@ function addResolversToSchema(schema, polyFields) {
8350
8350
  if (polyFields.find((fieldTypeName) => fieldTypeName === type.name) !== undefined) {
8351
8351
  polyTypes.push(type);
8352
8352
  }
8353
- const fields = values(type.getFields());
8353
+ const fields = values$1(type.getFields());
8354
8354
  // initialize the fields of current type with default behavior
8355
8355
  for (const field of fields) {
8356
8356
  field.resolve = defaultFieldResolver;
@@ -8667,7 +8667,7 @@ function generateRecordQueries(objectInfos) {
8667
8667
  let recordConnections = ``;
8668
8668
  const polymorphicFieldTypeNames = new Set();
8669
8669
  let typedScalars = new Set();
8670
- for (const objectInfo of values(objectInfos)) {
8670
+ for (const objectInfo of values$1(objectInfos)) {
8671
8671
  const { apiName, childRelationships } = objectInfo;
8672
8672
  let fields = ``;
8673
8673
  typedScalars.add(`${apiName}_Filter`);
@@ -8683,7 +8683,7 @@ function generateRecordQueries(objectInfos) {
8683
8683
  typedScalars.add(`${childObjectApiName}_OrderBy`);
8684
8684
  }
8685
8685
  }
8686
- for (const field of values(objectInfo.fields)) {
8686
+ for (const field of values$1(objectInfo.fields)) {
8687
8687
  if (!fieldsStaticallyAdded.includes(field.apiName)) {
8688
8688
  fields += `${field.apiName}: ${dataTypeToType(field.dataType, field.apiName)}\n`;
8689
8689
  }
@@ -9186,7 +9186,7 @@ function isMineScopeAvailable(apiNamePath, objectInfoApiMap, objectInfos) {
9186
9186
  const objectInfo = objectInfos[apiName[0]];
9187
9187
  if (!objectInfo)
9188
9188
  return false;
9189
- return values(objectInfo.fields).some((fieldInfo) => {
9189
+ return values$1(objectInfo.fields).some((fieldInfo) => {
9190
9190
  return (fieldInfo.apiName === 'OwnerId' &&
9191
9191
  fieldInfo.referenceToInfos.some((referenceToInfo) => {
9192
9192
  return referenceToInfo.apiName === 'User';
@@ -10437,7 +10437,7 @@ function referenceIdFieldForRelationship(relationshipName) {
10437
10437
  * For full license text, see the LICENSE.txt file
10438
10438
  */
10439
10439
 
10440
- const { keys: keys$2, create: create$2, assign: assign$2, freeze } = Object;
10440
+ const { keys: keys$2, values, create: create$2, assign: assign$2, freeze } = Object;
10441
10441
  const { stringify: stringify$2, parse: parse$2 } = JSON;
10442
10442
  const { shift } = Array.prototype;
10443
10443
  const { isArray: isArray$1 } = Array;
@@ -11168,15 +11168,15 @@ async function getAdapterData(adapter, config) {
11168
11168
  const LDS_ACTION_HANDLER_ID = 'LDS_ACTION_HANDLER';
11169
11169
  const LDS_ACTION_METADATA_API_NAME = 'LDS_ACTION_METADATA_API_NAME';
11170
11170
  class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11171
- constructor(getLuvio, networkAdapter, durableStore, draftQueue, getRecordAdapter, isDraftId, apiNameForPrefix, recordService) {
11171
+ constructor(getLuvio, networkAdapter, durableStore, draftQueue, getRecordAdapter, objectInfoService, isDraftId, recordService) {
11172
11172
  super(draftQueue, networkAdapter, getLuvio);
11173
11173
  this.getLuvio = getLuvio;
11174
11174
  this.networkAdapter = networkAdapter;
11175
11175
  this.durableStore = durableStore;
11176
11176
  this.draftQueue = draftQueue;
11177
11177
  this.getRecordAdapter = getRecordAdapter;
11178
+ this.objectInfoService = objectInfoService;
11178
11179
  this.isDraftId = isDraftId;
11179
- this.apiNameForPrefix = apiNameForPrefix;
11180
11180
  this.recordService = recordService;
11181
11181
  this.handlerId = LDS_ACTION_HANDLER_ID;
11182
11182
  this.collectedFields = create$2(null);
@@ -11223,8 +11223,55 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11223
11223
  throw Error('unknown draft precondition failed');
11224
11224
  }
11225
11225
  }
11226
+ else if (metaDataResult.status === 'missing-referenced-records') {
11227
+ const referenceFields = metaDataResult.missingRecordReferences;
11228
+ if (referenceFields !== undefined) {
11229
+ //fetches the reference record async
11230
+ this.fetchReferenceRecord(referenceFields);
11231
+ }
11232
+ }
11226
11233
  return pendingAction;
11227
11234
  }
11235
+ async fetchReferenceRecord(referenceFields) {
11236
+ const promises = referenceFields.map(async (referenceFieldInfo) => {
11237
+ const apiName = await this.identifyApiName(referenceFieldInfo.id, referenceFieldInfo.field);
11238
+ if (apiName === undefined) {
11239
+ return;
11240
+ }
11241
+ const objectInfoMap = await this.objectInfoService.getObjectInfos([
11242
+ apiName,
11243
+ ]);
11244
+ if (objectInfoMap[apiName] === undefined) {
11245
+ return;
11246
+ }
11247
+ const objectInfo = objectInfoMap[apiName];
11248
+ const optionalFields = values(objectInfo.fields).map((field) => `${apiName}.${field.apiName}`);
11249
+ await getAdapterData(this.getRecordAdapter, {
11250
+ recordId: referenceFieldInfo.id,
11251
+ optionalFields,
11252
+ });
11253
+ });
11254
+ await Promise.all(promises);
11255
+ }
11256
+ /**
11257
+ * identify the API Name from the record ID and its field representation. For example, ApiName for `001x0000004cKfzAAE` is `Account` if its field info reference to `Account`
11258
+ * representation
11259
+ * @param id
11260
+ * @param fieldInfo
11261
+ * @returns apiName
11262
+ */
11263
+ async identifyApiName(id, fieldInfo) {
11264
+ const referenceToInfos = fieldInfo.referenceToInfos;
11265
+ const apiNames = referenceToInfos.map((referenceToInfo) => referenceToInfo.apiName);
11266
+ const objectInfoMap = await this.objectInfoService.getObjectInfos(apiNames);
11267
+ for (const objectInfo of values(objectInfoMap)) {
11268
+ const { apiName, keyPrefix } = objectInfo;
11269
+ if (keyPrefix !== null && id.startsWith(keyPrefix)) {
11270
+ return apiName;
11271
+ }
11272
+ }
11273
+ return undefined;
11274
+ }
11228
11275
  canRepresentationContainDraftMetadata(representationName) {
11229
11276
  return representationName === RECORD_REPRESENTATION_NAME;
11230
11277
  }
@@ -11402,7 +11449,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11402
11449
  // as a last resort we'll do a lookup for cached object infos by prefix
11403
11450
  // note this will throw if the object info hasn't been previously cached
11404
11451
  const prefix = recordId.substring(0, 3);
11405
- return this.apiNameForPrefix(prefix);
11452
+ return this.objectInfoService.apiNameForPrefix(prefix);
11406
11453
  }
11407
11454
  /**
11408
11455
  * Inspects the resource request to ensure this handler can handle it
@@ -11844,7 +11891,7 @@ class UiApiDraftRecordService {
11844
11891
  }
11845
11892
  const objectInfoMap = new Map();
11846
11893
  const referenceMap = new Map();
11847
- const missingReferenceKeys = new Set();
11894
+ const referenceFields = [];
11848
11895
  const metadata = {
11849
11896
  luvio: this.getLuvio(),
11850
11897
  userId: this.userId,
@@ -11885,13 +11932,17 @@ class UiApiDraftRecordService {
11885
11932
  continue;
11886
11933
  }
11887
11934
  const key = getRecordKeyForId(this.getLuvio(), id);
11888
- if (referenceMap.has(key) === false && missingReferenceKeys.has(key) === false) {
11935
+ if (referenceMap.has(key) === false &&
11936
+ !referenceFields.some((refInfo) => refInfo.id === id)) {
11889
11937
  const record = await this.durableStore.getDenormalizedRecord(key);
11890
11938
  if (record !== undefined) {
11891
11939
  referenceMap.set(key, record);
11892
11940
  }
11893
11941
  else {
11894
- missingReferenceKeys.add(key);
11942
+ referenceFields.push({
11943
+ id,
11944
+ field: fieldInfo,
11945
+ });
11895
11946
  }
11896
11947
  }
11897
11948
  }
@@ -11904,12 +11955,12 @@ class UiApiDraftRecordService {
11904
11955
  };
11905
11956
  }
11906
11957
  }
11907
- if (missingReferenceKeys.size > 0) {
11958
+ if (referenceFields.length > 0) {
11908
11959
  return {
11909
11960
  ok: true,
11910
11961
  data: metadata,
11911
11962
  status: 'missing-referenced-records',
11912
- missingRecordReferenceKeys: Array.from(missingReferenceKeys),
11963
+ missingRecordReferences: referenceFields,
11913
11964
  };
11914
11965
  }
11915
11966
  return {
@@ -15562,7 +15613,7 @@ function getRuntime() {
15562
15613
  // draft queue
15563
15614
  lazyDraftQueue = buildLdsDraftQueue(recordDenormingStore);
15564
15615
  const draftService = new UiApiDraftRecordService(lazyDraftQueue, () => lazyLuvio, recordDenormingStore, getObjectInfo, newRecordId, userId, formatDisplayValue);
15565
- const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, recordDenormingStore, lazyDraftQueue, getRecord, isGenerated, lazyObjectInfoService.apiNameForPrefix, draftService);
15616
+ const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, recordDenormingStore, lazyDraftQueue, getRecord, lazyObjectInfoService, isGenerated, draftService);
15566
15617
  const quickActionHandler = new QuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated);
15567
15618
  const contentDocumentCompositeActionHandler = new ContentDocumentCompositeRepresentationActionHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, recordDenormingStore, NimbusBinaryStore);
15568
15619
  lazyDraftQueue.addHandler(uiApiRecordHandler);
@@ -15655,4 +15706,4 @@ register({
15655
15706
  });
15656
15707
 
15657
15708
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
15658
- // version: 1.147.2-2b0ae2d38
15709
+ // version: 1.147.3-6ff8ead8f
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.147.2",
3
+ "version": "1.147.3",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -57,16 +57,16 @@
57
57
  {
58
58
  "path": "./dist/main.js",
59
59
  "maxSize": {
60
- "none": "665 kB",
61
- "min": "272 kB",
60
+ "none": "667 kB",
61
+ "min": "273 kB",
62
62
  "compressed": "105 kB"
63
63
  }
64
64
  },
65
65
  {
66
66
  "path": "./sfdc/main.js",
67
67
  "maxSize": {
68
- "none": "665 kB",
69
- "min": "272 kB",
68
+ "none": "667 kB",
69
+ "min": "273 kB",
70
70
  "compressed": "105 kB"
71
71
  }
72
72
  }
package/sfdc/main.js CHANGED
@@ -1782,7 +1782,7 @@ function isFailure(result) {
1782
1782
  function errors(result) {
1783
1783
  return result.error;
1784
1784
  }
1785
- function values$2(result) {
1785
+ function values$3(result) {
1786
1786
  return result.value;
1787
1787
  }
1788
1788
  function flattenResults(results) {
@@ -1790,7 +1790,7 @@ function flattenResults(results) {
1790
1790
  if (fails.length > 0) {
1791
1791
  return failure(fails);
1792
1792
  }
1793
- return success(results.filter(isSuccess).map(values$2));
1793
+ return success(results.filter(isSuccess).map(values$3));
1794
1794
  }
1795
1795
 
1796
1796
  function getFieldInfo(apiName, fieldName, infoMap) {
@@ -2664,7 +2664,7 @@ function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperato
2664
2664
  if (failures.length > 0) {
2665
2665
  return failure(failures);
2666
2666
  }
2667
- const containers = results.filter(isSuccess).map(values$2);
2667
+ const containers = results.filter(isSuccess).map(values$3);
2668
2668
  const predicates = [];
2669
2669
  containers.forEach((c) => {
2670
2670
  if (c.predicate !== undefined) {
@@ -2956,7 +2956,7 @@ function dateFunctions(operatorNode, extract, dataType) {
2956
2956
  if (fails.length > 0) {
2957
2957
  return failure(fails);
2958
2958
  }
2959
- const vals = results.filter(isSuccess).reduce(flatMap(values$2), []);
2959
+ const vals = results.filter(isSuccess).reduce(flatMap(values$3), []);
2960
2960
  return success(vals);
2961
2961
  }
2962
2962
  function isFilterFunction(name) {
@@ -2966,7 +2966,7 @@ function fieldOperators(operatorNode, dataType) {
2966
2966
  const results = Object.entries(operatorNode.fields)
2967
2967
  .filter(([key, _]) => isFilterFunction(key) === false)
2968
2968
  .map(([key, value]) => operatorWithValue(key, value, dataType));
2969
- const _values = results.filter(isSuccess).map(values$2);
2969
+ const _values = results.filter(isSuccess).map(values$3);
2970
2970
  const fails = results.filter(isFailure).reduce(flatMap(errors), []);
2971
2971
  if (fails.length > 0) {
2972
2972
  return failure(fails);
@@ -3887,7 +3887,7 @@ function selectionToQueryField(node, names, parentApiName, parentAlias, input, j
3887
3887
  }
3888
3888
  function recordFields(luvioSelections, names, parentApiName, parentAlias, input, joins) {
3889
3889
  const results = luvioSelections.map((selection) => selectionToQueryField(selection, names, parentApiName, parentAlias, input, joins));
3890
- const fields = results.filter(isSuccess).reduce(flatMap(values$2), []);
3890
+ const fields = results.filter(isSuccess).reduce(flatMap(values$3), []);
3891
3891
  const fails = results.filter(isFailure).reduce(flatMap(errors), []);
3892
3892
  if (fails.length > 0) {
3893
3893
  return failure(fails);
@@ -4092,7 +4092,7 @@ function rootRecordQuery(selection, input) {
4092
4092
  }
4093
4093
  function rootQuery(recordNodes, input) {
4094
4094
  const results = recordNodes.map((record) => rootRecordQuery(record, input));
4095
- const connections = results.filter(isSuccess).map(values$2);
4095
+ const connections = results.filter(isSuccess).map(values$3);
4096
4096
  const fails = results.filter(isFailure).reduce(flatMap(errors), []);
4097
4097
  if (fails.length > 0) {
4098
4098
  return failure(fails);
@@ -4831,7 +4831,7 @@ function createDraftSynthesisErrorResponse(message = 'failed to synthesize draft
4831
4831
  return new DraftErrorFetchResponse(HttpStatusCode.BadRequest, error);
4832
4832
  }
4833
4833
 
4834
- const { keys: keys$4, create: create$4, assign: assign$3, values: values$1 } = Object;
4834
+ const { keys: keys$4, create: create$4, assign: assign$3, values: values$2 } = Object;
4835
4835
  const { stringify: stringify$4, parse: parse$4 } = JSON;
4836
4836
  const { isArray: isArray$3 } = Array;
4837
4837
 
@@ -5206,7 +5206,7 @@ class DurableDraftQueue {
5206
5206
  const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
5207
5207
  // write the queue operations to the store prior to ingesting the result
5208
5208
  await this.draftStore.completeAction(queueOperations);
5209
- await handler.handleActionCompleted(action, queueOperations, values$1(this.handlers));
5209
+ await handler.handleActionCompleted(action, queueOperations, values$2(this.handlers));
5210
5210
  this.retryIntervalMilliseconds = 0;
5211
5211
  this.uploadingActionId = undefined;
5212
5212
  await this.notifyChangedListeners({
@@ -6543,7 +6543,7 @@ function isArrayLike(x) {
6543
6543
  (x.length === 0 || (x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1))));
6544
6544
  }
6545
6545
 
6546
- const { create: create$3, keys: keys$3, values, entries: entries$2 } = Object;
6546
+ const { create: create$3, keys: keys$3, values: values$1, entries: entries$2 } = Object;
6547
6547
  const { stringify: stringify$3, parse: parse$3 } = JSON;
6548
6548
  const { isArray: isArray$2 } = Array;
6549
6549
 
@@ -6876,7 +6876,7 @@ function dateTimePredicate(input, operator, field, alias) {
6876
6876
  return predicate;
6877
6877
  }
6878
6878
  else if (literal !== undefined) {
6879
- const isAvailableLiteral = values(DateLiteral).includes(literal);
6879
+ const isAvailableLiteral = values$1(DateLiteral).includes(literal);
6880
6880
  // eslint-disable-next-line @salesforce/lds/no-error-in-production
6881
6881
  if (!isAvailableLiteral)
6882
6882
  throw new Error(`${literal} is not a valid DateLiteral`);
@@ -7538,7 +7538,7 @@ function dedupeJoins(joins) {
7538
7538
  for (const join of joins) {
7539
7539
  deduped[join.alias + join.to] = join;
7540
7540
  }
7541
- return values(deduped);
7541
+ return values$1(deduped);
7542
7542
  }
7543
7543
  function buildJoins(config) {
7544
7544
  let sql = '';
@@ -8172,7 +8172,7 @@ function flatten(previous, current) {
8172
8172
  return previous.concat(current);
8173
8173
  }
8174
8174
  function findFieldInfo(objectInfo, fieldName) {
8175
- return values(objectInfo.fields).find((field) => field.apiName === fieldName ||
8175
+ return values$1(objectInfo.fields).find((field) => field.apiName === fieldName ||
8176
8176
  (field.dataType === 'Reference' && field.relationshipName === fieldName));
8177
8177
  }
8178
8178
 
@@ -8192,10 +8192,10 @@ function orderByToPredicate(orderBy, recordType, alias, objectInfoMap, joins) {
8192
8192
  for (let i = 0, len = keys$1.length; i < len; i++) {
8193
8193
  const key = keys$1[i];
8194
8194
  const parentFields = objectInfoMap[recordType].fields;
8195
- const fieldInfo = values(parentFields).find(findSpanningField(key));
8195
+ const fieldInfo = values$1(parentFields).find(findSpanningField(key));
8196
8196
  if (fieldInfo && fieldInfo.referenceToInfos.length > 0) {
8197
8197
  const { apiName } = fieldInfo.referenceToInfos[0];
8198
- const parentFieldInfo = values(objectInfoMap[recordType].fields).find(findSpanningField(fieldInfo.apiName));
8198
+ const parentFieldInfo = values$1(objectInfoMap[recordType].fields).find(findSpanningField(fieldInfo.apiName));
8199
8199
  if (parentFieldInfo !== undefined) {
8200
8200
  const path = {
8201
8201
  leftPath: `$.fields.${parentFieldInfo.apiName}.value`,
@@ -8337,7 +8337,7 @@ function addResolversToSchema(schema, polyFields) {
8337
8337
  let baseRecord = undefined;
8338
8338
  // Concrete types for Polymorphic field
8339
8339
  const polyTypes = [];
8340
- for (const type of values(schema.getTypeMap())) {
8340
+ for (const type of values$1(schema.getTypeMap())) {
8341
8341
  if (type.name === 'Record') {
8342
8342
  recordInterface = type;
8343
8343
  }
@@ -8350,7 +8350,7 @@ function addResolversToSchema(schema, polyFields) {
8350
8350
  if (polyFields.find((fieldTypeName) => fieldTypeName === type.name) !== undefined) {
8351
8351
  polyTypes.push(type);
8352
8352
  }
8353
- const fields = values(type.getFields());
8353
+ const fields = values$1(type.getFields());
8354
8354
  // initialize the fields of current type with default behavior
8355
8355
  for (const field of fields) {
8356
8356
  field.resolve = defaultFieldResolver;
@@ -8667,7 +8667,7 @@ function generateRecordQueries(objectInfos) {
8667
8667
  let recordConnections = ``;
8668
8668
  const polymorphicFieldTypeNames = new Set();
8669
8669
  let typedScalars = new Set();
8670
- for (const objectInfo of values(objectInfos)) {
8670
+ for (const objectInfo of values$1(objectInfos)) {
8671
8671
  const { apiName, childRelationships } = objectInfo;
8672
8672
  let fields = ``;
8673
8673
  typedScalars.add(`${apiName}_Filter`);
@@ -8683,7 +8683,7 @@ function generateRecordQueries(objectInfos) {
8683
8683
  typedScalars.add(`${childObjectApiName}_OrderBy`);
8684
8684
  }
8685
8685
  }
8686
- for (const field of values(objectInfo.fields)) {
8686
+ for (const field of values$1(objectInfo.fields)) {
8687
8687
  if (!fieldsStaticallyAdded.includes(field.apiName)) {
8688
8688
  fields += `${field.apiName}: ${dataTypeToType(field.dataType, field.apiName)}\n`;
8689
8689
  }
@@ -9186,7 +9186,7 @@ function isMineScopeAvailable(apiNamePath, objectInfoApiMap, objectInfos) {
9186
9186
  const objectInfo = objectInfos[apiName[0]];
9187
9187
  if (!objectInfo)
9188
9188
  return false;
9189
- return values(objectInfo.fields).some((fieldInfo) => {
9189
+ return values$1(objectInfo.fields).some((fieldInfo) => {
9190
9190
  return (fieldInfo.apiName === 'OwnerId' &&
9191
9191
  fieldInfo.referenceToInfos.some((referenceToInfo) => {
9192
9192
  return referenceToInfo.apiName === 'User';
@@ -10437,7 +10437,7 @@ function referenceIdFieldForRelationship(relationshipName) {
10437
10437
  * For full license text, see the LICENSE.txt file
10438
10438
  */
10439
10439
 
10440
- const { keys: keys$2, create: create$2, assign: assign$2, freeze } = Object;
10440
+ const { keys: keys$2, values, create: create$2, assign: assign$2, freeze } = Object;
10441
10441
  const { stringify: stringify$2, parse: parse$2 } = JSON;
10442
10442
  const { shift } = Array.prototype;
10443
10443
  const { isArray: isArray$1 } = Array;
@@ -11168,15 +11168,15 @@ async function getAdapterData(adapter, config) {
11168
11168
  const LDS_ACTION_HANDLER_ID = 'LDS_ACTION_HANDLER';
11169
11169
  const LDS_ACTION_METADATA_API_NAME = 'LDS_ACTION_METADATA_API_NAME';
11170
11170
  class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11171
- constructor(getLuvio, networkAdapter, durableStore, draftQueue, getRecordAdapter, isDraftId, apiNameForPrefix, recordService) {
11171
+ constructor(getLuvio, networkAdapter, durableStore, draftQueue, getRecordAdapter, objectInfoService, isDraftId, recordService) {
11172
11172
  super(draftQueue, networkAdapter, getLuvio);
11173
11173
  this.getLuvio = getLuvio;
11174
11174
  this.networkAdapter = networkAdapter;
11175
11175
  this.durableStore = durableStore;
11176
11176
  this.draftQueue = draftQueue;
11177
11177
  this.getRecordAdapter = getRecordAdapter;
11178
+ this.objectInfoService = objectInfoService;
11178
11179
  this.isDraftId = isDraftId;
11179
- this.apiNameForPrefix = apiNameForPrefix;
11180
11180
  this.recordService = recordService;
11181
11181
  this.handlerId = LDS_ACTION_HANDLER_ID;
11182
11182
  this.collectedFields = create$2(null);
@@ -11223,8 +11223,55 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11223
11223
  throw Error('unknown draft precondition failed');
11224
11224
  }
11225
11225
  }
11226
+ else if (metaDataResult.status === 'missing-referenced-records') {
11227
+ const referenceFields = metaDataResult.missingRecordReferences;
11228
+ if (referenceFields !== undefined) {
11229
+ //fetches the reference record async
11230
+ this.fetchReferenceRecord(referenceFields);
11231
+ }
11232
+ }
11226
11233
  return pendingAction;
11227
11234
  }
11235
+ async fetchReferenceRecord(referenceFields) {
11236
+ const promises = referenceFields.map(async (referenceFieldInfo) => {
11237
+ const apiName = await this.identifyApiName(referenceFieldInfo.id, referenceFieldInfo.field);
11238
+ if (apiName === undefined) {
11239
+ return;
11240
+ }
11241
+ const objectInfoMap = await this.objectInfoService.getObjectInfos([
11242
+ apiName,
11243
+ ]);
11244
+ if (objectInfoMap[apiName] === undefined) {
11245
+ return;
11246
+ }
11247
+ const objectInfo = objectInfoMap[apiName];
11248
+ const optionalFields = values(objectInfo.fields).map((field) => `${apiName}.${field.apiName}`);
11249
+ await getAdapterData(this.getRecordAdapter, {
11250
+ recordId: referenceFieldInfo.id,
11251
+ optionalFields,
11252
+ });
11253
+ });
11254
+ await Promise.all(promises);
11255
+ }
11256
+ /**
11257
+ * identify the API Name from the record ID and its field representation. For example, ApiName for `001x0000004cKfzAAE` is `Account` if its field info reference to `Account`
11258
+ * representation
11259
+ * @param id
11260
+ * @param fieldInfo
11261
+ * @returns apiName
11262
+ */
11263
+ async identifyApiName(id, fieldInfo) {
11264
+ const referenceToInfos = fieldInfo.referenceToInfos;
11265
+ const apiNames = referenceToInfos.map((referenceToInfo) => referenceToInfo.apiName);
11266
+ const objectInfoMap = await this.objectInfoService.getObjectInfos(apiNames);
11267
+ for (const objectInfo of values(objectInfoMap)) {
11268
+ const { apiName, keyPrefix } = objectInfo;
11269
+ if (keyPrefix !== null && id.startsWith(keyPrefix)) {
11270
+ return apiName;
11271
+ }
11272
+ }
11273
+ return undefined;
11274
+ }
11228
11275
  canRepresentationContainDraftMetadata(representationName) {
11229
11276
  return representationName === RECORD_REPRESENTATION_NAME;
11230
11277
  }
@@ -11402,7 +11449,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11402
11449
  // as a last resort we'll do a lookup for cached object infos by prefix
11403
11450
  // note this will throw if the object info hasn't been previously cached
11404
11451
  const prefix = recordId.substring(0, 3);
11405
- return this.apiNameForPrefix(prefix);
11452
+ return this.objectInfoService.apiNameForPrefix(prefix);
11406
11453
  }
11407
11454
  /**
11408
11455
  * Inspects the resource request to ensure this handler can handle it
@@ -11844,7 +11891,7 @@ class UiApiDraftRecordService {
11844
11891
  }
11845
11892
  const objectInfoMap = new Map();
11846
11893
  const referenceMap = new Map();
11847
- const missingReferenceKeys = new Set();
11894
+ const referenceFields = [];
11848
11895
  const metadata = {
11849
11896
  luvio: this.getLuvio(),
11850
11897
  userId: this.userId,
@@ -11885,13 +11932,17 @@ class UiApiDraftRecordService {
11885
11932
  continue;
11886
11933
  }
11887
11934
  const key = getRecordKeyForId(this.getLuvio(), id);
11888
- if (referenceMap.has(key) === false && missingReferenceKeys.has(key) === false) {
11935
+ if (referenceMap.has(key) === false &&
11936
+ !referenceFields.some((refInfo) => refInfo.id === id)) {
11889
11937
  const record = await this.durableStore.getDenormalizedRecord(key);
11890
11938
  if (record !== undefined) {
11891
11939
  referenceMap.set(key, record);
11892
11940
  }
11893
11941
  else {
11894
- missingReferenceKeys.add(key);
11942
+ referenceFields.push({
11943
+ id,
11944
+ field: fieldInfo,
11945
+ });
11895
11946
  }
11896
11947
  }
11897
11948
  }
@@ -11904,12 +11955,12 @@ class UiApiDraftRecordService {
11904
11955
  };
11905
11956
  }
11906
11957
  }
11907
- if (missingReferenceKeys.size > 0) {
11958
+ if (referenceFields.length > 0) {
11908
11959
  return {
11909
11960
  ok: true,
11910
11961
  data: metadata,
11911
11962
  status: 'missing-referenced-records',
11912
- missingRecordReferenceKeys: Array.from(missingReferenceKeys),
11963
+ missingRecordReferences: referenceFields,
11913
11964
  };
11914
11965
  }
11915
11966
  return {
@@ -15562,7 +15613,7 @@ function getRuntime() {
15562
15613
  // draft queue
15563
15614
  lazyDraftQueue = buildLdsDraftQueue(recordDenormingStore);
15564
15615
  const draftService = new UiApiDraftRecordService(lazyDraftQueue, () => lazyLuvio, recordDenormingStore, getObjectInfo, newRecordId, userId, formatDisplayValue);
15565
- const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, recordDenormingStore, lazyDraftQueue, getRecord, isGenerated, lazyObjectInfoService.apiNameForPrefix, draftService);
15616
+ const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, recordDenormingStore, lazyDraftQueue, getRecord, lazyObjectInfoService, isGenerated, draftService);
15566
15617
  const quickActionHandler = new QuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated);
15567
15618
  const contentDocumentCompositeActionHandler = new ContentDocumentCompositeRepresentationActionHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, recordDenormingStore, NimbusBinaryStore);
15568
15619
  lazyDraftQueue.addHandler(uiApiRecordHandler);
@@ -15655,4 +15706,4 @@ register({
15655
15706
  });
15656
15707
 
15657
15708
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
15658
- // version: 1.147.2-2b0ae2d38
15709
+ // version: 1.147.3-6ff8ead8f