@salesforce/lds-worker-api 1.147.2 → 1.147.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -770,4 +770,4 @@ if (process.env.NODE_ENV !== 'production') {
770
770
  }
771
771
 
772
772
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
773
- // version: 1.147.2-2b0ae2d38
773
+ // version: 1.147.4-a137f215b
@@ -22,7 +22,7 @@ var SnapshotState$3;
22
22
  SnapshotState["Stale"] = "Stale";
23
23
  })(SnapshotState$3 || (SnapshotState$3 = {}));
24
24
 
25
- const { create: create$a, entries: entries$4, freeze: freeze$5, keys: keys$b, values: values$3 } = Object;
25
+ const { create: create$a, entries: entries$4, freeze: freeze$5, keys: keys$b, values: values$4 } = Object;
26
26
  const { hasOwnProperty: hasOwnProperty$3 } = Object.prototype;
27
27
  const { isArray: isArray$9 } = Array;
28
28
  const { push: push$4, indexOf, slice: slice$2 } = Array.prototype;
@@ -3801,7 +3801,7 @@ function withDefaultLuvio(callback) {
3801
3801
  }
3802
3802
  callbacks.push(callback);
3803
3803
  }
3804
- // version: 1.147.2-2b0ae2d38
3804
+ // version: 1.147.4-a137f215b
3805
3805
 
3806
3806
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3807
3807
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15225,7 +15225,7 @@ function parseAndVisit(source) {
15225
15225
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15226
15226
  return luvioDocumentNode;
15227
15227
  }
15228
- // version: 1.147.2-2b0ae2d38
15228
+ // version: 1.147.4-a137f215b
15229
15229
 
15230
15230
  function unwrap(data) {
15231
15231
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16138,7 +16138,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
16138
16138
  const { apiFamily, name } = metadata;
16139
16139
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16140
16140
  }
16141
- // version: 1.147.2-2b0ae2d38
16141
+ // version: 1.147.4-a137f215b
16142
16142
 
