@salesforce/lds-runtime-mobile 1.278.0 → 1.279.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/main.js +94 -136
  2. package/package.json +16 -16
  3. package/sfdc/main.js +94 -136
package/dist/main.js CHANGED
@@ -4,13 +4,17 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
 
7
- /* *******************************************************************************************
7
+ /*
8
8
  * ATTENTION!
9
9
  * THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
10
10
  * If you would like to contribute to LDS, please follow the steps outlined in the git repo.
11
11
  * Any changes made to this file in p4 will be automatically overwritten.
12
12
  * *******************************************************************************************
13
13
  */
14
+ /*
15
+ * Where possible, we changed noninclusive terms to align with our company value of Equality.
16
+ * We maintained certain terms to avoid any effect on customer implementations.
17
+ */
14
18
  import { withRegistration, register } from '@salesforce/lds-default-luvio';
15
19
  import { setupInstrumentation, instrumentAdapter as instrumentAdapter$1, instrumentLuvio, setLdsAdaptersUiapiInstrumentation, setLdsNetworkAdapterInstrumentation } from '@salesforce/lds-instrumentation';
16
20
  import { HttpStatusCode, StoreKeySet, serializeStructuredKey, StringKeyInMemoryStore, Reader, deepFreeze, emitAdapterEvent, createCustomAdapterEventEmitter, StoreKeyMap, isFileReference, Environment, Luvio, InMemoryStore } from '@luvio/engine';
@@ -7494,9 +7498,25 @@ function dateTimePredicate(input, operator, field, alias) {
7494
7498
  isCaseSensitive: false,
7495
7499
  };
7496
7500
  if (value !== undefined) {
7497
- const dateFn = field.dataType === 'Date' ? 'date' : 'datetime';
7498
- predicate.value = `${dateFn}(?)`;
7499
- predicate.bindings = [value];
7501
+ if (value === null) {
7502
+ switch (predicate.operator) {
7503
+ case '=':
7504
+ predicate.operator = 'IS';
7505
+ break;
7506
+ case '!=':
7507
+ predicate.operator = 'IS NOT';
7508
+ break;
7509
+ default:
7510
+ // eslint-disable-next-line @salesforce/lds/no-error-in-production
7511
+ throw new Error(`Unsupported operator ${predicate.operator} with null value operand`);
7512
+ }
7513
+ predicate.value = 'NULL';
7514
+ }
7515
+ else {
7516
+ const dateFn = field.dataType === 'Date' ? 'date' : 'datetime';
7517
+ predicate.value = `${dateFn}(?)`;
7518
+ predicate.bindings = [value];
7519
+ }
7500
7520
  return predicate;
7501
7521
  }
7502
7522
  else if (literal !== undefined) {
@@ -10141,6 +10161,18 @@ const parentRelationshipDirective = {
10141
10161
  },
10142
10162
  ],
10143
10163
  };
10164
+ const FieldValueNodeSelectionSet = {
10165
+ kind: Kind.SELECTION_SET,
10166
+ selections: [
10167
+ {
10168
+ kind: Kind.FIELD,
10169
+ name: {
10170
+ kind: Kind.NAME,
10171
+ value: 'value',
10172
+ },
10173
+ },
10174
+ ],
10175
+ };
10144
10176
  async function injectSyntheticFields(originalAST, objectInfoService, draftFunctions, variables) {
10145
10177
  const inlineFragmentSelections = {};
10146
10178
  // read pass; generate ObjectInfo
@@ -10294,20 +10326,19 @@ async function injectSyntheticFields(originalAST, objectInfoService, draftFuncti
10294
10326
  },
10295
10327
  },
