@salesforce/lds-worker-api 1.130.10 → 1.131.0-dev11

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.
@@ -26,26 +26,26 @@
26
26
  SnapshotState["Stale"] = "Stale";
27
27
  })(SnapshotState$3 || (SnapshotState$3 = {}));
28
28
 
29
- const { create: create$9, entries: entries$4, freeze: freeze$4, keys: keys$9, values: values$3 } = Object;
29
+ const { create: create$9, entries: entries$4, freeze: freeze$4, keys: keys$a, values: values$3 } = Object;
30
30
  const { hasOwnProperty: hasOwnProperty$3 } = Object.prototype;
31
31
  const { isArray: isArray$a } = Array;
32
32
  const { push: push$4, indexOf, slice: slice$2 } = Array.prototype;
33
33
  const { parse: parse$9, stringify: stringify$9 } = JSON;
34
34
 
35
- function deepFreeze$R(value) {
35
+ function deepFreeze$S(value) {
36
36
  // No need to freeze primitives
37
37
  if (typeof value !== 'object' || value === null) {
38
38
  return;
39
39
  }
40
40
  if (isArray$a(value)) {
41
41
  for (let i = 0, len = value.length; i < len; i += 1) {
42
- deepFreeze$R(value[i]);
42
+ deepFreeze$S(value[i]);
43
43
  }
44
44
  }
45
45
  else {
46
- const keys$1 = keys$9(value);
46
+ const keys$1 = keys$a(value);
47
47
  for (let i = 0, len = keys$1.length; i < len; i += 1) {
48
- deepFreeze$R(value[keys$1[i]]);
48
+ deepFreeze$S(value[keys$1[i]]);
49
49
  }
50
50
  }
51
51
  freeze$4(value);
@@ -67,7 +67,7 @@
67
67
  return snapshot.state === SnapshotState$3.Pending;
68
68
  }
69
69
  function createErrorSnapshot$1(error, refresh) {
70
- deepFreeze$R(error);
70
+ deepFreeze$S(error);
71
71
  const snap = {
72
72
  error,
73
73
  state: SnapshotState$3.Error,
@@ -304,7 +304,7 @@
304
304
  if (node === null) {
305
305
  return 'null';
306
306
  }
307
- const keys$1 = keys$9(node).sort();
307
+ const keys$1 = keys$a(node).sort();
308
308
  out = '';
309
309
  for (i = 0; i < keys$1.length; i++) {
310
310
  const key = keys$1[i];
@@ -575,13 +575,13 @@
575
575
  return this.records[this.getCanonicalRecordId(key)];
576
576
  }
577
577
  getNumEntries() {
578
- return keys$9(this.records).length;
578
+ return keys$a(this.records).length;
579
579
  }
580
580
  readMetadata(key) {
581
581
  return this.metadata[this.getCanonicalRecordId(key)];
582
582
  }
583
583
  readMetadataWhere(query) {
584
- const keys$1 = keys$9(this.metadata);
584
+ const keys$1 = keys$a(this.metadata);
585
585
  const results = [];
586
586
  const hasNamespaceQuery = hasOwnProperty$3.call(query, 'namespace');
587
587
  const hasRepresentationNameQuery = hasOwnProperty$3.call(query, 'representationName');
@@ -606,9 +606,8 @@
606
606
  }
607
607
  return results;
608
608
  }
609
- publish(recordId, record) {
609
+ put(recordId, record) {
610
610
  const { records, insertedIds, pendingTrimKeys, retainedIds } = this;
611
- // make sure we publish to the canonical record id in case it's been redirected
612
611
  const canonicalKey = this.getCanonicalRecordId(recordId);
613
612
  if (hasOwnProperty$3.call(records, canonicalKey) === false) {
614
613
  insertedIds[canonicalKey] = true;
@@ -621,6 +620,11 @@
621
620
  if (retainedIds[canonicalKey] === undefined) {
622
621
  pendingTrimKeys.add(canonicalKey);
623
622
  }
623
+ }
624
+ publish(recordId, record) {
625
+ // make sure we publish to the canonical record id in case it's been redirected
626
+ const canonicalKey = this.getCanonicalRecordId(recordId);
627
+ this.put(canonicalKey, record);
624
628
  this.markVisited(canonicalKey);
625
629
  // TODO: Emit event for store publish once structured keys are used everywhere.
626
630
  }
@@ -657,7 +661,8 @@
657
661
  if (key === canonicalKey) {
658
662
  throw new Error('cannot redirect a key to itself');
659
663
  }
660
- if (reverseRedirectKeys[canonicalKey] !== undefined) {
664
+ if (reverseRedirectKeys[canonicalKey] !== undefined &&
665
+ reverseRedirectKeys[canonicalKey] !== key) {
661
666
  throw new Error('cannot have multiple redirects keys point to the same canonical key');
662
667
  }
663
668
  if (redirectKeys[canonicalKey] !== undefined) {
@@ -673,8 +678,8 @@
673
678
  // Note: we should always get the subscription references from this at the beginning
674
679
  // of the function, in case the reference changes (because of an unsubscribe)
675
680
  const { snapshotSubscriptions, watchSubscriptions, visitedIds, refreshedIds, insertedIds } = this;
676
- const allVisitedIds = keys$9(visitedIds);
677
- const allRefreshedIds = keys$9(refreshedIds);
681
+ const allVisitedIds = keys$a(visitedIds);
682
+ const allRefreshedIds = keys$a(refreshedIds);
678
683
  // Early exit if nothing has changed
679
684
  if (allVisitedIds.length === 0 && allRefreshedIds.length === 0) {
680
685
  return Promise.resolve();
@@ -829,14 +834,7 @@
829
834
  // find and evict the canonical key
830
835
  const canonicalKey = this.getCanonicalRecordId(key);
831
836
  delete this.records[canonicalKey];
832
- this.visitedIds[canonicalKey] = true;
833
- // mark all redirects leading up to the canonical key as visited so
834
- // affected snapshots are updated
835
- let redirectKey = this.reverseRedirectKeys[canonicalKey];
836
- while (redirectKey !== undefined) {
837
- this.visitedIds[redirectKey] = true;
838
- redirectKey = this.reverseRedirectKeys[redirectKey];
839
- }
837
+ this.markVisited(canonicalKey);
840
838
  }
841
839
  /**
842
840
  * Deallocates data at the canonical key location for in-memory (L1) cache
@@ -1128,7 +1126,7 @@
1128
1126
  hasOverlappingIds(snapshot, visitedIds) === false);
1129
1127
  }
1130
1128
  function getMatchingIds(partialKey, visitedIds) {
1131
- const keys$1 = keys$9(partialKey);
1129
+ const keys$1 = keys$a(partialKey);
1132
1130
  return visitedIds.filter((visitedId) => {
1133
1131
  return keys$1.every((key) => {
1134
1132
  return partialKey[key] === visitedId[key];
@@ -1214,9 +1212,9 @@
1214
1212
  }
1215
1213
  return results;
1216
1214
  }
1217
- publish(recordId, record) {
1215
+ put(recordId, record) {
1218
1216
  if (typeof recordId === 'string') {
1219
- this.fallbackStringKeyInMemoryStore.publish(recordId, record);
1217
+ this.fallbackStringKeyInMemoryStore.put(recordId, record);
1220
1218
  return;
1221
1219
  }
1222
1220
  const { recordsMap, insertedIdsSet, pendingTrims, retainedIdsMap } = this;
@@ -1233,6 +1231,14 @@
1233
1231
  if (retainedIdsMap.get(canonicalKey) === undefined) {
1234
1232
  pendingTrims.add(canonicalKey);
1235
1233
  }
1234
+ }
1235
+ publish(recordId, record) {
1236
+ if (typeof recordId === 'string') {
1237
+ this.fallbackStringKeyInMemoryStore.publish(recordId, record);
1238
+ return;
1239
+ }
1240
+ const canonicalKey = this.getCanonicalRecordId(recordId);
1241
+ this.put(canonicalKey, record);
1236
1242
  this.markVisited(canonicalKey);
1237
1243
  this.emitStorePublishEvent(recordId);
1238
1244
  }
@@ -1469,14 +1475,7 @@
1469
1475
  // find and evict the canonical key
1470
1476
  const canonicalKey = this.getCanonicalRecordId(key);
1471
1477
  this.recordsMap.delete(canonicalKey);
1472
- this.visitedIdsSet.add(canonicalKey);
1473
- // mark all redirects leading up to the canonical key as visited so
1474
- // affected snapshots are updated
1475
- let redirectKey = this.reverseRedirectKeysMap.get(canonicalKey);
1476
- while (redirectKey !== undefined) {
1477
- this.visitedIdsSet.add(redirectKey);
1478
- redirectKey = this.reverseRedirectKeysMap.get(redirectKey);
1479
- }
1478
+ this.markVisited(canonicalKey);
1480
1479
  }
1481
1480
  /**
1482
1481
  * Deallocates data at the canonical key location for in-memory (L1) cache
@@ -1754,8 +1753,8 @@
1754
1753
  } while (redirectKey !== undefined);
1755
1754
  }
1756
1755
  isUsingStringKeys() {
1757
- return (keys$9(this.fallbackStringKeyInMemoryStore.visitedIds).length !== 0 ||
1758
- keys$9(this.fallbackStringKeyInMemoryStore.refreshedIds).length !== 0);
1756
+ return (keys$a(this.fallbackStringKeyInMemoryStore.visitedIds).length !== 0 ||
1757
+ keys$a(this.fallbackStringKeyInMemoryStore.refreshedIds).length !== 0);
1759
1758
  }
1760
1759
  delegateToFallbackStringKeyStore(snapshot) {
1761
1760
  return !isErrorSnapshot$3(snapshot) && typeof snapshot.recordId === 'string';
@@ -1797,7 +1796,7 @@
1797
1796
  buildKeySchema(keyMetadata) {
1798
1797
  // pull NamespacedType type out of NormalizedKeyMetadata
1799
1798
  const { namespace: _ns, representationName: _rn, ...keyParamValues } = keyMetadata;
1800
- const keySchema = keys$9(keyParamValues).sort();
1799
+ const keySchema = keys$a(keyParamValues).sort();
1801
1800
  return ['namespace', 'representationName', ...keySchema];
1802
1801
  }
1803
1802
  }
@@ -2085,7 +2084,7 @@
2085
2084
  return value;
2086
2085
  }
2087
2086
  keys() {
2088
- return keys$9(this.data);
2087
+ return keys$a(this.data);
2089
2088
  }
2090
2089
  isScalar(propertyName) {
2091
2090
  // TODO W-6900046 - merge.ts casts these to any and manually sets `data`
@@ -2463,7 +2462,7 @@
2463
2462
  }
2464
2463
  }
2465
2464
  selectAllObject(record, data, visitedKeys) {
2466
- const recordKeys = keys$9(record);
2465
+ const recordKeys = keys$a(record);
2467
2466
  const { length } = recordKeys;
2468
2467
  for (let i = 0; i < length; i += 1) {
2469
2468
  const key = recordKeys[i];
@@ -2646,7 +2645,7 @@
2646
2645
  }
2647
2646
  const { baseSnapshotValue } = this.currentPath;
2648
2647
  if (isDefined$1(baseSnapshotValue)) {
2649
- this.snapshotChanged = keys$1.length !== keys$9(baseSnapshotValue).length;
2648
+ this.snapshotChanged = keys$1.length !== keys$a(baseSnapshotValue).length;
2650
2649
  }
2651
2650
  }
2652
2651
  checkIfChanged(value) {
@@ -2682,7 +2681,7 @@
2682
2681
  return this.markMissing();
2683
2682
  }
2684
2683
  const sink = (data[propertyName] = {});
2685
- const keys$1 = keys$9(obj);
2684
+ const keys$1 = keys$a(obj);
2686
2685
  this.checkIfObjectKeysLengthChanged(keys$1);
2687
2686
  for (let i = 0, len = keys$1.length; i < len; i += 1) {
2688
2687
  const key = keys$1[i];
@@ -2694,7 +2693,7 @@
2694
2693
  }
2695
2694
  readLinkMap(propertyName, selection, record, data) {
2696
2695
  const map = record[propertyName];
2697
- const keys$1 = keys$9(map);
2696
+ const keys$1 = keys$a(map);
2698
2697
  const sink = {};
2699
2698
  this.checkIfObjectKeysLengthChanged(keys$1);
2700
2699
  for (let i = 0, len = keys$1.length; i < len; i += 1) {
@@ -2824,7 +2823,7 @@
2824
2823
  return;
2825
2824
  }
2826
2825
  const sink = (data[propertyName] = {});
2827
- const keys$1 = keys$9(obj);
2826
+ const keys$1 = keys$a(obj);
2828
2827
  this.checkIfObjectKeysLengthChanged(keys$1);
2829
2828
  for (let i = 0, len = keys$1.length; i < len; i += 1) {
2830
2829
  const key = keys$1[i];
@@ -3172,9 +3171,14 @@
3172
3171
  // since broadcast only deals with cached recordIds
3173
3172
  this.store.broadcastNonCachedSnapshot(key, errorSnapshot);
3174
3173
  }
3174
+ // Adds the given data to the store at the given key and marks the key as visited. Will cause subscribers to rebuild.
3175
3175
  storePublish(key, data) {
3176
3176
  this.store.publish(key, data);
3177
3177
  }
3178
+ // Adds the given data to the store at the given key (does NOT mark the key as visited). Will NOT cause subscribers to rebuild. NOTE: This should really only be used by internal Luvio APIs.
3179
+ storePut(key, data) {
3180
+ this.store.put(key, data);
3181
+ }
3178
3182
  storeRedirect(existingKey, redirectKey) {
3179
3183
  this.store.redirect(existingKey, redirectKey);
3180
3184
  }
@@ -3655,7 +3659,7 @@
3655
3659
  return this.environment.buildStructuredKey(namespace, representationName, idValues);
3656
3660
  }
3657
3661
  }
3658
- // engine version: 0.138.8-480e18f2
3662
+ // engine version: 0.138.8-244.1-492a715e
3659
3663
 
3660
3664
  /**
3661
3665
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3782,7 +3786,7 @@
3782
3786
  }
3783
3787
  callbacks.push(callback);
3784
3788
  }
3785
- // version: 1.130.10-0fac4c295
3789
+ // version: 1.131.0-dev11-b15472a13
3786
3790
 
3787
3791
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3788
3792
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -3791,6 +3795,15 @@
3791
3795
  function setLdsNetworkAdapterInstrumentation(_networkAdapterRegistration) { }
3792
3796
  function instrumentLuvio(_context) { }
3793
3797
 
3798
+ var excludeStaleRecordsGate = {
3799
+ isOpen: function (e) {
3800
+ return e.fallback;
3801
+ },
3802
+ hasError: function () {
3803
+ return !0;
3804
+ },
3805
+ };
3806
+
3794
3807
  /**
3795
3808
  * Copyright (c) 2022, Salesforce, Inc.,
3796
3809
  * All rights reserved.
@@ -15206,7 +15219,7 @@
15206
15219
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15207
15220
  return luvioDocumentNode;
15208
15221
  }
15209
- // version: 1.130.10-0fac4c295
15222
+ // version: 1.131.0-dev11-b15472a13
15210
15223
 
15211
15224
  function unwrap(data) {
15212
15225
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16119,7 +16132,7 @@
16119
16132
  const { apiFamily, name } = metadata;
16120
16133
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16121
16134
  }
16122
- // version: 1.130.10-0fac4c295
16135
+ // version: 1.131.0-dev11-b15472a13
16123
16136
 
16124
16137
  /**
16125
16138
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16202,7 +16215,7 @@
16202
16215
  ({
16203
16216
  state: FragmentReadResultState.Missing,
16204
16217
  });
16205
- // engine version: 0.138.8-480e18f2
16218
+ // engine version: 0.138.8-244.1-492a715e
16206
16219
 
16207
16220
  const { keys: ObjectKeys$3, freeze: ObjectFreeze$3, create: ObjectCreate$3 } = Object;
16208
16221
 
@@ -16548,7 +16561,7 @@
16548
16561
  return `Unexpected HTTP Status Code: ${status}`;
16549
16562
  }
16550
16563
  }
16551
- function isUnfulfilledSnapshot$1(snapshot) {
16564
+ function isUnfulfilledSnapshot$1$1(snapshot) {
16552
16565
  return snapshot.state === SNAPSHOT_STATE_UNFULFILLED;
16553
16566
  }
16554
16567
  const keyPrefix$1 = 'UiApi';
@@ -16588,20 +16601,20 @@
16588
16601
  }
16589
16602
  return true;
16590
16603
  }
16591
- function deepFreeze$P(value) {
16604
+ function deepFreeze$Q(value) {
16592
16605
  // No need to freeze primitives
16593
16606
  if (typeof value !== 'object' || value === null) {
16594
16607
  return;
16595
16608
  }
16596
16609
  if (ArrayIsArray$2(value)) {
16597
16610
  for (let i = 0, len = value.length; i < len; i += 1) {
16598
- deepFreeze$P(value[i]);
16611
+ deepFreeze$Q(value[i]);
16599
16612
  }
16600
16613
  }
16601
16614
  else {
16602
16615
  const keys = ObjectKeys$2(value);
16603
16616
  for (let i = 0, len = keys.length; i < len; i += 1) {
16604
- deepFreeze$P(value[keys[i]]);
16617
+ deepFreeze$Q(value[keys[i]]);
16605
16618
  }
16606
16619
  }
16607
16620
  ObjectFreeze$2(value);
@@ -16669,7 +16682,7 @@
16669
16682
  ]
16670
16683
  };
16671
16684
  };
16672
- function deepFreeze$O(input) {
16685
+ function deepFreeze$P(input) {
16673
16686
  const input_operandLabels = input.operandLabels;
16674
16687
  ObjectFreeze$2(input_operandLabels);
16675
16688
  ObjectFreeze$2(input);
@@ -16747,7 +16760,7 @@
16747
16760
  ]
16748
16761
  };
16749
16762
  };
16750
- function deepFreeze$N(input) {
16763
+ function deepFreeze$O(input) {
16751
16764
  ObjectFreeze$2(input);
16752
16765
  }
16753
16766
 
@@ -16771,7 +16784,7 @@
16771
16784
  ]
16772
16785
  };
16773
16786
  };
16774
- function deepFreeze$M(input) {
16787
+ function deepFreeze$N(input) {
16775
16788
  const input_columnWidths = input.columnWidths;
16776
16789
  const input_columnWidths_keys = Object.keys(input_columnWidths);
16777
16790
  const input_columnWidths_length = input_columnWidths_keys.length;
@@ -16790,7 +16803,7 @@
16790
16803
  }
16791
16804
 
16792
16805
  const TTL$x = 900000;
16793
- const VERSION$18 = "ce51760eb46b65c484f42de806102162";
16806
+ const VERSION$18 = "69101560544e3433c988f3a2b202744b";
16794
16807
  const RepresentationType$Q = 'ListInfoRepresentation';
16795
16808
  function keyBuilder$1R(luvio, config) {
16796
16809
  return keyPrefix$1 + '::' + RepresentationType$Q + ':' + (config.listViewApiName === null ? '' : config.listViewApiName) + ':' + config.objectApiName + ':' + config.type;
@@ -16856,11 +16869,6 @@
16856
16869
  kind: 'Object',
16857
16870
  selections: ListReferenceRepresentation__selections
16858
16871
  },
16859
- {
16860
- name: 'objectApiNames',
16861
- kind: 'Scalar',
16862
- plural: true
16863
- },
16864
16872
  {
16865
16873
  name: 'orderedByInfo',
16866
16874
  kind: 'Object',
@@ -16987,7 +16995,7 @@
16987
16995
  }
16988
16996
  return true;
16989
16997
  }
16990
- function deepFreeze$L(input) {
16998
+ function deepFreeze$M(input) {
16991
16999
  ObjectFreeze$2(input);
16992
17000
  }
16993
17001
 
@@ -17047,10 +17055,10 @@
17047
17055
  }
17048
17056
  return true;
17049
17057
  }
17050
- function deepFreeze$K(input) {
17058
+ function deepFreeze$L(input) {
17051
17059
  const input_value = input.value;
17052
17060
  if (input_value !== null && typeof input_value === 'object') {
17053
- deepFreeze$I(input_value);
17061
+ deepFreeze$J(input_value);
17054
17062
  }
17055
17063
  ObjectFreeze$2(input);
17056
17064
  }
@@ -17094,7 +17102,7 @@
17094
17102
  return rootKeySet;
17095
17103
  }
17096
17104
 
17097
- const { assign: assign$6, create: create$7, freeze: freeze$3, keys: keys$8 } = Object;
17105
+ const { assign: assign$7, create: create$7, freeze: freeze$3, keys: keys$9 } = Object;
17098
17106
  const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
17099
17107
  const { split, endsWith } = String.prototype;
17100
17108
  const { isArray: isArray$8 } = Array;
@@ -17112,7 +17120,7 @@
17112
17120
  mergeable: true,
17113
17121
  });
17114
17122
  const input_childRelationships = input.childRelationships;
17115
- const input_childRelationships_keys = keys$8(input_childRelationships);
17123
+ const input_childRelationships_keys = keys$9(input_childRelationships);
17116
17124
  const input_childRelationships_length = input_childRelationships_keys.length;
17117
17125
  for (let i = 0; i < input_childRelationships_length; i++) {
17118
17126
  const key = input_childRelationships_keys[i];
@@ -17120,7 +17128,7 @@
17120
17128
  rootKeySet.merge(cacheKeys);
17121
17129
  }
17122
17130
  const input_fields = input.fields;
17123
- const input_fields_keys = keys$8(input_fields);
17131
+ const input_fields_keys = keys$9(input_fields);
17124
17132
  const input_fields_length = input_fields_keys.length;
17125
17133
  for (let i = 0; i < input_fields_length; i++) {
17126
17134
  const key = input_fields_keys[i];
@@ -17243,11 +17251,11 @@
17243
17251
  }
17244
17252
  return true;
17245
17253
  }
17246
- function deepFreeze$J(input) {
17254
+ function deepFreeze$K(input) {
17247
17255
  const input_records = input.records;
17248
17256
  for (let i = 0; i < input_records.length; i++) {
17249
17257
  const input_records_item = input_records[i];
17250
- deepFreeze$I(input_records_item);
17258
+ deepFreeze$J(input_records_item);
17251
17259
  }
17252
17260
  ObjectFreeze$2(input_records);
17253
17261
  ObjectFreeze$2(input);
@@ -17540,14 +17548,14 @@
17540
17548
  }
17541
17549
  return true;
17542
17550
  }
17543
- function deepFreeze$I(input) {
17551
+ function deepFreeze$J(input) {
17544
17552
  const input_childRelationships = input.childRelationships;
17545
17553
  const input_childRelationships_keys = Object.keys(input_childRelationships);
17546
17554
  const input_childRelationships_length = input_childRelationships_keys.length;
17547
17555
  for (let i = 0; i < input_childRelationships_length; i++) {
17548
17556
  const key = input_childRelationships_keys[i];
17549
17557
  const input_childRelationships_prop = input_childRelationships[key];
17550
- deepFreeze$J(input_childRelationships_prop);
17558
+ deepFreeze$K(input_childRelationships_prop);
17551
17559
  }
17552
17560
  ObjectFreeze$2(input_childRelationships);
17553
17561
  const input_fields = input.fields;
@@ -17556,12 +17564,12 @@
17556
17564
  for (let i = 0; i < input_fields_length; i++) {
17557
17565
  const key = input_fields_keys[i];
17558
17566
  const input_fields_prop = input_fields[key];
17559
- deepFreeze$K(input_fields_prop);
17567
+ deepFreeze$L(input_fields_prop);
17560
17568
  }
17561
17569
  ObjectFreeze$2(input_fields);
17562
17570
  const input_recordTypeInfo = input.recordTypeInfo;
17563
17571
  if (input_recordTypeInfo !== null && typeof input_recordTypeInfo === 'object') {
17564
- deepFreeze$L(input_recordTypeInfo);
17572
+ deepFreeze$M(input_recordTypeInfo);
17565
17573
  }
17566
17574
  ObjectFreeze$2(input);
17567
17575
  }
@@ -17621,7 +17629,7 @@
17621
17629
  for (let i = 0, len = value.length; i < len; i += 1) {
17622
17630
  result[value[i]] = true;
17623
17631
  }
17624
- return keys$8(result);
17632
+ return keys$9(result);
17625
17633
  }
17626
17634
  /**
17627
17635
  * @param source The array of string to filter
@@ -19069,7 +19077,7 @@
19069
19077
  function createPathSelection(propertyName, fieldDefinition) {
19070
19078
  const fieldsSelection = [];
19071
19079
  const { children } = fieldDefinition;
19072
- const childrenKeys = keys$8(children);
19080
+ const childrenKeys = keys$9(children);
19073
19081
  for (let i = 0, len = childrenKeys.length; i < len; i += 1) {
19074
19082
  const childKey = childrenKeys[i];
19075
19083
  const childFieldDefinition = children[childKey];
@@ -19114,7 +19122,7 @@
19114
19122
  */
19115
19123
  function createPathSelectionFromValue(fields) {
19116
19124
  const fieldsSelection = [];
19117
- const fieldNames = keys$8(fields);
19125
+ const fieldNames = keys$9(fields);
19118
19126
  for (let i = 0, len = fieldNames.length; i < len; i++) {
19119
19127
  const fieldName = fieldNames[i];
19120
19128
  const { value: fieldValue } = fields[fieldName];
@@ -19153,7 +19161,7 @@
19153
19161
  }
19154
19162
  function extractRecordFieldsRecursively(record) {
19155
19163
  const fields = [];
19156
- const fieldNames = keys$8(record.fields);
19164
+ const fieldNames = keys$9(record.fields);
19157
19165
  for (let i = 0, len = fieldNames.length; i < len; i++) {
19158
19166
  const fieldName = fieldNames[i];
19159
19167
  const { value: fieldValue } = record.fields[fieldName];
@@ -19341,7 +19349,7 @@
19341
19349
  continue;
19342
19350
  }
19343
19351
  extractTrackedFieldsToTrie(spanningLink.data.__ref, spanning, next, config, spanningVisitedRecordIds, depth + 1);
19344
- if (keys$8(next.children).length > 0) {
19352
+ if (keys$9(next.children).length > 0) {
19345
19353
  current.children[key] = next;
19346
19354
  }
19347
19355
  else {
@@ -19393,13 +19401,13 @@
19393
19401
  return endsWith.call(spanningNode.scalar('apiName'), CUSTOM_EXTERNAL_OBJECT_FIELD_SUFFIX);
19394
19402
  }
19395
19403
  function convertTrieToFields(root) {
19396
- if (keys$8(root.children).length === 0) {
19404
+ if (keys$9(root.children).length === 0) {
19397
19405
  return [];
19398
19406
  }
19399
19407
  return convertTrieToFieldsRecursively(root);
19400
19408
  }
19401
19409
  function convertTrieToFieldsRecursively(root) {
19402
- const childKeys = keys$8(root.children);
19410
+ const childKeys = keys$9(root.children);
19403
19411
  if (childKeys.length === 0) {
19404
19412
  if (root.name === '') {
19405
19413
  return [];
@@ -19436,7 +19444,7 @@
19436
19444
  function mergeFieldsTries(rootA, rootB) {
19437
19445
  const rootAchildren = rootA.children;
19438
19446
  const rootBchildren = rootB.children;
19439
- const childBKeys = keys$8(rootBchildren);
19447
+ const childBKeys = keys$9(rootBchildren);
19440
19448
  for (let i = 0, len = childBKeys.length; i < len; i++) {
19441
19449
  const childBKey = childBKeys[i];
19442
19450
  if (rootAchildren[childBKey] === undefined) {
@@ -19589,8 +19597,8 @@
19589
19597
  }
19590
19598
  const childrenA = a.children;
19591
19599
  const childrenB = b.children;
19592
- const childKeysA = keys$8(childrenA);
19593
- const childKeysB = keys$8(childrenB);
19600
+ const childKeysA = keys$9(childrenA);
19601
+ const childKeysB = keys$9(childrenB);
19594
19602
  const childKeysBLength = childKeysB.length;
19595
19603
  if (childKeysBLength > childKeysA.length) {
19596
19604
  return false;
@@ -19614,7 +19622,7 @@
19614
19622
  // RecordRepresentationNormalized['fields'] to include `pending:true` property
19615
19623
  const mergedFields = { ...newRecord.fields };
19616
19624
  const merged = { ...newRecord, fields: mergedFields };
19617
- const existingFields = keys$8(oldRecord.fields);
19625
+ const existingFields = keys$9(oldRecord.fields);
19618
19626
  for (let i = 0, len = existingFields.length; i < len; i += 1) {
19619
19627
  const spanningFieldName = existingFields[i];
19620
19628
  if (newRecord.fields[spanningFieldName] === undefined) {
@@ -19747,7 +19755,7 @@
19747
19755
  if (isGraphNode(node)) {
19748
19756
  const dependencies = node.retrieve();
19749
19757
  if (dependencies !== null) {
19750
- const depKeys = keys$8(dependencies);
19758
+ const depKeys = keys$9(dependencies);
19751
19759
  for (let i = 0, len = depKeys.length; i < len; i++) {
19752
19760
  luvio.storeEvict(depKeys[i]);
19753
19761
  }
@@ -19894,7 +19902,7 @@
19894
19902
  }
19895
19903
  for (let i = 0; i < fieldSubtries.length; i++) {
19896
19904
  const subtrie = fieldSubtries[i];
19897
- const fieldNames = keys$8(subtrie.children);
19905
+ const fieldNames = keys$9(subtrie.children);
19898
19906
  for (let i = 0; i < fieldNames.length; i++) {
19899
19907
  const fieldName = fieldNames[i];
19900
19908
  const childTrie = subtrie.children[fieldName];
@@ -20006,9 +20014,9 @@
20006
20014
  return false;
20007
20015
  }
20008
20016
  }
20009
- const headersKeys = keys$8(headers);
20017
+ const headersKeys = keys$9(headers);
20010
20018
  const headersKeyLength = headersKeys.length;
20011
- if (headersKeyLength !== keys$8(existingHeaders).length) {
20019
+ if (headersKeyLength !== keys$9(existingHeaders).length) {
20012
20020
  return false;
20013
20021
  }
20014
20022
  for (let i = 0, len = headersKeyLength; i < len; i++) {
@@ -20780,7 +20788,7 @@
20780
20788
 
20781
20789
  // iterate through the map to build configs for network calls
20782
20790
  function resolveConflict(luvio, map) {
20783
- const ids = keys$8(map.conflicts);
20791
+ const ids = keys$9(map.conflicts);
20784
20792
  if (ids.length === 0) {
20785
20793
  instrumentation$2.recordConflictsResolved(map.serverRequestCount);
20786
20794
  return;
@@ -21962,18 +21970,18 @@
21962
21970
  return {
21963
21971
  getRecordSelectionFieldSets() {
21964
21972
  const optionalPlusDefaultFields = { ...optionalFields_ };
21965
- const fields = keys$8(defaultFields_);
21973
+ const fields = keys$9(defaultFields_);
21966
21974
  for (let i = 0; i < fields.length; ++i) {
21967
21975
  const field = fields[i];
21968
21976
  if (!fields_[field] && !defaultServerFieldStatus.missingFields[field]) {
21969
21977
  optionalPlusDefaultFields[field] = true;
21970
21978
  }
21971
21979
  }
21972
- return [keys$8(fields_).sort(), keys$8(optionalPlusDefaultFields).sort()];
21980
+ return [keys$9(fields_).sort(), keys$9(optionalPlusDefaultFields).sort()];
21973
21981
  },
21974
21982
  processRecords(records) {
21975
21983
  const { missingFields } = defaultServerFieldStatus;
21976
- const fields = keys$8(missingFields);
21984
+ const fields = keys$9(missingFields);
21977
21985
  for (let i = 0; i < fields.length; ++i) {
21978
21986
  const field = fields[i], splitField = field.split('.').slice(1);
21979
21987
  for (let i = 0; i < records.length; ++i) {
@@ -22799,7 +22807,7 @@
22799
22807
  config,
22800
22808
  resolve: () => buildNetworkSnapshot$U(luvio, config, snapshotRefreshOptions$1)
22801
22809
  });
22802
- if (isUnfulfilledSnapshot$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
22810
+ if (isUnfulfilledSnapshot$1$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
22803
22811
  context.cacheSnapshot = cacheSnapshot;
22804
22812
  }
22805
22813
  return cacheSnapshot;
@@ -23685,39 +23693,39 @@
23685
23693
  return null;
23686
23694
  }, { contextId: contextId$4 });
23687
23695
  };
23688
- function deepFreeze$H(input) {
23696
+ function deepFreeze$I(input) {
23689
23697
  const input_junctionIdListNames = input.junctionIdListNames;
23690
23698
  ObjectFreeze$2(input_junctionIdListNames);
23691
23699
  const input_junctionReferenceTo = input.junctionReferenceTo;
23692
23700
  ObjectFreeze$2(input_junctionReferenceTo);
23693
23701
  ObjectFreeze$2(input);
23694
23702
  }
23695
- function deepFreeze$G(input) {
23703
+ function deepFreeze$H(input) {
23696
23704
  const input_controllingFields = input.controllingFields;
23697
23705
  ObjectFreeze$2(input_controllingFields);
23698
23706
  ObjectFreeze$2(input);
23699
23707
  }
23700
- function deepFreeze$F(input) {
23708
+ function deepFreeze$G(input) {
23701
23709
  const input_nameFields = input.nameFields;
23702
23710
  ObjectFreeze$2(input_nameFields);
23703
23711
  ObjectFreeze$2(input);
23704
23712
  }
23705
- function deepFreeze$E(input) {
23713
+ function deepFreeze$F(input) {
23706
23714
  const input_controllingFields = input.controllingFields;
23707
23715
  ObjectFreeze$2(input_controllingFields);
23708
23716
  const input_filteredLookupInfo = input.filteredLookupInfo;
23709
23717
  if (input_filteredLookupInfo !== null && typeof input_filteredLookupInfo === 'object') {
23710
- deepFreeze$G(input_filteredLookupInfo);
23718
+ deepFreeze$H(input_filteredLookupInfo);
23711
23719
  }
23712
23720
  const input_referenceToInfos = input.referenceToInfos;
23713
23721
  for (let i = 0; i < input_referenceToInfos.length; i++) {
23714
23722
  const input_referenceToInfos_item = input_referenceToInfos[i];
23715
- deepFreeze$F(input_referenceToInfos_item);
23723
+ deepFreeze$G(input_referenceToInfos_item);
23716
23724
  }
23717
23725
  ObjectFreeze$2(input_referenceToInfos);
23718
23726
  ObjectFreeze$2(input);
23719
23727
  }
23720
- function deepFreeze$D(input) {
23728
+ function deepFreeze$E(input) {
23721
23729
  ObjectFreeze$2(input);
23722
23730
  }
23723
23731
 
@@ -23847,11 +23855,11 @@
23847
23855
  }
23848
23856
  return true;
23849
23857
  }
23850
- function deepFreeze$C(input) {
23858
+ function deepFreeze$D(input) {
23851
23859
  const input_childRelationships = input.childRelationships;
23852
23860
  for (let i = 0; i < input_childRelationships.length; i++) {
23853
23861
  const input_childRelationships_item = input_childRelationships[i];
23854
- deepFreeze$H(input_childRelationships_item);
23862
+ deepFreeze$I(input_childRelationships_item);
23855
23863
  }
23856
23864
  ObjectFreeze$2(input_childRelationships);
23857
23865
  const input_dependentFields = input.dependentFields;
@@ -23869,7 +23877,7 @@
23869
23877
  for (let i = 0; i < input_fields_length; i++) {
23870
23878
  const key = input_fields_keys[i];
23871
23879
  const input_fields_prop = input_fields[key];
23872
- deepFreeze$E(input_fields_prop);
23880
+ deepFreeze$F(input_fields_prop);
23873
23881
  }
23874
23882
  ObjectFreeze$2(input_fields);
23875
23883
  const input_nameFields = input.nameFields;
@@ -23880,12 +23888,12 @@
23880
23888
  for (let i = 0; i < input_recordTypeInfos_length; i++) {
23881
23889
  const key = input_recordTypeInfos_keys[i];
23882
23890
  const input_recordTypeInfos_prop = input_recordTypeInfos[key];
23883
- deepFreeze$L(input_recordTypeInfos_prop);
23891
+ deepFreeze$M(input_recordTypeInfos_prop);
23884
23892
  }
23885
23893
  ObjectFreeze$2(input_recordTypeInfos);
23886
23894
  const input_themeInfo = input.themeInfo;
23887
23895
  if (input_themeInfo !== null && typeof input_themeInfo === 'object') {
23888
- deepFreeze$D(input_themeInfo);
23896
+ deepFreeze$E(input_themeInfo);
23889
23897
  }
23890
23898
  ObjectFreeze$2(input);
23891
23899
  }
@@ -23899,7 +23907,7 @@
23899
23907
  propertyName: path.propertyName,
23900
23908
  ttl: ttlToUse
23901
23909
  });
23902
- deepFreeze$C(input);
23910
+ deepFreeze$D(input);
23903
23911
  if (existingRecord === undefined || equals$N(existingRecord, incomingRecord) === false) {
23904
23912
  luvio.storePublish(key, incomingRecord);
23905
23913
  }
@@ -24088,7 +24096,7 @@
24088
24096
  return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
24089
24097
  buildCachedSnapshotCachePolicy$H, buildNetworkSnapshotCachePolicy$I);
24090
24098
  };
24091
- function deepFreeze$B(input) {
24099
+ function deepFreeze$C(input) {
24092
24100
  ObjectFreeze$2(input);
24093
24101
  }
24094
24102
 
@@ -24101,32 +24109,32 @@
24101
24109
  DiscriminatorValues["Field"] = "Field";
24102
24110
  DiscriminatorValues["CustomLink"] = "CustomLink";
24103
24111
  })(DiscriminatorValues$4 || (DiscriminatorValues$4 = {}));
24104
- function deepFreeze$A(input) {
24112
+ function deepFreeze$B(input) {
24105
24113
  ObjectFreeze$2(input);
24106
24114
  }
24107
- function deepFreeze$z(input) {
24115
+ function deepFreeze$A(input) {
24108
24116
  const input_layoutComponents = input.layoutComponents;
24109
24117
  for (let i = 0; i < input_layoutComponents.length; i++) {
24110
24118
  const input_layoutComponents_item = input_layoutComponents[i];
24111
- deepFreeze$A(input_layoutComponents_item);
24119
+ deepFreeze$B(input_layoutComponents_item);
24112
24120
  }
24113
24121
  ObjectFreeze$2(input_layoutComponents);
24114
24122
  ObjectFreeze$2(input);
24115
24123
  }
24116
- function deepFreeze$y(input) {
24124
+ function deepFreeze$z(input) {
24117
24125
  const input_layoutItems = input.layoutItems;
24118
24126
  for (let i = 0; i < input_layoutItems.length; i++) {
24119
24127
  const input_layoutItems_item = input_layoutItems[i];
24120
- deepFreeze$z(input_layoutItems_item);
24128
+ deepFreeze$A(input_layoutItems_item);
24121
24129
  }
24122
24130
  ObjectFreeze$2(input_layoutItems);
24123
24131
  ObjectFreeze$2(input);
24124
24132
  }
24125
- function deepFreeze$x(input) {
24133
+ function deepFreeze$y(input) {
24126
24134
  const input_layoutRows = input.layoutRows;
24127
24135
  for (let i = 0; i < input_layoutRows.length; i++) {
24128
24136
  const input_layoutRows_item = input_layoutRows[i];
24129
- deepFreeze$y(input_layoutRows_item);
24137
+ deepFreeze$z(input_layoutRows_item);
24130
24138
  }
24131
24139
  ObjectFreeze$2(input_layoutRows);
24132
24140
  ObjectFreeze$2(input);
@@ -24197,17 +24205,17 @@
24197
24205
  }
24198
24206
  return true;
24199
24207
  }
24200
- function deepFreeze$w(input) {
24208
+ function deepFreeze$x(input) {
24201
24209
  const input_saveOptions = input.saveOptions;
24202
24210
  for (let i = 0; i < input_saveOptions.length; i++) {
24203
24211
  const input_saveOptions_item = input_saveOptions[i];
24204
- deepFreeze$B(input_saveOptions_item);
24212
+ deepFreeze$C(input_saveOptions_item);
24205
24213
  }
24206
24214
  ObjectFreeze$2(input_saveOptions);
24207
24215
  const input_sections = input.sections;
24208
24216
  for (let i = 0; i < input_sections.length; i++) {
24209
24217
  const input_sections_item = input_sections[i];
24210
- deepFreeze$x(input_sections_item);
24218
+ deepFreeze$y(input_sections_item);
24211
24219
  }
24212
24220
  ObjectFreeze$2(input_sections);
24213
24221
  ObjectFreeze$2(input);
@@ -24222,7 +24230,7 @@
24222
24230
  propertyName: path.propertyName,
24223
24231
  ttl: ttlToUse
24224
24232
  });
24225
- deepFreeze$w(input);
24233
+ deepFreeze$x(input);
24226
24234
  if (existingRecord === undefined || equals$M(existingRecord, incomingRecord) === false) {
24227
24235
  luvio.storePublish(key, incomingRecord);
24228
24236
  }
@@ -24248,7 +24256,7 @@
24248
24256
  });
24249
24257
  return rootKeySet;
24250
24258
  }
24251
- function deepFreeze$v(input) {
24259
+ function deepFreeze$w(input) {
24252
24260
  ObjectFreeze$2(input);
24253
24261
  }
24254
24262
 
@@ -24299,14 +24307,14 @@
24299
24307
  }
24300
24308
  return true;
24301
24309
  }
24302
- function deepFreeze$u(input) {
24310
+ function deepFreeze$v(input) {
24303
24311
  const input_sectionUserStates = input.sectionUserStates;
24304
24312
  const input_sectionUserStates_keys = Object.keys(input_sectionUserStates);
24305
24313
  const input_sectionUserStates_length = input_sectionUserStates_keys.length;
24306
24314
  for (let i = 0; i < input_sectionUserStates_length; i++) {
24307
24315
  const key = input_sectionUserStates_keys[i];
24308
24316
  const input_sectionUserStates_prop = input_sectionUserStates[key];
24309
- deepFreeze$v(input_sectionUserStates_prop);
24317
+ deepFreeze$w(input_sectionUserStates_prop);
24310
24318
  }
24311
24319
  ObjectFreeze$2(input_sectionUserStates);
24312
24320
  ObjectFreeze$2(input);
@@ -24321,7 +24329,7 @@
24321
24329
  propertyName: path.propertyName,
24322
24330
  ttl: ttlToUse
24323
24331
  });
24324
- deepFreeze$u(input);
24332
+ deepFreeze$v(input);
24325
24333
  if (existingRecord === undefined || equals$L(existingRecord, incomingRecord) === false) {
24326
24334
  luvio.storePublish(key, incomingRecord);
24327
24335
  }
@@ -24848,7 +24856,7 @@
24848
24856
  const lookupFields = {};
24849
24857
  const { apiName, fields: recordFields } = record;
24850
24858
  const { fields: objectInfoFields } = objectInfo;
24851
- const objectInfoFieldNames = keys$8(objectInfoFields);
24859
+ const objectInfoFieldNames = keys$9(objectInfoFields);
24852
24860
  for (let i = 0, len = objectInfoFieldNames.length; i < len; i += 1) {
24853
24861
  const fieldName = objectInfoFieldNames[i];
24854
24862
  const field = objectInfoFields[fieldName];
@@ -24867,12 +24875,12 @@
24867
24875
  const nameField = `${apiName}.${relationshipName}.${getNameField(objectInfo, fieldName)}`;
24868
24876
  lookupFields[nameField] = true;
24869
24877
  }
24870
- return keys$8(lookupFields);
24878
+ return keys$9(lookupFields);
24871
24879
  }
24872
24880
  function getRecordUiMissingRecordLookupFields(recordUi) {
24873
24881
  const { records, objectInfos } = recordUi;
24874
24882
  const recordLookupFields = {};
24875
- const recordIds = keys$8(records);
24883
+ const recordIds = keys$9(records);
24876
24884
  for (let i = 0, len = recordIds.length; i < len; i += 1) {
24877
24885
  const recordId = recordIds[i];
24878
24886
  const recordData = records[recordId];
@@ -24910,19 +24918,19 @@
24910
24918
  }
24911
24919
  function eachLayout(recordUi, cb) {
24912
24920
  const { layouts } = recordUi;
24913
- const layoutApiNames = keys$8(layouts);
24921
+ const layoutApiNames = keys$9(layouts);
24914
24922
  for (let a = 0, len = layoutApiNames.length; a < len; a += 1) {
24915
24923
  const apiName = layoutApiNames[a];
24916
24924
  const apiNameData = layouts[apiName];
24917
- const recordTypeIds = keys$8(apiNameData);
24925
+ const recordTypeIds = keys$9(apiNameData);
24918
24926
  for (let b = 0, recordTypeIdsLen = recordTypeIds.length; b < recordTypeIdsLen; b += 1) {
24919
24927
  const recordTypeId = recordTypeIds[b];
24920
24928
  const recordTypeData = apiNameData[recordTypeId];
24921
- const layoutTypes = keys$8(recordTypeData);
24929
+ const layoutTypes = keys$9(recordTypeData);
24922
24930
  for (let c = 0, layoutTypesLen = layoutTypes.length; c < layoutTypesLen; c += 1) {
24923
24931
  const layoutType = layoutTypes[c];
24924
24932
  const layoutTypeData = recordTypeData[layoutType];
24925
- const modes = keys$8(layoutTypeData);
24933
+ const modes = keys$9(layoutTypeData);
24926
24934
  for (let d = 0, modesLen = modes.length; d < modesLen; d += 1) {
24927
24935
  const mode = modes[d];
24928
24936
  const layout = layoutTypeData[mode];
@@ -25133,7 +25141,7 @@
25133
25141
  const node = luvio.getNode(recordDepKey);
25134
25142
  if (isGraphNode(node)) {
25135
25143
  const recordDeps = node.retrieve();
25136
- assign$6(dependencies, recordDeps);
25144
+ assign$7(dependencies, recordDeps);
25137
25145
  }
25138
25146
  luvio.storePublish(recordDepKey, dependencies);
25139
25147
  }
@@ -25301,11 +25309,11 @@
25301
25309
  ];
25302
25310
  function getFieldsFromLayoutMap(layoutMap, objectInfo) {
25303
25311
  let fields = [];
25304
- const layoutTypes = keys$8(layoutMap);
25312
+ const layoutTypes = keys$9(layoutMap);
25305
25313
  for (let i = 0, layoutTypesLen = layoutTypes.length; i < layoutTypesLen; i += 1) {
25306
25314
  const layoutType = layoutTypes[i];
25307
25315
  const modesMap = layoutMap[layoutType];
25308
- const modes = keys$8(modesMap);
25316
+ const modes = keys$9(modesMap);
25309
25317
  for (let m = 0, modesLen = modes.length; m < modesLen; m += 1) {
25310
25318
  const mode = modes[m];
25311
25319
  const modeKeys = getQualifiedFieldApiNamesFromLayout(modesMap[mode], objectInfo);
@@ -25522,7 +25530,7 @@
25522
25530
  }
25523
25531
  const { layoutType, mode, snapshot } = container;
25524
25532
  if (wrapper.layoutMap[layoutType] === undefined) {
25525
- wrapper.layoutMap = assign$6({}, wrapper.layoutMap, {
25533
+ wrapper.layoutMap = assign$7({}, wrapper.layoutMap, {
25526
25534
  [layoutType]: {},
25527
25535
  });
25528
25536
  }
@@ -25797,6 +25805,49 @@
25797
25805
  return rootKeySet;
25798
25806
  }
25799
25807
 
25808
+ function serializeFieldArguments$1(argumentNodes, variables) {
25809
+ const mutableArgumentNodes = Object.assign([], argumentNodes);
25810
+ return `args__(${mutableArgumentNodes.sort((a, b) => {
25811
+ const aName = a.name.value.toUpperCase();
25812
+ const bName = b.name.value.toUpperCase();
25813
+ return aName < bName ? -1 : (aName > bName) ? 1 : 0;
25814
+ }).map(node => serializeArgNode$1(node, variables)).join("::")})`;
25815
+ }
25816
+ function serializeArgNode$1(argumentNode, variables) {
25817
+ const argName = argumentNode.name.value;
25818
+ return `${argName}:${serializeValueNode$2(argumentNode.value, variables)}`;
25819
+ }
25820
+ function serializeValueNode$2(valueNode, variables) {
25821
+ switch (valueNode.kind) {
25822
+ case ("BooleanValue"):
25823
+ return valueNode.value + '';
25824
+ case ("IntValue"):
25825
+ case ("FloatValue"):
25826
+ case ("EnumValue"):
25827
+ case ("StringValue"):
25828
+ return valueNode.value;
25829
+ case ("ListValue"):
25830
+ const mutableValueNodeList = Object.assign([], valueNode.values);
25831
+ return mutableValueNodeList.sort((a, b) => {
25832
+ const aVal = serializeValueNode$2(a, variables).toUpperCase();
25833
+ const bVal = serializeValueNode$2(b, variables).toUpperCase();
25834
+ return aVal < bVal ? -1 : (aVal > bVal) ? 1 : 0;
25835
+ }).map((val, i) => serializeValueNode$2(val, variables) + `[${i}]`).join(',');
25836
+ case ("Variable"):
25837
+ const variableValue = variables[valueNode.name.value];
25838
+ return typeof variableValue === "string" ? variableValue : JSON.stringify(variableValue);
25839
+ case ("NullValue"):
25840
+ return "null";
25841
+ case ("ObjectValue"):
25842
+ const mutableFieldNodeList = Object.assign([], valueNode.fields);
25843
+ return mutableFieldNodeList.sort((a, b) => {
25844
+ const aName = a.name.value.toUpperCase();
25845
+ const bName = b.name.value.toUpperCase();
25846
+ return aName < bName ? -1 : (aName > bName) ? 1 : 0;
25847
+ }).map(field => field.name.value + ":" + serializeValueNode$2(field.value, variables)).join(',');
25848
+ }
25849
+ }
25850
+
25800
25851
  const VERSION$V = "3f49d751896cf66e6e29788d8880e2cc";
25801
25852
  const RepresentationType$D = 'PlatformActionRepresentation';
25802
25853
  function keyBuilder$1y(luvio, config) {
@@ -26533,9 +26584,9 @@
26533
26584
  }
26534
26585
  return true;
26535
26586
  }
26536
- function deepFreeze$t(input) {
26587
+ function deepFreeze$u(input) {
26537
26588
  const input_layout = input.layout;
26538
- deepFreeze$w(input_layout);
26589
+ deepFreeze$x(input_layout);
26539
26590
  ObjectFreeze$2(input);
26540
26591
  }
26541
26592
  const ingest$t$1 = function QuickActionLayoutRepresentationIngest(input, path, luvio, store, timestamp) {
@@ -26548,7 +26599,7 @@
26548
26599
  propertyName: path.propertyName,
26549
26600
  ttl: ttlToUse
26550
26601
  });
26551
- deepFreeze$t(input);
26602
+ deepFreeze$u(input);
26552
26603
  if (existingRecord === undefined || equals$F(existingRecord, incomingRecord) === false) {
26553
26604
  luvio.storePublish(key, incomingRecord);
26554
26605
  }
@@ -27191,7 +27242,7 @@
27191
27242
  }
27192
27243
  return true;
27193
27244
  }
27194
- function deepFreeze$s(input) {
27245
+ function deepFreeze$t(input) {
27195
27246
  const input_records = input.records;
27196
27247
  ObjectFreeze$2(input_records);
27197
27248
  ObjectFreeze$2(input);
@@ -27206,7 +27257,7 @@
27206
27257
  propertyName: path.propertyName,
27207
27258
  ttl: ttlToUse
27208
27259
  });
27209
- deepFreeze$s(input);
27260
+ deepFreeze$t(input);
27210
27261
  if (existingRecord === undefined || equals$E(existingRecord, incomingRecord) === false) {
27211
27262
  luvio.storePublish(key, incomingRecord);
27212
27263
  }
@@ -28232,7 +28283,7 @@
28232
28283
  buildCachedSnapshotCachePolicy$z, buildNetworkSnapshotCachePolicy$A);
28233
28284
  };
28234
28285
 
28235
- function validate$10(obj, path = 'ActionRelatedListSingleBatchInputRepresentation') {
28286
+ function validate$11(obj, path = 'ActionRelatedListSingleBatchInputRepresentation') {
28236
28287
  const v_error = (() => {
28237
28288
  if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
28238
28289
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -28623,7 +28674,7 @@
28623
28674
  const untrustedConfig_relatedListsActionParameters_array = [];
28624
28675
  for (let i = 0, arrayLength = untrustedConfig_relatedListsActionParameters.length; i < arrayLength; i++) {
28625
28676
  const untrustedConfig_relatedListsActionParameters_item = untrustedConfig_relatedListsActionParameters[i];
28626
- const referenceActionRelatedListSingleBatchInputRepresentationValidationError = validate$10(untrustedConfig_relatedListsActionParameters_item);
28677
+ const referenceActionRelatedListSingleBatchInputRepresentationValidationError = validate$11(untrustedConfig_relatedListsActionParameters_item);
28627
28678
  if (referenceActionRelatedListSingleBatchInputRepresentationValidationError === null) {
28628
28679
  untrustedConfig_relatedListsActionParameters_array.push(untrustedConfig_relatedListsActionParameters_item);
28629
28680
  }
@@ -29158,14 +29209,14 @@
29158
29209
  }
29159
29210
  return true;
29160
29211
  }
29161
- function deepFreeze$r(input) {
29212
+ function deepFreeze$s(input) {
29162
29213
  const input_attributes = input.attributes;
29163
29214
  const input_attributes_keys = Object.keys(input_attributes);
29164
29215
  const input_attributes_length = input_attributes_keys.length;
29165
29216
  for (let i = 0; i < input_attributes_length; i++) {
29166
29217
  const key = input_attributes_keys[i];
29167
29218
  const input_attributes_prop = input_attributes[key];
29168
- deepFreeze$P(input_attributes_prop);
29219
+ deepFreeze$Q(input_attributes_prop);
29169
29220
  }
29170
29221
  ObjectFreeze$2(input_attributes);
29171
29222
  const input_state = input.state;
@@ -29189,7 +29240,7 @@
29189
29240
  propertyName: path.propertyName,
29190
29241
  ttl: ttlToUse
29191
29242
  });
29192
- deepFreeze$r(input);
29243
+ deepFreeze$s(input);
29193
29244
  if (existingRecord === undefined || equals$C(existingRecord, incomingRecord) === false) {
29194
29245
  luvio.storePublish(key, incomingRecord);
29195
29246
  }
@@ -32952,24 +33003,24 @@
32952
33003
  return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
32953
33004
  buildCachedSnapshotCachePolicy$l, buildNetworkSnapshotCachePolicy$m);
32954
33005
  };
32955
- function deepFreeze$q(input) {
33006
+ function deepFreeze$r(input) {
32956
33007
  const input_recordIds = input.recordIds;
32957
33008
  ObjectFreeze$2(input_recordIds);
32958
33009
  ObjectFreeze$2(input);
32959
33010
  }
32960
- function deepFreeze$p(input) {
33011
+ function deepFreeze$q(input) {
32961
33012
  const input_matchResultInfo = input.matchResultInfo;
32962
- deepFreeze$q(input_matchResultInfo);
33013
+ deepFreeze$r(input_matchResultInfo);
32963
33014
  ObjectFreeze$2(input);
32964
33015
  }
32965
- function deepFreeze$o(input) {
33016
+ function deepFreeze$p(input) {
32966
33017
  const input_duplicateResultInfos = input.duplicateResultInfos;
32967
33018
  const input_duplicateResultInfos_keys = Object.keys(input_duplicateResultInfos);
32968
33019
  const input_duplicateResultInfos_length = input_duplicateResultInfos_keys.length;
32969
33020
  for (let i = 0; i < input_duplicateResultInfos_length; i++) {
32970
33021
  const key = input_duplicateResultInfos_keys[i];
32971
33022
  const input_duplicateResultInfos_prop = input_duplicateResultInfos[key];
32972
- deepFreeze$p(input_duplicateResultInfos_prop);
33023
+ deepFreeze$q(input_duplicateResultInfos_prop);
32973
33024
  }
32974
33025
  ObjectFreeze$2(input_duplicateResultInfos);
32975
33026
  const input_recordIds = input.recordIds;
@@ -32997,13 +33048,13 @@
32997
33048
  }
32998
33049
  return true;
32999
33050
  }
33000
- function deepFreeze$n(input) {
33051
+ function deepFreeze$o(input) {
33001
33052
  const input_duplicateRules = input.duplicateRules;
33002
33053
  ObjectFreeze$2(input_duplicateRules);
33003
33054
  const input_matches = input.matches;
33004
33055
  for (let i = 0; i < input_matches.length; i++) {
33005
33056
  const input_matches_item = input_matches[i];
33006
- deepFreeze$o(input_matches_item);
33057
+ deepFreeze$p(input_matches_item);
33007
33058
  }
33008
33059
  ObjectFreeze$2(input_matches);
33009
33060
  ObjectFreeze$2(input);
@@ -33018,7 +33069,7 @@
33018
33069
  propertyName: path.propertyName,
33019
33070
  ttl: ttlToUse
33020
33071
  });
33021
- deepFreeze$n(input);
33072
+ deepFreeze$o(input);
33022
33073
  if (existingRecord === undefined || equals$u(existingRecord, incomingRecord) === false) {
33023
33074
  luvio.storePublish(key, incomingRecord);
33024
33075
  }
@@ -34363,7 +34414,7 @@
34363
34414
  }
34364
34415
  }
34365
34416
  if (records.length > 0) {
34366
- assign$6(config, { records });
34417
+ assign$7(config, { records });
34367
34418
  }
34368
34419
  }
34369
34420
  return config;
@@ -34534,7 +34585,7 @@
34534
34585
  }
34535
34586
  return true;
34536
34587
  }
34537
- function deepFreeze$m(input) {
34588
+ function deepFreeze$n(input) {
34538
34589
  ObjectFreeze$2(input);
34539
34590
  }
34540
34591
 
@@ -35197,7 +35248,7 @@
35197
35248
  return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
35198
35249
  buildCachedSnapshotCachePolicy$g, buildNetworkSnapshotCachePolicy$h);
35199
35250
  };
35200
- function deepFreeze$l(input) {
35251
+ function deepFreeze$m(input) {
35201
35252
  const input_picklistValues = input.picklistValues;
35202
35253
  for (let i = 0; i < input_picklistValues.length; i++) {
35203
35254
  const input_picklistValues_item = input_picklistValues[i];
@@ -35333,11 +35384,11 @@
35333
35384
  }
35334
35385
  return true;
35335
35386
  }
35336
- function deepFreeze$k(input) {
35387
+ function deepFreeze$l(input) {
35337
35388
  const input_displayColumns = input.displayColumns;
35338
35389
  for (let i = 0; i < input_displayColumns.length; i++) {
35339
35390
  const input_displayColumns_item = input_displayColumns[i];
35340
- deepFreeze$l(input_displayColumns_item);
35391
+ deepFreeze$m(input_displayColumns_item);
35341
35392
  }
35342
35393
  ObjectFreeze$2(input_displayColumns);
35343
35394
  const input_fields = input.fields;
@@ -35345,11 +35396,11 @@
35345
35396
  const input_filteredByInfo = input.filteredByInfo;
35346
35397
  for (let i = 0; i < input_filteredByInfo.length; i++) {
35347
35398
  const input_filteredByInfo_item = input_filteredByInfo[i];
35348
- deepFreeze$O(input_filteredByInfo_item);
35399
+ deepFreeze$P(input_filteredByInfo_item);
35349
35400
  }
35350
35401
  ObjectFreeze$2(input_filteredByInfo);
35351
35402
  const input_listReference = input.listReference;
35352
- deepFreeze$m(input_listReference);
35403
+ deepFreeze$n(input_listReference);
35353
35404
  const input_objectApiNames = input.objectApiNames;
35354
35405
  ObjectFreeze$2(input_objectApiNames);
35355
35406
  const input_optionalFields = input.optionalFields;
@@ -35357,11 +35408,11 @@
35357
35408
  const input_orderedByInfo = input.orderedByInfo;
35358
35409
  for (let i = 0; i < input_orderedByInfo.length; i++) {
35359
35410
  const input_orderedByInfo_item = input_orderedByInfo[i];
35360
- deepFreeze$N(input_orderedByInfo_item);
35411
+ deepFreeze$O(input_orderedByInfo_item);
35361
35412
  }
35362
35413
  ObjectFreeze$2(input_orderedByInfo);
35363
35414
  const input_userPreferences = input.userPreferences;
35364
- deepFreeze$M(input_userPreferences);
35415
+ deepFreeze$N(input_userPreferences);
35365
35416
  ObjectFreeze$2(input);
35366
35417
  }
35367
35418
  const ingest$b$1 = function RelatedListInfoRepresentationIngest(input, path, luvio, store, timestamp) {
@@ -35374,7 +35425,7 @@
35374
35425
  propertyName: path.propertyName,
35375
35426
  ttl: ttlToUse
35376
35427
  });
35377
- deepFreeze$k(input);
35428
+ deepFreeze$l(input);
35378
35429
  if (existingRecord === undefined || equals$h(existingRecord, incomingRecord) === false) {
35379
35430
  luvio.storePublish(key, incomingRecord);
35380
35431
  }
@@ -35859,10 +35910,10 @@
35859
35910
  return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
35860
35911
  buildCachedSnapshotCachePolicy$f, buildNetworkSnapshotCachePolicy$g);
35861
35912
  };
35862
- function deepFreeze$j(input) {
35913
+ function deepFreeze$k(input) {
35863
35914
  const input_themeInfo = input.themeInfo;
35864
35915
  if (input_themeInfo !== null && typeof input_themeInfo === 'object') {
35865
- deepFreeze$D(input_themeInfo);
35916
+ deepFreeze$E(input_themeInfo);
35866
35917
  }
35867
35918
  ObjectFreeze$2(input);
35868
35919
  }
@@ -35912,11 +35963,11 @@
35912
35963
  }
35913
35964
  return true;
35914
35965
  }
35915
- function deepFreeze$i(input) {
35966
+ function deepFreeze$j(input) {
35916
35967
  const input_relatedLists = input.relatedLists;
35917
35968
  for (let i = 0; i < input_relatedLists.length; i++) {
35918
35969
  const input_relatedLists_item = input_relatedLists[i];
35919
- deepFreeze$j(input_relatedLists_item);
35970
+ deepFreeze$k(input_relatedLists_item);
35920
35971
  }
35921
35972
  ObjectFreeze$2(input_relatedLists);
35922
35973
  ObjectFreeze$2(input);
@@ -35931,7 +35982,7 @@
35931
35982
  propertyName: path.propertyName,
35932
35983
  ttl: ttlToUse
35933
35984
  });
35934
- deepFreeze$i(input);
35985
+ deepFreeze$j(input);
35935
35986
  if (existingRecord === undefined || equals$g(existingRecord, incomingRecord) === false) {
35936
35987
  luvio.storePublish(key, incomingRecord);
35937
35988
  }
@@ -36299,7 +36350,7 @@
36299
36350
  buildCachedSnapshotCachePolicy$d, buildNetworkSnapshotCachePolicy$e);
36300
36351
  };
36301
36352
 
36302
- function validate$t(obj, path = 'ListOrderedByInfoInputRepresentation') {
36353
+ function validate$u(obj, path = 'ListOrderedByInfoInputRepresentation') {
36303
36354
  const v_error = (() => {
36304
36355
  if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
36305
36356
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -36318,7 +36369,7 @@
36318
36369
  return v_error === undefined ? null : v_error;
36319
36370
  }
36320
36371
 
36321
- function validate$s(obj, path = 'ListUserPreferenceInputRepresentation') {
36372
+ function validate$t(obj, path = 'ListUserPreferenceInputRepresentation') {
36322
36373
  const v_error = (() => {
36323
36374
  if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
36324
36375
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -36450,7 +36501,7 @@
36450
36501
  const untrustedConfig_orderedByInfo_array = [];
36451
36502
  for (let i = 0, arrayLength = untrustedConfig_orderedByInfo.length; i < arrayLength; i++) {
36452
36503
  const untrustedConfig_orderedByInfo_item = untrustedConfig_orderedByInfo[i];
36453
- const referenceListOrderedByInfoInputRepresentationValidationError = validate$t(untrustedConfig_orderedByInfo_item);
36504
+ const referenceListOrderedByInfoInputRepresentationValidationError = validate$u(untrustedConfig_orderedByInfo_item);
36454
36505
  if (referenceListOrderedByInfoInputRepresentationValidationError === null) {
36455
36506
  untrustedConfig_orderedByInfo_array.push(untrustedConfig_orderedByInfo_item);
36456
36507
  }
@@ -36458,7 +36509,7 @@
36458
36509
  config.orderedByInfo = untrustedConfig_orderedByInfo_array;
36459
36510
  }
36460
36511
  const untrustedConfig_userPreferences = untrustedConfig.userPreferences;
36461
- const referenceListUserPreferenceInputRepresentationValidationError = validate$s(untrustedConfig_userPreferences);
36512
+ const referenceListUserPreferenceInputRepresentationValidationError = validate$t(untrustedConfig_userPreferences);
36462
36513
  if (referenceListUserPreferenceInputRepresentationValidationError === null) {
36463
36514
  config.userPreferences = untrustedConfig_userPreferences;
36464
36515
  }
@@ -36485,7 +36536,7 @@
36485
36536
  return luvio.storeBroadcast().then(() => snapshot);
36486
36537
  }, () => getResponseCacheKeys$k(luvio, resourceParams, response.body));
36487
36538
  }, (response) => {
36488
- deepFreeze$P(response);
36539
+ deepFreeze$Q(response);
36489
36540
  throw response;
36490
36541
  });
36491
36542
  }
@@ -36529,7 +36580,7 @@
36529
36580
  }
36530
36581
  return true;
36531
36582
  }
36532
- function deepFreeze$h(input) {
36583
+ function deepFreeze$i(input) {
36533
36584
  const input_columnWidths = input.columnWidths;
36534
36585
  const input_columnWidths_keys = Object.keys(input_columnWidths);
36535
36586
  const input_columnWidths_length = input_columnWidths_keys.length;
@@ -36547,7 +36598,7 @@
36547
36598
  const input_orderedBy = input.orderedBy;
36548
36599
  for (let i = 0; i < input_orderedBy.length; i++) {
36549
36600
  const input_orderedBy_item = input_orderedBy[i];
36550
- deepFreeze$N(input_orderedBy_item);
36601
+ deepFreeze$O(input_orderedBy_item);
36551
36602
  }
36552
36603
  ObjectFreeze$2(input_orderedBy);
36553
36604
  ObjectFreeze$2(input);
@@ -36562,7 +36613,7 @@
36562
36613
  propertyName: path.propertyName,
36563
36614
  ttl: ttlToUse
36564
36615
  });
36565
- deepFreeze$h(input);
36616
+ deepFreeze$i(input);
36566
36617
  if (existingRecord === undefined || equals$f(existingRecord, incomingRecord) === false) {
36567
36618
  luvio.storePublish(key, incomingRecord);
36568
36619
  }
@@ -37214,7 +37265,7 @@
37214
37265
  const untrustedConfig_orderedBy_array = [];
37215
37266
  for (let i = 0, arrayLength = untrustedConfig_orderedBy.length; i < arrayLength; i++) {
37216
37267
  const untrustedConfig_orderedBy_item = untrustedConfig_orderedBy[i];
37217
- const referenceListOrderedByInfoInputRepresentationValidationError = validate$t(untrustedConfig_orderedBy_item);
37268
+ const referenceListOrderedByInfoInputRepresentationValidationError = validate$u(untrustedConfig_orderedBy_item);
37218
37269
  if (referenceListOrderedByInfoInputRepresentationValidationError === null) {
37219
37270
  untrustedConfig_orderedBy_array.push(untrustedConfig_orderedBy_item);
37220
37271
  }
@@ -37243,7 +37294,7 @@
37243
37294
  return luvio.storeBroadcast().then(() => snapshot);
37244
37295
  }, () => getResponseCacheKeys$h(luvio, resourceParams, response.body));
37245
37296
  }, (response) => {
37246
- deepFreeze$P(response);
37297
+ deepFreeze$Q(response);
37247
37298
  throw response;
37248
37299
  });
37249
37300
  }
@@ -37258,7 +37309,7 @@
37258
37309
  };
37259
37310
  };
37260
37311
 
37261
- function validate$q(obj, path = 'RelatedListRecordsSingleBatchInputRepresentation') {
37312
+ function validate$r(obj, path = 'RelatedListRecordsSingleBatchInputRepresentation') {
37262
37313
  const v_error = (() => {
37263
37314
  if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
37264
37315
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -38232,7 +38283,7 @@
38232
38283
  const untrustedConfig_relatedListParameters_array = [];
38233
38284
  for (let i = 0, arrayLength = untrustedConfig_relatedListParameters.length; i < arrayLength; i++) {
38234
38285
  const untrustedConfig_relatedListParameters_item = untrustedConfig_relatedListParameters[i];
38235
- const referenceRelatedListRecordsSingleBatchInputRepresentationValidationError = validate$q(untrustedConfig_relatedListParameters_item);
38286
+ const referenceRelatedListRecordsSingleBatchInputRepresentationValidationError = validate$r(untrustedConfig_relatedListParameters_item);
38236
38287
  if (referenceRelatedListRecordsSingleBatchInputRepresentationValidationError === null) {
38237
38288
  untrustedConfig_relatedListParameters_array.push(untrustedConfig_relatedListParameters_item);
38238
38289
  }
@@ -38545,7 +38596,7 @@
38545
38596
  config,
38546
38597
  resolve: () => buildNetworkSnapshot$h(luvio, config, snapshotRefreshOptions$1)
38547
38598
  });
38548
- if (isUnfulfilledSnapshot$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
38599
+ if (isUnfulfilledSnapshot$1$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
38549
38600
  context.cacheSnapshot = cacheSnapshot;
38550
38601
  }
38551
38602
  return cacheSnapshot;
@@ -38578,7 +38629,7 @@
38578
38629
  ]
38579
38630
  };
38580
38631
  };
38581
- function deepFreeze$g(input) {
38632
+ function deepFreeze$h(input) {
38582
38633
  ObjectFreeze$2(input);
38583
38634
  }
38584
38635
 
@@ -39015,11 +39066,11 @@
39015
39066
  }
39016
39067
  return true;
39017
39068
  }
39018
- function deepFreeze$f(input) {
39069
+ function deepFreeze$g(input) {
39019
39070
  const input_options = input.options;
39020
39071
  for (let i = 0; i < input_options.length; i++) {
39021
39072
  const input_options_item = input_options[i];
39022
- deepFreeze$g(input_options_item);
39073
+ deepFreeze$h(input_options_item);
39023
39074
  }
39024
39075
  ObjectFreeze$2(input_options);
39025
39076
  ObjectFreeze$2(input);
@@ -39034,7 +39085,7 @@
39034
39085
  propertyName: path.propertyName,
39035
39086
  ttl: ttlToUse
39036
39087
  });
39037
- deepFreeze$f(input);
39088
+ deepFreeze$g(input);
39038
39089
  if (existingRecord === undefined || equals$a(existingRecord, incomingRecord) === false) {
39039
39090
  luvio.storePublish(key, incomingRecord);
39040
39091
  }
@@ -39227,28 +39278,28 @@
39227
39278
  return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
39228
39279
  buildCachedSnapshotCachePolicy$7, buildNetworkSnapshotCachePolicy$8);
39229
39280
  };
39230
- function deepFreeze$e(input) {
39281
+ function deepFreeze$f(input) {
39231
39282
  const input_displayFields = input.displayFields;
39232
39283
  ObjectFreeze$2(input_displayFields);
39233
39284
  ObjectFreeze$2(input);
39234
39285
  }
39235
- function deepFreeze$d(input) {
39286
+ function deepFreeze$e(input) {
39236
39287
  const input_matchingFields = input.matchingFields;
39237
39288
  ObjectFreeze$2(input_matchingFields);
39238
39289
  ObjectFreeze$2(input);
39239
39290
  }
39240
- function deepFreeze$c(input) {
39291
+ function deepFreeze$d(input) {
39241
39292
  const input_displayLayout = input.displayLayout;
39242
- deepFreeze$e(input_displayLayout);
39293
+ deepFreeze$f(input_displayLayout);
39243
39294
  const input_matchingInfo = input.matchingInfo;
39244
- deepFreeze$d(input_matchingInfo);
39295
+ deepFreeze$e(input_matchingInfo);
39245
39296
  ObjectFreeze$2(input);
39246
39297
  }
39247
- function deepFreeze$b(input) {
39298
+ function deepFreeze$c(input) {
39248
39299
  const input_fullSearchInfo = input.fullSearchInfo;
39249
- deepFreeze$c(input_fullSearchInfo);
39300
+ deepFreeze$d(input_fullSearchInfo);
39250
39301
  const input_suggestionsInfo = input.suggestionsInfo;
39251
- deepFreeze$c(input_suggestionsInfo);
39302
+ deepFreeze$d(input_suggestionsInfo);
39252
39303
  ObjectFreeze$2(input);
39253
39304
  }
39254
39305
 
@@ -39282,14 +39333,14 @@
39282
39333
  }
39283
39334
  return true;
39284
39335
  }
39285
- function deepFreeze$a(input) {
39336
+ function deepFreeze$b(input) {
39286
39337
  const input_targetInfo = input.targetInfo;
39287
39338
  const input_targetInfo_keys = Object.keys(input_targetInfo);
39288
39339
  const input_targetInfo_length = input_targetInfo_keys.length;
39289
39340
  for (let i = 0; i < input_targetInfo_length; i++) {
39290
39341
  const key = input_targetInfo_keys[i];
39291
39342
  const input_targetInfo_prop = input_targetInfo[key];
39292
- deepFreeze$b(input_targetInfo_prop);
39343
+ deepFreeze$c(input_targetInfo_prop);
39293
39344
  }
39294
39345
  ObjectFreeze$2(input_targetInfo);
39295
39346
  ObjectFreeze$2(input);
@@ -39304,7 +39355,7 @@
39304
39355
  propertyName: path.propertyName,
39305
39356
  ttl: ttlToUse
39306
39357
  });
39307
- deepFreeze$a(input);
39358
+ deepFreeze$b(input);
39308
39359
  if (existingRecord === undefined || equals$9(existingRecord, incomingRecord) === false) {
39309
39360
  luvio.storePublish(key, incomingRecord);
39310
39361
  }
@@ -39489,11 +39540,11 @@
39489
39540
  return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
39490
39541
  buildCachedSnapshotCachePolicy$6, buildNetworkSnapshotCachePolicy$7);
39491
39542
  };
39492
- function deepFreeze$9(input) {
39543
+ function deepFreeze$a(input) {
39493
39544
  ObjectFreeze$2(input);
39494
39545
  }
39495
39546
 
39496
- function deepFreeze$8(input) {
39547
+ function deepFreeze$9(input) {
39497
39548
  const input_fields = input.fields;
39498
39549
  const input_fields_keys = Object.keys(input_fields);
39499
39550
  const input_fields_length = input_fields_keys.length;
@@ -39504,57 +39555,66 @@
39504
39555
  ObjectFreeze$2(input);
39505
39556
  }
39506
39557
 
39507
- function deepFreeze$7(input) {
39558
+ function deepFreeze$8(input) {
39508
39559
  ObjectFreeze$2(input);
39509
39560
  }
39510
39561
 
39511
- function deepFreeze$6(input) {
39562
+ function deepFreeze$7(input) {
39512
39563
  const input_highlightInfo = input.highlightInfo;
39513
39564
  if (input_highlightInfo !== undefined) {
39514
- deepFreeze$8(input_highlightInfo);
39565
+ deepFreeze$9(input_highlightInfo);
39515
39566
  }
39516
39567
  const input_record = input.record;
39517
- deepFreeze$I(input_record);
39568
+ deepFreeze$J(input_record);
39518
39569
  const input_searchInfo = input.searchInfo;
39519
- deepFreeze$7(input_searchInfo);
39570
+ deepFreeze$8(input_searchInfo);
39520
39571
  ObjectFreeze$2(input);
39521
39572
  }
39522
- function deepFreeze$5(input) {
39573
+ function deepFreeze$6(input) {
39523
39574
  const input_error = input.error;
39524
39575
  if (input_error !== null && typeof input_error === 'object') {
39525
- deepFreeze$9(input_error);
39576
+ deepFreeze$a(input_error);
39526
39577
  }
39527
39578
  const input_orderBy = input.orderBy;
39528
39579
  for (let i = 0; i < input_orderBy.length; i++) {
39529
39580
  const input_orderBy_item = input_orderBy[i];
39530
- deepFreeze$N(input_orderBy_item);
39581
+ deepFreeze$O(input_orderBy_item);
39531
39582
  }
39532
39583
  ObjectFreeze$2(input_orderBy);
39533
39584
  const input_records = input.records;
39534
39585
  for (let i = 0; i < input_records.length; i++) {
39535
39586
  const input_records_item = input_records[i];
39536
- deepFreeze$6(input_records_item);
39587
+ deepFreeze$7(input_records_item);
39537
39588
  }
39538
39589
  ObjectFreeze$2(input_records);
39539
39590
  const input_relatedObjectApiNames = input.relatedObjectApiNames;
39540
39591
  ObjectFreeze$2(input_relatedObjectApiNames);
39541
39592
  ObjectFreeze$2(input);
39542
39593
  }
39543
- function deepFreeze$4(input) {
39594
+ function deepFreeze$5(input) {
39544
39595
  const input_results = input.results;
39545
39596
  for (let i = 0; i < input_results.length; i++) {
39546
39597
  const input_results_item = input_results[i];
39547
- deepFreeze$5(input_results_item);
39598
+ deepFreeze$6(input_results_item);
39548
39599
  }
39549
39600
  ObjectFreeze$2(input_results);
39550
39601
  ObjectFreeze$2(input);
39551
39602
  }
39603
+ function deepFreeze$4(input) {
39604
+ ObjectFreeze$2(input);
39605
+ }
39552
39606
  function deepFreeze$3(input) {
39607
+ const input_records = input.records;
39608
+ for (let i = 0; i < input_records.length; i++) {
39609
+ const input_records_item = input_records[i];
39610
+ deepFreeze$4(input_records_item);
39611
+ }
39612
+ ObjectFreeze$2(input_records);
39553
39613
  ObjectFreeze$2(input);
39554
39614
  }
39555
39615
 
39556
39616
  const TTL$6 = 200;
39557
- const VERSION$8$1 = "9760c93d10288bb6889882c757514189";
39617
+ const VERSION$8$1 = "da21e889922062e90012ba48c4a733e2";
39558
39618
  const RepresentationType$9 = 'SearchResultsSummaryRepresentation';
39559
39619
  function keyBuilder$f$1(luvio, config) {
39560
39620
  return keyPrefix$1 + '::' + RepresentationType$9 + ':' + config.query;
@@ -39585,7 +39645,7 @@
39585
39645
  function deepFreeze$2$1(input) {
39586
39646
  const input_keywordSearchResults = input.keywordSearchResults;
39587
39647
  if (input_keywordSearchResults !== null && typeof input_keywordSearchResults === 'object') {
39588
- deepFreeze$4(input_keywordSearchResults);
39648
+ deepFreeze$5(input_keywordSearchResults);
39589
39649
  }
39590
39650
  const input_qnaResult = input.qnaResult;
39591
39651
  if (input_qnaResult !== null && typeof input_qnaResult === 'object') {
@@ -39914,7 +39974,7 @@
39914
39974
  }
39915
39975
  function deepFreeze$1$1(input) {
39916
39976
  const input_keywordSearchResult = input.keywordSearchResult;
39917
- deepFreeze$5(input_keywordSearchResult);
39977
+ deepFreeze$6(input_keywordSearchResult);
39918
39978
  ObjectFreeze$2(input);
39919
39979
  }
39920
39980
  const ingest$3$1 = function KeywordSearchResultsSummaryRepresentationIngest(input, path, luvio, store, timestamp) {
@@ -40280,7 +40340,7 @@
40280
40340
  return luvio.storeBroadcast().then(() => snapshot);
40281
40341
  }, () => getResponseCacheKeys$9(luvio, resourceParams, response.body));
40282
40342
  }, (response) => {
40283
- deepFreeze$P(response);
40343
+ deepFreeze$Q(response);
40284
40344
  throw response;
40285
40345
  });
40286
40346
  }
@@ -40424,7 +40484,7 @@
40424
40484
  return luvio.storeBroadcast().then(() => snapshot);
40425
40485
  }, () => getResponseCacheKeys$8(luvio, resourceParams, response.body));
40426
40486
  }, (response) => {
40427
- deepFreeze$P(response);
40487
+ deepFreeze$Q(response);
40428
40488
  throw response;
40429
40489
  });
40430
40490
  }
@@ -40441,20 +40501,20 @@
40441
40501
 
40442
40502
  const factory$c = performQuickActionAdapterFactory;
40443
40503
 
40444
- function deepFreeze$Q(value) {
40504
+ function deepFreeze$R(value) {
40445
40505
  // No need to freeze primitives
40446
40506
  if (typeof value !== 'object' || value === null) {
40447
40507
  return;
40448
40508
  }
40449
40509
  if (isArray$8(value)) {
40450
40510
  for (let i = 0, len = value.length; i < len; i += 1) {
40451
- deepFreeze$Q(value[i]);
40511
+ deepFreeze$R(value[i]);
40452
40512
  }
40453
40513
  }
40454
40514
  else {
40455
- const keys$1 = keys$8(value);
40515
+ const keys$1 = keys$9(value);
40456
40516
  for (let i = 0, len = keys$1.length; i < len; i += 1) {
40457
- deepFreeze$Q(value[keys$1[i]]);
40517
+ deepFreeze$R(value[keys$1[i]]);
40458
40518
  }
40459
40519
  }
40460
40520
  freeze$3(value);
@@ -40510,7 +40570,7 @@
40510
40570
  const { body } = response;
40511
40571
  return luvio.handleSuccessResponse(() => ingestAndBroadcast(luvio, key, config, body), () => getTypeCacheKeys$G$1(luvio, body));
40512
40572
  }, (err) => {
40513
- deepFreeze$Q(err);
40573
+ deepFreeze$R(err);
40514
40574
  throw err;
40515
40575
  });
40516
40576
  }
@@ -40534,7 +40594,7 @@
40534
40594
  let clonedLayoutUserStateSections;
40535
40595
  const { sectionUserStates } = layoutUserStateInput;
40536
40596
  const { sectionUserStates: cachedSectionUserStates } = cachedLayoutUserState;
40537
- const sectionUserStateKeys = keys$8(sectionUserStates);
40597
+ const sectionUserStateKeys = keys$9(sectionUserStates);
40538
40598
  for (let i = 0, len = sectionUserStateKeys.length; i < len; i += 1) {
40539
40599
  const sectionId = sectionUserStateKeys[i];
40540
40600
  if (cachedSectionUserStates[sectionId] === undefined) {
@@ -40830,7 +40890,7 @@
40830
40890
  config,
40831
40891
  resolve: () => buildNetworkSnapshot$9(luvio, config, snapshotRefreshOptions$1)
40832
40892
  });
40833
- if (isUnfulfilledSnapshot$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
40893
+ if (isUnfulfilledSnapshot$1$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
40834
40894
  context.cacheSnapshot = cacheSnapshot;
40835
40895
  }
40836
40896
  return cacheSnapshot;
@@ -41104,7 +41164,7 @@
41104
41164
  .map((targetApiName) => body.lookupResults[targetApiName].records)
41105
41165
  .reduce((allRecords, records) => allRecords.concat(records), [])
41106
41166
  .forEach((record) => removeEtags(record));
41107
- deepFreeze$Q(body);
41167
+ deepFreeze$R(body);
41108
41168
  return Promise.resolve({
41109
41169
  state: 'Fulfilled',
41110
41170
  recordId: key,
@@ -41274,7 +41334,7 @@
41274
41334
  return luvio.storeBroadcast().then(() => snapshot);
41275
41335
  }, () => getTypeCacheKeys$n$1(luvio, body));
41276
41336
  }, (err) => {
41277
- deepFreeze$Q(err);
41337
+ deepFreeze$R(err);
41278
41338
  throw err;
41279
41339
  });
41280
41340
  };
@@ -43132,7 +43192,7 @@
43132
43192
  return luvio.dispatchResourceRequest(request).then((response) => {
43133
43193
  return luvio.handleSuccessResponse(() => onResponseSuccess$1(luvio, response, recordIngest, conflictMap), () => getResponseCacheKeys$3(luvio, resourceParams, response.body));
43134
43194
  }, (err) => {
43135
- deepFreeze$Q(err);
43195
+ deepFreeze$R(err);
43136
43196
  throw err;
43137
43197
  });
43138
43198
  }
@@ -43233,7 +43293,7 @@
43233
43293
  return luvio.storeBroadcast();
43234
43294
  }, () => getResponseCacheKeys$2$1(luvio, resourceParams));
