@salesforce/lds-runtime-mobile 1.228.1 → 1.229.0-dev2

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 +100 -60
  2. package/package.json +16 -16
  3. package/sfdc/main.js +100 -60
package/dist/main.js CHANGED
@@ -1455,6 +1455,72 @@ function makeDurable(environment, { durableStore, instrumentation }) {
1455
1455
  });
1456
1456
  }
1457
1457
 
1458
+ /**
1459
+ * Copyright (c) 2022, Salesforce, Inc.,
1460
+ * All rights reserved.
1461
+ * For full license text, see the LICENSE.txt file
1462
+ */
1463
+
1464
+ const API_NAMESPACE = 'UiApi';
1465
+ const RECORD_REPRESENTATION_NAME = 'RecordRepresentation';
1466
+ const RECORD_VIEW_ENTITY_REPRESENTATION_NAME = 'RecordViewEntityRepresentation';
1467
+ const RECORD_ID_PREFIX = `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME}:`;
1468
+ const RECORD_VIEW_ENTITY_ID_PREFIX = `${API_NAMESPACE}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME}:Name:`;
1469
+ const RECORD_FIELDS_KEY_JUNCTION = '__fields__';
1470
+ function isStoreKeyRecordId(key) {
1471
+ return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1;
1472
+ }
1473
+ function isStoreKeyRecordViewEntity(key) {
1474
+ return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) > -1 &&
1475
+ key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1);
1476
+ }
1477
+ function isStoreKeyRecordField(key) {
1478
+ return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) > -1;
1479
+ }
1480
+ function extractRecordIdFromStoreKey(key) {
1481
+ if (key === undefined ||
1482
+ (key.indexOf(RECORD_ID_PREFIX) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) === -1)) {
1483
+ return undefined;
1484
+ }
1485
+ const parts = key.split(':');
1486
+ return parts[parts.length - 1].split('_')[0];
1487
+ }
1488
+ function buildRecordFieldStoreKey(recordKey, fieldName) {
1489
+ return `${recordKey}${RECORD_FIELDS_KEY_JUNCTION}${fieldName}`;
1490
+ }
1491
+ function objectsDeepEqual(lhs, rhs) {
1492
+ if (lhs === rhs)
1493
+ return true;
1494
+ if (typeof lhs !== 'object' || typeof rhs !== 'object' || lhs === null || rhs === null)
1495
+ return false;
1496
+ const lhsKeys = Object.keys(lhs);
1497
+ const rhsKeys = Object.keys(rhs);
1498
+ if (lhsKeys.length !== rhsKeys.length)
1499
+ return false;
1500
+ for (let key of lhsKeys) {
1501
+ if (!rhsKeys.includes(key))
1502
+ return false;
1503
+ if (typeof lhs[key] === 'function' || typeof rhs[key] === 'function') {
1504
+ if (lhs[key].toString() !== rhs[key].toString())
1505
+ return false;
1506
+ }
1507
+ else {
1508
+ if (!objectsDeepEqual(lhs[key], rhs[key]))
1509
+ return false;
1510
+ }
1511
+ }
1512
+ return true;
1513
+ }
1514
+
1515
+ function isStoreRecordError(storeRecord) {
1516
+ return storeRecord.__type === 'error';
1517
+ }
1518
+ function isEntryDurableRecordRepresentation(entry, key) {
1519
+ // Either a DurableRecordRepresentation or StoreRecordError can live at a record key
1520
+ return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity(key)) &&
1521
+ entry.data.__type === undefined);
1522
+ }
1523
+
1458
1524
  /**
1459
1525
  * Copyright (c) 2022, Salesforce, Inc.,
1460
1526
  * All rights reserved.
@@ -4194,8 +4260,8 @@ function rootRecordQuery(selection, input) {
4194
4260
  // If there is no metadata for this query or it somehow lacks a timestamp
4195
4261
  // skip setting the root timestamp
4196
4262
  if (queryMetadata !== undefined && queryMetadata.ingestionTimestamp !== undefined) {
4197
- // subtract 10ms from timestamp to account for ingestion processing time
4198
- input.rootTimestamp = queryMetadata.ingestionTimestamp - 10;
4263
+ // subtract 1000ms from timestamp to account for ingestion processing time
4264
+ input.rootTimestamp = queryMetadata.ingestionTimestamp - 1000;
4199
4265
  }
4200
4266
  }
4201
4267
  return recordQuery(selection, alias, apiName, [], input);
@@ -4653,7 +4719,11 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
4653
4719
  try {
4654
4720
  const { data, seenRecords } = await queryEvaluator(rootQuery, context, eventEmitter);
4655
4721
  const rebuildWithStoreEval = ((originalSnapshot) => {
4656
- return storeEval(config, originalSnapshot, observers, connectionKeyBuilder);
4722
+ return storeEval(config, originalSnapshot, observers, connectionKeyBuilder).then((rebuiltSnapshot) => {
4723
+ return objectsDeepEqual(originalSnapshot.data, rebuiltSnapshot.data)
4724
+ ? originalSnapshot
4725
+ : rebuiltSnapshot;
4726
+ });
4657
4727
  });
4658
4728
  const recordId = generateUniqueRecordId$1();
4659
4729
  // if the non-eval'ed snapshot was an error then we return a synthetic
@@ -6613,49 +6683,6 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
6613
6683
  });
6614
6684
  }
6615
6685
 
6616
- /**
6617
- * Copyright (c) 2022, Salesforce, Inc.,
6618
- * All rights reserved.
6619
- * For full license text, see the LICENSE.txt file
6620
- */
6621
-
6622
- const API_NAMESPACE = 'UiApi';
6623
- const RECORD_REPRESENTATION_NAME = 'RecordRepresentation';
6624
- const RECORD_VIEW_ENTITY_REPRESENTATION_NAME = 'RecordViewEntityRepresentation';
6625
- const RECORD_ID_PREFIX = `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME}:`;
6626
- const RECORD_VIEW_ENTITY_ID_PREFIX = `${API_NAMESPACE}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME}:Name:`;
6627
- const RECORD_FIELDS_KEY_JUNCTION = '__fields__';
6628
- function isStoreKeyRecordId(key) {
6629
- return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1;
6630
- }
6631
- function isStoreKeyRecordViewEntity(key) {
6632
- return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) > -1 &&
6633
- key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1);
6634
- }
6635
- function isStoreKeyRecordField(key) {
6636
- return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) > -1;
6637
- }
6638
- function extractRecordIdFromStoreKey(key) {
6639
- if (key === undefined ||
6640
- (key.indexOf(RECORD_ID_PREFIX) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) === -1)) {
6641
- return undefined;
6642
- }
6643
- const parts = key.split(':');
6644
- return parts[parts.length - 1].split('_')[0];
6645
- }
6646
- function buildRecordFieldStoreKey(recordKey, fieldName) {
6647
- return `${recordKey}${RECORD_FIELDS_KEY_JUNCTION}${fieldName}`;
6648
- }
6649
-
6650
- function isStoreRecordError(storeRecord) {
6651
- return storeRecord.__type === 'error';
6652
- }
6653
- function isEntryDurableRecordRepresentation(entry, key) {
6654
- // Either a DurableRecordRepresentation or StoreRecordError can live at a record key
6655
- return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity(key)) &&
6656
- entry.data.__type === undefined);
6657
- }
6658
-
6659
6686
  function serializeFieldArguments(argumentNodes, variables) {
6660
6687
  const mutableArgumentNodes = Object.assign([], argumentNodes);
6661
6688
  return `args__(${mutableArgumentNodes
@@ -9072,8 +9099,8 @@ async function fetchIngestionTimeStampFromDatabase(apiName, info, args, query) {
9072
9099
  const results = await query(sql, [key]);
9073
9100
  const [timestamp] = results.rows.map((row) => row[0]);
9074
9101
  if (timestamp !== null && typeof timestamp === 'number') {
9075
- //go back 10 ms to adjust for margin of error when top level query is stored and when raml objects are stored
9076
- ingestionTimestamp = timestamp - 10;
9102
+ //go back 1000 ms to adjust for margin of error when top level query is stored and when raml objects are stored
9103
+ ingestionTimestamp = timestamp - 1000;
9077
9104
  }
9078
9105
  }
9079
9106
  return ingestionTimestamp;
@@ -9122,26 +9149,20 @@ function generateRecordQueries(objectInfos) {
9122
9149
  let recordConnections = ``;
9123
9150
  const polymorphicFieldTypeNames = new Set();
9124
9151
  let typedScalars = new Set();
9152
+ let parentRelationshipFields = new Set();
9125
9153
  for (const objectInfo of values$1(objectInfos)) {
9126
9154
  const { apiName, childRelationships } = objectInfo;
9127
9155
  let fields = ``;
9128
9156
  typedScalars.add(`${apiName}_Filter`);
9129
9157
  typedScalars.add(`${apiName}_OrderBy`);
9130
- for (const childRelationship of childRelationships) {
9131
- const { childObjectApiName } = childRelationship;
9132
- // Only add the relationship if there is relevant objectinfos for it,
9133
- // otherwise we'd be defining types we cannot satisfy and aren't referenced in
9134
- // the query.
9135
- if (objectInfos[childObjectApiName] !== undefined) {
9136
- fields += `${childRelationship.relationshipName}(first: Int, where: ${childObjectApiName}_Filter, orderBy: ${childObjectApiName}_OrderBy, scope: SupportedScopes): ${childObjectApiName}Connection \n`;
9137
- typedScalars.add(`${childObjectApiName}_Filter`);
9138
- typedScalars.add(`${childObjectApiName}_OrderBy`);
9139
- }
9140
- }
9141
9158
  for (const field of values$1(objectInfo.fields)) {
9142
9159
  if (!fieldsStaticallyAdded.includes(field.apiName)) {
9143
9160
  fields += `${field.apiName}: ${dataTypeToType(field.dataType, field.apiName)}\n`;
9144
9161
  }
9162
+ //handles parent relationship
9163
+ if (field.relationshipName === null) {
9164
+ continue;
9165
+ }
9145
9166
  // For spanning parent relationships with no union types
9146
9167
  if (field.referenceToInfos.length === 1) {
9147
9168
  const [relation] = field.referenceToInfos;
@@ -9149,11 +9170,13 @@ function generateRecordQueries(objectInfos) {
9149
9170
  // otherwise we'd be defining types we cannot satisfy and aren't referenced in
9150
9171
  // the query.
9151
9172
  if (objectInfos[relation.apiName] !== undefined) {
9173
+ parentRelationshipFields.add(field.relationshipName);
9152
9174
  fields += `${field.relationshipName}: ${relation.apiName}\n`;
9153
9175
  }
9154
9176
  // For polymorphic field, its type is 'Record' inteface. The concrete entity type name is saved for field resolving of next phase
9155
9177
  }
9156
9178
  else if (field.referenceToInfos.length > 1) {
9179
+ parentRelationshipFields.add(field.relationshipName);
9157
9180
  fields += `${field.relationshipName}: Record\n`;
9158
9181
  for (const relation of field.referenceToInfos) {
9159
9182
  if (objectInfos[relation.apiName] !== undefined) {
@@ -9162,6 +9185,20 @@ function generateRecordQueries(objectInfos) {
9162
9185
  }
9163
9186
  }
9164
9187
  }
9188
+ // handles child relationship
9189
+ for (const childRelationship of childRelationships) {
9190
+ const { childObjectApiName } = childRelationship;
9191
+ // Only add the relationship if there is relevant objectinfos for it,
9192
+ // otherwise we'd be defining types we cannot satisfy and aren't referenced in
9193
+ // the query.
9194
+ // If one field has both parent relationship and child relationship with the same name, the child relationship is ignored. This is how the server GQL has implemented as date of 08/07/2023
9195
+ if (objectInfos[childObjectApiName] !== undefined &&
9196
+ !parentRelationshipFields.has(childRelationship.relationshipName)) {
9197
+ fields += `${childRelationship.relationshipName}(first: Int, where: ${childObjectApiName}_Filter, orderBy: ${childObjectApiName}_OrderBy, scope: SupportedScopes): ${childObjectApiName}Connection \n`;
9198
+ typedScalars.add(`${childObjectApiName}_Filter`);
9199
+ typedScalars.add(`${childObjectApiName}_OrderBy`);
9200
+ }
9201
+ }
9165
9202
  recordQueries += `${apiName}(first: Int, where: ${apiName}_Filter, orderBy: ${apiName}_OrderBy, scope: SupportedScopes): ${apiName}Connection\n`;
9166
9203
  const isServiceAppointment = apiName === 'ServiceAppointment';
9167
9204
  recordConnections += /* GraphQL */ `
@@ -12826,6 +12863,9 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
12826
12863
  if (!rebuildResult.errors) {
12827
12864
  rebuildResult = removeSyntheticFields(rebuildResult, config.query);
12828
12865
  }
12866
+ if (objectsDeepEqual(rebuildResult, originalSnapshot.data)) {
12867
+ return originalSnapshot;
12868
+ }
12829
12869
  // 'originalSnapshot' is the local eval snapshot subscribed. It is always in 'Fulfilled' state. This behavior would change once W-1273462(rebuild non-evaluated snapshot when the graphql local eval rebuild is triggered) is resolved.
12830
12870
  return {
12831
12871
  ...originalSnapshot,
@@ -16731,4 +16771,4 @@ register({
16731
16771
  });
16732
16772
 
16733
16773
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
16734
- // version: 1.228.1-4e6356f71
16774
+ // version: 1.229.0-dev2-e9832aaff
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.228.1",
3
+ "version": "1.229.0-dev2",
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": "*",
36
- "@salesforce/lds-bindings": "*",
37
- "@salesforce/lds-instrumentation": "*",
38
- "@salesforce/lds-priming": "*",
35
+ "@salesforce/lds-adapters-uiapi": "1.229.0-dev2",
36
+ "@salesforce/lds-bindings": "1.229.0-dev2",
37
+ "@salesforce/lds-instrumentation": "1.229.0-dev2",
38
+ "@salesforce/lds-priming": "1.229.0-dev2",
39
39
  "@salesforce/user": "0.0.21",
40
40
  "o11y": "244.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-graphql": "*",
44
- "@salesforce/lds-drafts": "*",
45
- "@salesforce/lds-drafts-adapters-uiapi": "*",
46
- "@salesforce/lds-graphql-eval": "*",
47
- "@salesforce/lds-network-adapter": "*",
48
- "@salesforce/lds-network-nimbus": "*",
49
- "@salesforce/lds-store-nimbus": "*",
50
- "@salesforce/lds-store-binary": "*",
51
- "@salesforce/lds-store-sql": "*",
52
- "@salesforce/lds-utils-adapters": "*",
53
- "@salesforce/nimbus-plugin-lds": "*",
43
+ "@salesforce/lds-adapters-graphql": "1.229.0-dev2",
44
+ "@salesforce/lds-drafts": "1.229.0-dev2",
45
+ "@salesforce/lds-drafts-adapters-uiapi": "1.229.0-dev2",
46
+ "@salesforce/lds-graphql-eval": "1.229.0-dev2",
47
+ "@salesforce/lds-network-adapter": "1.229.0-dev2",
48
+ "@salesforce/lds-network-nimbus": "1.229.0-dev2",
49
+ "@salesforce/lds-store-binary": "1.229.0-dev2",
50
+ "@salesforce/lds-store-nimbus": "1.229.0-dev2",
51
+ "@salesforce/lds-store-sql": "1.229.0-dev2",
52
+ "@salesforce/lds-utils-adapters": "1.229.0-dev2",
53
+ "@salesforce/nimbus-plugin-lds": "1.229.0-dev2",
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
@@ -1455,6 +1455,72 @@ function makeDurable(environment, { durableStore, instrumentation }) {
1455
1455
  });
1456
1456
  }
