@salesforce/lds-worker-api 1.142.1 → 1.143.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.142.1-d514db71e
761
+ // version: 1.143.0-a6d2a998d
@@ -3673,7 +3673,7 @@ class Luvio {
3673
3673
  return this.environment.buildStructuredKey(namespace, representationName, idValues);
3674
3674
  }
3675
3675
  }
3676
- // engine version: 0.142.3-97d0da6c
3676
+ // engine version: 0.142.4-be29f4f3
3677
3677
 
3678
3678
  /**
3679
3679
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3800,7 +3800,7 @@ function withDefaultLuvio(callback) {
3800
3800
  }
3801
3801
  callbacks.push(callback);
3802
3802
  }
3803
- // version: 1.142.1-d514db71e
3803
+ // version: 1.143.0-a6d2a998d
3804
3804
 
3805
3805
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3806
3806
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15224,7 +15224,7 @@ function parseAndVisit(source) {
15224
15224
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15225
15225
  return luvioDocumentNode;
15226
15226
  }
15227
- // version: 1.142.1-d514db71e
15227
+ // version: 1.143.0-a6d2a998d
15228
15228
 
15229
15229
  function unwrap(data) {
15230
15230
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16137,7 +16137,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
16137
16137
  const { apiFamily, name } = metadata;
16138
16138
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16139
16139
  }
16140
- // version: 1.142.1-d514db71e
16140
+ // version: 1.143.0-a6d2a998d
16141
16141
 
16142
16142
  /**
16143
16143
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16220,7 +16220,7 @@ var FragmentReadResultState;
16220
16220
  ({
16221
16221
  state: FragmentReadResultState.Missing,
16222
16222
  });
16223
- // engine version: 0.142.3-97d0da6c
16223
+ // engine version: 0.142.4-be29f4f3
16224
16224
 
16225
16225
  const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
16226
16226
 
@@ -16568,7 +16568,7 @@ function getFetchResponseStatusText$1(status) {
16568
16568
  return `Unexpected HTTP Status Code: ${status}`;
16569
16569
  }
16570
16570
  }
16571
- function isUnfulfilledSnapshot$1(snapshot) {
16571
+ function isUnfulfilledSnapshot$1$1(snapshot) {
16572
16572
  return snapshot.state === SNAPSHOT_STATE_UNFULFILLED;
16573
16573
  }
16574
16574
  const keyPrefix$1 = 'UiApi';
@@ -22810,7 +22810,7 @@ function buildCachedSnapshotCachePolicy$I(context, storeLookup) {
22810
22810
  config,
22811
22811
  resolve: () => buildNetworkSnapshot$U(luvio, config, snapshotRefreshOptions$1)
22812
22812
  });
22813
- if (isUnfulfilledSnapshot$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
22813
+ if (isUnfulfilledSnapshot$1$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
22814
22814
  context.cacheSnapshot = cacheSnapshot;
22815
22815
  }
22816
22816
  return cacheSnapshot;
@@ -38256,7 +38256,7 @@ function buildCachedSnapshotCachePolicy$9(context, storeLookup) {
38256
38256
  config,
38257
38257
  resolve: () => buildNetworkSnapshot$h(luvio, config, snapshotRefreshOptions$1)
38258
38258
  });
38259
- if (isUnfulfilledSnapshot$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
38259
+ if (isUnfulfilledSnapshot$1$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
38260
38260
  context.cacheSnapshot = cacheSnapshot;
38261
38261
  }
38262
38262
  return cacheSnapshot;
@@ -40398,7 +40398,7 @@ function buildCachedSnapshotCachePolicy$3(context, storeLookup) {
40398
40398
  config,
40399
40399
  resolve: () => buildNetworkSnapshot$9(luvio, config, snapshotRefreshOptions$1)
40400
40400
  });
40401
- if (isUnfulfilledSnapshot$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
40401
+ if (isUnfulfilledSnapshot$1$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
40402
40402
  context.cacheSnapshot = cacheSnapshot;
40403
40403
  }
40404
40404
  return cacheSnapshot;
@@ -44007,7 +44007,7 @@ withDefaultLuvio((luvio) => {
44007
44007
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44008
44008
  });
44009
44009
  });
44010
- // version: 1.142.1-1511d83f4
44010
+ // version: 1.143.0-7a79bacc1
44011
44011
 
44012
44012
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44013
44013
 
@@ -44082,6 +44082,33 @@ function formattingOptions(pattern) {
44082
44082
  return pattern;
44083
44083
  }
44084
44084
 
44085
+ var eagerEvalValidAt = {
44086
+ isOpen: function (e) {
44087
+ return e.fallback;
44088
+ },
44089
+ hasError: function () {
44090
+ return !0;
44091
+ },
44092
+ };
44093
+
44094
+ var eagerEvalStaleWhileRevalidate = {
44095
+ isOpen: function (e) {
44096
+ return e.fallback;
44097
+ },
44098
+ hasError: function () {
44099
+ return !0;
44100
+ },
44101
+ };
44102
+
44103
+ var eagerEvalDefaultCachePolicy = {
44104
+ isOpen: function (e) {
44105
+ return e.fallback;
44106
+ },
44107
+ hasError: function () {
44108
+ return !0;
44109
+ },
44110
+ };
44111
+
44085
44112
  /**
44086
44113
  * Copyright (c) 2022, Salesforce, Inc.,
44087
44114
  * All rights reserved.
@@ -44924,7 +44951,7 @@ async function reviveOrCreateContext(adapterId, durableStore, durableStoreErrorH
44924
44951
  }
44925
44952
  return contextReturn();
44926
44953
  }
44927
- function isUnfulfilledSnapshot(cachedSnapshotResult) {
44954
+ function isUnfulfilledSnapshot$1(cachedSnapshotResult) {
44928
44955
  if (cachedSnapshotResult === undefined) {
44929
44956
  return false;
44930
44957
  }
@@ -45208,7 +45235,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
45208
45235
  const snapshot = buildCachedSnapshot(injectedBuildSnapshotContext, injectedStoreLookup, luvio);
45209
45236
  // if the adapter attempted to do an L1 lookup and it was unfulfilled
45210
45237
  // then we can attempt an L2 lookup
45211
- if (isUnfulfilledSnapshot(snapshot)) {
45238
+ if (isUnfulfilledSnapshot$1(snapshot)) {
45212
45239
  const start = Date.now();
45213
45240
  emitDurableEnvironmentAdapterEvent({ type: 'l2-revive-start' }, adapterRequestContext.eventObservers);
45214
45241
  const revivedSnapshot = reviveSnapshot(environment, durableStore, snapshot, durableStoreErrorHandler, () => injectedStoreLookup(snapshot.select, snapshot.refresh)).then((result) => {
@@ -56566,6 +56593,7 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
56566
56593
  query: injectedAST,
56567
56594
  },
56568
56595
  luvio,
56596
+ gqlEval: true,
56569
56597
  }, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy));
56570
56598
  if (isErrorSnapshotThatShouldGetReturnedToCaller(nonEvaluatedSnapshot)) {
56571
56599
  return nonEvaluatedSnapshot;
@@ -59024,8 +59052,17 @@ function formatDisplayValue(value, datatype) {
59024
59052
  }
59025
59053
  }
59026
59054
 
59027
- //TODO: [W-12734162] - rebuild non-evaluated snapshot when graph rebuild is triggered. The dependency work on luvio needs to be done.
59055
+ function isUnfulfilledSnapshot(cachedSnapshotResult) {
59056
+ if (cachedSnapshotResult === undefined) {
59057
+ return false;
59058
+ }
59059
+ if ('then' in cachedSnapshotResult) {
59060
+ return false;
59061
+ }
59062
+ return cachedSnapshotResult.state === 'Unfulfilled';
59063
+ }
59028
59064
  function makeEnvironmentGraphqlAware(environment) {
59065
+ //TODO: [W-12734162] - rebuild non-evaluated snapshot when graph rebuild is triggered. The dependency work on luvio needs to be done.
59029
59066
  const rebuildSnapshot = function (snapshot, onRebuild) {
59030
59067
  if (isStoreEvalSnapshot(snapshot)) {
59031
59068
  snapshot.rebuildWithStoreEval(snapshot).then((rebuilt) => {
@@ -59041,8 +59078,64 @@ function makeEnvironmentGraphqlAware(environment) {
59041
59078
  }
59042
59079
  return environment.rebuildSnapshot(snapshot, onRebuild);
59043
59080
  };
59081
+ const applyCachePolicy = function (luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot) {
59082
+ // Early exit for non-evaluating adapters
59083
+ let graphqlBuildSnapshotContext = buildSnapshotContext;
59084
+ if (graphqlBuildSnapshotContext.gqlEval !== true) {
59085
+ return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot);
59086
+ }
59087
+ var localBuildCachedSnapshot = buildCachedSnapshot;
59088
+ const hoistUnfulfilledToStale = (context, storeLookup, luvio) => {
59089
+ const upstream = buildCachedSnapshot(context, storeLookup, luvio);
59090
+ if (upstream === undefined)
59091
+ return upstream;
59092
+ if (isUnfulfilledSnapshot(upstream)) {
59093
+ return {
59094
+ ...upstream,
59095
+ data: upstream.data || {},
59096
+ state: 'Stale',
59097
+ };
59098
+ }
59099
+ else if ('then' in upstream) {
59100
+ return upstream.then((snapshot) => {
59101
+ if (snapshot === undefined)
59102
+ return snapshot;
59103
+ if (isUnfulfilledSnapshot(snapshot)) {
59104
+ return {
59105
+ ...snapshot,
59106
+ data: snapshot.data || {},
59107
+ state: 'Stale',
59108
+ };
59109
+ }
59110
+ return snapshot;
59111
+ });
59112
+ }
59113
+ return upstream;
59114
+ };
59115
+ const { cachePolicy } = adapterRequestContext;
59116
+ if (eagerEvalValidAt.isOpen({ fallback: false }) &&
59117
+ cachePolicy &&
59118
+ cachePolicy.type === 'valid-at' &&
59119
+ cachePolicy.timestamp === 0 &&
59120
+ cachePolicy.basePolicy &&
59121
+ cachePolicy.basePolicy.type === 'stale-while-revalidate') {
59122
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59123
+ }
59124
+ if (eagerEvalStaleWhileRevalidate.isOpen({ fallback: false }) &&
59125
+ cachePolicy &&
59126
+ cachePolicy.type === 'stale-while-revalidate' &&
59127
+ cachePolicy.staleDurationSeconds === Number.MAX_SAFE_INTEGER) {
59128
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59129
+ }
59130
+ if (eagerEvalDefaultCachePolicy.isOpen({ fallback: false }) && cachePolicy === undefined) {
59131
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59132
+ }
59133
+ return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, localBuildCachedSnapshot, buildNetworkSnapshot);
59134
+ };
59044
59135
  return create$6(environment, {
59045
59136
  rebuildSnapshot: { value: rebuildSnapshot },
59137
+ applyCachePolicy: { value: applyCachePolicy },
59138
+ setDefaultCachePolicy: { value: environment.setDefaultCachePolicy.bind(environment) },
59046
59139
  });
59047
59140
  }
59048
59141
 
@@ -59790,7 +59883,7 @@ register({
59790
59883
  id: '@salesforce/lds-network-adapter',
59791
59884
  instrument: instrument$1,
59792
59885
  });
59793
- // version: 1.142.1-d514db71e
59886
+ // version: 1.143.0-a6d2a998d
59794
59887
 
59795
59888
  const { create: create$2, keys: keys$2 } = Object;
59796
59889
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -79431,7 +79524,13 @@ function select$7(luvio, config) {
79431
79524
  return select$8(luvio, query, variables, operationName);
79432
79525
  }
79433
79526
  function keyBuilder$3(luvio, params) {
79434
- return keyPrefix + '::' + 'GraphQLRepresentation';
79527
+ const { query, operationName, variables } = params.body;
79528
+ const operationToExecute = getOperationFromDocument(query, operationName);
79529
+ if (operationToExecute !== undefined) {
79530
+ const fragments = createFragmentMap(query);
79531
+ return keyBuilder$4(luvio, operationToExecute, variables || {}, fragments);
79532
+ }
79533
+ return `adapters_adapter$45$utils_keyPrefix::GraphQLRepresentation::InvalidOperation`;
79435
79534
  }
79436
79535
  function getResponseCacheKeys$1(luvio, resourceParams, response) {
79437
79536
  const query = resourceParams.body.query;
@@ -79441,7 +79540,7 @@ function getResponseCacheKeys$1(luvio, resourceParams, response) {
79441
79540
  }
79442
79541
  function ingestSuccess$1(luvio, config, resourceParams, response, snapshotRefresh) {
79443
79542
  const { body } = response;
79444
- const key = keyBuilder$3();
79543
+ const key = keyBuilder$3(luvio, resourceParams);
79445
79544
  const { query, variables, operationName } = resourceParams.body;
79446
79545
  luvio.storeIngest(key, ingest(query, variables, operationName), body);
79447
79546
  // 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
@@ -79455,7 +79554,7 @@ function ingestSuccess$1(luvio, config, resourceParams, response, snapshotRefres
79455
79554
  return snapshot;
79456
79555
  }
79457
79556
  function ingestError$1(luvio, config, params, error, snapshotRefresh) {
79458
- const key = keyBuilder$3();
79557
+ const key = keyBuilder$3(luvio, params);
79459
79558
  const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
79460
79559
  const storeMetadataParams = {
79461
79560
  ttl: TTL,
@@ -79538,8 +79637,8 @@ function createResourceParams$1(config) {
79538
79637
  return resourceParams;
79539
79638
  }
79540
79639
  function keyBuilder$2(luvio, config) {
79541
- createResourceParams$1(config);
79542
- return keyBuilder$3();
79640
+ const resourceParams = createResourceParams$1(config);
79641
+ return keyBuilder$3(luvio, resourceParams);
79543
79642
  }
79544
79643
  function typeCheckConfig$1(untrustedConfig) {
79545
79644
  const config = {};
@@ -79887,7 +79986,7 @@ function selectChildResourceParams(luvio, childResources, resourceParams) {
79887
79986
  reader.enterPath(i);
79888
79987
  reader.enterPath(envelopeBodyPath);
79889
79988
  const childResource = childResources[i];
79890
- const childKey = keyBuilder$3();
79989
+ const childKey = keyBuilder$3(luvio, childResource);
79891
79990
  const childFragment = select$7(luvio, childResource.body); // MUST read from the ORIGINAL config not injected
79892
79991
  const isMissingDataBeforeChildRead = reader.getIsDataMissing();
79893
79992
  const childSnapshot = reader.read({
@@ -79998,7 +80097,7 @@ function getResponseCacheKeys$2(luvio, resourceParams, response) {
79998
80097
  ObjectAssign(keys, childKeys);
79999
80098
  }
80000
80099
  else if (childStatusCode === 404) {
80001
- const childKey = keyBuilder$3();
80100
+ const childKey = keyBuilder$3(luvio, childResourceParams);
80002
80101
  keys.set(childKey, {
80003
80102
  namespace: keyPrefix,
80004
80103
  representationName: RepresentationType,
@@ -80016,7 +80115,7 @@ function ingestSuccessChildResourceParams(luvio, childConfigs, childResourcePara
80016
80115
  // There's an assumption here that the config and resource params aren't reordered.
80017
80116
  const childConfig = childConfigs[index];
80018
80117
  const childResourceParams = childResourceParamsArray[index];
80019
- const childKey = keyBuilder$3();
80118
+ const childKey = keyBuilder$3(luvio, childResourceParams);
80020
80119
  const result = childEnvelopes[index];
80021
80120
  const { statusCode: childStatusCode, result: childBody } = result;
80022
80121
  if (childStatusCode === 200 &&
@@ -80629,7 +80728,7 @@ register({
80629
80728
  configuration: { ...configurationForGraphQLAdapters },
80630
80729
  instrument,
80631
80730
  });
80632
- // version: 1.142.1-1511d83f4
80731
+ // version: 1.143.0-7a79bacc1
80633
80732
 
80634
80733
  // On core the unstable adapters are re-exported with different names,
80635
80734
 
@@ -82813,6 +82912,12 @@ const graphQLAdapterFactory = (luvio) => {
82813
82912
  fragment,
82814
82913
  luvio,
82815
82914
  };
82915
+ // NOTE: For evaluating environments, set a context property to let the
82916
+ // environment detect that eval will happen and to check varous gates
82917
+ // for eval behavior customizations.
82918
+ if (storeEval !== undefined) {
82919
+ context.gqlEval = true;
82920
+ }
82816
82921
  const snapshotOrPromiseFromCachePolicy = luvio.applyCachePolicy(requestContext || {}, context, buildCachedSnapshot, buildNetworkSnapshotCachePolicy);
82817
82922
  if (storeEval !== undefined) {
82818
82923
  const observers = requestContext && requestContext.eventObservers
@@ -82861,7 +82966,7 @@ withDefaultLuvio((luvio) => {
82861
82966
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
82862
82967
  graphQLImperative = ldsAdapter;
82863
82968
  });
82864
- // version: 1.142.1-1511d83f4
82969
+ // version: 1.143.0-7a79bacc1
82865
82970
 
82866
82971
  var gqlApi = /*#__PURE__*/Object.freeze({
82867
82972
  __proto__: null,
@@ -83550,4 +83655,4 @@ const { luvio } = getRuntime();
83550
83655
  setDefaultLuvio({ luvio });
83551
83656
 
83552
83657
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
83553
- // version: 1.142.1-d514db71e
83658
+ // version: 1.143.0-a6d2a998d
@@ -3681,7 +3681,7 @@
3681
3681
  return this.environment.buildStructuredKey(namespace, representationName, idValues);
3682
3682
  }
3683
3683
  }
