@salesforce/lwc-adapters-uiapi 1.228.1 → 1.229.0-dev10
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 +102 -59
- package/package.json +4 -4
package/dist/main.js
CHANGED
|
@@ -19,12 +19,15 @@ var SnapshotState;
|
|
|
19
19
|
const { create: create$1, entries, freeze: freeze$1, keys: keys$1, values } = Object;
|
|
20
20
|
const { isArray: isArray$1 } = Array;
|
|
21
21
|
const { parse: parse$2, stringify: stringify$1 } = JSON;
|
|
22
|
+
const WeakSetCtor = WeakSet;
|
|
22
23
|
|
|
24
|
+
const deeplyFrozen = new WeakSetCtor();
|
|
23
25
|
function deepFreeze(value) {
|
|
24
|
-
// No need to freeze primitives
|
|
25
|
-
if (typeof value !== 'object' || value === null) {
|
|
26
|
+
// No need to freeze primitives or already frozen stuff
|
|
27
|
+
if (typeof value !== 'object' || value === null || deeplyFrozen.has(value)) {
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
30
|
+
deeplyFrozen.add(value);
|
|
28
31
|
if (isArray$1(value)) {
|
|
29
32
|
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
30
33
|
deepFreeze(value[i]);
|
|
@@ -364,6 +367,37 @@ var FragmentReadResultState;
|
|
|
364
367
|
({
|
|
365
368
|
state: FragmentReadResultState.Missing,
|
|
366
369
|
});
|
|
370
|
+
function resolveLink(reader, storeLink, version) {
|
|
371
|
+
const { StoreLinkStateValues } = reader;
|
|
372
|
+
const linkState = reader.getLinkState(storeLink);
|
|
373
|
+
switch (linkState.state) {
|
|
374
|
+
case StoreLinkStateValues.RefNotPresent:
|
|
375
|
+
case StoreLinkStateValues.NotPresent:
|
|
376
|
+
case StoreLinkStateValues.Missing:
|
|
377
|
+
reader.markMissingLink(storeLink.__ref);
|
|
378
|
+
reader.markMissing();
|
|
379
|
+
return;
|
|
380
|
+
case StoreLinkStateValues.Pending:
|
|
381
|
+
reader.markPending();
|
|
382
|
+
return;
|
|
383
|
+
case StoreLinkStateValues.Null:
|
|
384
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
385
|
+
throw new Error(`TODO: Invalid Link State. Link on "${reader.currentPath.fullPath}"`);
|
|
386
|
+
}
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const { key: __ref } = linkState;
|
|
390
|
+
return reader.read({
|
|
391
|
+
recordId: __ref,
|
|
392
|
+
node: {
|
|
393
|
+
kind: 'Fragment',
|
|
394
|
+
private: [],
|
|
395
|
+
opaque: true,
|
|
396
|
+
version,
|
|
397
|
+
},
|
|
398
|
+
variables: {},
|
|
399
|
+
});
|
|
400
|
+
}
|
|
367
401
|
|
|
368
402
|
var ResourceParamType;
|
|
369
403
|
(function (ResourceParamType) {
|
|
@@ -533,7 +567,7 @@ function createResourceParamsImpl(config, configMetadata) {
|
|
|
533
567
|
}
|
|
534
568
|
return resourceParams;
|
|
535
569
|
}
|
|
536
|
-
// engine version: 0.
|
|
570
|
+
// engine version: 0.146.0-dev5-a2ec6e3f
|
|
537
571
|
|
|
538
572
|
/**
|
|
539
573
|
* Returns true if the value acts like a Promise, i.e. has a "then" function,
|
|
@@ -8398,7 +8432,7 @@ function buildAdapterValidationConfig(displayName, paramsMeta) {
|
|
|
8398
8432
|
}
|
|
8399
8433
|
const keyPrefix = 'UiApi';
|
|
8400
8434
|
|
|
8401
|
-
const { assign, create, freeze, keys } = Object;
|
|
8435
|
+
const { assign, create, freeze, isFrozen, keys } = Object;
|
|
8402
8436
|
const { hasOwnProperty } = Object.prototype;
|
|
8403
8437
|
const { split, endsWith } = String.prototype;
|
|
8404
8438
|
const { isArray } = Array;
|
|
@@ -12268,7 +12302,7 @@ function extractTrackedFieldsToTrie(recordId, node, root, config, visitedRecordI
|
|
|
12268
12302
|
extractTrackedFieldsToTrie(spanningLink.data.__ref, spanning, next, config, spanningVisitedRecordIds, depth + 1);
|
|
12269
12303
|
// For a spanning record that is detected to be a circular reference, we add the field along with Id and Name.
|
|
12270
12304
|
// It's possible for spanning record lookup fields to sometimes be circular, and sometimes not - depending on the value of the lookup field.
|
|
12271
|
-
// For more information on scenarios that caused this fix:
|
|
12305
|
+
// For more information on scenarios that caused this fix: search "LDS Recursive Spanning Fields Problem" in Quip
|
|
12272
12306
|
if (keys(next.children).length === 0) {
|
|
12273
12307
|
addScalarFieldId(next);
|
|
12274
12308
|
addScalarFieldName(next);
|
|
@@ -12603,7 +12637,11 @@ function markNulledOutPath(record, path) {
|
|
|
12603
12637
|
}
|
|
12604
12638
|
const link = fieldValueRepresentation.link(fieldName);
|
|
12605
12639
|
const resolved = link.follow();
|
|
12606
|
-
if (isGraphNode(resolved) &&
|
|
12640
|
+
if (isGraphNode(resolved) &&
|
|
12641
|
+
resolved.isScalar('value') &&
|
|
12642
|
+
path.length > 0 &&
|
|
12643
|
+
// TODO [W-14082782]: temporary fix
|
|
12644
|
+
!isFrozen(link.data)) {
|
|
12607
12645
|
const linkState = link.linkData();
|
|
12608
12646
|
const fields = linkState === undefined ? [] : linkState.fields;
|
|
12609
12647
|
link.writeLinkData({
|
|
@@ -12631,22 +12669,12 @@ function _markMissingPath(record, path) {
|
|
|
12631
12669
|
const fieldValueRepresentation = record.object('fields');
|
|
12632
12670
|
const fieldName = path.shift();
|
|
12633
12671
|
if (fieldValueRepresentation.isUndefined(fieldName) === true) {
|
|
12634
|
-
|
|
12635
|
-
// an undefined/non-present __ref if isMissing is present
|
|
12636
|
-
fieldValueRepresentation.write(fieldName, {
|
|
12637
|
-
__ref: undefined,
|
|
12638
|
-
isMissing: true,
|
|
12639
|
-
});
|
|
12672
|
+
writeMissingFieldToStore(fieldValueRepresentation, fieldName);
|
|
12640
12673
|
return;
|
|
12641
12674
|
}
|
|
12642
12675
|
const link = fieldValueRepresentation.link(fieldName);
|
|
12643
12676
|
if (link.isPending()) {
|
|
12644
|
-
|
|
12645
|
-
// an undefined/non-present __ref if isMissing is present
|
|
12646
|
-
fieldValueRepresentation.write(fieldName, {
|
|
12647
|
-
__ref: undefined,
|
|
12648
|
-
isMissing: true,
|
|
12649
|
-
});
|
|
12677
|
+
writeMissingFieldToStore(fieldValueRepresentation, fieldName);
|
|
12650
12678
|
}
|
|
12651
12679
|
else if (path.length > 0 && link.isMissing() === false) {
|
|
12652
12680
|
const fieldValue = link.follow();
|
|
@@ -12662,6 +12690,19 @@ function _markMissingPath(record, path) {
|
|
|
12662
12690
|
}
|
|
12663
12691
|
}
|
|
12664
12692
|
}
|
|
12693
|
+
/**
|
|
12694
|
+
* Graph Node Directly modifies store entries, which is generally a non-starter.
|
|
12695
|
+
* Until we can refactor this mess, you need to use this function to safely mark the RecordRepresentation
|
|
12696
|
+
* as a seenId in the store when you perform this mutation.
|
|
12697
|
+
*/
|
|
12698
|
+
function writeMissingFieldToStore(field, fieldName) {
|
|
12699
|
+
// TODO [W-6900046]: remove cast, make RecordRepresentationNormalized['fields'] accept
|
|
12700
|
+
// an undefined/non-present __ref if isMissing is present
|
|
12701
|
+
field.write(fieldName, {
|
|
12702
|
+
__ref: undefined,
|
|
12703
|
+
isMissing: true,
|
|
12704
|
+
});
|
|
12705
|
+
}
|
|
12665
12706
|
/**
|
|
12666
12707
|
* Tells you if an objectApiName is supported by UI API or not.
|
|
12667
12708
|
* Note: Luvio does not currently support all the entities, the list is limited to UI API supported entities
|
|
@@ -12793,8 +12834,11 @@ function mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTr
|
|
|
12793
12834
|
return existing;
|
|
12794
12835
|
}
|
|
12795
12836
|
function mergeRecordConflict(luvio, incoming, existing, recordConflictMap) {
|
|
12796
|
-
const
|
|
12797
|
-
|
|
12837
|
+
const recordKey = keyBuilder$35(luvio, {
|
|
12838
|
+
recordId: incoming.id,
|
|
12839
|
+
});
|
|
12840
|
+
const incomingNode = luvio.wrapNormalizedGraphNode(incoming, recordKey);
|
|
12841
|
+
const existingNode = luvio.wrapNormalizedGraphNode(existing, recordKey);
|
|
12798
12842
|
const incomingTrackedFieldsTrieRoot = {
|
|
12799
12843
|
name: incoming.apiName,
|
|
12800
12844
|
children: {},
|
|
@@ -12803,9 +12847,6 @@ function mergeRecordConflict(luvio, incoming, existing, recordConflictMap) {
|
|
|
12803
12847
|
name: existing.apiName,
|
|
12804
12848
|
children: {},
|
|
12805
12849
|
};
|
|
12806
|
-
const recordKey = keyBuilder$35(luvio, {
|
|
12807
|
-
recordId: incoming.id,
|
|
12808
|
-
});
|
|
12809
12850
|
const trackedFieldsConfig = {
|
|
12810
12851
|
maxDepth: configurationForRestAdapters.getTrackedFieldDepthOnCacheMergeConflict(),
|
|
12811
12852
|
onlyFetchLeafNodeIdAndName: configurationForRestAdapters.getTrackedFieldLeafNodeIdAndNameOnly(),
|
|
@@ -13128,7 +13169,7 @@ function fulfill(existing, incoming) {
|
|
|
13128
13169
|
const batchRequestWithSingleRequest = isSingleBatchRecordRequest(existingUrlParams) &&
|
|
13129
13170
|
isSingleRecordRequest(urlParams) &&
|
|
13130
13171
|
incomingUrlRecords[0] === existingUrlRecords[0];
|
|
13131
|
-
if (!batchRequestWithSingleRequest) {
|
|
13172
|
+
if (!batchRequestWithSingleRequest || isRestrictedPathCondition(existingPath, path)) {
|
|
13132
13173
|
return false;
|
|
13133
13174
|
}
|
|
13134
13175
|
}
|
|
@@ -13171,6 +13212,12 @@ function isSingleBatchRecordRequest(urlParams) {
|
|
|
13171
13212
|
function isSingleRecordRequest(urlParams) {
|
|
13172
13213
|
return hasOwnProperty.call(urlParams, 'recordId');
|
|
13173
13214
|
}
|
|
13215
|
+
function isRestrictedPathCondition(existingPath, path) {
|
|
13216
|
+
// should not dedupe getRecordUi and getRecord as both of their representation is different
|
|
13217
|
+
// records call cannot digest response of getRecordUi
|
|
13218
|
+
return ((existingPath.includes('/record-ui') && path.includes('/records')) ||
|
|
13219
|
+
(existingPath.includes('/records') && path.includes('/record-ui')));
|
|
13220
|
+
}
|
|
13174
13221
|
|
|
13175
13222
|
const createResourceRequest$16 = function getUiApiRecordsByRecordIdCreateResourceRequest(config) {
|
|
13176
13223
|
return {
|
|
@@ -19587,7 +19634,7 @@ function getLayoutMapAndObjectInfo(recordId, data) {
|
|
|
19587
19634
|
// Temp fix until we can mimic the server behavior for non-layoutable entities.
|
|
19588
19635
|
let layoutMap = {};
|
|
19589
19636
|
if (hasOwnProperty.call(layouts, apiName)) {
|
|
19590
|
-
layoutMap = layouts[apiName][recordTypeId];
|
|
19637
|
+
layoutMap = layouts[apiName][recordTypeId] || {};
|
|
19591
19638
|
}
|
|
19592
19639
|
return {
|
|
19593
19640
|
layoutMap,
|
|
@@ -19769,18 +19816,28 @@ const buildLayoutModeCacheSnapshot = (apiName, recordTypeId, layoutType, mode) =
|
|
|
19769
19816
|
* These are intermediate lookups to check if the record is in the L2 cache
|
|
19770
19817
|
* @param {Luvio} luvio
|
|
19771
19818
|
* @param {GetRecordLayoutTypeConfig} config
|
|
19772
|
-
* @param {BuildCachedSnapshot<BuildSnapshotContext} cachedSnapshot
|
|
19819
|
+
* @param {BuildCachedSnapshot<BuildSnapshotContext>} cachedSnapshot
|
|
19773
19820
|
*/
|
|
19774
19821
|
function makeCacheOnlySnapshot(luvio, config, adapterContext, cachedSnapshot) {
|
|
19775
|
-
return luvio.applyCachePolicy(
|
|
19776
|
-
|
|
19777
|
-
|
|
19778
|
-
|
|
19779
|
-
},
|
|
19780
|
-
}, { config, luvio, adapterContext }, cachedSnapshot,
|
|
19781
|
-
// this won't be invoked since we're requesting only-if-cached
|
|
19822
|
+
return luvio.applyCachePolicy(
|
|
19823
|
+
// Pass empty context so environment will use its default cache-policy
|
|
19824
|
+
{}, { config, luvio, adapterContext }, cachedSnapshot,
|
|
19825
|
+
// disallow hitting the network by returning a gateway timeout
|
|
19782
19826
|
() => {
|
|
19783
|
-
|
|
19827
|
+
return new Promise((resolve) => {
|
|
19828
|
+
resolve({
|
|
19829
|
+
state: 'Error',
|
|
19830
|
+
data: undefined,
|
|
19831
|
+
error: {
|
|
19832
|
+
body: undefined,
|
|
19833
|
+
headers: {},
|
|
19834
|
+
ok: false,
|
|
19835
|
+
status: 504,
|
|
19836
|
+
statusText: 'Gateway Timeout',
|
|
19837
|
+
errorType: 'fetchResponse',
|
|
19838
|
+
},
|
|
19839
|
+
});
|
|
19840
|
+
});
|
|
19784
19841
|
});
|
|
19785
19842
|
}
|
|
19786
19843
|
/**
|
|
@@ -19991,7 +20048,7 @@ const notifyChangeFactory = (luvio) => {
|
|
|
19991
20048
|
const responsePromises = [];
|
|
19992
20049
|
for (let i = 0, len = entries.length; i < len; i++) {
|
|
19993
20050
|
const { key, record } = entries[i];
|
|
19994
|
-
const node = luvio.wrapNormalizedGraphNode(record);
|
|
20051
|
+
const node = luvio.wrapNormalizedGraphNode(record, key);
|
|
19995
20052
|
const optionalFields = getTrackedFields(key, node, {
|
|
19996
20053
|
maxDepth: configurationForRestAdapters.getTrackedFieldDepthOnNotifyChange(),
|
|
19997
20054
|
onlyFetchLeafNodeIdAndName: configurationForRestAdapters.getTrackedFieldLeafNodeIdAndNameOnly(),
|
|
@@ -50386,6 +50443,7 @@ function buildSelectionForField$7(source, reader, sel, variables, fragments, isC
|
|
|
50386
50443
|
}
|
|
50387
50444
|
if (fieldData === null) {
|
|
50388
50445
|
reader.assignScalar(requestedFieldName, sink, fieldData);
|
|
50446
|
+
reader.exitPath();
|
|
50389
50447
|
return sink;
|
|
50390
50448
|
}
|
|
50391
50449
|
const fieldType = getFieldType(sel);
|
|
@@ -50411,17 +50469,8 @@ function buildSelectionForField$7(source, reader, sel, variables, fragments, isC
|
|
|
50411
50469
|
return sink;
|
|
50412
50470
|
}
|
|
50413
50471
|
function selectTypeLink(sel, fieldData, reader, key, sink, variables, fragments, version, selectFn, isCursorConnection) {
|
|
50414
|
-
const resolvedLink = reader
|
|
50415
|
-
|
|
50416
|
-
node: {
|
|
50417
|
-
kind: 'Fragment',
|
|
50418
|
-
private: [],
|
|
50419
|
-
opaque: true,
|
|
50420
|
-
version,
|
|
50421
|
-
},
|
|
50422
|
-
variables: {}
|
|
50423
|
-
});
|
|
50424
|
-
if (resolvedLink.data !== undefined) {
|
|
50472
|
+
const resolvedLink = resolveLink(reader, fieldData, version);
|
|
50473
|
+
if (resolvedLink && resolvedLink.data !== undefined) {
|
|
50425
50474
|
if (isCursorConnection) {
|
|
50426
50475
|
selectTypeLinkWithPagination(resolvedLink, sel, fieldData, reader, key, sink, variables, fragments, selectFn);
|
|
50427
50476
|
}
|
|
@@ -51003,19 +51052,11 @@ function selectType$6(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
51003
51052
|
}
|
|
51004
51053
|
case 'PolymorphicParentRelationship':
|
|
51005
51054
|
case 'RecordRepresentation': {
|
|
51006
|
-
const spanningFieldLink = reader
|
|
51007
|
-
|
|
51008
|
-
|
|
51009
|
-
kind: 'Fragment',
|
|
51010
|
-
private: [],
|
|
51011
|
-
opaque: true,
|
|
51012
|
-
version: VERSION$2i,
|
|
51013
|
-
},
|
|
51014
|
-
variables: {},
|
|
51015
|
-
});
|
|
51016
|
-
reader.markSeenId(fieldData.__ref);
|
|
51017
|
-
const resolvedSpanningFieldValue = spanningFieldLink.data;
|
|
51055
|
+
const spanningFieldLink = resolveLink(reader, fieldData, VERSION$2i);
|
|
51056
|
+
const resolvedSpanningFieldValue = spanningFieldLink && spanningFieldLink.data;
|
|
51057
|
+
const fieldDataRef = fieldData.__ref;
|
|
51018
51058
|
if (resolvedSpanningFieldValue !== undefined) {
|
|
51059
|
+
reader.markSeenId(fieldDataRef);
|
|
51019
51060
|
const { value: spanningFieldResult } = resolvedSpanningFieldValue;
|
|
51020
51061
|
// Handle null values - graphql will return it at the field level, not return nested { value: null }
|
|
51021
51062
|
if (spanningFieldResult === null || typeof spanningFieldResult !== 'object') {
|
|
@@ -51039,7 +51080,9 @@ function selectType$6(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
51039
51080
|
}
|
|
51040
51081
|
}
|
|
51041
51082
|
else {
|
|
51042
|
-
|
|
51083
|
+
if (fieldDataRef !== undefined) {
|
|
51084
|
+
reader.markMissingLink(fieldDataRef);
|
|
51085
|
+
}
|
|
51043
51086
|
reader.markMissing();
|
|
51044
51087
|
}
|
|
51045
51088
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lwc-adapters-uiapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.229.0-dev10",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "UIAPI adapters with LWC bindings",
|
|
6
6
|
"module": "dist/main.js",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"clean": "rm -rf dist src/generated"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@salesforce/lds-adapters-uiapi": "
|
|
34
|
+
"@salesforce/lds-adapters-uiapi": "1.229.0-dev10"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@luvio/lwc-luvio": "0.
|
|
38
|
-
"@salesforce/lds-default-luvio": "
|
|
37
|
+
"@luvio/lwc-luvio": "0.146.0-dev5",
|
|
38
|
+
"@salesforce/lds-default-luvio": "1.229.0-dev10"
|
|
39
39
|
}
|
|
40
40
|
}
|