43235
43295
  }, (response) => {
43236
- deepFreeze$P(response);
43296
+ deepFreeze$Q(response);
43237
43297
  throw response;
43238
43298
  });
43239
43299
  }
@@ -43467,7 +43527,7 @@
43467
43527
  return luvio.dispatchResourceRequest(request).then((response) => {
43468
43528
  return luvio.handleSuccessResponse(() => onResponseSuccess(luvio, response, recordId, recordIngest, conflictMap), () => getResponseCacheKeys$1$1(luvio, resourceParams, response.body));
43469
43529
  }, (err) => {
43470
- deepFreeze$Q(err);
43530
+ deepFreeze$R(err);
43471
43531
  throw err;
43472
43532
  });
43473
43533
  }
@@ -43723,7 +43783,7 @@
43723
43783
  return luvio.storeBroadcast().then(() => snapshot);
43724
43784
  }, () => getResponseCacheKeys$T(luvio, {}, response.body));
43725
43785
  }, (response) => {
43726
- deepFreeze$P(response);
43786
+ deepFreeze$Q(response);
43727
43787
  throw response;
43728
43788
  });
43729
43789
  }
@@ -43790,7 +43850,7 @@
43790
43850
  return luvio.storeBroadcast().then(() => snapshot);
43791
43851
  }, () => getResponseCacheKeys$T(luvio, resourceParams, response.body));
