@salesforce/lds-runtime-mobile 1.277.1 → 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 +131 -136
  2. package/package.json +16 -16
  3. package/sfdc/main.js +131 -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) {
@@ -9402,6 +9422,9 @@ function addResolversToSchema(schema, polyFields) {
9402
9422
  return record.recordTypeId ? { value: record.recordTypeId } : null;
9403
9423
  };
9404
9424
  break;
9425
+ case 'DisplayValue':
9426
+ field.resolve = recordDisplayValueResolver;
9427
+ break;
9405
9428
  default: {
9406
9429
  const recordFieldType = schema.getType(field.type.name);
9407
9430
  // Both concrete record type and 'record' interface type(polymorphic field) uses 'RecordLoader' to resolve.
@@ -9470,6 +9493,40 @@ function addResolversToSchema(schema, polyFields) {
9470
9493
  }
9471
9494
  return schema;
9472
9495
  }
9496
+ /**
9497
+ * Resolver to fetch the DisplayValue of a graphql record.
9498
+ * This is taking the main Name field for the record
9499
+ * type and using it for the DisplayValue.
9500
+ *
9501
+ * This allows us to be more performant without needing to call
9502
+ * another SQL lookup for the cached graphql object of the RAML record.
9503
+ */
9504
+ function recordDisplayValueResolver({ recordRepresentation },
9505
+ // not used, but gets sent in the resolver
9506
+ _, { objectInfos }) {
9507
+ const { apiName } = recordRepresentation;
9508
+ const objectInfo = objectInfos[apiName];
9509
+ if (objectInfo !== undefined) {
9510
+ const { nameFields, fields } = objectInfo;
9511
+ let nameField;
9512
+ // use the field Name if it exists or the first field name
9513
+ if (nameFields.length !== 0) {
9514
+ nameField = nameFields.find((x) => x === 'Name');
9515
+ if (nameField === undefined) {
9516
+ nameField = nameFields[0];
9517
+ }
9518
+ }
9519
+ if (nameField !== undefined) {
9520
+ nameField = fields[nameField].apiName;
9521
+ const nameFieldRep = recordRepresentation.fields[nameField];
9522
+ if (nameFieldRep !== undefined) {
9523
+ return nameFieldRep.value;
9524
+ }
9525
+ }
9526
+ }
9527
+ // TODO [W-14660068]: composite name fields
9528
+ return null;
9529
+ }
9473
9530
  async function connectionEdgeResolver(obj, _args, context) {
9474
9531
  const { parentArgs = {}, parentRecord, currentFieldName, ingestionTimestamp } = obj;
9475
9532
  const { query, objectInfos, draftFunctions } = context;
@@ -10104,6 +10161,18 @@ const parentRelationshipDirective = {
10104
10161
  },
10105
10162
  ],
10106
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
+ };
10107
10176
  async function injectSyntheticFields(originalAST, objectInfoService, draftFunctions, variables) {
10108
10177
  const inlineFragmentSelections = {};
10109
10178
  // read pass; generate ObjectInfo
@@ -10257,20 +10326,19 @@ async function injectSyntheticFields(originalAST, objectInfoService, draftFuncti
10257
10326
  },
10258
10327
  },