16143
16143
  /**
16144
16144
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44001,7 +44001,7 @@ withDefaultLuvio((luvio) => {
44001
44001
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44002
44002
  });
44003
44003
  });
44004
- // version: 1.147.2-be9827ebc
44004
+ // version: 1.147.4-7830883a5
44005
44005
 
44006
44006
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44007
44007
 
@@ -45847,7 +45847,7 @@ function isFailure(result) {
45847
45847
  function errors(result) {
45848
45848
  return result.error;
45849
45849
  }
45850
- function values$2(result) {
45850
+ function values$3(result) {
45851
45851
  return result.value;
45852
45852
  }
45853
45853
  function flattenResults(results) {
@@ -45855,7 +45855,7 @@ function flattenResults(results) {
45855
45855
  if (fails.length > 0) {
45856
45856
  return failure(fails);
45857
45857
  }
45858
- return success(results.filter(isSuccess).map(values$2));
45858
+ return success(results.filter(isSuccess).map(values$3));
45859
45859
  }
45860
45860
 
45861
45861
  function getFieldInfo(apiName, fieldName, infoMap) {
@@ -46729,7 +46729,7 @@ function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperato
46729
46729
  if (failures.length > 0) {
46730
46730
  return failure(failures);
46731
46731
  }
46732
- const containers = results.filter(isSuccess).map(values$2);
46732
+ const containers = results.filter(isSuccess).map(values$3);
46733
46733
  const predicates = [];
46734
46734
  containers.forEach((c) => {
46735
46735
  if (c.predicate !== undefined) {
@@ -47021,7 +47021,7 @@ function dateFunctions(operatorNode, extract, dataType) {
47021
47021
  if (fails.length > 0) {
47022
47022
  return failure(fails);
47023
47023
  }
47024
- const vals = results.filter(isSuccess).reduce(flatMap$1(values$2), []);
47024
+ const vals = results.filter(isSuccess).reduce(flatMap$1(values$3), []);
47025
47025
  return success(vals);
47026
47026
  }
47027
47027
  function isFilterFunction(name) {
@@ -47031,7 +47031,7 @@ function fieldOperators(operatorNode, dataType) {
47031
47031
  const results = Object.entries(operatorNode.fields)
47032
47032
  .filter(([key, _]) => isFilterFunction(key) === false)
47033
47033
  .map(([key, value]) => operatorWithValue(key, value, dataType));
47034
- const _values = results.filter(isSuccess).map(values$2);
47034
+ const _values = results.filter(isSuccess).map(values$3);
47035
47035
  const fails = results.filter(isFailure).reduce(flatMap$1(errors), []);
47036
47036
  if (fails.length > 0) {
47037
47037
  return failure(fails);
@@ -47952,7 +47952,7 @@ function selectionToQueryField(node, names, parentApiName, parentAlias, input, j
47952
47952
  }
47953
47953
  function recordFields(luvioSelections, names, parentApiName, parentAlias, input, joins) {
47954
47954
  const results = luvioSelections.map((selection) => selectionToQueryField(selection, names, parentApiName, parentAlias, input, joins));
47955
- const fields = results.filter(isSuccess).reduce(flatMap$1(values$2), []);
47955
+ const fields = results.filter(isSuccess).reduce(flatMap$1(values$3), []);
47956
47956
  const fails = results.filter(isFailure).reduce(flatMap$1(errors), []);
47957
47957
  if (fails.length > 0) {
47958
47958
  return failure(fails);
@@ -48157,7 +48157,7 @@ function rootRecordQuery(selection, input) {
48157
48157
  }
48158
48158
  function rootQuery(recordNodes, input) {
48159
48159
  const results = recordNodes.map((record) => rootRecordQuery(record, input));
48160
- const connections = results.filter(isSuccess).map(values$2);
48160
+ const connections = results.filter(isSuccess).map(values$3);
48161
48161
  const fails = results.filter(isFailure).reduce(flatMap$1(errors), []);
48162
48162
  if (fails.length > 0) {
48163
48163
  return failure(fails);
@@ -48896,7 +48896,7 @@ function createDraftSynthesisErrorResponse(message = 'failed to synthesize draft
48896
48896
  return new DraftErrorFetchResponse(HttpStatusCode$1.BadRequest, error);
48897
48897
  }
48898
48898
 
48899
- const { keys: keys$4, create: create$4, assign: assign$3, values: values$1 } = Object;
48899
+ const { keys: keys$4, create: create$4, assign: assign$3, values: values$2 } = Object;
48900
48900
  const { stringify: stringify$4, parse: parse$4 } = JSON;
48901
48901
  const { isArray: isArray$3 } = Array;
48902
48902
 
@@ -49271,7 +49271,7 @@ class DurableDraftQueue {
49271
49271
  const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
49272
49272
  // write the queue operations to the store prior to ingesting the result
49273
49273
  await this.draftStore.completeAction(queueOperations);
49274
- await handler.handleActionCompleted(action, queueOperations, values$1(this.handlers));
49274
+ await handler.handleActionCompleted(action, queueOperations, values$2(this.handlers));
49275
49275
  this.retryIntervalMilliseconds = 0;
49276
49276
  this.uploadingActionId = undefined;
49277
49277
  await this.notifyChangedListeners({
@@ -50594,7 +50594,7 @@ function isArrayLike(x) {
50594
50594
  (x.length === 0 || (x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1))));
50595
50595
  }
50596
50596
 
50597
- const { create: create$3, keys: keys$3, values, entries: entries$2 } = Object;
50597
+ const { create: create$3, keys: keys$3, values: values$1, entries: entries$2 } = Object;
50598
50598
  const { stringify: stringify$3, parse: parse$3 } = JSON;
50599
50599
  const { isArray: isArray$2 } = Array;
50600
50600
 
@@ -50927,7 +50927,7 @@ function dateTimePredicate(input, operator, field, alias) {
50927
50927
  return predicate;
50928
50928
  }
50929
50929
  else if (literal !== undefined) {
50930
- const isAvailableLiteral = values(DateLiteral).includes(literal);
50930
+ const isAvailableLiteral = values$1(DateLiteral).includes(literal);
50931
50931
  // eslint-disable-next-line @salesforce/lds/no-error-in-production
50932
50932
  if (!isAvailableLiteral)
50933
50933
  throw new Error(`${literal} is not a valid DateLiteral`);
@@ -51589,7 +51589,7 @@ function dedupeJoins(joins) {
51589
51589
  for (const join of joins) {
51590
51590
  deduped[join.alias + join.to] = join;
51591
51591
  }
51592
- return values(deduped);
51592
+ return values$1(deduped);
51593
51593
  }
51594
51594
  function buildJoins(config) {
51595
51595
  let sql = '';
@@ -52223,7 +52223,7 @@ function flatten(previous, current) {
52223
52223
  return previous.concat(current);
52224
52224
  }
52225
52225
  function findFieldInfo(objectInfo, fieldName) {
52226
- return values(objectInfo.fields).find((field) => field.apiName === fieldName ||
52226
+ return values$1(objectInfo.fields).find((field) => field.apiName === fieldName ||
52227
52227
  (field.dataType === 'Reference' && field.relationshipName === fieldName));
52228
52228
  }
52229
52229
 
@@ -52243,10 +52243,10 @@ function orderByToPredicate(orderBy, recordType, alias, objectInfoMap, joins) {
52243
52243
  for (let i = 0, len = keys$1.length; i < len; i++) {
52244
52244
  const key = keys$1[i];
52245
52245
  const parentFields = objectInfoMap[recordType].fields;
52246
- const fieldInfo = values(parentFields).find(findSpanningField(key));
52246
+ const fieldInfo = values$1(parentFields).find(findSpanningField(key));
52247
52247
  if (fieldInfo && fieldInfo.referenceToInfos.length > 0) {
52248
52248
  const { apiName } = fieldInfo.referenceToInfos[0];
52249
- const parentFieldInfo = values(objectInfoMap[recordType].fields).find(findSpanningField(fieldInfo.apiName));
52249
+ const parentFieldInfo = values$1(objectInfoMap[recordType].fields).find(findSpanningField(fieldInfo.apiName));
52250
52250
  if (parentFieldInfo !== undefined) {
52251
52251
  const path = {
52252
52252
  leftPath: `$.fields.${parentFieldInfo.apiName}.value`,
@@ -52388,7 +52388,7 @@ function addResolversToSchema(schema, polyFields) {
52388
52388
  let baseRecord = undefined;
52389
52389
  // Concrete types for Polymorphic field
52390
52390
  const polyTypes = [];
52391
- for (const type of values(schema.getTypeMap())) {
52391
+ for (const type of values$1(schema.getTypeMap())) {
52392
52392
  if (type.name === 'Record') {
52393
52393
  recordInterface = type;
52394
52394
  }
@@ -52401,7 +52401,7 @@ function addResolversToSchema(schema, polyFields) {
52401
52401
  if (polyFields.find((fieldTypeName) => fieldTypeName === type.name) !== undefined) {
52402
52402
  polyTypes.push(type);
52403
52403
  }
52404
- const fields = values(type.getFields());
52404
+ const fields = values$1(type.getFields());
52405
52405
  // initialize the fields of current type with default behavior
52406
52406
  for (const field of fields) {
52407
52407
  field.resolve = defaultFieldResolver;
@@ -52718,7 +52718,7 @@ function generateRecordQueries(objectInfos) {
52718
52718
  let recordConnections = ``;
52719
52719
  const polymorphicFieldTypeNames = new Set();
52720
52720
  let typedScalars = new Set();
52721
- for (const objectInfo of values(objectInfos)) {
52721
+ for (const objectInfo of values$1(objectInfos)) {
52722
52722
  const { apiName, childRelationships } = objectInfo;
52723
52723
  let fields = ``;
52724
52724
  typedScalars.add(`${apiName}_Filter`);
@@ -52734,7 +52734,7 @@ function generateRecordQueries(objectInfos) {
52734
52734
  typedScalars.add(`${childObjectApiName}_OrderBy`);
52735
52735
  }
52736
52736
  }
52737
- for (const field of values(objectInfo.fields)) {
52737
+ for (const field of values$1(objectInfo.fields)) {
52738
52738
  if (!fieldsStaticallyAdded.includes(field.apiName)) {
52739
52739
  fields += `${field.apiName}: ${dataTypeToType(field.dataType, field.apiName)}\n`;
52740
52740
  }
@@ -53237,7 +53237,7 @@ function isMineScopeAvailable(apiNamePath, objectInfoApiMap, objectInfos) {
53237
53237
  const objectInfo = objectInfos[apiName[0]];
53238
53238
  if (!objectInfo)
53239
53239
  return false;
53240
- return values(objectInfo.fields).some((fieldInfo) => {
53240
+ return values$1(objectInfo.fields).some((fieldInfo) => {
53241
53241
  return (fieldInfo.apiName === 'OwnerId' &&
53242
53242
  fieldInfo.referenceToInfos.some((referenceToInfo) => {
53243
53243
  return referenceToInfo.apiName === 'User';
@@ -54488,7 +54488,7 @@ function referenceIdFieldForRelationship(relationshipName) {
54488
54488
  * For full license text, see the LICENSE.txt file
54489
54489
  */
