@salesforce/lds-ads-bridge 1.309.0-dev14 → 1.309.0-dev16

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.
@@ -433,7 +433,7 @@ function createResourceParamsImpl(config, configMetadata) {
433
433
  }
434
434
  return resourceParams;
435
435
  }
436
- // engine version: 0.156.4-dev1-8df86bf0
436
+ // engine version: 0.156.4-dev2-78889b7e
437
437
 
438
438
  /**
439
439
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -481,7 +481,7 @@ const callbacks$1 = [];
481
481
  function register(r) {
482
482
  callbacks$1.forEach((callback) => callback(r));
483
483
  }
484
- // version: 1.309.0-dev14-eec35cd428
484
+ // version: 1.309.0-dev16-7409c81567
485
485
 
486
486
  /**
487
487
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -4976,7 +4976,7 @@ function toSortedStringArray(value) {
4976
4976
  }
4977
4977
 
4978
4978
  const VERSION$2L = "d1e589a127fb1060c89070cdb6f500b2";
4979
- function validate$1$(obj, path = 'RecordTypeInfoRepresentation') {
4979
+ function validate$20(obj, path = 'RecordTypeInfoRepresentation') {
4980
4980
  const v_error = (() => {
4981
4981
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
4982
4982
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -5068,7 +5068,7 @@ function equals$1a(existing, incoming) {
5068
5068
  }
5069
5069
 
5070
5070
  const VERSION$2K = "195d918987a35f45e1aa4dce9a11d8c5";
5071
- function validate$1_(obj, path = 'FieldValueRepresentation') {
5071
+ function validate$1$(obj, path = 'FieldValueRepresentation') {
5072
5072
  const v_error = (() => {
5073
5073
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
5074
5074
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -5237,7 +5237,7 @@ const getTypeCacheKeys$2l = (rootKeySet, luvio, input, _fullPathFactory) => {
5237
5237
 
5238
5238
  const TTL$G = 120000;
5239
5239
  const VERSION$2J = "79cb5ac9f44542f683d00245fdfe500d";
5240
- function validate$1Z(obj, path = 'RecordCollectionRepresentation') {
5240
+ function validate$1_(obj, path = 'RecordCollectionRepresentation') {
5241
5241
  const v_error = (() => {
5242
5242
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
5243
5243
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -5510,7 +5510,7 @@ function equals$18(existing, incoming) {
5510
5510
  }
5511
5511
  const ingest$2h = function RecordCollectionRepresentationIngest(input, path, luvio, store, timestamp) {
5512
5512
  if (process.env.NODE_ENV !== 'production') {
5513
- const validateError = validate$1Z(input);
5513
+ const validateError = validate$1_(input);
5514
5514
  if (validateError !== null) {
5515
5515
  throw validateError;
5516
5516
  }
@@ -5546,7 +5546,7 @@ const keyBuilderFromType$E = function RecordRepresentationKeyBuilderFromType(luv
5546
5546
 
5547
5547
  const TTL$F = 30000;
5548
5548
  const VERSION$2I = "98c5b18512e48ca8d28727549507e4ba";
5549
- function validate$1Y(obj, path = 'RecordRepresentation') {
5549
+ function validate$1Z(obj, path = 'RecordRepresentation') {
5550
5550
  const v_error = (() => {
5551
5551
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
5552
5552
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -5676,7 +5676,7 @@ function validate$1Y(obj, path = 'RecordRepresentation') {
5676
5676
  const path_recordTypeInfo = path + '.recordTypeInfo';
5677
5677
  let obj_recordTypeInfo_union0 = null;
5678
5678
  const obj_recordTypeInfo_union0_error = (() => {
5679
- const referencepath_recordTypeInfoValidationError = validate$1$(obj_recordTypeInfo, path_recordTypeInfo);
5679
+ const referencepath_recordTypeInfoValidationError = validate$20(obj_recordTypeInfo, path_recordTypeInfo);
5680
5680
  if (referencepath_recordTypeInfoValidationError !== null) {
5681
5681
  let message = 'Object doesn\'t match RecordTypeInfoRepresentation (at "' + path_recordTypeInfo + '")\n';
5682
5682
  message += referencepath_recordTypeInfoValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -7573,7 +7573,7 @@ const RECORD_REPRESENTATION_ERROR_STORE_METADATA_PARAMS = {
7573
7573
  version: RECORD_REPRESENTATION_ERROR_VERSION,
7574
7574
  };
7575
7575
  function isGraphNode$1(node) {
7576
- return node !== null && node.type === 'Node';
7576
+ return !!node && node.type === 'Node';
7577
7577
  }
7578
7578
  function addScalarFieldId(current) {
7579
7579
  addScalarField(current, 'Id');
@@ -7640,6 +7640,8 @@ function extractTrackedFieldsToTrie(recordId, node, root, config, visitedRecordI
7640
7640
  const spanning = spanningLink.follow();
7641
7641
  // W-8058425, do not include external lookups added by getTrackedFields
7642
7642
  if (isExternalLookupFieldKey(spanning)) {
7643
+ // NOTE: the logic to get here is mimicked in RecordRepresentation/merge::mergePendingFields as of
7644
+ // W-11899329 due to issues with external lookups being marked pending but never fetched
7643
7645
  continue;
7644
7646
  }
7645
7647
  extractTrackedFieldsToTrie(spanningLink.data.__ref, spanning, next, config, spanningVisitedRecordIds, depth + 1);
@@ -7672,6 +7674,8 @@ function extractTrackedFieldsToTrie(recordId, node, root, config, visitedRecordI
7672
7674
  const { fields } = state;
7673
7675
  // W-8058425, do not include external lookups added by getTrackedFields
7674
7676
  if (includes.call(fields, 'ExternalId')) {
7677
+ // NOTE: the logic to get here is mimicked in RecordRepresentation/merge::mergePendingFields as of
7678
+ // W-11899329 due to issues with external lookups being marked pending but never fetched
7675
7679
  continue;
7676
7680
  }
7677
7681
  for (let s = 0, len = fields.length; s < len; s += 1) {
@@ -7883,15 +7887,49 @@ function isSuperRecordFieldTrie(a, b) {
7883
7887
 
7884
7888
  // This function sets fields that we are refreshing to pending
7885
7889
  // These values will go into the store
7886
- function mergePendingFields(newRecord, oldRecord) {
7887
- // TODO [W-6900046]: avoid casting to any by updating
7888
- // RecordRepresentationNormalized['fields'] to include `pending:true` property
7890
+ function mergePendingFields(newRecord, oldRecord, existingNode) {
7889
7891
  const mergedFields = { ...newRecord.fields };
7890
7892
  const merged = { ...newRecord, fields: mergedFields };
7891
7893
  const existingFields = keys$1(oldRecord.fields);
7892
7894
  for (let i = 0, len = existingFields.length; i < len; i += 1) {
7893
7895
  const spanningFieldName = existingFields[i];
7894
7896
  if (newRecord.fields[spanningFieldName] === undefined) {
7897
+ /*
7898
+ * Per W-8058425 external lookups fields are excluded from the tracked fields. However, as covered in
7899
+ * W-11899329, situations can arise in which a merge conflict occurs when the existing record has a
7900
+ * reference to an external lookup field. The exclusion ultimately results in a snapshot stuck in the
7901
+ * pending state. This is an approach to prevent that situation.
7902
+ *
7903
+ * The same logic checks for W-8058425 to "continue" as it relates to not tracking external lookups is
7904
+ * mimicked here as it relates to not marking them as pending.
7905
+ */
7906
+ // make sure external lookups are NOT marked as pending when `existingNode` is provided
7907
+ if (isGraphNode$1(existingNode)) {
7908
+ // get the node for the spanning field
7909
+ const fieldValueRep = existingNode
7910
+ .object('fields')
7911
+ .link(spanningFieldName);
7912
+ const field = fieldValueRep.follow();
7913
+ if (isGraphNode$1(field)) {
7914
+ if (field.isScalar('value') === false) {
7915
+ const record = field
7916
+ .link('value')
7917
+ .follow();
7918
+ if (isExternalLookupFieldKey(record)) {
7919
+ continue;
7920
+ }
7921
+ }
7922
+ }
7923
+ else {
7924
+ const state = fieldValueRep.linkData();
7925
+ if (state !== undefined) {
7926
+ const { fields } = state;
7927
+ if (includes.call(fields, 'ExternalId')) {
7928
+ continue;
7929
+ }
7930
+ }
7931
+ }
7932
+ }
7895
7933
  // TODO [W-6900046]: fix above casting issue so we're not stuffing arbitrary things
