@salesforce/lwc-adapters-uiapi 1.229.0-dev1 → 1.229.0-dev10

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 +95 -58
  2. package/package.json +4 -4
package/dist/main.js CHANGED
@@ -19,12 +19,15 @@ var SnapshotState;
19
19
  const { create: create$1, entries, freeze: freeze$1, keys: keys$1, values } = Object;
20
20
  const { isArray: isArray$1 } = Array;
21
21
  const { parse: parse$2, stringify: stringify$1 } = JSON;
22
+ const WeakSetCtor = WeakSet;
22
23
 
24
+ const deeplyFrozen = new WeakSetCtor();
23
25
  function deepFreeze(value) {
24
- // No need to freeze primitives
25
- if (typeof value !== 'object' || value === null) {
26
+ // No need to freeze primitives or already frozen stuff
27
+ if (typeof value !== 'object' || value === null || deeplyFrozen.has(value)) {
26
28
  return;
27
29
  }
30
+ deeplyFrozen.add(value);
28
31
  if (isArray$1(value)) {
29
32
  for (let i = 0, len = value.length; i < len; i += 1) {
30
33
  deepFreeze(value[i]);
@@ -364,6 +367,37 @@ var FragmentReadResultState;
364
367
  ({
365
368
  state: FragmentReadResultState.Missing,
366
369
  });
370
+ function resolveLink(reader, storeLink, version) {
371
+ const { StoreLinkStateValues } = reader;
372
+ const linkState = reader.getLinkState(storeLink);
373
+ switch (linkState.state) {
374
+ case StoreLinkStateValues.RefNotPresent:
375
+ case StoreLinkStateValues.NotPresent:
376
+ case StoreLinkStateValues.Missing:
377
+ reader.markMissingLink(storeLink.__ref);
378
+ reader.markMissing();
379
+ return;
380
+ case StoreLinkStateValues.Pending:
381
+ reader.markPending();
382
+ return;
383
+ case StoreLinkStateValues.Null:
384
+ if (process.env.NODE_ENV !== 'production') {
385
+ throw new Error(`TODO: Invalid Link State. Link on "${reader.currentPath.fullPath}"`);
386
+ }
387
+ return;
388
+ }
389
+ const { key: __ref } = linkState;
390
+ return reader.read({
391
+ recordId: __ref,
392
+ node: {
393
+ kind: 'Fragment',
394
+ private: [],
395
+ opaque: true,
396
+ version,
397
+ },
398
+ variables: {},
399
+ });
400
+ }
367
401
 
368
402
  var ResourceParamType;
369
403
  (function (ResourceParamType) {
@@ -533,7 +567,7 @@ function createResourceParamsImpl(config, configMetadata) {
533
567
  }
534
568
  return resourceParams;
535
569
  }
536
- // engine version: 0.145.2-6a13677c
570
+ // engine version: 0.146.0-dev5-a2ec6e3f
537
571
 
538
572
  /**
539
573
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -8398,7 +8432,7 @@ function buildAdapterValidationConfig(displayName, paramsMeta) {
8398
8432
  }
8399
8433
  const keyPrefix = 'UiApi';
8400
8434
 
8401
- const { assign, create, freeze, keys } = Object;
8435
+ const { assign, create, freeze, isFrozen, keys } = Object;
8402
8436
  const { hasOwnProperty } = Object.prototype;
8403
8437
  const { split, endsWith } = String.prototype;
8404
8438
  const { isArray } = Array;
@@ -12268,7 +12302,7 @@ function extractTrackedFieldsToTrie(recordId, node, root, config, visitedRecordI
12268
12302
  extractTrackedFieldsToTrie(spanningLink.data.__ref, spanning, next, config, spanningVisitedRecordIds, depth + 1);
12269
12303
  // For a spanning record that is detected to be a circular reference, we add the field along with Id and Name.
12270
12304
  // It's possible for spanning record lookup fields to sometimes be circular, and sometimes not - depending on the value of the lookup field.
12271
- // For more information on scenarios that caused this fix: https://salesforce.quip.com/OvzNAh3eNIWY
12305
+ // For more information on scenarios that caused this fix: search "LDS Recursive Spanning Fields Problem" in Quip
12272
12306
  if (keys(next.children).length === 0) {
12273
12307
  addScalarFieldId(next);
12274
12308
  addScalarFieldName(next);
@@ -12603,7 +12637,11 @@ function markNulledOutPath(record, path) {
12603
12637
  }
12604
12638
  const link = fieldValueRepresentation.link(fieldName);
12605
12639
  const resolved = link.follow();
12606
- if (isGraphNode(resolved) && resolved.isScalar('value') && path.length > 0) {
12640
+ if (isGraphNode(resolved) &&
12641
+ resolved.isScalar('value') &&
12642
+ path.length > 0 &&
12643
+ // TODO [W-14082782]: temporary fix
12644
+ !isFrozen(link.data)) {
12607
12645
  const linkState = link.linkData();
12608
12646
  const fields = linkState === undefined ? [] : linkState.fields;
12609
12647
  link.writeLinkData({
@@ -12631,22 +12669,12 @@ function _markMissingPath(record, path) {
12631
12669
  const fieldValueRepresentation = record.object('fields');
12632
12670
  const fieldName = path.shift();
12633
12671
  if (fieldValueRepresentation.isUndefined(fieldName) === true) {
12634
- // TODO [W-6900046]: remove cast, make RecordRepresentationNormalized['fields'] accept
12635
- // an undefined/non-present __ref if isMissing is present
12636
- fieldValueRepresentation.write(fieldName, {
12637
- __ref: undefined,
12638
- isMissing: true,
12639
- });
12672
+ writeMissingFieldToStore(fieldValueRepresentation, fieldName);
12640
12673
  return;
12641
12674
  }
12642
12675
  const link = fieldValueRepresentation.link(fieldName);
12643
12676
  if (link.isPending()) {
12644
- // TODO [W-6900046]: remove cast, make RecordRepresentationNormalized['fields'] accept
12645
- // an undefined/non-present __ref if isMissing is present
12646
- fieldValueRepresentation.write(fieldName, {
12647
- __ref: undefined,
12648
- isMissing: true,
12649
- });
12677
+ writeMissingFieldToStore(fieldValueRepresentation, fieldName);
12650
12678
  }
12651
12679
  else if (path.length > 0 && link.isMissing() === false) {
12652
12680
  const fieldValue = link.follow();
@@ -12662,6 +12690,19 @@ function _markMissingPath(record, path) {
12662
12690
  }
12663
12691
  }
12664
12692
  }
12693
+ /**
12694
+ * Graph Node Directly modifies store entries, which is generally a non-starter.
12695
+ * Until we can refactor this mess, you need to use this function to safely mark the RecordRepresentation
12696
+ * as a seenId in the store when you perform this mutation.
12697
+ */
12698
+ function writeMissingFieldToStore(field, fieldName) {
12699
+ // TODO [W-6900046]: remove cast, make RecordRepresentationNormalized['fields'] accept
12700
+ // an undefined/non-present __ref if isMissing is present
12701
+ field.write(fieldName, {
12702
+ __ref: undefined,
12703
+ isMissing: true,
12704
+ });
12705
+ }
12665
12706
  /**
12666
12707
  * Tells you if an objectApiName is supported by UI API or not.
12667
12708
  * Note: Luvio does not currently support all the entities, the list is limited to UI API supported entities
@@ -12793,8 +12834,11 @@ function mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTr
12793
12834
  return existing;
12794
12835
  }
12795
12836
  function mergeRecordConflict(luvio, incoming, existing, recordConflictMap) {
12796
- const incomingNode = luvio.wrapNormalizedGraphNode(incoming);
12797
- const existingNode = luvio.wrapNormalizedGraphNode(existing);
12837
+ const recordKey = keyBuilder$35(luvio, {
12838
+ recordId: incoming.id,
12839
+ });
12840
+ const incomingNode = luvio.wrapNormalizedGraphNode(incoming, recordKey);
12841
+ const existingNode = luvio.wrapNormalizedGraphNode(existing, recordKey);
12798
12842
  const incomingTrackedFieldsTrieRoot = {
12799
12843
  name: incoming.apiName,
12800
12844
  children: {},
@@ -12803,9 +12847,6 @@ function mergeRecordConflict(luvio, incoming, existing, recordConflictMap) {
12803
12847
  name: existing.apiName,
12804
12848
  children: {},
12805
12849
  };
12806
- const recordKey = keyBuilder$35(luvio, {
12807
- recordId: incoming.id,
12808
- });
12809
12850
  const trackedFieldsConfig = {
12810
12851
  maxDepth: configurationForRestAdapters.getTrackedFieldDepthOnCacheMergeConflict(),
12811
12852
  onlyFetchLeafNodeIdAndName: configurationForRestAdapters.getTrackedFieldLeafNodeIdAndNameOnly(),
@@ -19593,7 +19634,7 @@ function getLayoutMapAndObjectInfo(recordId, data) {
19593
19634
  // Temp fix until we can mimic the server behavior for non-layoutable entities.
19594
19635
  let layoutMap = {};
19595
19636
  if (hasOwnProperty.call(layouts, apiName)) {
19596
- layoutMap = layouts[apiName][recordTypeId];
19637
+ layoutMap = layouts[apiName][recordTypeId] || {};
19597
19638
  }
19598
19639
  return {
19599
19640
  layoutMap,
@@ -19775,18 +19816,28 @@ const buildLayoutModeCacheSnapshot = (apiName, recordTypeId, layoutType, mode) =
19775
19816
  * These are intermediate lookups to check if the record is in the L2 cache
19776
19817
  * @param {Luvio} luvio
19777
19818
  * @param {GetRecordLayoutTypeConfig} config
19778
- * @param {BuildCachedSnapshot<BuildSnapshotContext} cachedSnapshot
19819
+ * @param {BuildCachedSnapshot<BuildSnapshotContext>} cachedSnapshot
19779
19820
  */
19780
19821
  function makeCacheOnlySnapshot(luvio, config, adapterContext, cachedSnapshot) {
19781
- return luvio.applyCachePolicy({
19782
- cachePolicy: {
19783
- // only looking in the cache so we can check for L2 data offline
19784
- type: 'only-if-cached',
19785
- },
19786
- }, { config, luvio, adapterContext }, cachedSnapshot,
19787
- // this won't be invoked since we're requesting only-if-cached
19822
+ return luvio.applyCachePolicy(
19823
+ // Pass empty context so environment will use its default cache-policy
19824
+ {}, { config, luvio, adapterContext }, cachedSnapshot,
19825
+ // disallow hitting the network by returning a gateway timeout
19788
19826
  () => {
19789
- throw Error('buildNetworkSnapshot should not be called for only-if-cached policy');
19827
+ return new Promise((resolve) => {
19828
+ resolve({
19829
+ state: 'Error',
19830
+ data: undefined,
19831
+ error: {
19832
+ body: undefined,
19833
+ headers: {},
19834
+ ok: false,
19835
+ status: 504,
19836
+ statusText: 'Gateway Timeout',
19837
+ errorType: 'fetchResponse',
19838
+ },
19839
+ });
19840
+ });
19790
19841
  });
19791
19842
  }
19792
19843
  /**
@@ -19997,7 +20048,7 @@ const notifyChangeFactory = (luvio) => {
19997
20048
  const responsePromises = [];
19998
20049
  for (let i = 0, len = entries.length; i < len; i++) {
19999
20050
  const { key, record } = entries[i];
20000
- const node = luvio.wrapNormalizedGraphNode(record);
20051
+ const node = luvio.wrapNormalizedGraphNode(record, key);
20001
20052
  const optionalFields = getTrackedFields(key, node, {
20002
20053
  maxDepth: configurationForRestAdapters.getTrackedFieldDepthOnNotifyChange(),
20003
20054
  onlyFetchLeafNodeIdAndName: configurationForRestAdapters.getTrackedFieldLeafNodeIdAndNameOnly(),
@@ -50392,6 +50443,7 @@ function buildSelectionForField$7(source, reader, sel, variables, fragments, isC
50392
50443
  }
50393
50444
  if (fieldData === null) {
50394
50445
  reader.assignScalar(requestedFieldName, sink, fieldData);
50446
+ reader.exitPath();
50395
50447
  return sink;
50396
50448
  }
50397
50449
  const fieldType = getFieldType(sel);
@@ -50417,17 +50469,8 @@ function buildSelectionForField$7(source, reader, sel, variables, fragments, isC
50417
50469
  return sink;
50418
50470
  }
50419
50471
  function selectTypeLink(sel, fieldData, reader, key, sink, variables, fragments, version, selectFn, isCursorConnection) {
50420
- const resolvedLink = reader.read({
50421
- recordId: fieldData.__ref,
50422
- node: {
50423
- kind: 'Fragment',
50424
- private: [],
50425
- opaque: true,
50426
- version,
50427
- },
50428
- variables: {}
50429
- });
50430
- if (resolvedLink.data !== undefined) {
50472
+ const resolvedLink = resolveLink(reader, fieldData, version);
50473
+ if (resolvedLink && resolvedLink.data !== undefined) {
50431
50474
  if (isCursorConnection) {
50432
50475
  selectTypeLinkWithPagination(resolvedLink, sel, fieldData, reader, key, sink, variables, fragments, selectFn);
50433
50476
  }
@@ -51009,19 +51052,11 @@ function selectType$6(typename, sel, fieldData, reader, key, sink, variables, fr
51009
51052
  }
51010
51053
  case 'PolymorphicParentRelationship':
51011
51054
  case 'RecordRepresentation': {
51012
- const spanningFieldLink = reader.read({
51013
- recordId: fieldData.__ref,
51014
- node: {
51015
- kind: 'Fragment',
51016
- private: [],
51017
- opaque: true,
51018
- version: VERSION$2i,
51019
- },
51020
- variables: {},
51021
- });
51022
- reader.markSeenId(fieldData.__ref);
51023
- const resolvedSpanningFieldValue = spanningFieldLink.data;
51055
+ const spanningFieldLink = resolveLink(reader, fieldData, VERSION$2i);
51056
+ const resolvedSpanningFieldValue = spanningFieldLink && spanningFieldLink.data;
51057
+ const fieldDataRef = fieldData.__ref;
51024
51058
  if (resolvedSpanningFieldValue !== undefined) {
51059
+ reader.markSeenId(fieldDataRef);
51025
51060
  const { value: spanningFieldResult } = resolvedSpanningFieldValue;
51026
51061
  // Handle null values - graphql will return it at the field level, not return nested { value: null }
51027
51062
  if (spanningFieldResult === null || typeof spanningFieldResult !== 'object') {
@@ -51045,7 +51080,9 @@ function selectType$6(typename, sel, fieldData, reader, key, sink, variables, fr
51045
51080
  }
51046
51081
  }
51047
51082
  else {
51048
- reader.markMissingLink(fieldData.__ref);
51083
+ if (fieldDataRef !== undefined) {
51084
+ reader.markMissingLink(fieldDataRef);
51085
+ }
51049
51086
  reader.markMissing();
51050
51087
  }
51051
51088
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lwc-adapters-uiapi",
3
- "version": "1.229.0-dev1",
3
+ "version": "1.229.0-dev10",
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.229.0-dev1"
34
+ "@salesforce/lds-adapters-uiapi": "1.229.0-dev10"
35
35
  },
36
36
  "dependencies": {
37
- "@luvio/lwc-luvio": "0.145.2",
38
- "@salesforce/lds-default-luvio": "1.229.0-dev1"
37
+ "@luvio/lwc-luvio": "0.146.0-dev5",
38
+ "@salesforce/lds-default-luvio": "1.229.0-dev10"
39
39
  }
40
40
  }