54490
54490
 
54491
- const { keys: keys$2$1, create: create$2$1, assign: assign$2, freeze: freeze$2 } = Object;
54491
+ const { keys: keys$2$1, values, create: create$2$1, assign: assign$2, freeze: freeze$2 } = Object;
54492
54492
  const { stringify: stringify$2, parse: parse$2 } = JSON;
54493
54493
  const { shift } = Array.prototype;
54494
54494
  const { isArray: isArray$1$1 } = Array;
@@ -55219,15 +55219,15 @@ async function getAdapterData(adapter, config) {
55219
55219
  const LDS_ACTION_HANDLER_ID = 'LDS_ACTION_HANDLER';
55220
55220
  const LDS_ACTION_METADATA_API_NAME = 'LDS_ACTION_METADATA_API_NAME';
55221
55221
  class UiApiActionHandler extends AbstractResourceRequestActionHandler {
55222
- constructor(getLuvio, networkAdapter, durableStore, draftQueue, getRecordAdapter, isDraftId, apiNameForPrefix, recordService) {
55222
+ constructor(getLuvio, networkAdapter, durableStore, draftQueue, getRecordAdapter, objectInfoService, isDraftId, recordService) {
55223
55223
  super(draftQueue, networkAdapter, getLuvio);
55224
55224
  this.getLuvio = getLuvio;
55225
55225
  this.networkAdapter = networkAdapter;
55226
55226
  this.durableStore = durableStore;
55227
55227
  this.draftQueue = draftQueue;
55228
55228
  this.getRecordAdapter = getRecordAdapter;
55229
+ this.objectInfoService = objectInfoService;
55229
55230
  this.isDraftId = isDraftId;
55230
- this.apiNameForPrefix = apiNameForPrefix;
55231
55231
  this.recordService = recordService;
55232
55232
  this.handlerId = LDS_ACTION_HANDLER_ID;
55233
55233
  this.collectedFields = create$2$1(null);
@@ -55274,8 +55274,55 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
55274
55274
  throw Error('unknown draft precondition failed');
55275
55275
  }
55276
55276
  }
55277
+ else if (metaDataResult.status === 'missing-referenced-records') {
55278
+ const referenceFields = metaDataResult.missingRecordReferences;
55279
+ if (referenceFields !== undefined) {
55280
+ //fetches the reference record async
55281
+ this.fetchReferenceRecord(referenceFields);
55282
+ }
55283
+ }
55277
55284
  return pendingAction;
55278
55285
  }
55286
+ async fetchReferenceRecord(referenceFields) {
55287
+ const promises = referenceFields.map(async (referenceFieldInfo) => {
55288
+ const apiName = await this.identifyApiName(referenceFieldInfo.id, referenceFieldInfo.field);
55289
+ if (apiName === undefined) {
55290
+ return;
55291
+ }
55292
+ const objectInfoMap = await this.objectInfoService.getObjectInfos([
55293
+ apiName,
55294
+ ]);
55295
+ if (objectInfoMap[apiName] === undefined) {
55296
+ return;
55297
+ }
55298
+ const objectInfo = objectInfoMap[apiName];
55299
+ const optionalFields = values(objectInfo.fields).map((field) => `${apiName}.${field.apiName}`);
55300
+ await getAdapterData(this.getRecordAdapter, {
55301
+ recordId: referenceFieldInfo.id,
55302
+ optionalFields,
55303
+ });
55304
+ });
55305
+ await Promise.all(promises);
55306
+ }
55307
+ /**
55308
+ * 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`
55309
+ * representation
55310
+ * @param id
55311
+ * @param fieldInfo
55312
+ * @returns apiName
55313
+ */
55314
+ async identifyApiName(id, fieldInfo) {
55315
+ const referenceToInfos = fieldInfo.referenceToInfos;
55316
+ const apiNames = referenceToInfos.map((referenceToInfo) => referenceToInfo.apiName);
55317
+ const objectInfoMap = await this.objectInfoService.getObjectInfos(apiNames);
55318
+ for (const objectInfo of values(objectInfoMap)) {
55319
+ const { apiName, keyPrefix } = objectInfo;
55320
+ if (keyPrefix !== null && id.startsWith(keyPrefix)) {
55321
+ return apiName;
55322
+ }
55323
+ }
55324
+ return undefined;
55325
+ }
55279
55326
  canRepresentationContainDraftMetadata(representationName) {
55280
55327
  return representationName === RECORD_REPRESENTATION_NAME$1;
55281
55328
  }
@@ -55453,7 +55500,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
55453
55500
  // as a last resort we'll do a lookup for cached object infos by prefix
55454
55501
  // note this will throw if the object info hasn't been previously cached
55455
55502
  const prefix = recordId.substring(0, 3);
55456
- return this.apiNameForPrefix(prefix);
55503
+ return this.objectInfoService.apiNameForPrefix(prefix);
55457
55504
  }
