@salesforce/lwc-adapters-uiapi 1.320.0 → 1.322.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 (2) hide show
  1. package/dist/main.js +97 -33
  2. package/package.json +4 -4
package/dist/main.js CHANGED
@@ -572,7 +572,7 @@ function createResourceParamsImpl(config, configMetadata) {
572
572
  }
573
573
  return resourceParams;
574
574
  }
575
- // engine version: 0.156.4-a259372b
575
+ // engine version: 0.156.5-f5fd8c7a
576
576
 
577
577
  /**
578
578
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -12156,7 +12156,7 @@ const RECORD_REPRESENTATION_ERROR_STORE_METADATA_PARAMS = {
12156
12156
  version: RECORD_REPRESENTATION_ERROR_VERSION,
12157
12157
  };
12158
12158
  function isGraphNode(node) {
12159
- return node !== null && node.type === 'Node';
12159
+ return !!node && node.type === 'Node';
12160
12160
  }
12161
12161
  function addScalarFieldId(current) {
12162
12162
  addScalarField(current, 'Id');
@@ -12223,6 +12223,8 @@ function extractTrackedFieldsToTrie(recordId, node, root, config, visitedRecordI
12223
12223
  const spanning = spanningLink.follow();
12224
12224
  // W-8058425, do not include external lookups added by getTrackedFields
12225
12225
  if (isExternalLookupFieldKey(spanning)) {
12226
+ // NOTE: the logic to get here is mimicked in RecordRepresentation/merge::mergePendingFields as of
12227
+ // W-11899329 due to issues with external lookups being marked pending but never fetched
12226
12228
  continue;
12227
12229
  }
12228
12230
  extractTrackedFieldsToTrie(spanningLink.data.__ref, spanning, next, config, spanningVisitedRecordIds, depth + 1);
@@ -12255,6 +12257,8 @@ function extractTrackedFieldsToTrie(recordId, node, root, config, visitedRecordI
12255
12257
  const { fields } = state;
12256
12258
  // W-8058425, do not include external lookups added by getTrackedFields
12257
12259
  if (includes.call(fields, 'ExternalId')) {
12260
+ // NOTE: the logic to get here is mimicked in RecordRepresentation/merge::mergePendingFields as of
12261
+ // W-11899329 due to issues with external lookups being marked pending but never fetched
12258
12262
  continue;
12259
12263
  }
12260
12264
  for (let s = 0, len = fields.length; s < len; s += 1) {
@@ -12705,15 +12709,49 @@ function ingestRecordResponse(luvio, response, recordId, recordIngest, conflictM
12705
12709
 
12706
12710
  // This function sets fields that we are refreshing to pending
12707
12711
  // These values will go into the store
12708
- function mergePendingFields(newRecord, oldRecord) {
12709
- // TODO [W-6900046]: avoid casting to any by updating
12710
- // RecordRepresentationNormalized['fields'] to include `pending:true` property
12712
+ function mergePendingFields(newRecord, oldRecord, existingNode) {
12711
12713
  const mergedFields = { ...newRecord.fields };
12712
12714
  const merged = { ...newRecord, fields: mergedFields };
12713
12715
  const existingFields = keys(oldRecord.fields);
12714
12716
  for (let i = 0, len = existingFields.length; i < len; i += 1) {
12715
12717
  const spanningFieldName = existingFields[i];
12716
12718
  if (newRecord.fields[spanningFieldName] === undefined) {
12719
+ /*
12720
+ * Per W-8058425 external lookups fields are excluded from the tracked fields. However, as covered in
12721
+ * W-11899329, situations can arise in which a merge conflict occurs when the existing record has a
12722
+ * reference to an external lookup field. The exclusion ultimately results in a snapshot stuck in the
12723
+ * pending state. This is an approach to prevent that situation.
12724
+ *
12725
+ * The same logic checks for W-8058425 to "continue" as it relates to not tracking external lookups is
12726
+ * mimicked here as it relates to not marking them as pending.
12727
+ */
12728
+ // make sure external lookups are NOT marked as pending when `existingNode` is provided
12729
+ if (isGraphNode(existingNode)) {
12730
+ // get the node for the spanning field
12731
+ const fieldValueRep = existingNode
12732
+ .object('fields')
12733
+ .link(spanningFieldName);
12734
+ const field = fieldValueRep.follow();
12735
+ if (isGraphNode(field)) {
12736
+ if (field.isScalar('value') === false) {
12737
+ const record = field
12738
+ .link('value')
12739
+ .follow();
12740
+ if (isExternalLookupFieldKey(record)) {
12741
+ continue;
12742
+ }
12743
+ }
12744
+ }
12745
+ else {
12746
+ const state = fieldValueRep.linkData();
12747
+ if (state !== undefined) {
12748
+ const { fields } = state;
12749
+ if (includes.call(fields, 'ExternalId')) {
12750
+ continue;
12751
+ }
12752
+ }
12753
+ }
12754
+ }
12717
12755
  // TODO [W-6900046]: fix above casting issue so we're not stuffing arbitrary things
