@salesforce/lds-adapters-uiapi 1.182.0 → 1.183.0

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.
@@ -1,4 +1,4 @@
1
- import type { AdapterRequestContext, Luvio, Snapshot } from '@luvio/engine';
1
+ import type { AdapterContext, AdapterRequestContext, Luvio, Snapshot } from '@luvio/engine';
2
2
  import type { RecordRepresentation } from '../../generated/types/RecordRepresentation';
3
3
  import { LayoutMode } from '../../primitives/LayoutMode';
4
4
  import type { LayoutType } from '../../primitives/LayoutType';
@@ -8,4 +8,4 @@ export interface GetRecordLayoutTypeConfig {
8
8
  modes?: LayoutMode[];
9
9
  optionalFields?: string[];
10
10
  }
11
- export declare function getRecordLayoutType(luvio: Luvio, config: GetRecordLayoutTypeConfig, requestContext?: AdapterRequestContext): Snapshot<RecordRepresentation> | Promise<Snapshot<RecordRepresentation>>;
11
+ export declare function getRecordLayoutType(luvio: Luvio, config: GetRecordLayoutTypeConfig, adapterContext: AdapterContext, requestContext?: AdapterRequestContext): Snapshot<RecordRepresentation> | Promise<Snapshot<RecordRepresentation>>;
@@ -5155,6 +5155,7 @@ function toSortedStringArray(value) {
5155
5155
  return undefined;
5156
5156
  }
5157
5157
 
5158
+ const adapterName$5 = 'getRecord';
5158
5159
  const oneOfConfigPropertiesIdentifier$1 = [
5159
5160
  'layoutTypes',
5160
5161
  'fields',
@@ -9212,7 +9213,7 @@ const factory$j = (luvio) => function getMruListUi(untrustedConfig, requestConte
9212
9213
  : processListInfo(listInfoPromiseOrSnapshot);
9213
9214
  };
9214
9215
 
9215
- const contextId$4 = `${keyPrefix}__getListUi`;
9216
+ const contextId$5 = `${keyPrefix}__getListUi`;
9216
9217
  // eslint-disable-next-line @salesforce/lds/no-invalid-todo
9217
9218
  // TODO RAML - this more properly goes in the generated resource files
9218
9219
  const DEFAULT_PAGE_SIZE = 50;
@@ -9641,7 +9642,7 @@ const factory$i = (luvio) => {
9641
9642
  return listUiAdapter(untrustedConfig, adapterContext, requestContext);
9642
9643
  }
9643
9644
  return null;
9644
- }, { contextId: contextId$4 });
9645
+ }, { contextId: contextId$5 });
9645
9646
  };
9646
9647
 
9647
9648
  function validate$1r(obj, path = 'ChildRelationshipRepresentation') {
@@ -12424,6 +12425,10 @@ function buildSnapshotRefresh$3(luvio, config) {
12424
12425
  resolve: () => refresh(luvio, config),
12425
12426
  };
12426
12427
  }
12428
+ function buildObjectInfoSelectorKey(luvio, objectInfo) {
12429
+ const key = keyBuilderFromType$s(luvio, objectInfo);
12430
+ return `${key}__implicit__fields__selector`;
12431
+ }
12427
12432
  function refresh(luvio, config) {
12428
12433
  const { recordId, layoutTypes, modes: configModes, optionalFields: configOptionalFields, } = config;
12429
12434
  const modes = configModes === undefined ? [DEFAULT_MODE] : configModes;
@@ -12477,7 +12482,13 @@ function getLayoutMapAndObjectInfo(recordId, data) {
12477
12482
  objectInfo,
12478
12483
  };
12479
12484
  }
12480
- function processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, optionalFields) {
12485
+ function getFields(recordId, data) {
12486
+ const { records } = data;
12487
+ const record = records[recordId];
12488
+ const { fields } = record;
12489
+ return fields;
12490
+ }
12491
+ function processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, adapterContext, optionalFields) {
12481
12492
  if (isErrorSnapshot(snapshot)) {
12482
12493
  return luvio.errorSnapshot(snapshot.error, refresh);
12483
12494
  }
@@ -12492,7 +12503,12 @@ function processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot
12492
12503
  throw new Error(`RecordUi adapter resolved with a ${snapshot.state} snapshot with undefined data`);
12493
12504
  }
12494
12505
  const { layoutMap, objectInfo } = getLayoutMapAndObjectInfo(recordId, data);
12495
- return getRecord(luvio, refresh, recordId, layoutMap, objectInfo, optionalFields);
12506
+ if (objectInfo.layoutable) {
12507
+ return getRecordForLayoutableEntities(luvio, refresh, recordId, layoutMap, objectInfo, optionalFields);
12508
+ }
12509
+ else {
12510
+ return getRecordForNonLayoutableEntities(luvio, adapterContext, refresh, recordId, objectInfo, optionalFields, getFields(recordId, data));
12511
+ }
12496
12512
  }