55458
55505
  /**
55459
55506
  * Inspects the resource request to ensure this handler can handle it
@@ -55895,7 +55942,7 @@ class UiApiDraftRecordService {
55895
55942
  }
55896
55943
  const objectInfoMap = new Map();
55897
55944
  const referenceMap = new Map();
55898
- const missingReferenceKeys = new Set();
55945
+ const referenceFields = [];
55899
55946
  const metadata = {
55900
55947
  luvio: this.getLuvio(),
55901
55948
  userId: this.userId,
@@ -55936,13 +55983,17 @@ class UiApiDraftRecordService {
55936
55983
  continue;
55937
55984
  }
55938
55985
  const key = getRecordKeyForId(this.getLuvio(), id);
55939
- if (referenceMap.has(key) === false && missingReferenceKeys.has(key) === false) {
55986
+ if (referenceMap.has(key) === false &&
55987
+ !referenceFields.some((refInfo) => refInfo.id === id)) {
55940
55988
  const record = await this.durableStore.getDenormalizedRecord(key);
55941
55989
  if (record !== undefined) {
55942
55990
  referenceMap.set(key, record);
55943
55991
  }
55944
55992
  else {
55945
- missingReferenceKeys.add(key);
55993
+ referenceFields.push({
55994
+ id,
55995
+ field: fieldInfo,
55996
+ });
55946
55997
  }
55947
55998
  }
55948
55999
  }
@@ -55955,12 +56006,12 @@ class UiApiDraftRecordService {
55955
56006
  };
55956
56007
  }
55957
56008
  }
55958
- if (missingReferenceKeys.size > 0) {
56009
+ if (referenceFields.length > 0) {
55959
56010
  return {
55960
56011
  ok: true,
55961
56012
  data: metadata,
55962
56013
  status: 'missing-referenced-records',
55963
- missingRecordReferenceKeys: Array.from(missingReferenceKeys),
56014
+ missingRecordReferences: referenceFields,
55964
56015
  };
55965
56016
  }
55966
56017
  return {
@@ -59482,7 +59533,7 @@ function getRuntime() {
59482
59533
  // draft queue
59483
59534
  lazyDraftQueue = buildLdsDraftQueue(recordDenormingStore);
59484
59535
  const draftService = new UiApiDraftRecordService(lazyDraftQueue, () => lazyLuvio, recordDenormingStore, getObjectInfo, newRecordId, userId, formatDisplayValue);
59485
- const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, recordDenormingStore, lazyDraftQueue, getRecord, isGenerated, lazyObjectInfoService.apiNameForPrefix, draftService);
59536
+ const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, recordDenormingStore, lazyDraftQueue, getRecord, lazyObjectInfoService, isGenerated, draftService);
59486
59537
  const quickActionHandler = new QuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated);
59487
59538
  const contentDocumentCompositeActionHandler = new ContentDocumentCompositeRepresentationActionHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, recordDenormingStore, NimbusBinaryStore);
59488
59539
  lazyDraftQueue.addHandler(uiApiRecordHandler);
@@ -59572,7 +59623,7 @@ register({
59572
59623
  id: '@salesforce/lds-network-adapter',
59573
59624
  instrument: instrument$1,
59574
59625
  });
59575
- // version: 1.147.2-2b0ae2d38
59626
+ // version: 1.147.4-a137f215b
59576
59627
 
59577
59628
  const { create: create$2, keys: keys$2 } = Object;
59578
59629
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -80417,7 +80468,7 @@ register({
80417
80468
  configuration: { ...configurationForGraphQLAdapters },
80418
80469
  instrument,
80419
80470
  });
80420
- // version: 1.147.2-be9827ebc
80471
+ // version: 1.147.4-7830883a5
80421
80472
 
80422
80473
  // On core the unstable adapters are re-exported with different names,
80423
80474
 
@@ -82655,7 +82706,7 @@ withDefaultLuvio((luvio) => {
82655
82706
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
82656
82707
  graphQLImperative = ldsAdapter;
82657
82708
  });
82658
- // version: 1.147.2-be9827ebc
82709
+ // version: 1.147.4-7830883a5
82659
82710
 
82660
82711
  var gqlApi = /*#__PURE__*/Object.freeze({
82661
82712
  __proto__: null,
@@ -83344,4 +83395,4 @@ const { luvio } = getRuntime();
83344
83395
  setDefaultLuvio({ luvio });
83345
83396
 
83346
83397
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
83347
- // version: 1.147.2-2b0ae2d38
83398
+ // version: 1.147.4-a137f215b
@@ -30,7 +30,7 @@
30
30
  SnapshotState["Stale"] = "Stale";
31
31
  })(SnapshotState$3 || (SnapshotState$3 = {}));