12718
12756
  // into RecordRepresentationNormalized['fields']
12719
12757
  mergedFields[spanningFieldName] = {
@@ -12727,7 +12765,7 @@ function mergePendingFields(newRecord, oldRecord) {
12727
12765
  // This method gets called
12728
12766
  // when incoming record has a higher version
12729
12767
  // than the record that is currently in the store
12730
- function mergeAndRefreshHigherVersionRecord(incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap) {
12768
+ function mergeAndRefreshHigherVersionRecord(incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap, existingNode) {
12731
12769
  // If the higher version (incoming) does not contain a superset of fields as existing
12732
12770
  // then we need to refresh to get updated versions of fields in existing
12733
12771
  if (isSuperRecordFieldTrie(incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot) ===
@@ -12744,14 +12782,14 @@ function mergeAndRefreshHigherVersionRecord(incoming, existing, incomingTrackedF
12744
12782
  };
12745
12783
  // We want to mark fields in the store as pending
12746
12784
  // Because we don't want to emit any data to components
12747
- return mergePendingFields(incoming, existing);
12785
+ return mergePendingFields(incoming, existing, existingNode);
12748
12786
  }
12749
12787
  return incoming;
12750
12788
  }
12751
12789
  // This method gets called
12752
12790
  // when incoming record has a lower version
12753
12791
  // than the record that is currently in the store
12754
- function mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap) {
12792
+ function mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap, existingNode) {
12755
12793
  // If the higher version (existing) does not have a superset of fields as incoming
12756
12794
  // then we need to refresh to get updated versions of fields on incoming
12757
12795
  if (isSuperRecordFieldTrie(existingTrackedFieldsTrieRoot, incomingTrackedFieldsTrieRoot) ===
@@ -12761,7 +12799,7 @@ function mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTr
12761
12799
  if (isSupportedEntity(incoming.apiName) === false) {
12762
12800
  return mergeRecordFields(existing, incoming);
12763
12801
  }
12764
- const merged = mergePendingFields(existing, incoming);
12802
+ const merged = mergePendingFields(existing, incoming, existingNode);
12765
12803
  // update the conflict map to resolve the record conflict in resolveConflict
12766
12804
  if (recordConflictMap) {
12767
12805
  recordConflictMap.conflicts[incoming.id] = {
@@ -12800,7 +12838,7 @@ function mergeRecordConflict(luvio, incoming, existing, recordConflictMap) {
12800
12838
  extractTrackedFieldsToTrie(recordKey, incomingNode, incomingTrackedFieldsTrieRoot, trackedFieldsConfig);
12801
12839
  extractTrackedFieldsToTrie(recordKey, existingNode, existingTrackedFieldsTrieRoot, trackedFieldsConfig);
12802
12840
  if (incoming.weakEtag > existing.weakEtag) {
12803
- return mergeAndRefreshHigherVersionRecord(incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap);
12841
+ return mergeAndRefreshHigherVersionRecord(incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap, existingNode);
12804
12842
  }
12805
12843
  return mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTrackedFieldsTrieRoot, existingTrackedFieldsTrieRoot, recordConflictMap);
12806
12844
  }
@@ -19362,7 +19400,7 @@ function validate$1E(obj, path = 'RecordLayoutSectionUserStateRepresentation') {
19362
19400
  }
19363
19401
 
19364
19402
  const TTL$B = 900000;
19365
- const VERSION$2u = "4ba42e1fa0fb00cf78fce86082da41c9";
19403
+ const VERSION$2u = "12123f1aca1b5a48303b1d099f9f5629";
19366
19404
  function validate$1D(obj, path = 'RecordLayoutUserStateRepresentation') {
19367
19405
  const v_error = (() => {
19368
19406
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
@@ -19375,8 +19413,29 @@ function validate$1D(obj, path = 'RecordLayoutUserStateRepresentation') {
19375
19413
  }
19376
19414
  const obj_id = obj.id;
19377
19415
  const path_id = path + '.id';
19378
- if (typeof obj_id !== 'string') {
19379
- return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
19416
+ let obj_id_union0 = null;
19417
+ const obj_id_union0_error = (() => {
19418
+ if (typeof obj_id !== 'string') {
19419
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
19420
+ }
19421
+ })();
19422
+ if (obj_id_union0_error != null) {
19423
+ obj_id_union0 = obj_id_union0_error.message;
19424
+ }
19425
+ let obj_id_union1 = null;
19426
+ const obj_id_union1_error = (() => {
19427
+ if (obj_id !== null) {
19428
+ return new TypeError('Expected "null" but received "' + typeof obj_id + '" (at "' + path_id + '")');
19429
+ }
19430
+ })();
19431
+ if (obj_id_union1_error != null) {
19432
+ obj_id_union1 = obj_id_union1_error.message;
19433
+ }
19434
+ if (obj_id_union0 && obj_id_union1) {
19435
+ let message = 'Object doesn\'t match union (at "' + path_id + '")';
19436
+ message += '\n' + obj_id_union0.split('\n').map((line) => '\t' + line).join('\n');
19437
+ message += '\n' + obj_id_union1.split('\n').map((line) => '\t' + line).join('\n');
19438
+ return new TypeError(message);
19380
19439
  }
19381
19440
  const obj_layoutType = obj.layoutType;
19382
19441
  const path_layoutType = path + '.layoutType';
@@ -27695,11 +27754,11 @@ function validateAdapterConfig$Q(untrustedConfig, _configPropertyNames) {
27695
27754
  if (config === null) {
27696
27755
  return null;
27697
27756
  }
27698
- // recordTypeId coercion is nuts: if `null` (but not undefined) then use MASTER record type id
27699
27757
  let recordTypeId = config.recordTypeId;
27700
27758
  if (recordTypeId === undefined) {
27701
27759
  // must check untrusted bc config has been coerced
27702
- if (untrustedConfig.recordTypeId !== null) {
27760
+ if (untrustedConfig.recordTypeId !== null &&
27761
+ untrustedConfig.recordTypeId !== undefined) {
27703
27762
  return null;
27704
27763
  }
27705
27764
  recordTypeId = MAIN_RECORD_TYPE_ID;
@@ -58363,6 +58422,23 @@ function getInContextFragmentType$d(fragment, fragmentMap) {
58363
58422
  return sharedGetFragmentType(fragment, fragmentMap);
58364
58423
  }
58365
58424
 
58425
+ function getFieldType$b(field) {
58426
+ switch (field.name.value) {
58427
+ case '__typename': {
58428
+ return {
58429
+ isArray: false,
58430
+ typename: 'String',
58431
+ };
58432
+ }
58433
+ default: {
58434
+ return {
58435
+ isArray: false,
58436
+ typename: 'Setup__SetupAggregateConnection',
58437
+ };
58438
+ }
58439
+ }
58440
+ }
58441
+
58366
58442
  const name$2 = 'Setup__SetupQueryAggregate';
58367
58443
  const VERSION$e = '0592284764c8e58016880e291b9ffb64';
58368
58444
  function keyBuilder$g(luvio, path, data) {
@@ -58480,24 +58556,6 @@ function getTypeCacheKeys$b(cacheKeySink, astNode, state) {
58480
58556
  }
58481
58557
  // Deal with mapped types' cache keys
58482
58558
  }
58483
- function getFieldType$b(field) {
58484
- switch (field.name.value) {
58485
- case '__typename': {
58486
- return {
58487
- isArray: false,
58488
- typename: 'String'
58489
- };
58490
- }
58491
- case 'recordQueryAggregate': {
58492
- return {
58493
- isArray: false,
58494
- typename: 'Setup__SetupAggregateConnection'
58495
- };
58496
- }
58497
- default:
58498
- return undefined;
58499
- }
58500
- }
58501
58559
  function ingestFieldByType$2(typename, parentKey, requestedField, sink, fieldKey, fieldData, state) {
58502
58560
  // TODO: add validation logic to only allow nullable fields to be null in the future
58503
58561
  if (fieldData === null) {
@@ -60545,6 +60603,12 @@ function selectTypeLinkWithPagination(resolvedLink, sel, fieldData, reader, key,
60545
60603
  return;
60546
60604
  }
60547
60605
  }
60606
+ else if (totalEdges === 0 && !listIsComplete) {
60607
+ // empty edge list, but the list isn't complete?
60608
+ if (process.env.NODE_ENV !== 'production') {
60609
+ throw new Error("page size of zero, but pageInfo .hasNextPage is true.");
60610
+ }
60611
+ }
60548
60612
  else {
60549
60613
  if (startOffset === undefined || endOffset === undefined) {
60550
60614
  reader.markMissingLink(fieldData.__ref);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lwc-adapters-uiapi",
3
- "version": "1.320.0",
3
+ "version": "1.322.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "UIAPI adapters with LWC bindings",
6
6
  "module": "dist/main.js",
@@ -31,10 +31,10 @@
31
31
  "clean": "rm -rf dist src/generated"
32
32
  },
33
33
  "devDependencies": {
34
- "@salesforce/lds-adapters-uiapi": "^1.320.0"
34
+ "@salesforce/lds-adapters-uiapi": "^1.322.0"
35
35
  },
36
36
  "dependencies": {
37
- "@luvio/lwc-luvio": "0.156.4",
38
- "@salesforce/lds-default-luvio": "^1.320.0"
37
+ "@luvio/lwc-luvio": "0.156.5",
38
+ "@salesforce/lds-default-luvio": "^1.322.0"
39
39
  }
40
40
  }