@salesforce/lds-worker-api 1.229.0-dev2 → 1.229.0-dev4
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/sfdc/es/ldsWorkerApi.js +1 -1
- package/dist/standalone/es/lds-worker-api.js +235 -159
- package/dist/standalone/umd/lds-worker-api.js +235 -159
- package/package.json +10 -10
|
@@ -3847,7 +3847,7 @@
|
|
|
3847
3847
|
}
|
|
3848
3848
|
return resourceParams;
|
|
3849
3849
|
}
|
|
3850
|
-
// engine version: 0.
|
|
3850
|
+
// engine version: 0.146.0-dev3-502c4337
|
|
3851
3851
|
|
|
3852
3852
|
/**
|
|
3853
3853
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -3974,7 +3974,7 @@
|
|
|
3974
3974
|
}
|
|
3975
3975
|
callbacks.push(callback);
|
|
3976
3976
|
}
|
|
3977
|
-
// version: 1.229.0-
|
|
3977
|
+
// version: 1.229.0-dev4-07d38781a
|
|
3978
3978
|
|
|
3979
3979
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
3980
3980
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -15435,7 +15435,7 @@
|
|
|
15435
15435
|
}
|
|
15436
15436
|
return superResult;
|
|
15437
15437
|
}
|
|
15438
|
-
// version: 1.229.0-
|
|
15438
|
+
// version: 1.229.0-dev4-07d38781a
|
|
15439
15439
|
|
|
15440
15440
|
function unwrap(data) {
|
|
15441
15441
|
// The lwc-luvio bindings import a function from lwc called "unwrap".
|
|
@@ -15536,14 +15536,15 @@
|
|
|
15536
15536
|
return undefined;
|
|
15537
15537
|
});
|
|
15538
15538
|
}
|
|
15539
|
-
const { isArray: isArray$8 } = Array;
|
|
15540
|
-
const { stringify: stringify$9 } = JSON;
|
|
15541
15539
|
|
|
15542
15540
|
function isPromise$1(value) {
|
|
15543
15541
|
// check for Thenable due to test frameworks using custom Promise impls
|
|
15544
15542
|
return value.then !== undefined;
|
|
15545
15543
|
}
|
|
15546
15544
|
|
|
15545
|
+
const { isArray: isArray$8 } = Array;
|
|
15546
|
+
const { stringify: stringify$9 } = JSON;
|
|
15547
|
+
|
|
15547
15548
|
/**
|
|
15548
15549
|
* (Re)throws an error after adding a prefix to the message.
|
|
15549
15550
|
*
|
|
@@ -16358,7 +16359,7 @@
|
|
|
16358
16359
|
const { apiFamily, name } = metadata;
|
|
16359
16360
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
16360
16361
|
}
|
|
16361
|
-
// version: 1.229.0-
|
|
16362
|
+
// version: 1.229.0-dev4-07d38781a
|
|
16362
16363
|
|
|
16363
16364
|
/**
|
|
16364
16365
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -16457,7 +16458,7 @@
|
|
|
16457
16458
|
TypeCheckShapes[TypeCheckShapes["Integer"] = 3] = "Integer";
|
|
16458
16459
|
TypeCheckShapes[TypeCheckShapes["Unsupported"] = 4] = "Unsupported";
|
|
16459
16460
|
})(TypeCheckShapes || (TypeCheckShapes = {}));
|
|
16460
|
-
// engine version: 0.
|
|
16461
|
+
// engine version: 0.146.0-dev3-502c4337
|
|
16461
16462
|
|
|
16462
16463
|
const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
|
|
16463
16464
|
|
|
@@ -41174,7 +41175,7 @@
|
|
|
41174
41175
|
throttle(60, 60000, createLDSAdapter(luvio, 'notifyListInfoUpdateAvailable', notifyUpdateAvailableFactory$1));
|
|
41175
41176
|
throttle(60, 60000, createLDSAdapter(luvio, 'notifyQuickActionDefaultsUpdateAvailable', notifyUpdateAvailableFactory));
|
|
41176
41177
|
});
|
|
41177
|
-
// version: 1.229.0-
|
|
41178
|
+
// version: 1.229.0-dev4-4a7593877
|
|
41178
41179
|
|
|
41179
41180
|
var caseSensitiveUserId = '005B0000000GR4OIAW';
|
|
41180
41181
|
|
|
@@ -41805,6 +41806,9 @@
|
|
|
41805
41806
|
}
|
|
41806
41807
|
|
|
41807
41808
|
function isStoreEntryError(storeRecord) {
|
|
41809
|
+
if (!storeRecord || typeof storeRecord !== 'object') {
|
|
41810
|
+
return false;
|
|
41811
|
+
}
|
|
41808
41812
|
return storeRecord.__type === 'error';
|
|
41809
41813
|
}
|
|
41810
41814
|
|
|
@@ -49296,6 +49300,10 @@
|
|
|
49296
49300
|
return node.kind === 'OperationDefinition';
|
|
49297
49301
|
}
|
|
49298
49302
|
|
|
49303
|
+
const POLYMORPHIC_PARENT_RELATIONSHIP = 'polymorphicParentRelationship';
|
|
49304
|
+
const PARENT_RELATIONSHIP = 'parentRelationship';
|
|
49305
|
+
const CHILD_RELATIONSHIP = 'childRelationship';
|
|
49306
|
+
const RECORD_QUERY = 'recordQuery';
|
|
49299
49307
|
function requestsDraftsField(recordFieldNode) {
|
|
49300
49308
|
if (!recordFieldNode.selectionSet)
|
|
49301
49309
|
return false;
|
|
@@ -49311,18 +49319,41 @@
|
|
|
49311
49319
|
directive.arguments
|
|
49312
49320
|
.map((argument) => argument.value)
|
|
49313
49321
|
.filter(isStringValueNode)
|
|
49314
|
-
.some((categoryName) => categoryName.value ===
|
|
49322
|
+
.some((categoryName) => categoryName.value === RECORD_QUERY));
|
|
49315
49323
|
});
|
|
49316
49324
|
}
|
|
49317
49325
|
return false;
|
|
49318
49326
|
}
|
|
49319
|
-
// finds field with 'recordQuery' and 'childRelationship' directive
|
|
49320
|
-
function
|
|
49321
|
-
const
|
|
49322
|
-
return
|
|
49327
|
+
// finds connection field with 'recordQuery' and 'childRelationship' directive.
|
|
49328
|
+
function findNearestConnection(ancestors) {
|
|
49329
|
+
const connectionAncestor = findNearestAncesterPath(ancestors, true).node;
|
|
49330
|
+
return connectionAncestor === undefined ? undefined : connectionAncestor;
|
|
49331
|
+
}
|
|
49332
|
+
// convinient method to find nearest connection with its path
|
|
49333
|
+
function findNearestConnectionWithPath(ancestors) {
|
|
49334
|
+
const closestAncestorPath = findNearestAncesterPath(ancestors, true);
|
|
49335
|
+
let connection = undefined;
|
|
49336
|
+
let connectionPath = undefined;
|
|
49337
|
+
if (closestAncestorPath.parentIndex > 0) {
|
|
49338
|
+
const connectionAncestor = closestAncestorPath.node;
|
|
49339
|
+
const connectionAncestors = ancestors.slice(0, closestAncestorPath.parentIndex);
|
|
49340
|
+
connection =
|
|
49341
|
+
connectionAncestor === undefined ? undefined : connectionAncestor;
|
|
49342
|
+
if (connection !== undefined) {
|
|
49343
|
+
const ancesterPath = findAncesterPath(connectionAncestors);
|
|
49344
|
+
connectionPath =
|
|
49345
|
+
ancesterPath === ''
|
|
49346
|
+
? connection.name.value
|
|
49347
|
+
: `${ancesterPath}#${connection.name.value}`;
|
|
49348
|
+
}
|
|
49349
|
+
}
|
|
49350
|
+
return {
|
|
49351
|
+
connection,
|
|
49352
|
+
path: connectionPath,
|
|
49353
|
+
};
|
|
49323
49354
|
}
|
|
49324
|
-
// finds
|
|
49325
|
-
function findNearestAncesterPath(ancestors,
|
|
49355
|
+
// finds closest ancestor. If node with 'parentRelationship' is the ancester, the end result could be 'InlineFragmentNode' since it inherits the 'parent' relationship. 'InlineFragmentNode' makes sure that only one 'apiName' returns when tree is traversed.
|
|
49356
|
+
function findNearestAncesterPath(ancestors, connectionOnly) {
|
|
49326
49357
|
let recordQueryPath = { node: undefined, parentIndex: -1 };
|
|
49327
49358
|
let relationship = '';
|
|
49328
49359
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
@@ -49336,9 +49367,11 @@
|
|
|
49336
49367
|
continue;
|
|
49337
49368
|
for (let arg of directive.arguments) {
|
|
49338
49369
|
if (arg.value &&
|
|
49339
|
-
(arg.value.value ===
|
|
49340
|
-
arg.value.value ===
|
|
49341
|
-
(!
|
|
49370
|
+
(arg.value.value === RECORD_QUERY ||
|
|
49371
|
+
arg.value.value === CHILD_RELATIONSHIP ||
|
|
49372
|
+
(!connectionOnly &&
|
|
49373
|
+
(arg.value.value === PARENT_RELATIONSHIP ||
|
|
49374
|
+
arg.value.value === POLYMORPHIC_PARENT_RELATIONSHIP)))) {
|
|
49342
49375
|
recordQueryPath = { node: node, parentIndex: i };
|
|
49343
49376
|
relationship = arg.value.value;
|
|
49344
49377
|
break;
|
|
@@ -49353,17 +49386,19 @@
|
|
|
49353
49386
|
//checks if nearest ancester could be an inline fragment
|
|
49354
49387
|
if (recordQueryPath.node !== undefined &&
|
|
49355
49388
|
recordQueryPath.node.selectionSet &&
|
|
49356
|
-
relationship ===
|
|
49357
|
-
//
|
|
49358
|
-
|
|
49359
|
-
|
|
49360
|
-
|
|
49361
|
-
if (
|
|
49389
|
+
(relationship === PARENT_RELATIONSHIP || relationship === POLYMORPHIC_PARENT_RELATIONSHIP)) {
|
|
49390
|
+
// InlineFragment is usually 3 steps aways from its FieldNode parent within ancester hierarchy if it exists. The below search
|
|
49391
|
+
// is applied to adapt to future AST structure change
|
|
49392
|
+
let parentIndex = recordQueryPath.parentIndex + 1;
|
|
49393
|
+
while (parentIndex < ancestors.length) {
|
|
49394
|
+
if (isInlineFragmentNode(ancestors[parentIndex])) {
|
|
49362
49395
|
recordQueryPath = {
|
|
49363
|
-
node: ancestors[
|
|
49364
|
-
parentIndex
|
|
49396
|
+
node: ancestors[parentIndex],
|
|
49397
|
+
parentIndex,
|
|
49365
49398
|
};
|
|
49399
|
+
break;
|
|
49366
49400
|
}
|
|
49401
|
+
parentIndex++;
|
|
49367
49402
|
}
|
|
49368
49403
|
}
|
|
49369
49404
|
return recordQueryPath;
|
|
@@ -49387,7 +49422,7 @@
|
|
|
49387
49422
|
? sectionPath
|
|
49388
49423
|
: sectionPath === ''
|
|
49389
49424
|
? path
|
|
49390
|
-
: `${sectionPath}
|
|
49425
|
+
: `${sectionPath}#${path}`;
|
|
49391
49426
|
}
|
|
49392
49427
|
}
|
|
49393
49428
|
boundaryIndex = parentIndex;
|
|
@@ -49445,9 +49480,9 @@
|
|
|
49445
49480
|
const relationships = args
|
|
49446
49481
|
.map((arg) => arg.value)
|
|
49447
49482
|
.filter(isStringValueNode)
|
|
49448
|
-
.filter((valueNode) => valueNode.value ===
|
|
49449
|
-
valueNode.value ===
|
|
49450
|
-
valueNode.value ===
|
|
49483
|
+
.filter((valueNode) => valueNode.value === CHILD_RELATIONSHIP ||
|
|
49484
|
+
valueNode.value === PARENT_RELATIONSHIP ||
|
|
49485
|
+
valueNode.value === POLYMORPHIC_PARENT_RELATIONSHIP)
|
|
49451
49486
|
.map((relationshipNode) => relationshipNode.value);
|
|
49452
49487
|
if (relationships.length > 0) {
|
|
49453
49488
|
return relationships[0];
|
|
@@ -49504,8 +49539,8 @@
|
|
|
49504
49539
|
*/
|
|
49505
49540
|
function isParentRelationship(node) {
|
|
49506
49541
|
return (node &&
|
|
49507
|
-
(isRelationship(node,
|
|
49508
|
-
isRelationship(node,
|
|
49542
|
+
(isRelationship(node, PARENT_RELATIONSHIP) ||
|
|
49543
|
+
isRelationship(node, POLYMORPHIC_PARENT_RELATIONSHIP)));
|
|
49509
49544
|
}
|
|
49510
49545
|
/*
|
|
49511
49546
|
checks if the InlineFragment spans
|
|
@@ -50597,7 +50632,7 @@
|
|
|
50597
50632
|
},
|
|
50598
50633
|
value: {
|
|
50599
50634
|
kind: Kind.STRING,
|
|
50600
|
-
value:
|
|
50635
|
+
value: PARENT_RELATIONSHIP,
|
|
50601
50636
|
block: false,
|
|
50602
50637
|
},
|
|
50603
50638
|
},
|
|
@@ -50611,8 +50646,8 @@
|
|
|
50611
50646
|
// example 2 'ServiceAppointment' -> ['Owner']; 'Owner' -> ['User', 'Group']
|
|
50612
50647
|
const objectNodeInfoTree = {};
|
|
50613
50648
|
// save the field path to apiName map
|
|
50614
|
-
// example 1: 'ServiceAppointment' -> ['ServiceAppointment']; '
|
|
50615
|
-
const
|
|
50649
|
+
// example 1: 'ServiceAppointment' -> ['ServiceAppointment']; 'ServiceAppointment#ccount' -> ['Account']; 'ServiceAppointment#Account#Owner' -> ['User']
|
|
50650
|
+
const pathToObjectApiNamesMap = {};
|
|
50616
50651
|
let startNodes = new Set();
|
|
50617
50652
|
let totalNodes = new Set();
|
|
50618
50653
|
let objectInfos = {};
|
|
@@ -50626,11 +50661,11 @@
|
|
|
50626
50661
|
visit(originalAST, {
|
|
50627
50662
|
Argument: {
|
|
50628
50663
|
enter(node, key, parent, path, ancestors) {
|
|
50629
|
-
const
|
|
50630
|
-
if (!
|
|
50664
|
+
const { connection: recordConnectionNode, path: ancesterPath } = findNearestConnectionWithPath(ancestors);
|
|
50665
|
+
if (!recordConnectionNode || !ancesterPath)
|
|
50631
50666
|
return;
|
|
50632
|
-
if (!objectNodeInfoTree[
|
|
50633
|
-
objectNodeInfoTree[
|
|
50667
|
+
if (!objectNodeInfoTree[ancesterPath]) {
|
|
50668
|
+
objectNodeInfoTree[ancesterPath] = [];
|
|
50634
50669
|
}
|
|
50635
50670
|
switch (node.name.value) {
|
|
50636
50671
|
case 'orderBy':
|
|
@@ -50638,12 +50673,12 @@
|
|
|
50638
50673
|
if (node.value.kind !== 'ObjectValue') {
|
|
50639
50674
|
return;
|
|
50640
50675
|
}
|
|
50641
|
-
totalNodes.add(
|
|
50676
|
+
totalNodes.add(ancesterPath);
|
|
50642
50677
|
// 'childRelationship' node is not taken as the startNode of the 'NodeInfoTree' graph. The field scanning will construct the graph which lead here.
|
|
50643
|
-
if (isRecordQuery(
|
|
50644
|
-
startNodes.add(
|
|
50678
|
+
if (isRecordQuery(recordConnectionNode)) {
|
|
50679
|
+
startNodes.add(recordConnectionNode.name.value);
|
|
50645
50680
|
}
|
|
50646
|
-
growObjectFieldTree(objectNodeInfoTree,
|
|
50681
|
+
growObjectFieldTree(objectNodeInfoTree, ancesterPath, node.value, totalNodes, startNodes);
|
|
50647
50682
|
break;
|
|
50648
50683
|
case 'scope':
|
|
50649
50684
|
if (!isScopeArgumentNodeWithType(node, 'ASSIGNEDTOME', variables)) {
|
|
@@ -50658,17 +50693,16 @@
|
|
|
50658
50693
|
name: 'ServiceResources',
|
|
50659
50694
|
});
|
|
50660
50695
|
}
|
|
50661
|
-
if (objectNodeInfoTree['ServiceResources'] === undefined) {
|
|
50662
|
-
objectNodeInfoTree['ServiceResources'] = [
|
|
50663
|
-
|
|
50664
|
-
|
|
50665
|
-
|
|
50666
|
-
|
|
50667
|
-
|
|
50668
|
-
});
|
|
50696
|
+
if (objectNodeInfoTree['ServiceAppointment#ServiceResources'] === undefined) {
|
|
50697
|
+
objectNodeInfoTree['ServiceAppointment#ServiceResources'] = [
|
|
50698
|
+
{
|
|
50699
|
+
relation: 'parent',
|
|
50700
|
+
name: 'ServiceResource',
|
|
50701
|
+
},
|
|
50702
|
+
];
|
|
50669
50703
|
}
|
|
50670
|
-
if (objectNodeInfoTree['ServiceResource'] === undefined) {
|
|
50671
|
-
objectNodeInfoTree['ServiceResource'] = [];
|
|
50704
|
+
if (objectNodeInfoTree['ServiceAppointment#ServiceResources#ServiceResource'] === undefined) {
|
|
50705
|
+
objectNodeInfoTree['ServiceAppointment#ServiceResources#ServiceResource'] = [];
|
|
50672
50706
|
}
|
|
50673
50707
|
break;
|
|
50674
50708
|
default:
|
|
@@ -50682,7 +50716,7 @@
|
|
|
50682
50716
|
return;
|
|
50683
50717
|
if (!node.selectionSet)
|
|
50684
50718
|
return;
|
|
50685
|
-
const recordQueryField =
|
|
50719
|
+
const recordQueryField = findNearestConnection(ancestors);
|
|
50686
50720
|
//only injects fields for 'recordQuery' field. ignores the 'childRelationship' field since it will be traversed as the child of the 'recordQuery'
|
|
50687
50721
|
if (isRecordQuery(recordQueryField) && recordQueryField) {
|
|
50688
50722
|
totalNodes.add(recordQueryField.name.value);
|
|
@@ -50693,21 +50727,21 @@
|
|
|
50693
50727
|
},
|
|
50694
50728
|
});
|
|
50695
50729
|
if (objectInfoService && startNodes.size > 0) {
|
|
50696
|
-
objectInfos = await resolveObjectInfos(objectNodeInfoTree,
|
|
50730
|
+
objectInfos = await resolveObjectInfos(objectNodeInfoTree, pathToObjectApiNamesMap, startNodes, objectInfoService);
|
|
50697
50731
|
}
|
|
50698
50732
|
// read pass; gather whats needed
|
|
50699
50733
|
visit(originalAST, {
|
|
50700
50734
|
Argument: {
|
|
50701
50735
|
leave(node, key, parent, path, ancestors) {
|
|
50702
|
-
const recordQueryField =
|
|
50736
|
+
const recordQueryField = findNearestConnection(ancestors);
|
|
50703
50737
|
if (!recordQueryField)
|
|
50704
50738
|
return;
|
|
50705
50739
|
const ancestorPath = findAncesterPath(ancestors);
|
|
50706
50740
|
if (!inlineFragmentSelections[ancestorPath]) {
|
|
50707
50741
|
inlineFragmentSelections[ancestorPath] = [];
|
|
50708
50742
|
}
|
|
50709
|
-
const recordQueryApiName =
|
|
50710
|
-
?
|
|
50743
|
+
const recordQueryApiName = pathToObjectApiNamesMap[ancestorPath]
|
|
50744
|
+
? pathToObjectApiNamesMap[ancestorPath][0]
|
|
50711
50745
|
: recordQueryField.name.value;
|
|
50712
50746
|
// The record node acts as the reference. The duplicated field in the record node is not injected
|
|
50713
50747
|
const recordReferenceNode = [recordQueryField]
|
|
@@ -50721,7 +50755,7 @@
|
|
|
50721
50755
|
case 'scope':
|
|
50722
50756
|
// Hanle 'MINE' field
|
|
50723
50757
|
if (isScopeArgumentNodeWithType(node, 'MINE', variables)) {
|
|
50724
|
-
if (isMineScopeAvailable(ancestorPath,
|
|
50758
|
+
if (isMineScopeAvailable(ancestorPath, pathToObjectApiNamesMap, objectInfos)) {
|
|
50725
50759
|
// 'typeConditon' is added when the 'InlineFragmentNode' is appended at the write pass
|
|
50726
50760
|
inlineFragmentSelections[ancestorPath].push(...mineFragmentSelections);
|
|
50727
50761
|
}
|
|
@@ -50747,7 +50781,7 @@
|
|
|
50747
50781
|
case 'where': {
|
|
50748
50782
|
inlineFragmentSelections[ancestorPath] = [
|
|
50749
50783
|
...inlineFragmentSelections[ancestorPath],
|
|
50750
|
-
...injectFilter(node, idState, ancestorPath, objectInfos,
|
|
50784
|
+
...injectFilter(node, idState, ancestorPath, false, objectInfos, pathToObjectApiNamesMap, draftFunctions, recordReferenceNode),
|
|
50751
50785
|
];
|
|
50752
50786
|
break;
|
|
50753
50787
|
}
|
|
@@ -50763,7 +50797,7 @@
|
|
|
50763
50797
|
if (!node.selectionSet)
|
|
50764
50798
|
return;
|
|
50765
50799
|
// it could be 'recordQuery' or 'childRelationship'
|
|
50766
|
-
const recordQueryField =
|
|
50800
|
+
const recordQueryField = findNearestConnection(ancestors);
|
|
50767
50801
|
if (!recordQueryField)
|
|
50768
50802
|
return;
|
|
50769
50803
|
const ancestorPath = findAncesterPath(ancestors);
|
|
@@ -50775,7 +50809,7 @@
|
|
|
50775
50809
|
spanningSelections.push(selection);
|
|
50776
50810
|
}
|
|
50777
50811
|
}
|
|
50778
|
-
const injectedFields = injectFields(spanningSelections, node, ancestors, objectInfos,
|
|
50812
|
+
const injectedFields = injectFields(spanningSelections, node, ancestorPath, ancestors, objectInfos, pathToObjectApiNamesMap);
|
|
50779
50813
|
const mergedInjectedFields = mergeSelectionNodes$1(inlineFragmentSelections[ancestorPath], injectedFields);
|
|
50780
50814
|
inlineFragmentSelections[ancestorPath] = mergedInjectedFields;
|
|
50781
50815
|
},
|
|
@@ -50788,7 +50822,7 @@
|
|
|
50788
50822
|
// removes 'ServicesResources' query field node if 'assignedtome' scope shows up
|
|
50789
50823
|
if (assignedtomeQueryFieldNode !== undefined &&
|
|
50790
50824
|
node.name.value === 'ServiceResources') {
|
|
50791
|
-
const serviceResourcesAncestor =
|
|
50825
|
+
const serviceResourcesAncestor = findNearestConnection(ancestors);
|
|
50792
50826
|
if (serviceResourcesAncestor === assignedtomeQueryFieldNode) {
|
|
50793
50827
|
return null;
|
|
50794
50828
|
}
|
|
@@ -50797,7 +50831,7 @@
|
|
|
50797
50831
|
return;
|
|
50798
50832
|
if (!node.selectionSet)
|
|
50799
50833
|
return;
|
|
50800
|
-
const recordQueryField =
|
|
50834
|
+
const recordQueryField = findNearestConnection(ancestors);
|
|
50801
50835
|
if (!recordQueryField)
|
|
50802
50836
|
return;
|
|
50803
50837
|
const ancestorPath = findAncesterPath(ancestors);
|
|
@@ -50806,8 +50840,8 @@
|
|
|
50806
50840
|
return;
|
|
50807
50841
|
//const recordQueryPath = findAncesterPath(ancestors);
|
|
50808
50842
|
// 'apiName' has to be at index 0 since 'node' record type could only be of 'recordQuery' or 'childRelationship'. They can not have the 'InlineFragmentNode' as its children.
|
|
50809
|
-
const recordQueryApiName =
|
|
50810
|
-
?
|
|
50843
|
+
const recordQueryApiName = pathToObjectApiNamesMap[ancestorPath]
|
|
50844
|
+
? pathToObjectApiNamesMap[ancestorPath][0]
|
|
50811
50845
|
: recordQueryField.name.value;
|
|
50812
50846
|
const nodeWithFragments = {
|
|
50813
50847
|
...node,
|
|
@@ -50844,7 +50878,7 @@
|
|
|
50844
50878
|
if (node.name.value === 'where') {
|
|
50845
50879
|
const ancestorPath = findAncesterPath(ancestors);
|
|
50846
50880
|
if (idState.paths.includes(ancestorPath)) {
|
|
50847
|
-
const apiName =
|
|
50881
|
+
const apiName = pathToObjectApiNamesMap[ancestorPath][0];
|
|
50848
50882
|
const objectInfo = objectInfos[apiName];
|
|
50849
50883
|
const swappedIdFilter = swapIdField(node.value, objectInfo, false, idState, draftFunctions);
|
|
50850
50884
|
return {
|
|
@@ -50910,8 +50944,8 @@
|
|
|
50910
50944
|
};
|
|
50911
50945
|
}
|
|
50912
50946
|
}
|
|
50913
|
-
function isMineScopeAvailable(apiNamePath,
|
|
50914
|
-
const apiName =
|
|
50947
|
+
function isMineScopeAvailable(apiNamePath, pathToObjectApiNamesMap, objectInfos) {
|
|
50948
|
+
const apiName = pathToObjectApiNamesMap[apiNamePath];
|
|
50915
50949
|
if (!apiName)
|
|
50916
50950
|
return false;
|
|
50917
50951
|
const objectInfo = objectInfos[apiName[0]];
|
|
@@ -51000,15 +51034,16 @@
|
|
|
51000
51034
|
}
|
|
51001
51035
|
// example: 'Account'
|
|
51002
51036
|
const childNode = objectFieldNode.name.value;
|
|
51037
|
+
const childNodepath = `${parentNode}#${childNode}`;
|
|
51003
51038
|
if (!tree[parentNode].some((child) => child.name === childNode)) {
|
|
51004
51039
|
tree[parentNode].push({
|
|
51005
51040
|
relation: 'parent',
|
|
51006
51041
|
name: childNode,
|
|
51007
51042
|
});
|
|
51008
|
-
totalNodes.add(
|
|
51043
|
+
totalNodes.add(childNodepath);
|
|
51009
51044
|
}
|
|
51010
51045
|
// recursively go to deeper level of filter.
|
|
51011
|
-
growObjectFieldTree(tree,
|
|
51046
|
+
growObjectFieldTree(tree, childNodepath, objectFieldNode.value, totalNodes, startNodes);
|
|
51012
51047
|
}
|
|
51013
51048
|
}
|
|
51014
51049
|
}
|
|
@@ -51043,19 +51078,20 @@
|
|
|
51043
51078
|
}
|
|
51044
51079
|
if (!tree[parentSectionPath].some((field) => field.name === fieldName)) {
|
|
51045
51080
|
tree[parentSectionPath].push({
|
|
51046
|
-
relation: relationType ===
|
|
51047
|
-
relationType ===
|
|
51081
|
+
relation: relationType === PARENT_RELATIONSHIP ||
|
|
51082
|
+
relationType === POLYMORPHIC_PARENT_RELATIONSHIP
|
|
51048
51083
|
? 'parent'
|
|
51049
51084
|
: 'child',
|
|
51050
51085
|
name: fieldName,
|
|
51051
51086
|
});
|
|
51052
|
-
totalNodes.add(fieldName);
|
|
51087
|
+
totalNodes.add(`${parentSectionPath}#${fieldName}`);
|
|
51053
51088
|
}
|
|
51054
51089
|
if (entryNode.selectionSet && entryNode.selectionSet.selections) {
|
|
51055
51090
|
const childNodes = entryNode.selectionSet.selections.filter(isFieldOrInlineFragmentNode);
|
|
51056
51091
|
// recursively build the traversal tree
|
|
51057
51092
|
for (const child of childNodes) {
|
|
51058
|
-
|
|
51093
|
+
const path = `${parentSectionPath}#${fieldName}`;
|
|
51094
|
+
growFieldTree(tree, path, child, entryNode, totalNodes, startNodes);
|
|
51059
51095
|
}
|
|
51060
51096
|
}
|
|
51061
51097
|
}
|
|
@@ -51085,23 +51121,23 @@
|
|
|
51085
51121
|
}
|
|
51086
51122
|
if (!tree[parentSectionPath].some((field) => field.name === conditionName)) {
|
|
51087
51123
|
tree[parentSectionPath].push({
|
|
51088
|
-
relation: relationType ===
|
|
51089
|
-
relationType ===
|
|
51124
|
+
relation: relationType === PARENT_RELATIONSHIP ||
|
|
51125
|
+
relationType === POLYMORPHIC_PARENT_RELATIONSHIP
|
|
51090
51126
|
? 'parent'
|
|
51091
51127
|
: 'child',
|
|
51092
51128
|
name: conditionName,
|
|
51093
51129
|
});
|
|
51094
|
-
|
|
51130
|
+
const path = `${parentSectionPath}#${conditionName}`;
|
|
51131
|
+
totalNodes.add(path);
|
|
51095
51132
|
}
|
|
51096
51133
|
}
|
|
51097
51134
|
}
|
|
51098
51135
|
// dive deep immediately for 'InlineFragment'
|
|
51099
51136
|
const childNodes = entryNode.selectionSet.selections.filter(isFieldOrInlineFragmentNode);
|
|
51137
|
+
const path = `${parentSectionPath}${entryNode.typeCondition ? '#' + entryNode.typeCondition.name.value : ''}`;
|
|
51100
51138
|
// Navigates into InLineFragment
|
|
51101
51139
|
for (const child of childNodes) {
|
|
51102
|
-
growFieldTree(tree, entryNode
|
|
51103
|
-
? entryNode.typeCondition.name.value
|
|
51104
|
-
: parentSectionPath, child, entryNode, totalNodes, startNodes);
|
|
51140
|
+
growFieldTree(tree, path, child, entryNode, totalNodes, startNodes);
|
|
51105
51141
|
}
|
|
51106
51142
|
}
|
|
51107
51143
|
}
|
|
@@ -51113,7 +51149,7 @@
|
|
|
51113
51149
|
* @param startNodes start nodes of the tree. It can be used to fetch ObjectInfo immediately
|
|
51114
51150
|
* @param path
|
|
51115
51151
|
*/
|
|
51116
|
-
async function resolveObjectInfos(objectInfotree,
|
|
51152
|
+
async function resolveObjectInfos(objectInfotree, pathToObjectApiNamesMap, startNodes, objectInfoService) {
|
|
51117
51153
|
let objectInfos;
|
|
51118
51154
|
try {
|
|
51119
51155
|
objectInfos = await objectInfoService.getObjectInfos(Array.from(startNodes));
|
|
@@ -51127,9 +51163,9 @@
|
|
|
51127
51163
|
throw new Error(`Unable to resolve ObjectInfo(s) for ${Array.from(startNodes)}`);
|
|
51128
51164
|
}
|
|
51129
51165
|
for (const startNode of startNodes) {
|
|
51130
|
-
|
|
51166
|
+
pathToObjectApiNamesMap[startNode] = [startNode];
|
|
51131
51167
|
const children = objectInfotree[startNode];
|
|
51132
|
-
const subObjectInfoMap = await fetchObjectInfos(objectInfotree,
|
|
51168
|
+
const subObjectInfoMap = await fetchObjectInfos(objectInfotree, pathToObjectApiNamesMap, objectInfos, children, startNode, objectInfoService);
|
|
51133
51169
|
objectInfos = { ...objectInfos, ...subObjectInfoMap };
|
|
51134
51170
|
}
|
|
51135
51171
|
return objectInfos;
|
|
@@ -51137,15 +51173,15 @@
|
|
|
51137
51173
|
// example 1: 'parentPath': 'ServiceAppointment', 'nodesAtSameLevel': ['Account']
|
|
51138
51174
|
// example 2: 'parentPath': 'ServiceAppointment', 'nodesAtSameLevel': ['Owner'], this example has 2 apiName for the node 'Owner'
|
|
51139
51175
|
// example 3: 'parentPath': 'ServiceAppointment_Owner', 'nodesAtSameLevel': ['User', 'Group']
|
|
51140
|
-
async function fetchObjectInfos(objectInfotree,
|
|
51141
|
-
const objectInfoApiNames =
|
|
51176
|
+
async function fetchObjectInfos(objectInfotree, pathToObjectApiNamesMap, objectInfoMap, nodesAtSameLevel, parentPath, objectInfoService) {
|
|
51177
|
+
const objectInfoApiNames = pathToObjectApiNamesMap[parentPath];
|
|
51142
51178
|
if (!objectInfoApiNames) {
|
|
51143
51179
|
// eslint-disable-next-line
|
|
51144
51180
|
throw new Error(`Object Info does not exist for ${parentPath}`);
|
|
51145
51181
|
}
|
|
51146
51182
|
const validObjectInfoNodes = [];
|
|
51147
51183
|
let updatedObjectInfoMap = {};
|
|
51148
|
-
// InlineFragment and polymorphic field support fits into this scenario
|
|
51184
|
+
// InlineFragment and polymorphic field support fits into this scenario pathToObjectApiNamesMap Entry: 'ServiceAppointment#Owner' -> ['User', 'Group']; ServiceAppointment#Owner#User' -> ['User']
|
|
51149
51185
|
if (objectInfoApiNames.length > 0 &&
|
|
51150
51186
|
nodesAtSameLevel.length > 0 &&
|
|
51151
51187
|
objectInfoApiNames.includes(nodesAtSameLevel[0].name)) {
|
|
@@ -51157,8 +51193,8 @@
|
|
|
51157
51193
|
// eslint-disable-next-line
|
|
51158
51194
|
throw new Error(`Condition ${field.name} does not exists for ${parentPath}`);
|
|
51159
51195
|
}
|
|
51160
|
-
const path = `${parentPath}
|
|
51161
|
-
|
|
51196
|
+
const path = `${parentPath}#${field.name}`;
|
|
51197
|
+
pathToObjectApiNamesMap[path] = [field.name];
|
|
51162
51198
|
}
|
|
51163
51199
|
validObjectInfoNodes.push(...nodesAtSameLevel);
|
|
51164
51200
|
updatedObjectInfoMap = { ...objectInfoMap };
|
|
@@ -51173,7 +51209,7 @@
|
|
|
51173
51209
|
let apiNames = [];
|
|
51174
51210
|
for (const nodeInfo of nodesAtSameLevel) {
|
|
51175
51211
|
const field = nodeInfo.name;
|
|
51176
|
-
const path = `${parentPath}
|
|
51212
|
+
const path = `${parentPath}#${field}`;
|
|
51177
51213
|
// Handle 'parentRelationship'
|
|
51178
51214
|
if (nodeInfo.relation === 'parent') {
|
|
51179
51215
|
const relationshipId = referenceIdFieldForRelationship(field);
|
|
@@ -51191,21 +51227,21 @@
|
|
|
51191
51227
|
}
|
|
51192
51228
|
}
|
|
51193
51229
|
// This is a polymorphic field
|
|
51194
|
-
if (fieldDefinition.referenceToInfos.length > 1 && objectInfotree[
|
|
51230
|
+
if (fieldDefinition.referenceToInfos.length > 1 && objectInfotree[path]) {
|
|
51195
51231
|
// Fields needs to expand and heterogenous entity ObjectInfo needs to be fetched
|
|
51196
|
-
const referencedNodeInfos = objectInfotree[
|
|
51232
|
+
const referencedNodeInfos = objectInfotree[path];
|
|
51197
51233
|
const requestedApiNames = referencedNodeInfos.map((referenceNodeInfo) => referenceNodeInfo.name);
|
|
51198
51234
|
// Fetches requested ObjectInfo only. Some entity's relation field could define more than 6 references. Only references show up in query need to be handled.
|
|
51199
|
-
if (requestedApiNames.length > 0 && objectInfotree[
|
|
51235
|
+
if (requestedApiNames.length > 0 && objectInfotree[path]) {
|
|
51200
51236
|
fieldDefinition.referenceToInfos
|
|
51201
51237
|
.filter((referenceToInfo) => requestedApiNames.includes(referenceToInfo.apiName))
|
|
51202
51238
|
.forEach((ref) => {
|
|
51203
|
-
if (!
|
|
51204
|
-
|
|
51239
|
+
if (!pathToObjectApiNamesMap[path]) {
|
|
51240
|
+
pathToObjectApiNamesMap[path] = [];
|
|
51205
51241
|
}
|
|
51206
51242
|
// 'ServiceAppointment_Owner' ->['User', 'Group']
|
|
51207
|
-
if (!
|
|
51208
|
-
|
|
51243
|
+
if (!pathToObjectApiNamesMap[path].includes(ref.apiName)) {
|
|
51244
|
+
pathToObjectApiNamesMap[path].push(ref.apiName);
|
|
51209
51245
|
}
|
|
51210
51246
|
if (!apiNames.includes(ref.apiName)) {
|
|
51211
51247
|
apiNames.push(ref.apiName);
|
|
@@ -51215,11 +51251,11 @@
|
|
|
51215
51251
|
}
|
|
51216
51252
|
else if (fieldDefinition.referenceToInfos.length === 1) {
|
|
51217
51253
|
const ref = fieldDefinition.referenceToInfos[0];
|
|
51218
|
-
if (!
|
|
51219
|
-
|
|
51254
|
+
if (!pathToObjectApiNamesMap[path]) {
|
|
51255
|
+
pathToObjectApiNamesMap[path] = [];
|
|
51220
51256
|
}
|
|
51221
|
-
if (!
|
|
51222
|
-
|
|
51257
|
+
if (!pathToObjectApiNamesMap[path].includes(ref.apiName)) {
|
|
51258
|
+
pathToObjectApiNamesMap[path].push(ref.apiName);
|
|
51223
51259
|
}
|
|
51224
51260
|
if (!apiNames.includes(ref.apiName)) {
|
|
51225
51261
|
apiNames.push(ref.apiName);
|
|
@@ -51230,11 +51266,11 @@
|
|
|
51230
51266
|
// handles 'childRelationship'
|
|
51231
51267
|
const childRelationship = parentObjectInfo.childRelationships.find((childRelationship) => childRelationship.relationshipName === field);
|
|
51232
51268
|
if (childRelationship) {
|
|
51233
|
-
if (!
|
|
51234
|
-
|
|
51269
|
+
if (!pathToObjectApiNamesMap[path]) {
|
|
51270
|
+
pathToObjectApiNamesMap[path] = [];
|
|
51235
51271
|
}
|
|
51236
|
-
if (!
|
|
51237
|
-
|
|
51272
|
+
if (!pathToObjectApiNamesMap[path].includes(childRelationship.childObjectApiName)) {
|
|
51273
|
+
pathToObjectApiNamesMap[path].push(childRelationship.childObjectApiName);
|
|
51238
51274
|
}
|
|
51239
51275
|
if (!apiNames.includes(childRelationship.childObjectApiName)) {
|
|
51240
51276
|
apiNames.push(childRelationship.childObjectApiName);
|
|
@@ -51256,10 +51292,10 @@
|
|
|
51256
51292
|
}
|
|
51257
51293
|
for (const nodeInfo of validObjectInfoNodes) {
|
|
51258
51294
|
const field = nodeInfo.name;
|
|
51259
|
-
const
|
|
51260
|
-
const
|
|
51295
|
+
const path = `${parentPath}#${field}`;
|
|
51296
|
+
const subLevelFields = objectInfotree[path];
|
|
51261
51297
|
if (subLevelFields && subLevelFields.length > 0) {
|
|
51262
|
-
const subObjectInfos = await fetchObjectInfos(objectInfotree,
|
|
51298
|
+
const subObjectInfos = await fetchObjectInfos(objectInfotree, pathToObjectApiNamesMap, updatedObjectInfoMap, subLevelFields, path, objectInfoService);
|
|
51263
51299
|
updatedObjectInfoMap = { ...updatedObjectInfoMap, ...subObjectInfos };
|
|
51264
51300
|
}
|
|
51265
51301
|
}
|
|
@@ -51274,27 +51310,29 @@
|
|
|
51274
51310
|
* 'path' and 'queryNode' is 1 level above the 'filterNode'
|
|
51275
51311
|
* @param filterNode filter node which needs to be injected. For example, 'State' ObjectFieldNode within filter 'where: { State: { eq: "Nova Scotia" }}'
|
|
51276
51312
|
* @param idState ID state will be updated to determine if the ID fields in AST need to be swapped. The swapping happens later.
|
|
51277
|
-
* @param
|
|
51313
|
+
* @param parentPath path to the current filterNode's parent. For example, path could be 'ServiceApointment' when filterNode is 'State'. If the path does not exist in 'pathToObjectApiNamesMap', parent node is not an field of relationship or recordQuery
|
|
51314
|
+
* @param isParentPolymorphic true if parent points to a polymorphic field.
|
|
51278
51315
|
* @param queryNode referece FieldNode which provides the information if 'filterNode' exist in it nor not.
|
|
51279
51316
|
* @param objectInfos ObjectInfo map used in injection. If ObjectInfo misses or field does not exist in ObjectInfo, the error will be thrown
|
|
51280
|
-
* @param
|
|
51317
|
+
* @param pathToObjectApiNamesMap map used to locate the ObjectInfo. The key is path to a field, value is the ObjectInfo's apiName array. In the case of polymorphic fields, the apiName array have 2 or more elements. For example, 'ServiceAppointment' -> ['ServiceAppointment']; 'ServiceAppointment_Account' -> ['Account'], 'ServiceAppointment_Owner' -> ['User', 'Group'].
|
|
51281
51318
|
* @param draftFunctions functions for working with record ids that may be draft-created ids
|
|
51282
51319
|
* @returns an array of nodes with injected fields
|
|
51283
51320
|
*/
|
|
51284
|
-
function injectFilter(filterNode, idState,
|
|
51321
|
+
function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, objectInfos, pathToObjectApiNamesMap, draftFunctions, queryNode) {
|
|
51285
51322
|
const injectedSelections = [];
|
|
51323
|
+
let isPolymorphicField = false;
|
|
51286
51324
|
switch (filterNode.kind) {
|
|
51287
51325
|
case Kind.ARGUMENT:
|
|
51288
51326
|
if (filterNode.value.kind !== 'ObjectValue')
|
|
51289
51327
|
return [];
|
|
51290
51328
|
filterNode.value.fields.forEach((objectFieldNode) => {
|
|
51291
|
-
let subResults = injectFilter(objectFieldNode, idState,
|
|
51329
|
+
let subResults = injectFilter(objectFieldNode, idState, parentPath, isParentPolymorphic, objectInfos, pathToObjectApiNamesMap, draftFunctions, queryNode);
|
|
51292
51330
|
for (const subResult of subResults) {
|
|
51293
51331
|
mergeOrAddToGroup(injectedSelections, subResult);
|
|
51294
51332
|
}
|
|
51295
51333
|
// multiple Ids might need to be swapped. remember their paths for faster write.
|
|
51296
51334
|
if (idState.swapNeeded) {
|
|
51297
|
-
idState.paths.push(
|
|
51335
|
+
idState.paths.push(parentPath);
|
|
51298
51336
|
}
|
|
51299
51337
|
});
|
|
51300
51338
|
return injectedSelections;
|
|
@@ -51303,7 +51341,7 @@
|
|
|
51303
51341
|
case Kind.LIST: {
|
|
51304
51342
|
filterNode.value.values.filter(isObjectValueNode).forEach((objectValueNode) => {
|
|
51305
51343
|
objectValueNode.fields.forEach((objectFieldNode) => {
|
|
51306
|
-
const subResults = injectFilter(objectFieldNode, idState,
|
|
51344
|
+
const subResults = injectFilter(objectFieldNode, idState, parentPath, isParentPolymorphic, objectInfos, pathToObjectApiNamesMap, draftFunctions, queryNode);
|
|
51307
51345
|
for (const subResult of subResults) {
|
|
51308
51346
|
mergeOrAddToGroup(injectedSelections, subResult);
|
|
51309
51347
|
}
|
|
@@ -51314,7 +51352,7 @@
|
|
|
51314
51352
|
case Kind.OBJECT: {
|
|
51315
51353
|
if (filterNode.name.value === 'not') {
|
|
51316
51354
|
filterNode.value.fields.forEach((objectFieldNode) => {
|
|
51317
|
-
const subResults = injectFilter(objectFieldNode, idState,
|
|
51355
|
+
const subResults = injectFilter(objectFieldNode, idState, parentPath, isParentPolymorphic, objectInfos, pathToObjectApiNamesMap, draftFunctions, queryNode);
|
|
51318
51356
|
for (const subResult of subResults) {
|
|
51319
51357
|
mergeOrAddToGroup(injectedSelections, subResult);
|
|
51320
51358
|
}
|
|
@@ -51324,15 +51362,15 @@
|
|
|
51324
51362
|
let apiNames = [];
|
|
51325
51363
|
let isScalarField = false;
|
|
51326
51364
|
//It is possible that this is a polymorphic field
|
|
51327
|
-
apiNames =
|
|
51328
|
-
// example: path: '
|
|
51365
|
+
apiNames = pathToObjectApiNamesMap[parentPath];
|
|
51366
|
+
// example: path: 'ServiceAppointment#LastModifiedDate'; filterNode: '{eq: {literal: LAST_WEEK}}'. queryNode: 'LastModifedDate { value}' FilterNode's parent has been verifed as a valid node
|
|
51329
51367
|
if (apiNames === undefined) {
|
|
51330
51368
|
isScalarField = true;
|
|
51331
51369
|
}
|
|
51332
51370
|
else {
|
|
51333
51371
|
if (apiNames.some((apiName) => objectInfos[apiName] === undefined)) {
|
|
51334
51372
|
// eslint-disable-next-line
|
|
51335
|
-
throw new Error(`ObjectInfo is missing for ${
|
|
51373
|
+
throw new Error(`ObjectInfo is missing for ${parentPath}`);
|
|
51336
51374
|
}
|
|
51337
51375
|
}
|
|
51338
51376
|
if (isScalarField) {
|
|
@@ -51354,29 +51392,19 @@
|
|
|
51354
51392
|
}
|
|
51355
51393
|
});
|
|
51356
51394
|
let isSpanning = false;
|
|
51395
|
+
// if true, current node is a polymorphic concrete type node. For example, field node `User` under `Owner`
|
|
51357
51396
|
let isInlineFragment = false;
|
|
51358
|
-
let isPolymorphicField = false;
|
|
51359
51397
|
let isTypeNameExisting = false;
|
|
51360
51398
|
let curPath;
|
|
51361
51399
|
let fieldName = filterNode.name.value;
|
|
51362
|
-
curPath = `${
|
|
51363
|
-
if (
|
|
51400
|
+
curPath = `${parentPath}#${fieldName}`;
|
|
51401
|
+
if (pathToObjectApiNamesMap[curPath] &&
|
|
51402
|
+
pathToObjectApiNamesMap[curPath].length > 0) {
|
|
51364
51403
|
isSpanning = true;
|
|
51365
|
-
|
|
51366
|
-
|
|
51367
|
-
|
|
51368
|
-
|
|
51369
|
-
isInlineFragment = true;
|
|
51370
|
-
}
|
|
51371
|
-
}
|
|
51372
|
-
// Checks if the current filter node is a polymorphic field. 'ServiceAppointment_Owner' --> ['User']; 'ServiceAppointment_Owner_User' --> ['User']
|
|
51373
|
-
const childApiName = objectInfoApiMap[curPath][0];
|
|
51374
|
-
const trialApiNames = objectInfoApiMap[`${curPath}_${childApiName}`];
|
|
51375
|
-
if (trialApiNames !== undefined &&
|
|
51376
|
-
trialApiNames.length === 1 &&
|
|
51377
|
-
trialApiNames[0] === childApiName) {
|
|
51378
|
-
isPolymorphicField = true;
|
|
51379
|
-
}
|
|
51404
|
+
isInlineFragment =
|
|
51405
|
+
isParentPolymorphic &&
|
|
51406
|
+
pathToObjectApiNamesMap[curPath].length === 1;
|
|
51407
|
+
isPolymorphicField = isPolymorphicFieldPath(curPath, pathToObjectApiNamesMap, objectInfos);
|
|
51380
51408
|
}
|
|
51381
51409
|
// When filter node is at InLineFragment Level(a concrete entity of polymorphic field), query node is one level up. For example, ObjectFieldNode is ...{User:{...}}, queryNode is Owner:[User]
|
|
51382
51410
|
if (isInlineFragment) {
|
|
@@ -51420,9 +51448,9 @@
|
|
|
51420
51448
|
throw new Error(`Field ${fieldName} does not exist in ${apiNames[0]}`);
|
|
51421
51449
|
}
|
|
51422
51450
|
}
|
|
51423
|
-
const objectInfoName =
|
|
51424
|
-
?
|
|
51425
|
-
:
|
|
51451
|
+
const objectInfoName = pathToObjectApiNamesMap[curPath] !== undefined
|
|
51452
|
+
? pathToObjectApiNamesMap[curPath][0]
|
|
51453
|
+
: pathToObjectApiNamesMap[parentPath][0];
|
|
51426
51454
|
const isIdField = isFieldAnIdField(filterNode.name.value, objectInfos[objectInfoName]);
|
|
51427
51455
|
if (!isIdField) {
|
|
51428
51456
|
let subSelectionNodes = [];
|
|
@@ -51434,7 +51462,7 @@
|
|
|
51434
51462
|
updateIDInfo(subFieldNode, idState, draftFunctions);
|
|
51435
51463
|
}
|
|
51436
51464
|
// try injecting the fields within predicate no matter it has relation or not.
|
|
51437
|
-
let subResults = injectFilter(subFieldNode, idState, curPath, objectInfos,
|
|
51465
|
+
let subResults = injectFilter(subFieldNode, idState, curPath, isPolymorphicField, objectInfos, pathToObjectApiNamesMap, draftFunctions, existingFields ? existingFields[0] : undefined);
|
|
51438
51466
|
subSelectionNodes = subSelectionNodes.concat(subResults);
|
|
51439
51467
|
});
|
|
51440
51468
|
if (!subFieldsHasId) {
|
|
@@ -51595,6 +51623,44 @@
|
|
|
51595
51623
|
}
|
|
51596
51624
|
group.push(element);
|
|
51597
51625
|
}
|
|
51626
|
+
// checks if the path points to a polymorphic field. For example, for the below `pathToObjectApiNamesMap`
|
|
51627
|
+
// {
|
|
51628
|
+
// 'ServiceAppointment' -> ['ServiceAppointment']
|
|
51629
|
+
// 'ServiceAppointment#Owner' --> ['User'],
|
|
51630
|
+
// 'ServiceAppointment#Owner#User' --> ['User']
|
|
51631
|
+
// }
|
|
51632
|
+
// path `ServiceAppointment#Owner` points to a polymorphic field, but path `ServiceAppointment#Owner#User` does not.
|
|
51633
|
+
function isPolymorphicFieldPath(path, pathToObjectApiNamesMap, objectInfos) {
|
|
51634
|
+
const lastSegmentIndex = path.lastIndexOf('#');
|
|
51635
|
+
if (lastSegmentIndex < 0) {
|
|
51636
|
+
return false;
|
|
51637
|
+
}
|
|
51638
|
+
const lastSegment = path.slice(lastSegmentIndex + 1);
|
|
51639
|
+
const parentApiPath = path.slice(0, lastSegmentIndex);
|
|
51640
|
+
if (pathToObjectApiNamesMap[parentApiPath] === undefined) {
|
|
51641
|
+
return false;
|
|
51642
|
+
}
|
|
51643
|
+
const parentObjectApiNames = pathToObjectApiNamesMap[parentApiPath];
|
|
51644
|
+
// If the last segment is a Polymorphic field, its immediate parent is a concrete object entity, which has 1 objectApiName mapped to the parent path in `pathToObjectApiNamesMap`.
|
|
51645
|
+
// For example, we like to check if `ServiceAppointment#Owner` path is polymorphic. The last segment is `Owner` and its parent `ServiceAppointment` has one element (which is also `ServiceAppointment`) array as its value.
|
|
51646
|
+
// Below are the entries in `pathToObjectApiNamesMap`
|
|
51647
|
+
// {
|
|
51648
|
+
// `ServiceAppointmen`t: [`ServiceAppointment`],
|
|
51649
|
+
// `ServiceAppointment#Owner`: [`User`, `Group`],
|
|
51650
|
+
// `ServiceAppointment#Owner#User`: [`User`],
|
|
51651
|
+
// `ServiceAppointment#Owner#Group`: [`Group`],
|
|
51652
|
+
// }
|
|
51653
|
+
if (parentObjectApiNames.length !== 1) {
|
|
51654
|
+
return false;
|
|
51655
|
+
}
|
|
51656
|
+
const parentObjectInfo = objectInfos[parentObjectApiNames[0]];
|
|
51657
|
+
const relationshipField = referenceIdFieldForRelationship(lastSegment);
|
|
51658
|
+
let fieldDefinition = parentObjectInfo.fields[relationshipField];
|
|
51659
|
+
if (fieldDefinition === undefined) {
|
|
51660
|
+
return false;
|
|
51661
|
+
}
|
|
51662
|
+
return fieldDefinition.polymorphicForeignKey;
|
|
51663
|
+
}
|
|
51598
51664
|
function isFieldAnIdField(fieldName, objectInfo) {
|
|
51599
51665
|
if (fieldName === 'Id')
|
|
51600
51666
|
return true;
|
|
@@ -51647,10 +51713,10 @@
|
|
|
51647
51713
|
* @param parentNode parent node of param 1
|
|
51648
51714
|
* @param ancestors ancester of param 1
|
|
51649
51715
|
* @param objectInfos ObjectInfo map used in injection. If ObjectInfo misses or field does not exist in ObjectInfo, the error will be thrown
|
|
51650
|
-
* @param
|
|
51716
|
+
* @param pathToObjectApiNamesMap map used to locate the ObjectInfo. The key is path to a field, value is the ObjectInfo's apiName array. In the case of polymorphic fields, the apiName array have 2 or more elements. For example, 'ServiceAppointment' -> ['ServiceAppointment']; 'ServiceAppointment#Account' -> ['Account'], 'ServiceAppointment#Owner' -> ['User', 'Group'].
|
|
51651
51717
|
* @return injected SelectionNodes used to construct the InlineFragment.
|
|
51652
51718
|
*/
|
|
51653
|
-
function injectFields(selections, parentNode, ancestors, objectInfos,
|
|
51719
|
+
function injectFields(selections, parentNode, parentPath, ancestors, objectInfos, pathToObjectApiNamesMap) {
|
|
51654
51720
|
/**
|
|
51655
51721
|
* 1 parentship can return 2 FieldNode which need to be flattened
|
|
51656
51722
|
* Concact: { ** Contact { ** ContactId {
|
|
@@ -51668,6 +51734,10 @@
|
|
|
51668
51734
|
if (!selection.selectionSet) {
|
|
51669
51735
|
return selection;
|
|
51670
51736
|
}
|
|
51737
|
+
const segment = isFieldNode(selection)
|
|
51738
|
+
? selection.name.value
|
|
51739
|
+
: selection.typeCondition.name.value;
|
|
51740
|
+
const curPath = `${parentPath}#${segment}`;
|
|
51671
51741
|
const spanningSubSelections = [];
|
|
51672
51742
|
for (const subSelection of selection.selectionSet.selections) {
|
|
51673
51743
|
if (isFieldSpanning(subSelection, selection)) {
|
|
@@ -51675,7 +51745,7 @@
|
|
|
51675
51745
|
}
|
|
51676
51746
|
}
|
|
51677
51747
|
// Handles multiple level field injection like 'ServiceAppointment' --> 'Account' --> 'Owner'
|
|
51678
|
-
const subInjectedSelections = injectFields(spanningSubSelections, selection, ancestors, objectInfos,
|
|
51748
|
+
const subInjectedSelections = injectFields(spanningSubSelections, selection, curPath, ancestors, objectInfos, pathToObjectApiNamesMap);
|
|
51679
51749
|
if (!selection.selectionSet) {
|
|
51680
51750
|
return selection;
|
|
51681
51751
|
}
|
|
@@ -51718,7 +51788,7 @@
|
|
|
51718
51788
|
}
|
|
51719
51789
|
}
|
|
51720
51790
|
// For polymorphic fields, the Id field is excluded.
|
|
51721
|
-
const excludeId =
|
|
51791
|
+
const excludeId = isPolymorphicFieldPath(curPath, pathToObjectApiNamesMap, objectInfos);
|
|
51722
51792
|
const idSelection = [];
|
|
51723
51793
|
if (!excludeId && !hasIdAlready) {
|
|
51724
51794
|
idSelection.push({
|
|
@@ -51729,8 +51799,8 @@
|
|
|
51729
51799
|
},
|
|
51730
51800
|
});
|
|
51731
51801
|
}
|
|
51732
|
-
// Inject '__typename' for
|
|
51733
|
-
// please reference 'removeSyntheticFields'.
|
|
51802
|
+
// Inject '__typename' for InlineFragment. '__typename' field acts as a reference to concrete type of a polymorphic field or a standard field in the returned GQL response, which equals to
|
|
51803
|
+
// `typedCondition` of the InlineFragment in the query AST. It is used to match JSON response with AST node. For more detail, please reference 'removeSyntheticFields'.
|
|
51734
51804
|
if (isInlineFragmentNode(selection) &&
|
|
51735
51805
|
!selection.selectionSet.selections.find((selection) => isFieldNode(selection) && selection.name.value === '__typename')) {
|
|
51736
51806
|
idSelection.push({
|
|
@@ -51764,7 +51834,7 @@
|
|
|
51764
51834
|
if (isFieldNode(parentNode) && parentNode.selectionSet && parentNode.name.value === 'node') {
|
|
51765
51835
|
if (parentNode.selectionSet.selections
|
|
51766
51836
|
.filter(isFieldOrInlineFragmentNode)
|
|
51767
|
-
.some((selectionNode) => isRelationship(selectionNode,
|
|
51837
|
+
.some((selectionNode) => isRelationship(selectionNode, CHILD_RELATIONSHIP))) {
|
|
51768
51838
|
if (!parentNode.selectionSet.selections
|
|
51769
51839
|
.filter(isFieldNode)
|
|
51770
51840
|
.some((sibling) => sibling.name.value === 'Id')) {
|
|
@@ -51783,15 +51853,15 @@
|
|
|
51783
51853
|
if (parentInfo.parentIndex >= 0) {
|
|
51784
51854
|
// example node { TimeSheetEntries { edges { node { Id }}}}
|
|
51785
51855
|
const parent = parentInfo.node;
|
|
51786
|
-
if (isRelationship(parent,
|
|
51856
|
+
if (isRelationship(parent, CHILD_RELATIONSHIP)) {
|
|
51787
51857
|
const unVisitedAncestors = ancestors.slice(0, parentInfo.parentIndex);
|
|
51788
51858
|
// path : "TimeSheet"
|
|
51789
51859
|
const grandParentPath = findAncesterPath(unVisitedAncestors);
|
|
51790
|
-
if (
|
|
51791
|
-
|
|
51860
|
+
if (pathToObjectApiNamesMap &&
|
|
51861
|
+
pathToObjectApiNamesMap[grandParentPath] &&
|
|
51792
51862
|
objectInfos &&
|
|
51793
|
-
objectInfos[
|
|
51794
|
-
const grandParentObjectInfo = objectInfos[
|
|
51863
|
+
objectInfos[pathToObjectApiNamesMap[grandParentPath][0]]) {
|
|
51864
|
+
const grandParentObjectInfo = objectInfos[pathToObjectApiNamesMap[grandParentPath][0]];
|
|
51795
51865
|
// exmaple "TimeSheetEntries"
|
|
51796
51866
|
const parentFieldName = parent.name.value;
|
|
51797
51867
|
const targetRelationship = grandParentObjectInfo.childRelationships.find((childRelationship) => {
|
|
@@ -51912,7 +51982,7 @@
|
|
|
51912
51982
|
},
|
|
51913
51983
|
value: {
|
|
51914
51984
|
kind: 'StringValue',
|
|
51915
|
-
value:
|
|
51985
|
+
value: CHILD_RELATIONSHIP,
|
|
51916
51986
|
block: false,
|
|
51917
51987
|
},
|
|
51918
51988
|
},
|
|
@@ -52004,7 +52074,7 @@
|
|
|
52004
52074
|
},
|
|
52005
52075
|
value: {
|
|
52006
52076
|
kind: 'StringValue',
|
|
52007
|
-
value:
|
|
52077
|
+
value: PARENT_RELATIONSHIP,
|
|
52008
52078
|
block: false,
|
|
52009
52079
|
},
|
|
52010
52080
|
},
|
|
@@ -52141,7 +52211,9 @@
|
|
|
52141
52211
|
jsonOutput[fieldName] = null;
|
|
52142
52212
|
return;
|
|
52143
52213
|
}
|
|
52144
|
-
jsonOutput[fieldName]
|
|
52214
|
+
if (jsonOutput[fieldName] === undefined) {
|
|
52215
|
+
jsonOutput[fieldName] = {};
|
|
52216
|
+
}
|
|
52145
52217
|
createUserJsonOutput(selection, jsonInput[fieldName], jsonOutput[fieldName]);
|
|
52146
52218
|
}
|
|
52147
52219
|
else {
|
|
@@ -57016,6 +57088,9 @@
|
|
|
57016
57088
|
this.ldsRecordRefresher = config.ldsRecordRefresher;
|
|
57017
57089
|
this.networkWorkerPool = new AsyncWorkerPool(this.concurrency);
|
|
57018
57090
|
this.useBatchGQL = ldsPrimingGraphqlBatch.isOpen({ fallback: false });
|
|
57091
|
+
if (this.useBatchGQL) {
|
|
57092
|
+
this.batchSize = this.batchSize / DEFAULT_GQL_QUERY_BATCH_SIZE;
|
|
57093
|
+
}
|
|
57019
57094
|
this.conflictPool = new ConflictPool(config.store, this.objectInfoLoader);
|
|
57020
57095
|
}
|
|
57021
57096
|
// function that enqueues priming work
|
|
@@ -57872,7 +57947,7 @@
|
|
|
57872
57947
|
id: '@salesforce/lds-network-adapter',
|
|
57873
57948
|
instrument: instrument$1,
|
|
57874
57949
|
});
|
|
57875
|
-
// version: 1.229.0-
|
|
57950
|
+
// version: 1.229.0-dev4-07d38781a
|
|
57876
57951
|
|
|
57877
57952
|
const { create: create$2, keys: keys$2 } = Object;
|
|
57878
57953
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -72635,6 +72710,7 @@
|
|
|
72635
72710
|
}
|
|
72636
72711
|
if (fieldData === null) {
|
|
72637
72712
|
reader.assignScalar(requestedFieldName, sink, fieldData);
|
|
72713
|
+
reader.exitPath();
|
|
72638
72714
|
return sink;
|
|
72639
72715
|
}
|
|
72640
72716
|
const fieldType = getFieldType(sel);
|
|
@@ -76318,7 +76394,7 @@
|
|
|
76318
76394
|
configuration: { ...configurationForGraphQLAdapters },
|
|
76319
76395
|
instrument,
|
|
76320
76396
|
});
|
|
76321
|
-
// version: 1.229.0-
|
|
76397
|
+
// version: 1.229.0-dev4-4a7593877
|
|
76322
76398
|
|
|
76323
76399
|
// On core the unstable adapters are re-exported with different names,
|
|
76324
76400
|
|
|
@@ -78565,7 +78641,7 @@
|
|
|
78565
78641
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
78566
78642
|
graphQLImperative = ldsAdapter;
|
|
78567
78643
|
});
|
|
78568
|
-
// version: 1.229.0-
|
|
78644
|
+
// version: 1.229.0-dev4-4a7593877
|
|
78569
78645
|
|
|
78570
78646
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
78571
78647
|
__proto__: null,
|
|
@@ -79296,4 +79372,4 @@
|
|
|
79296
79372
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
79297
79373
|
|
|
79298
79374
|
}));
|
|
79299
|
-
// version: 1.229.0-
|
|
79375
|
+
// version: 1.229.0-dev4-07d38781a
|