32
32
 
33
- const { create: create$a, entries: entries$4, freeze: freeze$5, keys: keys$b, values: values$3 } = Object;
33
+ const { create: create$a, entries: entries$4, freeze: freeze$5, keys: keys$b, values: values$4 } = Object;
34
34
  const { hasOwnProperty: hasOwnProperty$3 } = Object.prototype;
35
35
  const { isArray: isArray$9 } = Array;
36
36
  const { push: push$4, indexOf, slice: slice$2 } = Array.prototype;
@@ -3809,7 +3809,7 @@
3809
3809
  }
3810
3810
  callbacks.push(callback);
3811
3811
  }
3812
- // version: 1.147.2-2b0ae2d38
3812
+ // version: 1.147.4-a137f215b
3813
3813
 
3814
3814
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3815
3815
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15233,7 +15233,7 @@
15233
15233
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15234
15234
  return luvioDocumentNode;
15235
15235
  }
15236
- // version: 1.147.2-2b0ae2d38
15236
+ // version: 1.147.4-a137f215b
15237
15237
 
15238
15238
  function unwrap(data) {
15239
15239
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16146,7 +16146,7 @@
16146
16146
  const { apiFamily, name } = metadata;
16147
16147
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16148
16148
  }
16149
- // version: 1.147.2-2b0ae2d38
16149
+ // version: 1.147.4-a137f215b
16150
16150
 