10296
10328
  Field: {
10297
- leave(node, key, parent, path, ancestors) {
10298
- if (node.name.value !== `node`)
10299
- return;
10300
- if (!node.selectionSet)
10329
+ leave(node, _key, _parent, _path, ancestors) {
10330
+ if (node.name.value !== 'node')
10301
10331
  return;
10302
10332
  // it could be 'recordQuery' or 'childRelationship'
10303
- const recordQueryField = findNearestConnection(ancestors);
10304
- if (!recordQueryField)
10333
+ const recordConnection = findNearestConnection(ancestors);
10334
+ if (recordConnection === undefined)
10305
10335
  return;
10306
10336
  const ancestorPath = findAncesterPath(ancestors);
10337
+ if (node.selectionSet === undefined)
10338
+ return;
10307
10339
  // spanning fields of the 'parentRelationship'. 'childRelationship' is handled by 'node' parent.
10308
10340
  const spanningSelections = [];
10309
10341
  for (const selection of node.selectionSet.selections) {
10310
- //
10311
10342
  if (isFieldSpanning(selection) || isInlineFragmentFieldSpanning(selection)) {
10312
10343
  spanningSelections.push(selection);
10313
10344
  }
@@ -10924,25 +10955,9 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
10924
10955
  }
10925
10956
  // spanning field needs to have the directive with 'parentRelationship'
10926
10957
  const directives = isSpanning && !isInlineFragment ? [parentRelationshipDirective] : [];
10927
- let idField = isSpanning && !isPolymorphicField
10928
- ? [
10929
- {
10930
- kind: Kind.FIELD,
10931
- name: {
10932
- kind: Kind.NAME,
10933
- value: 'Id',
10934
- },
10935
- },
10936
- ]
10937
- : [];
10958
+ let idField = isSpanning && !isPolymorphicField ? [createFieldNode('Id')] : [];
10938
10959
  // This variable change to InlineFragment if 'isInlineFragment' is true
10939
- let sel = {
10940
- kind: Kind.FIELD,
10941
- name: {
10942
- kind: Kind.NAME,
10943
- value: fieldName,
10944
- },
10945
- };
10960
+ let sel = createFieldNode(fieldName);
10946
10961
  // Check if fields is valid
10947
10962
  if (apiNames.length === 1 && !isInlineFragment) {
10948
10963
  const objectInfo = objectInfos[apiNames[0]];
@@ -10988,13 +11003,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
10988
11003
  idField = [];
10989
11004
  }
10990
11005
  if (isInlineFragment && !isTypeNameExisting) {
10991
- idField.push({
10992
- kind: Kind.FIELD,
10993
- name: {
10994
- kind: Kind.NAME,
10995
- value: '__typename',
10996
- },
10997
- });
11006
+ idField.push(createFieldNode('__typename'));
10998
11007
  }
10999
11008
  //Inject Conditions: 1. Same field does not exist 2. Same fields has different children. 3. Filter spanning field does not have Id. 4. InLineFragment does not have the '__typename' field
11000
11009
  if (!existingFields ||
@@ -11040,18 +11049,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
11040
11049
  if (!isSpanning) {
11041
11050
  sel = {
11042
11051
  ...sel,
11043
- selectionSet: {
11044
- kind: Kind.SELECTION_SET,
11045
- selections: [
11046
- {
11047
- kind: Kind.FIELD,
11048
- name: {
11049
- kind: Kind.NAME,
11050
- value: 'value',
11051
- },
11052
- },
11053
- ],
11054
- },
11052
+ selectionSet: FieldValueNodeSelectionSet,
11055
11053
  };
11056
11054
  }
11057
11055
  }
@@ -11072,25 +11070,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
11072
11070
  .filter(isFieldNode)
11073
11071
  .filter((subNode) => subNode.name.value === relationField);
11074
11072
  if (!existingRelationFields || existingRelationFields.length === 0) {
11075
- injectedSelections.push({
11076
- kind: Kind.FIELD,
11077
- name: {
11078
- kind: Kind.NAME,
11079
- value: relationField,
11080
- },
11081
- selectionSet: {
11082
- kind: Kind.SELECTION_SET,
11083
- selections: [
11084
- {
11085
- kind: Kind.FIELD,
11086
- name: {
11087
- kind: Kind.NAME,
11088
- value: 'value',
11089
- },
11090
- },
11091
- ],
11092
- },
11093
- });
11073
+ injectedSelections.push(createFieldNode(relationField, FieldValueNodeSelectionSet));
11094
11074
  }
11095
11075
  }
11096
11076
  }
@@ -11181,15 +11161,7 @@ function produceValueFieldLeaves(queryNode) {
11181
11161
  .filter(isFieldNode)
11182
11162
  .filter((subNode) => subNode.name.value === 'value');
11183
11163
  return !existingValueFields || existingValueFields.length === 0
11184
- ? [
11185
- {
11186
- kind: Kind.FIELD,
11187
- name: {
11188
- kind: Kind.NAME,
11189
- value: 'value',
11190
- },
11191
- },
11192
- ]
11164
+ ? [createFieldNode('value')]
11193
11165
  : [];
11194
11166
  }
11195
11167
  function updateIDInfo(fieldNode, idState, draftFunctions) {
@@ -11271,25 +11243,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11271
11243
  .filter((subNode) => subNode.name.value === relationshipId);
11272
11244
  if (existingRelationFields.length === 0) {
11273
11245
  injectedRelationshipField = [
11274
- {
11275
- kind: Kind.FIELD,
11276
- name: {
11277
- kind: Kind.NAME,
11278
- value: relationshipId,
11279
- },
11280
- selectionSet: {
11281
- kind: Kind.SELECTION_SET,
11282
- selections: [
11283
- {
11284
- kind: Kind.FIELD,
11285
- name: {
11286
- kind: Kind.NAME,
11287
- value: 'value',
11288
- },
11289
- },
11290
- ],
11291
- },
11292
- },
11246
+ createFieldNode(relationshipId, FieldValueNodeSelectionSet),
11293
11247
  ];
11294
11248
  }
11295
11249
  }
@@ -11297,25 +11251,13 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11297
11251
  const excludeId = isPolymorphicFieldPath(curPath, pathToObjectApiNamesMap, objectInfos);
11298
11252
  const idSelection = [];
11299
11253
  if (!excludeId && !hasIdAlready) {
11300
- idSelection.push({
11301
- kind: Kind.FIELD,
11302
- name: {
11303
- kind: Kind.NAME,
11304
- value: 'Id',
11305
- },
11306
- });
11254
+ idSelection.push(createFieldNode('Id'));
11307
11255
  }
11308
11256
  // 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
11309
11257
  // `typedCondition` of the InlineFragment in the query AST. It is used to match JSON response with AST node. For more detail, please reference 'removeSyntheticFields'.
11310
11258
  if (isInlineFragmentNode(selection) &&
11311
11259
  !selection.selectionSet.selections.find((selection) => isFieldNode(selection) && selection.name.value === '__typename')) {
11312
- idSelection.push({
11313
- kind: Kind.FIELD,
11314
- name: {
11315
- kind: Kind.NAME,
11316
- value: '__typename',
11317
- },
11318
- });
11260
+ idSelection.push(createFieldNode('__typename'));
11319
11261
  }
11320
11262
  // 'ServiceAppointment' --> 'Contact' --> 'Id', Inject 'Contact' with Id. 'Id' field is at the sub level.
11321
11263
  const injectedSelectionIdField = idSelection.length > 0 || subInjectedSelections.length > 0
@@ -11335,6 +11277,8 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11335
11277
  const idForChildRelationship = [];
11336
11278
  // inject related field for the parent of the 'childRelationship'.
11337
11279
  const relatedIdForChildRelationship = [];
11280
+ // injected fields for DisplayValue
11281
+ let displayValueNameFields = [];
11338
11282
  // injects 'childRelatiship' at the 'node' level, it does not matter if the 'selections' is empty or not.
11339
11283
  // the operation happens at the same level as the 'childRelationship' field.
11340
11284
  if (isFieldNode(parentNode) && parentNode.selectionSet && parentNode.name.value === 'node') {
@@ -11344,13 +11288,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11344
11288
  if (!parentNode.selectionSet.selections
11345
11289
  .filter(isFieldNode)
11346
11290
  .some((sibling) => sibling.name.value === 'Id')) {
11347
- idForChildRelationship.push({
11348
- kind: Kind.FIELD,
11349
- name: {
11350
- kind: Kind.NAME,
11351
- value: 'Id',
11352
- },
11353
- });
11291
+ idForChildRelationship.push(createFieldNode('Id'));
11354
11292
  }
11355
11293
  }
11356
11294
  else {
@@ -11379,29 +11317,32 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11379
11317
  .filter(isFieldNode)
11380
11318
  .some((sibling) => sibling.name.value === injectedParentFieldName)) {
11381
11319
  // example: TimeSheetId { value }
11382
- relatedIdForChildRelationship.push({
11383
- kind: Kind.FIELD,
11384
- name: {
11385
- kind: Kind.NAME,
11386
- value: injectedParentFieldName,
11387
- },
11388
- selectionSet: {
11389
- kind: Kind.SELECTION_SET,
11390
- selections: [
11391
- {
11392
- kind: Kind.FIELD,
11393
- name: {
11394
- kind: Kind.NAME,
11395
- value: 'value',
11396
- },
11397
- },
11398
- ],
11399
- },
11400
- });
11320
+ relatedIdForChildRelationship.push(createFieldNode(injectedParentFieldName, FieldValueNodeSelectionSet));
11401
11321
  }
11402
11322
  }
