@salesforce/lwc-adapters-uiapi 1.228.0 → 1.229.0-dev1
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 +292 -122
- package/package.json +4 -4
package/dist/main.js
CHANGED
|
@@ -533,7 +533,7 @@ function createResourceParamsImpl(config, configMetadata) {
|
|
|
533
533
|
}
|
|
534
534
|
return resourceParams;
|
|
535
535
|
}
|
|
536
|
-
// engine version: 0.145.
|
|
536
|
+
// engine version: 0.145.2-6a13677c
|
|
537
537
|
|
|
538
538
|
/**
|
|
539
539
|
* Returns true if the value acts like a Promise, i.e. has a "then" function,
|
|
@@ -7646,6 +7646,21 @@ function createFragmentMap(documentNode) {
|
|
|
7646
7646
|
});
|
|
7647
7647
|
return fragments;
|
|
7648
7648
|
}
|
|
7649
|
+
function mergeFragmentWithExistingSelections(fragmentFieldSelection, existingSelections) {
|
|
7650
|
+
// Check if there is an existing selection for this field we can merge with
|
|
7651
|
+
const existingField = getRequestedField(fragmentFieldSelection.name.value, existingSelections);
|
|
7652
|
+
if (existingField === undefined) {
|
|
7653
|
+
existingSelections.push(fragmentFieldSelection);
|
|
7654
|
+
}
|
|
7655
|
+
else {
|
|
7656
|
+
if (existingField.selectionSet) {
|
|
7657
|
+
const mergedSelections = mergeSelectionSets(existingField.selectionSet, fragmentFieldSelection.selectionSet);
|
|
7658
|
+
existingField.selectionSet.selections = mergedSelections
|
|
7659
|
+
? mergedSelections.selections
|
|
7660
|
+
: [];
|
|
7661
|
+
}
|
|
7662
|
+
}
|
|
7663
|
+
}
|
|
7649
7664
|
|
|
7650
7665
|
function buildFieldState(state, fullPath, data) {
|
|
7651
7666
|
return {
|
|
@@ -7714,6 +7729,220 @@ function serializeValueNode(valueNode, variables) {
|
|
|
7714
7729
|
}
|
|
7715
7730
|
}
|
|
7716
7731
|
}
|
|
7732
|
+
let selectionSetRequestedFieldsWeakMap = new WeakMap();
|
|
7733
|
+
function getRequestedFieldsForType(typename, selectionSet, namedFragmentsMap, isFragmentApplicable) {
|
|
7734
|
+
let cachedRequestedFieldsConfigurations = selectionSetRequestedFieldsWeakMap.get(selectionSet);
|
|
7735
|
+
if (cachedRequestedFieldsConfigurations === undefined) {
|
|
7736
|
+
cachedRequestedFieldsConfigurations = new Map();
|
|
7737
|
+
selectionSetRequestedFieldsWeakMap.set(selectionSet, cachedRequestedFieldsConfigurations);
|
|
7738
|
+
}
|
|
7739
|
+
const cachedRequestedFieldsForType = cachedRequestedFieldsConfigurations.get(typename);
|
|
7740
|
+
if (cachedRequestedFieldsForType !== undefined) {
|
|
7741
|
+
return cachedRequestedFieldsForType;
|
|
7742
|
+
}
|
|
7743
|
+
const selections = calculateRequestedFieldsForType(typename, selectionSet, namedFragmentsMap, isFragmentApplicable);
|
|
7744
|
+
cachedRequestedFieldsConfigurations.set(typename, selections);
|
|
7745
|
+
return selections;
|
|
7746
|
+
}
|
|
7747
|
+
function getRequestedField(responseDataFieldName, requestedFields) {
|
|
7748
|
+
return requestedFields.find((fieldNode) => (fieldNode.alias && fieldNode.alias.value === responseDataFieldName) ||
|
|
7749
|
+
(!fieldNode.alias && fieldNode.name.value === responseDataFieldName));
|
|
7750
|
+
}
|
|
7751
|
+
function calculateRequestedFieldsForType(typename, selectionSet, namedFragmentsMap, isFragmentApplicable) {
|
|
7752
|
+
const selections = [];
|
|
7753
|
+
selectionSet.selections.forEach((selection) => {
|
|
7754
|
+
if (selection.kind === 'Field') {
|
|
7755
|
+
selections.push(selection);
|
|
7756
|
+
}
|
|
7757
|
+
if (selection.kind === 'InlineFragment' && isFragmentApplicable(selection, typename)) {
|
|
7758
|
+
// loops over the map to get the values.
|
|
7759
|
+
getRequestedFieldsForType(typename, selection.selectionSet, namedFragmentsMap, isFragmentApplicable).forEach((fragmentFieldSelection) => {
|
|
7760
|
+
mergeFragmentWithExistingSelections(fragmentFieldSelection, selections);
|
|
7761
|
+
});
|
|
7762
|
+
}
|
|
7763
|
+
if (selection.kind === 'FragmentSpread') {
|
|
7764
|
+
const namedFragment = namedFragmentsMap[selection.name.value];
|
|
7765
|
+
if (namedFragment && isFragmentApplicable(namedFragment, typename)) {
|
|
7766
|
+
// loops over the map to get the values.
|
|
7767
|
+
getRequestedFieldsForType(typename, namedFragment.selectionSet, namedFragmentsMap, isFragmentApplicable).forEach((fragmentFieldSelection) => {
|
|
7768
|
+
mergeFragmentWithExistingSelections(fragmentFieldSelection, selections);
|
|
7769
|
+
});
|
|
7770
|
+
}
|
|
7771
|
+
}
|
|
7772
|
+
});
|
|
7773
|
+
// Needs to happen after the selections are merged.
|
|
7774
|
+
return selections.reduce((acc, fieldNode) => {
|
|
7775
|
+
const fieldName = fieldNode.alias ? fieldNode.alias.value : fieldNode.name.value;
|
|
7776
|
+
// TODO: W-13485835. Some fields are not being merged, and this logic reproduces the current behavior in which the first field with name is being used.
|
|
7777
|
+
if (!acc.has(fieldName)) {
|
|
7778
|
+
acc.set(fieldName, fieldNode);
|
|
7779
|
+
}
|
|
7780
|
+
else {
|
|
7781
|
+
const existingFieldNode = acc.get(fieldName);
|
|
7782
|
+
acc.set(fieldName, {
|
|
7783
|
+
...existingFieldNode,
|
|
7784
|
+
selectionSet: mergeSelectionSets(existingFieldNode === null || existingFieldNode === void 0 ? void 0 : existingFieldNode.selectionSet, fieldNode.selectionSet),
|
|
7785
|
+
});
|
|
7786
|
+
}
|
|
7787
|
+
return acc;
|
|
7788
|
+
}, new Map());
|
|
7789
|
+
}
|
|
7790
|
+
function mergeSelectionSets(set1, set2) {
|
|
7791
|
+
if (!set2) {
|
|
7792
|
+
return set1;
|
|
7793
|
+
}
|
|
7794
|
+
const set1Selections = !set1 ? [] : set1.selections;
|
|
7795
|
+
const mergedSelections = [...set1Selections];
|
|
7796
|
+
for (const selection of set2.selections) {
|
|
7797
|
+
if (selection.kind === 'Field') {
|
|
7798
|
+
const existingFieldIndex = mergedSelections.findIndex((sel) => {
|
|
7799
|
+
return sel.kind === 'Field' && isExactSameField(sel, selection);
|
|
7800
|
+
});
|
|
7801
|
+
if (existingFieldIndex > -1) {
|
|
7802
|
+
const existingField = mergedSelections[existingFieldIndex];
|
|
7803
|
+
const mergedSelectionSet = mergeSelectionSets(existingField.selectionSet, selection.selectionSet);
|
|
7804
|
+
if (mergedSelectionSet) {
|
|
7805
|
+
mergedSelections[existingFieldIndex] = {
|
|
7806
|
+
...existingField,
|
|
7807
|
+
selectionSet: mergedSelectionSet,
|
|
7808
|
+
};
|
|
7809
|
+
}
|
|
7810
|
+
}
|
|
7811
|
+
else {
|
|
7812
|
+
mergedSelections.push(selection);
|
|
7813
|
+
}
|
|
7814
|
+
}
|
|
7815
|
+
else if (selection.kind === 'FragmentSpread') {
|
|
7816
|
+
if (!mergedSelections.some((sel) => sel.kind === 'FragmentSpread' &&
|
|
7817
|
+
sel.name.value === selection.name.value &&
|
|
7818
|
+
areDirectivesEqual(sel.directives, selection.directives))) {
|
|
7819
|
+
mergedSelections.push(selection);
|
|
7820
|
+
}
|
|
7821
|
+
}
|
|
7822
|
+
else if (selection.kind === 'InlineFragment') {
|
|
7823
|
+
const existingFragmentIndex = mergedSelections.findIndex((sel) => {
|
|
7824
|
+
return (sel.kind === 'InlineFragment' &&
|
|
7825
|
+
areTypeConditionsEqual(sel.typeCondition, selection.typeCondition) &&
|
|
7826
|
+
areDirectivesEqual(sel.directives, selection.directives));
|
|
7827
|
+
});
|
|
7828
|
+
if (existingFragmentIndex > -1) {
|
|
7829
|
+
const existingFragment = mergedSelections[existingFragmentIndex];
|
|
7830
|
+
const mergedSelectionSet = mergeSelectionSets(existingFragment.selectionSet, selection.selectionSet);
|
|
7831
|
+
if (mergedSelectionSet) {
|
|
7832
|
+
mergedSelections[existingFragmentIndex] = {
|
|
7833
|
+
...existingFragment,
|
|
7834
|
+
selectionSet: mergedSelectionSet,
|
|
7835
|
+
};
|
|
7836
|
+
}
|
|
7837
|
+
}
|
|
7838
|
+
else {
|
|
7839
|
+
mergedSelections.push(selection);
|
|
7840
|
+
}
|
|
7841
|
+
}
|
|
7842
|
+
}
|
|
7843
|
+
return { kind: 'SelectionSet', selections: mergedSelections };
|
|
7844
|
+
}
|
|
7845
|
+
function areArgumentsEqual(args1, args2) {
|
|
7846
|
+
if (!args1 && !args2) {
|
|
7847
|
+
return true;
|
|
7848
|
+
}
|
|
7849
|
+
// length 0 arguments is semantically equivalent to falsy arguments.
|
|
7850
|
+
if ((!args1 || args1.length === 0) && (!args2 || args2.length === 0)) {
|
|
7851
|
+
return true;
|
|
7852
|
+
}
|
|
7853
|
+
if ((!args1 && args2) || (args1 && !args2)) {
|
|
7854
|
+
return false;
|
|
7855
|
+
}
|
|
7856
|
+
if (args1.length !== args2.length) {
|
|
7857
|
+
return false;
|
|
7858
|
+
}
|
|
7859
|
+
for (const arg of args1) {
|
|
7860
|
+
const matchingArg = args2.find((a) => a.name.value === arg.name.value && areValuesEqual(a.value, arg.value));
|
|
7861
|
+
if (!matchingArg) {
|
|
7862
|
+
return false;
|
|
7863
|
+
}
|
|
7864
|
+
}
|
|
7865
|
+
return true;
|
|
7866
|
+
}
|
|
7867
|
+
function areDirectivesEqual(dirs1, dirs2) {
|
|
7868
|
+
if (!dirs1 && !dirs2) {
|
|
7869
|
+
return true;
|
|
7870
|
+
}
|
|
7871
|
+
if ((!dirs1 || dirs1.length === 0) && (!dirs2 || dirs2.length === 0)) {
|
|
7872
|
+
return true;
|
|
7873
|
+
}
|
|
7874
|
+
if ((!dirs1 && dirs2) || (dirs1 && !dirs2)) {
|
|
7875
|
+
return false;
|
|
7876
|
+
}
|
|
7877
|
+
if (dirs1.length !== dirs2.length) {
|
|
7878
|
+
return false;
|
|
7879
|
+
}
|
|
7880
|
+
for (const dir of dirs1) {
|
|
7881
|
+
const matchingDir = dirs2.find((d) => d.name.value === dir.name.value && areArgumentsEqual(d.arguments, dir.arguments));
|
|
7882
|
+
if (!matchingDir) {
|
|
7883
|
+
return false;
|
|
7884
|
+
}
|
|
7885
|
+
}
|
|
7886
|
+
return true;
|
|
7887
|
+
}
|
|
7888
|
+
function areValuesEqual(valueNode1, valueNode2) {
|
|
7889
|
+
if (valueNode1.kind !== valueNode2.kind) {
|
|
7890
|
+
return false;
|
|
7891
|
+
}
|
|
7892
|
+
// Typescript doesn't understand that the above check means that the switch applies to both values. So there will be casts here.
|
|
7893
|
+
switch (valueNode1.kind) {
|
|
7894
|
+
case 'StringValue':
|
|
7895
|
+
case 'IntValue':
|
|
7896
|
+
case 'FloatValue':
|
|
7897
|
+
case 'BooleanValue':
|
|
7898
|
+
case 'EnumValue':
|
|
7899
|
+
return valueNode1.value === valueNode2.value;
|
|
7900
|
+
case 'NullValue':
|
|
7901
|
+
return true; // Both Null value nodes? Always true.
|
|
7902
|
+
case 'ListValue':
|
|
7903
|
+
if (valueNode1.values.length !== valueNode2.values.length) {
|
|
7904
|
+
return false;
|
|
7905
|
+
}
|
|
7906
|
+
for (let i = 0; i < valueNode1.values.length; i++) {
|
|
7907
|
+
if (!areValuesEqual(valueNode1.values[i], valueNode2.values[i])) {
|
|
7908
|
+
return false;
|
|
7909
|
+
}
|
|
7910
|
+
}
|
|
7911
|
+
return true;
|
|
7912
|
+
case 'ObjectValue':
|
|
7913
|
+
if (valueNode1.fields.length !== valueNode2.fields.length) {
|
|
7914
|
+
return false;
|
|
7915
|
+
}
|
|
7916
|
+
for (let i = 0; i < valueNode1.fields.length; i++) {
|
|
7917
|
+
const field1 = valueNode1.fields[i];
|
|
7918
|
+
const field2 = valueNode2.fields.find((f) => f.name.value === field1.name.value);
|
|
7919
|
+
if (!field2 || !areValuesEqual(field1.value, field2.value)) {
|
|
7920
|
+
return false;
|
|
7921
|
+
}
|
|
7922
|
+
}
|
|
7923
|
+
return true;
|
|
7924
|
+
case 'Variable':
|
|
7925
|
+
return valueNode1.name.value === valueNode2.name.value;
|
|
7926
|
+
default:
|
|
7927
|
+
return false;
|
|
7928
|
+
}
|
|
7929
|
+
}
|
|
7930
|
+
function areTypeConditionsEqual(typeCondition1, typeCondition2) {
|
|
7931
|
+
if (typeCondition1 === undefined && typeCondition2 === undefined) {
|
|
7932
|
+
return true;
|
|
7933
|
+
}
|
|
7934
|
+
if ((!typeCondition1 && typeCondition2) || (typeCondition1 && !typeCondition2)) {
|
|
7935
|
+
return false;
|
|
7936
|
+
}
|
|
7937
|
+
return typeCondition1.name.value === typeCondition2.name.value;
|
|
7938
|
+
}
|
|
7939
|
+
function isExactSameField(field1, field2) {
|
|
7940
|
+
var _a, _b;
|
|
7941
|
+
return (field1.name.value === field2.name.value &&
|
|
7942
|
+
((_a = field1.alias) === null || _a === void 0 ? void 0 : _a.value) === ((_b = field2.alias) === null || _b === void 0 ? void 0 : _b.value) &&
|
|
7943
|
+
areArgumentsEqual(field1.arguments, field2.arguments) &&
|
|
7944
|
+
areDirectivesEqual(field1.directives, field2.directives));
|
|
7945
|
+
}
|
|
7717
7946
|
|
|
7718
7947
|
function serializeOperationNode(operationNode, variables, fragmentMap) {
|
|
7719
7948
|
return `${serializeSelectionSet(operationNode.selectionSet, variables, fragmentMap)}`;
|
|
@@ -7770,6 +7999,53 @@ function getOperationFromDocument(document, operationName) {
|
|
|
7770
7999
|
return operations[0]; // If a named operation is not provided, we return the first one
|
|
7771
8000
|
}
|
|
7772
8001
|
|
|
8002
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty$1 } = Object.prototype;
|
|
8003
|
+
// Deep merge that works on GraphQL data. It:
|
|
8004
|
+
// - recursively merges any Object properties that are present in both
|
|
8005
|
+
// - recursively merges arrays by deepMerging each Object item in the array (by index).
|
|
8006
|
+
function deepMerge(target, ...sources) {
|
|
8007
|
+
for (const source of sources) {
|
|
8008
|
+
for (const key in source) {
|
|
8009
|
+
if (ObjectPrototypeHasOwnProperty$1.call(source, key)) {
|
|
8010
|
+
const targetValue = target[key];
|
|
8011
|
+
const sourceValue = source[key];
|
|
8012
|
+
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
8013
|
+
const maxLength = Math.max(targetValue.length, sourceValue.length);
|
|
8014
|
+
target[key] = Array.from({ length: maxLength }, (_, index) => {
|
|
8015
|
+
const targetItem = targetValue[index];
|
|
8016
|
+
const sourceItem = sourceValue[index];
|
|
8017
|
+
if (targetItem === undefined) {
|
|
8018
|
+
return sourceItem;
|
|
8019
|
+
}
|
|
8020
|
+
else if (sourceItem === undefined) {
|
|
8021
|
+
return targetItem;
|
|
8022
|
+
}
|
|
8023
|
+
else if (targetItem instanceof Object &&
|
|
8024
|
+
!Array.isArray(targetItem) &&
|
|
8025
|
+
sourceItem instanceof Object &&
|
|
8026
|
+
!Array.isArray(sourceItem)) {
|
|
8027
|
+
return deepMerge({}, targetItem, sourceItem);
|
|
8028
|
+
}
|
|
8029
|
+
else {
|
|
8030
|
+
return sourceItem;
|
|
8031
|
+
}
|
|
8032
|
+
});
|
|
8033
|
+
}
|
|
8034
|
+
else if (targetValue instanceof Object &&
|
|
8035
|
+
!Array.isArray(targetValue) &&
|
|
8036
|
+
sourceValue instanceof Object &&
|
|
8037
|
+
!Array.isArray(sourceValue)) {
|
|
8038
|
+
deepMerge(targetValue, sourceValue);
|
|
8039
|
+
}
|
|
8040
|
+
else {
|
|
8041
|
+
target[key] = sourceValue;
|
|
8042
|
+
}
|
|
8043
|
+
}
|
|
8044
|
+
}
|
|
8045
|
+
}
|
|
8046
|
+
return target;
|
|
8047
|
+
}
|
|
8048
|
+
|
|
7773
8049
|
/**
|
|
7774
8050
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
7775
8051
|
* All rights reserved.
|
|
@@ -12852,7 +13128,7 @@ function fulfill(existing, incoming) {
|
|
|
12852
13128
|
const batchRequestWithSingleRequest = isSingleBatchRecordRequest(existingUrlParams) &&
|
|
12853
13129
|
isSingleRecordRequest(urlParams) &&
|
|
12854
13130
|
incomingUrlRecords[0] === existingUrlRecords[0];
|
|
12855
|
-
if (!batchRequestWithSingleRequest) {
|
|
13131
|
+
if (!batchRequestWithSingleRequest || isRestrictedPathCondition(existingPath, path)) {
|
|
12856
13132
|
return false;
|
|
12857
13133
|
}
|
|
12858
13134
|
}
|
|
@@ -12895,6 +13171,12 @@ function isSingleBatchRecordRequest(urlParams) {
|
|
|
12895
13171
|
function isSingleRecordRequest(urlParams) {
|
|
12896
13172
|
return hasOwnProperty.call(urlParams, 'recordId');
|
|
12897
13173
|
}
|
|
13174
|
+
function isRestrictedPathCondition(existingPath, path) {
|
|
13175
|
+
// should not dedupe getRecordUi and getRecord as both of their representation is different
|
|
13176
|
+
// records call cannot digest response of getRecordUi
|
|
13177
|
+
return ((existingPath.includes('/record-ui') && path.includes('/records')) ||
|
|
13178
|
+
(existingPath.includes('/records') && path.includes('/record-ui')));
|
|
13179
|
+
}
|
|
12898
13180
|
|
|
12899
13181
|
const createResourceRequest$16 = function getUiApiRecordsByRecordIdCreateResourceRequest(config) {
|
|
12900
13182
|
return {
|
|
@@ -49485,13 +49767,12 @@ function injectSelectionSet(selectionSetNode, queryTransformHelper, fragmentMap)
|
|
|
49485
49767
|
selectionSetNode === undefined) {
|
|
49486
49768
|
return;
|
|
49487
49769
|
}
|
|
49488
|
-
const
|
|
49489
|
-
|
|
49490
|
-
selections
|
|
49491
|
-
|
|
49492
|
-
|
|
49493
|
-
|
|
49494
|
-
mergedSelections.forEach(selection => {
|
|
49770
|
+
const minimumSelectionSet = {
|
|
49771
|
+
kind: 'SelectionSet',
|
|
49772
|
+
selections: queryTransformHelper.getMinimumSelections()
|
|
49773
|
+
};
|
|
49774
|
+
const mergedSelections = mergeSelectionSets(selectionSetNode, minimumSelectionSet);
|
|
49775
|
+
mergedSelections === null || mergedSelections === void 0 ? void 0 : mergedSelections.selections.forEach(selection => {
|
|
49495
49776
|
if (selection.kind === 'Field') {
|
|
49496
49777
|
const fieldType = queryTransformHelper.getFieldType(selection);
|
|
49497
49778
|
const fieldTransformHelper = fieldType === undefined ? undefined : getQueryTransformerForType(fieldType.typename);
|
|
@@ -49520,46 +49801,7 @@ function injectSelectionSet(selectionSetNode, queryTransformHelper, fragmentMap)
|
|
|
49520
49801
|
}
|
|
49521
49802
|
}
|
|
49522
49803
|
});
|
|
49523
|
-
Object.assign(selectionSetNode,
|
|
49524
|
-
selections: mergedSelections.length > 0 ? mergedSelections : undefined
|
|
49525
|
-
});
|
|
49526
|
-
}
|
|
49527
|
-
function mergeSelections(minimumSelections, querySelections) {
|
|
49528
|
-
const mergedSelections = [...querySelections];
|
|
49529
|
-
for (let i = 0; i < minimumSelections.length; i++) {
|
|
49530
|
-
const minimumSelection = minimumSelections[i];
|
|
49531
|
-
if (minimumSelection.kind === 'Field') {
|
|
49532
|
-
const existingNode = mergedSelections.find(selection => {
|
|
49533
|
-
return selection.kind === 'Field' && selection.name.value === minimumSelection.name.value && (selection.directives === undefined || selection.directives.length === 0);
|
|
49534
|
-
});
|
|
49535
|
-
if (existingNode !== undefined && existingNode.kind === 'Field') { // Maybe do better type narrowing above
|
|
49536
|
-
const existingNodeHasSubselections = existingNode.selectionSet !== undefined && existingNode.selectionSet.selections.length > 0;
|
|
49537
|
-
const minimumFieldNodeHasSubselections = minimumSelection.selectionSet !== undefined && minimumSelection.selectionSet.selections.length > 0;
|
|
49538
|
-
// TODO(correctness enhancement): this doesn't handle arugments. Add alias if arguments disagree?
|
|
49539
|
-
if (existingNodeHasSubselections && minimumFieldNodeHasSubselections) {
|
|
49540
|
-
const mergedChildSelections = mergeSelections(minimumSelection.selectionSet.selections, existingNode.selectionSet.selections);
|
|
49541
|
-
Object.assign(existingNode.selectionSet, {
|
|
49542
|
-
selections: mergedChildSelections
|
|
49543
|
-
});
|
|
49544
|
-
}
|
|
49545
|
-
}
|
|
49546
|
-
else {
|
|
49547
|
-
mergedSelections.push(minimumSelection);
|
|
49548
|
-
}
|
|
49549
|
-
}
|
|
49550
|
-
if (minimumSelection.kind === 'InlineFragment') {
|
|
49551
|
-
mergedSelections.push(minimumSelection);
|
|
49552
|
-
}
|
|
49553
|
-
if (minimumSelection.kind === 'FragmentSpread') {
|
|
49554
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
49555
|
-
console.error('named fragment minimum selections are not supported and will not be added to the query.');
|
|
49556
|
-
}
|
|
49557
|
-
}
|
|
49558
|
-
}
|
|
49559
|
-
return mergedSelections;
|
|
49560
|
-
}
|
|
49561
|
-
function getRequestedField(responseDataFieldName, requestedFields) {
|
|
49562
|
-
return requestedFields.find(fieldNode => (fieldNode.alias && fieldNode.alias.value === responseDataFieldName) || (!fieldNode.alias && fieldNode.name.value === responseDataFieldName));
|
|
49804
|
+
Object.assign(selectionSetNode, mergedSelections);
|
|
49563
49805
|
}
|
|
49564
49806
|
function getPageMetadata(paginationMetadata, paginationParams) {
|
|
49565
49807
|
const metadataProperties = {};
|
|
@@ -49605,67 +49847,6 @@ function getSerializedKeyForField(field, variables, fieldType) {
|
|
|
49605
49847
|
const argumentString = mutableArgumentNodes.length > 0 ? '__' + serializeFieldArguments(mutableArgumentNodes, variables) : '';
|
|
49606
49848
|
return field.name.value + argumentString; // It should be safe to always use the fieldName - If an alias is meaningful, there will be arguments on the key also.
|
|
49607
49849
|
}
|
|
49608
|
-
function mergeFragmentWithExistingSelections(fragmentFieldSelection, existingSelections) {
|
|
49609
|
-
// Check if there is an existing selection for this field we can merge with
|
|
49610
|
-
// If this isn't done, we will see issues such as W-12293630 & W-12236456 as examples
|
|
49611
|
-
const existingField = getRequestedField(fragmentFieldSelection.name.value, existingSelections);
|
|
49612
|
-
if (existingField === undefined) {
|
|
49613
|
-
existingSelections.push(fragmentFieldSelection);
|
|
49614
|
-
}
|
|
49615
|
-
else {
|
|
49616
|
-
if (existingField.selectionSet === undefined) {
|
|
49617
|
-
existingField.selectionSet === fragmentFieldSelection.selectionSet;
|
|
49618
|
-
}
|
|
49619
|
-
else if (fragmentFieldSelection.selectionSet !== undefined) {
|
|
49620
|
-
existingField.selectionSet.selections = mergeSelections(fragmentFieldSelection.selectionSet.selections, existingField.selectionSet.selections);
|
|
49621
|
-
}
|
|
49622
|
-
}
|
|
49623
|
-
}
|
|
49624
|
-
function calculateRequestedFieldsForType(typename, selectionSet, namedFragmentsMap, isFragmentApplicable) {
|
|
49625
|
-
const selections = [];
|
|
49626
|
-
selectionSet.selections.forEach(selection => {
|
|
49627
|
-
if (selection.kind === "Field") {
|
|
49628
|
-
selections.push(selection);
|
|
49629
|
-
}
|
|
49630
|
-
if (selection.kind === "InlineFragment" && isFragmentApplicable(selection, typename)) {
|
|
49631
|
-
// loops over the map to get the values.
|
|
49632
|
-
getRequestedFieldsForType(typename, selection.selectionSet, namedFragmentsMap, isFragmentApplicable)
|
|
49633
|
-
.forEach(fragmentFieldSelection => { mergeFragmentWithExistingSelections(fragmentFieldSelection, selections); });
|
|
49634
|
-
}
|
|
49635
|
-
if (selection.kind === "FragmentSpread") {
|
|
49636
|
-
const namedFragment = namedFragmentsMap[selection.name.value];
|
|
49637
|
-
if (namedFragment && isFragmentApplicable(namedFragment, typename)) {
|
|
49638
|
-
// loops over the map to get the values.
|
|
49639
|
-
getRequestedFieldsForType(typename, namedFragment.selectionSet, namedFragmentsMap, isFragmentApplicable)
|
|
49640
|
-
.forEach(fragmentFieldSelection => { mergeFragmentWithExistingSelections(fragmentFieldSelection, selections); });
|
|
49641
|
-
}
|
|
49642
|
-
}
|
|
49643
|
-
});
|
|
49644
|
-
// Needs to happen after the selections are merged.
|
|
49645
|
-
return selections.reduce((acc, fieldNode) => {
|
|
49646
|
-
const fieldName = fieldNode.alias ? fieldNode.alias.value : fieldNode.name.value;
|
|
49647
|
-
// TODO: W-13485835. Some fields are not being merged, and this logic reproduces the current behavior in which the first field with name is being used.
|
|
49648
|
-
if (!acc.has(fieldName)) {
|
|
49649
|
-
acc.set(fieldName, fieldNode);
|
|
49650
|
-
}
|
|
49651
|
-
return acc;
|
|
49652
|
-
}, new Map());
|
|
49653
|
-
}
|
|
49654
|
-
let selectionSetRequestedFieldsWeakMap = new WeakMap();
|
|
49655
|
-
function getRequestedFieldsForType(typename, selectionSet, namedFragmentsMap, isFragmentApplicable) {
|
|
49656
|
-
let cachedRequestedFieldsConfigurations = selectionSetRequestedFieldsWeakMap.get(selectionSet);
|
|
49657
|
-
if (cachedRequestedFieldsConfigurations === undefined) {
|
|
49658
|
-
cachedRequestedFieldsConfigurations = new Map();
|
|
49659
|
-
selectionSetRequestedFieldsWeakMap.set(selectionSet, cachedRequestedFieldsConfigurations);
|
|
49660
|
-
}
|
|
49661
|
-
const cachedRequestedFieldsForType = cachedRequestedFieldsConfigurations.get(typename);
|
|
49662
|
-
if (cachedRequestedFieldsForType !== undefined) {
|
|
49663
|
-
return cachedRequestedFieldsForType;
|
|
49664
|
-
}
|
|
49665
|
-
const selections = calculateRequestedFieldsForType(typename, selectionSet, namedFragmentsMap, isFragmentApplicable);
|
|
49666
|
-
cachedRequestedFieldsConfigurations.set(typename, selections);
|
|
49667
|
-
return selections;
|
|
49668
|
-
}
|
|
49669
49850
|
function getQueryTransformerForType(typename, fragmentMap) {
|
|
49670
49851
|
switch (typename) {
|
|
49671
49852
|
case "PercentAggregate": return {
|
|
@@ -50284,18 +50465,7 @@ function selectCalculateSink(sink, field, buildSelectionForNodeFn, source, reade
|
|
|
50284
50465
|
(_a = field.selectionSet) === null || _a === void 0 ? void 0 : _a.selections.forEach((sel) => {
|
|
50285
50466
|
const builtSelection = buildSelectionForNodeFn(source, reader, field, sel, variables, fragments, parentRecordId);
|
|
50286
50467
|
if (builtSelection !== undefined) {
|
|
50287
|
-
|
|
50288
|
-
Object.keys(builtSelection).forEach((key, value) => {
|
|
50289
|
-
// We only assign a field selection in the fragment if it doesn't already exist in sink
|
|
50290
|
-
// The non-fragment selection already got the merged selections in getRequestedFieldsForType
|
|
50291
|
-
if (sink[key] === undefined) {
|
|
50292
|
-
sink[key] = builtSelection[key];
|
|
50293
|
-
}
|
|
50294
|
-
});
|
|
50295
|
-
}
|
|
50296
|
-
else {
|
|
50297
|
-
Object.assign(sink, builtSelection);
|
|
50298
|
-
}
|
|
50468
|
+
deepMerge(sink, builtSelection);
|
|
50299
50469
|
}
|
|
50300
50470
|
});
|
|
50301
50471
|
return sink;
|
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-dev1",
|
|
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-dev1"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@luvio/lwc-luvio": "0.145.
|
|
38
|
-
"@salesforce/lds-default-luvio": "
|
|
37
|
+
"@luvio/lwc-luvio": "0.145.2",
|
|
38
|
+
"@salesforce/lds-default-luvio": "1.229.0-dev1"
|
|
39
39
|
}
|
|
40
40
|
}
|