16151
16151
  /**
16152
16152
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44009,7 +44009,7 @@
44009
44009
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44010
44010
  });
44011
44011
  });
44012
- // version: 1.147.2-be9827ebc
44012
+ // version: 1.147.4-7830883a5
44013
44013
 
44014
44014
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44015
44015
 
@@ -45855,7 +45855,7 @@
45855
45855
  function errors(result) {
45856
45856
  return result.error;
45857
45857
  }
45858
- function values$2(result) {
45858
+ function values$3(result) {
45859
45859
  return result.value;
45860
45860
  }
45861
45861
  function flattenResults(results) {
@@ -45863,7 +45863,7 @@
45863
45863
  if (fails.length > 0) {
45864
45864
  return failure(fails);
45865
45865
  }
45866
- return success(results.filter(isSuccess).map(values$2));
45866
+ return success(results.filter(isSuccess).map(values$3));
45867
45867
  }
45868
45868
 
45869
45869
  function getFieldInfo(apiName, fieldName, infoMap) {
@@ -46737,7 +46737,7 @@
46737
46737
  if (failures.length > 0) {
46738
46738
  return failure(failures);
46739
46739
  }
46740
- const containers = results.filter(isSuccess).map(values$2);
46740
+ const containers = results.filter(isSuccess).map(values$3);
46741
46741
  const predicates = [];
46742
46742
  containers.forEach((c) => {
46743
46743
  if (c.predicate !== undefined) {
@@ -47029,7 +47029,7 @@
47029
47029
  if (fails.length > 0) {
47030
47030
  return failure(fails);
47031
47031
  }
47032
- const vals = results.filter(isSuccess).reduce(flatMap$1(values$2), []);
47032
+ const vals = results.filter(isSuccess).reduce(flatMap$1(values$3), []);
47033
47033
  return success(vals);
47034
47034
  }
47035
47035
  function isFilterFunction(name) {
@@ -47039,7 +47039,7 @@
47039
47039
  const results = Object.entries(operatorNode.fields)
47040
47040
  .filter(([key, _]) => isFilterFunction(key) === false)
47041
47041
  .map(([key, value]) => operatorWithValue(key, value, dataType));
47042
- const _values = results.filter(isSuccess).map(values$2);
47042
+ const _values = results.filter(isSuccess).map(values$3);
47043
47043
  const fails = results.filter(isFailure).reduce(flatMap$1(errors), []);
47044
47044
  if (fails.length > 0) {
47045
47045
  return failure(fails);
@@ -47960,7 +47960,7 @@
47960
47960
  }
47961
47961
  function recordFields(luvioSelections, names, parentApiName, parentAlias, input, joins) {
47962
47962
  const results = luvioSelections.map((selection) => selectionToQueryField(selection, names, parentApiName, parentAlias, input, joins));
47963
- const fields = results.filter(isSuccess).reduce(flatMap$1(values$2), []);
47963
+ const fields = results.filter(isSuccess).reduce(flatMap$1(values$3), []);
47964
47964
  const fails = results.filter(isFailure).reduce(flatMap$1(errors), []);
47965
47965
  if (fails.length > 0) {
47966
47966
  return failure(fails);
@@ -48165,7 +48165,7 @@
48165
48165
  }
48166
48166
  function rootQuery(recordNodes, input) {
48167
48167
  const results = recordNodes.map((record) => rootRecordQuery(record, input));
48168
- const connections = results.filter(isSuccess).map(values$2);
48168
+ const connections = results.filter(isSuccess).map(values$3);
48169
48169
  const fails = results.filter(isFailure).reduce(flatMap$1(errors), []);
48170
48170
  if (fails.length > 0) {
48171
48171
  return failure(fails);
@@ -48904,7 +48904,7 @@
48904
48904
  return new DraftErrorFetchResponse(HttpStatusCode$1.BadRequest, error);
48905
48905
  }
48906
48906
 
48907
- const { keys: keys$4, create: create$4, assign: assign$3, values: values$1 } = Object;
48907
+ const { keys: keys$4, create: create$4, assign: assign$3, values: values$2 } = Object;
48908
48908
  const { stringify: stringify$4, parse: parse$4 } = JSON;
48909
48909
  const { isArray: isArray$3 } = Array;
48910
48910
 
@@ -49279,7 +49279,7 @@
49279
49279
  const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
49280
49280
  // write the queue operations to the store prior to ingesting the result
49281
49281
  await this.draftStore.completeAction(queueOperations);
49282
- await handler.handleActionCompleted(action, queueOperations, values$1(this.handlers));
49282
+ await handler.handleActionCompleted(action, queueOperations, values$2(this.handlers));
49283
49283
  this.retryIntervalMilliseconds = 0;
49284
49284
  this.uploadingActionId = undefined;
49285
49285
  await this.notifyChangedListeners({
@@ -50602,7 +50602,7 @@
50602
50602
  (x.length === 0 || (x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1))));
50603
50603
  }
50604
50604
 
50605
- const { create: create$3, keys: keys$3, values, entries: entries$2 } = Object;
50605
+ const { create: create$3, keys: keys$3, values: values$1, entries: entries$2 } = Object;
50606
50606
  const { stringify: stringify$3, parse: parse$3 } = JSON;
50607
50607
  const { isArray: isArray$2 } = Array;
50608
50608
 
@@ -50935,7 +50935,7 @@
50935
50935
  return predicate;
50936
50936
  }
50937
50937
  else if (literal !== undefined) {
50938
- const isAvailableLiteral = values(DateLiteral).includes(literal);
50938
+ const isAvailableLiteral = values$1(DateLiteral).includes(literal);
50939
50939
  // eslint-disable-next-line @salesforce/lds/no-error-in-production
50940
50940
  if (!isAvailableLiteral)
50941
50941
  throw new Error(`${literal} is not a valid DateLiteral`);
@@ -51597,7 +51597,7 @@
51597
51597
  for (const join of joins) {
51598
51598
  deduped[join.alias + join.to] = join;
51599
51599
  }
51600
- return values(deduped);
51600
+ return values$1(deduped);
51601
51601
  }
51602
51602
  function buildJoins(config) {
51603
51603
  let sql = '';
@@ -52231,7 +52231,7 @@
52231
52231
  return previous.concat(current);
52232
52232
  }
52233
52233
  function findFieldInfo(objectInfo, fieldName) {
52234
- return values(objectInfo.fields).find((field) => field.apiName === fieldName ||
52234
+ return values$1(objectInfo.fields).find((field) => field.apiName === fieldName ||
52235
52235
  (field.dataType === 'Reference' && field.relationshipName === fieldName));
52236
52236
  }
52237
52237
 
@@ -52251,10 +52251,10 @@
52251
52251
  for (let i = 0, len = keys$1.length; i < len; i++) {
52252
52252
  const key = keys$1[i];
52253
52253
  const parentFields = objectInfoMap[recordType].fields;
52254
- const fieldInfo = values(parentFields).find(findSpanningField(key));
52254
+ const fieldInfo = values$1(parentFields).find(findSpanningField(key));
52255
52255
  if (fieldInfo && fieldInfo.referenceToInfos.length > 0) {
52256
52256
  const { apiName } = fieldInfo.referenceToInfos[0];
52257
- const parentFieldInfo = values(objectInfoMap[recordType].fields).find(findSpanningField(fieldInfo.apiName));
52257
+ const parentFieldInfo = values$1(objectInfoMap[recordType].fields).find(findSpanningField(fieldInfo.apiName));
52258
52258
  if (parentFieldInfo !== undefined) {
52259
52259
  const path = {
52260
52260
  leftPath: `$.fields.${parentFieldInfo.apiName}.value`,
@@ -52396,7 +52396,7 @@
52396
52396
  let baseRecord = undefined;
52397
52397
  // Concrete types for Polymorphic field
52398
52398
  const polyTypes = [];
52399
- for (const type of values(schema.getTypeMap())) {
52399
+ for (const type of values$1(schema.getTypeMap())) {
52400
52400
  if (type.name === 'Record') {
52401
52401
  recordInterface = type;
52402
52402
  }
@@ -52409,7 +52409,7 @@
52409
52409
  if (polyFields.find((fieldTypeName) => fieldTypeName === type.name) !== undefined) {
52410
52410
  polyTypes.push(type);
52411
52411
  }
52412
- const fields = values(type.getFields());
52412
+ const fields = values$1(type.getFields());
52413
52413
  // initialize the fields of current type with default behavior
52414
52414
  for (const field of fields) {
52415
52415
  field.resolve = defaultFieldResolver;
@@ -52726,7 +52726,7 @@
52726
52726
  let recordConnections = ``;
52727
52727
  const polymorphicFieldTypeNames = new Set();
52728
52728
  let typedScalars = new Set();
52729
- for (const objectInfo of values(objectInfos)) {
52729
+ for (const objectInfo of values$1(objectInfos)) {
52730
52730
  const { apiName, childRelationships } = objectInfo;
52731
52731
  let fields = ``;
52732
52732
  typedScalars.add(`${apiName}_Filter`);
@@ -52742,7 +52742,7 @@
52742
52742
  typedScalars.add(`${childObjectApiName}_OrderBy`);
52743
52743
  }
52744
52744
  }
52745
- for (const field of values(objectInfo.fields)) {
52745
+ for (const field of values$1(objectInfo.fields)) {
52746
52746
  if (!fieldsStaticallyAdded.includes(field.apiName)) {
52747
52747
  fields += `${field.apiName}: ${dataTypeToType(field.dataType, field.apiName)}\n`;
52748
52748
  }
@@ -53245,7 +53245,7 @@
53245
53245
  const objectInfo = objectInfos[apiName[0]];
53246
53246
  if (!objectInfo)
53247
53247
  return false;
53248
- return values(objectInfo.fields).some((fieldInfo) => {
53248
+ return values$1(objectInfo.fields).some((fieldInfo) => {
53249
53249
  return (fieldInfo.apiName === 'OwnerId' &&
53250
53250
  fieldInfo.referenceToInfos.some((referenceToInfo) => {
53251
53251
  return referenceToInfo.apiName === 'User';
@@ -54496,7 +54496,7 @@
54496
54496
  * For full license text, see the LICENSE.txt file
54497
54497
  */