11403
11323
  }
11404
11324
  }
11325
+ const { selectionSet: { selections }, } = parentNode;
11326
+ // see if node selection has DisplayValue and needs to inject
11327
+ let displayValue;
11328
+ for (let i = 0, len = selections.length; i < len; i++) {
11329
+ const node = selections[i];
11330
+ if (isFieldNode(node) && node.name.value === 'DisplayValue') {
11331
+ displayValue = node;
11332
+ break;
11333
+ }
11334
+ }
11335
+ if (displayValue !== undefined) {
11336
+ const apiName = parent.name.value;
11337
+ const objectInfo = objectInfos[apiName];
11338
+ if (objectInfo !== undefined &&
11339
+ objectInfo.nameFields !== undefined &&
11340
+ objectInfo.nameFields.length > 0) {
11341
+ displayValueNameFields = objectInfo.nameFields.map((fieldName) => {
11342
+ return createFieldNode(fieldName, FieldValueNodeSelectionSet);
11343
+ });
11344
+ }
11345
+ }
11405
11346
  }
11406
11347
  }
11407
11348
  }
@@ -11409,6 +11350,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11409
11350
  ...flat(parentRelaltionships),
11410
11351
  ...idForChildRelationship,
11411
11352
  ...relatedIdForChildRelationship,