12497
12513
  const recordLayoutFragmentSelector = [
12498
12514
  {
@@ -12519,8 +12535,20 @@ function getFieldsFromLayoutMap(layoutMap, objectInfo) {
12519
12535
  }
12520
12536
  return dedupe(fields).sort();
12521
12537
  }
12522
- function getRecord(luvio, refresh, recordId, layoutMap, objectInfo, configOptionalFields) {
12538
+ function getRecordForLayoutableEntities(luvio, refresh, recordId, layoutMap, objectInfo, configOptionalFields) {
12523
12539
  const fields = getFieldsFromLayoutMap(layoutMap, objectInfo);
12540
+ return getRecord(luvio, refresh, recordId, fields, configOptionalFields);
12541
+ }
12542
+ function getRecordForNonLayoutableEntities(luvio, adapterContext, refresh, recordId, objectInfo, configOptionalFields, configFields) {
12543
+ const fields = keys(configFields ? configFields : {}).map((key) => `${objectInfo.apiName}.${key}`);
12544
+ // W-12697744
12545
+ // Set the implicit fields received from the server in adapter context
12546
+ // This ensures that the implicit fields are available when data is read locally or from durable store
12547
+ const selectorKey = buildObjectInfoSelectorKey(luvio, objectInfo);
12548
+ adapterContext.set(selectorKey, fields);
12549
+ return getRecord(luvio, refresh, recordId, fields, configOptionalFields);
12550
+ }
12551
+ function getRecord(luvio, refresh, recordId, fields, configOptionalFields) {
12524
12552
  const optionalFields = configOptionalFields === undefined ? [] : dedupe(configOptionalFields).sort();
12525
12553
  // We know what fields we need so delegate to getRecordByFields
12526
12554
  // This should be a cache hit because we just fetched the record-ui
@@ -12542,7 +12570,7 @@ function getRecord(luvio, refresh, recordId, layoutMap, objectInfo, configOption
12542
12570
  return recordSnapshotOrPromise;
12543
12571
  }
12544
12572
  function buildNetworkSnapshot$V(context, coercedAdapterRequestContext) {
12545
- const { config, luvio } = context;
12573
+ const { config, luvio, adapterContext } = context;
12546
12574
  const { recordId } = config;
12547
12575
  const optionalFields = config.optionalFields === undefined ? [] : dedupe(config.optionalFields).sort();
12548
12576
  const refresh = buildSnapshotRefresh$3(luvio, config);
@@ -12579,7 +12607,7 @@ function buildNetworkSnapshot$V(context, coercedAdapterRequestContext) {
12579
12607
  modes,
12580
12608
  optionalFields,
12581
12609
  };
12582
- return buildNetworkSnapshot$W(luvio, recordUiConfig, dispatchOptions).then((snapshot) => processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, optionalFields));
12610
+ return buildNetworkSnapshot$W(luvio, recordUiConfig, dispatchOptions).then((snapshot) => processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, adapterContext, optionalFields));
12583
12611
  }
12584
12612
  function buildRecordLayoutCachedSnapshot(context, storeLookup) {
12585
12613
  const { config, luvio } = context;
@@ -12631,13 +12659,13 @@ const buildLayoutModeCacheSnapshot = (apiName, recordTypeId, layoutType, mode) =
12631
12659
  * @param {GetRecordLayoutTypeConfig} config
12632
12660
  * @param {BuildCachedSnapshot<BuildSnapshotContext} cachedSnapshot
12633
12661
  */
12634
- function makeCacheOnlySnapshot(luvio, config, cachedSnapshot) {
12662
+ function makeCacheOnlySnapshot(luvio, config, adapterContext, cachedSnapshot) {
12635
12663
  return luvio.applyCachePolicy({
12636
12664
  cachePolicy: {
12637
12665
  // only looking in the cache so we can check for L2 data offline
12638
12666
  type: 'only-if-cached',
12639
12667
  },
12640
- }, { config, luvio }, cachedSnapshot,
12668
+ }, { config, luvio, adapterContext }, cachedSnapshot,
12641
12669
  // this won't be invoked since we're requesting only-if-cached
12642
12670
  () => {
12643
12671
  throw Error('buildNetworkSnapshot should not be called for only-if-cached policy');
@@ -12650,37 +12678,50 @@ function makeCacheOnlySnapshot(luvio, config, cachedSnapshot) {
12650
12678
  * @param {GetRecordLayoutTypeConfig} config
12651
12679
  * @param {AdapterRequestContext} requestContext?
12652
12680
  */
12653
- function makeNetworkOnlySnapshot(luvio, config, requestContext) {
12654
- return luvio.applyCachePolicy(requestContext || {}, { config, luvio }, () => {
12681
+ function makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext) {
12682
+ return luvio.applyCachePolicy(requestContext || {}, { config, luvio, adapterContext }, () => {
12655
12683
  return undefined;
12656
12684
  }, buildNetworkSnapshot$V);
12657
12685
  }
12658
- function getRecordLayoutType(luvio, config, requestContext) {
12686
+ function getRecordLayoutType(luvio, config, adapterContext, requestContext) {
12659
12687
  // lookup record layout
12660
- const recordLayoutSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, buildRecordLayoutCachedSnapshot);
12688
+ const recordLayoutSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, adapterContext, buildRecordLayoutCachedSnapshot);
12661
12689
  return runSnapshotOrPromise(recordLayoutSnapshotOrPromise, (recordLayoutSnapshot) => {
12662
12690
  // if record layout is not fulfulled or data is undefined send to the network
12663
12691
  if (recordLayoutSnapshot.state === 'Unfulfilled' ||
12664
12692
  recordLayoutSnapshot.state === 'Error' ||
12665
12693
  recordLayoutSnapshot.data === undefined) {
12666
- return makeNetworkOnlySnapshot(luvio, config, requestContext);
12694
+ return makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext);
12667
12695
  }
12668
12696
  // lookup object info
12669
- const objectInfoSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, buildObjectInfoCacheSnapshot(recordLayoutSnapshot));
12697
+ const objectInfoSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, adapterContext, buildObjectInfoCacheSnapshot(recordLayoutSnapshot));
12670
12698
  return runSnapshotOrPromise(objectInfoSnapshotOrPromise, (objectInfoSnapshot) => {
12671
12699
  const { layoutTypes } = config;
12672
12700
  // if not fulfilled or missing data send to the network
12673
12701
  if (objectInfoSnapshot.state === 'Unfulfilled' ||
12674
12702
  objectInfoSnapshot.state === 'Error' ||
12675
12703
  objectInfoSnapshot.data === undefined) {
12676
- return makeNetworkOnlySnapshot(luvio, config, requestContext);
12704
+ return makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext);
12677
12705
  }
12678
12706
  const { data: record } = recordLayoutSnapshot;
12679
12707
  // try to load all the requested layouts from cache
12680
12708
  const recordTypeId = getRecordTypeId$2(record);
12681
12709
  const modes = config.modes === undefined ? [DEFAULT_MODE] : config.modes;
12682
- return makeRecordLayoutMap(luvio, config, objectInfoSnapshot.data.apiName, recordTypeId, layoutTypes, modes).then((recordLayoutMap) => {
12683
- return luvio.applyCachePolicy(requestContext || {}, { config, luvio }, buildRecordLayoutSnapshot(recordLayoutMap, luvio, config, recordLayoutSnapshot, objectInfoSnapshot), buildNetworkSnapshot$V);
12710
+ // W-12697744
12711
+ // For non-layoutable entities, use the implicit fields as the fields are not available in layout
12712
+ // Fields can be fetched from adapter context if the server request was already made at some point in the past
12713
+ // If fields are not available in adapter context, make a network request to get the data
12714
+ // and store implicit fields in adapter context.
12715
+ if (!objectInfoSnapshot.data.layoutable) {
12716
+ const selectorKey = buildObjectInfoSelectorKey(luvio, objectInfoSnapshot.data);
12717
+ const fields = adapterContext.get(selectorKey);
12718
+ if (!fields) {
12719
+ return makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext);
12720
+ }
12721
+ return luvio.applyCachePolicy(requestContext || {}, { config, luvio, adapterContext }, buildRecordSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields), buildNetworkSnapshot$V);
12722
+ }
12723
+ return makeRecordLayoutMap(luvio, config, objectInfoSnapshot.data.apiName, recordTypeId, layoutTypes, modes, adapterContext).then((recordLayoutMap) => {
12724
+ return luvio.applyCachePolicy(requestContext || {}, { config, luvio, adapterContext }, buildRecordLayoutSnapshot(recordLayoutMap, luvio, config, recordLayoutSnapshot, objectInfoSnapshot), buildNetworkSnapshot$V);
12684
12725
  });
12685
12726
  });
12686
12727
  });
@@ -12695,13 +12736,13 @@ function getRecordLayoutType(luvio, config, requestContext) {
12695
12736
  * @param {LayoutType[]} layoutTypes
12696
12737
  * @param {LayoutMode[]} modes
12697
12738
  */
12698
- function makeRecordLayoutMap(luvio, config, apiName, recordTypeId, layoutTypes, modes) {
12739
+ function makeRecordLayoutMap(luvio, config, apiName, recordTypeId, layoutTypes, modes, adapterContext) {
12699
12740
  let promises = [];
12700
12741
  for (let i = 0; i < layoutTypes.length; i++) {
12701
12742
  const layoutType = layoutTypes[i];
12702
12743
  for (let m = 0; m < modes.length; m++) {
12703
12744
  const mode = modes[m];
12704
- promises.push(Promise.resolve(makeCacheOnlySnapshot(luvio, config, buildLayoutModeCacheSnapshot(apiName, recordTypeId, layoutType, mode))).then((snapshot) => {
12745
+ promises.push(Promise.resolve(makeCacheOnlySnapshot(luvio, config, adapterContext, buildLayoutModeCacheSnapshot(apiName, recordTypeId, layoutType, mode))).then((snapshot) => {
12705
12746
  return {
12706
12747
  layoutType,
12707
12748
  mode,
@@ -12741,34 +12782,46 @@ function makeRecordLayoutMap(luvio, config, apiName, recordTypeId, layoutTypes,
12741
12782
  }
12742
12783
  function buildRecordLayoutSnapshot(recordLayout, luvio, config, recordLayoutSnapshot, objectInfoSnapshot) {
12743
12784
  return (context, storeLookup) => {
12744
- const { layoutMap, isStale } = recordLayout;
12785
+ const { layoutMap, isStale: isRecordLayoutStale } = recordLayout;
12745
12786
  if (layoutMap === undefined || objectInfoSnapshot.data === undefined) {
12746
12787
  return;
12747
12788
  }
12748
12789
  // transform the layouts & object info into a set of fields
12749
12790
  const fields = getFieldsFromLayoutMap(layoutMap, objectInfoSnapshot.data);
12750
- const optionalFields = config.optionalFields === undefined ? [] : dedupe(config.optionalFields).sort();
12751
- const { recordId } = config;
12752
- // borrow GetRecordFields' logic to construct the RecordRepresentation with the necessary fields
12753
- const sel = buildRecordSelector(luvio, recordId, fields, optionalFields);
12754
- const recordRepSnapshot = storeLookup(sel, buildSnapshotRefresh$3(luvio, config));
12755
- if (isFulfilledSnapshot(recordRepSnapshot)) {
12756
- // mark snapshot as stale if any of the information used to construct it was stale
12757
- if (isStaleSnapshot(recordLayoutSnapshot) ||
12758
- isStaleSnapshot(objectInfoSnapshot) ||
12759
- isStale) {
12760
- recordRepSnapshot.state = 'Stale';
12761
- }
12762
- }
12763
- // allow buildNetworkSnapshot() to use GetRecordFields if we were just missing some fields in L1
12764
- else if (isUnfulfilledSnapshot(recordRepSnapshot)) {
12765
- context.fields = fields;
12766
- }
12767
- // return however much of the record we were able to find in L1; cache policy decides if we
12768
- // should consult L2 or go to network
12769
- return recordRepSnapshot;
12791
+ return getRecordRepSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields, isRecordLayoutStale, context, storeLookup);
12770
12792
  };
12771
12793
  }
12794
+ function buildRecordSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields) {
12795
+ return (context, storeLookup) => {
12796
+ return getRecordRepSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields, false, context, storeLookup);
12797
+ };
12798
+ }
12799
+ function getRecordRepSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields, isRecordLayoutStale, context, storeLookup) {
12800
+ if (objectInfoSnapshot.data === undefined) {
12801
+ return;
12802
+ }
12803
+ // transform the layouts & object info into a set of fields
12804
+ const optionalFields = config.optionalFields === undefined ? [] : dedupe(config.optionalFields).sort();
12805
+ const { recordId } = config;
12806
+ // borrow GetRecordFields' logic to construct the RecordRepresentation with the necessary fields
12807
+ const sel = buildRecordSelector(luvio, recordId, fields, optionalFields);
12808
+ const recordRepSnapshot = storeLookup(sel, buildSnapshotRefresh$3(luvio, config));
12809
+ if (isFulfilledSnapshot(recordRepSnapshot)) {
12810
+ // mark snapshot as stale if any of the information used to construct it was stale
12811
+ if (isStaleSnapshot(objectInfoSnapshot) ||
12812
+ isStaleSnapshot(recordLayoutSnapshot) ||
12813
+ isRecordLayoutStale) {
12814
+ recordRepSnapshot.state = 'Stale';
12815
+ }
12816
+ }
12817
+ // allow buildNetworkSnapshot() to use GetRecordFields if we were just missing some fields in L1
12818
+ else if (isUnfulfilledSnapshot(recordRepSnapshot)) {
12819
+ context.fields = fields;
12820
+ }
12821
+ // return however much of the record we were able to find in L1; cache policy decides if we
12822
+ // should consult L2 or go to network
12823
+ return recordRepSnapshot;
12824
+ }
12772
12825
  function runSnapshotOrPromise(promiseOrSnapshot, next) {
12773
12826
  if (isPromise(promiseOrSnapshot)) {
12774
12827
  return promiseOrSnapshot.then(next);
@@ -12778,6 +12831,7 @@ function runSnapshotOrPromise(promiseOrSnapshot, next) {
12778
12831
  }
12779
12832
  }
12780
12833
 
12834
+ const contextId$4 = `${keyPrefix}__${adapterName$5}`;
12781
12835
  // Custom adapter config due to `unsupported` items
12782
12836
  const GET_RECORD_ADAPTER_CONFIG = {
12783
12837
  displayName: 'getRecord',
@@ -12868,19 +12922,21 @@ const notifyChangeFactory = (luvio) => {
12868
12922
  });
12869
12923
  };
12870
12924
  };
12871
- const factory$g = (luvio) => function getRecord(untrustedConfig, requestContext) {
12872
- // standard config validation and coercion
12873
- const config = validateAdapterConfig$12(untrustedConfig, GET_RECORD_ADAPTER_CONFIG);
12874
- if (config === null) {
12925
+ const factory$g = (luvio) => {
12926
+ return luvio.withContext(function getRecord(untrustedConfig, adapterContext, requestContext) {
12927
+ // standard config validation and coercion
12928
+ const config = validateAdapterConfig$12(untrustedConfig, GET_RECORD_ADAPTER_CONFIG);
12929
+ if (config === null) {
12930
+ return null;
12931
+ }
12932
+ if (hasLayoutTypes(config)) {
12933
+ return getRecordLayoutType(luvio, config, adapterContext, requestContext);
12934
+ }
12935
+ else if (hasFieldsOrOptionalFields(config)) {
12936
+ return getRecordByFields(luvio, config, requestContext);
12937
+ }
12875
12938
  return null;
12876
- }
12877
- if (hasLayoutTypes(config)) {
12878
- return getRecordLayoutType(luvio, config, requestContext);
12879
- }
12880
- else if (hasFieldsOrOptionalFields(config)) {
12881
- return getRecordByFields(luvio, config, requestContext);
12882
- }
12883
- return null;
12939
+ }, { contextId: contextId$4 });
12884
12940
  };
12885
12941
 
12886
12942
  const VERSION$22 = "7e00c51105cbf56a79ab8fcddf462c1e";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-adapters-uiapi",
3
- "version": "1.182.0",
3
+ "version": "1.183.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "Wire adapters for record related UI API endpoints",
6
6
  "main": "dist/es/es2018/uiapi-records-service.js",
@@ -17298,4 +17298,4 @@ register({
17298
17298
  });
17299
17299
 
17300
17300
  export { configurationForGraphQLAdapters as configuration, graphql, factory$1 as graphqlAdapterFactory, graphqlBatch, graphqlBatch_imperative, graphql_imperative };
17301
- // version: 1.182.0-84968af24
17301
+ // version: 1.183.0-c61f9da4f
package/sfdc/index.js CHANGED
@@ -5021,6 +5021,7 @@ function toSortedStringArray(value) {
5021
5021
  return undefined;
5022
5022
  }
5023
5023
 
5024
+ const adapterName$K = 'getRecord';
5024
5025
  const oneOfConfigPropertiesIdentifier$1 = [
5025
5026
  'layoutTypes',
5026
5027
  'fields',
@@ -8716,7 +8717,7 @@ const factory$h = (luvio) => function getMruListUi(untrustedConfig, requestConte
8716
8717
  : processListInfo(listInfoPromiseOrSnapshot);
8717
8718
  };
8718
8719
 
8719
- const contextId$4 = `${keyPrefix}__getListUi`;
8720
+ const contextId$5 = `${keyPrefix}__getListUi`;
8720
8721
  // eslint-disable-next-line @salesforce/lds/no-invalid-todo
8721
8722
  // TODO RAML - this more properly goes in the generated resource files
8722
8723
  const DEFAULT_PAGE_SIZE = 50;
@@ -9145,7 +9146,7 @@ const factory$g = (luvio) => {
9145
9146
  return listUiAdapter(untrustedConfig, adapterContext, requestContext);
9146
9147
  }
9147
9148
  return null;
9148
- }, { contextId: contextId$4 });
9149
+ }, { contextId: contextId$5 });
9149
9150
  };
9150
9151
 
9151
9152
  function validate$1n(obj, path = 'ChildRelationshipRepresentation') {
@@ -11929,6 +11930,10 @@ function buildSnapshotRefresh$3(luvio, config) {
11929
11930
  resolve: () => refresh$1(luvio, config),
11930
11931
  };
11931
11932
  }
11933
+ function buildObjectInfoSelectorKey(luvio, objectInfo) {
11934
+ const key = keyBuilderFromType$s(luvio, objectInfo);
11935
+ return `${key}__implicit__fields__selector`;
11936
+ }
11932
11937
  function refresh$1(luvio, config) {
11933
11938
  const { recordId, layoutTypes, modes: configModes, optionalFields: configOptionalFields, } = config;
11934
11939
  const modes = configModes === undefined ? [DEFAULT_MODE] : configModes;
@@ -11982,7 +11987,13 @@ function getLayoutMapAndObjectInfo(recordId, data) {
11982
11987
  objectInfo,
11983
11988
  };
11984
11989
  }
11985
- function processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, optionalFields) {
11990
+ function getFields(recordId, data) {
11991
+ const { records } = data;
11992
+ const record = records[recordId];
11993
+ const { fields } = record;
11994
+ return fields;
11995
+ }
11996
+ function processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, adapterContext, optionalFields) {
11986
11997
  if (isErrorSnapshot(snapshot)) {
11987
11998
  return luvio.errorSnapshot(snapshot.error, refresh);
11988
11999
  }
@@ -11997,7 +12008,12 @@ function processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot
11997
12008
  throw new Error(`RecordUi adapter resolved with a ${snapshot.state} snapshot with undefined data`);
11998
12009
  }
11999
12010
  const { layoutMap, objectInfo } = getLayoutMapAndObjectInfo(recordId, data);
12000
- return getRecord$1(luvio, refresh, recordId, layoutMap, objectInfo, optionalFields);
12011
+ if (objectInfo.layoutable) {
12012
+ return getRecordForLayoutableEntities(luvio, refresh, recordId, layoutMap, objectInfo, optionalFields);
12013
+ }
12014
+ else {
12015
+ return getRecordForNonLayoutableEntities(luvio, adapterContext, refresh, recordId, objectInfo, optionalFields, getFields(recordId, data));
12016
+ }
12001
12017
  }
12002
12018
  const recordLayoutFragmentSelector = [
12003
12019
  {
@@ -12024,8 +12040,20 @@ function getFieldsFromLayoutMap(layoutMap, objectInfo) {
12024
12040
  }
12025
12041
  return dedupe(fields).sort();
12026
12042
  }
12027
- function getRecord$1(luvio, refresh, recordId, layoutMap, objectInfo, configOptionalFields) {
12043
+ function getRecordForLayoutableEntities(luvio, refresh, recordId, layoutMap, objectInfo, configOptionalFields) {
12028
12044
  const fields = getFieldsFromLayoutMap(layoutMap, objectInfo);
12045
+ return getRecord$1(luvio, refresh, recordId, fields, configOptionalFields);
12046
+ }
12047
+ function getRecordForNonLayoutableEntities(luvio, adapterContext, refresh, recordId, objectInfo, configOptionalFields, configFields) {
12048
+ const fields = keys(configFields ? configFields : {}).map((key) => `${objectInfo.apiName}.${key}`);
12049
+ // W-12697744
12050
+ // Set the implicit fields received from the server in adapter context
12051
+ // This ensures that the implicit fields are available when data is read locally or from durable store
12052
+ const selectorKey = buildObjectInfoSelectorKey(luvio, objectInfo);
12053
+ adapterContext.set(selectorKey, fields);
12054
+ return getRecord$1(luvio, refresh, recordId, fields, configOptionalFields);
12055
+ }
12056
+ function getRecord$1(luvio, refresh, recordId, fields, configOptionalFields) {
12029
12057
  const optionalFields = configOptionalFields === undefined ? [] : dedupe(configOptionalFields).sort();
12030
12058
  // We know what fields we need so delegate to getRecordByFields
12031
12059
  // This should be a cache hit because we just fetched the record-ui
@@ -12047,7 +12075,7 @@ function getRecord$1(luvio, refresh, recordId, layoutMap, objectInfo, configOpti
12047
12075
  return recordSnapshotOrPromise;
12048
12076
  }
12049
12077
  function buildNetworkSnapshot$S(context, coercedAdapterRequestContext) {
12050
- const { config, luvio } = context;
12078
+ const { config, luvio, adapterContext } = context;
12051
12079
  const { recordId } = config;
12052
12080
  const optionalFields = config.optionalFields === undefined ? [] : dedupe(config.optionalFields).sort();
12053
12081
  const refresh = buildSnapshotRefresh$3(luvio, config);
@@ -12084,7 +12112,7 @@ function buildNetworkSnapshot$S(context, coercedAdapterRequestContext) {
12084
12112
  modes,
12085
12113
  optionalFields,
12086
12114
  };
12087
- return buildNetworkSnapshot$T(luvio, recordUiConfig, dispatchOptions).then((snapshot) => processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, optionalFields));
12115
+ return buildNetworkSnapshot$T(luvio, recordUiConfig, dispatchOptions).then((snapshot) => processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, adapterContext, optionalFields));
12088
12116
  }
12089
12117
  function buildRecordLayoutCachedSnapshot(context, storeLookup) {
12090
12118
  const { config, luvio } = context;
@@ -12136,13 +12164,13 @@ const buildLayoutModeCacheSnapshot = (apiName, recordTypeId, layoutType, mode) =
12136
12164
  * @param {GetRecordLayoutTypeConfig} config
12137
12165
  * @param {BuildCachedSnapshot<BuildSnapshotContext} cachedSnapshot
12138
12166
  */
12139
- function makeCacheOnlySnapshot(luvio, config, cachedSnapshot) {
12167
+ function makeCacheOnlySnapshot(luvio, config, adapterContext, cachedSnapshot) {
12140
12168
  return luvio.applyCachePolicy({
12141
12169
  cachePolicy: {
12142
12170
  // only looking in the cache so we can check for L2 data offline
12143
12171
  type: 'only-if-cached',
12144
12172
  },
12145
- }, { config, luvio }, cachedSnapshot,
12173
+ }, { config, luvio, adapterContext }, cachedSnapshot,
12146
12174
  // this won't be invoked since we're requesting only-if-cached
12147
12175
  () => {
12148
12176
  throw Error('buildNetworkSnapshot should not be called for only-if-cached policy');
@@ -12155,37 +12183,50 @@ function makeCacheOnlySnapshot(luvio, config, cachedSnapshot) {
12155
12183
  * @param {GetRecordLayoutTypeConfig} config
12156
12184
  * @param {AdapterRequestContext} requestContext?
12157
12185
  */
12158
- function makeNetworkOnlySnapshot(luvio, config, requestContext) {
12159
- return luvio.applyCachePolicy(requestContext || {}, { config, luvio }, () => {
12186
+ function makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext) {
12187
+ return luvio.applyCachePolicy(requestContext || {}, { config, luvio, adapterContext }, () => {
12160
12188
  return undefined;
12161
12189
  }, buildNetworkSnapshot$S);
12162
12190
  }
12163
- function getRecordLayoutType(luvio, config, requestContext) {
12191
+ function getRecordLayoutType(luvio, config, adapterContext, requestContext) {
12164
12192
  // lookup record layout
12165
- const recordLayoutSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, buildRecordLayoutCachedSnapshot);
12193
+ const recordLayoutSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, adapterContext, buildRecordLayoutCachedSnapshot);
12166
12194
  return runSnapshotOrPromise(recordLayoutSnapshotOrPromise, (recordLayoutSnapshot) => {
12167
12195
  // if record layout is not fulfulled or data is undefined send to the network
12168
12196
  if (recordLayoutSnapshot.state === 'Unfulfilled' ||
12169
12197
  recordLayoutSnapshot.state === 'Error' ||
12170
12198
  recordLayoutSnapshot.data === undefined) {
12171
- return makeNetworkOnlySnapshot(luvio, config, requestContext);
12199
+ return makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext);
12172
12200
  }
12173
12201
  // lookup object info
12174
- const objectInfoSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, buildObjectInfoCacheSnapshot(recordLayoutSnapshot));
12202
+ const objectInfoSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, adapterContext, buildObjectInfoCacheSnapshot(recordLayoutSnapshot));
12175
12203
  return runSnapshotOrPromise(objectInfoSnapshotOrPromise, (objectInfoSnapshot) => {
12176
12204
  const { layoutTypes } = config;
12177
12205
  // if not fulfilled or missing data send to the network
12178
12206
  if (objectInfoSnapshot.state === 'Unfulfilled' ||
12179
12207
  objectInfoSnapshot.state === 'Error' ||
12180
12208
  objectInfoSnapshot.data === undefined) {
12181
- return makeNetworkOnlySnapshot(luvio, config, requestContext);
12209
+ return makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext);
12182
12210
  }
12183
12211
  const { data: record } = recordLayoutSnapshot;
12184
12212
  // try to load all the requested layouts from cache
12185
12213
  const recordTypeId = getRecordTypeId$2(record);
12186
12214
  const modes = config.modes === undefined ? [DEFAULT_MODE] : config.modes;
12187
- return makeRecordLayoutMap(luvio, config, objectInfoSnapshot.data.apiName, recordTypeId, layoutTypes, modes).then((recordLayoutMap) => {
12188
- return luvio.applyCachePolicy(requestContext || {}, { config, luvio }, buildRecordLayoutSnapshot(recordLayoutMap, luvio, config, recordLayoutSnapshot, objectInfoSnapshot), buildNetworkSnapshot$S);
12215
+ // W-12697744
12216
+ // For non-layoutable entities, use the implicit fields as the fields are not available in layout
12217
+ // Fields can be fetched from adapter context if the server request was already made at some point in the past
12218
+ // If fields are not available in adapter context, make a network request to get the data
12219
+ // and store implicit fields in adapter context.
12220
+ if (!objectInfoSnapshot.data.layoutable) {
12221
+ const selectorKey = buildObjectInfoSelectorKey(luvio, objectInfoSnapshot.data);
12222
+ const fields = adapterContext.get(selectorKey);
12223
+ if (!fields) {
12224
+ return makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext);
12225
+ }
12226
+ return luvio.applyCachePolicy(requestContext || {}, { config, luvio, adapterContext }, buildRecordSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields), buildNetworkSnapshot$S);
12227
+ }
12228
+ return makeRecordLayoutMap(luvio, config, objectInfoSnapshot.data.apiName, recordTypeId, layoutTypes, modes, adapterContext).then((recordLayoutMap) => {
12229
+ return luvio.applyCachePolicy(requestContext || {}, { config, luvio, adapterContext }, buildRecordLayoutSnapshot(recordLayoutMap, luvio, config, recordLayoutSnapshot, objectInfoSnapshot), buildNetworkSnapshot$S);
12189
12230
  });
12190
12231
  });
12191
12232
  });
@@ -12200,13 +12241,13 @@ function getRecordLayoutType(luvio, config, requestContext) {
12200
12241
  * @param {LayoutType[]} layoutTypes
12201
12242
  * @param {LayoutMode[]} modes
12202
12243
  */
12203
- function makeRecordLayoutMap(luvio, config, apiName, recordTypeId, layoutTypes, modes) {
12244
+ function makeRecordLayoutMap(luvio, config, apiName, recordTypeId, layoutTypes, modes, adapterContext) {
12204
12245
  let promises = [];
12205
12246
  for (let i = 0; i < layoutTypes.length; i++) {
12206
12247
  const layoutType = layoutTypes[i];
12207
12248
  for (let m = 0; m < modes.length; m++) {
12208
12249
  const mode = modes[m];
12209
- promises.push(Promise.resolve(makeCacheOnlySnapshot(luvio, config, buildLayoutModeCacheSnapshot(apiName, recordTypeId, layoutType, mode))).then((snapshot) => {
12250
+ promises.push(Promise.resolve(makeCacheOnlySnapshot(luvio, config, adapterContext, buildLayoutModeCacheSnapshot(apiName, recordTypeId, layoutType, mode))).then((snapshot) => {
12210
12251
  return {
12211
12252
  layoutType,
12212
12253
  mode,
@@ -12246,34 +12287,46 @@ function makeRecordLayoutMap(luvio, config, apiName, recordTypeId, layoutTypes,
12246
12287
  }
12247
12288
  function buildRecordLayoutSnapshot(recordLayout, luvio, config, recordLayoutSnapshot, objectInfoSnapshot) {
12248
12289
  return (context, storeLookup) => {
12249
- const { layoutMap, isStale } = recordLayout;
12290
+ const { layoutMap, isStale: isRecordLayoutStale } = recordLayout;
12250
12291
  if (layoutMap === undefined || objectInfoSnapshot.data === undefined) {
12251
12292
  return;
12252
12293
  }
12253
12294
  // transform the layouts & object info into a set of fields
12254
12295
  const fields = getFieldsFromLayoutMap(layoutMap, objectInfoSnapshot.data);
12255
- const optionalFields = config.optionalFields === undefined ? [] : dedupe(config.optionalFields).sort();
12256
- const { recordId } = config;
12257
- // borrow GetRecordFields' logic to construct the RecordRepresentation with the necessary fields
12258
- const sel = buildRecordSelector(luvio, recordId, fields, optionalFields);
12259
- const recordRepSnapshot = storeLookup(sel, buildSnapshotRefresh$3(luvio, config));
12260
- if (isFulfilledSnapshot(recordRepSnapshot)) {
12261
- // mark snapshot as stale if any of the information used to construct it was stale
12262
- if (isStaleSnapshot(recordLayoutSnapshot) ||
12263
- isStaleSnapshot(objectInfoSnapshot) ||
12264
- isStale) {
12265
- recordRepSnapshot.state = 'Stale';
12266
- }
12267
- }
12268
- // allow buildNetworkSnapshot() to use GetRecordFields if we were just missing some fields in L1
12269
- else if (isUnfulfilledSnapshot(recordRepSnapshot)) {
12270
- context.fields = fields;
12271
- }
12272
- // return however much of the record we were able to find in L1; cache policy decides if we
12273
- // should consult L2 or go to network
12274
- return recordRepSnapshot;
12296
+ return getRecordRepSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields, isRecordLayoutStale, context, storeLookup);
12275
12297
  };
12276
12298
  }
12299
+ function buildRecordSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields) {
12300
+ return (context, storeLookup) => {
12301
+ return getRecordRepSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields, false, context, storeLookup);
12302
+ };
12303
+ }
12304
+ function getRecordRepSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields, isRecordLayoutStale, context, storeLookup) {
12305
+ if (objectInfoSnapshot.data === undefined) {
12306
+ return;
12307
+ }
12308
+ // transform the layouts & object info into a set of fields
12309
+ const optionalFields = config.optionalFields === undefined ? [] : dedupe(config.optionalFields).sort();
12310
+ const { recordId } = config;
12311
+ // borrow GetRecordFields' logic to construct the RecordRepresentation with the necessary fields
12312
+ const sel = buildRecordSelector(luvio, recordId, fields, optionalFields);
12313
+ const recordRepSnapshot = storeLookup(sel, buildSnapshotRefresh$3(luvio, config));
12314
+ if (isFulfilledSnapshot(recordRepSnapshot)) {
12315
+ // mark snapshot as stale if any of the information used to construct it was stale
12316
+ if (isStaleSnapshot(objectInfoSnapshot) ||
12317
+ isStaleSnapshot(recordLayoutSnapshot) ||
12318
+ isRecordLayoutStale) {
12319
+ recordRepSnapshot.state = 'Stale';
12320
+ }
12321
+ }
12322
+ // allow buildNetworkSnapshot() to use GetRecordFields if we were just missing some fields in L1
12323
+ else if (isUnfulfilledSnapshot(recordRepSnapshot)) {
12324
+ context.fields = fields;
12325
+ }
12326
+ // return however much of the record we were able to find in L1; cache policy decides if we
12327
+ // should consult L2 or go to network
12328
+ return recordRepSnapshot;
12329
+ }
12277
12330
  function runSnapshotOrPromise(promiseOrSnapshot, next) {
12278
12331
  if (isPromise(promiseOrSnapshot)) {
12279
12332
  return promiseOrSnapshot.then(next);
@@ -12283,6 +12336,7 @@ function runSnapshotOrPromise(promiseOrSnapshot, next) {
12283
12336
  }
12284
12337
  }
12285
12338
 
12339
+ const contextId$4 = `${keyPrefix}__${adapterName$K}`;
12286
12340
  // Custom adapter config due to `unsupported` items
12287
12341
  const GET_RECORD_ADAPTER_CONFIG = {
12288
12342
  displayName: 'getRecord',
@@ -12373,19 +12427,21 @@ const notifyChangeFactory = (luvio) => {
12373
12427
  });
12374
12428
  };
12375
12429
  };
12376
- const factory$e = (luvio) => function getRecord(untrustedConfig, requestContext) {
12377
- // standard config validation and coercion
12378
- const config = validateAdapterConfig$$(untrustedConfig, GET_RECORD_ADAPTER_CONFIG);
12379
- if (config === null) {
12430
+ const factory$e = (luvio) => {
12431
+ return luvio.withContext(function getRecord(untrustedConfig, adapterContext, requestContext) {
12432
+ // standard config validation and coercion
12433
+ const config = validateAdapterConfig$$(untrustedConfig, GET_RECORD_ADAPTER_CONFIG);
12434
+ if (config === null) {
12435
+ return null;
12436
+ }
12437
+ if (hasLayoutTypes(config)) {
12438
+ return getRecordLayoutType(luvio, config, adapterContext, requestContext);
12439
+ }
12440
+ else if (hasFieldsOrOptionalFields(config)) {
12441
+ return getRecordByFields(luvio, config, requestContext);
12442
+ }
12380
12443
  return null;
12381
- }
12382
- if (hasLayoutTypes(config)) {
12383
- return getRecordLayoutType(luvio, config, requestContext);
12384
- }
12385
- else if (hasFieldsOrOptionalFields(config)) {
12386
- return getRecordByFields(luvio, config, requestContext);
12387
- }
12388
- return null;
12444
+ }, { contextId: contextId$4 });
12389
12445
  };
12390
12446
 
12391
12447
  const VERSION$W = "7e00c51105cbf56a79ab8fcddf462c1e";
@@ -36146,4 +36202,4 @@ withDefaultLuvio((luvio) => {
36146
36202
  });
36147
36203
 
36148
36204
  export { InMemoryRecordRepresentationQueryEvaluator, MRU, RepresentationType$I as ObjectInfoRepresentationType, RepresentationType$N as RecordRepresentationRepresentationType, TTL$v as RecordRepresentationTTL, RepresentationType$N as RecordRepresentationType, VERSION$14 as RecordRepresentationVersion, keyPrefix as UiApiNamespace, configurationForRestAdapters as configuration, createContentDocumentAndVersion, createContentVersion, createIngestRecordWithFields, createRecord, deleteRecord, getActionOverrides, getActionOverrides_imperative, getAllApps, getAllApps_imperative, getAppDetails, getAppDetails_imperative, getDuplicateConfiguration, getDuplicateConfiguration_imperative, getDuplicates, getDuplicates_imperative, getGlobalActions, getGlobalActions_imperative, getKeywordSearchResults, getKeywordSearchResults_imperative, getLayout, getLayoutUserState, getLayoutUserState_imperative, getLayout_imperative, getListInfoByName, getListInfoByName_imperative, getListInfosByName, getListInfosByName_imperative, getListRecordsByName, getListRecordsByName_imperative, getListUi, getListUi_imperative, getLookupActions, getLookupActions_imperative, getLookupMetadata, getLookupMetadata_imperative, getLookupRecords, getLookupRecords_imperative, getNavItems, getNavItems_imperative, getObjectCreateActions, getObjectCreateActions_imperative, getObjectInfo, getObjectInfoAdapterFactory, getObjectInfo_imperative, getObjectInfos, getObjectInfosAdapterFactory, getObjectInfos_imperative, getPicklistValues, getPicklistValuesByRecordType, getPicklistValuesByRecordType_imperative, getPicklistValues_imperative, getQuickActionDefaults, getQuickActionDefaults_imperative, getQuickActionLayout, getQuickActionLayout_imperative, getRecord, getRecordActions, getRecordActions_imperative, factory$e as getRecordAdapterFactory, getRecordAvatars, getRecordAvatars_imperative, getRecordCreateDefaults, getRecordCreateDefaults_imperative, getRecordEditActions, getRecordEditActions_imperative, getRecordId18, getRecordNotifyChange, getRecordTemplateClone, getRecordTemplateClone_imperative, getRecordTemplateCreate, getRecordTemplateCreate_imperative, getRecordUi, getRecordUi_imperative, getRecord_imperative, getRecords, getRecords_imperative, getRelatedListActions, getRelatedListActions_imperative, getRelatedListCount, getRelatedListCount_imperative, getRelatedListInfo, getRelatedListInfoBatch, getRelatedListInfoBatch_imperative, getRelatedListInfo_imperative, getRelatedListPreferences, getRelatedListPreferencesBatch, getRelatedListPreferencesBatch_imperative, getRelatedListPreferences_imperative, getRelatedListRecordActions, getRelatedListRecordActions_imperative, getRelatedListRecords, getRelatedListRecordsBatch, getRelatedListRecordsBatch_imperative, getRelatedListRecords_imperative, getRelatedListsActions, getRelatedListsActions_imperative, getRelatedListsCount, getRelatedListsCount_imperative, getRelatedListsInfo, getRelatedListsInfo_imperative, getResponseCacheKeys as getResponseCacheKeysContentDocumentCompositeRepresentation, getSearchFilterMetadata, getSearchFilterMetadata_imperative, getSearchFilterOptions, getSearchFilterOptions_imperative, getSearchResults, getSearchResults_imperative, getTypeCacheKeys$P as getTypeCacheKeysRecord, ingest as ingestContentDocumentCompositeRepresentation, ingest$B as ingestObjectInfo, ingest$x as ingestQuickActionExecutionRepresentation, ingest$G as ingestRecord, instrument, keyBuilder as keyBuilderContentDocumentCompositeRepresentation, keyBuilderFromType as keyBuilderFromTypeContentDocumentCompositeRepresentation, keyBuilderFromType$x as keyBuilderFromTypeRecordRepresentation, keyBuilder$1G as keyBuilderObjectInfo, keyBuilder$1A as keyBuilderQuickActionExecutionRepresentation, keyBuilder$1R as keyBuilderRecord, notifyRecordUpdateAvailable, performQuickAction, performUpdateRecordQuickAction, refresh, updateLayoutUserState, updateListInfoByName, updateRecord, updateRecordAvatar, updateRelatedListInfo, updateRelatedListPreferences };
36149
- // version: 1.182.0-84968af24
36205
+ // version: 1.183.0-c61f9da4f