10259
10328
  Field: {
10260
- leave(node, key, parent, path, ancestors) {
10261
- if (node.name.value !== `node`)
10262
- return;
10263
- if (!node.selectionSet)
10329
+ leave(node, _key, _parent, _path, ancestors) {
10330
+ if (node.name.value !== 'node')
10264
10331
  return;
10265
10332
  // it could be 'recordQuery' or 'childRelationship'
10266
- const recordQueryField = findNearestConnection(ancestors);
10267
- if (!recordQueryField)
10333
+ const recordConnection = findNearestConnection(ancestors);
10334
+ if (recordConnection === undefined)
10268
10335
  return;
10269
10336
  const ancestorPath = findAncesterPath(ancestors);
10337
+ if (node.selectionSet === undefined)
10338
+ return;
10270
10339
  // spanning fields of the 'parentRelationship'. 'childRelationship' is handled by 'node' parent.
10271
10340
  const spanningSelections = [];
10272
10341
  for (const selection of node.selectionSet.selections) {
10273
- //
10274
10342
  if (isFieldSpanning(selection) || isInlineFragmentFieldSpanning(selection)) {
10275
10343
  spanningSelections.push(selection);
10276
10344
  }
@@ -10887,25 +10955,9 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
10887
10955
  }
10888
10956
  // spanning field needs to have the directive with 'parentRelationship'
10889
10957
  const directives = isSpanning && !isInlineFragment ? [parentRelationshipDirective] : [];
10890
- let idField = isSpanning && !isPolymorphicField
10891
- ? [
10892
- {
10893
- kind: Kind.FIELD,
10894
- name: {
10895
- kind: Kind.NAME,
10896
- value: 'Id',
10897
- },
10898
- },
10899
- ]
10900
- : [];
10958
+ let idField = isSpanning && !isPolymorphicField ? [createFieldNode('Id')] : [];
10901
10959
  // This variable change to InlineFragment if 'isInlineFragment' is true
10902
- let sel = {
10903
- kind: Kind.FIELD,
10904
- name: {
10905
- kind: Kind.NAME,
10906
- value: fieldName,
10907
- },
10908
- };
10960
+ let sel = createFieldNode(fieldName);
10909
10961
  // Check if fields is valid
10910
10962
  if (apiNames.length === 1 && !isInlineFragment) {
10911
10963
  const objectInfo = objectInfos[apiNames[0]];
@@ -10951,13 +11003,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
10951
11003
  idField = [];
10952
11004
  }
10953
11005
  if (isInlineFragment && !isTypeNameExisting) {
10954
- idField.push({
10955
- kind: Kind.FIELD,
10956
- name: {
10957
- kind: Kind.NAME,
10958
- value: '__typename',
10959
- },
10960
- });
11006
+ idField.push(createFieldNode('__typename'));
10961
11007
  }
10962
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
10963
11009
  if (!existingFields ||
@@ -11003,18 +11049,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
11003
11049
  if (!isSpanning) {
11004
11050
  sel = {
11005
11051
  ...sel,
11006
- selectionSet: {
11007
- kind: Kind.SELECTION_SET,
11008
- selections: [
11009
- {
11010
- kind: Kind.FIELD,
11011
- name: {
11012
- kind: Kind.NAME,
11013
- value: 'value',
11014
- },
11015
- },
11016
- ],
11017
- },
11052
+ selectionSet: FieldValueNodeSelectionSet,
11018
11053
  };
11019
11054
  }
11020
11055
  }
@@ -11035,25 +11070,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
11035
11070
  .filter(isFieldNode)
11036
11071
  .filter((subNode) => subNode.name.value === relationField);
11037
11072
  if (!existingRelationFields || existingRelationFields.length === 0) {
11038
- injectedSelections.push({
11039
- kind: Kind.FIELD,
11040
- name: {
11041
- kind: Kind.NAME,
11042
- value: relationField,
11043
- },
11044
- selectionSet: {
11045
- kind: Kind.SELECTION_SET,
11046
- selections: [
11047
- {
11048
- kind: Kind.FIELD,
11049
- name: {
11050
- kind: Kind.NAME,
11051
- value: 'value',
11052
- },
11053
- },
11054
- ],
11055
- },
11056
- });
11073
+ injectedSelections.push(createFieldNode(relationField, FieldValueNodeSelectionSet));
11057
11074
  }
11058
11075
  }
11059
11076
  }
@@ -11144,15 +11161,7 @@ function produceValueFieldLeaves(queryNode) {
11144
11161
  .filter(isFieldNode)
11145
11162
  .filter((subNode) => subNode.name.value === 'value');
11146
11163
  return !existingValueFields || existingValueFields.length === 0
11147
- ? [
11148
- {
11149
- kind: Kind.FIELD,
11150
- name: {
11151
- kind: Kind.NAME,
11152
- value: 'value',
11153
- },
11154
- },
11155
- ]
11164
+ ? [createFieldNode('value')]
11156
11165
  : [];
11157
11166
  }
11158
11167
  function updateIDInfo(fieldNode, idState, draftFunctions) {
@@ -11234,25 +11243,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11234
11243
  .filter((subNode) => subNode.name.value === relationshipId);
11235
11244
  if (existingRelationFields.length === 0) {
11236
11245
  injectedRelationshipField = [
11237
- {
11238
- kind: Kind.FIELD,
11239
- name: {
11240
- kind: Kind.NAME,
11241
- value: relationshipId,
11242
- },
11243
- selectionSet: {
11244
- kind: Kind.SELECTION_SET,
11245
- selections: [
11246
- {
11247
- kind: Kind.FIELD,
11248
- name: {
11249
- kind: Kind.NAME,
11250
- value: 'value',
11251
- },
11252
- },
11253
- ],
11254
- },
11255
- },
11246
+ createFieldNode(relationshipId, FieldValueNodeSelectionSet),
11256
11247
  ];
11257
11248
  }
11258
11249
  }
@@ -11260,25 +11251,13 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11260
11251
  const excludeId = isPolymorphicFieldPath(curPath, pathToObjectApiNamesMap, objectInfos);
11261
11252
  const idSelection = [];
11262
11253
  if (!excludeId && !hasIdAlready) {
11263
- idSelection.push({
11264
- kind: Kind.FIELD,
11265
- name: {
11266
- kind: Kind.NAME,
11267
- value: 'Id',
11268
- },
11269
- });
11254
+ idSelection.push(createFieldNode('Id'));
11270
11255
  }
11271
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
11272
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'.
11273
11258
  if (isInlineFragmentNode(selection) &&
11274
11259
  !selection.selectionSet.selections.find((selection) => isFieldNode(selection) && selection.name.value === '__typename')) {
11275
- idSelection.push({
11276
- kind: Kind.FIELD,
11277
- name: {
11278
- kind: Kind.NAME,
11279
- value: '__typename',
11280
- },
11281
- });
11260
+ idSelection.push(createFieldNode('__typename'));
11282
11261
  }
11283
11262
  // 'ServiceAppointment' --> 'Contact' --> 'Id', Inject 'Contact' with Id. 'Id' field is at the sub level.
11284
11263
  const injectedSelectionIdField = idSelection.length > 0 || subInjectedSelections.length > 0
@@ -11298,6 +11277,8 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11298
11277
  const idForChildRelationship = [];
11299
11278
  // inject related field for the parent of the 'childRelationship'.
11300
11279
  const relatedIdForChildRelationship = [];
11280
+ // injected fields for DisplayValue
11281
+ let displayValueNameFields = [];
11301
11282
  // injects 'childRelatiship' at the 'node' level, it does not matter if the 'selections' is empty or not.
11302
11283
  // the operation happens at the same level as the 'childRelationship' field.
11303
11284
  if (isFieldNode(parentNode) && parentNode.selectionSet && parentNode.name.value === 'node') {
@@ -11307,13 +11288,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11307
11288
  if (!parentNode.selectionSet.selections
11308
11289
  .filter(isFieldNode)
11309
11290
  .some((sibling) => sibling.name.value === 'Id')) {
11310
- idForChildRelationship.push({
11311
- kind: Kind.FIELD,
11312
- name: {
11313
- kind: Kind.NAME,
11314
- value: 'Id',
11315
- },
11316
- });
11291
+ idForChildRelationship.push(createFieldNode('Id'));
11317
11292
  }
11318
11293
  }
11319
11294
  else {
@@ -11342,29 +11317,32 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11342
11317
  .filter(isFieldNode)
11343
11318
  .some((sibling) => sibling.name.value === injectedParentFieldName)) {
11344
11319
  // example: TimeSheetId { value }
11345
- relatedIdForChildRelationship.push({
11346
- kind: Kind.FIELD,
11347
- name: {
11348
- kind: Kind.NAME,
11349
- value: injectedParentFieldName,
11350
- },
11351
- selectionSet: {
11352
- kind: Kind.SELECTION_SET,
11353
- selections: [
11354
- {
11355
- kind: Kind.FIELD,
11356
- name: {
11357
- kind: Kind.NAME,
11358
- value: 'value',
11359
- },
11360
- },
11361
- ],
11362
- },
11363
- });
11320
+ relatedIdForChildRelationship.push(createFieldNode(injectedParentFieldName, FieldValueNodeSelectionSet));
11364
11321
  }
11365
11322
  }