11353
+ ...displayValueNameFields,
11412
11354
  ];
11413
11355
  }
11414
11356
  function dedupeFieldOrInlineFragmentNodes(duped) {
@@ -11739,6 +11681,22 @@ function referenceIdFieldForRelationship(relationshipName) {
11739
11681
  ? relationshipName.replace('__r', '__c')
11740
11682
  : `${relationshipName}Id`;
11741
11683
  }
11684
+ /**
11685
+ * Creates a FieldNode with the passed name value and optional selection set node
11686
+ * @param nameValue
11687
+ * @param selectionSet
11688
+ * @returns
11689
+ */
11690
+ function createFieldNode(nameValue, selectionSet) {
11691
+ return {
11692
+ kind: Kind.FIELD,
11693
+ name: {
11694
+ kind: Kind.NAME,
11695
+ value: nameValue,
11696
+ },
11697
+ selectionSet,
11698
+ };
11699
+ }
11742
11700
 
11743
11701
  /**
11744
11702
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -18001,4 +17959,4 @@ register({
18001
17959
  });
18002
17960
 
18003
17961
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
18004
- // version: 1.278.0-f0e8ebcd6
17962
+ // version: 1.279.0-21eae5cb0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.278.0",
3
+ "version": "1.279.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -32,25 +32,25 @@
32
32
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-mobile"
33
33
  },
34
34
  "dependencies": {
35
- "@salesforce/lds-adapters-uiapi": "^1.278.0",
36
- "@salesforce/lds-bindings": "^1.278.0",
37
- "@salesforce/lds-instrumentation": "^1.278.0",
38
- "@salesforce/lds-priming": "^1.278.0",
35
+ "@salesforce/lds-adapters-uiapi": "^1.279.0",
36
+ "@salesforce/lds-bindings": "^1.279.0",
37
+ "@salesforce/lds-instrumentation": "^1.279.0",
38
+ "@salesforce/lds-priming": "^1.279.0",
39
39
  "@salesforce/user": "0.0.21",
40
40
  "o11y": "244.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-graphql": "^1.278.0",
44
- "@salesforce/lds-drafts": "^1.278.0",
45
- "@salesforce/lds-drafts-adapters-uiapi": "^1.278.0",
46
- "@salesforce/lds-graphql-eval": "^1.278.0",
47
- "@salesforce/lds-network-adapter": "^1.278.0",
48
- "@salesforce/lds-network-nimbus": "^1.278.0",
49
- "@salesforce/lds-store-binary": "^1.278.0",
50
- "@salesforce/lds-store-nimbus": "^1.278.0",
51
- "@salesforce/lds-store-sql": "^1.278.0",
52
- "@salesforce/lds-utils-adapters": "^1.278.0",
53
- "@salesforce/nimbus-plugin-lds": "^1.278.0",
43
+ "@salesforce/lds-adapters-graphql": "^1.279.0",
44
+ "@salesforce/lds-drafts": "^1.279.0",
45
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.279.0",
46
+ "@salesforce/lds-graphql-eval": "^1.279.0",
47
+ "@salesforce/lds-network-adapter": "^1.279.0",
48
+ "@salesforce/lds-network-nimbus": "^1.279.0",
49
+ "@salesforce/lds-store-binary": "^1.279.0",
50
+ "@salesforce/lds-store-nimbus": "^1.279.0",
51
+ "@salesforce/lds-store-sql": "^1.279.0",
52
+ "@salesforce/lds-utils-adapters": "^1.279.0",
53
+ "@salesforce/nimbus-plugin-lds": "^1.279.0",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
55
55
  "wait-for-expect": "^3.0.2"
56
56
  },
package/sfdc/main.js CHANGED
@@ -4,13 +4,17 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
 
7
- /* *******************************************************************************************
7
+ /*
8
8
  * ATTENTION!
9
9
  * THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
10
10
  * If you would like to contribute to LDS, please follow the steps outlined in the git repo.
11
11
  * Any changes made to this file in p4 will be automatically overwritten.
12
12
  * *******************************************************************************************
13
13
  */
14
+ /*
15
+ * Where possible, we changed noninclusive terms to align with our company value of Equality.
16
+ * We maintained certain terms to avoid any effect on customer implementations.
17
+ */
14
18
  import { withRegistration, register } from 'native/ldsEngineMobile';
15
19
  import { setupInstrumentation, instrumentAdapter as instrumentAdapter$1, instrumentLuvio, setLdsAdaptersUiapiInstrumentation, setLdsNetworkAdapterInstrumentation } from 'force/ldsInstrumentation';
16
20
  import { HttpStatusCode, StoreKeySet, serializeStructuredKey, StringKeyInMemoryStore, Reader, deepFreeze, emitAdapterEvent, createCustomAdapterEventEmitter, StoreKeyMap, isFileReference, Environment, Luvio, InMemoryStore } from 'force/luvioEngine';
@@ -7494,9 +7498,25 @@ function dateTimePredicate(input, operator, field, alias) {
7494
7498
  isCaseSensitive: false,
7495
7499
  };
7496
7500
  if (value !== undefined) {
7497
- const dateFn = field.dataType === 'Date' ? 'date' : 'datetime';
7498
- predicate.value = `${dateFn}(?)`;
7499
- predicate.bindings = [value];
7501
+ if (value === null) {
7502
+ switch (predicate.operator) {
7503
+ case '=':
7504
+ predicate.operator = 'IS';
7505
+ break;
7506
+ case '!=':
7507
+ predicate.operator = 'IS NOT';
7508
+ break;
7509
+ default:
7510
+ // eslint-disable-next-line @salesforce/lds/no-error-in-production
7511
+ throw new Error(`Unsupported operator ${predicate.operator} with null value operand`);
7512
+ }
7513
+ predicate.value = 'NULL';
7514
+ }
7515
+ else {
7516
+ const dateFn = field.dataType === 'Date' ? 'date' : 'datetime';
7517
+ predicate.value = `${dateFn}(?)`;
7518
+ predicate.bindings = [value];
7519
+ }
7500
7520
  return predicate;
7501
7521
  }
7502
7522
  else if (literal !== undefined) {
@@ -10141,6 +10161,18 @@ const parentRelationshipDirective = {
10141
10161
  },
10142
10162
  ],
10143
10163
  };