43792
43852
  }, (response) => {
43793
- deepFreeze$P(response);
43853
+ deepFreeze$Q(response);
43794
43854
  throw response;
43795
43855
  });
43796
43856
  }
@@ -44418,7 +44478,7 @@
44418
44478
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44419
44479
  });
44420
44480
  });
44421
- // version: 1.130.10-b649bb8d1
44481
+ // version: 1.131.0-dev11-734408c01
44422
44482
 
44423
44483
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44424
44484
 
@@ -44444,6 +44504,15 @@
44444
44504
  declarePollableTaskMulti,
44445
44505
  };
44446
44506
 
44507
+ var ldsUseShortUrlGate = {
44508
+ isOpen: function (e) {
44509
+ return e.fallback;
44510
+ },
44511
+ hasError: function () {
44512
+ return !0;
44513
+ },
44514
+ };
44515
+
44447
44516
  var LOCALE = 'en-US';
44448
44517
 
44449
44518
  var CURRENCY = 'USD';
@@ -44481,6 +44550,33 @@
44481
44550
  return pattern;
44482
44551
  }
44483
44552
 
44553
+ var eagerEvalValidAt = {
44554
+ isOpen: function (e) {
44555
+ return e.fallback;
44556
+ },
44557
+ hasError: function () {
44558
+ return !0;
44559
+ },
44560
+ };
44561
+
44562
+ var eagerEvalStaleWhileRevalidate = {
44563
+ isOpen: function (e) {
44564
+ return e.fallback;
44565
+ },
44566
+ hasError: function () {
44567
+ return !0;
44568
+ },
44569
+ };
44570
+
44571
+ var eagerEvalDefaultCachePolicy = {
44572
+ isOpen: function (e) {
44573
+ return e.fallback;
44574
+ },
44575
+ hasError: function () {
44576
+ return !0;
44577
+ },
44578
+ };
44579
+
44484
44580
  /**
44485
44581
  * Copyright (c) 2022, Salesforce, Inc.,
44486
44582
  * All rights reserved.
@@ -44496,7 +44592,7 @@
44496
44592
  const { parse: parse$5, stringify: stringify$5 } = JSON;
44497
44593
  const { join: join$2, push: push$2, unshift } = Array.prototype;
44498
44594
  const { isArray: isArray$6 } = Array;
44499
- const { entries: entries$3, keys: keys$6 } = Object;
44595
+ const { entries: entries$3, keys: keys$7 } = Object;
44500
44596
 
44501
44597
  const UI_API_BASE_URI = '/services/data/v58.0/ui-api';
44502
44598
 
@@ -44561,7 +44657,7 @@
44561
44657
  function mergeRecordFields$1(first, second) {
44562
44658
  const { fields: targetFields } = first;
44563
44659
  const { fields: sourceFields } = second;
44564
- const fieldNames = keys$6(sourceFields);
44660
+ const fieldNames = keys$7(sourceFields);
44565
44661
  for (let i = 0, len = fieldNames.length; i < len; i += 1) {
44566
44662
  const fieldName = fieldNames[i];
44567
44663
  const sourceField = sourceFields[fieldName];
@@ -44964,8 +45060,9 @@
44964
45060
  return false;
44965
45061
  }
44966
45062
  const DefaultDurableSegment = 'DEFAULT';
45063
+ const RedirectDurableSegment = 'REDIRECT_KEYS';
44967
45064
 
44968
- const { keys: keys$5, create: create$5, assign: assign$4, freeze: freeze$1$1 } = Object;
45065
+ const { keys: keys$6, create: create$5, assign: assign$5, freeze: freeze$1$1 } = Object;
44969
45066
  const { isArray: isArray$5 } = Array;
44970
45067
 
44971
45068
  //Durable store error instrumentation key
@@ -45000,7 +45097,7 @@
45000
45097
  }
45001
45098
  }
45002
45099
  else {
45003
- const keys$1 = keys$5(value);
45100
+ const keys$1 = keys$6(value);
45004
45101
  for (let i = 0, len = keys$1.length; i < len; i += 1) {
45005
45102
  deepFreeze$2(value[keys$1[i]]);
45006
45103
  }
@@ -45023,13 +45120,13 @@
45023
45120
  * @param pendingWriter the PendingWriter (this is going away soon)
45024
45121
  * @returns
45025
45122
  */
