@salesforce/lds-worker-api 1.141.1 → 1.142.1

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.
@@ -758,4 +758,4 @@ if (process.env.NODE_ENV !== 'production') {
758
758
  }
759
759
 
760
760
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
761
- // version: 1.141.1-07065b50d
761
+ // version: 1.142.1-d514db71e
@@ -2988,18 +2988,22 @@ class Reader {
2988
2988
  }
2989
2989
 
2990
2990
  /**
2991
- * Maps a CachePolicy to a CachePolicyImplementation
2991
+ * Maps a CachePolicy to a CachePolicyImplementation. We don't necessarily trust
2992
+ * "cachePolicy" because that could come from userland code. But we do trust
2993
+ * "defaultCachePolicy" because that comes from our own library code and should
2994
+ * be a valid type, so this function will fall back to "defaultCachePolicy" if
2995
+ * "cachePolicy" is invalid.
2992
2996
  *
2993
2997
  * @param cachePolicy cache policy
2994
2998
  * @param defaultCachePolicy default cache policy
2995
- * @param luvio the luvio instance
2996
- * @returns cache policy implementation corresponnding to cachePolicy
2999
+ * @returns cache policy implementation corresponding to cachePolicy
2997
3000
  */
2998
3001
  function resolveCachePolicy(cachePolicy, defaultCachePolicy) {
2999
3002
  if (cachePolicy === undefined) {
3000
- return defaultCachePolicy;
3003
+ return resolveCachePolicy(defaultCachePolicy, defaultCachePolicy);
3001
3004
  }
3002
- switch (cachePolicy.type) {
3005
+ const { type } = cachePolicy;
3006
+ switch (type) {
3003
3007
  case 'cache-and-network':
3004
3008
  return buildCacheAndNetworkImplementation(cachePolicy.staleDurationSeconds);
3005
3009
  case 'cache-then-network':
@@ -3015,7 +3019,7 @@ function resolveCachePolicy(cachePolicy, defaultCachePolicy) {
3015
3019
  return buildValidAtImplementation(basePolicy, cachePolicy.timestamp);
3016
3020
  }
3017
3021
  default: {
3018
- return defaultCachePolicy;
3022
+ return resolveCachePolicy(defaultCachePolicy, defaultCachePolicy);
3019
3023
  }
3020
3024
  }
3021
3025
  }
@@ -3042,10 +3046,7 @@ class Environment {
3042
3046
  constructor(store, networkAdapter) {
3043
3047
  this.networkCount = 0;
3044
3048
  this.storeQueryEvaluator = undefined;
3045
- this.defaultCachePolicy = {
3046
- type: 'cache-then-network',
3047
- implementation: cacheThenNetworkImplementation,
3048
- };
3049
+ this.defaultCachePolicy = { type: 'cache-then-network' };
3049
3050
  this.store = store;
3050
3051
  this.networkAdapter = networkAdapter;
3051
3052
  this.adapterContextMap = create$a(null);
@@ -3055,6 +3056,9 @@ class Environment {
3055
3056
  this.createSnapshot = this.createSnapshot.bind(this);
3056
3057
  this.rebuildSnapshot = this.rebuildSnapshot.bind(this);
3057
3058
  }
3059
+ setDefaultCachePolicy(cachePolicy) {
3060
+ this.defaultCachePolicy = cachePolicy;
3061
+ }
3058
3062
  /**
3059
3063
  * Returns a resolved promise of a FetchResponse for ok http status codes.
3060
3064
  * Returns a rejected promise of an ErrorResponse of type "fetchResponse" for non-ok http status codes.
@@ -3319,17 +3323,14 @@ class Environment {
3319
3323
  applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot) {
3320
3324
  const { defaultCachePolicy } = this;
3321
3325
  const { cachePolicy, eventObservers } = adapterRequestContext;
3322
- let cachePolicyType = defaultCachePolicy.type;
3323
- if (cachePolicy !== undefined) {
3324
- cachePolicyType = cachePolicy.type;
3325
- }
3326
- let cachePolicyImpl = resolveCachePolicy(cachePolicy, defaultCachePolicy.implementation);
3326
+ let cachePolicyImpl = resolveCachePolicy(cachePolicy, defaultCachePolicy);
3327
3327
  const resolvePendingSnapshot = (snapshot) => this.resolvePendingSnapshot(snapshot);
3328
3328
  const storeLookup = (sel, refresh, ttlStrategy) => this.storeLookup(sel, this.createSnapshot, refresh, ttlStrategy);
3329
3329
  let wrappedBuildCacheSnapshot = buildCachedSnapshot;
3330
3330
  let wrappedBuildNetworkSnapshot = buildNetworkSnapshot;
3331
3331
  // if eventObservers are provided for the adapter, wrap calls in versions that emit events
3332
3332
  if (eventObservers !== undefined) {
3333
+ const cachePolicyType = cachePolicy === undefined ? defaultCachePolicy.type : cachePolicy.type;
3333
3334
  cachePolicyImpl = cachePolicyImplWithEvents(cachePolicyImpl, cachePolicyType, eventObservers);
3334
3335
  wrappedBuildCacheSnapshot = buildCachedSnapshotWithEvents(buildCachedSnapshot, eventObservers);
3335
3336
  wrappedBuildNetworkSnapshot = buildNetworkSnapshotWithEvents(buildNetworkSnapshot, eventObservers);
@@ -3672,7 +3673,7 @@ class Luvio {
3672
3673
  return this.environment.buildStructuredKey(namespace, representationName, idValues);
3673
3674
  }
3674
3675
  }
3675
- // engine version: 0.140.3-86f83ec8
3676
+ // engine version: 0.142.3-97d0da6c
3676
3677
 
3677
3678
  /**
3678
3679
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3799,7 +3800,7 @@ function withDefaultLuvio(callback) {
3799
3800
  }
3800
3801
  callbacks.push(callback);
3801
3802
  }
3802
- // version: 1.141.1-07065b50d
3803
+ // version: 1.142.1-d514db71e
3803
3804
 
3804
3805
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3805
3806
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15223,7 +15224,7 @@ function parseAndVisit(source) {
15223
15224
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15224
15225
  return luvioDocumentNode;
15225
15226
  }
15226
- // version: 1.141.1-07065b50d
15227
+ // version: 1.142.1-d514db71e
15227
15228
 
15228
15229
  function unwrap(data) {
15229
15230
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16136,7 +16137,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
16136
16137
  const { apiFamily, name } = metadata;
16137
16138
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16138
16139
  }
16139
- // version: 1.141.1-07065b50d
16140
+ // version: 1.142.1-d514db71e
16140
16141
 
16141
16142
  /**
16142
16143
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16219,7 +16220,7 @@ var FragmentReadResultState;
16219
16220
  ({
16220
16221
  state: FragmentReadResultState.Missing,
16221
16222
  });
16222
- // engine version: 0.140.3-86f83ec8
16223
+ // engine version: 0.142.3-97d0da6c
16223
16224
 
16224
16225
  const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
16225
16226
 
@@ -16616,11 +16617,11 @@ function assignMetadataLink$1(entry, metadataKey) {
16616
16617
  entry['__metadata'] = createLink$3(metadataKey);
16617
16618
  }
16618
16619
 
16619
- const VERSION$1d = "275ae22194003d1e53f548b81219c5cb";
16620
- const select$1H = function ListColumnRepresentationSelect() {
16620
+ const VERSION$1g = "275ae22194003d1e53f548b81219c5cb";
16621
+ const select$1K = function ListColumnRepresentationSelect() {
16621
16622
  return {
16622
16623
  kind: 'Fragment',
16623
- version: VERSION$1d,
16624
+ version: VERSION$1g,
16624
16625
  private: [],
16625
16626
  selections: [
16626
16627
  {
@@ -16643,11 +16644,11 @@ const select$1H = function ListColumnRepresentationSelect() {
16643
16644
  };
16644
16645
  };
16645
16646
 
16646
- const VERSION$1c = "623aa9ce3a11031e35faf5671a41746e";
16647
- const select$1G = function ListFilterByInfoRepresentationSelect() {
16647
+ const VERSION$1f = "623aa9ce3a11031e35faf5671a41746e";
16648
+ const select$1J = function ListFilterByInfoRepresentationSelect() {
16648
16649
  return {
16649
16650
  kind: 'Fragment',
16650
- version: VERSION$1c,
16651
+ version: VERSION$1f,
16651
16652
  private: [],
16652
16653
  selections: [
16653
16654
  {
@@ -16671,11 +16672,11 @@ const select$1G = function ListFilterByInfoRepresentationSelect() {
16671
16672
  };
16672
16673
  };
16673
16674
 
16674
- const VERSION$1b$1 = "76042ff4af603b2ac0ec69fa0bd12046";
16675
- const select$1F = function ListReferenceRepresentationSelect() {
16675
+ const VERSION$1e = "76042ff4af603b2ac0ec69fa0bd12046";
16676
+ const select$1I = function ListReferenceRepresentationSelect() {
16676
16677
  return {
16677
16678
  kind: 'Fragment',
16678
- version: VERSION$1b$1,
16679
+ version: VERSION$1e,
16679
16680
  private: [],
16680
16681
  selections: [
16681
16682
  {
@@ -16721,11 +16722,11 @@ function equals$X(existing, incoming) {
16721
16722
  return true;
16722
16723
  }
16723
16724
 
16724
- const VERSION$1a$1 = "32def9b631252c12b91a8209c1f49f5a";
16725
- const select$1E = function ListOrderByInfoRepresentationSelect() {
16725
+ const VERSION$1d = "32def9b631252c12b91a8209c1f49f5a";
16726
+ const select$1H = function ListOrderByInfoRepresentationSelect() {
16726
16727
  return {
16727
16728
  kind: 'Fragment',
16728
- version: VERSION$1a$1,
16729
+ version: VERSION$1d,
16729
16730
  private: [],
16730
16731
  selections: [
16731
16732
  {
@@ -16744,6 +16745,79 @@ const select$1E = function ListOrderByInfoRepresentationSelect() {
16744
16745
  };
16745
16746
  };
16746
16747
 
16748
+ const VERSION$1c = "2634258f216db34315c06d759a35676d";
16749
+ const select$1G = function ListScopeEntityRepresentationSelect() {
16750
+ return {
16751
+ kind: 'Fragment',
16752
+ version: VERSION$1c,
16753
+ private: [],
16754
+ selections: [
16755
+ {
16756
+ name: 'id',
16757
+ kind: 'Scalar'
16758
+ },
16759
+ {
16760
+ name: 'label',
16761
+ kind: 'Scalar'
16762
+ }
16763
+ ]
16764
+ };
16765
+ };
16766
+
16767
+ const VERSION$1b$1 = "3b85c5a08d50ce328481b9f8ab56127b";
16768
+ const select$1F = function ListScopeRelatedEntityRepresentationSelect() {
16769
+ return {
16770
+ kind: 'Fragment',
16771
+ version: VERSION$1b$1,
16772
+ private: [],
16773
+ selections: [
16774
+ {
16775
+ name: 'id',
16776
+ kind: 'Scalar'
16777
+ },
16778
+ {
16779
+ name: 'label',
16780
+ kind: 'Scalar'
16781
+ },
16782
+ {
16783
+ name: 'type',
16784
+ kind: 'Scalar'
16785
+ }
16786
+ ]
16787
+ };
16788
+ };
16789
+
16790
+ const VERSION$1a$1 = "fce88f94b1244707458c795247592939";
16791
+ const select$1E = function ListScopeRepresentationSelect() {
16792
+ const { selections: ListScopeEntityRepresentation__selections, opaque: ListScopeEntityRepresentation__opaque, } = select$1G();
16793
+ const { selections: ListScopeRelatedEntityRepresentation__selections, opaque: ListScopeRelatedEntityRepresentation__opaque, } = select$1F();
16794
+ return {
16795
+ kind: 'Fragment',
16796
+ version: VERSION$1a$1,
16797
+ private: [],
16798
+ selections: [
16799
+ {
16800
+ name: 'apiName',
16801
+ kind: 'Scalar'
16802
+ },
16803
+ {
16804
+ name: 'entity',
16805
+ kind: 'Object',
16806
+ selections: ListScopeEntityRepresentation__selections
16807
+ },
16808
+ {
16809
+ name: 'label',
16810
+ kind: 'Scalar'
16811
+ },
16812
+ {
16813
+ name: 'relatedEntity',
16814
+ kind: 'Object',
16815
+ selections: ListScopeRelatedEntityRepresentation__selections
16816
+ }
16817
+ ]
16818
+ };
16819
+ };
16820
+
16747
16821
  const VERSION$19$1 = "6506134f4d72fdfa349fe60ef1af2413";
16748
16822
  const select$1D = function ListUserPreferenceRepresentationSelect() {
16749
16823
  return {
@@ -16766,7 +16840,7 @@ const select$1D = function ListUserPreferenceRepresentationSelect() {
16766
16840
  };
16767
16841
 
16768
16842
  const TTL$x = 900000;
16769
- const VERSION$18$1 = "8f469cbf563d2ed6b2d3a7b2ee422e1f";
16843
+ const VERSION$18$1 = "8b55d621d80c84ec2e331abc4e12fc56";
16770
16844
  const RepresentationType$Q = 'ListInfoRepresentation';
16771
16845
  function keyBuilder$1R(luvio, config) {
16772
16846
  return keyPrefix$1 + '::' + RepresentationType$Q + ':' + (config.listViewApiName === null ? '' : config.listViewApiName) + ':' + config.objectApiName + ':' + config.type;
@@ -16783,10 +16857,11 @@ function normalize$J(input, existing, path, luvio, store, timestamp) {
16783
16857
  return input;
16784
16858
  }
16785
16859
  const select$1C = function ListInfoRepresentationSelect() {
16786
- const { selections: ListColumnRepresentation__selections, opaque: ListColumnRepresentation__opaque, } = select$1H();
16787
- const { selections: ListFilterByInfoRepresentation__selections, opaque: ListFilterByInfoRepresentation__opaque, } = select$1G();
16788
- const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1F();
16789
- const { selections: ListOrderByInfoRepresentation__selections, opaque: ListOrderByInfoRepresentation__opaque, } = select$1E();
16860
+ const { selections: ListColumnRepresentation__selections, opaque: ListColumnRepresentation__opaque, } = select$1K();
16861
+ const { selections: ListFilterByInfoRepresentation__selections, opaque: ListFilterByInfoRepresentation__opaque, } = select$1J();
16862
+ const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1I();
16863
+ const { selections: ListOrderByInfoRepresentation__selections, opaque: ListOrderByInfoRepresentation__opaque, } = select$1H();
16864
+ const { selections: ListScopeRepresentation__selections, opaque: ListScopeRepresentation__opaque, } = select$1E();
16790
16865
  const { selections: ListUserPreferenceRepresentation__selections, opaque: ListUserPreferenceRepresentation__opaque, } = select$1D();
16791
16866
  return {
16792
16867
  kind: 'Fragment',
@@ -16844,6 +16919,13 @@ const select$1C = function ListInfoRepresentationSelect() {
16844
16919
  plural: true,
16845
16920
  selections: ListOrderByInfoRepresentation__selections
16846
16921
  },
16922
+ {
16923
+ name: 'scope',
16924
+ kind: 'Object',
16925
+ nullable: true,
16926
+ selections: ListScopeRepresentation__selections,
16927
+ required: false
16928
+ },
16847
16929
  {
16848
16930
  name: 'updateable',
16849
16931
  kind: 'Scalar'
@@ -20890,7 +20972,7 @@ function normalize$F(input, existing, path, luvio, store, timestamp) {
20890
20972
  return input;
20891
20973
  }
20892
20974
  const select$1x = function ListRecordCollectionRepresentationSelect(paginationParams) {
20893
- const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1F();
20975
+ const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1I();
20894
20976
  return {
20895
20977
  kind: 'Fragment',
20896
20978
  reader: true,
@@ -21004,7 +21086,7 @@ const dynamicSelect$7 = function dynamicListRecordCollectionRepresentationSelect
21004
21086
  kind: 'Link',
21005
21087
  fragment: select$1y()
21006
21088
  } : params.records;
21007
- const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1F();
21089
+ const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1I();
21008
21090
  return {
21009
21091
  kind: 'Fragment',
21010
21092
  reader: true,
@@ -42990,7 +43072,7 @@ const factory$2 = (luvio) => {
42990
43072
  };
42991
43073
  };
42992
43074
 
42993
- const VERSION$1e = "5f97eb4f2c3f805ef9d98ba7f0530b3e";
43075
+ const VERSION$1h = "5f97eb4f2c3f805ef9d98ba7f0530b3e";
42994
43076
  const RepresentationType$R = 'ContentDocumentCompositeRepresentation';
42995
43077
  function keyBuilder$1S(luvio, config) {
42996
43078
  return keyPrefix$1 + '::' + RepresentationType$R + ':' + config.contentDocumentId;
@@ -43084,7 +43166,7 @@ const ingest$14 = function ContentDocumentCompositeRepresentationIngest(input, p
43084
43166
  const storeMetadataParams = {
43085
43167
  ttl: ttlToUse,
43086
43168
  namespace: "UiApi",
43087
- version: VERSION$1e,
43169
+ version: VERSION$1h,
43088
43170
  representationName: RepresentationType$R,
43089
43171
  };
43090
43172
  luvio.publishStoreMetadata(key, storeMetadataParams);
@@ -43159,11 +43241,11 @@ function createResourceRequest$1$1(config) {
43159
43241
  priority: 'normal',
43160
43242
  };
43161
43243
  }
43162
- const select$1I = function ContentDocumentCompositeRepresentationSelect(body) {
43244
+ const select$1L = function ContentDocumentCompositeRepresentationSelect(body) {
43163
43245
  return {
43164
43246
  kind: 'Fragment',
43165
43247
  private: [],
43166
- version: VERSION$1e,
43248
+ version: VERSION$1h,
43167
43249
  selections: [
43168
43250
  {
43169
43251
  name: 'contentDocument',
@@ -43202,7 +43284,7 @@ const select$1I = function ContentDocumentCompositeRepresentationSelect(body) {
43202
43284
  function ingestSuccess$1$1(luvio, resourceParams, response) {
43203
43285
  const { body } = response;
43204
43286
  const key = keyBuilderFromType$A(luvio, body);
43205
- const node = select$1I(body);
43287
+ const node = select$1L(body);
43206
43288
  luvio.storeIngest(key, ingest$14, body);
43207
43289
  const snapshot = luvio.storeLookup({
43208
43290
  recordId: key,
@@ -43269,7 +43351,7 @@ function createResourceRequest$11(config) {
43269
43351
  function ingestSuccess$I(luvio, resourceParams, response) {
43270
43352
  const { body } = response;
43271
43353
  const key = keyBuilderFromType$A(luvio, body);
43272
- const node = select$1I(body);
43354
+ const node = select$1L(body);
43273
43355
  luvio.storeIngest(key, ingest$14, body);
43274
43356
  const snapshot = luvio.storeLookup({
43275
43357
  recordId: key,
@@ -43925,7 +44007,7 @@ withDefaultLuvio((luvio) => {
43925
44007
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
43926
44008
  });
43927
44009
  });
43928
- // version: 1.141.1-8f6d93cad
44010
+ // version: 1.142.1-1511d83f4
43929
44011
 
43930
44012
  var caseSensitiveUserId = '005B0000000GR4OIAW';
43931
44013
 
@@ -44723,7 +44805,7 @@ class DurableTTLStore {
44723
44805
  }
44724
44806
  }
44725
44807
 
44726
- function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler) {
44808
+ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler, additionalDurableStoreOperations = []) {
44727
44809
  const durableRecords = create$5(null);
44728
44810
  const evictedRecords = create$5(null);
44729
44811
  const { records, metadata: storeMetadata, visitedIds, refreshedIds, } = store.fallbackStringKeyInMemoryStore;
@@ -44750,7 +44832,7 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
44750
44832
  };
44751
44833
  }
44752
44834
  }
44753
- const durableStoreOperations = [];
44835
+ const durableStoreOperations = additionalDurableStoreOperations;
44754
44836
  // publishes
44755
44837
  const recordKeys = keys$6(durableRecords);
44756
44838
  if (recordKeys.length > 0) {
@@ -44853,7 +44935,8 @@ function isUnfulfilledSnapshot(cachedSnapshotResult) {
44853
44935
  }
44854
44936
  /**
44855
44937
  * Configures the environment to persist data into a durable store and attempt to resolve
44856
- * data from the persistent store before hitting the network.
44938
+ * data from the persistent store before hitting the network. Sets the default
44939
+ * cache policy to stale-while-revalidate with infinite staleDuration.
44857
44940
  *
44858
44941
  * @param environment The base environment
44859
44942
  * @param durableStore A DurableStore implementation
@@ -44993,12 +45076,12 @@ function makeDurable(environment, { durableStore, instrumentation }) {
44993
45076
  // call the base storeBroadcast
44994
45077
  return publishChangesToDurableStore();
44995
45078
  };
44996
- const publishChangesToDurableStore = function () {
45079
+ const publishChangesToDurableStore = function (additionalDurableStoreOperations) {
44997
45080
  validateNotDisposed();
44998
45081
  if (ingestStagingStore === null) {
44999
45082
  return Promise.resolve();
45000
45083
  }
45001
- const promise = flushInMemoryStoreValuesToDurableStore(ingestStagingStore, durableStore, durableStoreErrorHandler);
45084
+ const promise = flushInMemoryStoreValuesToDurableStore(ingestStagingStore, durableStore, durableStoreErrorHandler, additionalDurableStoreOperations);
45002
45085
  ingestStagingStore = null;
45003
45086
  return promise;
45004
45087
  };
@@ -45278,10 +45361,11 @@ function makeDurable(environment, { durableStore, instrumentation }) {
45278
45361
  return entries;
45279
45362
  });
45280
45363
  };
45281
- environment.defaultCachePolicy = {
45364
+ // set the default cache policy of the base environment
45365
+ environment.setDefaultCachePolicy({
45282
45366
  type: 'stale-while-revalidate',
45283
- implementation: buildStaleWhileRevalidateImplementation(Number.MAX_SAFE_INTEGER),
45284
- };
45367
+ staleDurationSeconds: Number.MAX_SAFE_INTEGER,
45368
+ });
45285
45369
  return create$5(environment, {
45286
45370
  publishStoreMetadata: { value: publishStoreMetadata },
45287
45371
  storeIngest: { value: storeIngest },
@@ -59706,7 +59790,7 @@ register({
59706
59790
  id: '@salesforce/lds-network-adapter',
59707
59791
  instrument: instrument$1,
59708
59792
  });
59709
- // version: 1.141.1-07065b50d
59793
+ // version: 1.142.1-d514db71e
59710
59794
 
59711
59795
  const { create: create$2, keys: keys$2 } = Object;
59712
59796
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -59820,6 +59904,20 @@ function buildQueryTypeStringKey(args) {
59820
59904
  return `${keyPrefix}::${schemaName}::${queryTypeName}[${serializeOperationNode$1(operationNode, variables, fragmentMap)}]`;
59821
59905
  }
59822
59906
 
59907
+ /**
59908
+ * @description Spec compliant way to retrieve the correct Operation from the Document that Luvio should operate on. https://spec.graphql.org/June2018/#sec-Named-Operation-Definitions
59909
+ * @param document
59910
+ * @param operationName
59911
+ * @returns The Operation in the GraphQL document we should use for the current call.
59912
+ */
59913
+ function getOperationFromDocument(document, operationName) {
59914
+ const operations = document.definitions.filter((def) => def.kind === 'OperationDefinition');
59915
+ if (operationName) {
59916
+ return operations.find((def) => def.name !== undefined && def.name.value === operationName);
59917
+ }
59918
+ return operations[0]; // If a named operation is not provided, we return the first one
59919
+ }
59920
+
59823
59921
  /**
59824
59922
  * Copyright (c) 2022, Salesforce, Inc.,
59825
59923
  * All rights reserved.
@@ -79231,43 +79329,38 @@ function getInContextFragmentType(fragment, fragmentMap) {
79231
79329
  const TTL = 900000;
79232
79330
  const VERSION$6 = "b440235e7e724631f92002fe50e3e096";
79233
79331
  const RepresentationType = 'GraphQLRepresentation';
79234
- function select$8(luvio, query, variables) {
79235
- const definitions = query.definitions === undefined ? [] : query.definitions;
79332
+ function select$8(luvio, document, variables, operationName) {
79333
+ const operationToExecute = getOperationFromDocument(document, operationName);
79236
79334
  return {
79237
79335
  kind: 'Fragment',
79238
79336
  synthetic: true,
79239
79337
  reader: true,
79240
79338
  read: (builder) => {
79241
79339
  builder.enterPath('data');
79242
- let sink = {};
79243
- const fragments = createFragmentMap(query);
79244
- for (let i = 0, len = definitions.length; i < len; i += 1) {
79245
- const def = definitions[i];
79246
- if (def.kind === 'OperationDefinition') {
79247
- const queryTypeRecordId = keyBuilder$4(luvio, def, variables, fragments);
79248
- const snapshot = builder.read({
79249
- recordId: queryTypeRecordId,
79250
- node: {
79251
- kind: 'Fragment',
79252
- private: [],
79253
- opaque: true,
79254
- version: VERSION$7
79255
- },
79256
- variables: {}
79257
- });
79258
- if (snapshot.data === undefined) {
79259
- builder.markMissingLink(queryTypeRecordId);
79260
- break;
79261
- }
79262
- const data = select$9(def, variables, fragments)(snapshot.data, builder, queryTypeRecordId);
79263
- sink = {
79264
- ...sink,
79265
- ...data,
79266
- };
79267
- }
79268
- }
79269
79340
  const gqlData = {};
79270
- builder.assignNonScalar(gqlData, 'data', sink);
79341
+ if (operationToExecute === undefined) {
79342
+ builder.markMissing(); // Never give a cache hit for an undefined operation
79343
+ return gqlData;
79344
+ }
79345
+ const fragments = createFragmentMap(document);
79346
+ const queryTypeRecordId = keyBuilder$4(luvio, operationToExecute, variables, fragments);
79347
+ const snapshot = builder.read({
79348
+ recordId: queryTypeRecordId,
79349
+ node: {
79350
+ kind: 'Fragment',
79351
+ private: [],
79352
+ opaque: true,
79353
+ version: VERSION$7
79354
+ },
79355
+ variables: {}
79356
+ });
79357
+ if (snapshot.data === undefined) {
79358
+ builder.markMissingLink(queryTypeRecordId);
79359
+ }
79360
+ else {
79361
+ const data = select$9(operationToExecute, variables, fragments)(snapshot.data, builder, queryTypeRecordId);
79362
+ builder.assignNonScalar(gqlData, 'data', data);
79363
+ }
79271
79364
  builder.exitPath();
79272
79365
  return gqlData;
79273
79366
  }
@@ -79287,10 +79380,10 @@ function ingestOperationNode(luvio, input, node, state) {
79287
79380
  });
79288
79381
  }
79289
79382
  }
79290
- const ingest = function GraphQLRepresentationIngest(query, variables) {
79383
+ const ingest = function GraphQLRepresentationIngest(document, variables, operationName) {
79291
79384
  return (input, path, luvio, store, timestamp) => {
79292
79385
  if (input.data) {
79293
- const fragments = createFragmentMap(query);
79386
+ const fragments = createFragmentMap(document);
79294
79387
  const state = {
79295
79388
  data: input.data,
79296
79389
  luvio,
@@ -79300,44 +79393,42 @@ const ingest = function GraphQLRepresentationIngest(query, variables) {
79300
79393
  variables,
79301
79394
  fragments,
79302
79395
  };
79303
- query.definitions.forEach((node) => {
79304
- if (node.kind === 'OperationDefinition') {
79305
- ingestOperationNode(luvio, input, node, state);
79306
- }
79307
- });
79396
+ const operationToExecute = getOperationFromDocument(document, operationName);
79397
+ if (operationToExecute !== undefined) {
79398
+ ingestOperationNode(luvio, input, operationToExecute, state);
79399
+ }
79308
79400
  }
79309
79401
  return {
79310
79402
  __ref: undefined
79311
79403
  };
79312
79404
  };
79313
79405
  };
79314
- function getTypeCacheKeys(luvio, query, variables, data) {
79406
+ function getTypeCacheKeys(luvio, document, variables, data, operationName) {
79315
79407
  const sink = new StoreKeyMap();
79316
79408
  if (data.data) {
79317
- const fragments = createFragmentMap(query);
79318
- query.definitions.forEach((node) => {
79319
- if (node.kind === 'OperationDefinition') {
79320
- const state = {
79321
- luvio,
79322
- variables,
79323
- fragments,
79324
- data: data.data,
79325
- path: {
79326
- parent: null,
79327
- propertyName: null,
79328
- fullPath: '' // TODO: W-13079691 - Need to take another pass at what we want to do for structured keys
79329
- }
79330
- };
79331
- sink.merge(getTypeCacheKeys$1(node, state));
79332
- }
79333
- });
79409
+ const fragments = createFragmentMap(document);
79410
+ const operationToExecute = getOperationFromDocument(document, operationName);
79411
+ if (operationToExecute !== undefined) {
79412
+ const state = {
79413
+ luvio,
79414
+ variables,
79415
+ fragments,
79416
+ data: data.data,
79417
+ path: {
79418
+ parent: null,
79419
+ propertyName: null,
79420
+ fullPath: '' // TODO: W-13079691 - Need to take another pass at what we want to do for structured keys
79421
+ }
79422
+ };
79423
+ sink.merge(getTypeCacheKeys$1(operationToExecute, state));
79424
+ }
79334
79425
  }
79335
79426
  return sink;
79336
79427
  }
79337
79428
 
79338
79429
  function select$7(luvio, config) {
79339
- const { query, variables } = config;
79340
- return select$8(luvio, query, variables);
79430
+ const { query, variables, operationName } = config;
79431
+ return select$8(luvio, query, variables, operationName);
79341
79432
  }
79342
79433
  function keyBuilder$3(luvio, params) {
79343
79434
  return keyPrefix + '::' + 'GraphQLRepresentation';
@@ -79345,13 +79436,14 @@ function keyBuilder$3(luvio, params) {
79345
79436
  function getResponseCacheKeys$1(luvio, resourceParams, response) {
79346
79437
  const query = resourceParams.body.query;
79347
79438
  const variables = resourceParams.body.variables || {};
79348
- return getTypeCacheKeys(luvio, query, variables, response);
79439
+ const operationName = resourceParams.body.operationName;
79440
+ return getTypeCacheKeys(luvio, query, variables, response, operationName);
79349
79441
  }
79350
79442
  function ingestSuccess$1(luvio, config, resourceParams, response, snapshotRefresh) {
79351
79443
  const { body } = response;
79352
79444
  const key = keyBuilder$3();
79353
- const { query, variables } = resourceParams.body;
79354
- luvio.storeIngest(key, ingest(query, variables), body);
79445
+ const { query, variables, operationName } = resourceParams.body;
79446
+ luvio.storeIngest(key, ingest(query, variables, operationName), body);
79355
79447
  // revert the optimized pagination variables back to its original so that subsequent store lookup will include all records, not just the ones loaded by an optimized query
79356
79448
  // see optimizePagination for initial update to optimize the query
79357
79449
  revertPaginationOptimization(variables);
@@ -80537,7 +80629,7 @@ register({
80537
80629
  configuration: { ...configurationForGraphQLAdapters },
80538
80630
  instrument,
80539
80631
  });
80540
- // version: 1.141.1-8f6d93cad
80632
+ // version: 1.142.1-1511d83f4
80541
80633
 
80542
80634
  // On core the unstable adapters are re-exported with different names,
80543
80635
 
@@ -82769,7 +82861,7 @@ withDefaultLuvio((luvio) => {
82769
82861
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
82770
82862
  graphQLImperative = ldsAdapter;
82771
82863
  });
82772
- // version: 1.141.1-8f6d93cad
82864
+ // version: 1.142.1-1511d83f4
82773
82865
 
82774
82866
  var gqlApi = /*#__PURE__*/Object.freeze({
82775
82867
  __proto__: null,
@@ -83458,4 +83550,4 @@ const { luvio } = getRuntime();
83458
83550
  setDefaultLuvio({ luvio });
83459
83551
 
83460
83552
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
83461
- // version: 1.141.1-07065b50d
83553
+ // version: 1.142.1-d514db71e
@@ -2996,18 +2996,22 @@
2996
2996
  }
2997
2997
 
2998
2998
  /**
2999
- * Maps a CachePolicy to a CachePolicyImplementation
2999
+ * Maps a CachePolicy to a CachePolicyImplementation. We don't necessarily trust
3000
+ * "cachePolicy" because that could come from userland code. But we do trust
3001
+ * "defaultCachePolicy" because that comes from our own library code and should
3002
+ * be a valid type, so this function will fall back to "defaultCachePolicy" if
3003
+ * "cachePolicy" is invalid.
3000
3004
  *
3001
3005
  * @param cachePolicy cache policy
3002
3006
  * @param defaultCachePolicy default cache policy
3003
- * @param luvio the luvio instance
3004
- * @returns cache policy implementation corresponnding to cachePolicy
3007
+ * @returns cache policy implementation corresponding to cachePolicy
3005
3008
  */
3006
3009
  function resolveCachePolicy(cachePolicy, defaultCachePolicy) {
3007
3010
  if (cachePolicy === undefined) {
3008
- return defaultCachePolicy;
3011
+ return resolveCachePolicy(defaultCachePolicy, defaultCachePolicy);
3009
3012
  }
3010
- switch (cachePolicy.type) {
3013
+ const { type } = cachePolicy;
3014
+ switch (type) {
3011
3015
  case 'cache-and-network':
3012
3016
  return buildCacheAndNetworkImplementation(cachePolicy.staleDurationSeconds);
3013
3017
  case 'cache-then-network':
@@ -3023,7 +3027,7 @@
3023
3027
  return buildValidAtImplementation(basePolicy, cachePolicy.timestamp);
3024
3028
  }
3025
3029
  default: {
3026
- return defaultCachePolicy;
3030
+ return resolveCachePolicy(defaultCachePolicy, defaultCachePolicy);
3027
3031
  }
3028
3032
  }
3029
3033
  }
@@ -3050,10 +3054,7 @@
3050
3054
  constructor(store, networkAdapter) {
3051
3055
  this.networkCount = 0;
3052
3056
  this.storeQueryEvaluator = undefined;
3053
- this.defaultCachePolicy = {
3054
- type: 'cache-then-network',
3055
- implementation: cacheThenNetworkImplementation,
3056
- };
3057
+ this.defaultCachePolicy = { type: 'cache-then-network' };
3057
3058
  this.store = store;
3058
3059
  this.networkAdapter = networkAdapter;
3059
3060
  this.adapterContextMap = create$a(null);
@@ -3063,6 +3064,9 @@
3063
3064
  this.createSnapshot = this.createSnapshot.bind(this);
3064
3065
  this.rebuildSnapshot = this.rebuildSnapshot.bind(this);
3065
3066
  }
3067
+ setDefaultCachePolicy(cachePolicy) {
3068
+ this.defaultCachePolicy = cachePolicy;
3069
+ }
3066
3070
  /**
3067
3071
  * Returns a resolved promise of a FetchResponse for ok http status codes.
3068
3072
  * Returns a rejected promise of an ErrorResponse of type "fetchResponse" for non-ok http status codes.
@@ -3327,17 +3331,14 @@
3327
3331
  applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot) {
3328
3332
  const { defaultCachePolicy } = this;
3329
3333
  const { cachePolicy, eventObservers } = adapterRequestContext;
3330
- let cachePolicyType = defaultCachePolicy.type;
3331
- if (cachePolicy !== undefined) {
3332
- cachePolicyType = cachePolicy.type;
3333
- }
3334
- let cachePolicyImpl = resolveCachePolicy(cachePolicy, defaultCachePolicy.implementation);
3334
+ let cachePolicyImpl = resolveCachePolicy(cachePolicy, defaultCachePolicy);
3335
3335
  const resolvePendingSnapshot = (snapshot) => this.resolvePendingSnapshot(snapshot);
3336
3336
  const storeLookup = (sel, refresh, ttlStrategy) => this.storeLookup(sel, this.createSnapshot, refresh, ttlStrategy);
3337
3337
  let wrappedBuildCacheSnapshot = buildCachedSnapshot;
3338
3338
  let wrappedBuildNetworkSnapshot = buildNetworkSnapshot;
3339
3339
  // if eventObservers are provided for the adapter, wrap calls in versions that emit events
3340
3340
  if (eventObservers !== undefined) {
3341
+ const cachePolicyType = cachePolicy === undefined ? defaultCachePolicy.type : cachePolicy.type;
3341
3342
  cachePolicyImpl = cachePolicyImplWithEvents(cachePolicyImpl, cachePolicyType, eventObservers);
3342
3343
  wrappedBuildCacheSnapshot = buildCachedSnapshotWithEvents(buildCachedSnapshot, eventObservers);
3343
3344
  wrappedBuildNetworkSnapshot = buildNetworkSnapshotWithEvents(buildNetworkSnapshot, eventObservers);
@@ -3680,7 +3681,7 @@
3680
3681
  return this.environment.buildStructuredKey(namespace, representationName, idValues);
3681
3682
  }
3682
3683
  }
3683
- // engine version: 0.140.3-86f83ec8
3684
+ // engine version: 0.142.3-97d0da6c
3684
3685
 
3685
3686
  /**
3686
3687
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3807,7 +3808,7 @@
3807
3808
  }
3808
3809
  callbacks.push(callback);
3809
3810
  }
3810
- // version: 1.141.1-07065b50d
3811
+ // version: 1.142.1-d514db71e
3811
3812
 
3812
3813
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3813
3814
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15231,7 +15232,7 @@
15231
15232
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15232
15233
  return luvioDocumentNode;
15233
15234
  }
15234
- // version: 1.141.1-07065b50d
15235
+ // version: 1.142.1-d514db71e
15235
15236
 
15236
15237
  function unwrap(data) {
15237
15238
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16144,7 +16145,7 @@
16144
16145
  const { apiFamily, name } = metadata;
16145
16146
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16146
16147
  }
16147
- // version: 1.141.1-07065b50d
16148
+ // version: 1.142.1-d514db71e
16148
16149
 
16149
16150
  /**
16150
16151
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16227,7 +16228,7 @@
16227
16228
  ({
16228
16229
  state: FragmentReadResultState.Missing,
16229
16230
  });
16230
- // engine version: 0.140.3-86f83ec8
16231
+ // engine version: 0.142.3-97d0da6c
16231
16232
 
16232
16233
  const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
16233
16234
 
@@ -16624,11 +16625,11 @@
16624
16625
  entry['__metadata'] = createLink$3(metadataKey);
16625
16626
  }
16626
16627
 
16627
- const VERSION$1d = "275ae22194003d1e53f548b81219c5cb";
16628
- const select$1H = function ListColumnRepresentationSelect() {
16628
+ const VERSION$1g = "275ae22194003d1e53f548b81219c5cb";
16629
+ const select$1K = function ListColumnRepresentationSelect() {
16629
16630
  return {
16630
16631
  kind: 'Fragment',
16631
- version: VERSION$1d,
16632
+ version: VERSION$1g,
16632
16633
  private: [],
16633
16634
  selections: [
16634
16635
  {
@@ -16651,11 +16652,11 @@
16651
16652
  };
16652
16653
  };
16653
16654
 
16654
- const VERSION$1c = "623aa9ce3a11031e35faf5671a41746e";
16655
- const select$1G = function ListFilterByInfoRepresentationSelect() {
16655
+ const VERSION$1f = "623aa9ce3a11031e35faf5671a41746e";
16656
+ const select$1J = function ListFilterByInfoRepresentationSelect() {
16656
16657
  return {
16657
16658
  kind: 'Fragment',
16658
- version: VERSION$1c,
16659
+ version: VERSION$1f,
16659
16660
  private: [],
16660
16661
  selections: [
16661
16662
  {
@@ -16679,11 +16680,11 @@
16679
16680
  };
16680
16681
  };
16681
16682
 
16682
- const VERSION$1b$1 = "76042ff4af603b2ac0ec69fa0bd12046";
16683
- const select$1F = function ListReferenceRepresentationSelect() {
16683
+ const VERSION$1e = "76042ff4af603b2ac0ec69fa0bd12046";
16684
+ const select$1I = function ListReferenceRepresentationSelect() {
16684
16685
  return {
16685
16686
  kind: 'Fragment',
16686
- version: VERSION$1b$1,
16687
+ version: VERSION$1e,
16687
16688
  private: [],
16688
16689
  selections: [
16689
16690
  {
@@ -16729,11 +16730,11 @@
16729
16730
  return true;
16730
16731
  }
16731
16732
 
16732
- const VERSION$1a$1 = "32def9b631252c12b91a8209c1f49f5a";
16733
- const select$1E = function ListOrderByInfoRepresentationSelect() {
16733
+ const VERSION$1d = "32def9b631252c12b91a8209c1f49f5a";
16734
+ const select$1H = function ListOrderByInfoRepresentationSelect() {
16734
16735
  return {
16735
16736
  kind: 'Fragment',
16736
- version: VERSION$1a$1,
16737
+ version: VERSION$1d,
16737
16738
  private: [],
16738
16739
  selections: [
16739
16740
  {
@@ -16752,6 +16753,79 @@
16752
16753
  };
16753
16754
  };
16754
16755
 
16756
+ const VERSION$1c = "2634258f216db34315c06d759a35676d";
16757
+ const select$1G = function ListScopeEntityRepresentationSelect() {
16758
+ return {
16759
+ kind: 'Fragment',
16760
+ version: VERSION$1c,
16761
+ private: [],
16762
+ selections: [
16763
+ {
16764
+ name: 'id',
16765
+ kind: 'Scalar'
16766
+ },
16767
+ {
16768
+ name: 'label',
16769
+ kind: 'Scalar'
16770
+ }
16771
+ ]
16772
+ };
16773
+ };
16774
+
16775
+ const VERSION$1b$1 = "3b85c5a08d50ce328481b9f8ab56127b";
16776
+ const select$1F = function ListScopeRelatedEntityRepresentationSelect() {
16777
+ return {
16778
+ kind: 'Fragment',
16779
+ version: VERSION$1b$1,
16780
+ private: [],
16781
+ selections: [
16782
+ {
16783
+ name: 'id',
16784
+ kind: 'Scalar'
16785
+ },
16786
+ {
16787
+ name: 'label',
16788
+ kind: 'Scalar'
16789
+ },
16790
+ {
16791
+ name: 'type',
16792
+ kind: 'Scalar'
16793
+ }
16794
+ ]
16795
+ };
16796
+ };
16797
+
16798
+ const VERSION$1a$1 = "fce88f94b1244707458c795247592939";
16799
+ const select$1E = function ListScopeRepresentationSelect() {
16800
+ const { selections: ListScopeEntityRepresentation__selections, opaque: ListScopeEntityRepresentation__opaque, } = select$1G();
16801
+ const { selections: ListScopeRelatedEntityRepresentation__selections, opaque: ListScopeRelatedEntityRepresentation__opaque, } = select$1F();
16802
+ return {
16803
+ kind: 'Fragment',
16804
+ version: VERSION$1a$1,
16805
+ private: [],
16806
+ selections: [
16807
+ {
16808
+ name: 'apiName',
16809
+ kind: 'Scalar'
16810
+ },
16811
+ {
16812
+ name: 'entity',
16813
+ kind: 'Object',
16814
+ selections: ListScopeEntityRepresentation__selections
16815
+ },
16816
+ {
16817
+ name: 'label',
16818
+ kind: 'Scalar'
16819
+ },
16820
+ {
16821
+ name: 'relatedEntity',
16822
+ kind: 'Object',
16823
+ selections: ListScopeRelatedEntityRepresentation__selections
16824
+ }
16825
+ ]
16826
+ };
16827
+ };
16828
+
16755
16829
  const VERSION$19$1 = "6506134f4d72fdfa349fe60ef1af2413";
16756
16830
  const select$1D = function ListUserPreferenceRepresentationSelect() {
16757
16831
  return {
@@ -16774,7 +16848,7 @@
16774
16848
  };
16775
16849
 
16776
16850
  const TTL$x = 900000;
16777
- const VERSION$18$1 = "8f469cbf563d2ed6b2d3a7b2ee422e1f";
16851
+ const VERSION$18$1 = "8b55d621d80c84ec2e331abc4e12fc56";
16778
16852
  const RepresentationType$Q = 'ListInfoRepresentation';
16779
16853
  function keyBuilder$1R(luvio, config) {
16780
16854
  return keyPrefix$1 + '::' + RepresentationType$Q + ':' + (config.listViewApiName === null ? '' : config.listViewApiName) + ':' + config.objectApiName + ':' + config.type;
@@ -16791,10 +16865,11 @@
16791
16865
  return input;
16792
16866
  }
16793
16867
  const select$1C = function ListInfoRepresentationSelect() {
16794
- const { selections: ListColumnRepresentation__selections, opaque: ListColumnRepresentation__opaque, } = select$1H();
16795
- const { selections: ListFilterByInfoRepresentation__selections, opaque: ListFilterByInfoRepresentation__opaque, } = select$1G();
16796
- const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1F();
16797
- const { selections: ListOrderByInfoRepresentation__selections, opaque: ListOrderByInfoRepresentation__opaque, } = select$1E();
16868
+ const { selections: ListColumnRepresentation__selections, opaque: ListColumnRepresentation__opaque, } = select$1K();
16869
+ const { selections: ListFilterByInfoRepresentation__selections, opaque: ListFilterByInfoRepresentation__opaque, } = select$1J();
16870
+ const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1I();
16871
+ const { selections: ListOrderByInfoRepresentation__selections, opaque: ListOrderByInfoRepresentation__opaque, } = select$1H();
16872
+ const { selections: ListScopeRepresentation__selections, opaque: ListScopeRepresentation__opaque, } = select$1E();
16798
16873
  const { selections: ListUserPreferenceRepresentation__selections, opaque: ListUserPreferenceRepresentation__opaque, } = select$1D();
16799
16874
  return {
16800
16875
  kind: 'Fragment',
@@ -16852,6 +16927,13 @@
16852
16927
  plural: true,
16853
16928
  selections: ListOrderByInfoRepresentation__selections
16854
16929
  },
16930
+ {
16931
+ name: 'scope',
16932
+ kind: 'Object',
16933
+ nullable: true,
16934
+ selections: ListScopeRepresentation__selections,
16935
+ required: false
16936
+ },
16855
16937
  {
16856
16938
  name: 'updateable',
16857
16939
  kind: 'Scalar'
@@ -20898,7 +20980,7 @@
20898
20980
  return input;
20899
20981
  }
20900
20982
  const select$1x = function ListRecordCollectionRepresentationSelect(paginationParams) {
20901
- const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1F();
20983
+ const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1I();
20902
20984
  return {
20903
20985
  kind: 'Fragment',
20904
20986
  reader: true,
@@ -21012,7 +21094,7 @@
21012
21094
  kind: 'Link',
21013
21095
  fragment: select$1y()
21014
21096
  } : params.records;
21015
- const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1F();
21097
+ const { selections: ListReferenceRepresentation__selections, opaque: ListReferenceRepresentation__opaque, } = select$1I();
21016
21098
  return {
21017
21099
  kind: 'Fragment',
21018
21100
  reader: true,
@@ -42998,7 +43080,7 @@
42998
43080
  };
42999
43081
  };
43000
43082
 
43001
- const VERSION$1e = "5f97eb4f2c3f805ef9d98ba7f0530b3e";
43083
+ const VERSION$1h = "5f97eb4f2c3f805ef9d98ba7f0530b3e";
43002
43084
  const RepresentationType$R = 'ContentDocumentCompositeRepresentation';
43003
43085
  function keyBuilder$1S(luvio, config) {
43004
43086
  return keyPrefix$1 + '::' + RepresentationType$R + ':' + config.contentDocumentId;
@@ -43092,7 +43174,7 @@
43092
43174
  const storeMetadataParams = {
43093
43175
  ttl: ttlToUse,
43094
43176
  namespace: "UiApi",
43095
- version: VERSION$1e,
43177
+ version: VERSION$1h,
43096
43178
  representationName: RepresentationType$R,
43097
43179
  };
43098
43180
  luvio.publishStoreMetadata(key, storeMetadataParams);
@@ -43167,11 +43249,11 @@
43167
43249
  priority: 'normal',
43168
43250
  };
43169
43251
  }
43170
- const select$1I = function ContentDocumentCompositeRepresentationSelect(body) {
43252
+ const select$1L = function ContentDocumentCompositeRepresentationSelect(body) {
43171
43253
  return {
43172
43254
  kind: 'Fragment',
43173
43255
  private: [],
43174
- version: VERSION$1e,
43256
+ version: VERSION$1h,
43175
43257
  selections: [
43176
43258
  {
43177
43259
  name: 'contentDocument',
@@ -43210,7 +43292,7 @@
43210
43292
  function ingestSuccess$1$1(luvio, resourceParams, response) {
43211
43293
  const { body } = response;
43212
43294
  const key = keyBuilderFromType$A(luvio, body);
43213
- const node = select$1I(body);
43295
+ const node = select$1L(body);
43214
43296
  luvio.storeIngest(key, ingest$14, body);
43215
43297
  const snapshot = luvio.storeLookup({
43216
43298
  recordId: key,
@@ -43277,7 +43359,7 @@
43277
43359
  function ingestSuccess$I(luvio, resourceParams, response) {
43278
43360
  const { body } = response;
43279
43361
  const key = keyBuilderFromType$A(luvio, body);
43280
- const node = select$1I(body);
43362
+ const node = select$1L(body);
43281
43363
  luvio.storeIngest(key, ingest$14, body);
43282
43364
  const snapshot = luvio.storeLookup({
43283
43365
  recordId: key,
@@ -43933,7 +44015,7 @@
43933
44015
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
43934
44016
  });
43935
44017
  });
43936
- // version: 1.141.1-8f6d93cad
44018
+ // version: 1.142.1-1511d83f4
43937
44019
 
43938
44020
  var caseSensitiveUserId = '005B0000000GR4OIAW';
43939
44021
 
@@ -44731,7 +44813,7 @@
44731
44813
  }
44732
44814
  }
44733
44815
 
44734
- function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler) {
44816
+ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler, additionalDurableStoreOperations = []) {
44735
44817
  const durableRecords = create$5(null);
44736
44818
  const evictedRecords = create$5(null);
44737
44819
  const { records, metadata: storeMetadata, visitedIds, refreshedIds, } = store.fallbackStringKeyInMemoryStore;
@@ -44758,7 +44840,7 @@
44758
44840
  };
44759
44841
  }
44760
44842
  }
44761
- const durableStoreOperations = [];
44843
+ const durableStoreOperations = additionalDurableStoreOperations;
44762
44844
  // publishes
44763
44845
  const recordKeys = keys$6(durableRecords);
44764
44846
  if (recordKeys.length > 0) {
@@ -44861,7 +44943,8 @@
44861
44943
  }
44862
44944
  /**
44863
44945
  * Configures the environment to persist data into a durable store and attempt to resolve
44864
- * data from the persistent store before hitting the network.
44946
+ * data from the persistent store before hitting the network. Sets the default
44947
+ * cache policy to stale-while-revalidate with infinite staleDuration.
44865
44948
  *
44866
44949
  * @param environment The base environment
44867
44950
  * @param durableStore A DurableStore implementation
@@ -45001,12 +45084,12 @@
45001
45084
  // call the base storeBroadcast
45002
45085
  return publishChangesToDurableStore();
45003
45086
  };
45004
- const publishChangesToDurableStore = function () {
45087
+ const publishChangesToDurableStore = function (additionalDurableStoreOperations) {
45005
45088
  validateNotDisposed();
45006
45089
  if (ingestStagingStore === null) {
45007
45090
  return Promise.resolve();
45008
45091
  }
45009
- const promise = flushInMemoryStoreValuesToDurableStore(ingestStagingStore, durableStore, durableStoreErrorHandler);
45092
+ const promise = flushInMemoryStoreValuesToDurableStore(ingestStagingStore, durableStore, durableStoreErrorHandler, additionalDurableStoreOperations);
45010
45093
  ingestStagingStore = null;
45011
45094
  return promise;
45012
45095
  };
@@ -45286,10 +45369,11 @@
45286
45369
  return entries;
45287
45370
  });
45288
45371
  };
45289
- environment.defaultCachePolicy = {
45372
+ // set the default cache policy of the base environment
45373
+ environment.setDefaultCachePolicy({
45290
45374
  type: 'stale-while-revalidate',
45291
- implementation: buildStaleWhileRevalidateImplementation(Number.MAX_SAFE_INTEGER),
45292
- };
45375
+ staleDurationSeconds: Number.MAX_SAFE_INTEGER,
45376
+ });
45293
45377
  return create$5(environment, {
45294
45378
  publishStoreMetadata: { value: publishStoreMetadata },
45295
45379
  storeIngest: { value: storeIngest },
@@ -59714,7 +59798,7 @@
59714
59798
  id: '@salesforce/lds-network-adapter',
59715
59799
  instrument: instrument$1,
59716
59800
  });
59717
- // version: 1.141.1-07065b50d
59801
+ // version: 1.142.1-d514db71e
59718
59802
 
59719
59803
  const { create: create$2, keys: keys$2 } = Object;
59720
59804
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -59828,6 +59912,20 @@
59828
59912
  return `${keyPrefix}::${schemaName}::${queryTypeName}[${serializeOperationNode$1(operationNode, variables, fragmentMap)}]`;
59829
59913
  }
59830
59914
 
59915
+ /**
59916
+ * @description Spec compliant way to retrieve the correct Operation from the Document that Luvio should operate on. https://spec.graphql.org/June2018/#sec-Named-Operation-Definitions
59917
+ * @param document
59918
+ * @param operationName
59919
+ * @returns The Operation in the GraphQL document we should use for the current call.
59920
+ */
59921
+ function getOperationFromDocument(document, operationName) {
59922
+ const operations = document.definitions.filter((def) => def.kind === 'OperationDefinition');
59923
+ if (operationName) {
59924
+ return operations.find((def) => def.name !== undefined && def.name.value === operationName);
59925
+ }
59926
+ return operations[0]; // If a named operation is not provided, we return the first one
59927
+ }
59928
+
59831
59929
  /**
59832
59930
  * Copyright (c) 2022, Salesforce, Inc.,
59833
59931
  * All rights reserved.
@@ -79239,43 +79337,38 @@
79239
79337
  const TTL = 900000;
79240
79338
  const VERSION$6 = "b440235e7e724631f92002fe50e3e096";
79241
79339
  const RepresentationType = 'GraphQLRepresentation';
79242
- function select$8(luvio, query, variables) {
79243
- const definitions = query.definitions === undefined ? [] : query.definitions;
79340
+ function select$8(luvio, document, variables, operationName) {
79341
+ const operationToExecute = getOperationFromDocument(document, operationName);
79244
79342
  return {
79245
79343
  kind: 'Fragment',
79246
79344
  synthetic: true,
79247
79345
  reader: true,
79248
79346
  read: (builder) => {
79249
79347
  builder.enterPath('data');
79250
- let sink = {};
79251
- const fragments = createFragmentMap(query);
79252
- for (let i = 0, len = definitions.length; i < len; i += 1) {
79253
- const def = definitions[i];
79254
- if (def.kind === 'OperationDefinition') {
79255
- const queryTypeRecordId = keyBuilder$4(luvio, def, variables, fragments);
79256
- const snapshot = builder.read({
79257
- recordId: queryTypeRecordId,
79258
- node: {
79259
- kind: 'Fragment',
79260
- private: [],
79261
- opaque: true,
79262
- version: VERSION$7
79263
- },
79264
- variables: {}
79265
- });
79266
- if (snapshot.data === undefined) {
79267
- builder.markMissingLink(queryTypeRecordId);
79268
- break;
79269
- }
79270
- const data = select$9(def, variables, fragments)(snapshot.data, builder, queryTypeRecordId);
79271
- sink = {
79272
- ...sink,
79273
- ...data,
79274
- };
79275
- }
79276
- }
79277
79348
  const gqlData = {};
79278
- builder.assignNonScalar(gqlData, 'data', sink);
79349
+ if (operationToExecute === undefined) {
79350
+ builder.markMissing(); // Never give a cache hit for an undefined operation
79351
+ return gqlData;
79352
+ }
79353
+ const fragments = createFragmentMap(document);
79354
+ const queryTypeRecordId = keyBuilder$4(luvio, operationToExecute, variables, fragments);
79355
+ const snapshot = builder.read({
79356
+ recordId: queryTypeRecordId,
79357
+ node: {
79358
+ kind: 'Fragment',
79359
+ private: [],
79360
+ opaque: true,
79361
+ version: VERSION$7
79362
+ },
79363
+ variables: {}
79364
+ });
79365
+ if (snapshot.data === undefined) {
79366
+ builder.markMissingLink(queryTypeRecordId);
79367
+ }
79368
+ else {
79369
+ const data = select$9(operationToExecute, variables, fragments)(snapshot.data, builder, queryTypeRecordId);
79370
+ builder.assignNonScalar(gqlData, 'data', data);
79371
+ }
79279
79372
  builder.exitPath();
79280
79373
  return gqlData;
79281
79374
  }
@@ -79295,10 +79388,10 @@
79295
79388
  });
79296
79389
  }
79297
79390
  }
79298
- const ingest = function GraphQLRepresentationIngest(query, variables) {
79391
+ const ingest = function GraphQLRepresentationIngest(document, variables, operationName) {
79299
79392
  return (input, path, luvio, store, timestamp) => {
79300
79393
  if (input.data) {
79301
- const fragments = createFragmentMap(query);
79394
+ const fragments = createFragmentMap(document);
79302
79395
  const state = {
79303
79396
  data: input.data,
79304
79397
  luvio,
@@ -79308,44 +79401,42 @@
79308
79401
  variables,
79309
79402
  fragments,
79310
79403
  };
79311
- query.definitions.forEach((node) => {
79312
- if (node.kind === 'OperationDefinition') {
79313
- ingestOperationNode(luvio, input, node, state);
79314
- }
79315
- });
79404
+ const operationToExecute = getOperationFromDocument(document, operationName);
79405
+ if (operationToExecute !== undefined) {
79406
+ ingestOperationNode(luvio, input, operationToExecute, state);
79407
+ }
79316
79408
  }
79317
79409
  return {
79318
79410
  __ref: undefined
79319
79411
  };
79320
79412
  };
79321
79413
  };
79322
- function getTypeCacheKeys(luvio, query, variables, data) {
79414
+ function getTypeCacheKeys(luvio, document, variables, data, operationName) {
79323
79415
  const sink = new StoreKeyMap();
79324
79416
  if (data.data) {
79325
- const fragments = createFragmentMap(query);
79326
- query.definitions.forEach((node) => {
79327
- if (node.kind === 'OperationDefinition') {
79328
- const state = {
79329
- luvio,
79330
- variables,
79331
- fragments,
79332
- data: data.data,
79333
- path: {
79334
- parent: null,
79335
- propertyName: null,
79336
- fullPath: '' // TODO: W-13079691 - Need to take another pass at what we want to do for structured keys
79337
- }
79338
- };
79339
- sink.merge(getTypeCacheKeys$1(node, state));
79340
- }
79341
- });
79417
+ const fragments = createFragmentMap(document);
79418
+ const operationToExecute = getOperationFromDocument(document, operationName);
79419
+ if (operationToExecute !== undefined) {
79420
+ const state = {
79421
+ luvio,
79422
+ variables,
79423
+ fragments,
79424
+ data: data.data,
79425
+ path: {
79426
+ parent: null,
79427
+ propertyName: null,
79428
+ fullPath: '' // TODO: W-13079691 - Need to take another pass at what we want to do for structured keys
79429
+ }
79430
+ };
79431
+ sink.merge(getTypeCacheKeys$1(operationToExecute, state));
79432
+ }
79342
79433
  }
79343
79434
  return sink;
79344
79435
  }
79345
79436
 
79346
79437
  function select$7(luvio, config) {
79347
- const { query, variables } = config;
79348
- return select$8(luvio, query, variables);
79438
+ const { query, variables, operationName } = config;
79439
+ return select$8(luvio, query, variables, operationName);
79349
79440
  }
79350
79441
  function keyBuilder$3(luvio, params) {
79351
79442
  return keyPrefix + '::' + 'GraphQLRepresentation';
@@ -79353,13 +79444,14 @@
79353
79444
  function getResponseCacheKeys$1(luvio, resourceParams, response) {
79354
79445
  const query = resourceParams.body.query;
79355
79446
  const variables = resourceParams.body.variables || {};
79356
- return getTypeCacheKeys(luvio, query, variables, response);
79447
+ const operationName = resourceParams.body.operationName;
79448
+ return getTypeCacheKeys(luvio, query, variables, response, operationName);
79357
79449
  }
79358
79450
  function ingestSuccess$1(luvio, config, resourceParams, response, snapshotRefresh) {
79359
79451
  const { body } = response;
79360
79452
  const key = keyBuilder$3();
79361
- const { query, variables } = resourceParams.body;
79362
- luvio.storeIngest(key, ingest(query, variables), body);
79453
+ const { query, variables, operationName } = resourceParams.body;
79454
+ luvio.storeIngest(key, ingest(query, variables, operationName), body);
79363
79455
  // revert the optimized pagination variables back to its original so that subsequent store lookup will include all records, not just the ones loaded by an optimized query
79364
79456
  // see optimizePagination for initial update to optimize the query
79365
79457
  revertPaginationOptimization(variables);
@@ -80545,7 +80637,7 @@
80545
80637
  configuration: { ...configurationForGraphQLAdapters },
80546
80638
  instrument,
80547
80639
  });
80548
- // version: 1.141.1-8f6d93cad
80640
+ // version: 1.142.1-1511d83f4
80549
80641
 
80550
80642
  // On core the unstable adapters are re-exported with different names,
80551
80643
 
@@ -82777,7 +82869,7 @@
82777
82869
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
82778
82870
  graphQLImperative = ldsAdapter;
82779
82871
  });
82780
- // version: 1.141.1-8f6d93cad
82872
+ // version: 1.142.1-1511d83f4
82781
82873
 
82782
82874
  var gqlApi = /*#__PURE__*/Object.freeze({
82783
82875
  __proto__: null,
@@ -83483,4 +83575,4 @@
83483
83575
  Object.defineProperty(exports, '__esModule', { value: true });
83484
83576
 
83485
83577
  }));
83486
- // version: 1.141.1-07065b50d
83578
+ // version: 1.142.1-d514db71e
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.141.1",
3
+ "version": "1.142.1",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",