10164
+ const FieldValueNodeSelectionSet = {
10165
+ kind: Kind.SELECTION_SET,
10166
+ selections: [
10167
+ {
10168
+ kind: Kind.FIELD,
10169
+ name: {
10170
+ kind: Kind.NAME,
10171
+ value: 'value',
10172
+ },
10173
+ },
10174
+ ],
10175
+ };
10144
10176
  async function injectSyntheticFields(originalAST, objectInfoService, draftFunctions, variables) {
10145
10177
  const inlineFragmentSelections = {};
10146
10178
  // read pass; generate ObjectInfo
@@ -10294,20 +10326,19 @@ async function injectSyntheticFields(originalAST, objectInfoService, draftFuncti
10294
10326
  },
10295
10327
  },
10296
10328
  Field: {
10297
- leave(node, key, parent, path, ancestors) {
10298
- if (node.name.value !== `node`)
10299
- return;
10300
- if (!node.selectionSet)
10329
+ leave(node, _key, _parent, _path, ancestors) {
10330
+ if (node.name.value !== 'node')
10301
10331
  return;
10302
10332
  // it could be 'recordQuery' or 'childRelationship'
10303
- const recordQueryField = findNearestConnection(ancestors);
10304
- if (!recordQueryField)
10333
+ const recordConnection = findNearestConnection(ancestors);
10334
+ if (recordConnection === undefined)
10305
10335
  return;
10306
10336
  const ancestorPath = findAncesterPath(ancestors);
10337
+ if (node.selectionSet === undefined)
10338
+ return;
10307
10339
  // spanning fields of the 'parentRelationship'. 'childRelationship' is handled by 'node' parent.
10308
10340
  const spanningSelections = [];
10309
10341
  for (const selection of node.selectionSet.selections) {
10310
- //
10311
10342
  if (isFieldSpanning(selection) || isInlineFragmentFieldSpanning(selection)) {
10312
10343
  spanningSelections.push(selection);
10313
10344
  }
@@ -10924,25 +10955,9 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
10924
10955
  }
10925
10956
  // spanning field needs to have the directive with 'parentRelationship'
10926
10957
  const directives = isSpanning && !isInlineFragment ? [parentRelationshipDirective] : [];
10927
- let idField = isSpanning && !isPolymorphicField
10928
- ? [
10929
- {
10930
- kind: Kind.FIELD,
10931
- name: {
10932
- kind: Kind.NAME,
10933
- value: 'Id',
10934
- },
10935
- },
10936
- ]
10937
- : [];
10958
+ let idField = isSpanning && !isPolymorphicField ? [createFieldNode('Id')] : [];
10938
10959
  // This variable change to InlineFragment if 'isInlineFragment' is true
10939
- let sel = {
10940
- kind: Kind.FIELD,
10941
- name: {
10942
- kind: Kind.NAME,
10943
- value: fieldName,
10944
- },
10945
- };
10960
+ let sel = createFieldNode(fieldName);
10946
10961
  // Check if fields is valid
10947
10962
  if (apiNames.length === 1 && !isInlineFragment) {
10948
10963
  const objectInfo = objectInfos[apiNames[0]];
@@ -10988,13 +11003,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
10988
11003
  idField = [];
10989
11004
  }
10990
11005
  if (isInlineFragment && !isTypeNameExisting) {
10991
- idField.push({
10992
- kind: Kind.FIELD,
10993
- name: {
10994
- kind: Kind.NAME,
10995
- value: '__typename',
10996
- },
10997
- });
11006
+ idField.push(createFieldNode('__typename'));
10998
11007
  }
10999
11008
  //Inject Conditions: 1. Same field does not exist 2. Same fields has different children. 3. Filter spanning field does not have Id. 4. InLineFragment does not have the '__typename' field
11000
11009
  if (!existingFields ||
@@ -11040,18 +11049,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
11040
11049
  if (!isSpanning) {
11041
11050
  sel = {
11042
11051
  ...sel,
11043
- selectionSet: {
11044
- kind: Kind.SELECTION_SET,
11045
- selections: [
11046
- {
11047
- kind: Kind.FIELD,
11048
- name: {
11049
- kind: Kind.NAME,
11050
- value: 'value',
11051
- },
11052
- },
11053
- ],
11054
- },
11052
+ selectionSet: FieldValueNodeSelectionSet,
11055
11053
  };
11056
11054
  }
11057
11055
  }
@@ -11072,25 +11070,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
11072
11070
  .filter(isFieldNode)
11073
11071
  .filter((subNode) => subNode.name.value === relationField);
11074
11072
  if (!existingRelationFields || existingRelationFields.length === 0) {
11075
- injectedSelections.push({
11076
- kind: Kind.FIELD,
11077
- name: {
11078
- kind: Kind.NAME,
11079
- value: relationField,
11080
- },
11081
- selectionSet: {
11082
- kind: Kind.SELECTION_SET,
11083
- selections: [
11084
- {
11085
- kind: Kind.FIELD,
11086
- name: {
11087
- kind: Kind.NAME,
11088
- value: 'value',
11089
- },
11090
- },
11091
- ],
11092
- },
11093
- });
11073
+ injectedSelections.push(createFieldNode(relationField, FieldValueNodeSelectionSet));
11094
11074
  }
11095
11075
  }
11096
11076
  }
@@ -11181,15 +11161,7 @@ function produceValueFieldLeaves(queryNode) {
11181
11161
  .filter(isFieldNode)
11182
11162
  .filter((subNode) => subNode.name.value === 'value');
11183
11163
  return !existingValueFields || existingValueFields.length === 0
11184
- ? [
11185
- {
11186
- kind: Kind.FIELD,
11187
- name: {
11188
- kind: Kind.NAME,
11189
- value: 'value',
11190
- },
11191
- },
11192
- ]
11164
+ ? [createFieldNode('value')]
11193
11165
  : [];
11194
11166
  }
11195
11167
  function updateIDInfo(fieldNode, idState, draftFunctions) {
@@ -11271,25 +11243,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11271
11243
  .filter((subNode) => subNode.name.value === relationshipId);
11272
11244
  if (existingRelationFields.length === 0) {
11273
11245
  injectedRelationshipField = [
11274
- {
11275
- kind: Kind.FIELD,
11276
- name: {
11277
- kind: Kind.NAME,
11278
- value: relationshipId,
11279
- },
11280
- selectionSet: {
11281
- kind: Kind.SELECTION_SET,
11282
- selections: [
11283
- {
11284
- kind: Kind.FIELD,
11285
- name: {
11286
- kind: Kind.NAME,
11287
- value: 'value',
11288
- },
11289
- },
11290
- ],
11291
- },
11292
- },
11246
+ createFieldNode(relationshipId, FieldValueNodeSelectionSet),
11293
11247
  ];
11294
11248
  }
11295
11249
  }
@@ -11297,25 +11251,13 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11297
11251
  const excludeId = isPolymorphicFieldPath(curPath, pathToObjectApiNamesMap, objectInfos);
11298
11252
  const idSelection = [];
11299
11253
  if (!excludeId && !hasIdAlready) {
11300
- idSelection.push({
11301
- kind: Kind.FIELD,
11302
- name: {
11303
- kind: Kind.NAME,
11304
- value: 'Id',
11305
- },
11306
- });
11254
+ idSelection.push(createFieldNode('Id'));
11307
11255
  }
11308
11256
  // 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
11309
11257
  // `typedCondition` of the InlineFragment in the query AST. It is used to match JSON response with AST node. For more detail, please reference 'removeSyntheticFields'.
11310
11258
  if (isInlineFragmentNode(selection) &&
11311
11259
  !selection.selectionSet.selections.find((selection) => isFieldNode(selection) && selection.name.value === '__typename')) {
11312
- idSelection.push({
11313
- kind: Kind.FIELD,
11314
- name: {
11315
- kind: Kind.NAME,
11316
- value: '__typename',
11317
- },
11318
- });
11260
+ idSelection.push(createFieldNode('__typename'));
11319
11261
  }
11320
11262
  // 'ServiceAppointment' --> 'Contact' --> 'Id', Inject 'Contact' with Id. 'Id' field is at the sub level.
11321
11263
  const injectedSelectionIdField = idSelection.length > 0 || subInjectedSelections.length > 0
@@ -11335,6 +11277,8 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11335
11277
  const idForChildRelationship = [];
11336
11278
  // inject related field for the parent of the 'childRelationship'.
11337
11279
  const relatedIdForChildRelationship = [];
11280
+ // injected fields for DisplayValue
11281
+ let displayValueNameFields = [];
11338
11282
  // injects 'childRelatiship' at the 'node' level, it does not matter if the 'selections' is empty or not.
11339
11283
  // the operation happens at the same level as the 'childRelationship' field.
11340
11284
  if (isFieldNode(parentNode) && parentNode.selectionSet && parentNode.name.value === 'node') {
@@ -11344,13 +11288,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11344
11288
  if (!parentNode.selectionSet.selections
11345
11289
  .filter(isFieldNode)
11346
11290
  .some((sibling) => sibling.name.value === 'Id')) {
11347
- idForChildRelationship.push({
11348
- kind: Kind.FIELD,
11349
- name: {
11350
- kind: Kind.NAME,
11351
- value: 'Id',
11352
- },
11353
- });
11291
+ idForChildRelationship.push(createFieldNode('Id'));
11354
11292
  }
11355
11293
  }
11356
11294
  else {
@@ -11379,29 +11317,32 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11379
11317
  .filter(isFieldNode)
11380
11318
  .some((sibling) => sibling.name.value === injectedParentFieldName)) {
11381
11319
  // example: TimeSheetId { value }
11382
- relatedIdForChildRelationship.push({
11383
- kind: Kind.FIELD,
11384
- name: {
11385
- kind: Kind.NAME,
11386
- value: injectedParentFieldName,
11387
- },
11388
- selectionSet: {
11389
- kind: Kind.SELECTION_SET,
11390
- selections: [
11391
- {
11392
- kind: Kind.FIELD,
11393
- name: {
11394
- kind: Kind.NAME,
11395
- value: 'value',
11396
- },
11397
- },
11398
- ],
11399
- },
11400
- });
11320
+ relatedIdForChildRelationship.push(createFieldNode(injectedParentFieldName, FieldValueNodeSelectionSet));
11401
11321
  }
11402
11322
  }