1457
1457
 
1458
+ /**
1459
+ * Copyright (c) 2022, Salesforce, Inc.,
1460
+ * All rights reserved.
1461
+ * For full license text, see the LICENSE.txt file
1462
+ */
1463
+
1464
+ const API_NAMESPACE = 'UiApi';
1465
+ const RECORD_REPRESENTATION_NAME = 'RecordRepresentation';
1466
+ const RECORD_VIEW_ENTITY_REPRESENTATION_NAME = 'RecordViewEntityRepresentation';
1467
+ const RECORD_ID_PREFIX = `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME}:`;
1468
+ const RECORD_VIEW_ENTITY_ID_PREFIX = `${API_NAMESPACE}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME}:Name:`;
1469
+ const RECORD_FIELDS_KEY_JUNCTION = '__fields__';
1470
+ function isStoreKeyRecordId(key) {
1471
+ return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1;
1472
+ }
1473
+ function isStoreKeyRecordViewEntity(key) {
1474
+ return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) > -1 &&
1475
+ key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1);
1476
+ }
1477
+ function isStoreKeyRecordField(key) {
1478
+ return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) > -1;
1479
+ }
1480
+ function extractRecordIdFromStoreKey(key) {
1481
+ if (key === undefined ||
1482
+ (key.indexOf(RECORD_ID_PREFIX) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) === -1)) {
1483
+ return undefined;
1484
+ }
1485
+ const parts = key.split(':');
1486
+ return parts[parts.length - 1].split('_')[0];
1487
+ }
1488
+ function buildRecordFieldStoreKey(recordKey, fieldName) {
1489
+ return `${recordKey}${RECORD_FIELDS_KEY_JUNCTION}${fieldName}`;
1490
+ }
1491
+ function objectsDeepEqual(lhs, rhs) {
1492
+ if (lhs === rhs)
1493
+ return true;
1494
+ if (typeof lhs !== 'object' || typeof rhs !== 'object' || lhs === null || rhs === null)
1495
+ return false;
1496
+ const lhsKeys = Object.keys(lhs);
1497
+ const rhsKeys = Object.keys(rhs);
1498
+ if (lhsKeys.length !== rhsKeys.length)
1499
+ return false;
1500
+ for (let key of lhsKeys) {
1501
+ if (!rhsKeys.includes(key))
1502
+ return false;
1503
+ if (typeof lhs[key] === 'function' || typeof rhs[key] === 'function') {
1504
+ if (lhs[key].toString() !== rhs[key].toString())
1505
+ return false;
1506
+ }
1507
+ else {
1508
+ if (!objectsDeepEqual(lhs[key], rhs[key]))
1509
+ return false;
1510
+ }
1511
+ }
1512
+ return true;
1513
+ }
1514
+
1515
+ function isStoreRecordError(storeRecord) {
1516
+ return storeRecord.__type === 'error';
1517
+ }
1518
+ function isEntryDurableRecordRepresentation(entry, key) {
1519
+ // Either a DurableRecordRepresentation or StoreRecordError can live at a record key
1520
+ return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity(key)) &&
1521
+ entry.data.__type === undefined);
1522
+ }
1523
+
1458
1524
  /**
1459
1525
  * Copyright (c) 2022, Salesforce, Inc.,
1460
1526
  * All rights reserved.
@@ -4194,8 +4260,8 @@ function rootRecordQuery(selection, input) {
4194
4260
  // If there is no metadata for this query or it somehow lacks a timestamp
4195
4261
  // skip setting the root timestamp
4196
4262
  if (queryMetadata !== undefined && queryMetadata.ingestionTimestamp !== undefined) {
4197
- // subtract 10ms from timestamp to account for ingestion processing time
4198
- input.rootTimestamp = queryMetadata.ingestionTimestamp - 10;
4263
+ // subtract 1000ms from timestamp to account for ingestion processing time
4264
+ input.rootTimestamp = queryMetadata.ingestionTimestamp - 1000;
4199
4265
  }
4200
4266
  }
4201
4267
  return recordQuery(selection, alias, apiName, [], input);
@@ -4653,7 +4719,11 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
4653
4719
  try {
4654
4720
  const { data, seenRecords } = await queryEvaluator(rootQuery, context, eventEmitter);
4655
4721
  const rebuildWithStoreEval = ((originalSnapshot) => {
4656
- return storeEval(config, originalSnapshot, observers, connectionKeyBuilder);
4722
+ return storeEval(config, originalSnapshot, observers, connectionKeyBuilder).then((rebuiltSnapshot) => {
4723
+ return objectsDeepEqual(originalSnapshot.data, rebuiltSnapshot.data)
4724
+ ? originalSnapshot
4725
+ : rebuiltSnapshot;
4726
+ });
4657
4727
  });
4658
4728
  const recordId = generateUniqueRecordId$1();
4659
4729
  // if the non-eval'ed snapshot was an error then we return a synthetic
@@ -6613,49 +6683,6 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
6613
6683
  });
6614
6684
  }
6615
6685
 
6616
- /**
6617
- * Copyright (c) 2022, Salesforce, Inc.,
6618
- * All rights reserved.
6619
- * For full license text, see the LICENSE.txt file
6620
- */
6621
-
6622
- const API_NAMESPACE = 'UiApi';
6623
- const RECORD_REPRESENTATION_NAME = 'RecordRepresentation';
6624
- const RECORD_VIEW_ENTITY_REPRESENTATION_NAME = 'RecordViewEntityRepresentation';
6625
- const RECORD_ID_PREFIX = `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME}:`;
6626
- const RECORD_VIEW_ENTITY_ID_PREFIX = `${API_NAMESPACE}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME}:Name:`;
6627
- const RECORD_FIELDS_KEY_JUNCTION = '__fields__';
6628
- function isStoreKeyRecordId(key) {
6629
- return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1;
6630
- }
6631
- function isStoreKeyRecordViewEntity(key) {
6632
- return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) > -1 &&
6633
- key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1);
6634
- }
6635
- function isStoreKeyRecordField(key) {
6636
- return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) > -1;
6637
- }
6638
- function extractRecordIdFromStoreKey(key) {
6639
- if (key === undefined ||
6640
- (key.indexOf(RECORD_ID_PREFIX) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) === -1)) {
6641
- return undefined;
6642
- }
6643
- const parts = key.split(':');
6644
- return parts[parts.length - 1].split('_')[0];
6645
- }
6646
- function buildRecordFieldStoreKey(recordKey, fieldName) {
6647
- return `${recordKey}${RECORD_FIELDS_KEY_JUNCTION}${fieldName}`;
6648
- }
6649
-
6650
- function isStoreRecordError(storeRecord) {
6651
- return storeRecord.__type === 'error';
6652
- }
6653
- function isEntryDurableRecordRepresentation(entry, key) {
6654
- // Either a DurableRecordRepresentation or StoreRecordError can live at a record key
6655
- return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity(key)) &&
6656
- entry.data.__type === undefined);
6657
- }
6658
-
6659
6686
  function serializeFieldArguments(argumentNodes, variables) {
6660
6687
  const mutableArgumentNodes = Object.assign([], argumentNodes);
6661
6688
  return `args__(${mutableArgumentNodes
@@ -9072,8 +9099,8 @@ async function fetchIngestionTimeStampFromDatabase(apiName, info, args, query) {
9072
9099
  const results = await query(sql, [key]);
9073
9100
  const [timestamp] = results.rows.map((row) => row[0]);
9074
9101
  if (timestamp !== null && typeof timestamp === 'number') {
9075
- //go back 10 ms to adjust for margin of error when top level query is stored and when raml objects are stored
9076
- ingestionTimestamp = timestamp - 10;
9102
+ //go back 1000 ms to adjust for margin of error when top level query is stored and when raml objects are stored
9103
+ ingestionTimestamp = timestamp - 1000;
9077
9104
  }
9078
9105
  }
9079
9106
  return ingestionTimestamp;
@@ -9122,26 +9149,20 @@ function generateRecordQueries(objectInfos) {
9122
9149
  let recordConnections = ``;
9123
9150
  const polymorphicFieldTypeNames = new Set();
9124
9151
  let typedScalars = new Set();
9152
+ let parentRelationshipFields = new Set();
9125
9153
  for (const objectInfo of values$1(objectInfos)) {
9126
9154
  const { apiName, childRelationships } = objectInfo;
9127
9155
  let fields = ``;
9128
9156
  typedScalars.add(`${apiName}_Filter`);
9129
9157
  typedScalars.add(`${apiName}_OrderBy`);
9130
- for (const childRelationship of childRelationships) {
9131
- const { childObjectApiName } = childRelationship;
9132
- // Only add the relationship if there is relevant objectinfos for it,
9133
- // otherwise we'd be defining types we cannot satisfy and aren't referenced in
9134
- // the query.
9135
- if (objectInfos[childObjectApiName] !== undefined) {
9136
- fields += `${childRelationship.relationshipName}(first: Int, where: ${childObjectApiName}_Filter, orderBy: ${childObjectApiName}_OrderBy, scope: SupportedScopes): ${childObjectApiName}Connection \n`;
9137
- typedScalars.add(`${childObjectApiName}_Filter`);
9138
- typedScalars.add(`${childObjectApiName}_OrderBy`);
9139
- }
9140
- }
9141
9158
  for (const field of values$1(objectInfo.fields)) {
9142
9159
  if (!fieldsStaticallyAdded.includes(field.apiName)) {
9143
9160
  fields += `${field.apiName}: ${dataTypeToType(field.dataType, field.apiName)}\n`;
9144
9161
  }
9162
+ //handles parent relationship
9163
+ if (field.relationshipName === null) {
9164
+ continue;
9165
+ }
9145
9166
  // For spanning parent relationships with no union types
9146
9167
  if (field.referenceToInfos.length === 1) {
9147
9168
  const [relation] = field.referenceToInfos;
@@ -9149,11 +9170,13 @@ function generateRecordQueries(objectInfos) {
9149
9170
  // otherwise we'd be defining types we cannot satisfy and aren't referenced in
9150
9171
  // the query.
9151
9172
  if (objectInfos[relation.apiName] !== undefined) {
9173
+ parentRelationshipFields.add(field.relationshipName);
9152
9174
  fields += `${field.relationshipName}: ${relation.apiName}\n`;
9153
9175
  }
9154
9176
  // For polymorphic field, its type is 'Record' inteface. The concrete entity type name is saved for field resolving of next phase
9155
9177
  }
9156
9178
  else if (field.referenceToInfos.length > 1) {
9179
+ parentRelationshipFields.add(field.relationshipName);
9157
9180
  fields += `${field.relationshipName}: Record\n`;
9158
9181
  for (const relation of field.referenceToInfos) {
9159
9182
  if (objectInfos[relation.apiName] !== undefined) {
@@ -9162,6 +9185,20 @@ function generateRecordQueries(objectInfos) {
9162
9185
  }
9163
9186
  }
9164
9187
  }
9188
+ // handles child relationship
9189
+ for (const childRelationship of childRelationships) {
9190
+ const { childObjectApiName } = childRelationship;
9191
+ // Only add the relationship if there is relevant objectinfos for it,
9192
+ // otherwise we'd be defining types we cannot satisfy and aren't referenced in
9193
+ // the query.
9194
+ // If one field has both parent relationship and child relationship with the same name, the child relationship is ignored. This is how the server GQL has implemented as date of 08/07/2023
9195
+ if (objectInfos[childObjectApiName] !== undefined &&
9196
+ !parentRelationshipFields.has(childRelationship.relationshipName)) {
9197
+ fields += `${childRelationship.relationshipName}(first: Int, where: ${childObjectApiName}_Filter, orderBy: ${childObjectApiName}_OrderBy, scope: SupportedScopes): ${childObjectApiName}Connection \n`;
9198
+ typedScalars.add(`${childObjectApiName}_Filter`);
9199
+ typedScalars.add(`${childObjectApiName}_OrderBy`);
9200
+ }
9201
+ }
9165
9202
  recordQueries += `${apiName}(first: Int, where: ${apiName}_Filter, orderBy: ${apiName}_OrderBy, scope: SupportedScopes): ${apiName}Connection\n`;
9166
9203
  const isServiceAppointment = apiName === 'ServiceAppointment';
9167
9204
  recordConnections += /* GraphQL */ `
@@ -12826,6 +12863,9 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
12826
12863
  if (!rebuildResult.errors) {
12827
12864
  rebuildResult = removeSyntheticFields(rebuildResult, config.query);
12828
12865
  }
12866
+ if (objectsDeepEqual(rebuildResult, originalSnapshot.data)) {
12867
+ return originalSnapshot;
12868
+ }
12829
12869
  // 'originalSnapshot' is the local eval snapshot subscribed. It is always in 'Fulfilled' state. This behavior would change once W-1273462(rebuild non-evaluated snapshot when the graphql local eval rebuild is triggered) is resolved.
12830
12870
  return {
12831
12871
  ...originalSnapshot,
@@ -16731,4 +16771,4 @@ register({
16731
16771
  });
16732
16772
 
16733
16773
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
16734
- // version: 1.228.1-4e6356f71
16774
+ // version: 1.229.0-dev2-e9832aaff