11366
11323
  }
11367
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
+ }
11368
11346
  }
11369
11347
  }
11370
11348
  }
@@ -11372,6 +11350,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11372
11350
  ...flat(parentRelaltionships),
11373
11351
  ...idForChildRelationship,
11374
11352
  ...relatedIdForChildRelationship,
11353
+ ...displayValueNameFields,
11375
11354
  ];
11376
11355
  }
11377
11356
  function dedupeFieldOrInlineFragmentNodes(duped) {
@@ -11702,6 +11681,22 @@ function referenceIdFieldForRelationship(relationshipName) {
11702
11681
  ? relationshipName.replace('__r', '__c')
11703
11682
  : `${relationshipName}Id`;
11704
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
+ }
11705
11700
 
11706
11701
  /**
11707
11702
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -17964,4 +17959,4 @@ register({
17964
17959
  });
17965
17960
 
17966
17961
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
17967
- // version: 1.277.1-0c6d52b34
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.277.1",
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.277.1",
36
- "@salesforce/lds-bindings": "^1.277.1",
37
- "@salesforce/lds-instrumentation": "^1.277.1",
38
- "@salesforce/lds-priming": "^1.277.1",
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.277.1",
44
- "@salesforce/lds-drafts": "^1.277.1",
45
- "@salesforce/lds-drafts-adapters-uiapi": "^1.277.1",
46
- "@salesforce/lds-graphql-eval": "^1.277.1",
47
- "@salesforce/lds-network-adapter": "^1.277.1",
48
- "@salesforce/lds-network-nimbus": "^1.277.1",
49
- "@salesforce/lds-store-binary": "^1.277.1",
50
- "@salesforce/lds-store-nimbus": "^1.277.1",
51
- "@salesforce/lds-store-sql": "^1.277.1",
52
- "@salesforce/lds-utils-adapters": "^1.277.1",
53
- "@salesforce/nimbus-plugin-lds": "^1.277.1",
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) {
@@ -9402,6 +9422,9 @@ function addResolversToSchema(schema, polyFields) {
9402
9422
  return record.recordTypeId ? { value: record.recordTypeId } : null;
9403
9423
  };
9404
9424
  break;
9425
+ case 'DisplayValue':
9426
+ field.resolve = recordDisplayValueResolver;
9427
+ break;
9405
9428
  default: {
9406
9429
  const recordFieldType = schema.getType(field.type.name);
9407
9430
  // Both concrete record type and 'record' interface type(polymorphic field) uses 'RecordLoader' to resolve.
@@ -9470,6 +9493,40 @@ function addResolversToSchema(schema, polyFields) {
9470
9493
  }
9471
9494
  return schema;
9472
9495
  }
9496
+ /**
9497
+ * Resolver to fetch the DisplayValue of a graphql record.
9498
+ * This is taking the main Name field for the record
9499
+ * type and using it for the DisplayValue.
9500
+ *
9501
+ * This allows us to be more performant without needing to call
9502
+ * another SQL lookup for the cached graphql object of the RAML record.
9503
+ */
9504
+ function recordDisplayValueResolver({ recordRepresentation },
9505
+ // not used, but gets sent in the resolver
9506
+ _, { objectInfos }) {
9507
+ const { apiName } = recordRepresentation;
9508
+ const objectInfo = objectInfos[apiName];
9509
+ if (objectInfo !== undefined) {
9510
+ const { nameFields, fields } = objectInfo;
9511
+ let nameField;
9512
+ // use the field Name if it exists or the first field name
9513
+ if (nameFields.length !== 0) {
9514
+ nameField = nameFields.find((x) => x === 'Name');
9515
+ if (nameField === undefined) {
9516
+ nameField = nameFields[0];
9517
+ }
9518
+ }
9519
+ if (nameField !== undefined) {
9520
+ nameField = fields[nameField].apiName;
9521
+ const nameFieldRep = recordRepresentation.fields[nameField];
9522
+ if (nameFieldRep !== undefined) {
9523
+ return nameFieldRep.value;
9524
+ }
9525
+ }
9526
+ }
9527
+ // TODO [W-14660068]: composite name fields
9528
+ return null;
9529
+ }
9473
9530
  async function connectionEdgeResolver(obj, _args, context) {
9474
9531
  const { parentArgs = {}, parentRecord, currentFieldName, ingestionTimestamp } = obj;
9475
9532
  const { query, objectInfos, draftFunctions } = context;
@@ -10104,6 +10161,18 @@ const parentRelationshipDirective = {
10104
10161
  },
10105
10162
  ],
10106
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
+ };
10107
10176
  async function injectSyntheticFields(originalAST, objectInfoService, draftFunctions, variables) {
10108
10177
  const inlineFragmentSelections = {};
10109
10178
  // read pass; generate ObjectInfo
@@ -10257,20 +10326,19 @@ async function injectSyntheticFields(originalAST, objectInfoService, draftFuncti
10257
10326
  },
10258
10327
  },
