@salesforce/lds-worker-api 1.229.0-dev7 → 1.229.0-dev9

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.
@@ -795,4 +795,4 @@ if (process.env.NODE_ENV !== 'production') {
795
795
  }
796
796
 
797
797
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
798
- // version: 1.229.0-dev7-157e3a4db
798
+ // version: 1.229.0-dev9-dd96b5901
@@ -25,12 +25,15 @@ const { hasOwnProperty: hasOwnProperty$3 } = Object.prototype;
25
25
  const { isArray: isArray$9 } = Array;
26
26
  const { push: push$5, indexOf, slice: slice$2 } = Array.prototype;
27
27
  const { parse: parse$a, stringify: stringify$a } = JSON;
28
+ const WeakSetCtor = WeakSet;
28
29
 
30
+ const deeplyFrozen = new WeakSetCtor();
29
31
  function deepFreeze(value) {
30
- // No need to freeze primitives
31
- if (typeof value !== 'object' || value === null) {
32
+ // No need to freeze primitives or already frozen stuff
33
+ if (typeof value !== 'object' || value === null || deeplyFrozen.has(value)) {
32
34
  return;
33
35
  }
36
+ deeplyFrozen.add(value);
34
37
  if (isArray$9(value)) {
35
38
  for (let i = 0, len = value.length; i < len; i += 1) {
36
39
  deepFreeze(value[i]);
@@ -1727,6 +1730,10 @@ class InMemoryStore {
1727
1730
  }
1728
1731
  }
1729
1732
  markVisited(canonicalKey) {
1733
+ if (typeof canonicalKey === 'string') {
1734
+ this.fallbackStringKeyInMemoryStore.markVisited(canonicalKey);
1735
+ return;
1736
+ }
1730
1737
  const { visitedIdsSet, reverseRedirectKeysMap } = this;
1731
1738
  let redirectKey = canonicalKey;
1732
1739
  // mark all redirects leading up to the canonical key as visited so
@@ -2038,7 +2045,7 @@ class GraphLink {
2038
2045
  if (isStoreRecordError$1(linked)) {
2039
2046
  return new GraphNodeError(this.store, linked);
2040
2047
  }
2041
- return new GraphNode(this.store, linked);
2048
+ return new GraphNode(this.store, linked, __ref);
2042
2049
  }
2043
2050
  linkData() {
2044
2051
  return this.data.data;
@@ -2048,10 +2055,11 @@ class GraphLink {
2048
2055
  }
2049
2056
  }
2050
2057
  class GraphNode {
2051
- constructor(store, data) {
2058
+ constructor(store, data, storeKey) {
2052
2059
  this.type = GraphNodeType$1.Node;
2053
2060
  this.store = store;
2054
2061
  this.data = data;
2062
+ this.storeKey = storeKey;
2055
2063
  }
2056
2064
  object(propertyName) {
2057
2065
  const value = this.data[propertyName];
@@ -2061,7 +2069,8 @@ class GraphNode {
2061
2069
  if (typeof value !== 'object' || value === null) {
2062
2070
  throw new Error(`Cannot walk to path ${String(propertyName)}. "${String(propertyName)}" is a scalar: "${value}"`);
2063
2071
  }
2064
- return new GraphNode(this.store, value);
2072
+ // We're walking to an object property on the current store record, pass the storeKey down.
2073
+ return new GraphNode(this.store, value, this.storeKey);
2065
2074
  }
2066
2075
  link(propertyName) {
2067
2076
  const value = this.data[propertyName];
@@ -2091,6 +2100,8 @@ class GraphNode {
2091
2100
  }
2092
2101
  write(propertyName, value) {
2093
2102
  this.data[propertyName] = value;
2103
+ const canonicalKey = this.store.getCanonicalRecordId(this.storeKey);
2104
+ this.store.markVisited(canonicalKey);
2094
2105
  }
2095
2106
  isUndefined(propertyName) {
2096
2107
  return this.data[propertyName] === undefined;
@@ -3253,9 +3264,9 @@ class Environment {
3253
3264
  if (value === undefined) {
3254
3265
  return null;
3255
3266
  }
3256
- return this.wrapNormalizedGraphNode(value, store);
3267
+ return this.wrapNormalizedGraphNode(value, key, store);
3257
3268
  }
3258
- wrapNormalizedGraphNode(normalized, storeOverride) {
3269
+ wrapNormalizedGraphNode(normalized, key, storeOverride) {
3259
3270
  if (normalized === null) {
3260
3271
  return null;
3261
3272
  }
@@ -3263,7 +3274,7 @@ class Environment {
3263
3274
  if (isStoreRecordError$1(normalized)) {
3264
3275
  return new GraphNodeError(store, normalized);
3265
3276
  }
3266
- return new GraphNode(store, normalized);
3277
+ return new GraphNode(store, normalized, key);
3267
3278
  }
3268
3279
  withContext(adapter, options) {
3269
3280
  const { contextId, onContextLoaded } = options;
@@ -3558,8 +3569,8 @@ class Luvio {
3558
3569
  getNode(key) {
3559
3570
  return this.environment.getNode(key);
3560
3571
  }
3561
- wrapNormalizedGraphNode(normalized) {
3562
- return this.environment.wrapNormalizedGraphNode(normalized);
3572
+ wrapNormalizedGraphNode(normalized, key) {
3573
+ return this.environment.wrapNormalizedGraphNode(normalized, key);
3563
3574
  }
3564
3575
  instrument(paramsBuilder) {
3565
3576
  const { instrument } = this.options;
@@ -3869,7 +3880,7 @@ function createResourceParamsImpl(config, configMetadata) {
3869
3880
  }
3870
3881
  return resourceParams;
3871
3882
  }
3872
- // engine version: 0.146.0-dev4-c265089a
3883
+ // engine version: 0.146.0-dev5-a2ec6e3f
3873
3884
 
3874
3885
  /**
3875
3886
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3996,7 +4007,7 @@ function withDefaultLuvio(callback) {
3996
4007
  }
3997
4008
  callbacks.push(callback);
3998
4009
  }
3999
- // version: 1.229.0-dev7-157e3a4db
4010
+ // version: 1.229.0-dev9-dd96b5901
4000
4011
 
4001
4012
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4002
4013
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15457,7 +15468,7 @@ function gql(literals, ...subs) {
15457
15468
  }
15458
15469
  return superResult;
15459
15470
  }
15460
- // version: 1.229.0-dev7-157e3a4db
15471
+ // version: 1.229.0-dev9-dd96b5901
15461
15472
 
15462
15473
  function unwrap(data) {
15463
15474
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16381,7 +16392,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
16381
16392
  const { apiFamily, name } = metadata;
16382
16393
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16383
16394
  }
16384
- // version: 1.229.0-dev7-157e3a4db
16395
+ // version: 1.229.0-dev9-dd96b5901
16385
16396
 
16386
16397
  /**
16387
16398
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16480,7 +16491,7 @@ var TypeCheckShapes;
16480
16491
  TypeCheckShapes[TypeCheckShapes["Integer"] = 3] = "Integer";
16481
16492
  TypeCheckShapes[TypeCheckShapes["Unsupported"] = 4] = "Unsupported";
16482
16493
  })(TypeCheckShapes || (TypeCheckShapes = {}));
16483
- // engine version: 0.146.0-dev4-c265089a
16494
+ // engine version: 0.146.0-dev5-a2ec6e3f
16484
16495
 
16485
16496
  const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
16486
16497
 
@@ -19823,7 +19834,7 @@ function extractTrackedFieldsToTrie(recordId, node, root, config, visitedRecordI
19823
19834
  extractTrackedFieldsToTrie(spanningLink.data.__ref, spanning, next, config, spanningVisitedRecordIds, depth + 1);
19824
19835
  // For a spanning record that is detected to be a circular reference, we add the field along with Id and Name.
19825
19836
  // It's possible for spanning record lookup fields to sometimes be circular, and sometimes not - depending on the value of the lookup field.
19826
- // For more information on scenarios that caused this fix: https://salesforce.quip.com/OvzNAh3eNIWY
19837
+ // For more information on scenarios that caused this fix: search "LDS Recursive Spanning Fields Problem" in Quip
19827
19838
  if (keys$a(next.children).length === 0) {
19828
19839
  addScalarFieldId(next);
19829
19840
  addScalarFieldName(next);
@@ -20008,22 +20019,12 @@ function _markMissingPath(record, path) {
20008
20019
  const fieldValueRepresentation = record.object('fields');
20009
20020
  const fieldName = path.shift();
20010
20021
  if (fieldValueRepresentation.isUndefined(fieldName) === true) {
20011
- // TODO [W-6900046]: remove cast, make RecordRepresentationNormalized['fields'] accept
20012
- // an undefined/non-present __ref if isMissing is present
20013
- fieldValueRepresentation.write(fieldName, {
20014
- __ref: undefined,
20015
- isMissing: true,
20016
- });
20022
+ writeMissingFieldToStore(fieldValueRepresentation, fieldName);
20017
20023
  return;
20018
20024
  }
20019
20025
  const link = fieldValueRepresentation.link(fieldName);
20020
20026
  if (link.isPending()) {
20021
- // TODO [W-6900046]: remove cast, make RecordRepresentationNormalized['fields'] accept
20022
- // an undefined/non-present __ref if isMissing is present
20023
- fieldValueRepresentation.write(fieldName, {
20024
- __ref: undefined,
20025
- isMissing: true,
20026
- });
20027
+ writeMissingFieldToStore(fieldValueRepresentation, fieldName);
20027
20028
  }
20028
20029
  else if (path.length > 0 && link.isMissing() === false) {
20029
20030
  const fieldValue = link.follow();
@@ -20039,6 +20040,19 @@ function _markMissingPath(record, path) {
20039
20040
  }
20040
20041
  }
20041
20042
  }
20043
+ /**
20044
+ * Graph Node Directly modifies store entries, which is generally a non-starter.
20045
+ * Until we can refactor this mess, you need to use this function to safely mark the RecordRepresentation
20046
+ * as a seenId in the store when you perform this mutation.
20047
+ */
20048
+ function writeMissingFieldToStore(field, fieldName) {
20049
+ // TODO [W-6900046]: remove cast, make RecordRepresentationNormalized['fields'] accept
20050
+ // an undefined/non-present __ref if isMissing is present
20051
+ field.write(fieldName, {
20052
+ __ref: undefined,
20053
+ isMissing: true,
20054
+ });
20055
+ }
20042
20056
  /**
20043
20057
  * Tells you if an objectApiName is supported by UI API or not.
20044
20058
  * Note: Luvio does not currently support all the entities, the list is limited to UI API supported entities
@@ -20170,8 +20184,11 @@ function mergeAndRefreshLowerVersionRecord(luvio, incoming, existing, incomingTr
20170
20184
  return existing;
20171
20185
  }
20172
20186
  function mergeRecordConflict(luvio, incoming, existing, recordConflictMap) {
20173
- const incomingNode = luvio.wrapNormalizedGraphNode(incoming);
20174
- const existingNode = luvio.wrapNormalizedGraphNode(existing);
20187
+ const recordKey = keyBuilder$1U(luvio, {
20188
+ recordId: incoming.id,
20189
+ });
20190
+ const incomingNode = luvio.wrapNormalizedGraphNode(incoming, recordKey);
20191
+ const existingNode = luvio.wrapNormalizedGraphNode(existing, recordKey);
20175
20192
  const incomingTrackedFieldsTrieRoot = {
20176
20193
  name: incoming.apiName,
20177
20194
  children: {},
@@ -20180,9 +20197,6 @@ function mergeRecordConflict(luvio, incoming, existing, recordConflictMap) {
20180
20197
  name: existing.apiName,
20181
20198
  children: {},
20182
20199
  };
20183
- const recordKey = keyBuilder$1U(luvio, {
20184
- recordId: incoming.id,
20185
- });
20186
20200
  const trackedFieldsConfig = {
20187
20201
  maxDepth: configurationForRestAdapters$1.getTrackedFieldDepthOnCacheMergeConflict(),
20188
20202
  onlyFetchLeafNodeIdAndName: configurationForRestAdapters$1.getTrackedFieldLeafNodeIdAndNameOnly(),
@@ -25303,7 +25317,7 @@ const notifyChangeFactory = (luvio) => {
25303
25317
  const responsePromises = [];
25304
25318
  for (let i = 0, len = entries.length; i < len; i++) {
25305
25319
  const { key, record } = entries[i];
25306
- const node = luvio.wrapNormalizedGraphNode(record);
25320
+ const node = luvio.wrapNormalizedGraphNode(record, key);
25307
25321
  const optionalFields = getTrackedFields(key, node, {
25308
25322
  maxDepth: configurationForRestAdapters$1.getTrackedFieldDepthOnNotifyChange(),
25309
25323
  onlyFetchLeafNodeIdAndName: configurationForRestAdapters$1.getTrackedFieldLeafNodeIdAndNameOnly(),
@@ -41201,7 +41215,16 @@ withDefaultLuvio((luvio) => {
41201
41215
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyListInfoUpdateAvailable', notifyUpdateAvailableFactory$1));
41202
41216
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyQuickActionDefaultsUpdateAvailable', notifyUpdateAvailableFactory));
41203
41217
  });
41204
- // version: 1.229.0-dev7-22b616ee5
41218
+ // version: 1.229.0-dev9-939b09095
41219
+
41220
+ var ldsIdempotencyWriteDisabled = {
41221
+ isOpen: function (e) {
41222
+ return e.fallback;
41223
+ },
41224
+ hasError: function () {
41225
+ return !0;
41226
+ },
41227
+ };
41205
41228
 
41206
41229
  var caseSensitiveUserId = '005B0000000GR4OIAW';
41207
41230
 
@@ -42419,12 +42442,12 @@ function makeDurable(environment, { durableStore, instrumentation }) {
42419
42442
  }
42420
42443
  return environment.getNode(key, ingestStagingStore);
42421
42444
  };
42422
- const wrapNormalizedGraphNode = function (normalized) {
42445
+ const wrapNormalizedGraphNode = function (normalized, key) {
42423
42446
  validateNotDisposed();
42424
42447
  if (ingestStagingStore === null) {
42425
42448
  ingestStagingStore = buildIngestStagingStore(environment);
42426
42449
  }
42427
- return environment.wrapNormalizedGraphNode(normalized, ingestStagingStore);
42450
+ return environment.wrapNormalizedGraphNode(normalized, key, ingestStagingStore);
42428
42451
  };
42429
42452
  const rebuildSnapshot = function (snapshot, onRebuild) {
42430
42453
  validateNotDisposed();
@@ -47216,7 +47239,12 @@ class AbstractResourceRequestActionHandler {
47216
47239
  // the luvio store redirect table, during which a new draft might be enqueued
47217
47240
  // which would not see a necessary mapping.
47218
47241
  this.ephemeralRedirects = {};
47242
+ // determined by Server setup.
47219
47243
  this.isIdempotencySupported = true;
47244
+ // idempotency write flag set by lds
47245
+ this.isLdsIdempotencyWriteDisabled = ldsIdempotencyWriteDisabled.isOpen({
47246
+ fallback: false,
47247
+ });
47220
47248
  }
47221
47249
  enqueue(data) {
47222
47250
  return this.draftQueue.enqueue(this.handlerId, data);
@@ -47576,7 +47604,7 @@ class AbstractResourceRequestActionHandler {
47576
47604
  return [action.targetId];
47577
47605
  }
47578
47606
  hasIdempotencySupport() {
47579
- return this.isIdempotencySupported;
47607
+ return this.isIdempotencySupported && !this.isLdsIdempotencyWriteDisabled;
47580
47608
  }
47581
47609
  async ingestResponses(responses, action) {
47582
47610
  const luvio = this.getLuvio();
@@ -53031,34 +53059,42 @@ function applyReferenceLinksToDraft(record, draftMetadata) {
53031
53059
  }
53032
53060
  const { dataType, relationshipName, referenceToInfos } = fieldInfo;
53033
53061
  const draftFieldValue = record.fields[draftField].value;
53034
- if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
53035
- if (typeof draftFieldValue !== 'string') {
53036
- throw Error('reference field value is not a string');
53062
+ if (dataType === 'Reference' && relationshipName !== null) {
53063
+ if (draftFieldValue === null) {
53064
+ recordFields[relationshipName] = {
53065
+ displayValue: null,
53066
+ value: null,
53067
+ };
53037
53068
  }
53038
- const key = getRecordKeyForId(luvio, draftFieldValue);
53039
- const referencedRecord = referencedRecords.get(key);
53040
- recordFields[relationshipName] = {
53041
- displayValue: null,
53042
- value: createLink$2(key),
53043
- };
53044
- // for custom objects, we select the 'Name' field
53045
- // otherwise we check the object info for name fields.
53046
- //if there are multiple we select 'Name' if it exists, otherwise the first one
53047
- if (referencedRecord !== undefined && referenceToInfos.length > 0) {
53048
- let nameField;
53049
- const referenceToInfo = referenceToInfos[0];
53050
- const nameFields = referenceToInfo.nameFields;
53051
- if (nameFields.length !== 0) {
53052
- nameField = nameFields.find((x) => x === 'Name');
53053
- if (nameField === undefined) {
53054
- nameField = nameFields[0];
53055
- }
53069
+ else {
53070
+ if (typeof draftFieldValue !== 'string') {
53071
+ throw Error('reference field value is not a string');
53056
53072
  }
53057
- if (nameField !== undefined) {
53058
- const nameFieldRef = referencedRecord.fields[nameField];
53059
- if (nameFieldRef) {
53060
- recordFields[relationshipName].displayValue =
53061
- (_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
53073
+ const key = getRecordKeyForId(luvio, draftFieldValue);
53074
+ const referencedRecord = referencedRecords.get(key);
53075
+ recordFields[relationshipName] = {
53076
+ displayValue: null,
53077
+ value: createLink$2(key),
53078
+ };
53079
+ // for custom objects, we select the 'Name' field
53080
+ // otherwise we check the object info for name fields.
53081
+ //if there are multiple we select 'Name' if it exists, otherwise the first one
53082
+ if (referencedRecord !== undefined && referenceToInfos.length > 0) {
53083
+ let nameField;
53084
+ const referenceToInfo = referenceToInfos[0];
53085
+ const nameFields = referenceToInfo.nameFields;
53086
+ if (nameFields.length !== 0) {
53087
+ nameField = nameFields.find((x) => x === 'Name');
53088
+ if (nameField === undefined) {
53089
+ nameField = nameFields[0];
53090
+ }
53091
+ }
53092
+ if (nameField !== undefined) {
53093
+ const nameFieldRef = referencedRecord.fields[nameField];
53094
+ if (nameFieldRef) {
53095
+ recordFields[relationshipName].displayValue =
53096
+ (_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
53097
+ }
53062
53098
  }
53063
53099
  }
53064
53100
  }
@@ -53351,17 +53387,8 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
53351
53387
  };
53352
53388
  for (const fieldName of keys$3(recordWithSpanningRefLinks.fields)) {
53353
53389
  const fieldKey = buildRecordFieldStoreKey(key, fieldName);
53354
- if (this.collectedFields[fieldKey] !== undefined) {
53355
- const fieldData = recordWithSpanningRefLinks.fields[fieldName];
53356
- normalizedRecord.fields[fieldName] = { __ref: fieldKey };
53357
- publishData(fieldKey, fieldData);
53358
- }
53359
- else if (recordWithSpanningRefLinks.fields[fieldName] &&
53360
- recordWithSpanningRefLinks.fields[fieldName].value &&
53361
- recordWithSpanningRefLinks.fields[fieldName].value.__ref !== undefined) {
53362
- normalizedRecord.fields[fieldName] = { __ref: fieldKey };
53363
- publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
53364
- }
53390
+ normalizedRecord.fields[fieldName] = { __ref: fieldKey };
53391
+ publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
53365
53392
  }
53366
53393
  // publish the normalized record
53367
53394
  publishData(key, normalizedRecord);
@@ -58049,7 +58076,7 @@ register({
58049
58076
  id: '@salesforce/lds-network-adapter',
58050
58077
  instrument: instrument$1,
58051
58078
  });
58052
- // version: 1.229.0-dev7-157e3a4db
58079
+ // version: 1.229.0-dev9-dd96b5901
58053
58080
 
58054
58081
  const { create: create$2, keys: keys$2 } = Object;
58055
58082
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -76481,7 +76508,7 @@ register({
76481
76508
  configuration: { ...configurationForGraphQLAdapters },
76482
76509
  instrument,
76483
76510
  });
76484
- // version: 1.229.0-dev7-22b616ee5
76511
+ // version: 1.229.0-dev9-939b09095
76485
76512
 
76486
76513
  // On core the unstable adapters are re-exported with different names,
76487
76514
 
@@ -78728,7 +78755,7 @@ withDefaultLuvio((luvio) => {
78728
78755
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
78729
78756
  graphQLImperative = ldsAdapter;
78730
78757
  });
78731
- // version: 1.229.0-dev7-22b616ee5
78758
+ // version: 1.229.0-dev9-939b09095
78732
78759
 
78733
78760
  var gqlApi = /*#__PURE__*/Object.freeze({
78734
78761
  __proto__: null,
@@ -79442,4 +79469,4 @@ const { luvio } = getRuntime();
79442
79469
  setDefaultLuvio({ luvio });
79443
79470
 
79444
79471
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
79445
- // version: 1.229.0-dev7-157e3a4db
79472
+ // version: 1.229.0-dev9-dd96b5901
@@ -31,12 +31,15 @@
31
31
  const { isArray: isArray$9 } = Array;
32
32
  const { push: push$5, indexOf, slice: slice$2 } = Array.prototype;
33
33
  const { parse: parse$a, stringify: stringify$a } = JSON;
34
+ const WeakSetCtor = WeakSet;
34
35
 
36
+ const deeplyFrozen = new WeakSetCtor();
35
37
  function deepFreeze(value) {
36
- // No need to freeze primitives
37
- if (typeof value !== 'object' || value === null) {
38
+ // No need to freeze primitives or already frozen stuff
39
+ if (typeof value !== 'object' || value === null || deeplyFrozen.has(value)) {
38
40
  return;
39
41
  }
42
+ deeplyFrozen.add(value);
40
43
  if (isArray$9(value)) {
41
44
  for (let i = 0, len = value.length; i < len; i += 1) {
42
45
  deepFreeze(value[i]);
@@ -1733,6 +1736,10 @@
1733
1736
  }
1734
1737
  }
1735
1738
  markVisited(canonicalKey) {
1739
+ if (typeof canonicalKey === 'string') {
1740
+ this.fallbackStringKeyInMemoryStore.markVisited(canonicalKey);
1741
+ return;
1742
+ }
1736
1743
  const { visitedIdsSet, reverseRedirectKeysMap } = this;
1737
1744
  let redirectKey = canonicalKey;
1738
1745
  // mark all redirects leading up to the canonical key as visited so
@@ -2044,7 +2051,7 @@
2044
2051
  if (isStoreRecordError$1(linked)) {
2045
2052
  return new GraphNodeError(this.store, linked);
2046
2053
  }
2047
- return new GraphNode(this.store, linked);
2054
+ return new GraphNode(this.store, linked, __ref);
2048
2055
  }
2049
2056
  linkData() {
2050
2057
  return this.data.data;
@@ -2054,10 +2061,11 @@
2054
2061
  }
2055
2062
  }
2056
2063
  class GraphNode {
2057
- constructor(store, data) {
2064
+ constructor(store, data, storeKey) {
2058
2065
  this.type = GraphNodeType$1.Node;
2059
2066
  this.store = store;
2060
2067
  this.data = data;
2068
+ this.storeKey = storeKey;
2061
2069
  }
2062
2070
  object(propertyName) {
2063
2071
  const value = this.data[propertyName];
@@ -2067,7 +2075,8 @@
2067
2075
  if (typeof value !== 'object' || value === null) {
2068
2076
  throw new Error(`Cannot walk to path ${String(propertyName)}. "${String(propertyName)}" is a scalar: "${value}"`);
2069
2077
  }
2070
- return new GraphNode(this.store, value);
2078
+ // We're walking to an object property on the current store record, pass the storeKey down.
2079
+ return new GraphNode(this.store, value, this.storeKey);
2071
2080
  }
2072
2081
  link(propertyName) {
2073
2082
  const value = this.data[propertyName];
@@ -2097,6 +2106,8 @@
2097
2106
  }
2098
2107
  write(propertyName, value) {
2099
2108
  this.data[propertyName] = value;
2109
+ const canonicalKey = this.store.getCanonicalRecordId(this.storeKey);
2110
+ this.store.markVisited(canonicalKey);
2100
2111
  }
2101
2112
  isUndefined(propertyName) {
2102
2113
  return this.data[propertyName] === undefined;
@@ -3259,9 +3270,9 @@
3259
3270
  if (value === undefined) {
3260
3271
  return null;
3261
3272
  }
3262
- return this.wrapNormalizedGraphNode(value, store);
3273
+ return this.wrapNormalizedGraphNode(value, key, store);
3263
3274
  }
3264
- wrapNormalizedGraphNode(normalized, storeOverride) {
3275
+ wrapNormalizedGraphNode(normalized, key, storeOverride) {
3265
3276
  if (normalized === null) {
3266
3277
  return null;
3267
3278
  }
@@ -3269,7 +3280,7 @@
3269
3280
  if (isStoreRecordError$1(normalized)) {
3270
3281
  return new GraphNodeError(store, normalized);
3271
3282
  }
3272
- return new GraphNode(store, normalized);
3283
+ return new GraphNode(store, normalized, key);
3273
3284
  }
3274
3285
  withContext(adapter, options) {
3275
3286
  const { contextId, onContextLoaded } = options;
@@ -3564,8 +3575,8 @@
3564
3575
  getNode(key) {
3565
3576
  return this.environment.getNode(key);
3566
3577
  }
3567
- wrapNormalizedGraphNode(normalized) {
3568
- return this.environment.wrapNormalizedGraphNode(normalized);
3578
+ wrapNormalizedGraphNode(normalized, key) {
3579
+ return this.environment.wrapNormalizedGraphNode(normalized, key);
3569
3580
  }
3570
3581
  instrument(paramsBuilder) {
3571
3582
  const { instrument } = this.options;
@@ -3875,7 +3886,7 @@
3875
3886
  }
3876
3887
  return resourceParams;
3877
3888
  }
3878
- // engine version: 0.146.0-dev4-c265089a
3889
+ // engine version: 0.146.0-dev5-a2ec6e3f
3879
3890
 
3880
3891
  /**
3881
3892
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -4002,7 +4013,7 @@
4002
4013
  }
4003
4014
  callbacks.push(callback);
4004
4015
  }
4005
- // version: 1.229.0-dev7-157e3a4db
4016
+ // version: 1.229.0-dev9-dd96b5901
4006
4017
 
4007
4018
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4008
4019
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15463,7 +15474,7 @@
15463
15474
  }
15464
15475
  return superResult;
15465
15476
  }
15466
- // version: 1.229.0-dev7-157e3a4db
15477
+ // version: 1.229.0-dev9-dd96b5901
15467
15478
 
15468
15479
  function unwrap(data) {
15469
15480
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16387,7 +16398,7 @@
16387
16398
  const { apiFamily, name } = metadata;
16388
16399
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16389
16400
  }
16390
- // version: 1.229.0-dev7-157e3a4db
16401
+ // version: 1.229.0-dev9-dd96b5901
16391
16402
 
16392
16403
  /**
16393
16404
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16486,7 +16497,7 @@
16486
16497
  TypeCheckShapes[TypeCheckShapes["Integer"] = 3] = "Integer";
16487
16498
  TypeCheckShapes[TypeCheckShapes["Unsupported"] = 4] = "Unsupported";
16488
16499
  })(TypeCheckShapes || (TypeCheckShapes = {}));
16489
- // engine version: 0.146.0-dev4-c265089a
16500
+ // engine version: 0.146.0-dev5-a2ec6e3f
16490
16501
 
16491
16502
  const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
16492
16503
 
@@ -19829,7 +19840,7 @@
19829
19840
  extractTrackedFieldsToTrie(spanningLink.data.__ref, spanning, next, config, spanningVisitedRecordIds, depth + 1);
19830
19841
  // For a spanning record that is detected to be a circular reference, we add the field along with Id and Name.
19831
19842
  // It's possible for spanning record lookup fields to sometimes be circular, and sometimes not - depending on the value of the lookup field.
19832
- // For more information on scenarios that caused this fix: https://salesforce.quip.com/OvzNAh3eNIWY
19843
+ // For more information on scenarios that caused this fix: search "LDS Recursive Spanning Fields Problem" in Quip
19833
19844
  if (keys$a(next.children).length === 0) {
19834
19845
  addScalarFieldId(next);
19835
19846
  addScalarFieldName(next);
@@ -20014,22 +20025,12 @@
20014
20025
  const fieldValueRepresentation = record.object('fields');
20015
20026
  const fieldName = path.shift();
20016
20027
  if (fieldValueRepresentation.isUndefined(fieldName) === true) {
20017
- // TODO [W-6900046]: remove cast, make RecordRepresentationNormalized['fields'] accept
20018
- // an undefined/non-present __ref if isMissing is present
20019
- fieldValueRepresentation.write(fieldName, {
20020
- __ref: undefined,
20021
- isMissing: true,
20022
- });
20028
+ writeMissingFieldToStore(fieldValueRepresentation, fieldName);
20023
20029
  return;
20024
20030
  }
20025
20031
  const link = fieldValueRepresentation.link(fieldName);
20026
20032
  if (link.isPending()) {
20027
- // TODO [W-6900046]: remove cast, make RecordRepresentationNormalized['fields'] accept
20028
- // an undefined/non-present __ref if isMissing is present
20029
- fieldValueRepresentation.write(fieldName, {
20030
- __ref: undefined,
20031
- isMissing: true,
20032
- });
20033
+ writeMissingFieldToStore(fieldValueRepresentation, fieldName);
20033
20034
  }
20034
20035
  else if (path.length > 0 && link.isMissing() === false) {
20035
20036
  const fieldValue = link.follow();
@@ -20045,6 +20046,19 @@
20045
20046
  }
20046
20047
  }
20047
20048
  }
20049
+ /**
20050
+ * Graph Node Directly modifies store entries, which is generally a non-starter.
20051
+ * Until we can refactor this mess, you need to use this function to safely mark the RecordRepresentation
20052
+ * as a seenId in the store when you perform this mutation.
20053
+ */
20054
+ function writeMissingFieldToStore(field, fieldName) {
20055
+ // TODO [W-6900046]: remove cast, make RecordRepresentationNormalized['fields'] accept
20056
+ // an undefined/non-present __ref if isMissing is present
20057
+ field.write(fieldName, {
20058
+ __ref: undefined,
20059
+ isMissing: true,
20060
+ });
20061
+ }
20048
20062
  /**
20049
20063
  * Tells you if an objectApiName is supported by UI API or not.
20050
20064
  * Note: Luvio does not currently support all the entities, the list is limited to UI API supported entities
@@ -20176,8 +20190,11 @@
20176
20190
  return existing;
20177
20191
  }
20178
20192
  function mergeRecordConflict(luvio, incoming, existing, recordConflictMap) {
20179
- const incomingNode = luvio.wrapNormalizedGraphNode(incoming);
20180
- const existingNode = luvio.wrapNormalizedGraphNode(existing);
20193
+ const recordKey = keyBuilder$1U(luvio, {
20194
+ recordId: incoming.id,
20195
+ });
20196
+ const incomingNode = luvio.wrapNormalizedGraphNode(incoming, recordKey);
20197
+ const existingNode = luvio.wrapNormalizedGraphNode(existing, recordKey);
20181
20198
  const incomingTrackedFieldsTrieRoot = {
20182
20199
  name: incoming.apiName,
20183
20200
  children: {},
@@ -20186,9 +20203,6 @@
20186
20203
  name: existing.apiName,
20187
20204
  children: {},
20188
20205
  };
20189
- const recordKey = keyBuilder$1U(luvio, {
20190
- recordId: incoming.id,
20191
- });
20192
20206
  const trackedFieldsConfig = {
20193
20207
  maxDepth: configurationForRestAdapters$1.getTrackedFieldDepthOnCacheMergeConflict(),
20194
20208
  onlyFetchLeafNodeIdAndName: configurationForRestAdapters$1.getTrackedFieldLeafNodeIdAndNameOnly(),
@@ -25309,7 +25323,7 @@
25309
25323
  const responsePromises = [];
25310
25324
  for (let i = 0, len = entries.length; i < len; i++) {
25311
25325
  const { key, record } = entries[i];
25312
- const node = luvio.wrapNormalizedGraphNode(record);
25326
+ const node = luvio.wrapNormalizedGraphNode(record, key);
25313
25327
  const optionalFields = getTrackedFields(key, node, {
25314
25328
  maxDepth: configurationForRestAdapters$1.getTrackedFieldDepthOnNotifyChange(),
25315
25329
  onlyFetchLeafNodeIdAndName: configurationForRestAdapters$1.getTrackedFieldLeafNodeIdAndNameOnly(),
@@ -41207,7 +41221,16 @@
41207
41221
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyListInfoUpdateAvailable', notifyUpdateAvailableFactory$1));
41208
41222
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyQuickActionDefaultsUpdateAvailable', notifyUpdateAvailableFactory));
41209
41223
  });
41210
- // version: 1.229.0-dev7-22b616ee5
41224
+ // version: 1.229.0-dev9-939b09095
41225
+
41226
+ var ldsIdempotencyWriteDisabled = {
41227
+ isOpen: function (e) {
41228
+ return e.fallback;
41229
+ },
41230
+ hasError: function () {
41231
+ return !0;
41232
+ },
41233
+ };
41211
41234
 
41212
41235
  var caseSensitiveUserId = '005B0000000GR4OIAW';
41213
41236
 
@@ -42425,12 +42448,12 @@
42425
42448
  }
42426
42449
  return environment.getNode(key, ingestStagingStore);
42427
42450
  };
42428
- const wrapNormalizedGraphNode = function (normalized) {
42451
+ const wrapNormalizedGraphNode = function (normalized, key) {
42429
42452
  validateNotDisposed();
42430
42453
  if (ingestStagingStore === null) {
42431
42454
  ingestStagingStore = buildIngestStagingStore(environment);
42432
42455
  }
42433
- return environment.wrapNormalizedGraphNode(normalized, ingestStagingStore);
42456
+ return environment.wrapNormalizedGraphNode(normalized, key, ingestStagingStore);
42434
42457
  };
42435
42458
  const rebuildSnapshot = function (snapshot, onRebuild) {
42436
42459
  validateNotDisposed();
@@ -47222,7 +47245,12 @@
47222
47245
  // the luvio store redirect table, during which a new draft might be enqueued
47223
47246
  // which would not see a necessary mapping.
47224
47247
  this.ephemeralRedirects = {};
47248
+ // determined by Server setup.
47225
47249
  this.isIdempotencySupported = true;
47250
+ // idempotency write flag set by lds
47251
+ this.isLdsIdempotencyWriteDisabled = ldsIdempotencyWriteDisabled.isOpen({
47252
+ fallback: false,
47253
+ });
47226
47254
  }
47227
47255
  enqueue(data) {
47228
47256
  return this.draftQueue.enqueue(this.handlerId, data);
@@ -47582,7 +47610,7 @@
47582
47610
  return [action.targetId];
47583
47611
  }
47584
47612
  hasIdempotencySupport() {
47585
- return this.isIdempotencySupported;
47613
+ return this.isIdempotencySupported && !this.isLdsIdempotencyWriteDisabled;
47586
47614
  }
47587
47615
  async ingestResponses(responses, action) {
47588
47616
  const luvio = this.getLuvio();
@@ -53037,34 +53065,42 @@
53037
53065
  }
53038
53066
  const { dataType, relationshipName, referenceToInfos } = fieldInfo;
53039
53067
  const draftFieldValue = record.fields[draftField].value;
53040
- if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
53041
- if (typeof draftFieldValue !== 'string') {
53042
- throw Error('reference field value is not a string');
53068
+ if (dataType === 'Reference' && relationshipName !== null) {
53069
+ if (draftFieldValue === null) {
53070
+ recordFields[relationshipName] = {
53071
+ displayValue: null,
53072
+ value: null,
53073
+ };
53043
53074
  }
53044
- const key = getRecordKeyForId(luvio, draftFieldValue);
53045
- const referencedRecord = referencedRecords.get(key);
53046
- recordFields[relationshipName] = {
53047
- displayValue: null,
53048
- value: createLink$2(key),
53049
- };
53050
- // for custom objects, we select the 'Name' field
53051
- // otherwise we check the object info for name fields.
53052
- //if there are multiple we select 'Name' if it exists, otherwise the first one
53053
- if (referencedRecord !== undefined && referenceToInfos.length > 0) {
53054
- let nameField;
53055
- const referenceToInfo = referenceToInfos[0];
53056
- const nameFields = referenceToInfo.nameFields;
53057
- if (nameFields.length !== 0) {
53058
- nameField = nameFields.find((x) => x === 'Name');
53059
- if (nameField === undefined) {
53060
- nameField = nameFields[0];
53061
- }
53075
+ else {
53076
+ if (typeof draftFieldValue !== 'string') {
53077
+ throw Error('reference field value is not a string');
53062
53078
  }
53063
- if (nameField !== undefined) {
53064
- const nameFieldRef = referencedRecord.fields[nameField];
53065
- if (nameFieldRef) {
53066
- recordFields[relationshipName].displayValue =
53067
- (_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
53079
+ const key = getRecordKeyForId(luvio, draftFieldValue);
53080
+ const referencedRecord = referencedRecords.get(key);
53081
+ recordFields[relationshipName] = {
53082
+ displayValue: null,
53083
+ value: createLink$2(key),
53084
+ };
53085
+ // for custom objects, we select the 'Name' field
53086
+ // otherwise we check the object info for name fields.
53087
+ //if there are multiple we select 'Name' if it exists, otherwise the first one
53088
+ if (referencedRecord !== undefined && referenceToInfos.length > 0) {
53089
+ let nameField;
53090
+ const referenceToInfo = referenceToInfos[0];
53091
+ const nameFields = referenceToInfo.nameFields;
53092
+ if (nameFields.length !== 0) {
53093
+ nameField = nameFields.find((x) => x === 'Name');
53094
+ if (nameField === undefined) {
53095
+ nameField = nameFields[0];
53096
+ }
53097
+ }
53098
+ if (nameField !== undefined) {
53099
+ const nameFieldRef = referencedRecord.fields[nameField];
53100
+ if (nameFieldRef) {
53101
+ recordFields[relationshipName].displayValue =
53102
+ (_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
53103
+ }
53068
53104
  }
53069
53105
  }
53070
53106
  }
@@ -53357,17 +53393,8 @@
53357
53393
  };
53358
53394
  for (const fieldName of keys$3(recordWithSpanningRefLinks.fields)) {
53359
53395
  const fieldKey = buildRecordFieldStoreKey(key, fieldName);
53360
- if (this.collectedFields[fieldKey] !== undefined) {
53361
- const fieldData = recordWithSpanningRefLinks.fields[fieldName];
53362
- normalizedRecord.fields[fieldName] = { __ref: fieldKey };
53363
- publishData(fieldKey, fieldData);
53364
- }
53365
- else if (recordWithSpanningRefLinks.fields[fieldName] &&
53366
- recordWithSpanningRefLinks.fields[fieldName].value &&
53367
- recordWithSpanningRefLinks.fields[fieldName].value.__ref !== undefined) {
53368
- normalizedRecord.fields[fieldName] = { __ref: fieldKey };
53369
- publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
53370
- }
53396
+ normalizedRecord.fields[fieldName] = { __ref: fieldKey };
53397
+ publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
53371
53398
  }
53372
53399
  // publish the normalized record
53373
53400
  publishData(key, normalizedRecord);
@@ -58055,7 +58082,7 @@
58055
58082
  id: '@salesforce/lds-network-adapter',
58056
58083
  instrument: instrument$1,
58057
58084
  });
58058
- // version: 1.229.0-dev7-157e3a4db
58085
+ // version: 1.229.0-dev9-dd96b5901
58059
58086
 
58060
58087
  const { create: create$2, keys: keys$2 } = Object;
58061
58088
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -76487,7 +76514,7 @@
76487
76514
  configuration: { ...configurationForGraphQLAdapters },
76488
76515
  instrument,
76489
76516
  });
76490
- // version: 1.229.0-dev7-22b616ee5
76517
+ // version: 1.229.0-dev9-939b09095
76491
76518
 
76492
76519
  // On core the unstable adapters are re-exported with different names,
76493
76520
 
@@ -78734,7 +78761,7 @@
78734
78761
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
78735
78762
  graphQLImperative = ldsAdapter;
78736
78763
  });
78737
- // version: 1.229.0-dev7-22b616ee5
78764
+ // version: 1.229.0-dev9-939b09095
78738
78765
 
78739
78766
  var gqlApi = /*#__PURE__*/Object.freeze({
78740
78767
  __proto__: null,
@@ -79465,4 +79492,4 @@
79465
79492
  Object.defineProperty(exports, '__esModule', { value: true });
79466
79493
 
79467
79494
  }));
79468
- // version: 1.229.0-dev7-157e3a4db
79495
+ // version: 1.229.0-dev9-dd96b5901
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.229.0-dev7",
3
+ "version": "1.229.0-dev9",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",
@@ -35,15 +35,15 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
38
- "@salesforce/lds-adapters-graphql": "1.229.0-dev7",
39
- "@salesforce/lds-adapters-uiapi": "1.229.0-dev7",
40
- "@salesforce/lds-default-luvio": "1.229.0-dev7",
41
- "@salesforce/lds-drafts": "1.229.0-dev7",
42
- "@salesforce/lds-graphql-parser": "1.229.0-dev7",
43
- "@salesforce/lds-luvio-engine": "1.229.0-dev7",
44
- "@salesforce/lds-priming": "1.229.0-dev7",
45
- "@salesforce/lds-runtime-mobile": "1.229.0-dev7",
46
- "@salesforce/nimbus-plugin-lds": "1.229.0-dev7",
38
+ "@salesforce/lds-adapters-graphql": "1.229.0-dev9",
39
+ "@salesforce/lds-adapters-uiapi": "1.229.0-dev9",
40
+ "@salesforce/lds-default-luvio": "1.229.0-dev9",
41
+ "@salesforce/lds-drafts": "1.229.0-dev9",
42
+ "@salesforce/lds-graphql-parser": "1.229.0-dev9",
43
+ "@salesforce/lds-luvio-engine": "1.229.0-dev9",
44
+ "@salesforce/lds-priming": "1.229.0-dev9",
45
+ "@salesforce/lds-runtime-mobile": "1.229.0-dev9",
46
+ "@salesforce/nimbus-plugin-lds": "1.229.0-dev9",
47
47
  "ajv": "^8.11.0",
48
48
  "glob": "^7.1.5",
49
49
  "nimbus-types": "^2.0.0-alpha1",