54498
54498
 
54499
- const { keys: keys$2$1, create: create$2$1, assign: assign$2, freeze: freeze$2 } = Object;
54499
+ const { keys: keys$2$1, values, create: create$2$1, assign: assign$2, freeze: freeze$2 } = Object;
54500
54500
  const { stringify: stringify$2, parse: parse$2 } = JSON;
54501
54501
  const { shift } = Array.prototype;
54502
54502
  const { isArray: isArray$1$1 } = Array;
@@ -55227,15 +55227,15 @@
55227
55227
  const LDS_ACTION_HANDLER_ID = 'LDS_ACTION_HANDLER';
55228
55228
  const LDS_ACTION_METADATA_API_NAME = 'LDS_ACTION_METADATA_API_NAME';
55229
55229
  class UiApiActionHandler extends AbstractResourceRequestActionHandler {
55230
- constructor(getLuvio, networkAdapter, durableStore, draftQueue, getRecordAdapter, isDraftId, apiNameForPrefix, recordService) {
55230
+ constructor(getLuvio, networkAdapter, durableStore, draftQueue, getRecordAdapter, objectInfoService, isDraftId, recordService) {
55231
55231
  super(draftQueue, networkAdapter, getLuvio);
55232
55232
  this.getLuvio = getLuvio;
55233
55233
  this.networkAdapter = networkAdapter;
55234
55234
  this.durableStore = durableStore;
55235
55235
  this.draftQueue = draftQueue;
55236
55236
  this.getRecordAdapter = getRecordAdapter;
55237
+ this.objectInfoService = objectInfoService;
55237
55238
  this.isDraftId = isDraftId;
55238
- this.apiNameForPrefix = apiNameForPrefix;
55239
55239
  this.recordService = recordService;
55240
55240
  this.handlerId = LDS_ACTION_HANDLER_ID;
55241
55241
  this.collectedFields = create$2$1(null);
@@ -55282,8 +55282,55 @@
55282
55282
  throw Error('unknown draft precondition failed');
55283
55283
  }
55284
55284
  }
55285
+ else if (metaDataResult.status === 'missing-referenced-records') {
55286
+ const referenceFields = metaDataResult.missingRecordReferences;
55287
+ if (referenceFields !== undefined) {
55288
+ //fetches the reference record async
55289
+ this.fetchReferenceRecord(referenceFields);
55290
+ }
55291
+ }
55285
55292
  return pendingAction;
55286
55293
  }
55294
+ async fetchReferenceRecord(referenceFields) {
55295
+ const promises = referenceFields.map(async (referenceFieldInfo) => {
55296
+ const apiName = await this.identifyApiName(referenceFieldInfo.id, referenceFieldInfo.field);
55297
+ if (apiName === undefined) {
55298
+ return;
55299
+ }
55300
+ const objectInfoMap = await this.objectInfoService.getObjectInfos([
55301
+ apiName,
55302
+ ]);
55303
+ if (objectInfoMap[apiName] === undefined) {
55304
+ return;
55305
+ }
55306
+ const objectInfo = objectInfoMap[apiName];
55307
+ const optionalFields = values(objectInfo.fields).map((field) => `${apiName}.${field.apiName}`);
55308
+ await getAdapterData(this.getRecordAdapter, {
55309
+ recordId: referenceFieldInfo.id,
55310
+ optionalFields,
55311
+ });
55312
+ });
55313
+ await Promise.all(promises);
55314
+ }
55315
+ /**
55316
+ * 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`
55317
+ * representation
55318
+ * @param id
55319
+ * @param fieldInfo
55320
+ * @returns apiName
55321
+ */
55322
+ async identifyApiName(id, fieldInfo) {
55323
+ const referenceToInfos = fieldInfo.referenceToInfos;
55324
+ const apiNames = referenceToInfos.map((referenceToInfo) => referenceToInfo.apiName);
55325
+ const objectInfoMap = await this.objectInfoService.getObjectInfos(apiNames);
55326
+ for (const objectInfo of values(objectInfoMap)) {
55327
+ const { apiName, keyPrefix } = objectInfo;
55328
+ if (keyPrefix !== null && id.startsWith(keyPrefix)) {
55329
+ return apiName;
55330
+ }
55331
+ }
55332
+ return undefined;
55333
+ }
55287
55334
  canRepresentationContainDraftMetadata(representationName) {
55288
55335
  return representationName === RECORD_REPRESENTATION_NAME$1;
55289
55336
  }
