@salesforce/lwc-adapters-uiapi 1.182.0 → 1.182.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +109 -53
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -12753,6 +12753,7 @@ function toSortedStringArray(value) {
|
|
|
12753
12753
|
return undefined;
|
|
12754
12754
|
}
|
|
12755
12755
|
|
|
12756
|
+
const adapterName$5 = 'getRecord';
|
|
12756
12757
|
const oneOfConfigPropertiesIdentifier$1 = [
|
|
12757
12758
|
'layoutTypes',
|
|
12758
12759
|
'fields',
|
|
@@ -16562,7 +16563,7 @@ const factory$j = (luvio) => function getMruListUi(untrustedConfig, requestConte
|
|
|
16562
16563
|
: processListInfo(listInfoPromiseOrSnapshot);
|
|
16563
16564
|
};
|
|
16564
16565
|
|
|
16565
|
-
const contextId$
|
|
16566
|
+
const contextId$5 = `${keyPrefix}__getListUi`;
|
|
16566
16567
|
// eslint-disable-next-line @salesforce/lds/no-invalid-todo
|
|
16567
16568
|
// TODO RAML - this more properly goes in the generated resource files
|
|
16568
16569
|
const DEFAULT_PAGE_SIZE = 50;
|
|
@@ -16991,7 +16992,7 @@ const factory$i = (luvio) => {
|
|
|
16991
16992
|
return listUiAdapter(untrustedConfig, adapterContext, requestContext);
|
|
16992
16993
|
}
|
|
16993
16994
|
return null;
|
|
16994
|
-
}, { contextId: contextId$
|
|
16995
|
+
}, { contextId: contextId$5 });
|
|
16995
16996
|
};
|
|
16996
16997
|
|
|
16997
16998
|
function validate$1r(obj, path = 'ChildRelationshipRepresentation') {
|
|
@@ -19774,6 +19775,10 @@ function buildSnapshotRefresh$3(luvio, config) {
|
|
|
19774
19775
|
resolve: () => refresh$1(luvio, config),
|
|
19775
19776
|
};
|
|
19776
19777
|
}
|
|
19778
|
+
function buildObjectInfoSelectorKey(luvio, objectInfo) {
|
|
19779
|
+
const key = keyBuilderFromType$s(luvio, objectInfo);
|
|
19780
|
+
return `${key}__implicit__fields__selector`;
|
|
19781
|
+
}
|
|
19777
19782
|
function refresh$1(luvio, config) {
|
|
19778
19783
|
const { recordId, layoutTypes, modes: configModes, optionalFields: configOptionalFields, } = config;
|
|
19779
19784
|
const modes = configModes === undefined ? [DEFAULT_MODE] : configModes;
|
|
@@ -19827,7 +19832,13 @@ function getLayoutMapAndObjectInfo(recordId, data) {
|
|
|
19827
19832
|
objectInfo,
|
|
19828
19833
|
};
|
|
19829
19834
|
}
|
|
19830
|
-
function
|
|
19835
|
+
function getFields(recordId, data) {
|
|
19836
|
+
const { records } = data;
|
|
19837
|
+
const record = records[recordId];
|
|
19838
|
+
const { fields } = record;
|
|
19839
|
+
return fields;
|
|
19840
|
+
}
|
|
19841
|
+
function processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, adapterContext, optionalFields) {
|
|
19831
19842
|
if (isErrorSnapshot(snapshot)) {
|
|
19832
19843
|
return luvio.errorSnapshot(snapshot.error, refresh);
|
|
19833
19844
|
}
|
|
@@ -19842,7 +19853,12 @@ function processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot
|
|
|
19842
19853
|
throw new Error(`RecordUi adapter resolved with a ${snapshot.state} snapshot with undefined data`);
|
|
19843
19854
|
}
|
|
19844
19855
|
const { layoutMap, objectInfo } = getLayoutMapAndObjectInfo(recordId, data);
|
|
19845
|
-
|
|
19856
|
+
if (objectInfo.layoutable) {
|
|
19857
|
+
return getRecordForLayoutableEntities(luvio, refresh, recordId, layoutMap, objectInfo, optionalFields);
|
|
19858
|
+
}
|
|
19859
|
+
else {
|
|
19860
|
+
return getRecordForNonLayoutableEntities(luvio, adapterContext, refresh, recordId, objectInfo, optionalFields, getFields(recordId, data));
|
|
19861
|
+
}
|
|
19846
19862
|
}
|
|
19847
19863
|
const recordLayoutFragmentSelector = [
|
|
19848
19864
|
{
|
|
@@ -19869,8 +19885,20 @@ function getFieldsFromLayoutMap(layoutMap, objectInfo) {
|
|
|
19869
19885
|
}
|
|
19870
19886
|
return dedupe(fields).sort();
|
|
19871
19887
|
}
|
|
19872
|
-
function
|
|
19888
|
+
function getRecordForLayoutableEntities(luvio, refresh, recordId, layoutMap, objectInfo, configOptionalFields) {
|
|
19873
19889
|
const fields = getFieldsFromLayoutMap(layoutMap, objectInfo);
|
|
19890
|
+
return getRecord$1(luvio, refresh, recordId, fields, configOptionalFields);
|
|
19891
|
+
}
|
|
19892
|
+
function getRecordForNonLayoutableEntities(luvio, adapterContext, refresh, recordId, objectInfo, configOptionalFields, configFields) {
|
|
19893
|
+
const fields = keys(configFields ? configFields : {}).map((key) => `${objectInfo.apiName}.${key}`);
|
|
19894
|
+
// W-12697744
|
|
19895
|
+
// Set the implicit fields received from the server in adapter context
|
|
19896
|
+
// This ensures that the implicit fields are available when data is read locally or from durable store
|
|
19897
|
+
const selectorKey = buildObjectInfoSelectorKey(luvio, objectInfo);
|
|
19898
|
+
adapterContext.set(selectorKey, fields);
|
|
19899
|
+
return getRecord$1(luvio, refresh, recordId, fields, configOptionalFields);
|
|
19900
|
+
}
|
|
19901
|
+
function getRecord$1(luvio, refresh, recordId, fields, configOptionalFields) {
|
|
19874
19902
|
const optionalFields = configOptionalFields === undefined ? [] : dedupe(configOptionalFields).sort();
|
|
19875
19903
|
// We know what fields we need so delegate to getRecordByFields
|
|
19876
19904
|
// This should be a cache hit because we just fetched the record-ui
|
|
@@ -19892,7 +19920,7 @@ function getRecord$1(luvio, refresh, recordId, layoutMap, objectInfo, configOpti
|
|
|
19892
19920
|
return recordSnapshotOrPromise;
|
|
19893
19921
|
}
|
|
19894
19922
|
function buildNetworkSnapshot$V(context, coercedAdapterRequestContext) {
|
|
19895
|
-
const { config, luvio } = context;
|
|
19923
|
+
const { config, luvio, adapterContext } = context;
|
|
19896
19924
|
const { recordId } = config;
|
|
19897
19925
|
const optionalFields = config.optionalFields === undefined ? [] : dedupe(config.optionalFields).sort();
|
|
19898
19926
|
const refresh = buildSnapshotRefresh$3(luvio, config);
|
|
@@ -19929,7 +19957,7 @@ function buildNetworkSnapshot$V(context, coercedAdapterRequestContext) {
|
|
|
19929
19957
|
modes,
|
|
19930
19958
|
optionalFields,
|
|
19931
19959
|
};
|
|
19932
|
-
return buildNetworkSnapshot$W(luvio, recordUiConfig, dispatchOptions).then((snapshot) => processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, optionalFields));
|
|
19960
|
+
return buildNetworkSnapshot$W(luvio, recordUiConfig, dispatchOptions).then((snapshot) => processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot, adapterContext, optionalFields));
|
|
19933
19961
|
}
|
|
19934
19962
|
function buildRecordLayoutCachedSnapshot(context, storeLookup) {
|
|
19935
19963
|
const { config, luvio } = context;
|
|
@@ -19981,13 +20009,13 @@ const buildLayoutModeCacheSnapshot = (apiName, recordTypeId, layoutType, mode) =
|
|
|
19981
20009
|
* @param {GetRecordLayoutTypeConfig} config
|
|
19982
20010
|
* @param {BuildCachedSnapshot<BuildSnapshotContext} cachedSnapshot
|
|
19983
20011
|
*/
|
|
19984
|
-
function makeCacheOnlySnapshot(luvio, config, cachedSnapshot) {
|
|
20012
|
+
function makeCacheOnlySnapshot(luvio, config, adapterContext, cachedSnapshot) {
|
|
19985
20013
|
return luvio.applyCachePolicy({
|
|
19986
20014
|
cachePolicy: {
|
|
19987
20015
|
// only looking in the cache so we can check for L2 data offline
|
|
19988
20016
|
type: 'only-if-cached',
|
|
19989
20017
|
},
|
|
19990
|
-
}, { config, luvio }, cachedSnapshot,
|
|
20018
|
+
}, { config, luvio, adapterContext }, cachedSnapshot,
|
|
19991
20019
|
// this won't be invoked since we're requesting only-if-cached
|
|
19992
20020
|
() => {
|
|
19993
20021
|
throw Error('buildNetworkSnapshot should not be called for only-if-cached policy');
|
|
@@ -20000,37 +20028,50 @@ function makeCacheOnlySnapshot(luvio, config, cachedSnapshot) {
|
|
|
20000
20028
|
* @param {GetRecordLayoutTypeConfig} config
|
|
20001
20029
|
* @param {AdapterRequestContext} requestContext?
|
|
20002
20030
|
*/
|
|
20003
|
-
function makeNetworkOnlySnapshot(luvio, config, requestContext) {
|
|
20004
|
-
return luvio.applyCachePolicy(requestContext || {}, { config, luvio }, () => {
|
|
20031
|
+
function makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext) {
|
|
20032
|
+
return luvio.applyCachePolicy(requestContext || {}, { config, luvio, adapterContext }, () => {
|
|
20005
20033
|
return undefined;
|
|
20006
20034
|
}, buildNetworkSnapshot$V);
|
|
20007
20035
|
}
|
|
20008
|
-
function getRecordLayoutType(luvio, config, requestContext) {
|
|
20036
|
+
function getRecordLayoutType(luvio, config, adapterContext, requestContext) {
|
|
20009
20037
|
// lookup record layout
|
|
20010
|
-
const recordLayoutSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, buildRecordLayoutCachedSnapshot);
|
|
20038
|
+
const recordLayoutSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, adapterContext, buildRecordLayoutCachedSnapshot);
|
|
20011
20039
|
return runSnapshotOrPromise(recordLayoutSnapshotOrPromise, (recordLayoutSnapshot) => {
|
|
20012
20040
|
// if record layout is not fulfulled or data is undefined send to the network
|
|
20013
20041
|
if (recordLayoutSnapshot.state === 'Unfulfilled' ||
|
|
20014
20042
|
recordLayoutSnapshot.state === 'Error' ||
|
|
20015
20043
|
recordLayoutSnapshot.data === undefined) {
|
|
20016
|
-
return makeNetworkOnlySnapshot(luvio, config, requestContext);
|
|
20044
|
+
return makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext);
|
|
20017
20045
|
}
|
|
20018
20046
|
// lookup object info
|
|
20019
|
-
const objectInfoSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, buildObjectInfoCacheSnapshot(recordLayoutSnapshot));
|
|
20047
|
+
const objectInfoSnapshotOrPromise = makeCacheOnlySnapshot(luvio, config, adapterContext, buildObjectInfoCacheSnapshot(recordLayoutSnapshot));
|
|
20020
20048
|
return runSnapshotOrPromise(objectInfoSnapshotOrPromise, (objectInfoSnapshot) => {
|
|
20021
20049
|
const { layoutTypes } = config;
|
|
20022
20050
|
// if not fulfilled or missing data send to the network
|
|
20023
20051
|
if (objectInfoSnapshot.state === 'Unfulfilled' ||
|
|
20024
20052
|
objectInfoSnapshot.state === 'Error' ||
|
|
20025
20053
|
objectInfoSnapshot.data === undefined) {
|
|
20026
|
-
return makeNetworkOnlySnapshot(luvio, config, requestContext);
|
|
20054
|
+
return makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext);
|
|
20027
20055
|
}
|
|
20028
20056
|
const { data: record } = recordLayoutSnapshot;
|
|
20029
20057
|
// try to load all the requested layouts from cache
|
|
20030
20058
|
const recordTypeId = getRecordTypeId$2(record);
|
|
20031
20059
|
const modes = config.modes === undefined ? [DEFAULT_MODE] : config.modes;
|
|
20032
|
-
|
|
20033
|
-
|
|
20060
|
+
// W-12697744
|
|
20061
|
+
// For non-layoutable entities, use the implicit fields as the fields are not available in layout
|
|
20062
|
+
// Fields can be fetched from adapter context if the server request was already made at some point in the past
|
|
20063
|
+
// If fields are not available in adapter context, make a network request to get the data
|
|
20064
|
+
// and store implicit fields in adapter context.
|
|
20065
|
+
if (!objectInfoSnapshot.data.layoutable) {
|
|
20066
|
+
const selectorKey = buildObjectInfoSelectorKey(luvio, objectInfoSnapshot.data);
|
|
20067
|
+
const fields = adapterContext.get(selectorKey);
|
|
20068
|
+
if (!fields) {
|
|
20069
|
+
return makeNetworkOnlySnapshot(luvio, config, adapterContext, requestContext);
|
|
20070
|
+
}
|
|
20071
|
+
return luvio.applyCachePolicy(requestContext || {}, { config, luvio, adapterContext }, buildRecordSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields), buildNetworkSnapshot$V);
|
|
20072
|
+
}
|
|
20073
|
+
return makeRecordLayoutMap(luvio, config, objectInfoSnapshot.data.apiName, recordTypeId, layoutTypes, modes, adapterContext).then((recordLayoutMap) => {
|
|
20074
|
+
return luvio.applyCachePolicy(requestContext || {}, { config, luvio, adapterContext }, buildRecordLayoutSnapshot(recordLayoutMap, luvio, config, recordLayoutSnapshot, objectInfoSnapshot), buildNetworkSnapshot$V);
|
|
20034
20075
|
});
|
|
20035
20076
|
});
|
|
20036
20077
|
});
|
|
@@ -20045,13 +20086,13 @@ function getRecordLayoutType(luvio, config, requestContext) {
|
|
|
20045
20086
|
* @param {LayoutType[]} layoutTypes
|
|
20046
20087
|
* @param {LayoutMode[]} modes
|
|
20047
20088
|
*/
|
|
20048
|
-
function makeRecordLayoutMap(luvio, config, apiName, recordTypeId, layoutTypes, modes) {
|
|
20089
|
+
function makeRecordLayoutMap(luvio, config, apiName, recordTypeId, layoutTypes, modes, adapterContext) {
|
|
20049
20090
|
let promises = [];
|
|
20050
20091
|
for (let i = 0; i < layoutTypes.length; i++) {
|
|
20051
20092
|
const layoutType = layoutTypes[i];
|
|
20052
20093
|
for (let m = 0; m < modes.length; m++) {
|
|
20053
20094
|
const mode = modes[m];
|
|
20054
|
-
promises.push(Promise.resolve(makeCacheOnlySnapshot(luvio, config, buildLayoutModeCacheSnapshot(apiName, recordTypeId, layoutType, mode))).then((snapshot) => {
|
|
20095
|
+
promises.push(Promise.resolve(makeCacheOnlySnapshot(luvio, config, adapterContext, buildLayoutModeCacheSnapshot(apiName, recordTypeId, layoutType, mode))).then((snapshot) => {
|
|
20055
20096
|
return {
|
|
20056
20097
|
layoutType,
|
|
20057
20098
|
mode,
|
|
@@ -20091,34 +20132,46 @@ function makeRecordLayoutMap(luvio, config, apiName, recordTypeId, layoutTypes,
|
|
|
20091
20132
|
}
|
|
20092
20133
|
function buildRecordLayoutSnapshot(recordLayout, luvio, config, recordLayoutSnapshot, objectInfoSnapshot) {
|
|
20093
20134
|
return (context, storeLookup) => {
|
|
20094
|
-
const { layoutMap, isStale } = recordLayout;
|
|
20135
|
+
const { layoutMap, isStale: isRecordLayoutStale } = recordLayout;
|
|
20095
20136
|
if (layoutMap === undefined || objectInfoSnapshot.data === undefined) {
|
|
20096
20137
|
return;
|
|
20097
20138
|
}
|
|
20098
20139
|
// transform the layouts & object info into a set of fields
|
|
20099
20140
|
const fields = getFieldsFromLayoutMap(layoutMap, objectInfoSnapshot.data);
|
|
20100
|
-
|
|
20101
|
-
const { recordId } = config;
|
|
20102
|
-
// borrow GetRecordFields' logic to construct the RecordRepresentation with the necessary fields
|
|
20103
|
-
const sel = buildRecordSelector(luvio, recordId, fields, optionalFields);
|
|
20104
|
-
const recordRepSnapshot = storeLookup(sel, buildSnapshotRefresh$3(luvio, config));
|
|
20105
|
-
if (isFulfilledSnapshot(recordRepSnapshot)) {
|
|
20106
|
-
// mark snapshot as stale if any of the information used to construct it was stale
|
|
20107
|
-
if (isStaleSnapshot(recordLayoutSnapshot) ||
|
|
20108
|
-
isStaleSnapshot(objectInfoSnapshot) ||
|
|
20109
|
-
isStale) {
|
|
20110
|
-
recordRepSnapshot.state = 'Stale';
|
|
20111
|
-
}
|
|
20112
|
-
}
|
|
20113
|
-
// allow buildNetworkSnapshot() to use GetRecordFields if we were just missing some fields in L1
|
|
20114
|
-
else if (isUnfulfilledSnapshot(recordRepSnapshot)) {
|
|
20115
|
-
context.fields = fields;
|
|
20116
|
-
}
|
|
20117
|
-
// return however much of the record we were able to find in L1; cache policy decides if we
|
|
20118
|
-
// should consult L2 or go to network
|
|
20119
|
-
return recordRepSnapshot;
|
|
20141
|
+
return getRecordRepSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields, isRecordLayoutStale, context, storeLookup);
|
|
20120
20142
|
};
|
|
20121
20143
|
}
|
|
20144
|
+
function buildRecordSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields) {
|
|
20145
|
+
return (context, storeLookup) => {
|
|
20146
|
+
return getRecordRepSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields, false, context, storeLookup);
|
|
20147
|
+
};
|
|
20148
|
+
}
|
|
20149
|
+
function getRecordRepSnapshot(luvio, config, recordLayoutSnapshot, objectInfoSnapshot, fields, isRecordLayoutStale, context, storeLookup) {
|
|
20150
|
+
if (objectInfoSnapshot.data === undefined) {
|
|
20151
|
+
return;
|
|
20152
|
+
}
|
|
20153
|
+
// transform the layouts & object info into a set of fields
|
|
20154
|
+
const optionalFields = config.optionalFields === undefined ? [] : dedupe(config.optionalFields).sort();
|
|
20155
|
+
const { recordId } = config;
|
|
20156
|
+
// borrow GetRecordFields' logic to construct the RecordRepresentation with the necessary fields
|
|
20157
|
+
const sel = buildRecordSelector(luvio, recordId, fields, optionalFields);
|
|
20158
|
+
const recordRepSnapshot = storeLookup(sel, buildSnapshotRefresh$3(luvio, config));
|
|
20159
|
+
if (isFulfilledSnapshot(recordRepSnapshot)) {
|
|
20160
|
+
// mark snapshot as stale if any of the information used to construct it was stale
|
|
20161
|
+
if (isStaleSnapshot(objectInfoSnapshot) ||
|
|
20162
|
+
isStaleSnapshot(recordLayoutSnapshot) ||
|
|
20163
|
+
isRecordLayoutStale) {
|
|
20164
|
+
recordRepSnapshot.state = 'Stale';
|
|
20165
|
+
}
|
|
20166
|
+
}
|
|
20167
|
+
// allow buildNetworkSnapshot() to use GetRecordFields if we were just missing some fields in L1
|
|
20168
|
+
else if (isUnfulfilledSnapshot(recordRepSnapshot)) {
|
|
20169
|
+
context.fields = fields;
|
|
20170
|
+
}
|
|
20171
|
+
// return however much of the record we were able to find in L1; cache policy decides if we
|
|
20172
|
+
// should consult L2 or go to network
|
|
20173
|
+
return recordRepSnapshot;
|
|
20174
|
+
}
|
|
20122
20175
|
function runSnapshotOrPromise(promiseOrSnapshot, next) {
|
|
20123
20176
|
if (isPromise(promiseOrSnapshot)) {
|
|
20124
20177
|
return promiseOrSnapshot.then(next);
|
|
@@ -20128,6 +20181,7 @@ function runSnapshotOrPromise(promiseOrSnapshot, next) {
|
|
|
20128
20181
|
}
|
|
20129
20182
|
}
|
|
20130
20183
|
|
|
20184
|
+
const contextId$4 = `${keyPrefix}__${adapterName$5}`;
|
|
20131
20185
|
// Custom adapter config due to `unsupported` items
|
|
20132
20186
|
const GET_RECORD_ADAPTER_CONFIG = {
|
|
20133
20187
|
displayName: 'getRecord',
|
|
@@ -20218,19 +20272,21 @@ const notifyChangeFactory = (luvio) => {
|
|
|
20218
20272
|
});
|
|
20219
20273
|
};
|
|
20220
20274
|
};
|
|
20221
|
-
const factory$g = (luvio) =>
|
|
20222
|
-
|
|
20223
|
-
|
|
20224
|
-
|
|
20275
|
+
const factory$g = (luvio) => {
|
|
20276
|
+
return luvio.withContext(function getRecord(untrustedConfig, adapterContext, requestContext) {
|
|
20277
|
+
// standard config validation and coercion
|
|
20278
|
+
const config = validateAdapterConfig$12(untrustedConfig, GET_RECORD_ADAPTER_CONFIG);
|
|
20279
|
+
if (config === null) {
|
|
20280
|
+
return null;
|
|
20281
|
+
}
|
|
20282
|
+
if (hasLayoutTypes(config)) {
|
|
20283
|
+
return getRecordLayoutType(luvio, config, adapterContext, requestContext);
|
|
20284
|
+
}
|
|
20285
|
+
else if (hasFieldsOrOptionalFields(config)) {
|
|
20286
|
+
return getRecordByFields(luvio, config, requestContext);
|
|
20287
|
+
}
|
|
20225
20288
|
return null;
|
|
20226
|
-
}
|
|
20227
|
-
if (hasLayoutTypes(config)) {
|
|
20228
|
-
return getRecordLayoutType(luvio, config, requestContext);
|
|
20229
|
-
}
|
|
20230
|
-
else if (hasFieldsOrOptionalFields(config)) {
|
|
20231
|
-
return getRecordByFields(luvio, config, requestContext);
|
|
20232
|
-
}
|
|
20233
|
-
return null;
|
|
20289
|
+
}, { contextId: contextId$4 });
|
|
20234
20290
|
};
|
|
20235
20291
|
|
|
20236
20292
|
const VERSION$22 = "7e00c51105cbf56a79ab8fcddf462c1e";
|