7896
7934
  // into RecordRepresentationNormalized['fields']
7897
7935
  mergedFields[spanningFieldName] = {
@@ -7905,7 +7943,7 @@ function mergePendingFields(newRecord, oldRecord) {
7905
7943
  // This method gets called
7906
7944
  // when incoming record has a higher version
7907
7945
  // than the record that is currently in the store
7908
- function mergeAndRefreshHigherVersionRecord(incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap) {
7946
+ function mergeAndRefreshHigherVersionRecord(incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap, existingNode) {
7909
7947
  // If the higher version (incoming) does not contain a superset of fields as existing
7910
7948
  // then we need to refresh to get updated versions of fields in existing
7911
7949
  if (isSuperRecordFieldTrie(incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot) ===
@@ -7922,14 +7960,14 @@ function mergeAndRefreshHigherVersionRecord(incoming, existing, incomingTrackedF
7922
7960
  };
7923
7961
  // We want to mark fields in the store as pending
7924
7962
  // Because we don't want to emit any data to components
7925
- return mergePendingFields(incoming, existing);
7963
+ return mergePendingFields(incoming, existing, existingNode);
7926
7964
  }
7927
7965
  return incoming;
7928
7966
  }
7929
7967
  // This method gets called
7930
7968
  // when incoming record has a lower version
7931
7969
  // than the record that is currently in the store
7932
- function mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap) {
7970
+ function mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap, existingNode) {
7933
7971
  // If the higher version (existing) does not have a superset of fields as incoming
7934
7972
  // then we need to refresh to get updated versions of fields on incoming
7935
7973
  if (isSuperRecordFieldTrie(existingTrackedFieldsTrieRoot, incomingTrackedFieldsTrieRoot) ===
@@ -7939,7 +7977,7 @@ function mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTr
7939
7977
  if (isSupportedEntity(incoming.apiName) === false) {
7940
7978
  return mergeRecordFields(existing, incoming);
7941
7979
  }
7942
- const merged = mergePendingFields(existing, incoming);
7980
+ const merged = mergePendingFields(existing, incoming, existingNode);
7943
7981
  // update the conflict map to resolve the record conflict in resolveConflict
7944
7982
  if (recordConflictMap) {
7945
7983
  recordConflictMap.conflicts[incoming.id] = {
@@ -7978,7 +8016,7 @@ function mergeRecordConflict(luvio, incoming, existing, recordConflictMap) {
7978
8016
  extractTrackedFieldsToTrie(recordKey, incomingNode, incomingTrackedFieldsTrieRoot, trackedFieldsConfig);
7979
8017
  extractTrackedFieldsToTrie(recordKey, existingNode, existingTrackedFieldsTrieRoot, trackedFieldsConfig);
7980
8018
  if (incoming.weakEtag > existing.weakEtag) {
7981
- return mergeAndRefreshHigherVersionRecord(incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap);
8019
+ return mergeAndRefreshHigherVersionRecord(incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap, existingNode);
7982
8020
  }
7983
8021
  return mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap);
7984
8022
  }
@@ -8134,7 +8172,7 @@ function normalize$S(input, existing, path, luvio, store, timestamp, fieldsTrie,
8134
8172
  function makeIngest(fieldsTrie, optionalFieldsTrie, recordConflictMap) {
8135
8173
  return (input, path, luvio, store, timestamp) => {
8136
8174
  if (process.env.NODE_ENV !== 'production') {
8137
- const validateError = validate$1_(input);
8175
+ const validateError = validate$1$(input);
8138
8176
  if (validateError !== null) {
8139
8177
  throw validateError;
8140
8178
  }
@@ -8227,7 +8265,7 @@ const createRecordIngest = (fieldsTrie, optionalFieldsTrie, recordConflictMap) =
8227
8265
  const childNormalize = createChildRecordNormalize(fieldsTrie, optionalFieldsTrie, recordConflictMap);
8228
8266
  return (input, path, luvio, store, timestamp) => {
8229
8267
  if (process.env.NODE_ENV !== 'production') {
8230
- const validateError = validate$1Y(input);
8268
+ const validateError = validate$1Z(input);
8231
8269
  if (validateError !== null) {
8232
8270
  throw validateError;
8233
8271
  }
package/dist/adsBridge.js CHANGED
@@ -367,4 +367,4 @@ function withAdsBridge(callback) {
367
367
  }
368
368
 
369
369
  export { instrument, withAdsBridge };
370
- // version: 1.309.0-dev14-eec35cd428
370
+ // version: 1.309.0-dev16-7409c81567
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-ads-bridge",
3
- "version": "1.309.0-dev14",
3
+ "version": "1.309.0-dev16",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "Bridge to sync data between LDS and ADS",
6
6
  "main": "dist/adsBridge.js",
@@ -30,8 +30,8 @@
30
30
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-ads-bridge"
31
31
  },
32
32
  "devDependencies": {
33
- "@salesforce/lds-adapters-uiapi": "^1.309.0-dev14",
34
- "@salesforce/lds-uiapi-record-utils-mobile": "^1.309.0-dev14"
33
+ "@salesforce/lds-adapters-uiapi": "^1.309.0-dev16",
34
+ "@salesforce/lds-uiapi-record-utils-mobile": "^1.309.0-dev16"
35
35
  },
36
36
  "volta": {
37
37
  "extends": "../../package.json"