@@ -55461,7 +55508,7 @@
55461
55508
  // as a last resort we'll do a lookup for cached object infos by prefix
55462
55509
  // note this will throw if the object info hasn't been previously cached
55463
55510
  const prefix = recordId.substring(0, 3);
55464
- return this.apiNameForPrefix(prefix);
55511
+ return this.objectInfoService.apiNameForPrefix(prefix);
55465
55512
  }
55466
55513
  /**
55467
55514
  * Inspects the resource request to ensure this handler can handle it
@@ -55903,7 +55950,7 @@
55903
55950
  }
55904
55951
  const objectInfoMap = new Map();
55905
55952
  const referenceMap = new Map();
55906
- const missingReferenceKeys = new Set();
55953
+ const referenceFields = [];
55907
55954
  const metadata = {
55908
55955
  luvio: this.getLuvio(),
55909
55956
  userId: this.userId,
@@ -55944,13 +55991,17 @@
55944
55991
  continue;
55945
55992
  }
55946
55993
  const key = getRecordKeyForId(this.getLuvio(), id);
55947
- if (referenceMap.has(key) === false && missingReferenceKeys.has(key) === false) {
55994
+ if (referenceMap.has(key) === false &&
55995
+ !referenceFields.some((refInfo) => refInfo.id === id)) {
55948
55996
  const record = await this.durableStore.getDenormalizedRecord(key);
55949
55997
  if (record !== undefined) {
55950
55998
  referenceMap.set(key, record);
55951
55999
  }
55952
56000
  else {
55953
- missingReferenceKeys.add(key);
56001
+ referenceFields.push({
56002
+ id,
56003
+ field: fieldInfo,
56004
+ });
55954
56005
  }
55955
56006
  }
55956
56007
  }
@@ -55963,12 +56014,12 @@
55963
56014
  };
55964
56015
  }
55965
56016
  }
55966
- if (missingReferenceKeys.size > 0) {
56017
+ if (referenceFields.length > 0) {
55967
56018
  return {
55968
56019
  ok: true,
55969
56020
  data: metadata,
55970
56021
  status: 'missing-referenced-records',
55971
- missingRecordReferenceKeys: Array.from(missingReferenceKeys),
56022
+ missingRecordReferences: referenceFields,
55972
56023
  };
55973
56024
  }
55974
56025
  return {
@@ -59490,7 +59541,7 @@
59490
59541
  // draft queue
59491
59542
  lazyDraftQueue = buildLdsDraftQueue(recordDenormingStore);
59492
59543
  const draftService = new UiApiDraftRecordService(lazyDraftQueue, () => lazyLuvio, recordDenormingStore, getObjectInfo, newRecordId, userId, formatDisplayValue);
59493
- const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, recordDenormingStore, lazyDraftQueue, getRecord, isGenerated, lazyObjectInfoService.apiNameForPrefix, draftService);
59544
+ const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, recordDenormingStore, lazyDraftQueue, getRecord, lazyObjectInfoService, isGenerated, draftService);
59494
59545
  const quickActionHandler = new QuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated);
59495
59546
  const contentDocumentCompositeActionHandler = new ContentDocumentCompositeRepresentationActionHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, recordDenormingStore, NimbusBinaryStore);
59496
59547
  lazyDraftQueue.addHandler(uiApiRecordHandler);
@@ -59580,7 +59631,7 @@
59580
59631
  id: '@salesforce/lds-network-adapter',
59581
59632
  instrument: instrument$1,
59582
59633
  });
59583
- // version: 1.147.2-2b0ae2d38
59634
+ // version: 1.147.4-a137f215b
59584
59635
 
59585
59636
  const { create: create$2, keys: keys$2 } = Object;
59586
59637
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -80425,7 +80476,7 @@
80425
80476
  configuration: { ...configurationForGraphQLAdapters },
80426
80477
  instrument,
80427
80478
  });
80428
- // version: 1.147.2-be9827ebc
80479
+ // version: 1.147.4-7830883a5
80429
80480
 
80430
80481
  // On core the unstable adapters are re-exported with different names,
80431
80482
 
@@ -82663,7 +82714,7 @@
82663
82714
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
82664
82715
  graphQLImperative = ldsAdapter;
82665
82716
  });
82666
- // version: 1.147.2-be9827ebc
82717
+ // version: 1.147.4-7830883a5
82667
82718
 
82668
82719
  var gqlApi = /*#__PURE__*/Object.freeze({
82669
82720
  __proto__: null,
@@ -83369,4 +83420,4 @@
83369
83420
  Object.defineProperty(exports, '__esModule', { value: true });
83370
83421
 
83371
83422
  }));
83372
- // version: 1.147.2-2b0ae2d38
83423
+ // version: 1.147.4-a137f215b
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.147.2",
3
+ "version": "1.147.4",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",