45026
- function publishDurableStoreEntries(durableRecords, publish, publishMetadata) {
45123
+ function publishDurableStoreEntries(durableRecords, put, publishMetadata) {
45027
45124
  const revivedKeys = new StoreKeySet();
45028
45125
  let hadUnexpectedShape = false;
45029
45126
  if (durableRecords === undefined) {
45030
45127
  return { revivedKeys, hadUnexpectedShape };
45031
45128
  }
45032
- const durableKeys = keys$5(durableRecords);
45129
+ const durableKeys = keys$6(durableRecords);
45033
45130
  if (durableKeys.length === 0) {
45034
45131
  // no records to revive
45035
45132
  return { revivedKeys, hadUnexpectedShape };
@@ -45061,7 +45158,7 @@
45061
45158
  // freeze errors on way into L1
45062
45159
  deepFreeze$2(data.error);
45063
45160
  }
45064
- publish(key, data);
45161
+ put(key, data);
45065
45162
  revivedKeys.add(key);
45066
45163
  }
45067
45164
  return { revivedKeys, hadUnexpectedShape };
@@ -45101,7 +45198,7 @@
45101
45198
  // TODO [W-10072584]: instead of implicitly using L1 we should take in
45102
45199
  // publish and publishMetadata funcs, so callers can decide where to
45103
45200
  // revive to (like they pass in how to do the buildL1Snapshot)
45104
- baseEnvironment.storePublish.bind(baseEnvironment), baseEnvironment.publishStoreMetadata.bind(baseEnvironment));
45201
+ baseEnvironment.storePut.bind(baseEnvironment), baseEnvironment.publishStoreMetadata.bind(baseEnvironment));
45105
45202
  // if the data coming back from DS had an unexpected shape then just
45106
45203
  // return the L1 snapshot
45107
45204
  if (hadUnexpectedShape === true) {
@@ -45203,7 +45300,7 @@
45203
45300
  overrides,
45204
45301
  };
45205
45302
  }
45206
- const keys$1 = keys$5(entries);
45303
+ const keys$1 = keys$6(entries);
45207
45304
  for (let i = 0, len = keys$1.length; i < len; i++) {
45208
45305
  const key = keys$1[i];
45209
45306
  const entry = entries[key];
@@ -45234,14 +45331,14 @@
45234
45331
  }
45235
45332
  return { ...source };
45236
45333
  }
45237
- function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler) {
45334
+ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler, redirects, additionalDurableStoreOperations = []) {
45238
45335
  const durableRecords = create$5(null);
45239
45336
  const evictedRecords = create$5(null);
45240
45337
  const { records, metadata: storeMetadata, visitedIds, refreshedIds, } = store.fallbackStringKeyInMemoryStore;
45241
45338
  // TODO: W-8909393 Once metadata is stored in its own segment we need to
45242
45339
  // call setEntries for the visitedIds on default segment and call setEntries
45243
45340
  // on the metadata segment for the refreshedIds
45244
- const keys$1 = keys$5({ ...visitedIds, ...refreshedIds });
45341
+ const keys$1 = keys$6({ ...visitedIds, ...refreshedIds });
45245
45342
  for (let i = 0, len = keys$1.length; i < len; i += 1) {
45246
45343
  const key = keys$1[i];
45247
45344
  const record = records[key];
@@ -45263,9 +45360,9 @@
45263
45360
  };
45264
45361
  }
45265
45362
  }
45266
- const durableStoreOperations = [];
45363
+ const durableStoreOperations = additionalDurableStoreOperations;
45267
45364
  // publishes
45268
- const recordKeys = keys$5(durableRecords);
45365
+ const recordKeys = keys$6(durableRecords);
45269
45366
  if (recordKeys.length > 0) {
45270
45367
  durableStoreOperations.push({
45271
45368
  type: 'setEntries',
@@ -45273,8 +45370,20 @@
45273
45370
  segment: DefaultDurableSegment,
45274
45371
  });
45275
45372
  }
45373
+ // redirects
45374
+ redirects.forEach((value, key) => {
45375
+ durableStoreOperations.push({
45376
+ type: 'setEntries',
45377
+ entries: {
45378
+ [key]: {
45379
+ data: { key, redirect: value },
45380
+ },
45381
+ },
45382
+ segment: RedirectDurableSegment,
45383
+ });
45384
+ });
45276
45385
  // evicts