11403
11323
  }
11404
11324
  }
11325
+ const { selectionSet: { selections }, } = parentNode;
11326
+ // see if node selection has DisplayValue and needs to inject
11327
+ let displayValue;
11328
+ for (let i = 0, len = selections.length; i < len; i++) {
11329
+ const node = selections[i];
11330
+ if (isFieldNode(node) && node.name.value === 'DisplayValue') {
11331
+ displayValue = node;
11332
+ break;
11333
+ }
11334
+ }
11335
+ if (displayValue !== undefined) {
11336
+ const apiName = parent.name.value;
11337
+ const objectInfo = objectInfos[apiName];
11338
+ if (objectInfo !== undefined &&
11339
+ objectInfo.nameFields !== undefined &&
11340
+ objectInfo.nameFields.length > 0) {
11341
+ displayValueNameFields = objectInfo.nameFields.map((fieldName) => {
11342
+ return createFieldNode(fieldName, FieldValueNodeSelectionSet);
11343
+ });
11344
+ }
11345
+ }
11405
11346
  }
11406
11347
  }
11407
11348
  }
@@ -11409,6 +11350,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11409
11350
  ...flat(parentRelaltionships),
11410
11351
  ...idForChildRelationship,
11411
11352
  ...relatedIdForChildRelationship,
11353
+ ...displayValueNameFields,
11412
11354
  ];
11413
11355
  }
11414
11356
  function dedupeFieldOrInlineFragmentNodes(duped) {
@@ -11739,6 +11681,22 @@ function referenceIdFieldForRelationship(relationshipName) {
11739
11681
  ? relationshipName.replace('__r', '__c')
11740
11682
  : `${relationshipName}Id`;
11741
11683
  }
11684
+ /**
11685
+ * Creates a FieldNode with the passed name value and optional selection set node
11686
+ * @param nameValue
11687
+ * @param selectionSet
11688
+ * @returns
11689
+ */
11690
+ function createFieldNode(nameValue, selectionSet) {
11691
+ return {
11692
+ kind: Kind.FIELD,
11693
+ name: {
11694
+ kind: Kind.NAME,
11695
+ value: nameValue,
11696
+ },
11697
+ selectionSet,
11698
+ };
11699
+ }
11742
11700
 
11743
11701
  /**
11744
11702
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -18001,4 +17959,4 @@ register({
18001
17959
  });
18002
17960
 
18003
17961
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
18004
- // version: 1.278.0-f0e8ebcd6
17962
+ // version: 1.279.0-21eae5cb0