10259
10328
  Field: {
10260
- leave(node, key, parent, path, ancestors) {
10261
- if (node.name.value !== `node`)
10262
- return;
10263
- if (!node.selectionSet)
10329
+ leave(node, _key, _parent, _path, ancestors) {
10330
+ if (node.name.value !== 'node')
10264
10331
  return;
10265
10332
  // it could be 'recordQuery' or 'childRelationship'
10266
- const recordQueryField = findNearestConnection(ancestors);
10267
- if (!recordQueryField)
10333
+ const recordConnection = findNearestConnection(ancestors);
10334
+ if (recordConnection === undefined)
10268
10335
  return;
10269
10336
  const ancestorPath = findAncesterPath(ancestors);
10337
+ if (node.selectionSet === undefined)
10338
+ return;
10270
10339
  // spanning fields of the 'parentRelationship'. 'childRelationship' is handled by 'node' parent.
10271
10340
  const spanningSelections = [];
10272
10341
  for (const selection of node.selectionSet.selections) {
10273
- //
10274
10342
  if (isFieldSpanning(selection) || isInlineFragmentFieldSpanning(selection)) {
10275
10343
  spanningSelections.push(selection);
10276
10344
  }
@@ -10887,25 +10955,9 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
10887
10955
  }
10888
10956
  // spanning field needs to have the directive with 'parentRelationship'
10889
10957
  const directives = isSpanning && !isInlineFragment ? [parentRelationshipDirective] : [];
10890
- let idField = isSpanning && !isPolymorphicField
10891
- ? [
10892
- {
10893
- kind: Kind.FIELD,
10894
- name: {
10895
- kind: Kind.NAME,
10896
- value: 'Id',
10897
- },
10898
- },
10899
- ]
10900
- : [];
10958
+ let idField = isSpanning && !isPolymorphicField ? [createFieldNode('Id')] : [];
10901
10959
  // This variable change to InlineFragment if 'isInlineFragment' is true
10902
- let sel = {
10903
- kind: Kind.FIELD,
10904
- name: {
10905
- kind: Kind.NAME,
10906
- value: fieldName,
10907
- },
10908
- };
10960
+ let sel = createFieldNode(fieldName);
10909
10961
  // Check if fields is valid
10910
10962
  if (apiNames.length === 1 && !isInlineFragment) {
10911
10963
  const objectInfo = objectInfos[apiNames[0]];
@@ -10951,13 +11003,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
10951
11003
  idField = [];
10952
11004
  }
10953
11005
  if (isInlineFragment && !isTypeNameExisting) {
10954
- idField.push({
10955
- kind: Kind.FIELD,
10956
- name: {
10957
- kind: Kind.NAME,
10958
- value: '__typename',
10959
- },
10960
- });
11006
+ idField.push(createFieldNode('__typename'));
10961
11007
  }
10962
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
10963
11009
  if (!existingFields ||
@@ -11003,18 +11049,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
11003
11049
  if (!isSpanning) {
11004
11050
  sel = {
11005
11051
  ...sel,
11006
- selectionSet: {
11007
- kind: Kind.SELECTION_SET,
11008
- selections: [
11009
- {
11010
- kind: Kind.FIELD,
11011
- name: {
11012
- kind: Kind.NAME,
11013
- value: 'value',
11014
- },
11015
- },
11016
- ],
11017
- },
11052
+ selectionSet: FieldValueNodeSelectionSet,
11018
11053
  };
11019
11054
  }
11020
11055
  }
@@ -11035,25 +11070,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
11035
11070
  .filter(isFieldNode)
11036
11071
  .filter((subNode) => subNode.name.value === relationField);
11037
11072
  if (!existingRelationFields || existingRelationFields.length === 0) {
11038
- injectedSelections.push({
11039
- kind: Kind.FIELD,
11040
- name: {
11041
- kind: Kind.NAME,
11042
- value: relationField,
11043
- },
11044
- selectionSet: {
11045
- kind: Kind.SELECTION_SET,
11046
- selections: [
11047
- {
11048
- kind: Kind.FIELD,
11049
- name: {
11050
- kind: Kind.NAME,
11051
- value: 'value',
11052
- },
11053
- },
11054
- ],
11055
- },
11056
- });
11073
+ injectedSelections.push(createFieldNode(relationField, FieldValueNodeSelectionSet));
11057
11074
  }
11058
11075
  }
11059
11076
  }
@@ -11144,15 +11161,7 @@ function produceValueFieldLeaves(queryNode) {
11144
11161
  .filter(isFieldNode)
11145
11162
  .filter((subNode) => subNode.name.value === 'value');
11146
11163
  return !existingValueFields || existingValueFields.length === 0
11147
- ? [
11148
- {
11149
- kind: Kind.FIELD,
11150
- name: {
11151
- kind: Kind.NAME,
11152
- value: 'value',
11153
- },
11154
- },
11155
- ]
11164
+ ? [createFieldNode('value')]
11156
11165
  : [];
11157
11166
  }
11158
11167
  function updateIDInfo(fieldNode, idState, draftFunctions) {
@@ -11234,25 +11243,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11234
11243
  .filter((subNode) => subNode.name.value === relationshipId);
11235
11244
  if (existingRelationFields.length === 0) {
11236
11245
  injectedRelationshipField = [
11237
- {
11238
- kind: Kind.FIELD,
11239
- name: {
11240
- kind: Kind.NAME,
11241
- value: relationshipId,
11242
- },
11243
- selectionSet: {
11244
- kind: Kind.SELECTION_SET,
11245
- selections: [
11246
- {
11247
- kind: Kind.FIELD,
11248
- name: {
11249
- kind: Kind.NAME,
11250
- value: 'value',
11251
- },
11252
- },
11253
- ],
11254
- },
11255
- },
11246
+ createFieldNode(relationshipId, FieldValueNodeSelectionSet),
11256
11247
  ];
11257
11248
  }
11258
11249
  }
@@ -11260,25 +11251,13 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11260
11251
  const excludeId = isPolymorphicFieldPath(curPath, pathToObjectApiNamesMap, objectInfos);
11261
11252
  const idSelection = [];
11262
11253
  if (!excludeId && !hasIdAlready) {
11263
- idSelection.push({
11264
- kind: Kind.FIELD,
11265
- name: {
11266
- kind: Kind.NAME,
11267
- value: 'Id',
11268
- },
11269
- });
11254
+ idSelection.push(createFieldNode('Id'));
11270
11255
  }
11271
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
11272
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'.
11273
11258
  if (isInlineFragmentNode(selection) &&
11274
11259
  !selection.selectionSet.selections.find((selection) => isFieldNode(selection) && selection.name.value === '__typename')) {
11275
- idSelection.push({
11276
- kind: Kind.FIELD,
11277
- name: {
11278
- kind: Kind.NAME,
11279
- value: '__typename',
11280
- },
11281
- });
11260
+ idSelection.push(createFieldNode('__typename'));
11282
11261
  }
11283
11262
  // 'ServiceAppointment' --> 'Contact' --> 'Id', Inject 'Contact' with Id. 'Id' field is at the sub level.
11284
11263
  const injectedSelectionIdField = idSelection.length > 0 || subInjectedSelections.length > 0
@@ -11298,6 +11277,8 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11298
11277
  const idForChildRelationship = [];
11299
11278
  // inject related field for the parent of the 'childRelationship'.
11300
11279
  const relatedIdForChildRelationship = [];
11280
+ // injected fields for DisplayValue
11281
+ let displayValueNameFields = [];
11301
11282
  // injects 'childRelatiship' at the 'node' level, it does not matter if the 'selections' is empty or not.
11302
11283
  // the operation happens at the same level as the 'childRelationship' field.
11303
11284
  if (isFieldNode(parentNode) && parentNode.selectionSet && parentNode.name.value === 'node') {
@@ -11307,13 +11288,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11307
11288
  if (!parentNode.selectionSet.selections
11308
11289
  .filter(isFieldNode)
11309
11290
  .some((sibling) => sibling.name.value === 'Id')) {
11310
- idForChildRelationship.push({
11311
- kind: Kind.FIELD,
11312
- name: {
11313
- kind: Kind.NAME,
11314
- value: 'Id',
11315
- },
11316
- });
11291
+ idForChildRelationship.push(createFieldNode('Id'));
11317
11292
  }
11318
11293
  }
11319
11294
  else {
@@ -11342,29 +11317,32 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11342
11317
  .filter(isFieldNode)
11343
11318
  .some((sibling) => sibling.name.value === injectedParentFieldName)) {
11344
11319
  // example: TimeSheetId { value }
11345
- relatedIdForChildRelationship.push({
11346
- kind: Kind.FIELD,
11347
- name: {
11348
- kind: Kind.NAME,
11349
- value: injectedParentFieldName,
11350
- },
11351
- selectionSet: {
11352
- kind: Kind.SELECTION_SET,
11353
- selections: [
11354
- {
11355
- kind: Kind.FIELD,
11356
- name: {
11357
- kind: Kind.NAME,
11358
- value: 'value',
11359
- },
11360
- },
11361
- ],
11362
- },
11363
- });
11320
+ relatedIdForChildRelationship.push(createFieldNode(injectedParentFieldName, FieldValueNodeSelectionSet));
11364
11321
  }
11365
11322
  }
11366
11323
  }
11367
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
+ }
11368
11346
  }
11369
11347
  }
11370
11348
  }
@@ -11372,6 +11350,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
11372
11350
  ...flat(parentRelaltionships),
11373
11351
  ...idForChildRelationship,
11374
11352
  ...relatedIdForChildRelationship,
11353
+ ...displayValueNameFields,
11375
11354
  ];
11376
11355
  }
11377
11356
  function dedupeFieldOrInlineFragmentNodes(duped) {
@@ -11702,6 +11681,22 @@ function referenceIdFieldForRelationship(relationshipName) {
11702
11681
  ? relationshipName.replace('__r', '__c')
11703
11682
  : `${relationshipName}Id`;
11704
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
+ }
11705
11700
 
11706
11701
  /**
11707
11702
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -17964,4 +17959,4 @@ register({
17964
17959
  });
17965
17960
 
17966
17961
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
17967
- // version: 1.277.1-0c6d52b34
17962
+ // version: 1.279.0-21eae5cb0