3684
- // engine version: 0.142.3-97d0da6c
3684
+ // engine version: 0.142.4-be29f4f3
3685
3685
 
3686
3686
  /**
3687
3687
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3808,7 +3808,7 @@
3808
3808
  }
3809
3809
  callbacks.push(callback);
3810
3810
  }
3811
- // version: 1.142.1-d514db71e
3811
+ // version: 1.143.0-a6d2a998d
3812
3812
 
3813
3813
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3814
3814
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15232,7 +15232,7 @@
15232
15232
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15233
15233
  return luvioDocumentNode;
15234
15234
  }
15235
- // version: 1.142.1-d514db71e
15235
+ // version: 1.143.0-a6d2a998d
15236
15236
 
15237
15237
  function unwrap(data) {
15238
15238
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16145,7 +16145,7 @@
16145
16145
  const { apiFamily, name } = metadata;
16146
16146
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16147
16147
  }
16148
- // version: 1.142.1-d514db71e
16148
+ // version: 1.143.0-a6d2a998d
16149
16149
 
16150
16150
  /**
16151
16151
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16228,7 +16228,7 @@
16228
16228
  ({
16229
16229
  state: FragmentReadResultState.Missing,
16230
16230
  });
16231
- // engine version: 0.142.3-97d0da6c
16231
+ // engine version: 0.142.4-be29f4f3
16232
16232
 
16233
16233
  const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
16234
16234
 
@@ -16576,7 +16576,7 @@
16576
16576
  return `Unexpected HTTP Status Code: ${status}`;
16577
16577
  }
16578
16578
  }
16579
- function isUnfulfilledSnapshot$1(snapshot) {
16579
+ function isUnfulfilledSnapshot$1$1(snapshot) {
16580
16580
  return snapshot.state === SNAPSHOT_STATE_UNFULFILLED;
16581
16581
  }
16582
16582
  const keyPrefix$1 = 'UiApi';
@@ -22818,7 +22818,7 @@
22818
22818
  config,
22819
22819
  resolve: () => buildNetworkSnapshot$U(luvio, config, snapshotRefreshOptions$1)
22820
22820
  });
22821
- if (isUnfulfilledSnapshot$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
22821
+ if (isUnfulfilledSnapshot$1$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
22822
22822
  context.cacheSnapshot = cacheSnapshot;
22823
22823
  }
22824
22824
  return cacheSnapshot;
@@ -38264,7 +38264,7 @@
38264
38264
  config,
38265
38265
  resolve: () => buildNetworkSnapshot$h(luvio, config, snapshotRefreshOptions$1)
38266
38266
  });
38267
- if (isUnfulfilledSnapshot$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
38267
+ if (isUnfulfilledSnapshot$1$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
38268
38268
  context.cacheSnapshot = cacheSnapshot;
38269
38269
  }
38270
38270
  return cacheSnapshot;
@@ -40406,7 +40406,7 @@
40406
40406
  config,
40407
40407
  resolve: () => buildNetworkSnapshot$9(luvio, config, snapshotRefreshOptions$1)
40408
40408
  });
40409
- if (isUnfulfilledSnapshot$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
40409
+ if (isUnfulfilledSnapshot$1$1(cacheSnapshot) && cacheSnapshot.data !== undefined) {
40410
40410
  context.cacheSnapshot = cacheSnapshot;
40411
40411
  }
40412
40412
  return cacheSnapshot;
@@ -44015,7 +44015,7 @@
44015
44015
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44016
44016
  });
44017
44017
  });
44018
- // version: 1.142.1-1511d83f4
44018
+ // version: 1.143.0-7a79bacc1
44019
44019
 
44020
44020
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44021
44021
 
@@ -44090,6 +44090,33 @@
44090
44090
  return pattern;
44091
44091
  }
44092
44092
 
44093
+ var eagerEvalValidAt = {
44094
+ isOpen: function (e) {
44095
+ return e.fallback;
44096
+ },
44097
+ hasError: function () {
44098
+ return !0;
44099
+ },
44100
+ };
44101
+
44102
+ var eagerEvalStaleWhileRevalidate = {
44103
+ isOpen: function (e) {
44104
+ return e.fallback;
44105
+ },
44106
+ hasError: function () {
44107
+ return !0;
44108
+ },
44109
+ };
44110
+
44111
+ var eagerEvalDefaultCachePolicy = {
44112
+ isOpen: function (e) {
44113
+ return e.fallback;
44114
+ },
44115
+ hasError: function () {
44116
+ return !0;
44117
+ },
44118
+ };
44119
+
44093
44120
  /**
44094
44121
  * Copyright (c) 2022, Salesforce, Inc.,
44095
44122
  * All rights reserved.
@@ -44932,7 +44959,7 @@
44932
44959
  }
44933
44960
  return contextReturn();
44934
44961
  }
44935
- function isUnfulfilledSnapshot(cachedSnapshotResult) {
44962
+ function isUnfulfilledSnapshot$1(cachedSnapshotResult) {
44936
44963
  if (cachedSnapshotResult === undefined) {
44937
44964
  return false;
44938
44965
  }
@@ -45216,7 +45243,7 @@
45216
45243
  const snapshot = buildCachedSnapshot(injectedBuildSnapshotContext, injectedStoreLookup, luvio);
45217
45244
  // if the adapter attempted to do an L1 lookup and it was unfulfilled
45218
45245
  // then we can attempt an L2 lookup
45219
- if (isUnfulfilledSnapshot(snapshot)) {
45246
+ if (isUnfulfilledSnapshot$1(snapshot)) {
45220
45247
  const start = Date.now();
45221
45248
  emitDurableEnvironmentAdapterEvent({ type: 'l2-revive-start' }, adapterRequestContext.eventObservers);
45222
45249
  const revivedSnapshot = reviveSnapshot(environment, durableStore, snapshot, durableStoreErrorHandler, () => injectedStoreLookup(snapshot.select, snapshot.refresh)).then((result) => {
@@ -56574,6 +56601,7 @@
56574
56601
  query: injectedAST,
56575
56602
  },
56576
56603
  luvio,
56604
+ gqlEval: true,
56577
56605
  }, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy));
56578
56606
  if (isErrorSnapshotThatShouldGetReturnedToCaller(nonEvaluatedSnapshot)) {
56579
56607
  return nonEvaluatedSnapshot;
@@ -59032,8 +59060,17 @@
59032
59060
  }
59033
59061
  }
59034
59062
 
59035
- //TODO: [W-12734162] - rebuild non-evaluated snapshot when graph rebuild is triggered. The dependency work on luvio needs to be done.
59063
+ function isUnfulfilledSnapshot(cachedSnapshotResult) {
59064
+ if (cachedSnapshotResult === undefined) {
59065
+ return false;
59066
+ }
59067
+ if ('then' in cachedSnapshotResult) {
59068
+ return false;
59069
+ }
59070
+ return cachedSnapshotResult.state === 'Unfulfilled';
59071
+ }
59036
59072
  function makeEnvironmentGraphqlAware(environment) {
59073
+ //TODO: [W-12734162] - rebuild non-evaluated snapshot when graph rebuild is triggered. The dependency work on luvio needs to be done.
59037
59074
  const rebuildSnapshot = function (snapshot, onRebuild) {
59038
59075
  if (isStoreEvalSnapshot(snapshot)) {
59039
59076
  snapshot.rebuildWithStoreEval(snapshot).then((rebuilt) => {
@@ -59049,8 +59086,64 @@
59049
59086
  }
59050
59087
  return environment.rebuildSnapshot(snapshot, onRebuild);
59051
59088
  };
59089
+ const applyCachePolicy = function (luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot) {
59090
+ // Early exit for non-evaluating adapters
59091
+ let graphqlBuildSnapshotContext = buildSnapshotContext;
59092
+ if (graphqlBuildSnapshotContext.gqlEval !== true) {
59093
+ return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot);
59094
+ }
59095
+ var localBuildCachedSnapshot = buildCachedSnapshot;
59096
+ const hoistUnfulfilledToStale = (context, storeLookup, luvio) => {
59097
+ const upstream = buildCachedSnapshot(context, storeLookup, luvio);
59098
+ if (upstream === undefined)
59099
+ return upstream;
59100
+ if (isUnfulfilledSnapshot(upstream)) {
59101
+ return {
59102
+ ...upstream,
59103
+ data: upstream.data || {},
59104
+ state: 'Stale',
59105
+ };
59106
+ }
59107
+ else if ('then' in upstream) {
59108
+ return upstream.then((snapshot) => {
59109
+ if (snapshot === undefined)
59110
+ return snapshot;
59111
+ if (isUnfulfilledSnapshot(snapshot)) {
59112
+ return {
59113
+ ...snapshot,
59114
+ data: snapshot.data || {},
59115
+ state: 'Stale',
59116
+ };
59117
+ }
59118
+ return snapshot;
59119
+ });
59120
+ }
59121
+ return upstream;
59122
+ };
59123
+ const { cachePolicy } = adapterRequestContext;
59124
+ if (eagerEvalValidAt.isOpen({ fallback: false }) &&
59125
+ cachePolicy &&
59126
+ cachePolicy.type === 'valid-at' &&
59127
+ cachePolicy.timestamp === 0 &&
59128
+ cachePolicy.basePolicy &&
59129
+ cachePolicy.basePolicy.type === 'stale-while-revalidate') {
59130
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59131
+ }
59132
+ if (eagerEvalStaleWhileRevalidate.isOpen({ fallback: false }) &&
59133
+ cachePolicy &&
59134
+ cachePolicy.type === 'stale-while-revalidate' &&
59135
+ cachePolicy.staleDurationSeconds === Number.MAX_SAFE_INTEGER) {
59136
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59137
+ }
59138
+ if (eagerEvalDefaultCachePolicy.isOpen({ fallback: false }) && cachePolicy === undefined) {
59139
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59140
+ }
59141
+ return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, localBuildCachedSnapshot, buildNetworkSnapshot);
59142
+ };
59052
59143
  return create$6(environment, {
59053
59144
  rebuildSnapshot: { value: rebuildSnapshot },
59145
+ applyCachePolicy: { value: applyCachePolicy },
59146
+ setDefaultCachePolicy: { value: environment.setDefaultCachePolicy.bind(environment) },
59054
59147
  });
59055
59148
  }
59056
59149
 
@@ -59798,7 +59891,7 @@
59798
59891
  id: '@salesforce/lds-network-adapter',
59799
59892
  instrument: instrument$1,
59800
59893
  });
59801
- // version: 1.142.1-d514db71e
59894
+ // version: 1.143.0-a6d2a998d
59802
59895
 
59803
59896
  const { create: create$2, keys: keys$2 } = Object;
59804
59897
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -79439,7 +79532,13 @@
79439
79532
  return select$8(luvio, query, variables, operationName);
79440
79533
  }
79441
79534
  function keyBuilder$3(luvio, params) {
79442
- return keyPrefix + '::' + 'GraphQLRepresentation';
79535
+ const { query, operationName, variables } = params.body;
79536
+ const operationToExecute = getOperationFromDocument(query, operationName);
79537
+ if (operationToExecute !== undefined) {
79538
+ const fragments = createFragmentMap(query);
79539
+ return keyBuilder$4(luvio, operationToExecute, variables || {}, fragments);
79540
+ }
79541
+ return `adapters_adapter$45$utils_keyPrefix::GraphQLRepresentation::InvalidOperation`;
79443
79542
  }
79444
79543
  function getResponseCacheKeys$1(luvio, resourceParams, response) {
79445
79544
  const query = resourceParams.body.query;
@@ -79449,7 +79548,7 @@
79449
79548
  }
79450
79549
  function ingestSuccess$1(luvio, config, resourceParams, response, snapshotRefresh) {
79451
79550
  const { body } = response;
79452
- const key = keyBuilder$3();
79551
+ const key = keyBuilder$3(luvio, resourceParams);
79453
79552
  const { query, variables, operationName } = resourceParams.body;
79454
79553
  luvio.storeIngest(key, ingest(query, variables, operationName), body);
79455
79554
  // 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
@@ -79463,7 +79562,7 @@
79463
79562
  return snapshot;
79464
79563
  }
79465
79564
  function ingestError$1(luvio, config, params, error, snapshotRefresh) {
79466
- const key = keyBuilder$3();
79565
+ const key = keyBuilder$3(luvio, params);
79467
79566
  const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
79468
79567
  const storeMetadataParams = {
79469
79568
  ttl: TTL,
@@ -79546,8 +79645,8 @@
79546
79645
  return resourceParams;
79547
79646
  }
79548
79647
  function keyBuilder$2(luvio, config) {
79549
- createResourceParams$1(config);
79550
- return keyBuilder$3();
79648
+ const resourceParams = createResourceParams$1(config);
79649
+ return keyBuilder$3(luvio, resourceParams);
79551
79650
  }
79552
79651
  function typeCheckConfig$1(untrustedConfig) {
79553
79652
  const config = {};
@@ -79895,7 +79994,7 @@
79895
79994
  reader.enterPath(i);
79896
79995
  reader.enterPath(envelopeBodyPath);
79897
79996
  const childResource = childResources[i];
79898
- const childKey = keyBuilder$3();
79997
+ const childKey = keyBuilder$3(luvio, childResource);
79899
79998
  const childFragment = select$7(luvio, childResource.body); // MUST read from the ORIGINAL config not injected
79900
79999
  const isMissingDataBeforeChildRead = reader.getIsDataMissing();
79901
80000
  const childSnapshot = reader.read({
@@ -80006,7 +80105,7 @@
80006
80105
  ObjectAssign(keys, childKeys);
80007
80106
  }
80008
80107
  else if (childStatusCode === 404) {
80009
- const childKey = keyBuilder$3();
80108
+ const childKey = keyBuilder$3(luvio, childResourceParams);
80010
80109
  keys.set(childKey, {
80011
80110
  namespace: keyPrefix,
80012
80111
  representationName: RepresentationType,
@@ -80024,7 +80123,7 @@
80024
80123
  // There's an assumption here that the config and resource params aren't reordered.
80025
80124
  const childConfig = childConfigs[index];
80026
80125
  const childResourceParams = childResourceParamsArray[index];
80027
- const childKey = keyBuilder$3();
80126
+ const childKey = keyBuilder$3(luvio, childResourceParams);
80028
80127
  const result = childEnvelopes[index];
80029
80128
  const { statusCode: childStatusCode, result: childBody } = result;
80030
80129
  if (childStatusCode === 200 &&
@@ -80637,7 +80736,7 @@
80637
80736
  configuration: { ...configurationForGraphQLAdapters },
80638
80737
  instrument,
80639
80738
  });
80640
- // version: 1.142.1-1511d83f4
80739
+ // version: 1.143.0-7a79bacc1
80641
80740
 
80642
80741
  // On core the unstable adapters are re-exported with different names,
80643
80742
 
@@ -82821,6 +82920,12 @@
82821
82920
  fragment,
82822
82921
  luvio,
82823
82922
  };
82923
+ // NOTE: For evaluating environments, set a context property to let the
82924
+ // environment detect that eval will happen and to check varous gates
82925
+ // for eval behavior customizations.
82926
+ if (storeEval !== undefined) {
82927
+ context.gqlEval = true;
82928
+ }
82824
82929
  const snapshotOrPromiseFromCachePolicy = luvio.applyCachePolicy(requestContext || {}, context, buildCachedSnapshot, buildNetworkSnapshotCachePolicy);
82825
82930
  if (storeEval !== undefined) {
82826
82931
  const observers = requestContext && requestContext.eventObservers
@@ -82869,7 +82974,7 @@
82869
82974
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
82870
82975
  graphQLImperative = ldsAdapter;
82871
82976
  });
82872
- // version: 1.142.1-1511d83f4
82977
+ // version: 1.143.0-7a79bacc1
82873
82978
 
82874
82979
  var gqlApi = /*#__PURE__*/Object.freeze({
82875
82980
  __proto__: null,
@@ -83575,4 +83680,4 @@
83575
83680
  Object.defineProperty(exports, '__esModule', { value: true });
83576
83681
 
83577
83682
  }));
83578
- // version: 1.142.1-d514db71e
83683
+ // version: 1.143.0-a6d2a998d
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.142.1",
3
+ "version": "1.143.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",