@salesforce/lds-worker-api 1.142.1 → 1.144.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.144.0-ac4b15ad8
@@ -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.144.0-ac4b15ad8
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.144.0-ac4b15ad8
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.144.0-ac4b15ad8
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.144.0-32cfd690e
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) => {
@@ -48708,6 +48735,10 @@ var DraftQueueEventType;
48708
48735
  * Triggered after an action had been added to the queue
48709
48736
  */
48710
48737
  DraftQueueEventType["ActionAdded"] = "added";
48738
+ /**
48739
+ * Triggered when starting to upload and process an action
48740
+ */
48741
+ DraftQueueEventType["ActionUploading"] = "uploading";
48711
48742
  /**
48712
48743
  * Triggered once an action failed
48713
48744
  */
@@ -49259,6 +49290,10 @@ class DurableDraftQueue {
49259
49290
  if (this.state === DraftQueueState.Waiting) {
49260
49291
  this.state = DraftQueueState.Started;
49261
49292
  }
49293
+ this.notifyChangedListeners({
49294
+ type: DraftQueueEventType.ActionUploading,
49295
+ action: { ...action, status: DraftActionStatus.Uploading },
49296
+ });
49262
49297
  return this.handle(action);
49263
49298
  }
49264
49299
  async handleServerError(action, error) {
@@ -50005,6 +50040,7 @@ var DraftActionOperationType;
50005
50040
  var DraftQueueOperationType;
50006
50041
  (function (DraftQueueOperationType) {
50007
50042
  DraftQueueOperationType["ItemAdded"] = "added";
50043
+ DraftQueueOperationType["ItemUploading"] = "uploading";
50008
50044
  DraftQueueOperationType["ItemDeleted"] = "deleted";
50009
50045
  DraftQueueOperationType["ItemCompleted"] = "completed";
50010
50046
  DraftQueueOperationType["ItemFailed"] = "failed";
@@ -50055,29 +50091,29 @@ function toQueueState(queue) {
50055
50091
  class DraftManager {
50056
50092
  constructor(draftQueue) {
50057
50093
  this.listeners = [];
50058
- this.draftQueue = draftQueue;
50059
- draftQueue.registerOnChangedListener((event) => {
50060
- if (this.shouldEmitDraftEvent(event)) {
50061
- return this.callListeners(event);
50062
- }
50063
- return Promise.resolve();
50064
- });
50065
- }
50066
- shouldEmitDraftEvent(event) {
50067
- const { type } = event;
50068
- return [
50094
+ this.draftEventsShouldBeEmitted = [
50069
50095
  DraftQueueEventType.ActionAdded,
50096
+ DraftQueueEventType.ActionUploading,
50070
50097
  DraftQueueEventType.ActionCompleted,
50071
50098
  DraftQueueEventType.ActionDeleted,
50072
50099
  DraftQueueEventType.ActionFailed,
50073
50100
  DraftQueueEventType.ActionUpdated,
50074
50101
  DraftQueueEventType.QueueStateChanged,
50075
- ].includes(type);
50102
+ ];
50103
+ this.draftQueue = draftQueue;
50104
+ draftQueue.registerOnChangedListener((event) => {
50105
+ if (this.draftEventsShouldBeEmitted.includes(event.type)) {
50106
+ return this.callListeners(event);
50107
+ }
50108
+ return Promise.resolve();
50109
+ });
50076
50110
  }
50077
50111
  draftQueueEventTypeToOperationType(type) {
50078
50112
  switch (type) {
50079
50113
  case DraftQueueEventType.ActionAdded:
50080
50114
  return DraftQueueOperationType.ItemAdded;
50115
+ case DraftQueueEventType.ActionUploading:
50116
+ return DraftQueueOperationType.ItemUploading;
50081
50117
  case DraftQueueEventType.ActionCompleted:
50082
50118
  return DraftQueueOperationType.ItemCompleted;
50083
50119
  case DraftQueueEventType.ActionDeleted:
@@ -56566,6 +56602,7 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
56566
56602
  query: injectedAST,
56567
56603
  },
56568
56604
  luvio,
56605
+ gqlEval: true,
56569
56606
  }, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy));
56570
56607
  if (isErrorSnapshotThatShouldGetReturnedToCaller(nonEvaluatedSnapshot)) {
56571
56608
  return nonEvaluatedSnapshot;
@@ -58325,6 +58362,8 @@ function instrumentDraftQueue(queue) {
58325
58362
  break;
58326
58363
  case DraftQueueEventType.ActionAdded:
58327
58364
  break;
58365
+ case DraftQueueEventType.ActionUploading:
58366
+ break;
58328
58367
  case DraftQueueEventType.ActionCompleted:
58329
58368
  break;
58330
58369
  case DraftQueueEventType.ActionDeleted:
@@ -59024,8 +59063,17 @@ function formatDisplayValue(value, datatype) {
59024
59063
  }
59025
59064
  }
59026
59065
 
59027
- //TODO: [W-12734162] - rebuild non-evaluated snapshot when graph rebuild is triggered. The dependency work on luvio needs to be done.
59066
+ function isUnfulfilledSnapshot(cachedSnapshotResult) {
59067
+ if (cachedSnapshotResult === undefined) {
59068
+ return false;
59069
+ }
59070
+ if ('then' in cachedSnapshotResult) {
59071
+ return false;
59072
+ }
59073
+ return cachedSnapshotResult.state === 'Unfulfilled';
59074
+ }
59028
59075
  function makeEnvironmentGraphqlAware(environment) {
59076
+ //TODO: [W-12734162] - rebuild non-evaluated snapshot when graph rebuild is triggered. The dependency work on luvio needs to be done.
59029
59077
  const rebuildSnapshot = function (snapshot, onRebuild) {
59030
59078
  if (isStoreEvalSnapshot(snapshot)) {
59031
59079
  snapshot.rebuildWithStoreEval(snapshot).then((rebuilt) => {
@@ -59041,8 +59089,64 @@ function makeEnvironmentGraphqlAware(environment) {
59041
59089
  }
59042
59090
  return environment.rebuildSnapshot(snapshot, onRebuild);
59043
59091
  };
59092
+ const applyCachePolicy = function (luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot) {
59093
+ // Early exit for non-evaluating adapters
59094
+ let graphqlBuildSnapshotContext = buildSnapshotContext;
59095
+ if (graphqlBuildSnapshotContext.gqlEval !== true) {
59096
+ return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot);
59097
+ }
59098
+ var localBuildCachedSnapshot = buildCachedSnapshot;
59099
+ const hoistUnfulfilledToStale = (context, storeLookup, luvio) => {
59100
+ const upstream = buildCachedSnapshot(context, storeLookup, luvio);
59101
+ if (upstream === undefined)
59102
+ return upstream;
59103
+ if (isUnfulfilledSnapshot(upstream)) {
59104
+ return {
59105
+ ...upstream,
59106
+ data: upstream.data || {},
59107
+ state: 'Stale',
59108
+ };
59109
+ }
59110
+ else if ('then' in upstream) {
59111
+ return upstream.then((snapshot) => {
59112
+ if (snapshot === undefined)
59113
+ return snapshot;
59114
+ if (isUnfulfilledSnapshot(snapshot)) {
59115
+ return {
59116
+ ...snapshot,
59117
+ data: snapshot.data || {},
59118
+ state: 'Stale',
59119
+ };
59120
+ }
59121
+ return snapshot;
59122
+ });
59123
+ }
59124
+ return upstream;
59125
+ };
59126
+ const { cachePolicy } = adapterRequestContext;
59127
+ if (eagerEvalValidAt.isOpen({ fallback: false }) &&
59128
+ cachePolicy &&
59129
+ cachePolicy.type === 'valid-at' &&
59130
+ cachePolicy.timestamp === 0 &&
59131
+ cachePolicy.basePolicy &&
59132
+ cachePolicy.basePolicy.type === 'stale-while-revalidate') {
59133
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59134
+ }
59135
+ if (eagerEvalStaleWhileRevalidate.isOpen({ fallback: false }) &&
59136
+ cachePolicy &&
59137
+ cachePolicy.type === 'stale-while-revalidate' &&
59138
+ cachePolicy.staleDurationSeconds === Number.MAX_SAFE_INTEGER) {
59139
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59140
+ }
59141
+ if (eagerEvalDefaultCachePolicy.isOpen({ fallback: false }) && cachePolicy === undefined) {
59142
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59143
+ }
59144
+ return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, localBuildCachedSnapshot, buildNetworkSnapshot);
59145
+ };
59044
59146
  return create$6(environment, {
59045
59147
  rebuildSnapshot: { value: rebuildSnapshot },
59148
+ applyCachePolicy: { value: applyCachePolicy },
59149
+ setDefaultCachePolicy: { value: environment.setDefaultCachePolicy.bind(environment) },
59046
59150
  });
59047
59151
  }
59048
59152
 
@@ -59790,7 +59894,7 @@ register({
59790
59894
  id: '@salesforce/lds-network-adapter',
59791
59895
  instrument: instrument$1,
59792
59896
  });
59793
- // version: 1.142.1-d514db71e
59897
+ // version: 1.144.0-ac4b15ad8
59794
59898
 
59795
59899
  const { create: create$2, keys: keys$2 } = Object;
59796
59900
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -79431,7 +79535,13 @@ function select$7(luvio, config) {
79431
79535
  return select$8(luvio, query, variables, operationName);
79432
79536
  }
79433
79537
  function keyBuilder$3(luvio, params) {
79434
- return keyPrefix + '::' + 'GraphQLRepresentation';
79538
+ const { query, operationName, variables } = params.body;
79539
+ const operationToExecute = getOperationFromDocument(query, operationName);
79540
+ if (operationToExecute !== undefined) {
79541
+ const fragments = createFragmentMap(query);
79542
+ return keyBuilder$4(luvio, operationToExecute, variables || {}, fragments);
79543
+ }
79544
+ return `adapters_adapter$45$utils_keyPrefix::GraphQLRepresentation::InvalidOperation`;
79435
79545
  }
79436
79546
  function getResponseCacheKeys$1(luvio, resourceParams, response) {
79437
79547
  const query = resourceParams.body.query;
@@ -79441,7 +79551,7 @@ function getResponseCacheKeys$1(luvio, resourceParams, response) {
79441
79551
  }
79442
79552
  function ingestSuccess$1(luvio, config, resourceParams, response, snapshotRefresh) {
79443
79553
  const { body } = response;
79444
- const key = keyBuilder$3();
79554
+ const key = keyBuilder$3(luvio, resourceParams);
79445
79555
  const { query, variables, operationName } = resourceParams.body;
79446
79556
  luvio.storeIngest(key, ingest(query, variables, operationName), body);
79447
79557
  // 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 +79565,7 @@ function ingestSuccess$1(luvio, config, resourceParams, response, snapshotRefres
79455
79565
  return snapshot;
79456
79566
  }
79457
79567
  function ingestError$1(luvio, config, params, error, snapshotRefresh) {
79458
- const key = keyBuilder$3();
79568
+ const key = keyBuilder$3(luvio, params);
79459
79569
  const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
79460
79570
  const storeMetadataParams = {
79461
79571
  ttl: TTL,
@@ -79538,8 +79648,8 @@ function createResourceParams$1(config) {
79538
79648
  return resourceParams;
79539
79649
  }
79540
79650
  function keyBuilder$2(luvio, config) {
79541
- createResourceParams$1(config);
79542
- return keyBuilder$3();
79651
+ const resourceParams = createResourceParams$1(config);
79652
+ return keyBuilder$3(luvio, resourceParams);
79543
79653
  }
79544
79654
  function typeCheckConfig$1(untrustedConfig) {
79545
79655
  const config = {};
@@ -79887,7 +79997,7 @@ function selectChildResourceParams(luvio, childResources, resourceParams) {
79887
79997
  reader.enterPath(i);
79888
79998
  reader.enterPath(envelopeBodyPath);
79889
79999
  const childResource = childResources[i];
79890
- const childKey = keyBuilder$3();
80000
+ const childKey = keyBuilder$3(luvio, childResource);
79891
80001
  const childFragment = select$7(luvio, childResource.body); // MUST read from the ORIGINAL config not injected
79892
80002
  const isMissingDataBeforeChildRead = reader.getIsDataMissing();
79893
80003
  const childSnapshot = reader.read({
@@ -79998,7 +80108,7 @@ function getResponseCacheKeys$2(luvio, resourceParams, response) {
79998
80108
  ObjectAssign(keys, childKeys);
79999
80109
  }
80000
80110
  else if (childStatusCode === 404) {
80001
- const childKey = keyBuilder$3();
80111
+ const childKey = keyBuilder$3(luvio, childResourceParams);
80002
80112
  keys.set(childKey, {
80003
80113
  namespace: keyPrefix,
80004
80114
  representationName: RepresentationType,
@@ -80016,7 +80126,7 @@ function ingestSuccessChildResourceParams(luvio, childConfigs, childResourcePara
80016
80126
  // There's an assumption here that the config and resource params aren't reordered.
80017
80127
  const childConfig = childConfigs[index];
80018
80128
  const childResourceParams = childResourceParamsArray[index];
80019
- const childKey = keyBuilder$3();
80129
+ const childKey = keyBuilder$3(luvio, childResourceParams);
80020
80130
  const result = childEnvelopes[index];
80021
80131
  const { statusCode: childStatusCode, result: childBody } = result;
80022
80132
  if (childStatusCode === 200 &&
@@ -80629,7 +80739,7 @@ register({
80629
80739
  configuration: { ...configurationForGraphQLAdapters },
80630
80740
  instrument,
80631
80741
  });
80632
- // version: 1.142.1-1511d83f4
80742
+ // version: 1.144.0-32cfd690e
80633
80743
 
80634
80744
  // On core the unstable adapters are re-exported with different names,
80635
80745
 
@@ -82813,6 +82923,12 @@ const graphQLAdapterFactory = (luvio) => {
82813
82923
  fragment,
82814
82924
  luvio,
82815
82925
  };
82926
+ // NOTE: For evaluating environments, set a context property to let the
82927
+ // environment detect that eval will happen and to check varous gates
82928
+ // for eval behavior customizations.
82929
+ if (storeEval !== undefined) {
82930
+ context.gqlEval = true;
82931
+ }
82816
82932
  const snapshotOrPromiseFromCachePolicy = luvio.applyCachePolicy(requestContext || {}, context, buildCachedSnapshot, buildNetworkSnapshotCachePolicy);
82817
82933
  if (storeEval !== undefined) {
82818
82934
  const observers = requestContext && requestContext.eventObservers
@@ -82861,7 +82977,7 @@ withDefaultLuvio((luvio) => {
82861
82977
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
82862
82978
  graphQLImperative = ldsAdapter;
82863
82979
  });
82864
- // version: 1.142.1-1511d83f4
82980
+ // version: 1.144.0-32cfd690e
82865
82981
 
82866
82982
  var gqlApi = /*#__PURE__*/Object.freeze({
82867
82983
  __proto__: null,
@@ -83550,4 +83666,4 @@ const { luvio } = getRuntime();
83550
83666
  setDefaultLuvio({ luvio });
83551
83667
 
83552
83668
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
83553
- // version: 1.142.1-d514db71e
83669
+ // version: 1.144.0-ac4b15ad8
@@ -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.144.0-ac4b15ad8
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.144.0-ac4b15ad8
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.144.0-ac4b15ad8
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.144.0-32cfd690e
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) => {
@@ -48716,6 +48743,10 @@
48716
48743
  * Triggered after an action had been added to the queue
48717
48744
  */
48718
48745
  DraftQueueEventType["ActionAdded"] = "added";
48746
+ /**
48747
+ * Triggered when starting to upload and process an action
48748
+ */
48749
+ DraftQueueEventType["ActionUploading"] = "uploading";
48719
48750
  /**
48720
48751
  * Triggered once an action failed
48721
48752
  */
@@ -49267,6 +49298,10 @@
49267
49298
  if (this.state === DraftQueueState.Waiting) {
49268
49299
  this.state = DraftQueueState.Started;
49269
49300
  }
49301
+ this.notifyChangedListeners({
49302
+ type: DraftQueueEventType.ActionUploading,
49303
+ action: { ...action, status: DraftActionStatus.Uploading },
49304
+ });
49270
49305
  return this.handle(action);
49271
49306
  }
49272
49307
  async handleServerError(action, error) {
@@ -50013,6 +50048,7 @@
50013
50048
  var DraftQueueOperationType;
50014
50049
  (function (DraftQueueOperationType) {
50015
50050
  DraftQueueOperationType["ItemAdded"] = "added";
50051
+ DraftQueueOperationType["ItemUploading"] = "uploading";
50016
50052
  DraftQueueOperationType["ItemDeleted"] = "deleted";
50017
50053
  DraftQueueOperationType["ItemCompleted"] = "completed";
50018
50054
  DraftQueueOperationType["ItemFailed"] = "failed";
@@ -50063,29 +50099,29 @@
50063
50099
  class DraftManager {
50064
50100
  constructor(draftQueue) {
50065
50101
  this.listeners = [];
50066
- this.draftQueue = draftQueue;
50067
- draftQueue.registerOnChangedListener((event) => {
50068
- if (this.shouldEmitDraftEvent(event)) {
50069
- return this.callListeners(event);
50070
- }
50071
- return Promise.resolve();
50072
- });
50073
- }
50074
- shouldEmitDraftEvent(event) {
50075
- const { type } = event;
50076
- return [
50102
+ this.draftEventsShouldBeEmitted = [
50077
50103
  DraftQueueEventType.ActionAdded,
50104
+ DraftQueueEventType.ActionUploading,
50078
50105
  DraftQueueEventType.ActionCompleted,
50079
50106
  DraftQueueEventType.ActionDeleted,
50080
50107
  DraftQueueEventType.ActionFailed,
50081
50108
  DraftQueueEventType.ActionUpdated,
50082
50109
  DraftQueueEventType.QueueStateChanged,
50083
- ].includes(type);
50110
+ ];
50111
+ this.draftQueue = draftQueue;
50112
+ draftQueue.registerOnChangedListener((event) => {
50113
+ if (this.draftEventsShouldBeEmitted.includes(event.type)) {
50114
+ return this.callListeners(event);
50115
+ }
50116
+ return Promise.resolve();
50117
+ });
50084
50118
  }
50085
50119
  draftQueueEventTypeToOperationType(type) {
50086
50120
  switch (type) {
50087
50121
  case DraftQueueEventType.ActionAdded:
50088
50122
  return DraftQueueOperationType.ItemAdded;
50123
+ case DraftQueueEventType.ActionUploading:
50124
+ return DraftQueueOperationType.ItemUploading;
50089
50125
  case DraftQueueEventType.ActionCompleted:
50090
50126
  return DraftQueueOperationType.ItemCompleted;
50091
50127
  case DraftQueueEventType.ActionDeleted:
@@ -56574,6 +56610,7 @@
56574
56610
  query: injectedAST,
56575
56611
  },
56576
56612
  luvio,
56613
+ gqlEval: true,
56577
56614
  }, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy));
56578
56615
  if (isErrorSnapshotThatShouldGetReturnedToCaller(nonEvaluatedSnapshot)) {
56579
56616
  return nonEvaluatedSnapshot;
@@ -58333,6 +58370,8 @@
58333
58370
  break;
58334
58371
  case DraftQueueEventType.ActionAdded:
58335
58372
  break;
58373
+ case DraftQueueEventType.ActionUploading:
58374
+ break;
58336
58375
  case DraftQueueEventType.ActionCompleted:
58337
58376
  break;
58338
58377
  case DraftQueueEventType.ActionDeleted:
@@ -59032,8 +59071,17 @@
59032
59071
  }
59033
59072
  }
59034
59073
 
59035
- //TODO: [W-12734162] - rebuild non-evaluated snapshot when graph rebuild is triggered. The dependency work on luvio needs to be done.
59074
+ function isUnfulfilledSnapshot(cachedSnapshotResult) {
59075
+ if (cachedSnapshotResult === undefined) {
59076
+ return false;
59077
+ }
59078
+ if ('then' in cachedSnapshotResult) {
59079
+ return false;
59080
+ }
59081
+ return cachedSnapshotResult.state === 'Unfulfilled';
59082
+ }
59036
59083
  function makeEnvironmentGraphqlAware(environment) {
59084
+ //TODO: [W-12734162] - rebuild non-evaluated snapshot when graph rebuild is triggered. The dependency work on luvio needs to be done.
59037
59085
  const rebuildSnapshot = function (snapshot, onRebuild) {
59038
59086
  if (isStoreEvalSnapshot(snapshot)) {
59039
59087
  snapshot.rebuildWithStoreEval(snapshot).then((rebuilt) => {
@@ -59049,8 +59097,64 @@
59049
59097
  }
59050
59098
  return environment.rebuildSnapshot(snapshot, onRebuild);
59051
59099
  };
59100
+ const applyCachePolicy = function (luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot) {
59101
+ // Early exit for non-evaluating adapters
59102
+ let graphqlBuildSnapshotContext = buildSnapshotContext;
59103
+ if (graphqlBuildSnapshotContext.gqlEval !== true) {
59104
+ return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot);
59105
+ }
59106
+ var localBuildCachedSnapshot = buildCachedSnapshot;
59107
+ const hoistUnfulfilledToStale = (context, storeLookup, luvio) => {
59108
+ const upstream = buildCachedSnapshot(context, storeLookup, luvio);
59109
+ if (upstream === undefined)
59110
+ return upstream;
59111
+ if (isUnfulfilledSnapshot(upstream)) {
59112
+ return {
59113
+ ...upstream,
59114
+ data: upstream.data || {},
59115
+ state: 'Stale',
59116
+ };
59117
+ }
59118
+ else if ('then' in upstream) {
59119
+ return upstream.then((snapshot) => {
59120
+ if (snapshot === undefined)
59121
+ return snapshot;
59122
+ if (isUnfulfilledSnapshot(snapshot)) {
59123
+ return {
59124
+ ...snapshot,
59125
+ data: snapshot.data || {},
59126
+ state: 'Stale',
59127
+ };
59128
+ }
59129
+ return snapshot;
59130
+ });
59131
+ }
59132
+ return upstream;
59133
+ };
59134
+ const { cachePolicy } = adapterRequestContext;
59135
+ if (eagerEvalValidAt.isOpen({ fallback: false }) &&
59136
+ cachePolicy &&
59137
+ cachePolicy.type === 'valid-at' &&
59138
+ cachePolicy.timestamp === 0 &&
59139
+ cachePolicy.basePolicy &&
59140
+ cachePolicy.basePolicy.type === 'stale-while-revalidate') {
59141
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59142
+ }
59143
+ if (eagerEvalStaleWhileRevalidate.isOpen({ fallback: false }) &&
59144
+ cachePolicy &&
59145
+ cachePolicy.type === 'stale-while-revalidate' &&
59146
+ cachePolicy.staleDurationSeconds === Number.MAX_SAFE_INTEGER) {
59147
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59148
+ }
59149
+ if (eagerEvalDefaultCachePolicy.isOpen({ fallback: false }) && cachePolicy === undefined) {
59150
+ localBuildCachedSnapshot = hoistUnfulfilledToStale;
59151
+ }
59152
+ return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, localBuildCachedSnapshot, buildNetworkSnapshot);
59153
+ };
59052
59154
  return create$6(environment, {
59053
59155
  rebuildSnapshot: { value: rebuildSnapshot },
59156
+ applyCachePolicy: { value: applyCachePolicy },
59157
+ setDefaultCachePolicy: { value: environment.setDefaultCachePolicy.bind(environment) },
59054
59158
  });
59055
59159
  }
59056
59160
 
@@ -59798,7 +59902,7 @@
59798
59902
  id: '@salesforce/lds-network-adapter',
59799
59903
  instrument: instrument$1,
59800
59904
  });
59801
- // version: 1.142.1-d514db71e
59905
+ // version: 1.144.0-ac4b15ad8
59802
59906
 
59803
59907
  const { create: create$2, keys: keys$2 } = Object;
59804
59908
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -79439,7 +79543,13 @@
79439
79543
  return select$8(luvio, query, variables, operationName);
79440
79544
  }
79441
79545
  function keyBuilder$3(luvio, params) {
79442
- return keyPrefix + '::' + 'GraphQLRepresentation';
79546
+ const { query, operationName, variables } = params.body;
79547
+ const operationToExecute = getOperationFromDocument(query, operationName);
79548
+ if (operationToExecute !== undefined) {
79549
+ const fragments = createFragmentMap(query);
79550
+ return keyBuilder$4(luvio, operationToExecute, variables || {}, fragments);
79551
+ }
79552
+ return `adapters_adapter$45$utils_keyPrefix::GraphQLRepresentation::InvalidOperation`;
79443
79553
  }
79444
79554
  function getResponseCacheKeys$1(luvio, resourceParams, response) {
79445
79555
  const query = resourceParams.body.query;
@@ -79449,7 +79559,7 @@
79449
79559
  }
79450
79560
  function ingestSuccess$1(luvio, config, resourceParams, response, snapshotRefresh) {
79451
79561
  const { body } = response;
79452
- const key = keyBuilder$3();
79562
+ const key = keyBuilder$3(luvio, resourceParams);
79453
79563
  const { query, variables, operationName } = resourceParams.body;
79454
79564
  luvio.storeIngest(key, ingest(query, variables, operationName), body);
79455
79565
  // 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 +79573,7 @@
79463
79573
  return snapshot;
79464
79574
  }
79465
79575
  function ingestError$1(luvio, config, params, error, snapshotRefresh) {
79466
- const key = keyBuilder$3();
79576
+ const key = keyBuilder$3(luvio, params);
79467
79577
  const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
79468
79578
  const storeMetadataParams = {
79469
79579
  ttl: TTL,
@@ -79546,8 +79656,8 @@
79546
79656
  return resourceParams;
79547
79657
  }
79548
79658
  function keyBuilder$2(luvio, config) {
79549
- createResourceParams$1(config);
79550
- return keyBuilder$3();
79659
+ const resourceParams = createResourceParams$1(config);
79660
+ return keyBuilder$3(luvio, resourceParams);
79551
79661
  }
79552
79662
  function typeCheckConfig$1(untrustedConfig) {
79553
79663
  const config = {};
@@ -79895,7 +80005,7 @@
79895
80005
  reader.enterPath(i);
79896
80006
  reader.enterPath(envelopeBodyPath);
79897
80007
  const childResource = childResources[i];
79898
- const childKey = keyBuilder$3();
80008
+ const childKey = keyBuilder$3(luvio, childResource);
79899
80009
  const childFragment = select$7(luvio, childResource.body); // MUST read from the ORIGINAL config not injected
79900
80010
  const isMissingDataBeforeChildRead = reader.getIsDataMissing();
79901
80011
  const childSnapshot = reader.read({
@@ -80006,7 +80116,7 @@
80006
80116
  ObjectAssign(keys, childKeys);
80007
80117
  }
80008
80118
  else if (childStatusCode === 404) {
80009
- const childKey = keyBuilder$3();
80119
+ const childKey = keyBuilder$3(luvio, childResourceParams);
80010
80120
  keys.set(childKey, {
80011
80121
  namespace: keyPrefix,
80012
80122
  representationName: RepresentationType,
@@ -80024,7 +80134,7 @@
80024
80134
  // There's an assumption here that the config and resource params aren't reordered.
80025
80135
  const childConfig = childConfigs[index];
80026
80136
  const childResourceParams = childResourceParamsArray[index];
80027
- const childKey = keyBuilder$3();
80137
+ const childKey = keyBuilder$3(luvio, childResourceParams);
80028
80138
  const result = childEnvelopes[index];
80029
80139
  const { statusCode: childStatusCode, result: childBody } = result;
80030
80140
  if (childStatusCode === 200 &&
@@ -80637,7 +80747,7 @@
80637
80747
  configuration: { ...configurationForGraphQLAdapters },
80638
80748
  instrument,
80639
80749
  });
80640
- // version: 1.142.1-1511d83f4
80750
+ // version: 1.144.0-32cfd690e
80641
80751
 
80642
80752
  // On core the unstable adapters are re-exported with different names,
80643
80753
 
@@ -82821,6 +82931,12 @@
82821
82931
  fragment,
82822
82932
  luvio,
82823
82933
  };
82934
+ // NOTE: For evaluating environments, set a context property to let the
82935
+ // environment detect that eval will happen and to check varous gates
82936
+ // for eval behavior customizations.
82937
+ if (storeEval !== undefined) {
82938
+ context.gqlEval = true;
82939
+ }
82824
82940
  const snapshotOrPromiseFromCachePolicy = luvio.applyCachePolicy(requestContext || {}, context, buildCachedSnapshot, buildNetworkSnapshotCachePolicy);
82825
82941
  if (storeEval !== undefined) {
82826
82942
  const observers = requestContext && requestContext.eventObservers
@@ -82869,7 +82985,7 @@
82869
82985
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
82870
82986
  graphQLImperative = ldsAdapter;
82871
82987
  });
82872
- // version: 1.142.1-1511d83f4
82988
+ // version: 1.144.0-32cfd690e
82873
82989
 
82874
82990
  var gqlApi = /*#__PURE__*/Object.freeze({
82875
82991
  __proto__: null,
@@ -83575,4 +83691,4 @@
83575
83691
  Object.defineProperty(exports, '__esModule', { value: true });
83576
83692
 
83577
83693
  }));
83578
- // version: 1.142.1-d514db71e
83694
+ // version: 1.144.0-ac4b15ad8
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.144.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",