45277
- const evictedKeys = keys$5(evictedRecords);
45386
+ const evictedKeys = keys$6(evictedRecords);
45278
45387
  if (evictedKeys.length > 0) {
45279
45388
  durableStoreOperations.push({
45280
45389
  type: 'evictEntries',
@@ -45318,6 +45427,19 @@
45318
45427
  return environment.storeBuildIngestionStagingStore();
45319
45428
  }
45320
45429
 
45430
+ async function reviveRedirects(durableStore, env) {
45431
+ const entries = await durableStore.getAllEntries(RedirectDurableSegment);
45432
+ if (entries) {
45433
+ for (const durableEntry of Object.keys(entries)) {
45434
+ const entry = entries[durableEntry];
45435
+ const { data: { key, redirect }, } = entry;
45436
+ if (entry) {
45437
+ env.storeRedirect(key, redirect);
45438
+ }
45439
+ }
45440
+ }
45441
+ }
45442
+
45321
45443
  const AdapterContextSegment = 'ADAPTER-CONTEXT';
45322
45444
  const ADAPTER_CONTEXT_ID_SUFFIX = '__NAMED_CONTEXT';
45323
45445
  async function reviveOrCreateContext(adapterId, durableStore, durableStoreErrorHandler, contextStores, pendingContextStoreKeys, onContextLoaded) {
@@ -45355,7 +45477,7 @@
45355
45477
  }
45356
45478
  return contextReturn();
45357
45479
  }
45358
- function isUnfulfilledSnapshot(cachedSnapshotResult) {
45480
+ function isUnfulfilledSnapshot$1(cachedSnapshotResult) {
45359
45481
  if (cachedSnapshotResult === undefined) {
45360
45482
  return false;
45361
45483
  }
@@ -45380,13 +45502,18 @@
45380
45502
  // event. If this instance of makeDurable caused that L2 write we can ignore that
45381
45503
  // on change event. This Set helps us do that.
45382
45504
  const pendingContextStoreKeys = new Set();
45505
+ // redirects that need to be flushed to the durable store
45506
+ const pendingStoreRedirects = new Map();
45383
45507
  const contextStores = create$5(null);
45384
45508
  let initializationPromise = new Promise((resolve) => {
45385
45509
  const finish = () => {
45386
45510
  resolve();
45387
45511
  initializationPromise = undefined;
45388
45512
  };
45389
- reviveTTLOverrides(durableTTLStore, environment).then(finish);
45513
+ Promise.all([
45514
+ reviveTTLOverrides(durableTTLStore, environment),
45515
+ reviveRedirects(durableStore, environment),
45516
+ ]).then(finish);
45390
45517
  });
45391
45518
  //instrumentation for durable store errors
45392
45519
  const durableStoreErrorHandler = handleDurableStoreRejection(instrumentation);
@@ -45399,6 +45526,8 @@
45399
45526
  const unsubscribe = durableStore.registerOnChangedListener(async (changes) => {
45400
45527
  const defaultSegmentKeys = [];
45401
45528
  const adapterContextSegmentKeys = [];
45529
+ const redirectSegmentKeys = [];
45530
+ let shouldBroadcast = false;
45402
45531
  for (let i = 0, len = changes.length; i < len; i++) {
45403
45532
  const change = changes[i];
45404
45533
  // we only care about changes to the data which is stored in the default
@@ -45409,6 +45538,20 @@
45409
45538
  else if (change.segment === AdapterContextSegment) {
45410
45539
  adapterContextSegmentKeys.push(...change.ids);
45411
45540
  }
45541
+ else if (change.segment === RedirectDurableSegment) {
45542
+ redirectSegmentKeys.push(...change.ids);
45543
+ }
45544
+ }
45545
+ if (redirectSegmentKeys.length > 0) {
45546
+ const redirectEntries = await durableStore.getEntries(redirectSegmentKeys, RedirectDurableSegment);
45547
+ if (redirectEntries !== undefined) {
45548
+ const redirectKeys = Object.keys(redirectEntries);
45549
+ for (const key of redirectKeys) {
45550
+ const redirectData = redirectEntries[key];
45551
+ environment.storeRedirect(redirectData.data.key, redirectData.data.redirect);
45552
+ shouldBroadcast = true;
45553
+ }
45554
+ }
45412
45555
  }
45413
45556
  // process adapter context changes
45414
45557
  const adapterContextKeysFromDifferentInstance = [];
@@ -45428,7 +45571,7 @@
45428
45571
  try {
45429
45572
  const entries = await durableStore.getEntries(adapterContextKeysFromDifferentInstance, AdapterContextSegment);
45430
45573
  if (entries !== undefined) {
45431
- const entryKeys = keys$5(entries);
45574
+ const entryKeys = keys$6(entries);
45432
45575
  for (let i = 0, len = entryKeys.length; i < len; i++) {
45433
45576
  const entryKey = entryKeys[i];
45434
45577
  const entry = entries[entryKey];
@@ -45445,10 +45588,6 @@
45445
45588
  if (defaultSegmentKeysLength > 0) {
45446
45589
  for (let i = 0; i < defaultSegmentKeysLength; i++) {
45447
45590
  const key = defaultSegmentKeys[i];
45448
- const canonical = environment.storeGetCanonicalKey(key);
45449
- if (canonical !== key) {
45450
- continue;
45451
- }
45452
45591
  // TODO: W-8909393 If expiration is the only thing that changed we should not evict the data... so
45453
45592
  // if we stored expiration and data at different keys (or same keys in different segments)
45454
45593
  // then we could know if only the expiration has changed and we wouldn't need to evict
@@ -45456,6 +45595,9 @@
45456
45595
  // call base environment storeEvict so this evict is not tracked for durable deletion
45457
45596
  environment.storeEvict(key);
45458
45597
  }
45598
+ shouldBroadcast = true;
45599
+ }
45600
+ if (shouldBroadcast) {
45459
45601
  await environment.storeBroadcast(rebuildSnapshot, environment.snapshotAvailable);
45460
45602
  }
45461
45603
  });
@@ -45506,12 +45648,13 @@
45506
45648
  // call the base storeBroadcast
45507
45649
  return publishChangesToDurableStore();
45508
45650
  };
45509
- const publishChangesToDurableStore = function () {
45651
+ const publishChangesToDurableStore = function (additionalDurableStoreOperations) {
45510
45652
  validateNotDisposed();
45511
45653
  if (ingestStagingStore === null) {
45512
45654
  return Promise.resolve();
45513
45655
  }
45514
- const promise = flushInMemoryStoreValuesToDurableStore(ingestStagingStore, durableStore, durableStoreErrorHandler);
45656
+ const promise = flushInMemoryStoreValuesToDurableStore(ingestStagingStore, durableStore, durableStoreErrorHandler, new Map(pendingStoreRedirects), additionalDurableStoreOperations);
45657
+ pendingStoreRedirects.clear();
45515
45658
  ingestStagingStore = null;
45516
45659
  return promise;
45517
45660
  };
@@ -45593,6 +45736,7 @@
45593
45736
  };
45594
45737
  const storeRedirect = function (existingKey, canonicalKey) {
45595
45738
  validateNotDisposed();
45739
+ pendingStoreRedirects.set(existingKey, canonicalKey);
45596
45740
  // call redirect on staging store so "old" keys are removed from L2 on
45597
45741
  // the next publishChangesToDurableStore. NOTE: we don't need to call
45598
45742
  // redirect on the base environment store because staging store and base
@@ -45638,7 +45782,7 @@
45638
45782
  const snapshot = buildCachedSnapshot(injectedBuildSnapshotContext, injectedStoreLookup, luvio);
45639
45783
  // if the adapter attempted to do an L1 lookup and it was unfulfilled
45640
45784
  // then we can attempt an L2 lookup
45641
- if (isUnfulfilledSnapshot(snapshot)) {
45785
+ if (isUnfulfilledSnapshot$1(snapshot)) {
45642
45786
  const start = Date.now();
45643
45787
  emitDurableEnvironmentAdapterEvent({ type: 'l2-revive-start' }, adapterRequestContext.eventObservers);
45644
45788
  const revivedSnapshot = reviveSnapshot(environment, durableStore, snapshot, durableStoreErrorHandler, () => injectedStoreLookup(snapshot.select, snapshot.refresh)).then((result) => {
@@ -46245,6 +46389,12 @@
46245
46389
  function stringLiteral(value, safe = false, isCaseSensitive = false) {
46246
46390
  return { type: ValueType.StringLiteral, value, safe, isCaseSensitive };
46247
46391
  }
46392
+ function isStringLiteral(expression) {
46393
+ return expression.type === ValueType.StringLiteral;
46394
+ }
46395
+ function isStringArray(expression) {
46396
+ return expression.type === ValueType.StringArray;
46397
+ }
46248
46398
  function comparison(left, operator, right) {
46249
46399
  return { type: PredicateType$1.comparison, left, right, operator };
46250
46400
  }
@@ -46504,7 +46654,7 @@
46504
46654
  case ComparisonOperator.eq:
46505
46655
  return '=';
46506
46656
  case ComparisonOperator.ne:
46507
- return '!=';
46657
+ return 'IS NOT';
46508
46658
  case ComparisonOperator.gt:
46509
46659
  return '>';
46510
46660
  case ComparisonOperator.gte:
@@ -46544,9 +46694,13 @@
46544
46694
  const pathPrefix = '$';
46545
46695
  const recordsCTE = 'recordsCTE';
46546
46696
  const MultiPickListValueSeparator$1 = ';';
46697
+ const recordCTESQL = excludeStaleRecordsGate.isOpen({ fallback: false })
46698
+ ? `WITH ${recordsCTE} AS NOT materialized ` +
46699
+ `(select data, metadata from lds_data where key like 'UiApi::RecordRepresentation:%')`
46700
+ : `WITH ${recordsCTE} AS NOT materialized ` +
46701
+ `(select data from lds_data where key like 'UiApi::RecordRepresentation:%')`;
46547
46702
  function cteSql() {
46548
- return (`WITH ${recordsCTE} AS NOT materialized ` +
46549
- `(select data from lds_data where key like 'UiApi::RecordRepresentation:%')`);
46703
+ return recordCTESQL;
46550
46704
  }
46551
46705
  function computeSql(rootQuery) {
46552
46706
  const fields = rootQuery.connections.map((connection) => {
@@ -46823,6 +46977,14 @@
46823
46977
  if (expression.subfield === 'displayValue' && targetDataType === 'Boolean') {
46824
46978
  return { sql: 'null', bindings: [] };
46825
46979
  }
46980
+ // metadata extract is somewhat different than a data extract
46981
+ if (expression.metadata === true) {
46982
+ let sql = `json_extract("${expression.jsonAlias}".metadata, '${pathPrefix}.${expression.field}')`;
46983
+ if (targetDataType !== undefined) {
46984
+ sql = coerceToTargetDataType(sql, targetDataType);
46985
+ }
46986
+ return { sql, bindings: [] };
46987
+ }
46826
46988
  let path = extractPath(expression.field, expression.subfield);
46827
46989
  // For multiple picklist includes/excluding filtering, we need to prefix and suffix the field value with ';'
46828
46990
  // to make the match safe.
@@ -47015,6 +47177,9 @@
47015
47177
  }
47016
47178
  }
47017
47179
 
47180
+ const { isArray: isArray$4 } = Array;
47181
+ const { keys: keys$5 } = Object;
47182
+
47018
47183
  function isListValueNode(node) {
47019
47184
  return node.kind === 'ListValue';
47020
47185
  }
@@ -47067,13 +47232,13 @@
47067
47232
  const NotOperator = 'not';
47068
47233
  const { eq, ne, gt, gte, lt, lte, nin, like, includes, excludes } = ComparisonOperator;
47069
47234
  const inOp = ComparisonOperator.in;
47070
- function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperator = CompoundOperator.and, joins) {
47235
+ function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperator = CompoundOperator.and, joins, draftFunctions) {
47071
47236
  const results = fieldValues
47072
47237
  .map((value) => {
47073
47238
  if (!isObjectValueNode$1(value)) {
47074
47239
  return [failure([message('Parent filter node should be an object.')])];
47075
47240
  }
47076
- return Object.entries(value.fields).map(([key, value]) => filter(key, value, joinAlias, apiName, input, joins));
47241
+ return Object.entries(value.fields).map(([key, value]) => filter(key, value, joinAlias, apiName, input, joins, draftFunctions));
47077
47242
  })
47078
47243
  .reduce(flatten$1, []);
47079
47244
  const failures = results.filter(isFailure).reduce(flatMap$1(errors), []);
@@ -47095,22 +47260,22 @@
47095
47260
  return success({ predicate: resolvedPredicate });
47096
47261
  }
47097
47262
  //{where: {Field: ... | and: ... | or: ... | not: ...}}
47098
- function recordFilter(where, joinAlias, apiName, input, joins) {
47263
+ function recordFilter(where, joinAlias, apiName, input, joins, draftFunctions) {
47099
47264
  if (where === undefined) {
47100
47265
  return success(undefined);
47101
47266
  }
47102
47267
  // when 'recordFilter' starts, there is no 'NotPredicated'
47103
- return fieldsToFilters([where.value], joinAlias, apiName, input, CompoundOperator.and, joins).map((result) => result.predicate === undefined || isEmptyPredicate(result.predicate) ? undefined : result);
47268
+ return fieldsToFilters([where.value], joinAlias, apiName, input, CompoundOperator.and, joins, draftFunctions).map((result) => result.predicate === undefined || isEmptyPredicate(result.predicate) ? undefined : result);
47104
47269
  }
47105
- function filter(name, value, tableAlias, apiName, input, joins) {
47270
+ function filter(name, value, tableAlias, apiName, input, joins, draftFunctions) {
47106
47271
  if (isCompoundOperator(name)) {
47107
47272
  if (!isListValueNode(value)) {
47108
47273
  return failure([message(`Value for ${name} node must be a list.`)]);
47109
47274
  }
47110
- return compoundPredicate(name, value, tableAlias, apiName, input, joins);
47275
+ return compoundPredicate(name, value, tableAlias, apiName, input, joins, draftFunctions);
47111
47276
  }
47112
47277
  if (name === NotOperator) {
47113
- const children = fieldsToFilters([value], tableAlias, apiName, input, CompoundOperator.and, joins);
47278
+ const children = fieldsToFilters([value], tableAlias, apiName, input, CompoundOperator.and, joins, draftFunctions);
47114
47279
  // take the children of a not predicate
47115
47280
  // and wrap them all inside it
47116
47281
  return children.flatMap((container) => {
@@ -47128,10 +47293,10 @@
47128
47293
  if (!isObjectValueNode$1(value)) {
47129
47294
  return failure([message('Filter node must be an object or list.')]);
47130
47295
  }
47131
- return fieldFilter(name, value, tableAlias, apiName, input, joins);
47296
+ return fieldFilter(name, value, tableAlias, apiName, input, joins, draftFunctions);
47132
47297
  }
47133
- function compoundPredicate(operator, list, joinAlias, apiName, input, joins) {
47134
- return fieldsToFilters(list.values, joinAlias, apiName, input, operator, joins);
47298
+ function compoundPredicate(operator, list, joinAlias, apiName, input, joins, draftFunctions) {
47299
+ return fieldsToFilters(list.values, joinAlias, apiName, input, operator, joins, draftFunctions);
47135
47300
  }
47136
47301
  /**
47137
47302
  * spans a FieldNode with its ObjectValueNode is passed. All the predicates is added into the 'join' array.
@@ -47142,7 +47307,7 @@
47142
47307
  * @param joins
47143
47308
  * @returns undefined predicate
47144
47309
  */
47145
- function spanningFilter(fieldInfo, fieldNode, alias, input, joins) {
47310
+ function spanningFilter(fieldInfo, fieldNode, alias, input, joins, draftFunctions) {
47146
47311
  const { apiName: fieldName, referenceToInfos, relationshipName } = fieldInfo;
47147
47312
  const referenceInfo = referenceToInfos[0];
47148
47313
  const jsonAlias = `${alias}.${relationshipName}`;
@@ -47161,7 +47326,7 @@
47161
47326
  joins.push(join);
47162
47327
  // moves constraint predicate to where
47163
47328
  const constraintPredicates = [];
47164
- const filterResult = fieldsToFilters([fieldNode], jsonAlias, apiName, input, CompoundOperator.and, joins);
47329
+ const filterResult = fieldsToFilters([fieldNode], jsonAlias, apiName, input, CompoundOperator.and, joins, draftFunctions);
47165
47330
  if (filterResult.isSuccess === false) {
47166
47331
  return filterResult;
47167
47332
  }
@@ -47173,7 +47338,11 @@
47173
47338
  });
47174
47339
  return success({ predicate: combinePredicates(constraintPredicates, CompoundOperator.and) });
47175
47340
  }
47176
- function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins) {
47341
+ function isIDValueField$1(fieldInfo) {
47342
+ return (fieldInfo.apiName === 'Id' ||
47343
+ (fieldInfo.referenceToInfos !== undefined && fieldInfo.referenceToInfos.length > 0));
47344
+ }
47345
+ function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins, draftFunctions) {
47177
47346
  const fieldInfoResult = getFieldInfo(apiName, fieldName, input);
47178
47347
  if (fieldInfoResult.isSuccess === false) {
47179
47348
  return failure([fieldInfoResult.error]);
@@ -47183,8 +47352,9 @@
47183
47352
  return failure([message(`Field ${fieldName} for type ${apiName} not found.`)]);
47184
47353
  }
47185
47354
  if (fieldInfo.dataType === 'Reference' && fieldInfo.relationshipName === fieldName) {
47186
- return spanningFilter(fieldInfo, fieldNode, alias, input, joins);
47355
+ return spanningFilter(fieldInfo, fieldNode, alias, input, joins, draftFunctions);
47187
47356
  }
47357
+ const idProcessingNeeded = isIDValueField$1(fieldInfo);
47188
47358
  const extract = {
47189
47359
  type: ValueType.Extract,
47190
47360
  jsonAlias: alias,
@@ -47272,7 +47442,29 @@
47272
47442
  children,
47273
47443
  };
47274
47444
  }
47275
- return comparison(extract, op.operator, op.value);
47445
+ const rightOperand = op.value;
47446
+ if (idProcessingNeeded) {
47447
+ if (isStringLiteral(rightOperand)) {
47448
+ if (rightOperand.value !== null) {
47449
+ if (draftFunctions.isDraftId(rightOperand.value)) {
47450
+ rightOperand.value = draftFunctions.getCanonicalId(rightOperand.value);
47451
+ }
47452
+ }
47453
+ }
47454
+ else if (isStringArray(rightOperand)) {
47455
+ if (rightOperand.value !== null) {
47456
+ rightOperand.value = rightOperand.value.map((originalId) => {
47457
+ if (originalId !== null) {
47458
+ if (draftFunctions.isDraftId(originalId)) {
47459
+ return draftFunctions.getCanonicalId(originalId);
47460
+ }
47461
+ }
47462
+ return originalId;
47463
+ });
47464
+ }
47465
+ }
47466
+ }
47467
+ return comparison(extract, op.operator, rightOperand);
47276
47468
  });
47277
47469
  const combined = combinePredicates(comparisons.concat(...dateFunction.value), CompoundOperator.and);
47278
47470
  const container = {
@@ -47479,7 +47671,11 @@
47479
47671
  }
47480
47672
  if (objectInfoDataType === 'Double') {
47481
47673
  if (isScalarOperatorType(operator)) {
47482
- return is(valueNode, 'FloatValue')
47674
+ // allow a float/double value to be passed
47675
+ // also allow an integer to be passed to a double, but not a double to an integer
47676
+ const isFloatOrInt = is(valueNode, 'FloatValue') ||
47677
+ is(valueNode, 'IntValue');
47678
+ return isFloatOrInt
47483
47679
  ? success({
47484
47680
  type: 'DoubleOperator',
47485
47681
  operator,
@@ -48368,7 +48564,7 @@
48368
48564
  const orderByJoins = [];
48369
48565
  const orderByResult = parseOrderBy(orderByArg, alias, apiName, input.objectInfoMap, orderByJoins);
48370
48566
  const filterJoins = [];
48371
- const whereResult = recordFilter(whereArg, alias, apiName, input.objectInfoMap, filterJoins);
48567
+ const whereResult = recordFilter(whereArg, alias, apiName, input.objectInfoMap, filterJoins, input.draftFunctions);
48372
48568
  const scopeJoins = [];
48373
48569
  const scopeResult = scopeFilter(scopeArg, alias, apiName, input, scopeJoins);
48374
48570
  let additionalPredicates = [];
@@ -48416,6 +48612,33 @@
48416
48612
  const draftsField = { type: FieldType.Scalar, extract, path: 'node._drafts' };
48417
48613
  const idExtract = { type: ValueType.Extract, jsonAlias: alias, field: 'Id' };
48418
48614
  const idField = { type: FieldType.Scalar, extract: idExtract, path: 'node.Id' };
48615
+ // When the exclude stale records gate is open and there is a root timestamp
48616
+ // in the parser input, inject an additional predicate to limit the search
48617
+ // to records that either have drafts associated to them or were ingested at
48618
+ // least as recently as the query.
48619
+ if (excludeStaleRecordsGate.isOpen({ fallback: false }) && input.rootTimestamp !== undefined) {
48620
+ const timestampCheck = {
48621
+ type: PredicateType$1.comparison,
48622
+ left: {
48623
+ type: ValueType.Extract,
48624
+ jsonAlias: alias,
48625
+ field: 'ingestionTimestamp',
48626
+ metadata: true,
48627
+ },
48628
+ operator: ComparisonOperator.gte,
48629
+ right: { type: ValueType.IntLiteral, value: input.rootTimestamp },
48630
+ };
48631
+ const isDraft = {
48632
+ type: PredicateType$1.nullComparison,
48633
+ left: { type: ValueType.Extract, jsonAlias: alias, field: 'drafts' },
48634
+ operator: NullComparisonOperator.isNot,
48635
+ };
48636
+ predicates.push({
48637
+ type: PredicateType$1.compound,
48638
+ operator: CompoundOperator.or,
48639
+ children: [timestampCheck, isDraft],
48640
+ });
48641
+ }
48419
48642
  return queryContainer(internalFields, alias, apiName, predicates).map((result) => {
48420
48643
  const { fields, predicates } = result;
48421
48644
  const allFields = removeDuplicateFields(fields.concat(...[draftsField, idField]));
@@ -48464,6 +48687,20 @@
48464
48687
  if (input.objectInfoMap[alias] === undefined) {
48465
48688
  return failure([missingObjectInfo(apiName)]);
48466
48689
  }
48690
+ // When the exclude stale records gate is open and the query has an
48691
+ // ingestion timestamp in its cache metadata, associate that with the input
48692
+ // so it can later be used to limit the search to records were ingested at
48693
+ // least as recently as the query.
48694
+ if (excludeStaleRecordsGate.isOpen({ fallback: false })) {
48695
+ const key = input.connectionKeyBuilder(selection, input.config.variables);
48696
+ const queryMetadata = input.metadata[key];
48697
+ // If there is no metadata for this query or it somehow lacks a timestamp
48698
+ // skip setting the root timestamp
48699
+ if (queryMetadata !== undefined && queryMetadata.ingestionTimestamp !== undefined) {
48700
+ // subtract 10ms from timestamp to account for ingestion processing time
48701
+ input.rootTimestamp = queryMetadata.ingestionTimestamp - 10;
48702
+ }
48703
+ }
48467
48704
  return recordQuery(selection, alias, apiName, [], input);
48468
48705
  }
48469
48706
  function rootQuery(recordNodes, input) {
@@ -48530,27 +48767,19 @@
48530
48767
  ? node.arguments
48531
48768
  .map((args) => {
48532
48769
  const { value, name } = args;
48770
+ //The variable is on the top level, for example `where: ${filter}`
48533
48771
  if (is(value, 'Variable')) {
48534
- const variable = variables[value.name];
48535
- if (variable) {
48536
- const jsonString = JSON.stringify(variable);
48537
- const buildRecordQueryString = (name, query, transform) => {
48538
- return `${name}: ${transform(query)}`;
48539
- };
48540
- switch (name) {
48541
- case 'scope':
48542
- case 'orderBy':
48543
- return buildRecordQueryString(name, jsonString, removeAllQuotations);
48544
- default:
48545
- return buildRecordQueryString(name, jsonString, removeQuotationsFromKeys);
48546
- }
48547
- }
48548
- return '';
48772
+ return generateVariableNodeQuery(value, name, name, variables);
48773
+ }
48774
+ else if (isObjectValueNode$1(value)) {
48775
+ return generateVariableSubQuery(value, name, name, variables);
48549
48776
  }
48550
48777
  })
48551
48778
  .filter(Boolean)
48552
48779
  : undefined;
48553
- return gqlArguments ? `${node.name}(${gqlArguments.join(',')}) { Id }` : '';
48780
+ return gqlArguments
48781
+ ? `${node.name} ${gqlArguments.length > 0 ? '(' + gqlArguments.join(',') + ')' : ''} { Id }`
48782
+ : '';
48554
48783
  })
48555
48784
  //remove empty strings
48556
48785
  .filter(Boolean)
@@ -48560,6 +48789,51 @@
48560
48789
  return [accu.slice(0, 1), query, accu.slice(1, length)].join('');
48561
48790
  }, '{ }'));
48562
48791
  }
48792
+ /**
48793
+ * Given a LuvioValueNode, generates a sql with its variable node replaced with actual value.
48794
+ * @param valueNode G
48795
+ * @param name
48796
+ * @param type
48797
+ * @param variables
48798
+ * @returns
48799
+ */
48800
+ function generateVariableSubQuery(valueNode, name, type, variables) {
48801
+ switch (valueNode.kind) {
48802
+ case Kind.OBJECT: {
48803
+ // For example, `{ Id: { eq: $draftId } }` is a `ObjectValueNode`, which has field keys 'Id'
48804
+ const resultQuery = keys$5(valueNode.fields)
48805
+ .map((key) => generateVariableSubQuery(valueNode.fields[key], key, type, variables))
48806
+ .filter((subquery) => subquery.length > 0)
48807
+ .join(',');
48808
+ if (resultQuery.length > 0) {
48809
+ return `${name}: {${resultQuery}}`;
48810
+ }
48811
+ return resultQuery;
48812
+ }
48813
+ case Kind.VARIABLE:
48814
+ return generateVariableNodeQuery(valueNode, name, type, variables);
48815
+ default:
48816
+ return '';
48817
+ }
48818
+ }
48819
+ // Generate a sql for the variable node with its actual value.
48820
+ function generateVariableNodeQuery(value, name, type, variables) {
48821
+ const variable = variables[value.name];
48822
+ if (variable) {
48823
+ const jsonString = JSON.stringify(variable);
48824
+ const buildRecordQueryString = (name, query, transform) => {
48825
+ return `${name}: ${transform(query)}`;
48826
+ };
48827
+ switch (type) {
48828
+ case 'scope':
48829
+ case 'orderBy':
48830
+ return buildRecordQueryString(name, jsonString, removeAllQuotations);
48831
+ default:
48832
+ return buildRecordQueryString(name, jsonString, removeQuotationsFromKeys);
48833
+ }
48834
+ }
48835
+ return '';
48836
+ }
48563
48837
  /**
48564
48838
  * Given an AST with variables
48565
48839
  * Swap out the LuvioArgumentNodes on the original AST with ones generated from its variables.
@@ -48578,14 +48852,43 @@
48578
48852
  const { name } = node;
48579
48853
  const first = allArgumentRecords.find((n) => n.name === name);
48580
48854
  if (first) {
48581
- // if we had arguments that did not contain variables we still want those
48582
- first.arguments = flatten$1(first.arguments
48583
- ? first.arguments.filter((x) => x.value.kind !== 'Variable')
48584
- : [], node.arguments ? node.arguments : []);
48855
+ const swappedArgments = swapArgumentWithVariableNodes(node.arguments, first.arguments);
48856
+ first.arguments = swappedArgments ? swappedArgments : [];
48585
48857
  }
48586
48858
  });
48587
48859
  }
48588
48860
  }
48861
+ // Replaces the variable node in original LuvioArgumentNode with the actual value in the swapped node with the same path.
48862
+ function swapArgumentWithVariableNodes(swapped, original) {
48863
+ if (swapped === undefined || original === undefined) {
48864
+ return original;
48865
+ }
48866
+ return original.map((x) => {
48867
+ const targetNode = swapped.find((y) => y.name === x.name);
48868
+ if (targetNode === undefined) {
48869
+ return x;
48870
+ }
48871
+ if (x.value.kind === 'Variable') {
48872
+ return targetNode;
48873
+ }
48874
+ swapValueNodeWithVariableNodes(x.value, targetNode.value);
48875
+ return x;
48876
+ });
48877
+ }
48878
+ function swapValueNodeWithVariableNodes(original, swapped) {
48879
+ if (original.kind === Kind.OBJECT) {
48880
+ for (const key of keys$5(original.fields)) {
48881
+ if (isObjectValueNode$1(swapped) && swapped.fields[key]) {
48882
+ if (is(original.fields[key], 'Variable')) {
48883
+ original.fields[key] = swapped.fields[key];
48884
+ }
48885
+ else {
48886
+ swapValueNodeWithVariableNodes(original.fields[key], swapped.fields[key]);
48887
+ }
48888
+ }
48889
+ }
48890
+ }
48891
+ }
48589
48892
  //find top level record queries
48590
48893
  function findRecordSelections$1(document) {
48591
48894
  return document.definitions
@@ -48620,12 +48923,24 @@
48620
48923
  * Missing object info records triggers the objectInfoService (same instance shared with Drafts code), to
48621
48924
  * use the getObjectInfos adapter to efficiently fetch the necessary records.
48622
48925
  */
48623
- async createRootQuery(config, objectInfoService, userId) {
48926
+ async createRootQuery(config, objectInfoService, userId, draftFunctions, connectionKeyBuilder, sqliteStore) {
48624
48927
  const { query: ast, variables } = config;
48625
48928
  swapVariableArguments(ast, variables);
48626
48929
  // Parse out top-level record queries types we know we will need, since spanning fields will
48627
48930
  // require at least this top level record present to resolve relationship lookups
48628
- const topLevelNeededRecords = findRecordSelections$1(ast).map((selection) => selection.name);
48931
+ const recordSelections = findRecordSelections$1(ast);
48932
+ let metadata = {};
48933
+ if (excludeStaleRecordsGate.isOpen({ fallback: false })) {
48934
+ const keys = recordSelections.map((rs) => connectionKeyBuilder(rs, variables));
48935
+ let sqlResult = await sqliteStore.query(`select key, metadata from lds_data where key in (${keys
48936
+ .map(() => '?')
48937
+ .join(',')})`, keys);
48938
+ metadata = sqlResult.rows.reduce((metadata, row) => {
48939
+ metadata[row[0]] = JSON.parse(row[1]);
48940
+ return metadata;
48941
+ }, {});
48942
+ }
48943
+ const topLevelNeededRecords = recordSelections.map((selection) => selection.name);
48629
48944
  // Seed the initial list of things to fetch
48630
48945
  const neededObjectInfos = new Set(topLevelNeededRecords);
48631
48946
  // Seed the list of things we've _tried_ to fetch. As we iterate and
@@ -48665,8 +48980,12 @@
48665
48980
  };
48666
48981
  // Attempt to parse the AST given what we know already...
48667
48982
  astTransformResult = transform(ast, {
48983
+ config,
48668
48984
  userId,
48669
48985
  objectInfoMap,
48986
+ draftFunctions,
48987
+ connectionKeyBuilder,
48988
+ metadata,
48670
48989
  });
48671
48990
  if (astTransformResult.isSuccess === false) {
48672
48991
  for (const error of astTransformResult.error) {
@@ -48704,8 +49023,6 @@
48704
49023
  }
48705
49024
  }
48706
49025
 
48707
- const { isArray: isArray$4 } = Array;
48708
-
48709
49026
  /**
48710
49027
  * Checks a GraphQL-shaped network response for errors, returning true if it does
48711
49028
  * and false otherwise
@@ -48743,15 +49060,15 @@
48743
49060
  return { data, seenRecords };
48744
49061
  }
48745
49062
  const wrapStartEndEvents = (storeEval) => {
48746
- return async (config, nonEvaluatedSnapshotOrPromise, observers) => {
49063
+ return async (config, nonEvaluatedSnapshotOrPromise, observers, connectionKeyBuilder) => {
48747
49064
  const eventEmitter = createCustomAdapterEventEmitter(GRAPHQL_EVAL_NAMESPACE$1, observers);
48748
49065
  eventEmitter({ type: 'graphql-eval-start' });
48749
- const snapshot = await storeEval(config, nonEvaluatedSnapshotOrPromise, observers);
49066
+ const snapshot = await storeEval(config, nonEvaluatedSnapshotOrPromise, observers, connectionKeyBuilder);
48750
49067
  eventEmitter({ type: 'graphql-eval-end' });
48751
49068
  return snapshot;
48752
49069
  };
48753
49070
  };
48754
- function sqliteStoreEvalFactory(userId, sqliteStore, objectInfoService) {
49071
+ function sqliteStoreEvalFactory(userId, sqliteStore, objectInfoService, draftFunctions) {
48755
49072
  // if the store does not support eval then use the noop version
48756
49073
  if (sqliteStore.isEvalSupported() === false) {
48757
49074
  return noopStoreEval;
@@ -48759,7 +49076,7 @@
48759
49076
  const preconditioner = new StoreEvalPreconditioner();
48760
49077
  return makeStoreEval(preconditioner, objectInfoService, userId, async () => {
48761
49078
  return undefined;
48762
- }, (query, _context, eventEmitter) => evaluateSqlite(query, eventEmitter, sqliteStore));
49079
+ }, (query, _context, eventEmitter) => evaluateSqlite(query, eventEmitter, sqliteStore), draftFunctions, sqliteStore);
48763
49080
  }
48764
49081
  async function noopStoreEval(_config, nonEvaluatedSnapshotOrPromise, _observers) {
48765
49082
  return nonEvaluatedSnapshotOrPromise;
@@ -48778,8 +49095,8 @@
48778
49095
  function generateUniqueRecordId$1() {
48779
49096
  return `${GRAPHQL_ROOT_KEY$1}${Date.now() + Math.random().toFixed(5).split('.')[1]}`;
48780
49097
  }
48781
- function makeStoreEval(preconditioner, objectInfoService, userId, contextProvider, queryEvaluator) {
48782
- const storeEval = async (config, nonEvaluatedSnapshotOrPromise, observers) => {
49098
+ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvider, queryEvaluator, draftFunctions, sqliteStore) {
49099
+ const storeEval = async (config, nonEvaluatedSnapshotOrPromise, observers, connectionKeyBuilder) => {
48783
49100
  const eventEmitter = createCustomAdapterEventEmitter(GRAPHQL_EVAL_NAMESPACE$1, observers);
48784
49101
  // the non-eval'ed input could either be a snapshot or promise of one so
48785
49102
  // await it here to normalize the input to a snapshot
@@ -48808,7 +49125,7 @@
48808
49125
  context = await contextProvider();
48809
49126
  // Ensures ObjectInfo metadata is available for the request. Sourcing records from L1/L2/Network
48810
49127
  // is delegated to the getObjectInfo adapter via objectInfoService
48811
- rootQuery = await preconditioner.createRootQuery(config, objectInfoService, userId);
49128
+ rootQuery = await preconditioner.createRootQuery(config, objectInfoService, userId, draftFunctions, connectionKeyBuilder, sqliteStore);
48812
49129
  }
48813
49130
  catch (error) {
48814
49131
  eventEmitter({
@@ -48839,7 +49156,7 @@
48839
49156
  try {
48840
49157
  const { data, seenRecords } = await queryEvaluator(rootQuery, context, eventEmitter);
48841
49158
  const rebuildWithStoreEval = ((originalSnapshot) => {
48842
- return storeEval(config, originalSnapshot, observers);
49159
+ return storeEval(config, originalSnapshot, observers, connectionKeyBuilder);
48843
49160
  });
48844
49161
  const recordId = generateUniqueRecordId$1();
48845
49162
  // if the non-eval'ed snapshot was an error then we return a synthetic
@@ -49138,7 +49455,7 @@
49138
49455
  return new DraftErrorFetchResponse(HttpStatusCode$1.BadRequest, error);
49139
49456
  }
49140
49457
 
49141
- const { keys: keys$4, create: create$4, assign: assign$3, values: values$1 } = Object;
49458
+ const { keys: keys$4, create: create$4, assign: assign$4, values: values$1 } = Object;
49142
49459
  const { stringify: stringify$4, parse: parse$4 } = JSON;
49143
49460
  const { isArray: isArray$3 } = Array;
49144
49461
 
@@ -49185,7 +49502,6 @@
49185
49502
  }
49186
49503
 
49187
49504
  const DraftIdMappingKeyPrefix240 = 'DraftIdMapping::';
49188
- const DraftKeyMappingKeyPrefix = 'DraftKeyMapping::V2::';
49189
49505
  const DRAFT_ID_MAPPINGS_SEGMENT = 'DRAFT_ID_MAPPINGS';
49190
49506
  function isLegacyDraftIdMapping(key, data) {
49191
49507
  return key.startsWith(DraftIdMappingKeyPrefix240);
@@ -49195,9 +49511,6 @@
49195
49511
  function getRecordKeyForId$1(id) {
49196
49512
  return `UiApi::RecordRepresentation:${id}`;
49197
49513
  }
49198
- function generateDraftIdMappingKey(draftIdMapping) {
49199
- return `${DraftKeyMappingKeyPrefix}${draftIdMapping.draftKey}::${draftIdMapping.canonicalKey}`;
49200
- }
49201
49514
  /**
49202
49515
  *
49203
49516
  * @param mappingIds (optional) requested mapping ids, if undefined all will be retrieved
@@ -49231,6 +49544,15 @@
49231
49544
  }
49232
49545
  return mappings;
49233
49546
  }
49547
+ async function clearDraftIdSegment(durableStore) {
49548
+ const entries = await durableStore.getAllEntries(DRAFT_ID_MAPPINGS_SEGMENT);
49549
+ if (entries) {
49550
+ const keys$1 = keys$4(entries);
49551
+ if (keys$1.length > 0) {
49552
+ await durableStore.evictEntries(keys$1, DRAFT_ID_MAPPINGS_SEGMENT);
49553
+ }
49554
+ }
49555
+ }
49234
49556
 
49235
49557
  /**
49236
49558
  * Generates a time-ordered, unique id to associate with a DraftAction. Ensures
@@ -49321,9 +49643,6 @@
49321
49643
  });
49322
49644
  return queueOperations;
49323
49645
  };
49324
- const getRedirectMappings = (_action) => {
49325
- return undefined;
49326
- };
49327
49646
  return {
49328
49647
  handlerId: id,
49329
49648
  enqueue: (data) => {
@@ -49335,7 +49654,6 @@
49335
49654
  handleReplaceAction: () => {
49336
49655
  throw Error('replaceAction not supported for custom actions');
49337
49656
  },
49338
- getRedirectMappings,
49339
49657
  handleActionRemoved: () => Promise.resolve(),
49340
49658
  handleActionCompleted: () => Promise.resolve(),
49341
49659
  handleActionEnqueued: () => Promise.resolve(),
@@ -49510,17 +49828,11 @@
49510
49828
  const handler = this.getHandler(action.handler);
49511
49829
  let queue = await this.getQueueActions();
49512
49830
  const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
49513
- const idAndKeyMappings = handler.getRedirectMappings(action);
49514
- const keyMappings = idAndKeyMappings === undefined
49515
- ? undefined
49516
- : idAndKeyMappings.map((m) => {
49517
- return { draftKey: m.draftKey, canonicalKey: m.canonicalKey };
49518
- });
49519
- await this.draftStore.completeAction(queueOperations, keyMappings);
49520
- queue = await this.getQueueActions();
49831
+ // write the queue operations to the store prior to ingesting the result
49832
+ await this.draftStore.completeAction(queueOperations);
49833
+ await handler.handleActionCompleted(action, queueOperations, values$1(this.handlers));
49521
49834
  this.retryIntervalMilliseconds = 0;
49522
49835
  this.uploadingActionId = undefined;
49523
- await handler.handleActionCompleted(action, queueOperations, queue, values$1(this.handlers));
49524
49836
  await this.notifyChangedListeners({
49525
49837
  type: DraftQueueEventType.ActionCompleted,
49526
49838
  action,
@@ -49839,7 +50151,7 @@
49839
50151
  };
49840
50152
  return this.enqueueAction(deleteAction);
49841
50153
  }
49842
- completeAction(queueOperations, mappings) {
50154
+ completeAction(queueOperations) {
49843
50155
  const action = () => {
49844
50156
  const durableStoreOperations = [];
49845
50157
  const { draftStore } = this;
@@ -49872,18 +50184,6 @@
49872
50184
  });
49873
50185
  }
49874
50186
  }
49875
- if (mappings !== undefined) {
49876
- const entries = {};
49877
- for (const mapping of mappings) {
49878
- const mappingKey = generateDraftIdMappingKey(mapping);
49879
- entries[mappingKey] = { data: mapping };
49880
- }
49881
- durableStoreOperations.push({
49882
- entries,
49883
- type: 'setEntries',
49884
- segment: DRAFT_ID_MAPPINGS_SEGMENT,
49885
- });
49886
- }
49887
50187
  return this.durableStore.batchOperations(durableStoreOperations);
49888
50188
  };
49889
50189
  return this.enqueueAction(action);
@@ -50148,7 +50448,7 @@
50148
50448
  },
50149
50449
  ];
50150
50450
  }
50151
- async handleActionCompleted(action, queueOperations, _queue, allHandlers) {
50451
+ async handleActionCompleted(action, queueOperations, allHandlers) {
50152
50452
  const { data: request, tag } = action;
50153
50453
  const { method } = request;
50154
50454
  if (method === 'delete') {
@@ -50225,6 +50525,8 @@
50225
50525
  };
50226
50526
  // overlay metadata
50227
50527
  merged.metadata = { ...targetMetadata, ...sourceMetadata };
50528
+ // put status back to pending to auto upload if queue is active and targed is at the head.
50529
+ merged.status = DraftActionStatus.Pending;
50228
50530
  return merged;
50229
50531
  }
50230
50532
  shouldDeleteActionByTagOnRemoval(action) {
@@ -50260,11 +50562,18 @@
50260
50562
  async ingestResponses(responses, action) {
50261
50563
  const luvio = this.getLuvio();
50262
50564
  await luvio.handleSuccessResponse(() => {
50565
+ if (action.status === DraftActionStatus.Completed) {
50566
+ const mappings = this.getRedirectMappings(action);
50567
+ if (mappings) {
50568
+ mappings.forEach((mapping) => {
50569
+ luvio.storeRedirect(mapping.draftKey, mapping.canonicalKey);
50570
+ });
50571
+ }
50572
+ }
50263
50573
  for (const entry of responses) {
50264
50574
  const { response, synchronousIngest } = entry;
50265
50575
  synchronousIngest(response, action);
50266
50576
  }
50267
- // must call base broadcast
50268
50577
  return luvio.storeBroadcast();
50269
50578
  },
50270
50579
  // getTypeCacheKeysRecord uses the response, not the full path factory
@@ -50592,6 +50901,8 @@
50592
50901
 
50593
50902
  function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueue) {
50594
50903
  const draftMetadata = {};
50904
+ // in 246 luvio took charge of persisting redirect mappings, this needs to stick around
50905
+ // for a couple of releases to support older environments
50595
50906
  // setup existing store redirects when bootstrapping the environment
50596
50907
  (async () => {
50597
50908
  const mappings = await getDraftIdMappings(durableStore);
@@ -50599,23 +50910,9 @@
50599
50910
  const { draftKey, canonicalKey } = mapping;
50600
50911
  env.storeRedirect(draftKey, canonicalKey);
50601
50912
  });
50913
+ await env.storeBroadcast(env.rebuildSnapshot, env.snapshotAvailable);
50914
+ await clearDraftIdSegment(durableStore);
50602
50915
  })();
50603
- durableStore.registerOnChangedListener(async (changes) => {
50604
- const draftIdMappingsIds = [];
50605
- for (let i = 0, len = changes.length; i < len; i++) {
50606
- const change = changes[i];
50607
- if (change.segment === DRAFT_ID_MAPPINGS_SEGMENT) {
50608
- draftIdMappingsIds.push(...change.ids);
50609
- }
50610
- }
50611
- if (draftIdMappingsIds.length > 0) {
50612
- const mappings = await getDraftIdMappings(durableStore, draftIdMappingsIds);
50613
- mappings.forEach((mapping) => {
50614
- const { draftKey, canonicalKey } = mapping;
50615
- env.storeRedirect(draftKey, canonicalKey);
50616
- });
50617
- }
50618
- });
50619
50916
  const handleSuccessResponse = async function (ingestAndBroadcastFunc, getResponseCacheKeysFunc) {
50620
50917
  const queue = await draftQueue.getQueueActions();
50621
50918
  if (queue.length === 0) {
@@ -50683,16 +50980,23 @@
50683
50980
 
50684
50981
  const API_NAMESPACE = 'UiApi';
50685
50982
  const RECORD_REPRESENTATION_NAME$1 = 'RecordRepresentation';
50983
+ const RECORD_VIEW_ENTITY_REPRESENTATION_NAME = 'RecordViewEntityRepresentation';
50686
50984
  const RECORD_ID_PREFIX = `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME$1}:`;
50985
+ const RECORD_VIEW_ENTITY_ID_PREFIX = `${API_NAMESPACE}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME}:Name:`;
50687
50986
  const RECORD_FIELDS_KEY_JUNCTION = '__fields__';
50688
50987
  function isStoreKeyRecordId(key) {
50689
50988
  return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1;
50690
50989
  }
50990
+ function isStoreKeyRecordViewEntity(key) {
50991
+ return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) > -1 &&
50992
+ key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1);
50993
+ }
50691
50994
  function isStoreKeyRecordField(key) {
50692
50995
  return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) > -1;
50693
50996
  }
50694
50997
  function extractRecordIdFromStoreKey(key) {
50695
- if (key === undefined || key.indexOf(RECORD_ID_PREFIX) === -1) {
50998
+ if (key === undefined ||
50999
+ (key.indexOf(RECORD_ID_PREFIX) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) === -1)) {
50696
51000
  return undefined;
50697
51001
  }
50698
51002
  const parts = key.split(':');
@@ -50707,7 +51011,8 @@
50707
51011
  }
50708
51012
  function isEntryDurableRecordRepresentation(entry, key) {
50709
51013
  // Either a DurableRecordRepresentation or StoreRecordError can live at a record key
50710
- return isStoreKeyRecordId(key) && entry.data.__type === undefined;
51014
+ return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity(key)) &&
51015
+ entry.data.__type === undefined);
50711
51016
  }
50712
51017
 
50713
51018
  /**
@@ -50843,7 +51148,7 @@
50843
51148
  (x.length === 0 || (x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1))));
50844
51149
  }
50845
51150
 
50846
- const { create: create$3, keys: keys$3, values, entries: entries$2 } = Object;
51151
+ const { create: create$3, keys: keys$3, values, entries: entries$2, assign: assign$3 } = Object;
50847
51152
  const { stringify: stringify$3, parse: parse$3 } = JSON;
50848
51153
  const { isArray: isArray$2 } = Array;
50849
51154
 
@@ -51282,6 +51587,10 @@
51282
51587
  };
51283
51588
  }
51284
51589
 
51590
+ const JSON_EXTRACT_PATH_INGESTION_TIMESTAMP = '$.ingestionTimestamp';
51591
+ const JSON_EXTRACT_PATH_INGESTION_APINAME = '$.apiName';
51592
+ const JSON_EXTRACT_PATH_DRAFTS = '$.drafts';
51593
+
51285
51594
  const MultiPickListValueSeparator = ';';
51286
51595
  function filterToPredicates(where, recordType, alias, objectInfoMap, joins, draftFunctions) {
51287
51596
  if (!where)
@@ -51343,7 +51652,7 @@
51343
51652
  return [
51344
51653
  {
51345
51654
  alias: childAlias,
51346
- leftPath: '$.apiName',
51655
+ leftPath: JSON_EXTRACT_PATH_INGESTION_APINAME,
51347
51656
  operator: '=',
51348
51657
  value: entityName,
51349
51658
  dataType: 'String',
@@ -51643,15 +51952,10 @@
51643
51952
  // If an explicit collating sequence is required on an IN operator it should be applied to the left operand,
51644
51953
  // like this: "x COLLATE NOCASE IN (y,z, ...)".
51645
51954
  const nullCheck = `json_extract("${alias}".data, '${leftPath}') ${operator === 'IN' ? 'IS' : 'IS NOT'} ?`;
51646
- //if we only have a null in/nin then dont add the IN (y, z, ...)
51647
- if (valueBinding.length > 0) {
51648
- sql = `json_extract("${alias}".data, '${leftPath}')${isCaseSensitive === true ? '' : ` COLLATE NOCASE`} ${operator} ${questionSql} ${includesNull ? `OR ${nullCheck}` : ''}`;
51649
- }
51650
- else {
51651
- sql = `${includesNull ? nullCheck : ''}`;
51652
- }
51955
+ sql = `json_extract("${alias}".data, '${leftPath}')${isCaseSensitive === true ? '' : ` COLLATE NOCASE`} ${operator} ${questionSql}`;
51653
51956
  binding.push(...valueBinding);
51654
51957
  if (includesNull) {
51958
+ sql = `(${sql} OR ${nullCheck})`;
51655
51959
  binding.push(null);
51656
51960
  }
51657
51961
  }
@@ -51799,11 +52103,18 @@
51799
52103
  const joins = buildJoins(config);
51800
52104
  const predicates = buildPredicates(config);
51801
52105
  const orderBy = buildOrderBy(config);
52106
+ const staleRecordsSql = excludeStaleRecordsGate.isOpen({ fallback: false })
52107
+ ? `AND (
52108
+ json_extract("${config.alias}".metadata, '${JSON_EXTRACT_PATH_INGESTION_TIMESTAMP}') >= ?
52109
+ OR json_extract("${config.alias}".data, '${JSON_EXTRACT_PATH_DRAFTS}') IS NOT NULL
52110
+ )`
52111
+ : '';
51802
52112
  const sql = `
51803
52113
  SELECT "${config.alias}".data
51804
52114
  FROM lds_data "${config.alias}" ${joins.sql}
51805
52115
  WHERE "${config.alias}".key like 'UiApi::RecordRepresentation:%'
51806
- AND json_extract("${config.alias}".data, '$.apiName') = ?
52116
+ AND json_extract("${config.alias}".data, '${JSON_EXTRACT_PATH_INGESTION_APINAME}') = ?
52117
+ ${staleRecordsSql}
51807
52118
  ${predicates.sql}
51808
52119
  ${orderBy.sql}
51809
52120
  LIMIT ?
@@ -51816,6 +52127,7 @@
51816
52127
  ...joins.bindings,
51817
52128
  // the api name for the main record type
51818
52129
  config.alias,
52130
+ ...(excludeStaleRecordsGate.isOpen({ fallback: false }) ? [config.ingestionTimestamp] : []),
51819
52131
  // where clause and parent scope bindings
51820
52132
  ...predicates.bindings,
51821
52133
  // limit binding
@@ -51841,19 +52153,33 @@
51841
52153
  if (allJoins.length === 0)
51842
52154
  return { sql, bindings };
51843
52155
  sql = allJoins.reduce((joinAccumulator, join) => {
52156
+ let timestampAdded = false;
51844
52157
  const joinConditions = join.conditions.reduce((conditionAccumulator, condition) => {
51845
52158
  let joined_sql;
52159
+ const joinMetadataTimestamp = excludeStaleRecordsGate.isOpen({ fallback: false })
52160
+ ? ` AND (json_extract("${join.alias}".metadata, '${JSON_EXTRACT_PATH_INGESTION_TIMESTAMP}') >= ? OR json_extract("${join.alias}".data, '${JSON_EXTRACT_PATH_DRAFTS}') IS NOT NULL)`
52161
+ : '';
51846
52162
  // predicate on a value, use the newly joined table
51847
52163
  if ('type' in condition) {
51848
52164
  const { sql, binding } = predicateToSQL(condition, join.alias);
51849
- joined_sql = ` AND ${sql}`;
52165
+ joined_sql = ` AND ${sql}${timestampAdded ? '' : joinMetadataTimestamp}`;
51850
52166
  bindings.push(...binding);
52167
+ if (excludeStaleRecordsGate.isOpen({ fallback: false }) &&
52168
+ timestampAdded === false) {
52169
+ bindings.push(config.ingestionTimestamp);
52170
+ timestampAdded = true;
52171
+ }
51851
52172
  }
51852
52173
  else {
51853
52174
  // predicate on a path
51854
52175
  const left = ` AND json_extract("${join.to}".data, '${condition.leftPath}')`;
51855
52176
  const right = `json_extract("${join.alias}".data, '${condition.rightPath}')`;
51856
- joined_sql = `${left} = ${right}`;
52177
+ joined_sql = `${left} = ${right}${timestampAdded ? '' : joinMetadataTimestamp}`;
52178
+ if (excludeStaleRecordsGate.isOpen({ fallback: false }) &&
52179
+ timestampAdded === false) {
52180
+ bindings.push(config.ingestionTimestamp);
52181
+ timestampAdded = true;
52182
+ }
51857
52183
  }
51858
52184
  conditionAccumulator += joined_sql;
51859
52185
  return conditionAccumulator;
@@ -52532,7 +52858,7 @@
52532
52858
  function pathForKey(key) {
52533
52859
  switch (key) {
52534
52860
  case 'ApiName':
52535
- return '$.apiName';
52861
+ return JSON_EXTRACT_PATH_INGESTION_APINAME;
52536
52862
  case 'WeakEtag':
52537
52863
  return '$.weakEtag';
52538
52864
  case 'Id':
@@ -52554,7 +52880,7 @@
52554
52880
  {
52555
52881
  type: PredicateType.single,
52556
52882
  alias: 'ServiceAppointment_AssignedResource',
52557
- leftPath: '$.apiName',
52883
+ leftPath: JSON_EXTRACT_PATH_INGESTION_APINAME,
52558
52884
  operator: '=',
52559
52885
  value: 'AssignedResource',
52560
52886
  dataType: 'String',
@@ -52575,7 +52901,7 @@
52575
52901
  {
52576
52902
  type: PredicateType.single,
52577
52903
  alias: 'ServiceAppointment_AssignedResource_ServiceResource',
52578
- leftPath: '$.apiName',
52904
+ leftPath: JSON_EXTRACT_PATH_INGESTION_APINAME,
52579
52905
  operator: '=',
52580
52906
  value: 'ServiceResource',
52581
52907
  dataType: 'String',
@@ -52680,14 +53006,21 @@
52680
53006
  // Fields of the `RecordQuery` type are the record queries for the entity types
52681
53007
  // supported for the org
52682
53008
  for (const recordQuery of fields) {
52683
- recordQuery.resolve = function recordConnectionResolver(record, args) {
53009
+ recordQuery.resolve = async function recordConnectionResolver(record, args, { query }, info) {
53010
+ const { name: currentFieldName } = recordQuery;
53011
+ let ingestionTimestamp = 0;
53012
+ if (excludeStaleRecordsGate.isOpen({ fallback: false })) {
53013
+ // at our record query we fetch each ingestion time stamp and pass it down to each lower resolver to query against
53014
+ ingestionTimestamp = await fetchIngestionTimeStampFromDatabase(currentFieldName, info, args, query);
53015
+ }
52684
53016
  // In the SF schema, the relevant arguments are passed into RecordQuery fields, but actually used
52685
53017
  // down in the edge resolvers. For this resolver, we can just return what was passed in
52686
53018
  // to make it available to the next execution step
52687
53019
  return {
52688
53020
  parentArgs: args,
52689
53021
  parentRecord: record,
52690
- currentFieldName: recordQuery.name,
53022
+ currentFieldName,
53023
+ ingestionTimestamp,
52691
53024
  };
52692
53025
  };
52693
53026
  }
@@ -52733,10 +53066,11 @@
52733
53066
  // }
52734
53067
  for (const field of fields) {
52735
53068
  if (field.name === 'node') {
52736
- field.resolve = function nodeResolver(record, _args, { seenRecordIds }) {
53069
+ field.resolve = function nodeResolver(obj, _args, { seenRecordIds }) {
53070
+ const { record, ingestionTimestamp } = obj;
52737
53071
  const recordRepresentation = parse$3(record);
52738
53072
  seenRecordIds.add(recordRepresentation.id);
52739
- return recordRepresentation;
53073
+ return { recordRepresentation, ingestionTimestamp };
52740
53074
  };
52741
53075
  }
52742
53076
  }
@@ -52759,40 +53093,40 @@
52759
53093
  for (const field of fields) {
52760
53094
  switch (field.name) {
52761
53095
  case 'Id':
52762
- field.resolve = (record) => record.id;
53096
+ field.resolve = ({ recordRepresentation: record }) => record.id;
52763
53097
  break;
52764
53098
  case 'ApiName':
52765
- field.resolve = (record) => record.apiName;
53099
+ field.resolve = ({ recordRepresentation: record }) => record.apiName;
52766
53100
  break;
52767
53101
  case 'WeakEtag':
52768
- field.resolve = (record) => record.weakEtag;
53102
+ field.resolve = ({ recordRepresentation: record }) => record.weakEtag;
52769
53103
  break;
52770
53104
  case '_drafts':
52771
- field.resolve = (record) => {
53105
+ field.resolve = ({ recordRepresentation: record, }) => {
52772
53106
  return record.drafts ? record.drafts : null;
52773
53107
  };
52774
53108
  break;
52775
53109
  case 'LastModifiedById':
52776
- field.resolve = (record) => {
53110
+ field.resolve = ({ recordRepresentation: record }) => {
52777
53111
  return record.lastModifiedById
52778
53112
  ? { value: record.lastModifiedById }
52779
53113
  : null;
52780
53114
  };
52781
53115
  break;
52782
53116
  case 'LastModifiedDate':
52783
- field.resolve = (record) => {
53117
+ field.resolve = ({ recordRepresentation: record }) => {
52784
53118
  return record.lastModifiedDate
52785
53119
  ? { value: record.lastModifiedDate }
52786
53120
  : null;
52787
53121
  };
52788
53122
  break;
52789
53123
  case 'SystemModstamp':
52790
- field.resolve = (record) => {
53124
+ field.resolve = ({ recordRepresentation: record }) => {
52791
53125
  return record.systemModstamp ? { value: record.systemModstamp } : null;
52792
53126
  };
52793
53127
  break;
52794
53128
  case 'RecordTypeId':
52795
- field.resolve = (record) => {
53129
+ field.resolve = ({ recordRepresentation: record }) => {
52796
53130
  return record.recordTypeId ? { value: record.recordTypeId } : null;
52797
53131
  };
52798
53132
  break;
@@ -52804,7 +53138,17 @@
52804
53138
  .getInterfaces()
52805
53139
  .find((iface) => iface.name === 'Record')) ||
52806
53140
  (recordFieldType && recordFieldType.name === 'Record')) {
52807
- field.resolve = function relationResolver(record, _args, { Record, seenRecordIds }) {
53141
+ field.resolve = async function relationResolver(obj, _args, { Record, seenRecordIds }) {
53142
+ const fetchRecordOrNull = async (key) => {
53143
+ const recordRepresentation = await Record.load(key);
53144
+ return recordRepresentation !== null
53145
+ ? {
53146
+ recordRepresentation,
53147
+ ingestionTimestamp,
53148
+ }
53149
+ : null;
53150
+ };
53151
+ const { recordRepresentation: record, ingestionTimestamp } = obj;
52808
53152
  const fieldName = field.name.endsWith('__r')
52809
53153
  ? field.name.replace('__r', '__c')
52810
53154
  : field.name;
@@ -52814,26 +53158,28 @@
52814
53158
  if (!id)
52815
53159
  return null;
52816
53160
  if (id['__ref'] !== undefined) {
52817
- return Record.load(record.fields[`${field.name}Id`].value);
53161
+ return fetchRecordOrNull(record.fields[`${field.name}Id`].value);
52818
53162
  }
52819
53163
  seenRecordIds.add(id);
52820
- return Record.load(id);
53164
+ return fetchRecordOrNull(id);
52821
53165
  };
52822
53166
  }
52823
53167
  else if (isObjectType(recordFieldType) &&
52824
53168
  field.type.name.endsWith('Connection')) {
52825
53169
  // spanning field to a connection
52826
- field.resolve = (record, args, { seenRecordIds }) => {
52827
- seenRecordIds.add(record.id);
53170
+ field.resolve = async ({ recordRepresentation, ingestionTimestamp }, args, { seenRecordIds }) => {
53171
+ seenRecordIds.add(recordRepresentation.id);
53172
+ const { name: currentFieldName } = field;
52828
53173
  return {
52829
53174
  parentArgs: args,
52830
- parentRecord: record,
52831
- currentFieldName: field.name,
53175
+ parentRecord: recordRepresentation,
53176
+ currentFieldName,
53177
+ ingestionTimestamp,
52832
53178
  };
52833
53179
  };
52834
53180
  }
52835
53181
  else {
52836
- field.resolve = function recordFieldResolver(record) {
53182
+ field.resolve = function recordFieldResolver({ recordRepresentation: record, }) {
52837
53183
  return record.fields[field.name] || null;
52838
53184
  };
52839
53185
  }
@@ -52845,7 +53191,7 @@
52845
53191
  if (recordInterface !== undefined && baseRecord !== undefined) {
52846
53192
  // Applys 'resolveType' of GraphQLInterfaceType to 'Record' interface. Since all the heterogenous types are named as 'apiName', the type with same name as the loaded record 'apiName' property is the type wanted.
52847
53193
  // GraphQL executor would match InLineFragment' condition with type and keeps the deeper level field resolving going.
52848
- recordInterface.resolveType = function (value) {
53194
+ recordInterface.resolveType = function ({ recordRepresentation: value, }) {
52849
53195
  const targetType = polyTypes.find((type) => type.name === value.apiName);
52850
53196
  return targetType === undefined ? baseRecord : targetType;
52851
53197
  };
@@ -52853,7 +53199,7 @@
52853
53199
  return schema;
52854
53200
  }
52855
53201
  async function connectionEdgeResolver(obj, _args, context) {
52856
- const { parentArgs = {}, parentRecord, currentFieldName } = obj;
53202
+ const { parentArgs = {}, parentRecord, currentFieldName, ingestionTimestamp } = obj;
52857
53203
  const { query, objectInfos, draftFunctions } = context;
52858
53204
  let joins = [];
52859
53205
  let alias = currentFieldName;
@@ -52884,10 +53230,19 @@
52884
53230
  predicates,
52885
53231
  orderBy: orderByToPredicate(parentArgs.orderBy, alias, alias, context.objectInfos),
52886
53232
  limit: parentArgs.first,
53233
+ ingestionTimestamp,
52887
53234
  };
52888
53235
  const { sql, bindings } = buildQuery(queryConfig);
52889
53236
  const results = await query(sql, bindings);
52890
- return results.rows.map((row) => row[0]);
53237
+ //map each sql result with the ingestion timestamp to pass it down a level
53238
+ return results.rows
53239
+ .map((row) => row[0])
53240
+ .map((record) => {
53241
+ return {
53242
+ record,
53243
+ ingestionTimestamp,
53244
+ };
53245
+ });
52891
53246
  }
52892
53247
  /**
52893
53248
  * Converts a childRelationship into a predicate
@@ -52913,6 +53268,53 @@
52913
53268
  const interfaces = type.getInterfaces();
52914
53269
  return Boolean(interfaces.find((iface) => iface.name === 'Record'));
52915
53270
  }
53271
+ /**
53272
+ * Builds the top level record query key based on AST data
53273
+ * @param operation
53274
+ * @param variables
53275
+ * @param argumentNodes
53276
+ * @param currentFieldName
53277
+ * @returns
53278
+ */
53279
+ function buildKeyStringForRecordQuery(variables, argumentNodes, currentFieldName) {
53280
+ const filteredArgumentNodes = assign$3([], argumentNodes).filter((node) => node.name.value !== 'first' && node.name.value !== 'after');
53281
+ const argumentString = filteredArgumentNodes.length > 0
53282
+ ? `__${serializeFieldArguments$1(filteredArgumentNodes, variables)}`
53283
+ : '';
53284
+ return `UiApi::GraphQLRepresentation__uiapi__query__${currentFieldName}${argumentString}`;
53285
+ }
53286
+ /**
53287
+ * fetches a query level ingestion time stamp from the L2 cache
53288
+ * if no query has been seen then the timestamp is 0
53289
+ * @param apiName
53290
+ * @param info
53291
+ * @param args
53292
+ * @param query
53293
+ * @returns
53294
+ */
53295
+ async function fetchIngestionTimeStampFromDatabase(apiName, info, args, query) {
53296
+ const { variableValues } = info;
53297
+ // if we cannot find the query key in the database then default to 0 as we assume we have not seen the query
53298
+ // and all the data is not stale
53299
+ let ingestionTimestamp = 0;
53300
+ if (info.fieldNodes.length > 0 && info.fieldNodes[0].arguments !== undefined) {
53301
+ const key = buildKeyStringForRecordQuery(
53302
+ // join varables passed from query to the argument variables given from the AST
53303
+ { ...variableValues, ...args }, info.fieldNodes[0].arguments, apiName);
53304
+ const sql = `
53305
+ SELECT json_extract(metadata, '${JSON_EXTRACT_PATH_INGESTION_TIMESTAMP}')
53306
+ FROM lds_data
53307
+ WHERE key IS ?
53308
+ `;
53309
+ const results = await query(sql, [key]);
53310
+ const [timestamp] = results.rows.map((row) => row[0]);
53311
+ if (timestamp !== null && typeof timestamp === 'number') {
53312
+ //go back 10 ms to adjust for margin of error when top level query is stored and when raml objects are stored
53313
+ ingestionTimestamp = timestamp - 10;
53314
+ }
53315
+ }
53316
+ return ingestionTimestamp;
53317
+ }
52916
53318
 
52917
53319
  const baseTypeDefinitions = /* GraphQL */ `
52918
53320
  schema {
@@ -55135,6 +55537,14 @@
55135
55537
  function getRecordKeyForId(luvio, recordId) {
55136
55538
  return keyBuilder$1Q(luvio, { recordId });
55137
55539
  }
55540
+ /**
55541
+ * Drafts are stored with denormalized fields and normalized field links. This method
55542
+ * filters out the field links and returns a flattened record representation.
55543
+ *
55544
+ * Note that reference field links get re-applied during draft record ingestion
55545
+ * @param record draft record representation
55546
+ * @returns flattened record representation
55547
+ */
55138
55548
  function filterOutReferenceFieldsAndLinks(record) {
55139
55549
  const filteredFields = {};
55140
55550
  const fieldNames = keys$2$1(record.fields);
@@ -55153,32 +55563,6 @@
55153
55563
  delete filteredRecords.links;
55154
55564
  return filteredRecords;
55155
55565
  }
55156
- async function resolveReferencesOneLevelDeep(record, getRecordFromKey) {
55157
- const fieldNames = keys$2$1(record.fields);
55158
- const resolvedFields = {};
55159
- for (const fieldName of fieldNames) {
55160
- const field = record.fields[fieldName];
55161
- if (isFieldLink(field)) {
55162
- const denormalizedRecord = await getRecordFromKey(field.value.__ref);
55163
- if (denormalizedRecord !== undefined) {
55164
- resolvedFields[fieldName] = {
55165
- value: filterOutReferenceFieldsAndLinks(denormalizedRecord),
55166
- displayValue: null,
55167
- };
55168
- }
55169
- else {
55170
- resolvedFields[fieldName] = {
55171
- value: null,
55172
- displayValue: null,
55173
- };
55174
- }
55175
- }
55176
- else {
55177
- resolvedFields[fieldName] = field;
55178
- }
55179
- }
55180
- return { ...record, fields: resolvedFields };
55181
- }
55182
55566
 
55183
55567
  /**
55184
55568
  * Checks if a resource request is a GET method on the record endpoint
@@ -55475,11 +55859,15 @@
55475
55859
  */
55476
55860
  function replayDraftsOnRecord(record, draftMetadata) {
55477
55861
  let objectInfo;
55862
+ let luvio;
55478
55863
  if (record && draftMetadata) {
55479
55864
  objectInfo = draftMetadata.objectInfos.get(record.apiName);
55480
55865
  }
55866
+ if (draftMetadata) {
55867
+ luvio = draftMetadata.luvio;
55868
+ }
55481
55869
  // remove drafts before reapply
55482
- const baseRecord = record === undefined ? undefined : removeDrafts(record, objectInfo);
55870
+ const baseRecord = record === undefined ? undefined : removeDrafts(record, luvio, objectInfo);
55483
55871
  // record is a draft create
55484
55872
  if (baseRecord === undefined) {
55485
55873
  if (draftMetadata === undefined) {
@@ -55602,7 +55990,7 @@
55602
55990
  * @param record record with drafts applied
55603
55991
  * @returns
55604
55992
  */
55605
- function removeDrafts(record, objectInfo) {
55993
+ function removeDrafts(record, luvio, objectInfo) {
55606
55994
  const { drafts, fields } = record;
55607
55995
  if (drafts === undefined) {
55608
55996
  return record;
@@ -55618,6 +56006,12 @@
55618
56006
  const originalField = drafts.serverValues[fieldName];
55619
56007
  if (originalField !== undefined) {
55620
56008
  updatedFields[fieldName] = originalField;
56009
+ if (objectInfo && luvio) {
56010
+ const reference = getReferenceInfoForKey(fieldName, originalField, luvio, objectInfo);
56011
+ if (reference) {
56012
+ updatedFields[reference.referenceFieldName] = reference.field;
56013
+ }
56014
+ }
55621
56015
  // restore the record type id on the root of the record
55622
56016
  if (fieldName === DEFAULT_FIELD_RECORD_TYPE_ID) {
55623
56017
  const originalRecordTypeId = originalField.value;
@@ -55655,7 +56049,6 @@
55655
56049
  * @param fields List of draft record fields
55656
56050
  */
55657
56051
  function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fields, objectInfos, referencedRecords, formatDisplayValue) {
55658
- var _a;
55659
56052
  const fieldNames = keys$2$1(fields);
55660
56053
  const recordFields = {};
55661
56054
  const objectInfo = objectInfos.get(apiName);
@@ -55669,7 +56062,7 @@
55669
56062
  if (objectInfo !== undefined) {
55670
56063
  const fieldInfo = objectInfo.fields[fieldName];
55671
56064
  if (fieldInfo !== undefined) {
55672
- const { dataType, relationshipName, referenceToInfos } = fieldInfo;
56065
+ const { dataType } = fieldInfo;
55673
56066
  recordFields[fieldName].displayValue = formatDisplayValue(draftField, dataType);
55674
56067
  if (dataType === 'DateTime' &&
55675
56068
  draftField !== null &&
@@ -55681,46 +56074,6 @@
55681
56074
  throw Error('date field value not valid');
55682
56075
  }
55683
56076
  }
55684
- if (dataType === 'Reference' && relationshipName !== null && draftField !== null) {
55685
- if (typeof draftField !== 'string') {
55686
- throw Error('reference field value is not a string');
55687
- }
55688
- const key = getRecordKeyForId(luvio, draftField);
55689
- const referencedRecord = referencedRecords.get(key);
55690
- if (referencedRecord) {
55691
- recordFields[relationshipName] = {
55692
- displayValue: null,
55693
- value: createLink$2(key),
55694
- };
55695
- }
55696
- else {
55697
- recordFields[relationshipName] = {
55698
- displayValue: null,
55699
- value: null,
55700
- };
55701
- }
55702
- // for custom objects, we select the 'Name' field
55703
- // otherwise we check the object info for name fields.
55704
- //if there are multiple we select 'Name' if it exists, otherwise the first one
55705
- if (referencedRecord !== undefined && referenceToInfos.length > 0) {
55706
- let nameField;
55707
- const referenceToInfo = referenceToInfos[0];
55708
- const nameFields = referenceToInfo.nameFields;
55709
- if (nameFields.length !== 0) {
55710
- nameField = nameFields.find((x) => x === 'Name');
55711
- if (nameField === undefined) {
55712
- nameField = nameFields[0];
55713
- }
55714
- }
55715
- if (nameField !== undefined) {
55716
- const nameFieldRef = referencedRecord.fields[nameField];
55717
- if (nameFieldRef) {
55718
- recordFields[relationshipName].displayValue =
55719
- (_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
55720
- }
55721
- }
55722
- }
55723
- }
55724
56077
  }
55725
56078
  }
55726
56079
  }
@@ -55794,9 +56147,78 @@
55794
56147
  },
55795
56148
  };
55796
56149
  }
56150
+ function applyReferenceLinksToDraft(record, draftMetadata) {
56151
+ var _a;
56152
+ const { objectInfos, referencedRecords, luvio } = draftMetadata;
56153
+ const objectInfo = objectInfos.get(record.apiName);
56154
+ if (objectInfo === undefined) {
56155
+ return record;
56156
+ }
56157
+ let fieldNames = Object.keys(record.fields);
56158
+ const recordFields = { ...record.fields };
56159
+ for (const draftField of fieldNames) {
56160
+ const fieldInfo = objectInfo.fields[draftField];
56161
+ if (fieldInfo === undefined) {
56162
+ continue;
56163
+ }
56164
+ const { dataType, relationshipName, referenceToInfos } = fieldInfo;
56165
+ const draftFieldValue = record.fields[draftField].value;
56166
+ if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
56167
+ if (typeof draftFieldValue !== 'string') {
56168
+ throw Error('reference field value is not a string');
56169
+ }
56170
+ const key = getRecordKeyForId(luvio, draftFieldValue);
56171
+ const referencedRecord = referencedRecords.get(key);
56172
+ recordFields[relationshipName] = {
56173
+ displayValue: null,
56174
+ value: createLink$2(key),
56175
+ };
56176
+ // for custom objects, we select the 'Name' field
56177
+ // otherwise we check the object info for name fields.
56178
+ //if there are multiple we select 'Name' if it exists, otherwise the first one
56179
+ if (referencedRecord !== undefined && referenceToInfos.length > 0) {
56180
+ let nameField;
56181
+ const referenceToInfo = referenceToInfos[0];
56182
+ const nameFields = referenceToInfo.nameFields;
56183
+ if (nameFields.length !== 0) {
56184
+ nameField = nameFields.find((x) => x === 'Name');
56185
+ if (nameField === undefined) {
56186
+ nameField = nameFields[0];
56187
+ }
56188
+ }
56189
+ if (nameField !== undefined) {
56190
+ const nameFieldRef = referencedRecord.fields[nameField];
56191
+ if (nameFieldRef) {
56192
+ recordFields[relationshipName].displayValue =
56193
+ (_a = nameFieldRef.displayValue) !== null && _a !== void 0 ? _a : nameFieldRef.value;
56194
+ }
56195
+ }
56196
+ }
56197
+ }
56198
+ }
56199
+ return { ...record, fields: recordFields };
56200
+ }
55797
56201
  function createLink$2(key) {
55798
56202
  return { __ref: key };
55799
56203
  }
56204
+ function getReferenceInfoForKey(fieldName, field, luvio, objectInfo) {
56205
+ const { dataType, relationshipName } = objectInfo.fields[fieldName];
56206
+ const draftFieldValue = field.value;
56207
+ if (dataType === 'Reference' && relationshipName !== null && draftFieldValue !== null) {
56208
+ if (typeof draftFieldValue !== 'string') {
56209
+ throw Error('reference field value is not a string');
56210
+ }
56211
+ const key = getRecordKeyForId(luvio, draftFieldValue);
56212
+ return {
56213
+ referenceFieldName: relationshipName,
56214
+ field: {
56215
+ displayValue: null,
56216
+ value: createLink$2(key),
56217
+ },
56218
+ };
56219
+ }
56220
+ return undefined;
56221
+ }
55800
56222
 
55801
56223
  async function getAdapterData(adapter, config) {
55802
56224
  const snapshot = await adapter(config);
@@ -55941,8 +56363,7 @@
55941
56363
  *
55942
56364
  * @param action The draft action related to this record
55943
56365
  * @param _queue The draft queue
55944
- * @returns The record with the updated draft queue applied. This record is resolved with references one-level
55945
- * deep to ensure that reference links are properly established during ingestion to it
56366
+ * @returns The record with the updated draft queue applied. References are not included and must be applied at ingest.
55946
56367
  *
55947
56368
  * or
55948
56369
  *
@@ -55966,7 +56387,7 @@
55966
56387
  if (recordWithDrafts === undefined) {
55967
56388
  return undefined;
55968
56389
  }
55969
- return resolveReferencesOneLevelDeep(recordWithDrafts, this.durableStore.getDenormalizedRecord.bind(this.durableStore));
56390
+ return filterOutReferenceFieldsAndLinks(recordWithDrafts);
55970
56391
  }
55971
56392
  const record = await this.durableStore.getDenormalizedRecord(key);
55972
56393
  if (record === undefined) {
@@ -55977,7 +56398,7 @@
55977
56398
  if (recordWithDrafts === undefined) {
55978
56399
  return recordWithDrafts;
55979
56400
  }
55980
- return resolveReferencesOneLevelDeep(recordWithDrafts, this.durableStore.getDenormalizedRecord.bind(this.durableStore));
56401
+ return filterOutReferenceFieldsAndLinks(recordWithDrafts);
55981
56402
  }
55982
56403
  applyDraftsToIncomingData(key, data, draftMetadata, publishData) {
55983
56404
  if (isField(key)) {
@@ -56004,19 +56425,26 @@
56004
56425
  }
56005
56426
  }
56006
56427
  const recordWithDrafts = replayDraftsOnRecord(partialRecord, draftMetadata);
56428
+ const recordWithSpanningRefLinks = applyReferenceLinksToDraft(recordWithDrafts, draftMetadata);
56007
56429
  // publish the normalized fields
56008
56430
  const normalizedRecord = {
56009
- ...recordWithDrafts,
56431
+ ...recordWithSpanningRefLinks,
56010
56432
  ...data,
56011
56433
  fields: { ...data.fields },
56012
56434
  };
56013
- for (const fieldName of recordFieldNames) {
56435
+ for (const fieldName of keys$2$1(recordWithSpanningRefLinks.fields)) {
56014
56436
  const fieldKey = buildRecordFieldStoreKey(key, fieldName);
56015
56437
  if (this.collectedFields[fieldKey] !== undefined) {
56016
- const fieldData = recordWithDrafts.fields[fieldName];
56438
+ const fieldData = recordWithSpanningRefLinks.fields[fieldName];
56017
56439
  normalizedRecord.fields[fieldName] = { __ref: fieldKey };
56018
56440
  publishData(fieldKey, fieldData);
56019
56441
  }
56442
+ else if (recordWithSpanningRefLinks.fields[fieldName] &&
56443
+ recordWithSpanningRefLinks.fields[fieldName].value &&
56444
+ recordWithSpanningRefLinks.fields[fieldName].value.__ref !== undefined) {
56445
+ normalizedRecord.fields[fieldName] = { __ref: fieldKey };
56446
+ publishData(fieldKey, recordWithSpanningRefLinks.fields[fieldName]);
56447
+ }
56020
56448
  }
56021
56449
  // publish the normalized record
56022
56450
  publishData(key, normalizedRecord);
@@ -56214,6 +56642,15 @@
56214
56642
  links,
56215
56643
  };
56216
56644
  }
56645
+ function getDenormalizedKey(originalKey, recordId, luvio) {
56646
+ // this will likely need to be handled when moving to structured keys
56647
+ // note record view entities dont have an associated keybuilder. They get ingested as records to a different key format
56648
+ // see the override for how they are handled packages/lds-adapters-uiapi/src/raml-artifacts/types/RecordRepresentation/keyBuilderFromType.ts
56649
+ if (originalKey.startsWith(RECORD_VIEW_ENTITY_ID_PREFIX)) {
56650
+ return RECORD_VIEW_ENTITY_ID_PREFIX + recordId;
56651
+ }
56652
+ return keyBuilder$1Q(luvio, { recordId });
56653
+ }
56217
56654
  function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecords, getStoreMetadata) {
56218
56655
  const getEntries = function (entries, segment) {
56219
56656
  // this HOF only inspects records in the default segment
@@ -56228,14 +56665,24 @@
56228
56665
  const filteredEntryIds = [];
56229
56666
  // map of records to avoid requesting duplicate record keys when requesting both records and fields
56230
56667
  const recordEntries = {};
56668
+ const recordViewEntries = {};
56231
56669
  for (let i = 0, len = entriesLength; i < len; i++) {
56232
56670
  const id = entries[i];
56233
56671
  const recordId = extractRecordIdFromStoreKey(id);
56234
56672
  if (recordId !== undefined) {
56235
- if (recordEntries[recordId] === undefined) {
56236
- const key = keyBuilder$1Q(luvio, { recordId });
56237
- recordEntries[recordId] = true;
56238
- filteredEntryIds.push(key);
56673
+ if (id.startsWith(RECORD_VIEW_ENTITY_ID_PREFIX)) {
56674
+ if (recordViewEntries[recordId] === undefined) {
56675
+ const key = getDenormalizedKey(id, recordId, luvio);
56676
+ recordViewEntries[recordId] = true;
56677
+ filteredEntryIds.push(key);
56678
+ }
56679
+ }
56680
+ else {
56681
+ if (recordEntries[recordId] === undefined) {
56682
+ const key = getDenormalizedKey(id, recordId, luvio);
56683
+ recordEntries[recordId] = true;
56684
+ filteredEntryIds.push(key);
56685
+ }
56239
56686
  }
56240
56687
  }
56241
56688
  else {
@@ -56269,6 +56716,7 @@
56269
56716
  const putEntries = create$2$1(null);
56270
56717
  const keys$1 = keys$2$1(entries);
56271
56718
  const putRecords = {};
56719
+ const putRecordViews = {};
56272
56720
  const storeRecords = getStoreRecords !== undefined ? getStoreRecords() : {};
56273
56721
  const storeMetadata = getStoreMetadata !== undefined ? getStoreMetadata() : {};
56274
56722
  for (let i = 0, len = keys$1.length; i < len; i++) {
@@ -56277,10 +56725,18 @@
56277
56725
  const recordId = extractRecordIdFromStoreKey(key);
56278
56726
  // do not put normalized field values
56279
56727
  if (recordId !== undefined) {
56280
- const recordKey = keyBuilder$1Q(luvio, { recordId });
56281
- if (putRecords[recordId] === true) {
56282
- continue;
56728
+ const isRecordView = key.startsWith(RECORD_VIEW_ENTITY_ID_PREFIX);
56729
+ if (isRecordView) {
56730
+ if (putRecordViews[recordId] === true) {
56731
+ continue;
56732
+ }
56733
+ }
56734
+ else {
56735
+ if (putRecords[recordId] === true) {
56736
+ continue;
56737
+ }
56283
56738
  }
56739
+ const recordKey = getDenormalizedKey(key, recordId, luvio);
56284
56740
  const recordEntries = entries;
56285
56741
  const entry = recordEntries[recordKey];
56286
56742
  let record = entry && entry.data;
@@ -56292,7 +56748,12 @@
56292
56748
  continue;
56293
56749
  }
56294
56750
  }
56295
- putRecords[recordId] = true;
56751
+ if (isRecordView) {
56752
+ putRecordViews[recordId] = true;
56753
+ }
56754
+ else {
56755
+ putRecords[recordId] = true;
56756
+ }
56296
56757
  if (isStoreRecordError(record)) {
56297
56758
  putEntries[recordKey] = value;
56298
56759
  continue;
@@ -56370,6 +56831,19 @@
56370
56831
  });
56371
56832
  }
56372
56833
 
56834
+ /**
56835
+ * This function takes an unknown error and normalizes it to an Error object
56836
+ */
56837
+ function normalizeError$1(error) {
56838
+ if (typeof error === 'object' && error instanceof Error) {
56839
+ return error;
56840
+ }
56841
+ else if (typeof error === 'string') {
56842
+ return new Error(error);
56843
+ }
56844
+ return new Error(stringify$2(error));
56845
+ }
56846
+
56373
56847
  const PERFORM_QUICK_ACTION_ENDPOINT_REGEX = /^\/ui-api\/actions\/perform-quick-action\/.*$/;
56374
56848
  /**
56375
56849
  * Checks if a provided resource request is a POST operation on the record
@@ -56388,7 +56862,7 @@
56388
56862
  return env.dispatchResourceRequest(request, context, eventObservers);
56389
56863
  }
56390
56864
  const { data } = await handler.enqueue(request).catch((err) => {
56391
- throw createDraftSynthesisErrorResponse(err.message);
56865
+ throw createDraftSynthesisErrorResponse(normalizeError$1(err).message);
56392
56866
  });
56393
56867
  if (data === undefined) {
56394
56868
  return Promise.reject(createDraftSynthesisErrorResponse());
@@ -56725,7 +57199,7 @@
56725
57199
  return `UiApi::GraphQLRepresentation:${Date.now() + Math.random().toFixed(5).split('.')[1]}`;
56726
57200
  }
56727
57201
  // Recursively replace draft ids with canonical ids
56728
- const replaceDraftIdsInVariables = (variables, draftFunctions, unmappedDraftIDs) => {
57202
+ const replaceDraftIdsInVariables$1 = (variables, draftFunctions, unmappedDraftIDs) => {
56729
57203
  const replace = (object) => {
56730
57204
  if (typeof object === 'string') {
56731
57205
  if (!draftFunctions.isDraftId(object)) {
@@ -56782,7 +57256,7 @@
56782
57256
  unmappedDraftIDs,
56783
57257
  } = await injectSyntheticFields(copy, objectInfoService, draftFunctions, config.variables));
56784
57258
  if (config.variables) {
56785
- config.variables = replaceDraftIdsInVariables(config.variables, draftFunctions, unmappedDraftIDs);
57259
+ config.variables = replaceDraftIdsInVariables$1(config.variables, draftFunctions, unmappedDraftIDs);
56786
57260
  }
56787
57261
  }
56788
57262
  catch (throwable) {
@@ -56815,6 +57289,7 @@
56815
57289
  query: injectedAST,
56816
57290
  },
56817
57291
  luvio,
57292
+ gqlEval: true,
56818
57293
  }, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy));
56819
57294
  if (isErrorSnapshotThatShouldGetReturnedToCaller(nonEvaluatedSnapshot)) {
56820
57295
  return nonEvaluatedSnapshot;
@@ -57143,27 +57618,10 @@
57143
57618
  if (contentVersion === undefined) {
57144
57619
  return undefined;
57145
57620
  }
57146
- // this lambda can be shared across the calls to resolveReferencesOneLevelDeep
57147
- const luvio = this.getLuvio();
57148
- const contentDocumentKey = getRecordKeyForId(luvio, contentDocumentId);
57149
- const contentDocumentLinkKey = getRecordKeyForId(luvio, contentDocumentLinkId);
57150
- const contentVersionKey = getRecordKeyForId(luvio, contentVersionId);
57151
- const getRecordFromKey = async (key) => {
57152
- if (key === contentDocumentKey) {
57153
- return contentDocRecord;
57154
- }
57155
- if (key === contentDocumentLinkKey) {
57156
- return contentDocLink;
57157
- }
57158
- if (key === contentVersionKey) {
57159
- return contentVersion;
57160
- }
57161
- return this.durableStore.getDenormalizedRecord(key);
57162
- };
57163
57621
  // finally we resolve all references for each record
57164
- const contentDocResolved = await resolveReferencesOneLevelDeep(contentDocRecord, getRecordFromKey);
57165
- const contentDocLinkResolved = await resolveReferencesOneLevelDeep(contentDocLink, getRecordFromKey);
57166
- const contentVersionResolved = await resolveReferencesOneLevelDeep(contentVersion, getRecordFromKey);
57622
+ const contentDocResolved = await filterOutReferenceFieldsAndLinks(contentDocRecord);
57623
+ const contentDocLinkResolved = await filterOutReferenceFieldsAndLinks(contentDocLink);
57624
+ const contentVersionResolved = await filterOutReferenceFieldsAndLinks(contentVersion);
57167
57625
  return {
57168
57626
  contentDocument: contentDocResolved,
57169
57627
  contentDocumentLinks: [contentDocLinkResolved],
@@ -57942,6 +58400,10 @@
57942
58400
  }
57943
58401
 
57944
58402
  const MAX_STRING_LENGTH_PER_CHUNK = 10000;
58403
+ //Salesforce/Akamai cdn uri max size is 8898 bytes, short than normal. Per
58404
+ //https://help.salesforce.com/s/articleView?id=sf.community_builder_cdn_considerations.htm&type=5
58405
+ //Due to we don't know the domain ResourceRequest, here we give 8000
58406
+ const MAX_URL_LENGTH = 8000;
57945
58407
  const PARSE_ERROR = 'PARSE_AGGREGATE_UI_RESPONSE_ERROR';
57946
58408
  function isErrorResponse(response) {
57947
58409
  return response.httpStatusCode >= 400;
@@ -58020,8 +58482,8 @@
58020
58482
  }
58021
58483
  return `${resourceRequest.baseUri}${resourceRequest.basePath}?${join$1.call(queryString, '&')}`;
58022
58484
  }
58023
- function shouldUseAggregateUiForFields(fieldsArray, optionalFieldsArray) {
58024
- return fieldsArray.length + optionalFieldsArray.length >= MAX_STRING_LENGTH_PER_CHUNK;
58485
+ function shouldUseAggregateUiForFields(fieldsArray, optionalFieldsArray, maxLengthPerChunk) {
58486
+ return fieldsArray.length + optionalFieldsArray.length >= maxLengthPerChunk;
58025
58487
  }
58026
58488
  function isSpanningRecord(fieldValue) {
58027
58489
  return fieldValue !== null && typeof fieldValue === 'object';
@@ -58084,14 +58546,15 @@
58084
58546
  if (fieldsArray.length === 0 && optionalFieldsArray.length === 0) {
58085
58547
  return undefined;
58086
58548
  }
58549
+ const allowedMaxStringLengthPerChunk = getMaxLengthPerChunkAllowed(resourceRequest);
58087
58550
  const fieldsString = fieldsArray.join(',');
58088
58551
  const optionalFieldsString = optionalFieldsArray.join(',');
58089
- const shouldUseAggregate = shouldUseAggregateUiForFields(fieldsString, optionalFieldsString);
58552
+ const shouldUseAggregate = shouldUseAggregateUiForFields(fieldsString, optionalFieldsString, allowedMaxStringLengthPerChunk);
58090
58553
  if (!shouldUseAggregate) {
58091
58554
  return undefined;
58092
58555
  }
58093
- const fieldCollection = ScopedFieldsCollection.fromQueryParameterValue(fieldsString).split(MAX_STRING_LENGTH_PER_CHUNK);
58094
- const optionalFieldCollection = ScopedFieldsCollection.fromQueryParameterValue(optionalFieldsString).split(MAX_STRING_LENGTH_PER_CHUNK);
58556
+ const fieldCollection = ScopedFieldsCollection.fromQueryParameterValue(fieldsString).split(allowedMaxStringLengthPerChunk);
58557
+ const optionalFieldCollection = ScopedFieldsCollection.fromQueryParameterValue(optionalFieldsString).split(allowedMaxStringLengthPerChunk);
58095
58558
  return {
58096
58559
  fieldCollection,
58097
58560
  optionalFieldCollection,
@@ -58164,6 +58627,25 @@
58164
58627
  function arrayOrEmpty(array) {
58165
58628
  return array !== undefined && isArray$7(array) ? array : [];
58166
58629
  }
58630
+ /**
58631
+ * Calculate the max lengh per chunk.
58632
+ * If useShortUrlGate is open, allow max chunk size is MAX_URL_LENGTH - the url without fields and optional fields in url.
58633
+ * Otherwise MAX_STRING_LENGTH_PER_CHUNK
58634
+ * @param resourceRequest
58635
+ * @returns
58636
+ */
58637
+ function getMaxLengthPerChunkAllowed(request) {
58638
+ if (!ldsUseShortUrlGate.isOpen({ fallback: false })) {
58639
+ return MAX_STRING_LENGTH_PER_CHUNK;
58640
+ }
58641
+ // Too much work to get exact length of the final url, so use stringified json to get the rough length.
58642
+ const roughUrlLengthWithoutFieldsAndOptionFields = request.basePath.length +
58643
+ request.baseUri.length +
58644
+ (request.urlParams ? stringify$1$1(request.urlParams).length : 0) +
58645
+ stringify$1$1({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
58646
+ // MAX_URL_LENGTH - full lenght without fields, optionalFields
58647
+ return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
58648
+ }
58167
58649
 
58168
58650
  const RECORD_ENDPOINT_REGEX = /^\/ui-api\/records\/?(([a-zA-Z0-9]+))?$/;
58169
58651
  const referenceId$3 = 'LDS_Records_AggregateUi';
@@ -58368,7 +58850,7 @@
58368
58850
  }, networkAdapter);
58369
58851
  }
58370
58852
 
58371
- const { keys: keys$7, create: create$6, assign: assign$5, entries } = Object;
58853
+ const { keys: keys$8, create: create$6, assign: assign$6, entries } = Object;
58372
58854
  const { stringify: stringify$6, parse: parse$6 } = JSON;
58373
58855
  const { push, join, slice } = Array.prototype;
58374
58856
 
@@ -58384,15 +58866,15 @@
58384
58866
  enqueue(handlerId, data) {
58385
58867
  const callProxyMethod = __nimbus.plugins.LdsDraftQueue.callProxyMethod;
58386
58868
  if (callProxyMethod === undefined) {
58387
- return Promise.reject('callProxyMethod not defined on the nimbus plugin');
58869
+ return Promise.reject(new Error('callProxyMethod not defined on the nimbus plugin'));
58388
58870
  }
58389
58871
  const serializedAction = stringify$6([handlerId, data]);
58390
58872
  return new Promise((resolve, reject) => {
58391
58873
  callProxyMethod('enqueue', serializedAction, (serializedActionResponse) => {
58392
58874
  const response = parse$6(serializedActionResponse);
58393
58875
  resolve(response);
58394
- }, (serializedError) => {
58395
- reject(parse$6(serializedError));
58876
+ }, (errorMessage) => {
58877
+ reject(new Error(errorMessage));
58396
58878
  });
58397
58879
  });
58398
58880
  }
@@ -58402,18 +58884,18 @@
58402
58884
  return Promise.resolve;
58403
58885
  }
58404
58886
  processNextAction() {
58405
- return Promise.reject('Cannot call processNextAction from the NimbusDraftQueue');
58887
+ return Promise.reject(new Error('Cannot call processNextAction from the NimbusDraftQueue'));
58406
58888
  }
58407
58889
  getQueueActions() {
58408
58890
  const callProxyMethod = __nimbus.plugins.LdsDraftQueue.callProxyMethod;
58409
58891
  if (callProxyMethod === undefined) {
58410
- return Promise.reject('callProxyMethod not defined on the nimbus plugin');
58892
+ return Promise.reject(new Error('callProxyMethod not defined on the nimbus plugin'));
58411
58893
  }
58412
58894
  return new Promise((resolve, reject) => {
58413
58895
  callProxyMethod('getQueueActions', stringify$6([]), (serializedQueue) => {
58414
58896
  resolve(parse$6(serializedQueue));
58415
- }, (serializedError) => {
58416
- reject(parse$6(serializedError));
58897
+ }, (errorMessage) => {
58898
+ reject(new Error(errorMessage));
58417
58899
  });
58418
58900
  });
58419
58901
  }
@@ -58441,32 +58923,32 @@
58441
58923
  throw new Error('Cannot call getQueueState from the NimbusDraftQueue');
58442
58924
  }
58443
58925
  removeDraftAction(_actionId) {
58444
- return Promise.reject('Cannot call removeDraftAction from the NimbusDraftQueue');
58926
+ return Promise.reject(new Error('Cannot call removeDraftAction from the NimbusDraftQueue'));
58445
58927
  }
58446
58928
  startQueue() {
58447
- return Promise.reject('Cannot call startQueue from the NimbusDraftQueue');
58929
+ return Promise.reject(new Error('Cannot call startQueue from the NimbusDraftQueue'));
58448
58930
  }
58449
58931
  stopQueue() {
58450
- return Promise.reject('Cannot call stopQueue from the NimbusDraftQueue');
58932
+ return Promise.reject(new Error('Cannot call stopQueue from the NimbusDraftQueue'));
58451
58933
  }
58452
58934
  replaceAction(_actionId, _withActionId) {
58453
- return Promise.reject('Cannot call replaceAction from the NimbusDraftQueue');
58935
+ return Promise.reject(new Error('Cannot call replaceAction from the NimbusDraftQueue'));
58454
58936
  }
58455
58937
  mergeActions(_targetActionId, _sourceActionId) {
58456
- return Promise.reject('Cannot call mergeActions from the NimbusDraftQueue');
58938
+ return Promise.reject(new Error('Cannot call mergeActions from the NimbusDraftQueue'));
58457
58939
  }
58458
58940
  setMetadata(_actionId, _metadata) {
58459
- return Promise.reject('Cannot call setMetadata from the NimbusDraftQueue');
58941
+ return Promise.reject(new Error('Cannot call setMetadata from the NimbusDraftQueue'));
58460
58942
  }
58461
58943
  addHandler(_handler) {
58462
58944
  // no-op -- all registration occurs against concrete draft queue
58463
58945
  return Promise.resolve();
58464
58946
  }
58465
58947
  addCustomHandler(_id, _executor) {
58466
- return Promise.reject('Cannot call setMetadata from the NimbusDraftQueue');
58948
+ return Promise.reject(new Error('Cannot call setMetadata from the NimbusDraftQueue'));
58467
58949
  }
58468
58950
  removeHandler(_id) {
58469
- return Promise.reject('Cannot call setMetadata from the NimbusDraftQueue');
58951
+ return Promise.reject(new Error('Cannot call setMetadata from the NimbusDraftQueue'));
58470
58952
  }
58471
58953
  }
58472
58954
 
@@ -58489,7 +58971,7 @@
58489
58971
  * @param err Unknown object to sanitize
58490
58972
  * @returns an instance of error
58491
58973
  */
58492
- function normalizeError$1(err) {
58974
+ function normalizeError$2(err) {
58493
58975
  if (err instanceof Error) {
58494
58976
  return err;
58495
58977
  }
@@ -58501,13 +58983,13 @@
58501
58983
  const DRAFT_QUEUE_TOTAL_MERGE_ACTIONS_CALLS = 'draft-queue-total-mergeActions-calls';
58502
58984
  const DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR = 'draft-aware-create-content-document-and-version-error';
58503
58985
  function reportGraphqlQueryParseError(err) {
58504
- normalizeError$1(err);
58986
+ normalizeError$2(err);
58505
58987
  }
58506
58988
  function reportGraphqlSqlEvalPreconditionError(err) {
58507
- normalizeError$1(err);
58989
+ normalizeError$2(err);
58508
58990
  }
58509
58991
  function reportGraphqlCreateSnapshotError(err) {
58510
- normalizeError$1(err);
58992
+ normalizeError$2(err);
58511
58993
  }
58512
58994
  function reportGraphQlEvalDbReadDuration(duration) {
58513
58995
  }
@@ -58517,7 +58999,7 @@
58517
58999
  error = err.body;
58518
59000
  }
58519
59001
  else {
58520
- error = normalizeError$1(err);
59002
+ error = normalizeError$2(err);
58521
59003
  }
58522
59004
  const errorCode = DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR;
58523
59005
  const errorType = error.errorType;
@@ -58546,7 +59028,7 @@
58546
59028
  const { tags, metricName, logError } = config;
58547
59029
  return operation()
58548
59030
  .catch((err) => {
58549
- const error = normalizeError$1(err);
59031
+ const error = normalizeError$2(err);
58550
59032
  tags['errorMessage'] = error.message;
58551
59033
  throw err;
58552
59034
  })
@@ -58928,7 +59410,7 @@
58928
59410
  },
58929
59411
  conflictColumns: this.conflictColumnNames,
58930
59412
  columns: this.columnNames,
58931
- rows: keys$7(entries).reduce((rows, key) => {
59413
+ rows: keys$8(entries).reduce((rows, key) => {
58932
59414
  const entry = entries[key];
58933
59415
  const { data, metadata } = entry;
58934
59416
  const row = [key, stringify$6(data), metadata ? stringify$6(metadata) : null];
@@ -58989,7 +59471,7 @@
58989
59471
  },
58990
59472
  conflictColumns: this.conflictColumnNames,
58991
59473
  columns: this.columnNames,
58992
- rows: keys$7(entries).reduce((rows, key) => {
59474
+ rows: keys$8(entries).reduce((rows, key) => {
58993
59475
  const entry = entries[key];
58994
59476
  rows.push([key, stringify$6(entry.data)]);
58995
59477
  return rows;
@@ -59074,7 +59556,7 @@
59074
59556
  },
59075
59557
  conflictColumns: this.conflictColumnNames,
59076
59558
  columns: this.columnNames,
59077
- rows: keys$7(entries).reduce((rows, key) => {
59559
+ rows: keys$8(entries).reduce((rows, key) => {
59078
59560
  const entry = entries[key];
59079
59561
  const { data, metadata } = entry;
59080
59562
  const row = [key, stringify$6(data)];
@@ -59158,7 +59640,7 @@
59158
59640
  registerOnChangedListener(listener) {
59159
59641
  let unsubscribeId = undefined;
59160
59642
  this.plugin
59161
- .registerOnChangedListener((changes) => {
59643
+ .registerOnChangedListener(async (changes) => {
59162
59644
  const durableChanges = changes.map((c) => {
59163
59645
  return {
59164
59646
  type: c.type === 'upsert' ? 'setEntries' : 'evictEntries',
@@ -59167,7 +59649,7 @@
59167
59649
  segment: c.context.segment,
59168
59650
  };
59169
59651
  });
59170
- listener(durableChanges);
59652
+ await listener(durableChanges);
59171
59653
  })
59172
59654
  .then((unsub) => {
59173
59655
  unsubscribeId = unsub;
@@ -59273,8 +59755,17 @@
59273
59755
  }
59274
59756
  }
59275
59757
 
59276
- //TODO: [W-12734162] - rebuild non-evaluated snapshot when graph rebuild is triggered. The dependency work on luvio needs to be done.
59758
+ function isUnfulfilledSnapshot(cachedSnapshotResult) {
59759
+ if (cachedSnapshotResult === undefined) {
59760
+ return false;
59761
+ }
59762
+ if ('then' in cachedSnapshotResult) {
59763
+ return false;
59764
+ }
59765
+ return cachedSnapshotResult.state === 'Unfulfilled';
59766
+ }
59277
59767
  function makeEnvironmentGraphqlAware(environment) {
59768
+ //TODO: [W-12734162] - rebuild non-evaluated snapshot when graph rebuild is triggered. The dependency work on luvio needs to be done.
59278
59769
  const rebuildSnapshot = function (snapshot, onRebuild) {
59279
59770
  if (isStoreEvalSnapshot(snapshot)) {
59280
59771
  snapshot.rebuildWithStoreEval(snapshot).then((rebuilt) => {
@@ -59290,8 +59781,72 @@
59290
59781
  }
59291
59782
  return environment.rebuildSnapshot(snapshot, onRebuild);
59292
59783
  };
59784
+ const applyCachePolicy = function (luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot) {
59785
+ // Early exit for non-evaluating adapters
59786
+ let graphqlBuildSnapshotContext = buildSnapshotContext;
59787
+ if (graphqlBuildSnapshotContext.gqlEval !== true) {
59788
+ return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot);
59789
+ }
59790
+ var localBuildCachedSnapshot = buildCachedSnapshot;
59791
+ const hoistUnfulfilledToStale = (context, storeLookup, luvio) => {
59792
+ const upstream = buildCachedSnapshot(context, storeLookup, luvio);
59793
+ if (upstream === undefined)
59794
+ return upstream;
59795
+ if (isUnfulfilledSnapshot(upstream)) {
59796
+ return {
59797
+ ...upstream,
59798
+ data: upstream.data || {},
59799
+ state: 'Stale',
59800
+ };
59801
+ }
59802
+ else if ('then' in upstream) {
59803
+ return upstream.then((snapshot) => {
59804
+ if (snapshot === undefined)
59805
+ return snapshot;
59806
+ if (isUnfulfilledSnapshot(snapshot)) {
59807
+ return {
59808
+ ...snapshot,
59809
+ data: snapshot.data || {},
59810
+ state: 'Stale',
59811
+ };
59812
+ }
59813
+ return snapshot;
59814
+ });
59815
+ }
59816
+ return upstream;
59817
+ };
59818
+ const { cachePolicy } = adapterRequestContext;
59819
+ if (eagerEvalValidAt.isOpen({ fallback: false }) &&
59820
+ cachePolicy &&
59821
+ cachePolicy.type === 'valid-at' &&
59822
+ cachePolicy.timestamp === 0 &&
59823
+ cachePolicy.basePolicy &&
59824
+ cachePolicy.basePolicy.type === 'stale-while-revalidate') {
59825
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59826
+ }
59827
+ if (eagerEvalStaleWhileRevalidate.isOpen({ fallback: false }) &&
59828
+ cachePolicy &&
59829
+ cachePolicy.type === 'stale-while-revalidate' &&
59830
+ cachePolicy.staleDurationSeconds >= Number.MAX_SAFE_INTEGER) {
59831
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59832
+ }
59833
+ if (eagerEvalDefaultCachePolicy.isOpen({ fallback: false }) &&
59834
+ (cachePolicy === undefined || cachePolicy === null)) {
59835
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59836
+ }
59837
+ return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, localBuildCachedSnapshot, buildNetworkSnapshot);
59838
+ };
59293
59839
  return create$6(environment, {
59294
59840
  rebuildSnapshot: { value: rebuildSnapshot },
59841
+ applyCachePolicy: { value: applyCachePolicy },
59842
+ defaultCachePolicy: {
59843
+ get() {
59844
+ return environment.defaultCachePolicy;
59845
+ },
59846
+ set(value) {
59847
+ environment.defaultCachePolicy = value;
59848
+ },
59849
+ },
59295
59850
  });
59296
59851
  }
59297
59852
 
@@ -59940,8 +60495,17 @@
59940
60495
  lazyObjectInfoService = new ObjectInfoService(getObjectInfo, getObjectInfos, internalAdapterDurableStore);
59941
60496
  // set storeEval function for lds-adapters-graghql to use
59942
60497
  withRegistration('@salesforce/lds-adapters-graphql', (registration) => {
59943
- const { configuration: { setStoreEval }, } = registration;
59944
- setStoreEval(sqliteStoreEvalFactory(userId, lazyBaseDurableStore, lazyObjectInfoService));
60498
+ const { configuration: { setStoreEval, setDraftFunctions }, } = registration;
60499
+ const getCanonicalId = (id) => {
60500
+ var _a;
60501
+ return ((_a = extractRecordIdFromStoreKey(lazyLuvio.storeGetCanonicalKey(RECORD_ID_PREFIX + id))) !== null && _a !== void 0 ? _a : id);
60502
+ };
60503
+ const draftFuncs = {
60504
+ isDraftId: isGenerated,
60505
+ getCanonicalId,
60506
+ };
60507
+ setStoreEval(sqliteStoreEvalFactory(userId, lazyBaseDurableStore, lazyObjectInfoService, draftFuncs));
60508
+ setDraftFunctions(draftFuncs);
59945
60509
  });
59946
60510
  // creates a durable store that denormalizes scalar fields for records
59947
60511
  let getIngestRecords;
@@ -60030,7 +60594,7 @@
60030
60594
  id: '@salesforce/lds-network-adapter',
60031
60595
  instrument: instrument$1,
60032
60596
  });
60033
- // version: 1.130.10-0fac4c295
60597
+ // version: 1.131.0-dev11-b15472a13
60034
60598
 
60035
60599
  const { create: create$2, keys: keys$2 } = Object;
60036
60600
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -74338,7 +74902,7 @@
74338
74902
  configuration: { ...configurationForGraphQLAdapters },
74339
74903
  instrument,
74340
74904
  });
74341
- // version: 1.130.10-b649bb8d1
74905
+ // version: 1.131.0-dev11-734408c01
74342
74906
 
74343
74907
  // On core the unstable adapters are re-exported with different names,
74344
74908
 
@@ -75729,10 +76293,14 @@
75729
76293
  }
75730
76294
 
75731
76295
  let storeEval = undefined;
76296
+ let draftFunctions = undefined;
75732
76297
  const configuration = {
75733
76298
  setStoreEval: function (storeEvalArg) {
75734
76299
  storeEval = storeEvalArg;
75735
76300
  },
76301
+ setDraftFunctions: function (draftFuncs) {
76302
+ draftFunctions = draftFuncs;
76303
+ },
75736
76304
  };
75737
76305
 
75738
76306
  const assignedToMe = {
@@ -75818,6 +76386,78 @@
75818
76386
  function injectFieldsGQL(ast) {
75819
76387
  return injectScopeFields(ast);
75820
76388
  }
76389
+ function swapIdsOfDocumentNode(documentnode, draftFunctions) {
76390
+ const recordNodes = findRecordSelections(documentnode);
76391
+ recordNodes.forEach((recordConnection) => {
76392
+ swapIdsOfFieldNode(recordConnection, draftFunctions);
76393
+ });
76394
+ return documentnode;
76395
+ }
76396
+ function swapIdsOfFieldNode(selectionNode, draftFunctions) {
76397
+ if (isCustomFieldNode(selectionNode) &&
76398
+ selectionNode.type === 'Connection' &&
76399
+ selectionNode.arguments !== undefined &&
76400
+ selectionNode.arguments.some((argment) => argment.name === 'where')) {
76401
+ const swappedArguments = selectionNode.arguments.map((argument) => {
76402
+ if (argument.name === 'where') {
76403
+ return {
76404
+ ...argument,
76405
+ value: swapIdsOfValueNode(argument.value, draftFunctions.isDraftId, draftFunctions.getCanonicalId),
76406
+ };
76407
+ }
76408
+ else {
76409
+ return argument;
76410
+ }
76411
+ });
76412
+ selectionNode.arguments = swappedArguments;
76413
+ }
76414
+ if (selectionNode.luvioSelections !== undefined) {
76415
+ for (const childSelectionNode of selectionNode.luvioSelections) {
76416
+ if (isCustomFieldNode(childSelectionNode) ||
76417
+ isObjectFieldSelection(childSelectionNode)) {
76418
+ swapIdsOfFieldNode(childSelectionNode, draftFunctions);
76419
+ }
76420
+ }
76421
+ }
76422
+ }
76423
+ function swapIdsOfValueNode(valueNode, isDraftId, idMapper) {
76424
+ switch (valueNode.kind) {
76425
+ case Kind.OBJECT: {
76426
+ const swappedObjectValueNode = {};
76427
+ for (const key of keys(valueNode.fields)) {
76428
+ swappedObjectValueNode[key] = swapIdsOfValueNode(valueNode.fields[key], isDraftId, idMapper);
76429
+ }
76430
+ return {
76431
+ kind: 'ObjectValue',
76432
+ fields: swappedObjectValueNode,
76433
+ };
76434
+ }
76435
+ case Kind.LIST: {
76436
+ const listValueNodes = [];
76437
+ for (const child of valueNode.values) {
76438
+ listValueNodes.push(swapIdsOfValueNode(child, isDraftId, idMapper));
76439
+ }
76440
+ return {
76441
+ kind: 'ListValue',
76442
+ values: listValueNodes,
76443
+ };
76444
+ }
76445
+ case Kind.STRING: {
76446
+ if (!isDraftId(valueNode.value)) {
76447
+ return valueNode;
76448
+ }
76449
+ return {
76450
+ kind: 'StringValue',
76451
+ value: idMapper(valueNode.value),
76452
+ block: false,
76453
+ };
76454
+ }
76455
+ default:
76456
+ return {
76457
+ ...valueNode,
76458
+ };
76459
+ }
76460
+ }
75821
76461
  function injectScopeFields(ast) {
75822
76462
  const modifiedDocumentNode = {
75823
76463
  kind: 'Document',
@@ -76398,6 +77038,34 @@
76398
77038
  }
76399
77039
  return buildNetworkSnapshot(luvio, config, fragment, dispatchOptions);
76400
77040
  }
77041
+ const replaceDraftIdsInVariables = (variables, draftFunctions) => {
77042
+ const replace = (object) => {
77043
+ if (typeof object === 'string') {
77044
+ if (!draftFunctions.isDraftId(object)) {
77045
+ return object;
77046
+ }
77047
+ return draftFunctions.getCanonicalId(object);
77048
+ }
77049
+ else if (isArray(object)) {
77050
+ return object.map(replace);
77051
+ }
77052
+ else if (typeof object === 'object' && object !== null) {
77053
+ let source = object;
77054
+ return keys(source).reduce((acc, key) => {
77055
+ acc[key] = replace(source[key]);
77056
+ return acc;
77057
+ }, {});
77058
+ }
77059
+ else {
77060
+ return object;
77061
+ }
77062
+ };
77063
+ let newVariables = keys(variables).reduce((acc, key) => {
77064
+ acc[key] = replace(variables[key]);
77065
+ return acc;
77066
+ }, {});
77067
+ return newVariables;
77068
+ };
76401
77069
  const graphQLAdapterFactory = (luvio) => {
76402
77070
  const uiApiGraphQLAdapter = factory$1(luvio);
76403
77071
  function graphql(untrustedConfig, requestContext) {
@@ -76422,19 +77090,33 @@
76422
77090
  const validatedConfigWithInjection = fieldInjectionRequired
76423
77091
  ? graphqlConfigWithInjectedAST(validatedConfig)
76424
77092
  : validatedConfig;
76425
- const fragment = createFragment(luvio, validatedConfigWithInjection.query, variables);
77093
+ const sanitizedConfig = draftFunctions !== undefined
77094
+ ? sanitizeConfig(validatedConfigWithInjection, draftFunctions)
77095
+ : validatedConfigWithInjection;
77096
+ if (sanitizedConfig.variables && draftFunctions !== undefined) {
77097
+ const variablesWithSwappedDraftIds = replaceDraftIdsInVariables(sanitizedConfig.variables, draftFunctions);
77098
+ sanitizedConfig.variables = variablesWithSwappedDraftIds;
77099
+ validatedConfig.variables = variablesWithSwappedDraftIds;
77100
+ }
77101
+ const fragment = createFragment(luvio, sanitizedConfig.query, sanitizedConfig.variables);
76426
77102
  const context = {
76427
- config: validatedConfigWithInjection,
77103
+ config: sanitizedConfig,
76428
77104
  fragment,
76429
77105
  luvio,
76430
77106
  };
77107
+ // NOTE: For evaluating environments, set a context property to let the
77108
+ // environment detect that eval will happen and to check varous gates
77109
+ // for eval behavior customizations.
77110
+ if (storeEval !== undefined) {
77111
+ context.gqlEval = true;
77112
+ }
76431
77113
  const snapshotOrPromiseFromCachePolicy = luvio.applyCachePolicy(requestContext || {}, context, buildCachedSnapshot, buildNetworkSnapshotCachePolicy);
76432
77114
  if (storeEval !== undefined) {
76433
77115
  const observers = requestContext && requestContext.eventObservers
76434
77116
  ? requestContext.eventObservers
76435
77117
  : [];
76436
- // uses the original ast to do the eval to avoid fields not needed by users
76437
- return storeEval(validatedConfig, snapshotOrPromiseFromCachePolicy, observers);
77118
+ // uses the original ast to do the eval to avoid fields not needed by users. The draftID swapping happens when filters transform to predicates.
77119
+ return storeEval(validatedConfig, snapshotOrPromiseFromCachePolicy, observers, keyBuilder);
76438
77120
  }
76439
77121
  return snapshotOrPromiseFromCachePolicy;
76440
77122
  }
@@ -76450,6 +77132,15 @@
76450
77132
  query: modifiedAST,
76451
77133
  };
76452
77134
  }
77135
+ function sanitizeConfig(graphqlConfig, draftFunctions) {
77136
+ const { query } = graphqlConfig;
77137
+ const astCopy = parse(stringify(query));
77138
+ const modifiedAST = swapIdsOfDocumentNode(astCopy, draftFunctions);
77139
+ return {
77140
+ ...graphqlConfig,
77141
+ query: modifiedAST,
77142
+ };
77143
+ }
76453
77144
  // make sure to register the configuration whenever this module loads
76454
77145
  register({ id: '@salesforce/lds-adapters-graphql', configuration });
76455
77146
 
@@ -76467,7 +77158,7 @@
76467
77158
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
76468
77159
  graphQLImperative = ldsAdapter;
76469
77160
  });
76470
- // version: 1.130.10-b649bb8d1
77161
+ // version: 1.131.0-dev11-734408c01
76471
77162
 
76472
77163
  var gqlApi = /*#__PURE__*/Object.freeze({
76473
77164
  __proto__: null,
@@ -76619,7 +77310,7 @@
76619
77310
  cachePolicy: buildCachePolicy(cachePolicy),
76620
77311
  priority,
76621
77312
  };
76622
- if (observabilityContext !== undefined) {
77313
+ if (observabilityContext !== undefined && observabilityContext !== null) {
76623
77314
  requestContext.requestCorrelator = {
76624
77315
  observabilityContext,
76625
77316
  };
@@ -77077,24 +77768,21 @@
77077
77768
  * to the instance of the lds-drafts' DraftQueue implementation
77078
77769
  */
77079
77770
  const nimbusDraftQueue = {
77080
- callProxyMethod(methodName, serializedArgsArray, resultCallback, errorCallback) {
77771
+ callProxyMethod(methodName, serializedArgsArray, resultCallback,
77772
+ // NOTE: the other side of the proxy is expecting an error message string
77773
+ // (not a JSON serialized Error object)
77774
+ errorCallback) {
77081
77775
  const method = draftQueue[methodName];
77082
77776
  if (method === undefined) {
77083
- return errorCallback(stringify$1({
77084
- message: 'Method does not exist on the draft queue',
77085
- }));
77777
+ return errorCallback('Method does not exist on the draft queue');
77086
77778
  }
77087
77779
  if (allowList.includes(methodName) === false) {
77088
- return errorCallback(stringify$1({
77089
- message: `Method ${methodName} is not available for proxy invocation`,
77090
- }));
77780
+ return errorCallback(`Method ${methodName} is not available for proxy invocation`);
77091
77781
  }
77092
77782
  const parsedArgs = parse$1(serializedArgsArray);
77093
77783
  // TODO [W-9933226]: we should validate the argument list based on which method is being called
77094
77784
  if (isArray$1(parsedArgs) === false) {
77095
- return errorCallback(stringify$1({
77096
- message: 'expected array argument list',
77097
- }));
77785
+ return errorCallback('expected array argument list');
77098
77786
  }
77099
77787
  let methodResult = undefined;
77100
77788
  try {
@@ -77106,7 +77794,7 @@
77106
77794
  }
77107
77795
  }
77108
77796
  catch (err) {
77109
- return errorCallback(stringify$1(err));
77797
+ return errorCallback(normalizeError(err).message);
77110
77798
  }
77111
77799
  if (methodResult.then === undefined) {
77112
77800
  return resultCallback(stringify$1(methodResult));
@@ -77116,7 +77804,7 @@
77116
77804
  resultCallback(stringify$1(result));
77117
77805
  })
77118
77806
  .catch((err) => {
77119
- errorCallback(stringify$1(err));
77807
+ errorCallback(normalizeError(err).message);
77120
77808
  });
77121
77809
  },
77122
77810
  };
@@ -77176,4 +77864,4 @@
77176
77864
  Object.defineProperty(exports, '__esModule', { value: true });
77177
77865
 
77178
77866
  }));
77179
- // version: 1.130.10-0fac4c295
77867
+ // version: 1.131.0-dev11-b15472a13